List of usage examples for org.eclipse.jface.viewers LabelProvider getText
@Override
public String getText(Object element)
LabelProvider
implementation of this ILabelProvider
method returns the element's toString
string. From source file:com.amalto.workbench.editors.DataModelMainPage.java
License:Open Source License
private boolean compareSchemaContent(XSDSchemaContent xc1, XSDSchemaContent xc2) { if (xc1.getClass().equals(xc2.getClass())) { LabelProvider provider = getContentLabelProvider(xc1); if (null != provider && provider.getText(xc1).equals(provider.getText(xc2))) { return true; }/*from w w w .j a va 2 s . c o m*/ } return false; }
From source file:com.amalto.workbench.editors.DataModelMainPage.java
License:Open Source License
protected void doImportSchema(final Collection<XSDSchemaContent> addtional) { if (null == addtional || addtional.isEmpty()) { return;/*from www.ja va2s . c o m*/ } try { int flag = ConflictDialog.NONE; boolean dialogPopup = false; List<XSDSchemaContent> contents = xsdSchema.getContents(); List<XSDSchemaContent> exists = new ArrayList<XSDSchemaContent>(contents); for (XSDSchemaContent content : addtional) { XSDSchemaContent exist = getContainedSchemaContent(exists, content); if (null == exist) { Node importElement = xsdSchema.getDocument().importNode(content.getElement(), true); xsdSchema.getElement().appendChild(importElement); } else { if (!dialogPopup) { String type = null; if (exist instanceof XSDElementDeclaration) { type = Messages.DataModelMainPage_entity; } else if (exist instanceof XSDTypeDefinition) { type = Messages.DataModelMainPage_type; } else { continue; } LabelProvider provider = getContentLabelProvider(exist); String message = Messages.bind(Messages.conflict_messages, type, provider.getText(exist)); ConflictDialog dialog = new ConflictDialog(getSite().getShell(), message); if (dialog.open() == Dialog.OK) { flag = dialog.getStatus(); dialogPopup = dialog.applyAll; } else { popupImportDialog(); return; } } if (flag == ConflictDialog.OVERWRITE) { contents.remove(exist); Node importElement = xsdSchema.getDocument().importNode(content.getElement(), true); xsdSchema.getElement().appendChild(importElement); } } } // validateSchema(); markDirtyWithoutCommit(); setXsdSchema(xsdSchema); getSchemaRoleFilterFromSchemaTree().setDataModelFilter(dataModelFilter); // refresh types viewer.setInput(getSite()); typesViewer.setInput(getSite()); MessageDialog.openInformation(getSite().getShell(), Messages.ImportXSDSche, Messages.ImportingXSDSchemaCompleted); } catch (Exception ex) { log.error(ex.getMessage(), ex); String detail = "";//$NON-NLS-1$ if (ex.getMessage() != null && !ex.getMessage().equals("")) {//$NON-NLS-1$ detail += " , " + Messages.bind(Messages.Dueto, ex.getMessage()); //$NON-NLS-1$ } MessageDialog.openError(getSite().getShell(), Messages._Error, Messages.bind(Messages.ImportingXSDSchemaFailed, detail)); } }
From source file:gov.nasa.ensemble.core.detail.emf.binding.ComboBindingFactory.java
License:Open Source License
/** * Sort the choices by the labels from the label provider, and return the * labels in that order.// www .j a va 2s . c om * * @param choices * @param labeler * @return */ protected final String[] sort(List<Object> choices, LabelProvider labeler) { final Map<Object, String> objectLabels = new LinkedHashMap<Object, String>(); for (Object choice : choices) { String label = labeler.getText(choice); objectLabels.put(choice, label); } Collections.sort(choices, new Comparator<Object>() { @Override public int compare(Object o1, Object o2) { String l1 = objectLabels.get(o1); String l2 = objectLabels.get(o2); return String.CASE_INSENSITIVE_ORDER.compare(l1, l2); } }); String[] items = new String[choices.size()]; int i = 0; for (Object choice : choices) { items[i++] = objectLabels.get(choice); } return items; }
From source file:gov.nasa.ensemble.core.detail.emf.binding.ComboBindingFactory.java
License:Open Source License
/** * Return a list of the labels for each choice, using the label provider * //from ww w . j a v a 2 s . com * @param choices * @param labeler * @return */ protected final String[] label(List<Object> choices, LabelProvider labeler) { String[] items = new String[choices.size()]; int i = 0; for (Object choice : choices) { items[i++] = labeler.getText(choice); } return items; }
From source file:gov.va.isaac.mdht.otf.ui.editors.ComponentEditorInput.java
License:Apache License
@Override public String getToolTipText() { LabelProvider labelProvider = new ComponentLabelProvider(true); String fsn = labelProvider.getText(componentVerision); return fsn;/*from www .j a va 2 s . c o m*/ }
From source file:net.sf.eclipsefp.haskell.ui.internal.views.worksheet.EvalComposite.java
License:Open Source License
private void buildJSON(final String json) { Object root = null;/* w w w .ja va 2 s . com*/ try { root = new JSONObject(json); } catch (JSONException je) { try { root = new JSONArray(json); } catch (JSONException je2) { root = JSONObject.stringToValue(json); } } if (root == null || root instanceof String) { buildText(json); } else { TreeControlProvider tcp; List<List<String>> names = null; if (lResult == null || !(lResult instanceof TreeControlProvider)) { if (lResult != null) { lResult.getControl().dispose(); lResult = null; } TreeViewer tv = new TreeViewer(this, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); tcp = new TreeControlProvider(tv); tcp.viewer.setContentProvider(new JSONContentProvider()); tcp.viewer.setComparator(new JSONContentProvider.JSONComparator()); Listener l = new Listener() { /* (non-Javadoc) * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) */ @Override public void handleEvent(final Event arg0) { // let the tree expand, then layout getDisplay().asyncExec(new Runnable() { @Override public void run() { EvalComposite.this.layout(true); EvalComposite.this.page.layout(); } }); } }; tcp.viewer.getTree().addListener(SWT.Expand, l); tcp.viewer.getTree().addListener(SWT.Collapse, l); tcp.getControl().addMouseListener(dblListener); } else { tcp = (TreeControlProvider) lResult; // converts tree path to simple string paths TreePath[] exp = tcp.viewer.getExpandedTreePaths(); if (exp != null && exp.length > 0) { names = new ArrayList<>(exp.length); LabelProvider lp = new LabelProvider(); for (TreePath tp : exp) { if (tp.getSegmentCount() > 0) { List<String> names1 = new ArrayList<>(tp.getSegmentCount()); for (int a = 0; a < tp.getSegmentCount(); a++) { names1.add(lp.getText(tp.getSegment(a))); } names.add(names1); } } } } tcp.viewer.setInput(root); setCurrentControl(tcp); // expand the tree by reconverting name paths into tree paths if (names != null) { LabelProvider lp = new LabelProvider(); JSONContentProvider cp = (JSONContentProvider) tcp.viewer.getContentProvider(); List<TreePath> tps = new ArrayList<>(); for (Object r : cp.getElements(root)) { String rn = lp.getText(r); for (List<String> names1 : names) { if (names1.size() > 0 && names1.get(0).equals(rn)) { List<Object> path = new ArrayList<>(); path.add(r); addToPath(path, r, names1.subList(1, names1.size()), lp, cp); tps.add(new TreePath(path.toArray())); } } } if (tps.size() > 0) { tcp.viewer.setExpandedTreePaths(tps.toArray(new TreePath[tps.size()])); } } } }
From source file:net.sf.eclipsefp.haskell.ui.internal.views.worksheet.EvalComposite.java
License:Open Source License
/** * converts one level name path into a path of proper objects * @param path the path of objects as given by the content provider * @param parent the parent objects//from w ww .j a v a 2s . c om * @param names1 the current name path * @param lp the label provider * @param cp the content provider */ private void addToPath(final List<Object> path, final Object parent, final List<String> names1, final LabelProvider lp, final JSONContentProvider cp) { if (names1.size() > 0) { Object[] cs = cp.getChildren(parent); if (cs != null && cs.length > 0) { for (Object c : cs) { String cn = lp.getText(c); if (names1.get(0).equals(cn)) { path.add(c); addToPath(path, c, names1.subList(1, names1.size()), lp, cp); } } } } }
From source file:org.eclipse.buckminster.ui.dependency.visualizer.viewer.figures.BOMNodeTooltipFigure.java
License:Open Source License
private IFigure createHeadFigure() { LabelProvider provider = new DependencyLabelProvider(); Image image = provider.getImage(node); String text = provider.getText(node); Label label = new Label(text, image); return label; }
From source file:org.eclipse.n4js.ui.N4JSHierarchicalNameComputerHelper.java
License:Open Source License
/** * Calculate the hierarchically qualified name of an EObject. * * @param eob/*from w ww . j av a2 s . c o m*/ * the EObject to calculate logical name for * @param labelProvider * the label provider that knows how to display EObject instances * * @return the hierarchically */ public static String calculateLogicallyQualifiedDisplayName(EObject eob, LabelProvider labelProvider, boolean includeRoot) { // Calculate hierarchical logical name, e.g. C.m String text = labelProvider.getText(eob); EObject currContainer = eob.eContainer(); while (currContainer != null) { if (isShowable(currContainer)) { text = labelProvider.getText(currContainer) + "." + text; } currContainer = currContainer.eContainer(); if (currContainer != null && !includeRoot && currContainer instanceof Script) break; } return text; }
From source file:org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.ExtensionDetailsViewer.java
License:Open Source License
private void createTextOrComboControl(ExtensionItem item, Composite composite) { Control control = null;//from w w w .j a va 2s . co m String value = contentProvider.getValue(item); NodeEditorConfiguration editorConfiguration = item.getPropertyEditorConfiguration(); if (editorConfiguration != null && hasStyle(editorConfiguration, NodeEditorConfiguration.STYLE_COMBO)) { ListNodeEditorConfiguration configuration = (ListNodeEditorConfiguration) editorConfiguration; CCombo combo = widgetFactory.createCCombo(composite); combo.setText(value); Object[] values = configuration.getValues(item); LabelProvider labelProvider = configuration.getLabelProvider(); for (int j = 0; j < values.length; j++) { Object o = values[j]; String displayName = labelProvider != null ? labelProvider.getText(o) : o.toString(); combo.add(displayName); } combo.addSelectionListener(internalControlListener); control = combo; } if (control == null) { Text text = widgetFactory.createText(composite, value); text.addKeyListener(internalControlListener); control = text; } control.setData(ITEM_DATA, item); control.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); control.addFocusListener(internalControlListener); }