Java Code Examples for org.eclipse.jface.viewers.TableViewerColumn#setEditingSupport()

The following examples show how to use org.eclipse.jface.viewers.TableViewerColumn#setEditingSupport() . 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: SellOrderTableViewer.java    From offspring with MIT License 6 votes vote down vote up
private void createColumns() {
  for (int id : SellOrderTable.getColumns()) {
    TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE);
    TableColumn column = viewerColumn.getColumn();

    viewerColumn.setEditingSupport(new SellOrderEditingSupport(this, id));

    viewerColumn.setLabelProvider(SellOrderTable.createLabelProvider(id));
    column.addSelectionListener(getSelectionAdapter(column, id));

    column.setText(SellOrderTable.getColumnLabel(id));
    column.setAlignment(SellOrderTable.getColumnAlignment(id));

    column.setResizable(SellOrderTable.getColumnResizable(id));
    column.setWidth(SellOrderTable.getColumnWidth(id));
  }
}
 
Example 2
Source File: IndexControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createIndexNameColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.name);
    IndexNameValidator indexNameValidator = new IndexNameValidator(formPage.observeWorkingCopy());

    column.setLabelProvider(new LabelProviderBuilder<Index>()
            .withTextProvider(element -> element.getName())
            .withStatusProvider(indexNameValidator::validate)
            .shouldRefreshAllLabels(viewer)
            .createColumnLabelProvider());
    column.setEditingSupport(new EditingSupportBuilder<Index>(viewer)
            .withId(SWTBotConstants.SWTBOT_ID_UNIQUE_CONSTRAINT_NAME_TEXTEDITOR)
            .withValueProvider(Index::getName)
            .withValueUpdater((index, newName) -> {
                if (!Objects.equals(index.getName(), newName)) {
                    index.setName((String) newName);
                }
            })
            .create());
}
 
Example 3
Source File: QueryDetailsControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected TableViewerColumn createNameColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.name);

    QueryParameterNameValidator parameterNameValidator = new QueryParameterNameValidator(querySelectedObservable);

    column.setLabelProvider(new LabelProviderBuilder<QueryParameter>()
            .withTextProvider(parameter -> parameter.getName())
            .withStatusProvider(parameterNameValidator::validate)
            .shouldRefreshAllLabels(viewer)
            .createColumnLabelProvider());
    column.setEditingSupport(new EditingSupportBuilder<QueryParameter>(viewer)
            .withCanEditProvider(e -> !isDefault())
            .withValueProvider(QueryParameter::getName)
            .withValueUpdater((parameter, newName) -> {
                String oldName = parameter.getName();
                if (!Objects.equals(oldName, newName)) {
                    parameter.setName((String) newName);
                    formPage.refreshQueryViewers();
                }
            })
            .withId(SWTBotConstants.SWTBOT_ID_QUERY_PARAM_NAME_TEXTEDITOR)
            .create());

    return column;
}
 
Example 4
Source File: QueryDetailsControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected TableViewerColumn createTypeColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.type);
    column.setLabelProvider(new LabelProviderBuilder<QueryParameter>()
            .withTextProvider(parameter -> {
                String classname = parameter.getClassName();
                Class<?> clazz;
                try {
                    clazz = Class.forName(classname);
                } catch (ClassNotFoundException e) {
                    return null;
                }
                return clazz.getCanonicalName();
            })
            .shouldRefreshAllLabels(viewer)
            .createColumnLabelProvider());
    column.setEditingSupport(new QueryParameterTypeEditingSupport(viewer, () -> isDefault()));
    return column;
}
 
Example 5
Source File: QueryDetailsControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createDescriptionColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.description);
    column.setLabelProvider(new LabelProviderBuilder<QueryParameter>()
            .withTextProvider(parameter -> parameter.getDescription())
            .shouldRefreshAllLabels(viewer)
            .createColumnLabelProvider());
    column.setEditingSupport(new EditingSupportBuilder<QueryParameter>(viewer)
            .withCanEditProvider(e -> !isDefault())
            .withValueProvider(parameter -> parameter.getDescription() != null ? parameter.getDescription() : "")
            .withValueUpdater((parameter, newDesc) -> {
                String oldDesc = parameter.getDescription();
                if (!Objects.equals(oldDesc, newDesc)) {
                    parameter.setDescription((String) newDesc);
                    formPage.refreshQueryViewers();
                }
            })
            .create());
}
 
