org.eclipse.jface.viewers.TableViewer Java Examples

The following examples show how to use org.eclipse.jface.viewers.TableViewer. 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: ManageJarDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createTree(final Composite composite) {

        tableViewer = new TableViewer(composite, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
        tableViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 300).create());
        tableViewer.setContentProvider(new ArrayContentProvider());
        tableViewer.addFilter(searchFilter);
        tableViewer.setLabelProvider(new FileStoreLabelProvider());
        tableViewer.setInput(libStore.getChildren());

        tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(final SelectionChangedEvent arg0) {
                if(removeButton != null){
                    removeButton.setEnabled(!tableViewer.getSelection().isEmpty());
                }
            }
        });



    }
 
Example #2
Source File: ConnectionSelectionPage.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	layout.horizontalSpacing = 5;
	layout.verticalSpacing = 7;
	composite.setLayout(layout);
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	composite.setLayoutData(data);
	
	connViewer = new TableViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
	connViewer.setContentProvider(ArrayContentProvider.getInstance());
	connViewer.setLabelProvider(new ConnLabelProvider());
	connViewer.setInput(connections);
	connViewer.getTable().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
	connViewer.addSelectionChangedListener((SelectionChangedEvent event) -> {
		connection = (CodewindConnection)connViewer.getStructuredSelection().getFirstElement();
		validate();
	});
	
	// Add Context Sensitive Help
	PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, CodewindUIPlugin.MAIN_CONTEXTID);

	setControl(composite);
}
 
Example #3
Source File: SamplePart.java    From codeexamples-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@PostConstruct
public void createComposite(Composite parent) {
	parent.setLayout(new GridLayout(1, false));

	txtInput = new Text(parent, SWT.BORDER);
	txtInput.setMessage("Enter text to mark part as dirty");
	txtInput.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			dirty.setDirty(true);
		}
	});
	txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	tableViewer = new TableViewer(parent);

	tableViewer.add("Sample item 1");
	tableViewer.add("Sample item 2");
	tableViewer.add("Sample item 3");
	tableViewer.add("Sample item 4");
	tableViewer.add("Sample item 5");
	tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
}
 
Example #4
Source File: FaelleComposite.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public FaelleComposite(Composite parent, int style){
	super(parent, style);
	setLayout(new GridLayout(1, false));
	tableViewerFaelle = new TableViewer(this, SWT.None);
	tableViewerFaelle.getTable().setBackground(UiDesk.getColor(UiDesk.COL_WHITE));
	tableViewerFaelle.getTable().setLayoutData(
		new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	
	tableViewerFaelle.setLabelProvider(new FaelleLabelProvider());
	tableViewerFaelle.setContentProvider(new FaelleContentProvider());
	MenuManager menuManager = new MenuManager();
	menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
	
	tableViewerFaelle.getTable().setMenu(
		menuManager.createContextMenu(tableViewerFaelle.getTable()));
	menuManager.add(GlobalActions.openFallaction);
	menuManager.add(GlobalActions.makeBillAction);
	menuManager.add(GlobalActions.delFallAction);
	menuManager.add(GlobalActions.reopenFallAction);
	
	tableViewerFaelle.addSelectionChangedListener(new FallSelectionChangedToEventDispatcher());
}
 
Example #5
Source File: MultiPageCSVEditor.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 *
 */
private void createTablePage() {
	final Composite parent = getContainer();
	final Composite intermediate = new Composite(parent, SWT.NONE);
	final Composite composite = GamaToolbarFactory.createToolbars(this, intermediate);
	tableViewer =
			new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
	tableViewer.setUseHashlookup(true);
	final Table table = tableViewer.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	// set the sorter for the table

	tableViewer.setComparator(tableSorter);
	// set a table filter
	tableViewer.addFilter(tableFilter);

	addPage(intermediate);
	setPageText(indexTBL, "Table");
}
 
Example #6
Source File: NwResultPage.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createTable(String title, List<ImpactResult> results,
		boolean withUnit) {
	String[] columns;
	double[] colWidths;
	if (withUnit) {
		columns = new String[] { M.ImpactCategory, M.Amount,
				M.Unit };
		colWidths = new double[] { 0.5, 0.25, 0.25 };
	} else {
		columns = new String[] { M.ImpactCategory, M.Amount };
		colWidths = new double[] { 0.5, 0.25 };
	}
	Composite composite = UI.formSection(body, toolkit, title);
	TableViewer viewer = Tables.createViewer(composite, columns);
	viewer.setLabelProvider(new Label());
	Tables.bindColumnWidths(viewer, colWidths);
	List<Contribution<ImpactResult>> items = Contributions.calculate(
			results, impactResult -> impactResult.value);
	Contributions.sortDescending(items);
	viewer.setInput(items);
	Actions.bind(viewer, TableClipboard.onCopy(viewer));
}
 
Example #7
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void addNameColumn(final TableViewer tViewer) {
    final TableViewerColumn column = new TableViewerColumn(tViewer, SWT.FILL);
    final TableColumn nameColumn = column.getColumn();
    column.getColumn().setText(Messages.roleName);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            return ((Role) element).getName();
        }
    });

    column.getColumn().setWidth(90);
    column.getColumn().setMoveable(false);
    column.getColumn().setResizable(true);

    final TableColumnSorter sorter = new TableColumnSorter(tViewer);
    sorter.setColumn(nameColumn);
}
 
