Java Code Examples for org.eclipse.jface.viewers.TableViewer

The following examples show how to use org.eclipse.jface.viewers.TableViewer. These examples are extracted from open source projects. 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 Project: codeexamples-eclipse   Source File: SamplePart.java    License: 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 2
@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 Project: elexis-3-core   Source File: FaelleComposite.java    License: 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 4
Source Project: gama   Source File: MultiPageCSVEditor.java    License: 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 5
Source Project: olca-app   Source File: NwResultPage.java    License: 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 6
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 7
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 8
Source Project: tlaplus   Source File: FormHelper.java    License: 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 9
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 10
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 11
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 12
Source Project: APICloud-Studio   Source File: CListTable.java    License: 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 13
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 14
Source Project: codeexamples-eclipse   Source File: SamplePart.java    License: 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 15
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 16
/**
 * 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 17
Source Project: MergeProcessor   Source File: Dashboard.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return the DataBindingContext
 */
private DataBindingContext initDataBindings() {
	DataBindingContext bindingContext = new DataBindingContext();
	final TableViewer tableViewer = view.getTableViewer();
	tableViewer.setContentProvider(new ArrayContentProvider());
	tableViewer.setInput(mergeUnits);

	return bindingContext;
}
 
Example 18
@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 19
Source Project: elexis-3-core   Source File: TableViewerSorter.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public TableViewerSorter(TableViewer tableViewer){
	this.tableViewer = tableViewer;
	addColumnSelectionListeners(tableViewer);
	tableViewer.setComparator(new ViewerComparator() {
		public int compare(Viewer viewer, Object e1, Object e2){
			return compareElements(e1, e2);
		}
	});
}
 
Example 20
Source Project: olca-app   Source File: Tables.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/** Add an event handler for double clicks on the given table viewer. */
public static void onDoubleClick(TableViewer viewer, Consumer<MouseEvent> handler) {
	if (viewer == null || viewer.getTable() == null || handler == null)
		return;
	viewer.getTable().addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDoubleClick(MouseEvent e) {
			handler.accept(e);
		}
	});
}
 
Example 21
Source Project: nebula   Source File: LazyPageTableExample.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static void createColumns(final TableViewer viewer) {

		// First column is for the first name
		TableViewerColumn col = createTableViewerColumn(viewer, "Name", 150);
		col.setLabelProvider(new ColumnLabelProvider() {
			@Override
			public String getText(Object element) {
				String p = (String) element;
				return p;
			}
		});
	}
 
Example 22
/**
 * 创建页面内容
 * @param parent
 *            ;
 */
private void createInputPageContent(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	GridLayout gl_composite = new GridLayout(1, false);
	gl_composite.marginHeight = 0;
	gl_composite.marginWidth = 0;
	gl_composite.verticalSpacing = 0;
	composite.setLayout(gl_composite);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	viewer = new TableViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
	final Table table = viewer.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.PreTranslationDialog.clmnTitles1"),
			Messages.getString("dialog.PreTranslationDialog.clmnTitles2"),
			Messages.getString("dialog.PreTranslationDialog.clmnTitles3"),
			Messages.getString("dialog.PreTranslationDialog.clmnTitles4") };
	int[] clmnBounds = { 80, 250, 100, 100 };
	for (int i = 0; i < clmnTitles.length; i++) {
		createTableViewerColumn(viewer, clmnTitles[i], clmnBounds[i], i);
	}

	viewer.setLabelProvider(new TableViewerLabelProvider());
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setInput(this.getTableViewerInput());

}
 
Example 23
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 24
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 25
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 Project: Flashtool   Source File: TableSorter.java    License: 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);
		}
	});
}
 
Example 27
Source Project: ADT_Frontend   Source File: AbapGitView.java    License: 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 28
@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 29
Source Project: neoscada   Source File: MonitorsViewTable.java    License: 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 30
Source Project: cmake4eclipse   Source File: DefinesViewer.java    License: 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
  }
}