Example 6
Source File: QueryExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createValueColumn(final TableViewer tableViewer) {
    final TableViewerColumn valueColumnViewer = new TableViewerColumn(tableViewer, SWT.FILL);
    final TableColumn column = valueColumnViewer.getColumn();
    column.setText(Messages.value);
    final ExpressionColumnLabelProvider expressionLabelProvider = new ExpressionColumnLabelProvider(0);
    valueColumnViewer.setLabelProvider(new LabelProviderBuilder<Expression>()
            .withTextProvider(exp -> exp.getReferencedElements().isEmpty() ? null
                    : expressionLabelProvider.getText(exp.getReferencedElements().get(0)))
            .withImageProvider(exp -> exp.getReferencedElements().isEmpty() ? null
                    : expressionLabelProvider.getImage(exp.getReferencedElements().get(0)))
            .createColumnLabelProvider());

    editingSupport = new ReferencedExpressionEditingSupport(valueColumnViewer.getViewer());
    editingSupport.setFilter(new AvailableExpressionTypeFilter(new String[] { ExpressionConstants.CONSTANT_TYPE,
            ExpressionConstants.VARIABLE_TYPE,
            ExpressionConstants.PARAMETER_TYPE,
            ExpressionConstants.SCRIPT_TYPE,
            ExpressionConstants.CONTRACT_INPUT_TYPE }));
    valueColumnViewer.setEditingSupport(editingSupport);
}
 
Example 7
Source File: ConstraintEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createConstraintnameColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.name);
    UniqueConstraintNameValidator constraintNameValidator = new UniqueConstraintNameValidator();

    column.setLabelProvider(new LabelProviderBuilder<UniqueConstraint>()
            .withTextProvider(element -> element.getName())
            .withStatusProvider(constraint -> constraintNameValidator.validate(constraint))
            .shouldRefreshAllLabels(viewer)
            .createColumnLabelProvider());
    column.setEditingSupport(new EditingSupportBuilder<UniqueConstraint>(viewer)
            .withId(SWTBotConstants.SWTBOT_ID_UNIQUE_CONSTRAINT_NAME_TEXTEDITOR)
            .withValueProvider(UniqueConstraint::getName)
            .withValueUpdater((constraint, newName) -> {
                if (!Objects.equals(constraint.getName(), newName)) {
                    constraint.setName((String) newName);
                }
            })
            .create());
}
 
Example 8
Source File: AttributeEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createMultipleColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.CENTER);
    column.getColumn().setText(Messages.multiple);
    column.setLabelProvider(new CheckboxLabelProviderBuilder<Field>()
            .withIsSelectedProvider(Field::isCollection)
            .createCheckboxLabelProvider(viewer));
    column.setEditingSupport(new EditingSupportBuilder<Field>(viewer)
            .withCellEditorProvider(field -> new CheckboxCellEditor((Composite) viewer.getControl(), SWT.CHECK))
            .withValueProvider(field -> field.isCollection())
            .withValueUpdater((field, multiple) -> {
                field.setCollection((boolean) multiple);
                if ((boolean) multiple) {
                    field.setNullable(true);
                }
            })
            .create());
}
 
Example 9
Source File: ContractConstraintsTableViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createConstraintErrorMessageColumn() {
    final TableViewerColumn descriptionColumnViewer = createColumnViewer(Messages.technicalErrorMessage, SWT.FILL);
    descriptionColumnViewer.setLabelProvider(new ConstraintErrorMessageCellLabelProvider(propertySourceProvider, knowElements()));
    final ErrorMessageObservableEditingSupport editingSupport = new ErrorMessageObservableEditingSupport(this,
            messageManager,
            emfDataBindingContext);
    editingSupport.setControlId(SWTBotConstants.SWTBOT_ID_CONSTRAINT_ERROR_MESSAGE_TEXTEDITOR);
    descriptionColumnViewer.setEditingSupport(editingSupport);
}
 