Example #8
Source File: MedicationViewerHelper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public static TableViewerColumn createBeginColumn(TableViewer viewer,
	TableColumnLayout layout, int columnIndex){
	TableViewerColumn ret = new TableViewerColumn(viewer, SWT.CENTER);
	TableColumn tblclmnEnacted = ret.getColumn();
	layout.setColumnData(tblclmnEnacted, new ColumnPixelData(60, true, true));
	tblclmnEnacted.setImage(Images.resize(Images.IMG_NEXT_WO_SHADOW.getImage(),
		ImageSize._12x12_TableColumnIconSize));
	tblclmnEnacted.setToolTipText(Messages.MedicationComposite_column_sortBy + " "
		+ Messages.MedicationComposite_column_beginDate);
	tblclmnEnacted
		.addSelectionListener(getSelectionAdapter(viewer, tblclmnEnacted, columnIndex));
	ret.setLabelProvider(new MedicationCellLabelProvider() {
		
		@Override
		public String getText(Object element){
			MedicationTableViewerItem pres = (MedicationTableViewerItem) element;
			return pres.getBeginDate();
		}
	});
	return ret;
}
 
Example #9
Source File: FormHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
    * Reads the input (list of formulas) and returns a list of strings which can be serialized 
    * @param source - viewer containing the formulas/assignments
    * @return
    */
public static List<String> getSerializedInput(final TableViewer tableViewer) {
	if (tableViewer instanceof CheckboxTableViewer) {
		final ArrayList<String> result = new ArrayList<>();
		final TableItem[] tableItems = tableViewer.getTable().getItems();
		final int itemCount = tableItems.length;
		for (int i = 0; i < itemCount; i++) {
			final TableItem item = tableItems[i];
			final String serialized = (item.getChecked() ? "1" : "0") + item.getText();
			
			result.add(serialized);
		}

           return result;
	} else {
           @SuppressWarnings("unchecked")
		List<Assignment> assignments = (List<Assignment>) tableViewer.getInput();
		if (assignments == null) {
			return null;
		}

           return ModelHelper.serializeAssignmentList(assignments);
       }
   }
 
Example #10
Source File: MedicationViewerHelper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public static TableViewerColumn createDosageColumn(TableViewer viewer,
	TableColumnLayout layout, int columnIndex){
	TableViewerColumn ret = new TableViewerColumn(viewer, SWT.NONE);
	ret.setLabelProvider(new MedicationCellLabelProvider() {
		
		@Override
		public String getText(Object element){
			MedicationTableViewerItem pres = (MedicationTableViewerItem) element;
			String dosis = pres.getDosis();
			return (dosis.equals(StringConstants.ZERO) ? Messages.MedicationComposite_stopped
					: dosis);
		}
	});
	TableColumn tblclmnDosage = ret.getColumn();
	tblclmnDosage.setToolTipText(Messages.TherapieplanComposite_tblclmnDosage_toolTipText);
	tblclmnDosage.addSelectionListener(getSelectionAdapter(viewer, tblclmnDosage, columnIndex));
	layout.setColumnData(tblclmnDosage, new ColumnPixelData(60, true, true));
	ret.getColumn().setText(Messages.TherapieplanComposite_tblclmnDosage_text);
	return ret;
}
 
