org.eclipse.jface.viewers.TextCellEditor Java Examples

The following examples show how to use org.eclipse.jface.viewers.TextCellEditor. 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: MultiPageCSVEditor.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 *
 */
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 #2
Source File: ModifySupport.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void setEditor(ICellModifier<T> modifier, int index) {
	switch (modifier.getCellEditingType()) {
	case TEXTBOX:
		if (modifier.getStyle() != SWT.NONE)
			editors[index] = new TextCellEditor(getComponent(), modifier.getStyle());
		else
			editors[index] = new TextCellEditor(getComponent());
		break;
	case COMBOBOX:
		editors[index] = new ComboEditor(getComponent(), new String[0]);
		break;
	case CHECKBOX:
		if (modifier.getStyle() != SWT.NONE)
			editors[index] = new CheckboxCellEditor(getComponent(), modifier.getStyle());
		else
			editors[index] = new CheckboxCellEditor(getComponent());
		break;
	default:
		break;
	}
}
 
Example #3
Source File: MenuStylesDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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 #4
Source File: DataTypeNameEditingSupport.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 #5
Source File: LiteralEditingSupport.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 ;
            }

            return null;
        }
    }) ;
    return  editor;
}
 
Example #6
Source File: CustomTextEMFObservableValueEditingSupport.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected TextCellEditor getCellEditor(final Object object) {
    cellEditor = new TextCellEditor((Composite) getViewer().getControl()) {

        /*
         * (non-Javadoc)
         * @see org.eclipse.jface.viewers.CellEditor#deactivate()
         */
        @Override
        public void deactivate() {
            super.deactivate();
            messageManager.removeAllMessages();
        }
    };
    cellEditor.getControl().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, controlId);
    return cellEditor;
}
 
Example #7
Source File: ActorDescripitonEditingSupport.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 value) {
			String desc = (String)value;
			if (desc.length()>255){
				return Messages.descTooLong;
			}
			return null;
		}
	});
	return  editor;
}
 
Example #8
Source File: SelectItemEditingSupport.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 : select.getItems()){
                if(item.equals(value)){
                    return "Item already exists" ;
                }
            }
            return null;
        }
    });
    return cellEditor ;
}
 
Example #9
Source File: RealEditingSupport.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@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 #10
Source File: IntegerEditingSupport.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public CellEditor getCellEditor(Object element) {
	TextCellEditor textCellEditor = new TextCellEditor((Composite) getViewer().getControl());
	textCellEditor.setValidator(new ICellEditorValidator() {
		public String isValid(Object value) {
			try {
				Long.parseLong((String) value);
			} catch (NumberFormatException e) {
				return "No valid integer value!";
			}
			return null;
		}
	});

	return textCellEditor;
}
 
Example #11
Source File: CaptionEditingSupport.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 : array.getColsCaption()){
                if(item.equals(value)){
                    return "Item already exists" ;
                }
            }
            return null;
        }
    });
    return cellEditor ;
}
 
Example #12
Source File: RadioGroupItemEditingSupport.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 #13
Source File: ParameterNameEditingSupport.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CellEditor getCellEditor(final Object element) {
	final TextCellEditor editor = new TextCellEditor((Composite) getViewer().getControl(), SWT.NONE) ;
	editor.setValidator(new ICellEditorValidator() {

		@Override
		public String isValid(final Object value) {
			final String input = (String) value ;

			final IStatus javaConventionNameStatus = new GroovyReferenceValidator(Messages.name).validate(value.toString());
			if(!javaConventionNameStatus.isOK()){
				return javaConventionNameStatus.getMessage();
			}

			final IStatus lenghtNameStatus = new InputLengthValidator(Messages.name, 50).validate(input);
			if(!lenghtNameStatus.isOK()){
				return lenghtNameStatus.getMessage();
			}
			final Parameter param = (Parameter) element ;
			final AbstractProcess process = (AbstractProcess) param.eContainer() ;
			for(final Parameter p : process.getParameters()){
				if(!p.equals(param)){
					if(p.getName().equals(input)){
						return Messages.invalidName ;
					}
				}
			}
			return null;
		}
	}) ;
	listener.setCellEditor(editor);
	editor.addListener(listener);
	return  editor;
}
 
