org.eclipse.jface.viewers.CellEditor Java Examples
The following examples show how to use
org.eclipse.jface.viewers.CellEditor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RealEditingSupport.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@Override public CellEditor getCellEditor(Object element) { TextCellEditor textCellEditor = new TextCellEditor((Composite) getViewer().getControl()); textCellEditor.setValidator(new ICellEditorValidator() { public String isValid(Object value) { String stringValue = (String) value; try { Double.parseDouble(stringValue); } catch (NumberFormatException e) { return "No valid real value!"; } return null; } }); return textCellEditor; }
Example #2
Source File: PushDownWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void setupCellEditors(final Table table) { final ComboBoxCellEditor comboBoxCellEditor= new ComboBoxCellEditor(); comboBoxCellEditor.setStyle(SWT.READ_ONLY); fTableViewer.setCellEditors(new CellEditor[] { null, comboBoxCellEditor}); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { if (comboBoxCellEditor.getControl() == null & !table.isDisposed()) comboBoxCellEditor.create(table); Assert.isTrue(event.getSelection() instanceof IStructuredSelection); final IStructuredSelection ss= (IStructuredSelection) event.getSelection(); if (ss.size() != 1) return; final MemberActionInfo mac= (MemberActionInfo) ss.getFirstElement(); comboBoxCellEditor.setItems(MemberActionInfoLabelProvider.getAvailableActionLabels(mac)); comboBoxCellEditor.setValue(new Integer(mac.getAction())); } }); final ICellModifier cellModifier= new PushDownCellModifier(); fTableViewer.setCellModifier(cellModifier); fTableViewer.setColumnProperties(new String[] { MEMBER_PROPERTY, ACTION_PROPERTY}); }
Example #3
Source File: AdvancePropertyDescriptor.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * @param data */ private CellEditor createCellEditor( Object data ) { CellEditor editor = null; if ( data instanceof GroupPropertyHandleWrapper && ( (GroupPropertyHandle) ( ( (GroupPropertyHandleWrapper) data ) ).getModel( ) ).isVisible( ) ) { editor = PropertyEditorFactory.getInstance( ) .createPropertyEditor( tableTree, ( (GroupPropertyHandleWrapper) data ).getModel( ) ); if ( editor instanceof ExpressionCellEditor ) { if ( DEUtil.getInputSize( input ) > 0 ) { ( (ExpressionCellEditor) editor ).setExpressionInput( new ExpressionProvider( (DesignElementHandle) DEUtil.getInputFirstElement( input ) ), DEUtil.getInputFirstElement( input ) ); } } } return editor; }
Example #4
Source File: GrandTotalProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
public CellEditor[] getCellEditors( ) { if ( cellEditor != null ) { return cellEditor; } ComboBoxCellEditor comboCell = new ComboBoxCellEditor( viewer.getTable( ), new String[0], SWT.READ_ONLY ); ComboBoxCellEditor positionCell = new ComboBoxCellEditor( viewer.getTable( ), positionItems, SWT.READ_ONLY ); cellEditor = new CellEditor[]{ null, null, comboCell, positionCell }; return cellEditor; }
Example #5
Source File: PullUpMemberPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void setupCellEditors(final Table table) { final ComboBoxCellEditor editor= new ComboBoxCellEditor(); editor.setStyle(SWT.READ_ONLY); fTableViewer.setCellEditors(new CellEditor[] { null, editor}); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { if (editor.getControl() == null & !table.isDisposed()) editor.create(table); final ISelection sel= event.getSelection(); if (!(sel instanceof IStructuredSelection)) return; final IStructuredSelection structured= (IStructuredSelection) sel; if (structured.size() != 1) return; final MemberActionInfo info= (MemberActionInfo) structured.getFirstElement(); editor.setItems(info.getAllowedLabels()); editor.setValue(new Integer(info.getAction())); } }); final ICellModifier cellModifier= new MemberActionCellModifier(); fTableViewer.setCellModifier(cellModifier); fTableViewer.setColumnProperties(new String[] { MEMBER_PROPERTY, ACTION_PROPERTY}); }
Example #6
Source File: ProcessEditPartFactory.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ public void relocate(CellEditor celleditor) { Text text = (Text) celleditor.getControl(); Rectangle rect = getWrapLabel().getTextBounds().getCopy(); getWrapLabel().translateToAbsolute(rect); if (!text.getFont().isDisposed()) { if (getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0) { //Adjust editor location rect.x = rect.x - 5; if (rect.width < 75) { rect.width = 75; } rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT))); } else { int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth(); rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0)); } } if (!rect.equals(new Rectangle(text.getBounds()))) { text.setBounds(rect.x, rect.y, rect.width, rect.height); } }
Example #7
Source File: RadioGroupItemEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected CellEditor getCellEditor(Object element) { TextCellEditor cellEditor = new TextCellEditor((Composite) getViewer().getControl()); cellEditor.setValidator(new ICellEditorValidator() { @Override public String isValid(Object value) { for(String item : radioGroup.getChoices()){ if(item.equals(value)){ return "Item already exists" ; } } return null; } }); return cellEditor ; }
Example #8
Source File: ModuleTableViewer.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 6 votes |
private void createTableViewer() { tableViewer = new TableViewer(table); tableViewer.setUseHashlookup(true); tableViewer.setColumnProperties(columnNames); // Create the cell editors CellEditor[] editors = new CellEditor[columnNames.length]; // Column 1 : nothing editors[0] = null; // Columns 2,3,4 : checkboxes editors[1] = new CheckboxCellEditor(table); editors[2] = new CheckboxCellEditor(table); editors[3] = new CheckboxCellEditor(table); // Assign the cell editors to the viewer tableViewer.setCellEditors(editors); // Set the cell modifier for the viewer tableViewer.setCellModifier(new ExtensionCellModifier(this)); // Set the default sorter for the viewer //tableViewer.setSorter(new ExtensionSorter(ExtensionSorter.NAME)); }
Example #9
Source File: MultiPageCSVEditor.java From gama with GNU General Public License v3.0 | 6 votes |
/** * */ void defineCellEditing() { final String[] columnProperties = new String[model.getColumnCount()]; final CellEditor[] cellEditors = new CellEditor[model.getColumnCount()]; for (int i = 0; i < model.getColumnCount(); i++) { columnProperties[i] = Integer.toString(i); cellEditors[i] = new TextCellEditor(tableViewer.getTable()); } tableViewer.setColumnProperties(columnProperties); // XXX can be replaced by tableViewer.setEditingSupport() tableViewer.setCellEditors(cellEditors); tableViewer.setCellModifier(new CSVEditorCellModifier()); }
Example #10
Source File: JFaceViewerIntegrationExample.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected CellEditor getCellEditor(Object element) { RichTextEditorConfiguration config = new RichTextEditorConfiguration(); config.setToolbarCollapsible(true); config.setToolbarInitialExpanded(false); final RichTextCellEditor editor = new RichTextCellEditor((Composite) getViewer().getControl(), config, SWT.RESIZE | SWT.MIN); editor.getRichTextEditor().addToolbarButton(new ToolbarButton("addContentButton", "addContentCommand", "Add content", "other", JFaceViewerIntegrationExample.class.getResource("images/debug_exc.gif")) { @Override public Object execute() { editor.getRichTextEditor().insertHTML("<em>Dynamically added content</em>"); return null; } }); return editor; }
Example #11
Source File: DataTypeNameEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected CellEditor getCellEditor(final Object element) { TextCellEditor editor = new TextCellEditor((Composite) getViewer().getControl(), SWT.NONE) ; editor.setValidator(new ICellEditorValidator() { @Override public String isValid(Object input) { if(input == null || input.toString().isEmpty()){ return Messages.dataNameIsEmpty ; } for(DataType type : existingTypes){ if(type.getName().equals(input.toString())){ return Messages.dataAlreadyExist ; } } return null; } }) ; return editor; }
Example #12
Source File: LabelEditManager.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates the cell editor on the given composite. The cell editor is * created by instantiating the cell editor type passed into this * DirectEditManager's constuctor. * * @param composite * the composite to create the cell editor on * @return the newly created cell editor */ protected CellEditor createCellEditorOn( Composite composite ) { int style = this.applyBidiStyle( SWT.MULTI | SWT.WRAP ); // bidi_hcg LabelCellEditor editor = new LabelCellEditor( composite, style ); //new LabelCellEditor( composite, SWT.MULTI | SWT.WRAP ); final Control c = editor.getControl( ); c.addMouseTrackListener( new MouseTrackAdapter( ) { public void mouseEnter( MouseEvent e ) { c.setCursor( SharedCursors.IBEAM ); } } ); return editor; }
Example #13
Source File: MenuStylesDialog.java From birt with Eclipse Public License 1.0 | 6 votes |
private CellEditor[] getCellEditors( Table table ) { CellEditor[] editors = new CellEditor[COLUMNS.length]; editors[0] = new TextCellEditor( table ) { @Override protected void keyReleaseOccured( KeyEvent keyEvent ) { super.keyReleaseOccured( keyEvent ); if ( keyEvent.character == '\r' ) { fTableViewer.editElement( fTableViewer.getElementAt( fTable.getSelectionIndex( ) ), 1 ); } } }; editors[1] = new TextCellEditor( table ); return editors; }
Example #14
Source File: NoteEditorLocator.java From ermaster-b with Apache License 2.0 | 5 votes |
public void relocate(CellEditor cellEditor) { Text text = (Text) cellEditor.getControl(); Rectangle rect = this.figure.getBounds().getCopy(); this.figure.translateToAbsolute(rect); text.setBounds(rect.x + NoteFigure.RETURN_WIDTH, rect.y + NoteFigure.RETURN_WIDTH, rect.width - NoteFigure.RETURN_WIDTH * 2, rect.height - NoteFigure.RETURN_WIDTH * 2); }
Example #15
Source File: SortingHandleProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
public CellEditor[] getEditors( Table table ) { if ( editors == null ) { editors = new CellEditor[columnKeys.length]; editors[0] = new TextCellEditor( table ); editors[1] = new TextCellEditor( table ); } return editors; }
Example #16
Source File: FilterHandleProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
public CellEditor[] getEditors( final Table table ) { if ( editors == null ) { editors = new CellEditor[columnKeys.length]; editors[0] = new TextCellEditor( table ); editors[1] = new TextCellEditor( table ); editors[2] = new TextCellEditor( table ); editors[3] = new TextCellEditor( table ); } return editors; }
Example #17
Source File: AbstractConversionTable.java From sarl with Apache License 2.0 | 5 votes |
/** Create a cell editor that enables to select a class. * * @return the cell editor. */ protected CellEditor createClassCellEditor() { return new DialogCellEditor(getControl()) { @Override protected Object openDialogBox(Control cellEditorWindow) { final OpenTypeSelectionDialog dialog = new OpenTypeSelectionDialog( getControl().getShell(), false, PlatformUI.getWorkbench().getProgressService(), null, IJavaSearchConstants.TYPE); dialog.setTitle(JavaUIMessages.OpenTypeAction_dialogTitle); dialog.setMessage(JavaUIMessages.OpenTypeAction_dialogMessage); final int result = dialog.open(); if (result != IDialogConstants.OK_ID) { return null; } final Object[] types = dialog.getResult(); if (types == null || types.length != 1 || !(types[0] instanceof IType)) { return null; } final IType type = (IType) types[0]; final String name = type.getFullyQualifiedName(); return Strings.emptyIfNull(name); } }; }
Example #18
Source File: DefaultEditingSupport.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public DefaultEditingSupport ( final ColumnViewer viewer, final DataBindingContext dbc, final IValueProperty cellEditorProperty, final CellEditor cellEditor, final IValueProperty elementProperty ) { super ( viewer, dbc ); this.cellEditorProperty = cellEditorProperty; this.cellEditor = cellEditor; this.elementProperty = elementProperty; this.dbc = dbc; }
Example #19
Source File: GridViewerSnippet7.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected CellEditor getCellEditor(Object element) { IMediator m = (IMediator) element; if (m.getType(colIndex) == int.class) { return integerEditor; } else if (m.getType(colIndex) == Date.class) { return dateEditor; } return null; }
Example #20
Source File: ExtendedPropertyDescriptor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public CellEditor createPropertyEditor ( final Composite composite ) { if ( this.itemPropertyDescriptor instanceof IItemPropertyDescriptor2 ) { final CellEditor editor = ( (IItemPropertyDescriptor2)this.itemPropertyDescriptor ).createPropertyEditor ( composite, this.object ); if ( editor != null ) { return editor; } } return super.createPropertyEditor ( composite ); }
Example #21
Source File: ContractInputTypeEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected CellEditor getCellEditor(Object element) { final ComboBoxViewerCellEditor comboBoxViewerCellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); comboBoxViewerCellEditor.setContentProvider(ArrayContentProvider.getInstance()); comboBoxViewerCellEditor.setInput(SELECTABLE_TYPES); return comboBoxViewerCellEditor; }
Example #22
Source File: LabResultEditingSupport.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override protected CellEditor getCellEditor(Object element){ if (element instanceof LaborItemResults) { LabItem labItem = ((LaborItemResults) element).getLabItem(); if (labItem.getTyp() == LabItemTyp.DOCUMENT) { return null; } else { return textCellEditor; } } return null; }
Example #23
Source File: RowPageBreakProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
public CellEditor[] getEditors( Table table ) { // TODO Auto-generated method stub if ( editors == null ) { editors = new CellEditor[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { editors[i] = new TextCellEditor( ); } } return editors; }
Example #24
Source File: XtextDirectEditManager.java From statecharts with Eclipse Public License 1.0 | 5 votes |
/** * This method is used to set the cell editors text * * @param toEdit * String to be set in the cell editor */ public void setEditText(String toEdit) { // Get the cell editor CellEditor cellEditor = getCellEditor(); // IF the cell editor doesn't exist yet... if (cellEditor == null) { // Do nothing return; } // Get the Text Compartment Edit Part IXtextAwareEditPart textEP = (IXtextAwareEditPart) getEditPart(); // Get the Text control StyledText textControl = (StyledText) cellEditor.getControl(); // Set the Figures text textEP.setLabelText(toEdit); // See RATLC00522324 if (cellEditor instanceof TextCellEditorEx) { ((TextCellEditorEx) cellEditor).setValueAndProcessEditOccured(toEdit); } else { cellEditor.setValue(toEdit); } // Set the controls text and position the caret at the end of the text textControl.setSelection(toEdit.length()); }
Example #25
Source File: CustomUserInformationDefinitionNameEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected CellEditor getCellEditor(final Object element) { final TextCellEditor textCellEditor = new TextCellEditor((Composite) getViewer().getControl()); final Text textControl = (Text) textCellEditor.getControl(); textControl.setTextLimit(CUSTOM_USER_DEFINITION_NAME_SIZE); return textCellEditor; }
Example #26
Source File: RemapTable.java From depan with Apache License 2.0 | 5 votes |
private Control setupControl(Composite parent) { Composite topLevel = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); topLevel.setLayout(layout); tableViewer = new TableViewer(topLevel, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); Table tableData = tableViewer.getTable(); tableData.setHeaderVisible(true); EditColTableDef.setupTable(TABLE_DEF, tableData); CellEditor[] cellEditors = new CellEditor[4]; cellEditors[0] = null; cellEditors[1] = null; cellEditors[2] = new TextCellEditor(tableData); cellEditors[3] = new TextCellEditor(tableData); tableViewer.setCellEditors(cellEditors); tableViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); RemapTableHelper cellHelper = new RemapTableHelper(); tableViewer.setLabelProvider(cellHelper); tableData.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); remapContent = new TableContentProvider<MigrationRule<?>>(); remapContent.initViewer(tableViewer); return topLevel; }
Example #27
Source File: PyEditorHoverConfigurationBlock.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override protected CellEditor getCellEditor(Object element) { if (this.column == PRIORITY_PROP) { this.editor = new TextCellEditor(this.viewer.getTable()); editor.setValidator(new ICellEditorValidator() { @Override public String isValid(Object value) { boolean valid = true; if (!"".equals(value)) { try { int val = Integer.parseInt((String) value); if (val <= 0) { valid = false; } } catch (NumberFormatException | ClassCastException e) { valid = false; } } editor.getControl() .setBackground(valid ? null : Display.getDefault().getSystemColor(SWT.COLOR_RED)); return (valid ? null : "positive integer required"); } }); ((Text) ((TextCellEditor) editor).getControl()).selectAll(); } else if (this.column == PREEMPT_PROP) { this.editor = new CheckboxCellEditor(viewer.getTable()); } return this.editor; }
Example #28
Source File: RelationDisplayTableControl.java From depan with Apache License 2.0 | 5 votes |
public RelationDisplayTableControl(Composite parent) { super(parent, SWT.NONE); setLayout(Widgets.buildContainerLayout(1)); propViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); // Layout embedded table Table propTable = propViewer.getTable(); propTable.setLayoutData(Widgets.buildGrabFillData()); // initialize the table propTable.setHeaderVisible(true); propTable.setToolTipText("Relations Display Properties"); EditColTableDef.setupTable(TABLE_DEF, propTable); // Configure cell editing CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_NAME] = null; cellEditors[INDEX_SOURCE] = null; cellEditors[INDEX_COLOR] = new ColorCellEditor(propTable); cellEditors[INDEX_STYLE] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.LineStyle.values(), true)); cellEditors[INDEX_ARROWHEAD] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.ArrowheadStyle.values(), true)); propViewer.setCellEditors(cellEditors); propViewer.setLabelProvider(new EdgeDisplayLabelProvider()); propViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); propViewer.setCellModifier(new EdgeDisplayCellModifier()); // TODO: Add column sorters, filters? configSorters(propTable); // Configure content last: use updateTable() to render relations propViewer.setContentProvider(ArrayContentProvider.getInstance()); }
Example #29
Source File: EdgeDisplayTableControl.java From depan with Apache License 2.0 | 5 votes |
public EdgeDisplayTableControl(Composite parent) { super(parent, SWT.NONE); setLayout(Widgets.buildContainerLayout(1)); propViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); // Layout embedded table Table propTable = propViewer.getTable(); propTable.setLayoutData(Widgets.buildGrabFillData()); // initialize the table propTable.setHeaderVisible(true); propTable.setToolTipText("Edge Display Properties"); EditColTableDef.setupTable(TABLE_DEF, propTable); // Configure cell editing CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_NAME] = null; cellEditors[INDEX_HEAD] = null; cellEditors[INDEX_TAIL] = null; cellEditors[INDEX_COLOR] = new ColorCellEditor(propTable); cellEditors[INDEX_STYLE] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.LineStyle.values(), true)); cellEditors[INDEX_ARROWHEAD] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.ArrowheadStyle.values(), true)); propViewer.setCellEditors(cellEditors); propViewer.setLabelProvider(new EdgeDisplayLabelProvider()); propViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); propViewer.setCellModifier(new EdgeDisplayCellModifier()); propViewer.setContentProvider(ArrayContentProvider.getInstance()); configSorters(propTable); }
Example #30
Source File: EnumerationEditingSupport.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public CellEditor getCellEditor(Object element) { if (element instanceof ExecutionSlot) { EnumerationType e = getEnumerationType((ExecutionSlot) element); List<String> enumeratorNames = new ArrayList<String>(); for (Enumerator enumerator : e.getEnumerator()) { enumeratorNames.add(enumerator.getName()); } return new ComboBoxCellEditor((Composite) getViewer().getControl(), enumeratorNames.toArray(new String[] {}), SWT.READ_ONLY); } return null; }