Example #11
Source File: MedicationViewerHelper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public static TableViewerColumn createStopColumn(TableViewer viewer, TableColumnLayout layout,
	int columnIndex){
	TableViewerColumn ret = new TableViewerColumn(viewer, SWT.CENTER);
	TableColumn tblclmnStop = ret.getColumn();
	ColumnPixelData stopColumnPixelData = new ColumnPixelData(60, true, true);
	layout.setColumnData(tblclmnStop, stopColumnPixelData);
	tblclmnStop.setImage(Images.resize(Images.IMG_ARROWSTOP_WO_SHADOW.getImage(),
		ImageSize._12x12_TableColumnIconSize));
	tblclmnStop.setToolTipText(Messages.MedicationComposite_column_sortBy + " "
		+ Messages.MedicationComposite_column_endDate);
	tblclmnStop.addSelectionListener(getSelectionAdapter(viewer, tblclmnStop, columnIndex));
	ret.setLabelProvider(new MedicationCellLabelProvider() {
		@Override
		public String getText(Object element){
			MedicationTableViewerItem pres = (MedicationTableViewerItem) element;
			if (pres.getEntryType() != EntryType.RECIPE
				&& pres.getEntryType() != EntryType.SELF_DISPENSED) {
				return pres.getEndDate();
			}
			return "";
		}
	});
	return ret;
}
 
Example #12
Source File: AbstractCallHierarchyViewPart.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected TableViewer createLocationViewer(Composite parent) {
	TableViewer locationViewer = new TableViewer(parent);
	locationViewer.setContentProvider(new ArrayContentProvider());
	locationViewer.setLabelProvider(createLocationLabelProvider());

	TableLayout layout = new TableLayout();
	locationViewer.getTable().setLayout(layout);
	locationViewer.getTable().setHeaderVisible(true);

	Pair<String, ColumnLayoutData>[] locationColumnDescriptions = getLocationColumnDescriptions();
	IntStream.range(0, locationColumnDescriptions.length).forEach(index -> {
		layout.addColumnData(locationColumnDescriptions[index].getValue());
		createColumn(locationViewer.getTable(), locationColumnDescriptions[index], index);
	});

	return locationViewer;
}
 
Example #13
Source File: CListTable.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void createTable(Composite parent)
{
	tableViewer = new TableViewer(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
	tableViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

	tableViewer.setContentProvider(ArrayContentProvider.getInstance());
	tableViewer.setLabelProvider(new LabelProvider());
	tableViewer.setComparator(new ViewerComparator());
	tableViewer.setInput(items);
	tableViewer.addSelectionChangedListener(new ISelectionChangedListener()
	{

		public void selectionChanged(SelectionChangedEvent event)
		{
			updateStates();
		}

	});
	updateStates();
}
 
Example #14
Source File: SelectDataWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void createBusinessVariableTableViewerComposite(final Composite parent, final DataBindingContext dbc) {
    businessVariableTableViewerComposite = new Composite(parent, SWT.NONE);
    businessVariableTableViewerComposite.setLayout(GridLayoutFactory.swtDefaults().create());
    businessVariableTableViewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final TableViewer businessDataTableViewer = new TableViewer(businessVariableTableViewerComposite,
            SWT.BORDER | SWT.SINGLE | SWT.NO_FOCUS | SWT.H_SCROLL
                    | SWT.V_SCROLL);
    businessDataTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create());
    businessDataTableViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create());
    final ObservableListContentProvider contentProvider = new ObservableListContentProvider();
    businessDataTableViewer.setContentProvider(contentProvider);
    final IObservableSet knownElements = contentProvider.getKnownElements();
    final IObservableMap[] labelMaps = EMFObservables.observeMaps(knownElements,
            new EStructuralFeature[] { ProcessPackage.Literals.ELEMENT__NAME,
                    ProcessPackage.Literals.DATA__MULTIPLE,
                    ProcessPackage.Literals.JAVA_OBJECT_DATA__CLASS_NAME });
    businessDataTableViewer
            .setLabelProvider(new BusinessObjectDataStyledLabelProvider(businessObjectStore, labelMaps));
    businessDataTableViewer
            .setInput(new WritableList(availableBusinessData, ProcessPackage.Literals.BUSINESS_OBJECT_DATA));
    final IViewerObservableValue observeSingleSelection = ViewersObservables
            .observeSingleSelection(businessDataTableViewer);
    dbc.bindValue(observeSingleSelection, selectedDataObservable);
    businessVariableButton.addSelectionListener(createBusinessVariableSelectionAdapter());
}
 