Example #14
Source File: ActorNameEditingSupport.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CellEditor getCellEditor(final Object element) {
    final TextCellEditor editor = new TextCellEditor((Composite) getViewer().getControl(), SWT.NONE);
    editor.setValidator(new ICellEditorValidator() {

        @Override
        public String isValid(final Object value) {
            final String input = (String) value;
            if (input.isEmpty()) {
                return Messages.nameIsEmpty;
            }
            if (input.length() > 50) {
                return Messages.nameTooLong;
            }
            final Actor actor = (Actor) element;
            final AbstractProcess process = ModelHelper.getParentProcess(actor);
            for (final Actor a : process.getActors()) {
                if (!a.equals(actor)) {
                    if (a.getName().equals(input)) {
                        return Messages.nameAlreadyExists;
                    }
                }
            }
            return null;
        }
    });
    listener.setCellEditor(editor);
    editor.addListener(listener);
    return editor;
}
 
Example #15
Source File: NoteEditManager.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void initCellEditor() {
	TextCellEditor editor = (TextCellEditor) this.getCellEditor();

	if (note.getText() != null) {
		editor.setValue(note.getText());
	}

	Text text = (Text) editor.getControl();

	text.selectAll();
}
 
Example #16
Source File: UnitMappingPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createCellEditors() {
	String[] flowPropertyNames = new String[flowProperties.size()];
	for (int i = 0; i < flowProperties.size(); i++)
		flowPropertyNames[i] = flowProperties.get(i).name;
	flowPropertyCellEditor = new ComboBoxCellEditor(tableViewer.getTable(),
			flowPropertyNames, SWT.READ_ONLY);
	final CellEditor[] editors = new CellEditor[] {
			new TextCellEditor(tableViewer.getTable()),
			flowPropertyCellEditor,
			new TextCellEditor(tableViewer.getTable()),
			new TextCellEditor(tableViewer.getTable()),
			new TextCellEditor(tableViewer.getTable()) };
	tableViewer.setCellEditors(editors);
}
 
