Java Code Examples for org.eclipse.jface.viewers.TextCellEditor#setValidator()

The following examples show how to use org.eclipse.jface.viewers.TextCellEditor#setValidator() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
Source File: OrganizationNameEditingSupport.java    From bonita-studio with GNU General Public License v2.0 4 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 OrganizationNameCellEditorValidator()) ;
	return  editor;
}