Example #15
Source File: SamplePart.java    From codeexamples-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@PostConstruct
public void createComposite(Composite parent) {
	parent.setLayout(new GridLayout(1, false));

	txtInput = new Text(parent, SWT.BORDER);
	txtInput.setMessage("Enter text to mark part as dirty");
	txtInput.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			dirty.setDirty(true);
		}
	});
	txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	tableViewer = new TableViewer(parent);

	tableViewer.setContentProvider(ArrayContentProvider.getInstance());;
	tableViewer.setInput(createInitialDataModel());
	tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
}
 
Example #16
Source File: StringSortPageableTableExample.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private static TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound) {
	final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
	final TableColumn column = viewerColumn.getColumn();
	column.setText(title);
	column.setWidth(bound);
	column.setResizable(true);
	column.setMoveable(true);
	return viewerColumn;
}
 
Example #17
Source File: AbapGitView.java    From ADT_Frontend with MIT License 5 votes vote down vote up
private void setupViewer(Composite parent) {
	this.viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
	this.viewer.getControl().setLayoutData(parent.getLayoutData());
	Table table = this.viewer.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	createColumns();
	this.viewer.setContentProvider(ArrayContentProvider.getInstance());
	addKeyListeners();
}
 
Example #18
Source File: ContractPropertySectionTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_bindRemoveButtonEnablement_convert_boolean_value() throws Exception {
    section.init(new WritableValue(aContract().build(), Contract.class));
    final Button removeButton = new Button(parent, SWT.PUSH);
    final TableViewer inputsTableViewer = new TableViewer(parent);
    inputsTableViewer.setLabelProvider(new LabelProvider());
    inputsTableViewer.setContentProvider(ArrayContentProvider.getInstance());
    inputsTableViewer.setInput(Arrays.asList("item"));
    section.bindRemoveButtonEnablement(removeButton, inputsTableViewer);
    assertThat(removeButton.isEnabled()).isFalse();
    assertThat(inputsTableViewer.getSelection().isEmpty()).isTrue();
    inputsTableViewer.setSelection(new StructuredSelection("item"));
    assertThat(removeButton.isEnabled()).isTrue();
    assertThat(inputsTableViewer.getSelection().isEmpty()).isFalse();
}
 
Example #19
Source File: DefinesViewer.java    From cmake4eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void handleDefineDelButton(TableViewer tableViewer) {
  final IStructuredSelection selection = (IStructuredSelection) tableViewer
      .getSelection();
  final Shell shell = tableViewer.getControl().getShell();
  if (MessageDialog.openQuestion(shell, "CMake-Define deletion confirmation",
      "Are you sure to delete the selected CMake-defines?")) {
    @SuppressWarnings("unchecked")
    ArrayList<CmakeDefine> defines = (ArrayList<CmakeDefine>) tableViewer
        .getInput();
    defines.removeAll(selection.toList());
    tableViewer.remove(selection.toArray());// updates the display
  }
}
 
Example #20
Source File: FilterTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
public FilterTableControl(Composite parent) {
  super(parent, SWT.NONE);
  setLayout(Widgets.buildContainerLayout(1));

  filterViewer = 
      new TableViewer(this, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI );

  // Set up layout properties.
  Table filterTable = filterViewer.getTable();
  filterTable.setLayoutData(Widgets.buildGrabFillData());

  // Initialize the table.
  filterTable.setHeaderVisible(true);
  filterTable.setToolTipText("Node Filter Editor");
  EditColTableDef.setupTable(TABLE_DEF, filterTable);

  CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length];
  cellEditors[INDEX_NAME] = new TextCellEditor(filterTable);
  cellEditors[INDEX_SUMMARY] = new NodeFilterCellEditor(filterTable);

  // Configure table properties.
  filterViewer.setCellEditors(cellEditors);
  filterViewer.setLabelProvider(LABEL_PROVIDER);
  filterViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF));
  filterViewer.setCellModifier(new ControlCellModifier());

  // Since the order is significant, no sorting capabilities.

  // Avoid setInput() invocations that come with
  // TableContentProvider.initViewer
  filterViewer.setContentProvider(ArrayContentProvider.getInstance());
}
 
