List of usage examples for org.eclipse.jface.viewers StyledString COUNTER_STYLER
Styler COUNTER_STYLER
To view the source code for org.eclipse.jface.viewers StyledString COUNTER_STYLER.
Click Source Link
From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.contentassist.FXGraphProposalProvider.java
License:Open Source License
private void createEnumPropnameProposals(IFXEnumProperty prop, EObject model, ContentAssistContext context, EStructuralFeature typeReference, ICompletionProposalAcceptor acceptor) { if (prop.isStatic() && typeReference.equals(FXGraphPackage.Literals.ELEMENT__STATIC_PROPERTIES)) { StyledString s = new StyledString(); s.append("(static) ", StyledString.COUNTER_STYLER); s.append(prop.getFXClass().getSimpleName() + "." + prop.getName() + " : " + prop.getEnumTypeAsString(false)); s.append(" - " + prop.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); context = context.copy().setMatcher(new StaticPrefixMatcher(context.getMatcher())).toContext(); ICompletionProposal p = createCompletionProposal("static " + prop.getName() + " : ", s, IconKeys.getIcon(IconKeys.FIELD_KEY), getPropertiesProposalsProposals() - 10, context.getPrefix(), context); if (p instanceof ConfigurableCompletionProposal) { ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p; cp.setAdditionalProposalInfo(model); cp.setHover(new HoverImpl(prop.getJavaElement())); }// w w w .j a v a 2 s. com acceptor.accept(p); } else { StyledString s = new StyledString(prop.getName() + " : " + prop.getEnumTypeAsString(false)); s.append(" - " + prop.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); ICompletionProposal p = createCompletionProposal(prop.getName() + " : ", s, IconKeys.getIcon(IconKeys.FIELD_KEY), getPropertiesProposalsProposals(), context.getPrefix(), context); if (p instanceof ConfigurableCompletionProposal) { ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p; cp.setAdditionalProposalInfo(model); cp.setHover(new HoverImpl(prop.getJavaElement())); } acceptor.accept(p); } }
From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.contentassist.FXGraphProposalProvider.java
License:Open Source License
private void createObjectPropnameProposals(IFXObjectProperty prop, EObject model, ContentAssistContext context, EStructuralFeature typeReference, ICompletionProposalAcceptor acceptor) { if (prop.isStatic() && typeReference.equals(FXGraphPackage.Literals.ELEMENT__STATIC_PROPERTIES)) { StyledString s = new StyledString(); s.append("(static) ", StyledString.COUNTER_STYLER); s.append(prop.getFXClass().getSimpleName() + "." + prop.getName() + " : " + prop.getElementTypeAsString(false)); s.append(" - " + prop.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); context = context.copy().setMatcher(new StaticPrefixMatcher(context.getMatcher())).toContext(); ICompletionProposal p = createCompletionProposal("static " + prop.getName() + " : ", s, IconKeys.getIcon(IconKeys.FIELD_KEY), getPropertiesProposalsProposals() - 10, context.getPrefix(), context); if (p instanceof ConfigurableCompletionProposal) { ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p; cp.setAdditionalProposalInfo(model); cp.setHover(new HoverImpl(prop.getJavaElement())); }/*w w w. jav a 2s . c om*/ acceptor.accept(p); } else { StyledString s = new StyledString(prop.getName() + " : " + prop.getElementTypeAsString(false)); s.append(" - " + prop.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); ICompletionProposal p = createCompletionProposal(prop.getName() + " : ", s, IconKeys.getIcon(IconKeys.FIELD_KEY), getPropertiesProposalsProposals(), context.getPrefix(), context); if (p instanceof ConfigurableCompletionProposal) { ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p; cp.setAdditionalProposalInfo(model); cp.setHover(new HoverImpl(prop.getJavaElement())); } acceptor.accept(p); } }
From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.contentassist.FXGraphProposalProvider.java
License:Open Source License
private void createPrimitivePropnameProposals(IFXPrimitiveProperty prop, EObject model, ContentAssistContext context, EStructuralFeature typeReference, ICompletionProposalAcceptor acceptor) { String typeName;/* w w w . j a va2 s. co m*/ String proposalValue = prop.getName() + " : "; switch (prop.getType()) { case BOOLEAN: typeName = "boolean"; break; case BYTE: typeName = "byte"; break; case CHAR: typeName = "char"; break; case DOUBLE: typeName = "double"; break; case FLOAT: typeName = "float"; break; case INTEGER: typeName = "integer"; break; case LONG: typeName = "long"; break; case SHORT: typeName = "short"; break; default: typeName = "String"; proposalValue += "\"\""; break; } if (prop.isStatic() && typeReference.equals(FXGraphPackage.Literals.ELEMENT__STATIC_PROPERTIES)) { StyledString s = new StyledString(); s.append("(static) ", StyledString.COUNTER_STYLER); s.append(prop.getFXClass().getSimpleName() + "." + prop.getName() + " : " + typeName); s.append(" - " + prop.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); proposalValue = "static " + proposalValue; context = context.copy().setMatcher(new StaticPrefixMatcher(context.getMatcher())).toContext(); ICompletionProposal p = createCompletionProposal(proposalValue, s, IconKeys.getIcon(IconKeys.FIELD_KEY), getPropertiesProposalsProposals() - 10, context.getPrefix(), context); if (p instanceof ConfigurableCompletionProposal) { ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p; cp.setAdditionalProposalInfo(model); cp.setHover(new HoverImpl(prop.getJavaElement())); } acceptor.accept(p); } else { StyledString s = new StyledString(prop.getName() + " : " + typeName); s.append(" - " + prop.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); if (proposalValue.equals("id : \"\"")) { proposalValue = "^" + proposalValue; } context = context.copy().setMatcher(new EscapePrefixMatcher(context.getMatcher())).toContext(); ICompletionProposal p = createCompletionProposal(proposalValue, s, IconKeys.getIcon(IconKeys.FIELD_KEY), getPropertiesProposalsProposals(), context.getPrefix(), context); if (p instanceof ConfigurableCompletionProposal) { ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p; cp.setAdditionalProposalInfo(model); cp.setHover(new HoverImpl(prop.getJavaElement())); if (prop.getType() == Type.STRING) { cp.setCursorPosition(cp.getCursorPosition() - 1); } } acceptor.accept(p); } }
From source file:at.bestsolution.efxclipse.tooling.fxml.editors.FXMLCompletionProposalComputer.java
License:Open Source License
private void createEnumPropnameProposals(ContentAssistRequest contentAssistRequest, CompletionProposalInvocationContext context, IFXEnumProperty prop) { FXMLCompletionProposal cp;/* w ww . j a va 2 s. c om*/ if (prop.isStatic()) { StyledString s = new StyledString(); s.append("(static) ", StyledString.COUNTER_STYLER); s.append(prop.getFXClass().getSimpleName() + "." + prop.getName() + " : " + prop.getEnumTypeAsString(false)); s.append(" - " + prop.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); String proposalValue = prop.getFXClass().getSimpleName() + "." + prop.getName() + "=\"\""; cp = createAttributeProposal(contentAssistRequest, context, proposalValue, s, IconKeys.getIcon(IconKeys.FIELD_KEY), DEFAULT_PRIORITY - 10, STATIC_ATTRIBUTE_MATCHER); } else { StyledString s = new StyledString(prop.getName() + " : " + prop.getEnumTypeAsString(false)); s.append(" - " + prop.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); String propValue = prop.getName() + "=\"\""; cp = createAttributeProposal(contentAssistRequest, context, propValue, s, IconKeys.getIcon(IconKeys.FIELD_KEY), DEFAULT_PRIORITY, MATCHER); } if (cp != null) { cp.setAdditionalProposalInfo(EcoreFactory.eINSTANCE.createEClass()); cp.setHover(new HoverImpl(prop.getJavaElement())); contentAssistRequest.addProposal(cp); } }
From source file:at.bestsolution.efxclipse.tooling.fxml.editors.FXMLCompletionProposalComputer.java
License:Open Source License
private void createObjectPropnameProposals(ContentAssistRequest contentAssistRequest, CompletionProposalInvocationContext context, IFXObjectProperty prop) { String type = prop.getElementTypeAsString(true); // TODO Should we allow other elements because one can use $... to // reference elements if ("java.lang.Boolean".equals(type) || isIntegerType(type) || isDoubleType(type) || prop.hasValueOf()) { FXMLCompletionProposal cp;/*from w ww . j av a 2s .c o m*/ if (prop.isStatic()) { StyledString s = new StyledString(); s.append("(static) ", StyledString.COUNTER_STYLER); s.append(prop.getFXClass().getSimpleName() + "." + prop.getName() + " : " + prop.getElementTypeAsString(false)); s.append(" - " + prop.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); String proposalValue = prop.getFXClass().getSimpleName() + "." + prop.getName() + "=\"\""; cp = createAttributeProposal(contentAssistRequest, context, proposalValue, s, IconKeys.getIcon(IconKeys.FIELD_KEY), DEFAULT_PRIORITY - 10, STATIC_ATTRIBUTE_MATCHER); } else { StyledString s = new StyledString(prop.getName() + " : " + prop.getElementTypeAsString(false)); s.append(" - " + prop.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); String propValue = prop.getName() + "=\"\""; cp = createAttributeProposal(contentAssistRequest, context, propValue, s, IconKeys.getIcon(IconKeys.FIELD_KEY), DEFAULT_PRIORITY, MATCHER); } if (cp != null) { cp.setAdditionalProposalInfo(EcoreFactory.eINSTANCE.createEClass()); cp.setHover(new HoverImpl(prop.getJavaElement())); contentAssistRequest.addProposal(cp); } } }
From source file:at.bestsolution.efxclipse.tooling.fxml.editors.FXMLCompletionProposalComputer.java
License:Open Source License
private void createPrimitivePropnameProposal(ContentAssistRequest contentAssistRequest, CompletionProposalInvocationContext context, IFXPrimitiveProperty fxProperty) { String typeName;//from w w w .j av a 2 s. com switch (fxProperty.getType()) { case BOOLEAN: typeName = "boolean"; break; case BYTE: typeName = "byte"; break; case CHAR: typeName = "char"; break; case DOUBLE: typeName = "double"; break; case FLOAT: typeName = "float"; break; case INTEGER: typeName = "integer"; break; case LONG: typeName = "long"; break; case SHORT: typeName = "short"; break; default: typeName = "String"; break; } FXMLCompletionProposal cp; if (fxProperty.isStatic()) { StyledString s = new StyledString(); s.append("(static) ", StyledString.COUNTER_STYLER); s.append(fxProperty.getFXClass().getSimpleName() + "." + fxProperty.getName() + " : " + typeName); s.append(" - " + fxProperty.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); String proposalValue = fxProperty.getFXClass().getSimpleName() + "." + fxProperty.getName() + "=\"\""; cp = createAttributeProposal(contentAssistRequest, context, proposalValue, s, IconKeys.getIcon(IconKeys.FIELD_KEY), DEFAULT_PRIORITY - 10, STATIC_ATTRIBUTE_MATCHER); } else { StyledString s = new StyledString(fxProperty.getName() + " : " + typeName); s.append(" - " + fxProperty.getFXClass().getSimpleName(), StyledString.QUALIFIER_STYLER); String proposalValue = fxProperty.getName() + "=\"\""; cp = createAttributeProposal(contentAssistRequest, context, proposalValue, s, IconKeys.getIcon(IconKeys.FIELD_KEY), DEFAULT_PRIORITY, MATCHER); } if (cp != null) { cp.setAdditionalProposalInfo(EcoreFactory.eINSTANCE.createEClass()); cp.setHover(new HoverImpl(fxProperty.getJavaElement())); contentAssistRequest.addProposal(cp); } }
From source file:at.bestsolution.efxclipse.tooling.fxml.editors.FXMLCompletionProposalComputer.java
License:Open Source License
@Override protected void addTagNameProposals(ContentAssistRequest contentAssistRequest, int childPosition, CompletionProposalInvocationContext context) { Node parent = contentAssistRequest.getParent(); if (parent.getNodeType() == Node.ELEMENT_NODE) { if (parent.getNodeName().contains(".")) { String[] parts = parent.getNodeName().split("\\."); IType ownerType = Util.findType(parts[0], parent.getOwnerDocument()); if (ownerType != null) { IFXClass fxClass = FXPlugin.getClassmodel().findClass(ownerType.getJavaProject(), ownerType); if (fxClass != null) { IFXProperty p = fxClass.getStaticProperty(parts[1]); if (p != null) { if (p instanceof IFXObjectProperty) { IFXObjectProperty op = (IFXObjectProperty) p; createSubtypeProposals(contentAssistRequest, context, op.getElementType()); } else if (p instanceof IFXCollectionProperty) { IFXCollectionProperty cp = (IFXCollectionProperty) p; createSubtypeProposals(contentAssistRequest, context, cp.getElementType()); }//from www . ja v a2s . com } } } } else if (Character.isUpperCase(parent.getNodeName().charAt(0)) || "fx:root".equals(parent.getNodeName())) { if (!contentAssistRequest.getMatchString().isEmpty() && Character.isUpperCase(contentAssistRequest.getMatchString().charAt(0))) { // TODO This means we are static? // IJavaProject jproject = // findProject(contentAssistRequest); // try { // IType superType = // jproject.findType("javafx.scene.Parent"); // if( superType != null ) { // createSubtypeProposals(contentAssistRequest, context, // superType); // } // } catch (JavaModelException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } } else { if (parent.getParentNode() != null) { Node n = null; if ("fx:root".equals(parent.getNodeName())) { n = parent; } else if (Character.isUpperCase(parent.getParentNode().getNodeName().charAt(0)) || "fx:root".equals(parent.getParentNode().getNodeName())) { n = parent.getParentNode(); } else if (parent.getParentNode().getParentNode() != null) { if (Character .isUpperCase(parent.getParentNode().getParentNode().getNodeName().charAt(0)) || "fx:root".equals(parent.getParentNode().getParentNode().getNodeName())) { n = parent.getParentNode().getParentNode(); } } if (n != null) { IType type; if ("fx:root".equals(n.getNodeName())) { type = Util.findType(n.getAttributes().getNamedItem("type").getNodeValue(), parent.getOwnerDocument()); } else { type = Util.findType(n.getNodeName(), parent.getOwnerDocument()); } if (type != null) { IFXClass fxclass = FXPlugin.getClassmodel().findClass(type.getJavaProject(), type); if (fxclass != null) { for (IFXProperty p : fxclass.getAllStaticProperties().values()) { String proposalValue = fxclass.getSimpleName() + "." + p.getName() + ">" + "</" + fxclass.getSimpleName() + "." + p.getName() + ">"; String sType; if (p instanceof IFXPrimitiveProperty) { IFXPrimitiveProperty pp = (IFXPrimitiveProperty) p; sType = pp.getType() == Type.STRING ? "String" : pp.getType().jvmType(); } else if (p instanceof IFXObjectProperty) { IFXObjectProperty op = (IFXObjectProperty) p; sType = op.getElementTypeAsString(false); } else if (p instanceof IFXEnumProperty) { IFXEnumProperty ep = (IFXEnumProperty) p; sType = ep.getEnumTypeAsString(false); } else { sType = "<unknown>"; } FXMLCompletionProposal cp = createElementProposal(contentAssistRequest, context, proposalValue, new StyledString().append("(static) ", StyledString.COUNTER_STYLER) .append(p.getFXClass().getSimpleName() + "." + p.getName()) .append(" - " + sType, StyledString.QUALIFIER_STYLER), true, PRIORITY_LOWER_1, null, STATIC_ELEMENT_MATCHER); if (cp != null) { cp.setAdditionalProposalInfo(EcoreFactory.eINSTANCE.createEClass()); cp.setHover(new HoverImpl(p.getJavaElement())); contentAssistRequest.addProposal(cp); } } } } } } IType type; if ("fx:root".equals(parent.getNodeName())) { type = Util.findType(parent.getAttributes().getNamedItem("type").getNodeValue(), parent.getOwnerDocument()); } else { type = Util.findType(parent.getNodeName(), parent.getOwnerDocument()); } if (type != null) { IFXClass fxClass = FXPlugin.getClassmodel().findClass(type.getJavaProject(), type); if (fxClass != null) { for (IFXProperty property : fxClass.getAllProperties().values()) { createPropertyElementNameProposal(contentAssistRequest, context, property); } } } } IType type; if ("fx:root".equals(parent.getNodeName())) { type = Util.findType(parent.getAttributes().getNamedItem("type").getNodeValue(), parent.getOwnerDocument()); } else { type = Util.findType(parent.getNodeName(), parent.getOwnerDocument()); } if (type != null) { IFXClass fxClass = FXPlugin.getClassmodel().findClass(type.getJavaProject(), type); if (fxClass != null) { IFXProperty p = fxClass.getDefaultProperty(); if (p instanceof IFXObjectProperty) { createSubtypeProposals(contentAssistRequest, context, ((IFXObjectProperty) p).getElementType()); } else if (p instanceof IFXCollectionProperty) { createSubtypeProposals(contentAssistRequest, context, ((IFXCollectionProperty) p).getElementType()); } } } } else { createClassElementNameProposal(contentAssistRequest, context); } } }
From source file:bndtools.editor.components.ComponentSvcRefTableLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { ComponentSvcReference svcRef = (ComponentSvcReference) cell.getElement(); int columnIndex = cell.getColumnIndex(); StyledString styledString;//w w w .j ava 2 s.c o m switch (columnIndex) { case 0: styledString = new StyledString(svcRef.getName()); String bind = svcRef.getBind(); String unbind = svcRef.getUnbind(); if (bind != null) { StringBuilder buffer = new StringBuilder(); buffer.append(" {").append(bind).append('/'); if (unbind != null) { buffer.append(unbind); } buffer.append('}'); styledString.append(buffer.toString(), StyledString.DECORATIONS_STYLER); } cell.setImage(svcRef.isDynamic() ? dynamicImg : staticImg); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); break; case 1: styledString = new StyledString(svcRef.getServiceClass(), StyledString.QUALIFIER_STYLER); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); break; case 2: char[] cardinality = new char[] { svcRef.isOptional() ? '0' : '1', '.', '.', svcRef.isMultiple() ? 'n' : '1' }; styledString = new StyledString(new String(cardinality), StyledString.COUNTER_STYLER); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); break; case 3: String target = svcRef.getTargetFilter(); cell.setText(target != null ? target : ""); break; } }
From source file:bndtools.editor.pkgpatterns.HeaderClauseLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { @SuppressWarnings("unchecked") C clause = (C) cell.getElement();/* w w w . j a v a 2s .c om*/ cell.setImage(packageImg); StyledString styledString = new StyledString(clause.getName()); String version = clause.getAttribs().get(org.osgi.framework.Constants.VERSION_ATTRIBUTE); if (version != null) { styledString.append(": " + version, StyledString.COUNTER_STYLER); } decorate(styledString, clause); cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); }
From source file:bndtools.editor.pkgpatterns.PkgPatternsLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { HeaderClause clause = (HeaderClause) cell.getElement(); cell.setImage(packageImg);/* w w w . java 2 s . co m*/ StyledString styledString = new StyledString(clause.getName()); String resolution = clause.getAttribs().get(Constants.RESOLUTION_DIRECTIVE); if (org.osgi.framework.Constants.RESOLUTION_OPTIONAL.equals(resolution)) { styledString.append(" <optional>", UIConstants.ITALIC_QUALIFIER_STYLER); } String version = clause.getAttribs().get(org.osgi.framework.Constants.VERSION_ATTRIBUTE); if (version != null) { styledString.append(": " + version, StyledString.COUNTER_STYLER); } cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); }