List of usage examples for org.eclipse.jface.viewers ViewerCell setText
public void setText(String text)
From source file:eu.esdihumboldt.hale.ui.util.groovy.ast.viewer.ASTViewer.java
License:Open Source License
/** * Constructor.// w w w. j ava 2s. c o m * * @param parent the parent composite * @param textViewer a text viewer where the code for an AST node should be * selected on double click, or <code>null</code> */ public ASTViewer(Composite parent, ITextViewer textViewer) { this.textViewer = textViewer; page = new Composite(parent, SWT.NONE); TreeColumnLayout layout = new TreeColumnLayout(); page.setLayout(layout); treeViewer = new TreeViewer(page, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); // new DrillDownAdapter(viewer); treeViewer.setContentProvider(new ViewContentProvider()); treeViewer.setLabelProvider(new ViewLabelProvider()); treeViewer.getTree().setHeaderVisible(true); TreeViewerColumn mainColumn = new TreeViewerColumn(treeViewer, SWT.NONE); mainColumn.setLabelProvider(new StyledCellLabelProvider() { @Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString text = new StyledString(); text.append(element.getClass().getSimpleName()); cell.setText(text.getString()); cell.setStyleRanges(text.getStyleRanges()); super.update(cell); } }); mainColumn.getColumn().setText("Node"); layout.setColumnData(mainColumn.getColumn(), new ColumnPixelData(200)); TreeViewerColumn infoColumn = new TreeViewerColumn(treeViewer, SWT.NONE); infoColumn.setLabelProvider(new StyledCellLabelProvider() { @Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString text = new StyledString(); if (element instanceof Parameter) { // getText not implemented for Parameter Parameter param = (Parameter) element; text.append(param.getName()); } else if (element instanceof ExpressionStatement) { // getText not properly implemented for ExpressionStatement text.append(((ExpressionStatement) element).getExpression().getText()); } else if (element instanceof ASTNode) { ASTNode node = (ASTNode) element; text.append(node.getText()); } else if (element instanceof Variable) { Variable var = (Variable) element; text.append(var.getName()); } else { text.append(element.toString()); } cell.setText(text.getString()); cell.setStyleRanges(text.getStyleRanges()); super.update(cell); } }); infoColumn.getColumn().setText("Text"); layout.setColumnData(infoColumn.getColumn(), new ColumnPixelData(300)); TreeViewerColumn propertiesColumn = new TreeViewerColumn(treeViewer, SWT.NONE); propertiesColumn.setLabelProvider(new StyledCellLabelProvider() { @Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString text = new StyledString(); if (element instanceof Variable || element instanceof ASTNode || element instanceof VariableScope) { ASTNodeUtil.addProperties(element, text); } cell.setText(text.getString()); cell.setStyleRanges(text.getStyleRanges()); super.update(cell); } }); propertiesColumn.getColumn().setText("Properties"); layout.setColumnData(propertiesColumn.getColumn(), new ColumnPixelData(1600)); makeActions(); if (textViewer != null) { addDoubleClickAction(); } }
From source file:eu.esdihumboldt.hale.ui.views.data.internal.compare.DefinitionInstanceLabelProvider.java
License:Open Source License
/** * @see CellLabelProvider#update(ViewerCell) *//* w ww . java 2 s .c om*/ @Override public void update(ViewerCell cell) { TreePath treePath = cell.getViewerRow().getTreePath(); InstanceEntry entry = findInstanceEntry(treePath); Object value = entry.value; InstanceValidationReport report = null; // If childDef is null we are at the top element. if (entry.definition && entry.childDef == null) { report = InstanceValidator.validate(instance); } boolean hasValue = false; if (entry.definition && value instanceof Instance) { hasValue = ((Instance) value).getValue() != null; } else if (!entry.definition && treePath.getSegmentCount() == 1) { // metadata root if (instance.getMetaDataNames().isEmpty()) { hasValue = true; value = null; } } StyledString styledString; if (value == null) { styledString = new StyledString("no value", StyledString.DECORATIONS_STYLER); } else if (value instanceof Group && !hasValue) { styledString = new StyledString("+", StyledString.QUALIFIER_STYLER); } else { if (value instanceof Instance) { value = ((Instance) value).getValue(); } // TODO some kind of conversion? String stringValue = value.toString(); /* * Values that are very large, e.g. string representations of very * complex geometries lead to * StyledCellLabelProvider.updateTextLayout taking a very long time, * rendering the application unresponsive when the data views are * displayed. As such, we reduce the string to a maximum size. */ if (stringValue.length() > MAX_STRING_LENGTH) { stringValue = stringValue.substring(0, MAX_STRING_LENGTH) + "..."; } styledString = new StyledString(stringValue, null); } // mark cell if there are other values if (entry.valueCount > 1) { String decoration = " " + MessageFormat.format(MULTIPLE_VALUE_FORMAT, entry.choice + 1, entry.valueCount); styledString.append(decoration, StyledString.COUNTER_STYLER); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); if (report != null && !report.getWarnings().isEmpty()) cell.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK)); super.update(cell); }
From source file:eu.esdihumboldt.hale.ui.views.data.internal.explore.InstanceValueLabelProvider.java
License:Open Source License
/** * @see CellLabelProvider#update(ViewerCell) *//*from w w w . j a va2 s. co m*/ @Override public void update(ViewerCell cell) { TreePath treePath = cell.getViewerRow().getTreePath(); Object element = treePath.getLastSegment(); Definition<?> definition = null; Object value = ((Pair<?, ?>) element).getSecond(); if (((Pair<?, ?>) element).getFirst() instanceof Definition) definition = (Definition<?>) ((Pair<?, ?>) element).getFirst(); InstanceValidationReport report = null; if (definition instanceof ChildDefinition<?>) report = InstanceValidator.validate(value, (ChildDefinition<?>) ((Pair<?, ?>) element).getFirst()); else if (definition instanceof TypeDefinition) report = InstanceValidator.validate((Instance) value); boolean hasValue = false; if (value instanceof Instance) { hasValue = ((Instance) value).getValue() != null; } StyledString styledString; if (value == null) { styledString = new StyledString("no value", StyledString.DECORATIONS_STYLER); } else if (value instanceof Group && !hasValue) { styledString = new StyledString("+", StyledString.QUALIFIER_STYLER); } else { if (value instanceof Instance) { value = ((Instance) value).getValue(); } // TODO some kind of conversion? String stringValue = value.toString(); /* * Values that are very large, e.g. string representations of very * complex geometries lead to * StyledCellLabelProvider.updateTextLayout taking a very long time, * rendering the application unresponsive when the data views are * displayed. As such, we reduce the string to a maximum size. */ if (stringValue.length() > MAX_STRING_LENGTH) { stringValue = stringValue.substring(0, MAX_STRING_LENGTH) + "..."; } styledString = new StyledString(stringValue, null); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); if (report != null && !report.getWarnings().isEmpty()) cell.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK)); super.update(cell); }
From source file:eu.esdihumboldt.hale.ui.views.properties.function.abstractfunction.AbstractFunctionParameterSection.java
License:Open Source License
/** * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) *//*from w w w . j a v a2 s . co m*/ @Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); Composite compparent = getWidgetFactory().createComposite(parent); compparent.setLayout(new FormLayout()); Composite composite = getWidgetFactory().createComposite(compparent); TableColumnLayout columnLayout = new TableColumnLayout(); composite.setLayout(columnLayout); FormData data = new FormData(); data.width = 100; data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, -0); data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE); data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE); composite.setLayoutData(data); tableViewer = new TableViewer(composite, SWT.FULL_SELECTION); Table table = tableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); tableViewer.setContentProvider(ArrayContentProvider.getInstance()); TableViewerColumn nameviewercol = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn namecol = nameviewercol.getColumn(); columnLayout.setColumnData(namecol, new ColumnWeightData(20)); namecol.setText("Name"); nameviewercol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { cell.setText(((FunctionParameter) cell.getElement()).getName()); } }); TableViewerColumn lableviewercol = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn lablecol = lableviewercol.getColumn(); columnLayout.setColumnData(lablecol, new ColumnWeightData(20)); lablecol.setText("Label"); lableviewercol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { cell.setText(((FunctionParameter) cell.getElement()).getDisplayName()); } }); TableViewerColumn occurenceviewercol = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn occurencecol = occurenceviewercol.getColumn(); columnLayout.setColumnData(occurencecol, new ColumnWeightData(10)); occurencecol.setText("Occurence"); occurenceviewercol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { FunctionParameter cellparameter = ((FunctionParameter) cell.getElement()); cell.setText(String.valueOf(cellparameter.getMinOccurrence()) + ".." + (String.valueOf(cellparameter.getMaxOccurrence()))); } }); TableViewerColumn descriptionviewercol = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn descriptioncol = descriptionviewercol.getColumn(); columnLayout.setColumnData(descriptioncol, new ColumnWeightData(40)); descriptioncol.setText("Description"); descriptionviewercol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { cell.setText(String.valueOf(((FunctionParameter) cell.getElement()).getDescription())); } }); }
From source file:eu.esdihumboldt.hale.ui.views.properties.function.AbstractFunctionTableSection.java
License:Open Source License
/** * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) *///from ww w . j a v a 2s . c om @Override @SuppressWarnings("unchecked") public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); Composite compparent = getWidgetFactory().createComposite(parent); compparent.setLayout(new FormLayout()); Composite composite = getWidgetFactory().createComposite(compparent); TableColumnLayout columnLayout = new TableColumnLayout(); composite.setLayout(columnLayout); FormData data = new FormData(); data.width = 100; data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, -0); data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE); data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE); composite.setLayoutData(data); tableViewer = new TableViewer(composite, SWT.FULL_SELECTION); Table table = tableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); tableViewer.setContentProvider(ArrayContentProvider.getInstance()); TableViewerColumn nameviewercol = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn namecol = nameviewercol.getColumn(); columnLayout.setColumnData(namecol, new ColumnWeightData(20)); namecol.setText("Name"); nameviewercol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { cell.setText(((P) cell.getElement()).getName()); } }); TableViewerColumn lableviewercol = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn lablecol = lableviewercol.getColumn(); columnLayout.setColumnData(lablecol, new ColumnWeightData(20)); lablecol.setText("Lable"); lableviewercol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { cell.setText(((P) cell.getElement()).getDisplayName()); } }); TableViewerColumn occurenceviewercol = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn occurencecol = occurenceviewercol.getColumn(); columnLayout.setColumnData(occurencecol, new ColumnWeightData(20)); occurencecol.setText("Occurence"); occurenceviewercol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { P cellparameter = ((P) cell.getElement()); cell.setText(String.valueOf(cellparameter.getMinOccurrence()) + ".." + (String.valueOf(cellparameter.getMaxOccurrence()))); } }); TableViewerColumn descriptionviewercol = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn descriptioncol = descriptionviewercol.getColumn(); columnLayout.setColumnData(descriptioncol, new ColumnWeightData(20)); descriptioncol.setText("Description"); descriptionviewercol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { cell.setText(String.valueOf(((P) cell.getElement()).getDescription())); } }); }
From source file:eu.esdihumboldt.hale.ui.views.resources.internal.ResourcesLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); cell.setImage(getImage(element));//from ww w. j a v a2 s .c om StyledString text = new StyledString(getText(element)); if (element instanceof Resource) { Resource resource = (Resource) element; if (resource.getContentType() != null) { text.append(" (" + resource.getContentType().getName() + ")", StyledString.DECORATIONS_STYLER); } } cell.setText(text.getString()); cell.setStyleRanges(text.getStyleRanges()); super.update(cell); }
From source file:fr.esrf.icat.manager.core.icatserver.IcatServerLabelProvider.java
License:Apache License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString text = new StyledString(); if (element instanceof ICATServer) { ICATServer icatServer = (ICATServer) element; text.append(icatServer.getServerURL()); if (icatServer.isConnected()) { cell.setImage(null);/*from w w w . ja va 2 s . co m*/ text.append(" (" + icatServer.getVersion() + ") ", StyledString.QUALIFIER_STYLER); } switch (icatServer.getStatus()) { case CONNECTED: cell.setImage(connected_server_image); break; case FAILED: cell.setImage(failed_server_image); break; default: cell.setImage(unknown_server_image); break; } } else if (element instanceof ICATEntity) { ICATEntity entity = (ICATEntity) element; text.append(entity.getEntityName()); Long count = entitiesCount.get(entity); if (null != count) { text.append(" (" + count.toString() + ") ", StyledString.COUNTER_STYLER); } } else { text.append(element.toString()); } cell.setText(text.toString()); cell.setStyleRanges(text.getStyleRanges()); super.update(cell); }
From source file:fr.inria.atlanmod.neoemf.eclipse.ui.wizard.SelectBlueprintsGraphTypeWizardPage.java
License:Open Source License
private void createColumns() { String[] titles = { "Property", "Value" }; int[] bounds = { 100, 100 }; // First column is for the first name TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0); col.setLabelProvider(new CellLabelProvider() { @Override//from ww w .ja v a 2 s .c om public void update(ViewerCell cell) { cell.setText(((GraphProperty) cell.getElement()).getProperty()); } }); col.setEditingSupport(new PropertyEditingSupport(tableViewer)); // Second column is for the last name col = createTableViewerColumn(titles[1], bounds[1], 1); col.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { cell.setText(((GraphProperty) cell.getElement()).getValue()); } }); col.setEditingSupport(new ValueEditingSupport(tableViewer)); }
From source file:fr.inria.atlanmod.neoemf.eclipse.ui.wizards.SelectBlueprintsGraphTypeWizardPage.java
License:Open Source License
protected void createColumns() { String[] titles = { "Property", "Value" }; int[] bounds = { 100, 100 }; // First column is for the first name TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0); col.setLabelProvider(new CellLabelProvider() { @Override// w w w . jav a2 s. com public void update(ViewerCell cell) { cell.setText(((GraphProperty) cell.getElement()).getProperty()); } }); col.setEditingSupport(new PropertyEditingSupport(tableViewer)); // Second column is for the last name col = createTableViewerColumn(titles[1], bounds[1], 1); col.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { cell.setText(((GraphProperty) cell.getElement()).getValue()); } }); col.setEditingSupport(new ValueEditingSupport(tableViewer)); }
From source file:gda.simplescan.SimpleScanComposite.java
License:Open Source License
public void createDetectors(Composite comp) { Composite composite_2 = new Composite(comp, SWT.NONE); GridData gd_composite_2 = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1); gd_composite_2.heightHint = 216;/*from w w w . j a v a2 s . co m*/ composite_2.setLayoutData(gd_composite_2); GridLayout gl_composite_2 = new GridLayout(2, false); gl_composite_2.horizontalSpacing = 0; gl_composite_2.marginWidth = 0; gl_composite_2.marginHeight = 0; gl_composite_2.verticalSpacing = 0; composite_2.setLayout(gl_composite_2); Composite composite_3 = new Composite(composite_2, SWT.NONE); GridLayout gl_composite_3 = new GridLayout(1, false); gl_composite_3.horizontalSpacing = 2; gl_composite_3.verticalSpacing = 2; gl_composite_3.marginWidth = 2; gl_composite_3.marginHeight = 2; composite_3.setLayout(gl_composite_3); GridData gd_composite_3 = new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1); gd_composite_3.heightHint = 229; composite_3.setLayoutData(gd_composite_3); Composite composite_4 = new Composite(composite_2, SWT.NONE); composite_4.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); lblAcqTime_1 = new Label(composite_3, SWT.CENTER); GridData gd_lblAcqTime_1 = new GridData(SWT.CENTER, SWT.TOP, false, false, 1, 1); gd_lblAcqTime_1.widthHint = 71; lblAcqTime_1.setLayoutData(gd_lblAcqTime_1); lblAcqTime_1.setText("Acq Time"); acqTime = new ScaleBox(composite_3, SWT.NONE); ((GridData) acqTime.getControl().getLayoutData()).widthHint = 71; acqTime.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); createEmptyLabel(composite_3); scan = new Button(composite_3, SWT.NONE); scan.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true, 1, 1)); scan.setText("Scan"); scan.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { performScan(); scanStatusJob.schedule(); } @Override public void widgetDefaultSelected(SelectionEvent arg0) { } }); stop = new Button(composite_3, SWT.NONE); stop.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); stop.setText("Stop"); stop.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { performStop(); } @Override public void widgetDefaultSelected(SelectionEvent arg0) { } }); stop.setEnabled(false); GridLayout gl_composite_4 = new GridLayout(1, false); gl_composite_4.marginHeight = 0; gl_composite_4.verticalSpacing = 0; gl_composite_4.marginWidth = 0; gl_composite_4.horizontalSpacing = 0; composite_4.setLayout(gl_composite_4); viewer = new TableViewer(composite_4, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); TableViewerColumn enabledCol = new TableViewerColumn(viewer, SWT.NONE); TableColumn enabledColumn = enabledCol.getColumn(); enabledColumn.setText("Enabled"); enabledColumn.setWidth(65); enabledColumn.setResizable(true); enabledColumn.setMoveable(true); detEnabled = new EnabledEditingSupport(viewer, bean); enabledCol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { bean = detEnabled.getBean(); for (int i = 0; i < bean.getDetectors().size(); i++) { if (bean.getDetectors().get(i).getDetectorName().equals(cell.getItem().getData().toString())) { if (bean.getDetectors().get(i).isEnabled()) cell.setImage(CHECKED); else cell.setImage(UNCHECKED); } } } }); enabledCol.setEditingSupport(detEnabled); TableViewerColumn nameCol = new TableViewerColumn(viewer, SWT.NONE); TableColumn nameColumn = nameCol.getColumn(); nameColumn.setText("Detector Name"); nameColumn.setWidth(150); nameColumn.setResizable(true); nameColumn.setMoveable(true); nameCol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { cell.setText(cell.getItem().getData().toString()); } }); TableViewerColumn descriptionCol = new TableViewerColumn(viewer, SWT.NONE); TableColumn descriptionColumn = descriptionCol.getColumn(); descriptionColumn.setText("Detector Description"); descriptionColumn.setWidth(150); descriptionColumn.setResizable(true); descriptionColumn.setMoveable(true); des = new DescriptionEditingSupport(viewer, bean); descriptionCol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { bean = des.getBean(); for (int i = 0; i < bean.getDetectors().size(); i++) if (bean.getDetectors().get(i).getDetectorName().equals(cell.getItem().getData().toString())) cell.setText(bean.getDetectors().get(i).getDetectorDescription()); } }); descriptionCol.setEditingSupport(des); Table table = viewer.getTable(); table.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false, 1, 1)); table.setHeaderVisible(true); table.setLinesVisible(true); viewer.setContentProvider(new ArrayContentProvider()); GridData gridData = new GridData(); gridData.grabExcessHorizontalSpace = false; gridData.heightHint = 200; gridData.widthHint = 465; viewer.getControl().setLayoutData(gridData); }