Example #21
Source File: MonitorsViewTable.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public MonitorsViewTable ( final Composite parent, final IViewSite viewSite, final int style, final WritableSet monitors, final List<ColumnProperties> columnSettings )
{
    super ( parent, style );

    this.monitors = monitors;

    final FillLayout layout = new FillLayout ();
    setLayout ( layout );

    this.tableViewer = new TableViewer ( this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI );
    this.tableRef.set ( this.tableViewer );
    createColumns ( this.tableViewer );
    applyColumSettings ( columnSettings );
    this.tableViewer.getTable ().setHeaderVisible ( true );
    this.tableViewer.getTable ().setLinesVisible ( true );
    this.tableViewer.setUseHashlookup ( true );
    this.tableViewer.setSorter ( new Sorter ( Columns.LAST_FAIL_TIMESTAMP, SWT.DOWN ) );
    this.tableViewer.getTable ().setSortDirection ( SWT.DOWN );

    hookContextMenu ( this.tableViewer.getControl (), this.tableViewer, viewSite );

    viewSite.setSelectionProvider ( this.tableViewer );

    final ObservableSetContentProvider contentProvider = new ObservableSetContentProvider ();
    this.tableViewer.setContentProvider ( contentProvider );
    this.tableViewer.setLabelProvider ( new MonitorTableLabelProvider ( Properties.observeEach ( contentProvider.getKnownElements (), BeanProperties.values ( new String[] { "id", "monitor" } ) ), Settings.getTimeZone () ) ); //$NON-NLS-1$ //$NON-NLS-2$
    this.tableViewer.setInput ( this.monitors );

    contentProvider.getRealizedElements ().addSetChangeListener ( new ISetChangeListener () {
        @Override
        public void handleSetChange ( final SetChangeEvent event )
        {
            if ( !MonitorsViewTable.this.scrollLock )
            {
                MonitorsViewTable.this.tableViewer.getTable ().setTopIndex ( 0 );
            }
        }
    } );
}
 
Example #22
Source File: MigrationGroupListViewer.java    From depan with Apache License 2.0 5 votes vote down vote up
/**
 * Create the GUI Control under the given parent.
 * @param parent the GUI parent.
 * @param listener {@link SelectionListener} for selection callbacks.
 * @return the top level Control for this widget.
 */
public Control createControl(Composite parent, SelectionListener listener) {
  table = new TableViewer(parent, SWT.V_SCROLL | SWT.BORDER);
  table.setContentProvider(
      CollectionContentProvider.newProvider(task.getMigrationGroups()));
  table.getTable().addSelectionListener(listener);
  return table.getControl();
}
 
Example #23
Source File: TableColumnSorter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public TableColumnSorter(TableViewer viewer) {
	this.viewer = viewer;
	Assert.isTrue(this.viewer.getComparator() == null);
	viewer.setComparator(this);

	for (TableColumn tableColumn : viewer.getTable().getColumns()) {
		tableColumn.addSelectionListener(selectionHandler);
	}
}
 
Example #24
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addDisplayNameColumn(final TableViewer tViewer) {
    final TableViewerColumn column = new TableViewerColumn(tViewer, SWT.FILL);
    column.getColumn().setText(Messages.displayName);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            return ((Role) element).getDisplayName();
        }
    });

    column.getColumn().setWidth(90);
    column.getColumn().setMoveable(false);
    column.getColumn().setResizable(true);
}
 
Example #25
Source File: AttributeEditionControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createAttributeTableViewer(Composite parent) {
    viewer = new TableViewer(parent,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewer.getTable().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ATTRIBUTE_LIST_VIEWER_ID);
    formPage.getToolkit().adapt(viewer.getTable());
    ColumnViewerToolTipSupport.enableFor(viewer);
    viewer.setUseHashlookup(true);
    viewer.getTable().setHeaderVisible(true);
    viewer.getTable().setLinesVisible(true);
    viewer.addFilter(new SearchFilter<>(fieldToFilter));

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(5, true));
    layout.addColumnData(new ColumnWeightData(4, true));
    layout.addColumnData(new ColumnWeightData(3, true));
    layout.addColumnData(new ColumnWeightData(3, true));
    viewer.getTable().setLayout(layout);

    createNameColumn(viewer);
    createTypeColumn(viewer);
    createMultipleColumn(viewer);
    createMandatoryColumn(viewer);

    viewer.setContentProvider(new ObservableListContentProvider());
    viewer.setInput(fieldsObservable);
    selectedFieldObservable = ViewerProperties.singleSelection(Field.class).observe(viewer);

    addDragAndDropSupport();
}
 
Example #26
Source File: MOOSETreePropertySection.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the table that displays properties for viewing and editing.
 * 
 * @param client
 *            The client <code>Composite</code> that should contain the
 *            table of properties.
 * @return The <code>TableViewer</code> for the table of properties.
 */