Example #17
Source File: ReflectiveEditingSupport.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public ReflectiveEditingSupport(TableViewer columnViewer, String field,
	ICellEditorValidator validator, boolean markValidationFailed){
	super(columnViewer);
	this.field = field;
	this.editor = new TextCellEditor(columnViewer.getTable());
	if (validator != null)
	{
		editor.setValidator(validator);
		
		if (markValidationFailed)
		{
			editor.addListener(new ICellEditorListener() {
				@Override
				public void editorValueChanged(boolean oldValidState, boolean newValidState){
					if (newValidState) {
						editor.getControl().setBackground(
							Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
					} else {
						editor.getControl().setBackground(
							Display.getCurrent().getSystemColor(SWT.COLOR_RED));
					}
				}
				
				@Override
				public void cancelEditor(){
					editor.getControl().setBackground(
						Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
				}
				
				@Override
				public void applyEditorValue(){
					editor.getControl().setBackground(
						Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
				}
			});
		}
	}
}
 
Example #18
Source File: PyEditorHoverConfigurationBlock.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@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 #19
Source File: CustomUserInformationDefinitionNameEditingSupport.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@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 #20
Source File: TextCellEditingSupport.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * The default constructor.
 * 
 * @param viewer
 *            The viewer that is using this <code>EditingSupport</code>.
 *            <code>Control</code>s required by this class will be
 *            constructed under this viewer's <code>Control</code> (usually
 *            a <code>Table</code>).
 * @param contentProvider
 *            The content provider. The methods required as an
 *            <code>EditingSupport</code> are passed to this content
 *            provider.
 */
public TextCellEditingSupport(ColumnViewer viewer,
		ICellContentProvider contentProvider) {
	super(viewer);

	this.contentProvider = contentProvider;

	// Get the viewer's Composite so we can create the CellEditors.
	Composite parent = (Composite) viewer.getControl();

	// Create the TextCellEditor.
	textCell = new TextCellEditor(parent, SWT.LEFT);

	return;
}
 
Example #21
Source File: SubTotalProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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 #22
Source File: DataSetColumnBindingsFormHandleProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public CellEditor[] getEditors( Table table )
{
	if ( editors == null )
	{
		editors = new CellEditor[columnNames.length];

		for ( int i = 0; i < editors.length; i++ )
		{
			editors[i] = new TextCellEditor( table );
		}
	}
	return editors;
}
 
Example #23
Source File: FilterHandleProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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 #24
Source File: LabelEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Perform director edit on label
 */
public void performDirectEdit( )
{
	if ( manager == null )
		manager = new LabelEditManager( this,
				TextCellEditor.class,
				new LabelCellEditorLocator( (Figure) getFigure( ) ) );
	manager.show( );
}
 
Example #25
Source File: SortingHandleProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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 #26
Source File: GroupHandleProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public CellEditor[] getEditors( Table table )
{
	if ( editors == null )
	{
		editors = new TextCellEditor[columnKeys.length];
		editors[0] = new TextCellEditor( table );
		editors[1] = new TextCellEditor( table );
	}
	return null;
}
 
Example #27
Source File: GridViewerShortTextPerformance.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public GridViewerShortTextPerformance(Shell shell)
{
	final GridTableViewer v = new GridTableViewer(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	v.setLabelProvider(new MyLabelProvider());
	v.setContentProvider(new MyContentProvider());
	v.getGrid().setCellSelectionEnabled(true);

	v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getGrid()), new TextCellEditor(v.getGrid()) });

	v.setColumnProperties(new String[] { "1", "2" });

	ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(v)
	{

		@Override
		protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
		{
			return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
					|| event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
					|| (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
							&& event.keyCode == SWT.CR);
		}
	};

	GridViewerEditor.create(v, actSupport,
			ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
					| ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);

	for (int i = 0; i < NUM_COLUMNS; i++)
	{
		createColumn(v, "Column " + i);
	}

	MyModel[] model = createModel();
	v.setInput(model);
	v.getGrid().setLinesVisible(true);
	v.getGrid().setHeaderVisible(true);
}
 
Example #28
Source File: ElementNamesConfigurationBlock.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * create a tableview for the existed table
 * 
 */
private void createTableViewer( )
{
	tableViewer = new TableViewer( table );
	tableViewer.setUseHashlookup( true );
	tableViewer.setColumnProperties( elementNames );

	// Create the cell editors
	CellEditor[] editors = new CellEditor[elementNames.length];

	for ( int i = 0; i < elementNames.length; i++ )
	{
		TextCellEditor textEditor = new TextCellEditor( table );
		( (Text) textEditor.getControl( ) ).setTextLimit( 60 );
		if ( i == 1 )
		{
			// assure that the CUSTOM NAME column doesn't contain
			// ReportPlugin.PREFERENCE_DELIMITER
			( (Text) textEditor.getControl( ) ).addVerifyListener(

			new VerifyListener( ) {

				public void verifyText( VerifyEvent e )
				{
					e.doit = e.text.indexOf( ReportPlugin.PREFERENCE_DELIMITER ) < 0;
				}
			} );

		}
		editors[i] = textEditor;
	}

	// Assign the cell editors to the viewer
	tableViewer.setCellEditors( editors );
	// Set the cell modifier for the viewer
	tableViewer.setCellModifier( new ElementNamesCellModifier( this ) );
}
 
Example #29
Source File: ColumnPageBreakProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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 #30
Source File: FilterHandleProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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;
}