Skip to content

Commit dabb850

Browse files
alshamamsHannesWell
authored andcommitted
Auto-complete for build.properties: Image Icons
The auto-complete feature attaches most relevant image icons to the properties listing, so that the user is able to associate meaning of the property intuitively.
1 parent b1a4e1c commit dabb850

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ public class PDEPluginImages {
110110
public static final ImageDescriptor DESC_PROCESSING_INST_OBJ = create(PATH_OBJ, "processinginst.png"); //$NON-NLS-1$
111111
public static final ImageDescriptor DESC_XML_ELEMENT_OBJ = create(PATH_OBJ, "element.png"); //$NON-NLS-1$
112112
public static final ImageDescriptor DESC_XML_ELEMENT_REF_OBJ = create(PATH_OBJ, "elref_sc_obj.png"); //$NON-NLS-1$
113+
public static final ImageDescriptor DESC_FOLDER_OBJ = create(PATH_OBJ, "fldr_obj.png"); //$NON-NLS-1$
114+
public static final ImageDescriptor DESC_DEFAULT_OBJ = create(PATH_OBJ, "build_var_obj.png"); //$NON-NLS-1$
113115

114116
public static final ImageDescriptor DESC_SIMPLECS_OBJ = create(PATH_OBJ, "cheatsheet_simple_obj.png"); //$NON-NLS-1$
115117
public static final ImageDescriptor DESC_COMPCS_OBJ = create(PATH_OBJ, "cheatsheet_composite_obj.png"); //$NON-NLS-1$

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/contentassist/BuildPropertiesContentAssistProcessor.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@
1414

1515
import java.lang.reflect.Field;
1616
import java.util.ArrayList;
17+
import org.eclipse.jface.resource.ImageDescriptor;
1718
import org.eclipse.jface.text.*;
1819
import org.eclipse.jface.text.contentassist.ICompletionProposal;
1920
import org.eclipse.pde.internal.build.IBuildPropertiesConstants;
21+
import org.eclipse.pde.internal.ui.PDEPluginImages;
2022
import org.eclipse.pde.internal.ui.editor.PDESourcePage;
23+
import org.eclipse.swt.graphics.Image;
2124

2225
public class BuildPropertiesContentAssistProcessor extends TypePackageCompletionProcessor {
2326

2427
protected PDESourcePage fSourcePage;
28+
2529
public BuildPropertiesContentAssistProcessor(PDESourcePage sourcePage) {
2630
fSourcePage = sourcePage;
2731
}
@@ -44,7 +48,8 @@ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int
4448
continue;
4549
}
4650
if (element.regionMatches(true, 0, value, 0, value.length())) {
47-
TypeCompletionProposal proposal = new TypeCompletionProposal(element, null, element, lineStart,
51+
Image img = getImage(element);
52+
TypeCompletionProposal proposal = new TypeCompletionProposal(element, img, element, lineStart,
4853
value.length());
4954
completions.add(proposal);
5055
}
@@ -54,4 +59,24 @@ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int
5459
}
5560
return null;
5661
}
62+
63+
@SuppressWarnings("nls")
64+
public Image getImage(String element) {
65+
ImageDescriptor desc = switch (element)
66+
{
67+
case "src.includes", "src.excludes", "src.additionalRoots", "permissions", "root.", // linebreak
68+
"root", ".permissions.", ".link", "folder.", ".folder.", "link", // linebreak
69+
"source.", "sourceFileExtensions", "bin.includes", "bin.excludes", "javacCustomEncodings.", // linebreak
70+
"javacDefaultEncoding." -> PDEPluginImages.DESC_CATEGORY_OBJ;
71+
case ".jar", "jars.compile.order", "jars.extra.classpath" -> PDEPluginImages.DESC_JAR_LIB_OBJ;
72+
case "javacProjectSettings" -> PDEPluginImages.DESC_SETTINGS_OBJ;
73+
case "javacErrors." -> PDEPluginImages.DESC_ERROR_ST_OBJ;
74+
case "significantVersionDigits", "generatedVersionLength" -> PDEPluginImages.DESC_INFO_ST_OBJ;
75+
case "javacWarnings." -> PDEPluginImages.DESC_ALERT_OBJ;
76+
case "jre.compilation.profile" -> PDEPluginImages.DESC_TARGET_ENVIRONMENT;
77+
case "manifest." -> PDEPluginImages.DESC_FOLDER_OBJ;
78+
default -> PDEPluginImages.DESC_DEFAULT_OBJ;
79+
};
80+
return desc != null ? desc.createImage() : null;
81+
}
5782
}

0 commit comments

Comments
 (0)