Example 10
Source File: ContractConstraintsTableViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createConstraintNameColumn() {
    final TableViewerColumn nameColumnViewer = createColumnViewer(Messages.name + " *", SWT.FILL);
    nameColumnViewer.setLabelProvider(new ConstraintNameCellLabelProvider(propertySourceProvider, knowElements()));
    final ConstraintNameObservableEditingSupport editingSupport = new ConstraintNameObservableEditingSupport(this, messageManager,
            emfDataBindingContext);
    editingSupport.setControlId(SWTBotConstants.SWTBOT_ID_CONSTRAINT_NAME_TEXTEDITOR);
    nameColumnViewer.setEditingSupport(editingSupport);
}
 
Example 11
Source File: AttributeEditionControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createNameColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.name);
    FieldNameValidator fieldNameValidator = new FieldNameValidator();

    column.setLabelProvider(new LabelProviderBuilder<Field>()
            .withTextProvider(element -> element.getName())
            .withStatusProvider(fieldNameValidator::validate)
            .shouldRefreshAllLabels(viewer)
            .createColumnLabelProvider());
    column.setEditingSupport(new EditingSupportBuilder<Field>(viewer)
            .withId(SWTBotConstants.SWTBOT_ID_ATTRIBUTE_NAME_TEXTEDITOR)
            .withValueProvider(Field::getName)
            .withValueUpdater((field, newName) -> {
                String oldName = field.getName();
                if (!Objects.equals(oldName, newName)) {
                    Field oldField = EcoreUtil.copy(field);
                    field.setName((String) newName);
                    refactorConstraintsOnRename(oldName, (String) newName);
                    refactorIndexesOnRename(oldName, (String) newName);
                    refactorQueriesOnRename(oldName, (String) newName);
                    DiffElement diff = new DiffElement(Event.RENAME_ATTRIBUTE, oldField, field);
                    diff.addProperty(PARENT_QUALIFIED_NAME, ((BusinessObject) field.eContainer()).getQualifiedName());
                    formPage.refactorAccessControl(diff);
                }
            })
            .create());
}
 
Example 12
Source File: AttributeEditionControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createMandatoryColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.CENTER);
    column.getColumn().setText(Messages.mandatory);
    column.setLabelProvider(new CheckboxLabelProviderBuilder<Field>()
            .withIsSelectedProvider(field -> !field.isNullable())
            .withIsEnableProvider(field -> !field.isCollection())
            .withTooltipProvider(field -> field.isCollection() ? Messages.disabledMandatoryTooltip : null)
            .createCheckboxLabelProvider(viewer));
    column.setEditingSupport(new EditingSupportBuilder<Field>(viewer)
            .withCanEditProvider(field -> !field.isCollection())
            .withCellEditorProvider(field -> new CheckboxCellEditor((Composite) viewer.getControl(), SWT.CHECK))
            .withValueProvider(field -> !field.isNullable())
            .withValueUpdater((field, mandatory) -> field.setNullable(!(boolean) mandatory))
            .create());
}
 
Example 13
Source File: ExpressionCollectionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void addColumnToViewer(final int index) {
    final TableViewerColumn column = new TableViewerColumn(viewer, SWT.FILL);

    if (captions != null && captions.size() > index
            && captions.get(index) != null) {
        column.getColumn().setText(captions.get(index));
    }

    final ExpressionCollectionEditingSupport editingSupport = new ExpressionCollectionEditingSupport(
            column.getViewer(), index, editingDomain, removeRowListener);
    if (context != null) {
        editingSupport.setInput(context);
    }
    if (viewerFilters != null && viewerFilters.size() > index) {
        final ViewerFilter filter = viewerFilters.get(index);
        if (filter != null) {
            editingSupport.addFilter(filter);
        }
        if (viewerExprProviders != null
                && viewerExprProviders.size() > index) {
            final IExpressionNatureProvider provider = viewerExprProviders
                    .get(index);
            if (provider != null) {
                editingSupport.setExpressionNatureProvider(provider);
            }
        }
    }
    editingSupports.add(index, editingSupport);
    column.setEditingSupport(editingSupport);
    column.setLabelProvider(new ExpressionColumnLabelProvider(index));
    viewer.getTable().setLayout(createTableLayout());
}
 