@Override
protected TableViewer createTableViewer(Composite client) {

	CheckboxTableViewer tableViewer = null;

	if (client != null) {
		Table table;

		// Create the TableViewer and the underlying Table Control.
		tableViewer = CheckboxTableViewer.newCheckList(client,
				SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
		// Set some properties for the table.
		table = tableViewer.getTable();
		table.setHeaderVisible(true);
		table.setLinesVisible(true);

		// Set up the content provider for the table viewer. Now the table
		// viewer's input can be set.
		tableViewer.setContentProvider(new TreePropertyContentProvider());

		// Enable tool tips for the Table's cells.
		ColumnViewerToolTipSupport.enableFor(tableViewer,
				ToolTip.NO_RECREATE);

		// Populate the TableViewer with its columns.
		addTableViewerColumns(tableViewer);
	}

	return tableViewer;
}
 
Example #27
Source File: PreTranslationResultDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);
	container.setLayout(new GridLayout(1, false));

	Composite composite = new Composite(container, SWT.NONE);
	GridLayout gl_composite = new GridLayout(1, false);
	gl_composite.verticalSpacing = 0;
	gl_composite.marginWidth = 0;
	gl_composite.marginHeight = 0;
	composite.setLayout(gl_composite);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
	Table table = tableViewer.getTable();

	GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	tableGd.heightHint = 220;
	table.setLayoutData(tableGd);

	table.setLinesVisible(true);
	table.setHeaderVisible(true);

	String[] clmnTitles = new String[] { Messages.getString("dialog.PreTranslationResultDialog.clmnTitles1"),
			Messages.getString("dialog.PreTranslationResultDialog.clmnTitles2"),
			Messages.getString("dialog.PreTranslationResultDialog.clmnTitles3"),
			Messages.getString("dialog.PreTranslationResultDialog.clmnTitles4"),
			Messages.getString("dialog.PreTranslationResultDialog.clmnTitles5"),
			Messages.getString("dialog.PreTranslationResultDialog.clmnTitles6") };
	int[] clmnBounds = { 60, 200, 100, 110, 110, 110 };
	for (int i = 0; i < clmnTitles.length; i++) {
		createTableViewerColumn(tableViewer, clmnTitles[i], clmnBounds[i], i);
	}

	tableViewer.setLabelProvider(new TableViewerLabelProvider());
	tableViewer.setContentProvider(new ArrayContentProvider());
	tableViewer.setInput(this.getTableViewerInput());
	return container;
}
 
Example #28
Source File: XPathExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Control createExpressionEditor(final Composite parent, final EMFDataBindingContext ctx) {
    mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(new GridLayout(2, true));

    viewer = new TableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);

    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(100, false));
    viewer.getTable().setLayout(layout);
    viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final TableViewerColumn columnViewer = new TableViewerColumn(viewer, SWT.NONE);
    final TableColumn column = columnViewer.getColumn();
    column.setText(Messages.name);

    final TableColumnSorter sorter = new TableColumnSorter(viewer);
    sorter.setColumn(column);

    viewer.getTable().setHeaderVisible(true);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new DataStyledTreeLabelProvider());
    viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            if (!event.getSelection().isEmpty()) {
                xsdViewer.expandAll();
                XPathExpressionEditor.this.fireSelectionChanged();
            }
        }
    });

    createXPathChooser(mainComposite);
    createReturnTypeComposite(parent);

    return mainComposite;
}
 
Example #29
Source File: LazyCommonViewerContentProvider.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void updateElement(int index){
	if (loadedElements != null && loadedElements.length > 0) {
		Object[] copy = new Object[loadedElements.length];
		System.arraycopy(loadedElements, 0, copy, 0, loadedElements.length);
		if (index >= 0 && index < copy.length) {
			Object o = copy[index];
			if (o != null) {
				TableViewer tv = (TableViewer) commonViewer.getViewerWidget();
				tv.replace(o, index);
			}
		}
	}
}
 
Example #30
Source File: TableSorter.java    From Flashtool with GNU General Public License v3.0 5 votes vote down vote up
public TableSorter(TableViewer tableViewer) {
	this.tableViewer = tableViewer;
	addColumnSelectionListeners(tableViewer);
	tableViewer.setComparator(new ViewerComparator() {
		public int compare(Viewer viewer, Object e1, Object e2) {
			return compareElements(e1, e2);
		}
	});
}