Example 14
Source File: AdditionalResourcesConfigurationWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createFileColumn() {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.file);

    AdditionalResourceProjectPathValidator validator = new AdditionalResourceProjectPathValidator();

    column.setLabelProvider(new LabelProviderBuilder<Resource>()
            .withTextProvider(Resource::getProjectPath)
            .shouldRefreshAllLabels(viewer)
            .withStatusProvider(validator::validate)
            .createColumnLabelProvider());
    column.setEditingSupport(new AdditionalResourcesFileEditingSupport(viewer));
}
 
Example 15
Source File: ContractConstraintsTableViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createConstraintDescriptionColumn() {
    final TableViewerColumn descriptionColumnViewer = createColumnViewer(Messages.description, SWT.FILL);
    descriptionColumnViewer.setLabelProvider(new ConstraintDescriptionCellLabelProvider(propertySourceProvider, knowElements()));
    final DescriptionObservableEditingSupport editingSupport = new DescriptionObservableEditingSupport(this,
            messageManager,
            emfDataBindingContext);
    editingSupport.setControlId(SWTBotConstants.SWTBOT_ID_CONSTRAINT_DESCRIPTION_TEXTEDITOR);
    descriptionColumnViewer.setEditingSupport(editingSupport);
}
 
Example 16
Source File: AttributeEditionControl.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createTypeColumn(TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.type);
    column.setLabelProvider(new TypeLabelProvider(formPage.observeWorkingCopy()));
    column.setEditingSupport(new FieldTypeEditingSupport(viewer, formPage));
}
 
Example 17
Source File: TreePropertySection.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Adds columns to the provided <code>TableViewer</code>.
 * 
 * @param tableViewer
 */
protected void addTableViewerColumns(TableViewer tableViewer) {

	if (tableViewer != null) {
		TableColumn column;
		ICellContentProvider contentProvider;

		// ---- Create the name column. ---- //
		nameColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
		column = nameColumn.getColumn();
		column.setText("Name");
		column.setToolTipText("The name of the property");
		column.setResizable(true);
		// Create an ICellContentProvider, then use it to generate the
		// column labels and provide editing support for the name column.
		contentProvider = new NameCellContentProvider() {
			@Override
			public boolean setValue(Object element, Object value) {
				boolean changed = super.setValue(element, value);
				// If the value changed, mark the associated ICEFormEditor
				// as dirty.
				if (changed && editor != null) {
					editor.setDirty(true);
				}
				return changed;
			}
		};
		nameColumn.setLabelProvider(
				new CellColumnLabelProvider(contentProvider));
		nameColumn.setEditingSupport(
				new TextCellEditingSupport(tableViewer, contentProvider));
				// --------------------------------- //

		// ---- Create the value column. ---- //
		valueColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
		column = valueColumn.getColumn();
		column.setText("Value");
		column.setToolTipText("The value of the property");
		column.setResizable(true);
		// Create an ICellContentProvider, then use it to generate the
		// column labels and provide editing support for the value column.
		contentProvider = new ValueCellContentProvider() {
			@Override
			public boolean setValue(Object element, Object value) {
				boolean changed = super.setValue(element, value);
				// If the value changed, mark the associated ICEFormEditor
				// as dirty.
				if (changed && editor != null) {
					editor.setDirty(true);
				}
				return changed;
			}
		};
		valueColumn.setLabelProvider(
				new CellColumnLabelProvider(contentProvider));
		valueColumn.setEditingSupport(new ComboCellEditingSupport(
				tableViewer, (IComboCellContentProvider) contentProvider));
		// ---------------------------------- //
	}

	return;
}
 
Example 18
Source File: MOOSETreePropertySection.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Adds the default and additional columns to the provided
 * <code>TableViewer</code>. This should only be invoked on
 * CheckboxTableViewers.
 */
@Override
protected void addTableViewerColumns(TableViewer tableViewer) {
	if (tableViewer != null) {
		TableColumn column;
		ICellContentProvider contentProvider;

		// // ---- Create the placeholder CheckBox column. ---- //
		checkColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
		column = checkColumn.getColumn();
		column.setText("Enabled");
		column.setToolTipText("If checked, the parameter will be written "
				+ "to the input file.\n" + "If unchecked, the parameter "
				+ "will be commented out in the input file.");
		column.setResizable(true);

		// Create the check state manager. It also functions as the cell
		// content provider for the first column.
		TableCheckStateManager checkStateManager = new TableCheckStateManager(
				tableViewer) {
			@Override
			public boolean setValue(Object element, Object value) {
				boolean changed = super.setValue(element, value);
				// If the value changed, mark the associated ICEFormEditor
				// as dirty.
				if (changed && getFormEditor() != null) {
					getFormEditor().setDirty(true);
				}
				return changed;
			}
		};

		// Create a MOOSECheckStateProvider which sets the FormEditor as
		// dirty when the checkbox's value is changed.
		contentProvider = checkStateManager;

		// Add a blank label provider. Nothing should appear in the first
		// column except for the checkboxes.
		checkColumn.setLabelProvider(
				new CellColumnLabelProvider(contentProvider));

		// Set the content provider and listener for the CheckBox column
		CheckboxTableViewer checkedTableViewer = (CheckboxTableViewer) tableViewer;
		checkedTableViewer.setCheckStateProvider(checkStateManager);
		checkedTableViewer.addCheckStateListener(checkStateManager);

		// Create the default columns.
		super.addTableViewerColumns(tableViewer);

		// ---- Create the description/comments column. ---- //
		descriptionColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
		column = descriptionColumn.getColumn();
		column.setText("Comments");
		column.setToolTipText("Comments about the property. These are "
				+ "stored as comments in the input file.");
		column.setResizable(true);
		// Create an ICellContentProvider for a column that shows the
		// descriptions of Entries. Then hook it up as a label provider and
		// for editing support.
		contentProvider = new DescriptionCellContentProvider() {
			@Override
			public boolean setValue(Object element, Object value) {
				boolean changed = super.setValue(element, value);
				// If the value changed, mark the associated ICEFormEditor
				// as dirty.
				if (changed && getFormEditor() != null) {
					getFormEditor().setDirty(true);
				}
				return changed;
			}
		};
		descriptionColumn.setLabelProvider(
				new CellColumnLabelProvider(contentProvider));
		descriptionColumn.setEditingSupport(
				new TextCellEditingSupport(tableViewer, contentProvider));
		// ------------------------------------------------- //
	}

	return;
}
 
Example 19
Source File: GenerericTableViewer.java    From offspring with MIT License 4 votes vote down vote up
private void createColumns() {
  GC gc = new GC(getTable().getParent());

  List<Integer> widths = new ArrayList<Integer>();

  for (final IGenericTableColumn c : table.getColumns()) {
    TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE);

    viewerColumn.setLabelProvider(new GenericLabelProvider(c
        .getDataProvider()));

    if (c.getEditable()) {
      viewerColumn.setEditingSupport(c.getEditingSupport(this));
    }

    TableColumn column = viewerColumn.getColumn();

    if (c.getSortable() && comparator != null) {
      column.addSelectionListener(getSelectionAdapter(column, c));
    }
    column.setText(c.getLabel());
    column.setAlignment(c.getAlignMent());

    int width;
    if (c.getWidth() != -1) {
      width = c.getWidth();
    }
    else if (c.getTextExtent() != null
        && c.getLabel().length() < c.getTextExtent().length()) {
      width = gc.textExtent(c.getTextExtent()).x + 2;
    }
    else {
      width = gc.textExtent(c.getLabel()).x + 2;
    }

    widths.add(width);
    column.setWidth(width);
    column.setResizable(c.getResizable());
  }
  gc.dispose();

  /* All columns have their prefered width set now calculate percentages */
  TableColumnLayout layout = new TableColumnLayout();
  for (int i = 0; i < widths.size(); i++) {
    layout.setColumnData(getTable().getColumns()[i], new ColumnWeightData(
        widths.get(i), widths.get(i), true));
  }
  getTable().getParent().setLayout(layout);
}
 
Example 20
Source File: ContractConstraintsTableViewer.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void createConstraintExpressionColumn() {
    final TableViewerColumn nameColumnViewer = createColumnViewer(Messages.expression + " *", SWT.FILL);
    nameColumnViewer.setLabelProvider(new ConstraintExpressionCellLabelProvider(propertySourceProvider, knowElements()));
    nameColumnViewer.setEditingSupport(new ConstraintExpressionPropertyEditingSupport(this, propertySourceProvider));
}