org.eclipse.jface.viewers.ColumnLabelProvider Java Examples

The following examples show how to use org.eclipse.jface.viewers.ColumnLabelProvider. 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: 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 #2
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void addUserNameColumn(final StructuredViewer viewer) {
    final TableViewerColumn column = new TableViewerColumn((TableViewer) viewer, SWT.FILL);
    final TableColumn usernameColumn = column.getColumn();
    column.getColumn().setText(Messages.userName);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            return ((User) element).getUserName();
        }
    });

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

    final TableColumnSorter sorter = new TableColumnSorter((TableViewer) viewer);
    sorter.setColumn(usernameColumn);
}
 
Example #3
Source File: SelectRegisteredTemplatePage.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    setControl(container);
    container.setLayout(new FillLayout(SWT.HORIZONTAL | SWT.VERTICAL));

    final TreeViewer templatesTreeViewer = new TreeViewer(container, SWT.BORDER);
    templatesTreeViewer.setContentProvider(new CollectionContentProvider());
    templatesTreeViewer.setLabelProvider(new ColumnLabelProvider());
    final List<String> registeredTemplates = new ArrayList<>(TemplateRegistry.INSTANCE.getTemplates().keySet());
    Collections.sort(registeredTemplates);
    templatesTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            setSelectedTemplateURI(TemplateRegistry.INSTANCE.getTemplates()
                    .get(((IStructuredSelection) event.getSelection()).getFirstElement()));
            setPageComplete(selectedTemplateURI != null);
        }
    });
    templatesTreeViewer.setInput(registeredTemplates);
    setPageComplete(selectedTemplateURI != null);
}
 
Example #4
Source File: TmfSimpleTableViewer.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create a column for the table. The column will have a default width set,
 * and will be resizable, moveable and sortable.
 *
 * @param name
 *            the name of the column
 * @param provider
 *            the label provider of the column
 * @param comparator
 *            the comparator associated with clicking on the column, if it
 *            is null, a string comparator on the label will be used
 * @return the column that was created
 * @since 2.0
 */
public final <T> TableColumn createColumn(String name, ColumnLabelProvider provider, @Nullable Comparator<T> comparator) {
    TableViewerColumn col = new TableViewerColumn(fTableViewer, SWT.NONE);
    col.setLabelProvider(provider);
    final TableColumn column = col.getColumn();
    column.setWidth(DEFAULT_COL_WIDTH);
    column.setText(name);
    column.setResizable(true);
    column.setMoveable(true);
    if (comparator == null) {
        column.addSelectionListener(new ColumnSorter<>(column, new ColumnLabelComparator(provider)));
    } else {
        column.addSelectionListener(new ColumnSorter<>(column, comparator));
    }
    return column;
}
 
Example #5
Source File: TableViewerFontSize.java    From codeexamples-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@PostConstruct
public void postConstruct(Composite parent) {

	ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent);

	TreeViewer viewer = new TreeViewer(parent);
	viewer.setContentProvider(new TreeContentProvider());
	viewer.getTree().setHeaderVisible(true);
	viewer.getTree().setLinesVisible(true);
	viewer.getTree().setFont(resourceManager.createFont(FontDescriptor.createFrom("Arial", 32, SWT.ITALIC)));

	TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.NONE);
	viewerColumn.getColumn().setWidth(300);
	viewerColumn.getColumn().setText("Names");
	viewerColumn.setLabelProvider(new ColumnLabelProvider());

	viewer.setInput(new String[] { "Simon Scholz", "Lars Vogel", "Dirk Fauth", "Wim Jongman", "Tom Schindl" });

	GridLayoutFactory.fillDefaults().generateLayout(parent);
}
 
Example #6
Source File: ValidationViewPart.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void addErrorDescriptionColumn() {
    final TableViewerColumn elements = new TableViewerColumn(tableViewer,
            SWT.NONE);
    elements.getColumn().setText(
            Messages.validationViewDescriptionColumnName);
    elements.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {

            final Marker marker = (Marker) element;
            try {
                return (String) marker.getAttribute("message");
            } catch (final CoreException e) {
                return "";
            }
        }
    });
}
 
Example #7
Source File: PopulationInspectView.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private ColumnLabelProvider getColumnLabelProvider(final String title) {
	return new ColumnLabelProvider() {

		@Override
		public String getText(final Object element) {
			final IAgent agent = (IAgent) element;
			if (agent.dead() && !title.equals(ID_ATTRIBUTE)) { return "N/A"; }
			if (title.equals(ID_ATTRIBUTE)) { return String.valueOf(agent.getIndex()); }
			// final Object value;
			if (agent.getSpecies().hasVar(title)) {
				return Cast.toGaml(getScope().getAgentVarValue(agent, title));
			} else {
				return Cast.toGaml(agent.getAttribute(title));
			}
		}
	};
}
 
Example #8
Source File: ViewAttributeList.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new column
 * @param table
 * @param name
 * @param width
 * @param provider
 */
private TableViewerColumn createColumn(PageableTable table,
                                       String name, 
                                       int width,
                                       ColumnLabelProvider provider) {
    
    TableViewerColumn column = new TableViewerColumn(table.getViewer(), SWT.NONE);
    column.setLabelProvider(provider);
    TableColumn tColumn = column.getColumn();
    tColumn.setToolTipText(name);
    tColumn.setText(name);
    tColumn.setWidth(width);
    tColumn.setResizable(true);
    return column;
}
 
Example #9
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addDescriptionColumn(final TableViewer tViewer) {
    final TableViewerColumn column = new TableViewerColumn(tViewer, SWT.FILL);
    column.getColumn().setText(Messages.description);
    column.setLabelProvider(new ColumnLabelProvider() {

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

    column.getColumn().setWidth(90);
    column.getColumn().setMoveable(false);
    column.getColumn().setResizable(true);
}
 
Example #10
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 #11
Source File: SelectUserMappingWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createControl(final Composite parent) {
    super.createControl(parent);

    final Composite mainComposite = (Composite) getControl();
    final Composite viewersComposite = new Composite(mainComposite, SWT.NONE);
    viewersComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).span(2, 1).hint(SWT.DEFAULT, 250).create());
    viewersComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(5, 5).extendedMargins(0, 0, 10, 0).create());

    availableUserViewer = CheckboxTableViewer.newCheckList(viewersComposite, SWT.BORDER | SWT.FULL_SELECTION);
    availableUserViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    availableUserViewer.getTable().setHeaderVisible(true);
    availableUserViewer.setContentProvider(new ArrayContentProvider());
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(100));
    availableUserViewer.getTable().setLayout(layout);

    final TableViewerColumn columnViewer = new TableViewerColumn(availableUserViewer, SWT.NONE);
    final TableColumn usernameColumn = columnViewer.getColumn();
    usernameColumn.setText(Messages.userName);
    columnViewer.setLabelProvider(new ColumnLabelProvider());
    final TableColumnSorter sorter = new TableColumnSorter(availableUserViewer);
    sorter.setColumn(usernameColumn);

    availableUserViewer.setInput(availableUsers);
    availableUserViewer.setCheckedElements(selectedUsers.toArray());

}
 
Example #12
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addLastNameColumn(final StructuredViewer viewer) {
    final TableViewerColumn column = new TableViewerColumn((TableViewer) viewer, SWT.FILL);
    column.getColumn().setText(Messages.lastName);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            return ((User) element).getLastName();
        }
    });

    column.getColumn().setWidth(90);
    column.getColumn().setMoveable(false);
    column.getColumn().setResizable(true);
}
 
Example #13
Source File: ViewAttributeWeights.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new column
 * @param table
 * @param name
 * @param provider
 */
private TableViewerColumn createColumn(PageableTable table,
                                       String name,
                                       ColumnLabelProvider provider) {
    TableViewerColumn column = new TableViewerColumn(table.getViewer(), SWT.NONE);
    column.setLabelProvider(provider);
    TableColumn tColumn = column.getColumn();
    tColumn.setToolTipText(name);
    tColumn.setText(name);
    tColumn.setWidth(200);
    tColumn.setResizable(true);
    return column;
}
 
Example #14
Source File: ViewStatisticsClassificationAttributes.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new column
 * @param table
 * @param name
 * @param width
 * @param provider
 */
private TableViewerColumn createColumn(PageableTable table,
                                       String name, 
                                       int width,
                                       ColumnLabelProvider provider) {
    
    TableViewerColumn column = new TableViewerColumn(table.getViewer(), SWT.NONE);
    column.setLabelProvider(provider);
    TableColumn tColumn = column.getColumn();
    tColumn.setToolTipText(name);
    tColumn.setText(name);
    tColumn.setWidth(width);
    tColumn.setResizable(true);
    return column;
}
 
Example #15
Source File: ViewStatisticsQuality.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new column
 * @param table
 * @param name
 * @param width
 * @param provider
 */
private TableViewerColumn createColumn(PageableTable table,
                                       String name, 
                                       ColumnLabelProvider provider) {
    
    TableViewerColumn column = new TableViewerColumn(table.getViewer(), SWT.NONE);
    column.setLabelProvider(provider);
    TableColumn tColumn = column.getColumn();
    tColumn.setToolTipText(name);
    tColumn.setText(name);
    tColumn.setWidth(30);
    tColumn.setResizable(false);
    return column;
}
 
Example #16
Source File: RnDialogs.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent){
	Composite ret = new Composite(parent, SWT.NONE);
	ret.setLayout(new GridLayout());
	ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	
	new Label(ret, SWT.NONE).setText(Messages.RnDialogs_date); //$NON-NLS-1$
	dp = new DatePickerCombo(ret, SWT.NONE);
	dp.setDate(new Date());
	new Label(ret, SWT.NONE).setText(Messages.RnDialogs_amount); //$NON-NLS-1$
	// nf=NumberFormat.getCurrencyInstance();
	amount = new Text(ret, SWT.BORDER);
	// amount.setText(rn.getOffenerBetrag().getAmountAsString());
	amount.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.RnDialogs_remark); //$NON-NLS-1$
	bemerkung = new Text(ret, SWT.MULTI | SWT.BORDER);
	bemerkung.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	amount.setFocus();
	
	tableViewer = new TableViewer(ret, SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
	GridData gd_Table = new GridData();
	gd_Table.grabExcessHorizontalSpace = true;
	gd_Table.horizontalSpan = 1;
	gd_Table.minimumHeight = 100;
	gd_Table.heightHint = 100;
	tableViewer.getTable().setLayoutData(gd_Table);
	tableViewer.getTable().setHeaderVisible(true);
	tableViewer.getTable().setLinesVisible(false);
	tableViewer.setContentProvider(new ArrayContentProvider());
	TableViewerColumn colRnNumber = new TableViewerColumn(tableViewer, SWT.NONE);
	colRnNumber.getColumn().setWidth(200);
	colRnNumber.getColumn().setText(Messages.RnDialogs_invoiceNumber);
	colRnNumber.setLabelProvider(new ColumnLabelProvider());
	
	tableViewer.setInput(rnNumbers);
	
	return ret;
}
 
Example #17
Source File: RnDialogs.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent){
	Composite ret = new Composite(parent, SWT.NONE);
	ret.setLayout(new GridLayout());
	ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	Label lblSelectState = new Label(ret, SWT.NONE);
	lblSelectState.setText(Messages.RnDialogs_pleaseNewStateForMulti);
	
	cbStates = new Combo(ret, SWT.READ_ONLY);
	cbStates.setItems(RnStatus.getStatusTexts());
	cbStates.setVisibleItemCount(RnStatus.getStatusTexts().length);
	cbStates.select(rechnungen.get(0).getStatus());
	cbStates.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	
	tableViewer = new TableViewer(ret, SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
	GridData gd_Table = new GridData();
	gd_Table.grabExcessHorizontalSpace = true;
	gd_Table.horizontalSpan = 1;
	gd_Table.minimumHeight = 150;
	gd_Table.heightHint = 150;
	tableViewer.getTable().setLayoutData(gd_Table);
	tableViewer.getTable().setHeaderVisible(true);
	tableViewer.getTable().setLinesVisible(false);
	
	tableViewer.setContentProvider(new ArrayContentProvider());
	TableViewerColumn colRnNumber = new TableViewerColumn(tableViewer, SWT.NONE);
	colRnNumber.getColumn().setWidth(200);
	colRnNumber.getColumn().setText(Messages.RnDialogs_invoiceNumber);
	colRnNumber.setLabelProvider(new ColumnLabelProvider());
	
	tableViewer.setInput(rnNumbers);
	
	return ret;
}
 
Example #18
Source File: ServiceDiagnosePrefs.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void createColumn(final Composite parent, final TableViewer viewer){
	TableViewerColumn tvCol = new TableViewerColumn(viewer, SWT.NONE);
	tvCol.setLabelProvider(new ColumnLabelProvider());
	TableColumn column = tvCol.getColumn();
	column.setText("");
	column.setWidth(150);
	column.setResizable(false);
	column.setMoveable(false);
}
 
Example #19
Source File: SelectRoleMappingWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createControl(final Composite parent) {
    super.createControl(parent);

    final Composite mainComposite = (Composite) getControl();
    final Composite viewersComposite = new Composite(mainComposite, SWT.NONE);
    viewersComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 250).create());
    viewersComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(0, 0).extendedMargins(0, 0, 10, 0).equalWidth(false).create());

    availableRoleViewer = CheckboxTableViewer.newCheckList(viewersComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
    availableRoleViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    availableRoleViewer.getTable().setHeaderVisible(true);
    availableRoleViewer.setContentProvider(new ArrayContentProvider());
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(100));
    availableRoleViewer.getTable().setLayout(layout);

    final TableViewerColumn columnViewer = new TableViewerColumn(availableRoleViewer, SWT.NONE);
    final TableColumn usernameColumn = columnViewer.getColumn();
    usernameColumn.setText(Messages.roleName);
    columnViewer.setLabelProvider(new ColumnLabelProvider());
    final TableColumnSorter sorter = new TableColumnSorter(availableRoleViewer);
    sorter.setColumn(usernameColumn);

    availableRoleViewer.setInput(availableRoles);
    availableRoleViewer.setCheckedElements(selectedRoles.toArray());

}
 
Example #20
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addFirstNameColumn(final StructuredViewer viewer) {
    final TableViewerColumn column = new TableViewerColumn((TableViewer) viewer, SWT.FILL);
    column.getColumn().setText(Messages.firstName);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            return ((User) element).getFirstName();
        }
    });

    column.getColumn().setWidth(90);
    column.getColumn().setMoveable(false);
    column.getColumn().setResizable(true);
}
 
Example #21
Source File: NameBluemixWizardPage.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
    super.createControl(parent);
    
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = WizardUtils.createGridLayout(1, 5);
    container.setLayout(layout);

    _newRadio = WizardUtils.createRadio(container, "Create a new application:", 1, this);  // $NLX-NameBluemixWizardPage.Createanewapplication-1$
    _newRadio.setSelection(true);
    
    _nameText = WizardUtils.createText(container, 1, 20);
    _nameText.addModifyListener(this);

    _existingRadio = WizardUtils.createRadio(container, "Overwrite an existing application:", 1, this);  // $NLX-NameBluemixWizardPage.Overwriteanexistingapplication-1$

    _appViewer = WizardUtils.createTableViewer(container, 1, 1, null, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL, 20);
    ColumnViewerToolTipSupport.enableFor(_appViewer, ToolTip.NO_RECREATE);
    _appViewer.getTable().setToolTipText("Choose application"); // $NLX-NameBluemixWizardPage.ChooseApplication-1$
    _appViewer.getTable().setHeaderVisible(false);
    _appViewer.getTable().setLinesVisible(false);
    _appViewer.getTable().addControlListener(this);
    _appViewer.setContentProvider(new ArrayContentProvider());
    _appViewer.addSelectionChangedListener(this);
    _appViewer.getTable().addSelectionListener(this);
    
    // Create the only column
    TableViewerColumn col = new TableViewerColumn(_appViewer, SWT.LEFT);
    col.getColumn().setResizable(false);
    col.setLabelProvider(new ColumnLabelProvider());

    // Create Host Group
    _hostGroup = WizardUtils.createGroup(container, 3, 3);            
    WizardUtils.createLabel(_hostGroup, "Host:", 1); // $NLX-NameBluemixWizardPage.Host-1$
    _hostText = WizardUtils.createText(_hostGroup, 1, 0);
    _hostText.addModifyListener(this);
    _domainLabel = WizardUtils.createLabel(_hostGroup, "", 1);

    setControl(container);
}
 
Example #22
Source File: SelectRegistredTemplateDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    final TableViewer templatesTreeViewer = new TableViewer(container, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    Table table = templatesTreeViewer.getTable();
    final GridData gdTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gdTable.minimumWidth = TABLE_MINIMUM_WIDTH;
    gdTable.minimumHeight = TABLE_MINIMUM_HEIGHT;
    table.setLayoutData(gdTable);
    templatesTreeViewer.setContentProvider(new CollectionContentProvider());
    templatesTreeViewer.setLabelProvider(new ColumnLabelProvider());
    final List<String> registeredTemplates = new ArrayList<>(TemplateRegistry.INSTANCE.getTemplates().keySet());
    Collections.sort(registeredTemplates);
    templatesTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            templateURI = TemplateRegistry.INSTANCE.getTemplates()
                    .get(((IStructuredSelection) event.getSelection()).getFirstElement());
        }
    });
    templatesTreeViewer.setInput(registeredTemplates);

    return container;
}
 
Example #23
Source File: Bug469441.java    From nebula with 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) {
				Bug469441Person p = (Bug469441Person) element;
				return p.getFirstName();
			}

			@Override
			public void update(ViewerCell cell) {
				Bug469441Person obj = (Bug469441Person) cell.getItem().getData();

				TableItem item = (TableItem) cell.getItem();
				TableEditor editor = new TableEditor(item.getParent());
				editor.grabHorizontal = true;
				editor.grabVertical = true;

				Button button = new Button(viewer.getTable(), SWT.NONE);
				button.setText(obj.getFirstName());
				editor.setEditor(button, item, cell.getColumnIndex());
				editor.layout();

				editors.add(editor);
			}

		});
		col.getColumn().addSelectionListener(new SortTableColumnSelectionListener("name"));

	}
 
Example #24
Source File: LazyPageTableExample.java    From nebula with 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 #25
Source File: GridViewerSnippet7.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	try {
		final Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		final ImageRegistry reg = new ImageRegistry(display);
		reg.put("ICON", ImageDescriptor.createFromFile(
				GridViewerSnippet6.class, "th_vertical.gif"));

		GridTableViewer v = new GridTableViewer(shell, SWT.FULL_SELECTION
				| SWT.H_SCROLL | SWT.V_SCROLL);
		v.getGrid().setLinesVisible(true);
		v.getGrid().setHeaderVisible(true);
		v.setContentProvider(new ContentProvider("birthday", "commits",
				"bugs"));
		v.getGrid().setRowHeaderVisible(true);
		v.setRowHeaderLabelProvider(new ColumnLabelProvider() {
			@Override
			public String getText(Object element) {
				String propertyName = ((Mediator) element)
						.getPropertyName();
				return propertyName;
			}

		});

		List<Committer> committers = new ArrayList<Committer>();
		committers.add(new Committer("Tom Schindl", new Date(), 10, 5));
		committers
				.add(new Committer("Boris Bokowski", new Date(), 1000, 35));

		int i = 0;
		for (Committer committer : committers) {
			GridViewerColumn column = new GridViewerColumn(v, SWT.NONE);
			column.setEditingSupport(new EditingSupportImpl(v, i));
			column.setLabelProvider(new LabelProviderImpl(i));
			column.getColumn().setText(committer.getName());
			column.getColumn().setWidth(200);
			i++;
		}

		v.setInput(committers);

		shell.setSize(500, 200);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}

		display.dispose();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #26
Source File: SelectGroupMappingWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
  public void createControl(Composite parent) {
      super.createControl(parent) ;

      final Composite mainComposite = (Composite) getControl();
      final Composite viewersComposite = new Composite(mainComposite, SWT.NONE) ;
      viewersComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT,250).create()) ;
      viewersComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(0, 0).extendedMargins(0, 0, 10, 0).equalWidth(false).create()) ;

      availableGroupViewer = CheckboxTableViewer.newCheckList(viewersComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL) ;
      availableGroupViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create()) ;
      availableGroupViewer.getTable().setHeaderVisible(true) ;
      availableGroupViewer.setContentProvider(new ArrayContentProvider()) ;
      final TableLayout layout = new TableLayout() ;
      layout.addColumnData(new ColumnWeightData(100));
      availableGroupViewer.getTable().setLayout(layout) ;

      final TableViewerColumn columnViewer = new TableViewerColumn(availableGroupViewer, SWT.NONE) ;
      final TableColumn usernameColumn = columnViewer.getColumn() ;
      usernameColumn.setText(Messages.groupName);
      columnViewer.setLabelProvider(new ColumnLabelProvider());
      final TableColumnSorter sorter = new TableColumnSorter(availableGroupViewer) ;
      sorter.setColumn(usernameColumn) ;

      availableGroupViewer.setInput(availableGroups) ;
      availableGroupViewer.setCheckedElements(selectedGroups.toArray());
      
      context = new DataBindingContext();

      final IObservableSet checkedElementsObservable =  ViewersObservables.observeCheckedElements(availableGroupViewer, String.class) ;
      final MultiValidator notEmptyValidator = new MultiValidator() {

      	@Override
          protected IStatus validate() {
		if(groupSelectionIsValid(checkedElementsObservable)){
			return ValidationStatus.ok();
		}
		return ValidationStatus.error(Messages.errorSelectionGroups);
	}
      }  ;

      context.addValidationStatusProvider(notEmptyValidator);
context.bindSet(checkedElementsObservable, PojoObservables.observeSet(this, "selectedGroups"));

WizardPageSupport.create(this, context);
setControl(mainComposite);
  }
 
Example #27
Source File: ValidationViewPart.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void addElementNameColumn() {
    final TableViewerColumn elements = new TableViewerColumn(tableViewer,
            SWT.NONE);
    elements.getColumn().setText(Messages.validationViewElementColumnName);
    elements.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            final Marker marker = (Marker) element;
            try {

                final String elementId = (String) marker
                        .getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID);
                String location = (String) marker.getAttribute("location");
                int idx = location.lastIndexOf(":");
                if (idx > 0) {
                    String result = location.substring(idx + 1);

                    // get parent name if name is empty
                    if (result.trim().isEmpty() && idx - 1 > 0) {
                        location = location.substring(0, idx - 1);
                        idx = location.lastIndexOf(":");
                        result = location.substring(idx + 1);
                    }

                    if (!(result.startsWith("<") && result.endsWith(">"))) {
                        return result;
                    } else {
                        final DiagramRepositoryStore store = RepositoryManager
                                .getInstance().getRepositoryStore(
                                        DiagramRepositoryStore.class);
                        final DiagramFileStore file = store.getChild(marker
                                .getResource().getLocation().toFile()
                                .getName(), true);
                        if (file != null) {
                            final EObject view = file.getEMFResource()
                                    .getEObject(elementId);
                            if (view != null) {
                                for (final EObject object : view
                                        .eCrossReferences()) {
                                    if (object instanceof Element) {
                                        return ((Element) object).getName();
                                    }
                                }
                            }
                        }
                        return "";
                    }
                }

                return location;
            } catch (final CoreException e) {
                BonitaStudioLog.error(e);
                return "";
            }
        }
    });

}
 
Example #28
Source File: TmfBaseColumnDataProviderTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Method with test cases.
 */
@Test
public void testGetColumnData() {
    List<TmfBaseColumnData> columnsData = provider.getColumnData();
    assertNotNull("getColumnData", columnsData);
    assertEquals("getColumnData", 4, columnsData.size());

    TmfStatisticsTreeNode parentNode = fStatsData.getNode(fTestName);
    TmfStatisticsTreeNode treeNode1 = fStatsData.getNode(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getName());
    TmfStatisticsTreeNode treeNode2 = fStatsData.getNode(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent3.getName());
    ViewerComparator vComp = null;
    for (TmfBaseColumnData columnData : columnsData) {
        assertNotNull("getColumnData", columnData);
        assertNotNull("getColumnData", columnData.getHeader());
        assertNotNull("getColumnData", columnData.getTooltip());

        // Testing labelProvider
        ColumnLabelProvider labelProvider = columnData.getLabelProvider();
        if (columnData.getHeader().compareTo(LEVEL_COLUMN) == 0) {
            assertEquals("getColumnData", 0, labelProvider.getText(treeNode1).compareTo(treeNode1.getName()));
        } else if (columnData.getHeader().compareTo(EVENTS_COUNT_COLUMN) == 0) {
            // might not work because of machine local number format
            assertEquals("getColumnData", "1", labelProvider.getText(treeNode1));
        }

        // Testing comparator
        vComp = columnData.getComparator();
        if (columnData.getHeader().compareTo(LEVEL_COLUMN) == 0) {
            assertTrue("getColumnData", vComp.compare(null, treeNode1, treeNode2) < 0);
            assertTrue("getColumnData", vComp.compare(null, treeNode2, treeNode1) > 0);
            assertTrue("getColumnData", vComp.compare(null, treeNode1, treeNode1) == 0);
        } else if (columnData.getHeader().compareTo(EVENTS_COUNT_COLUMN) == 0) {
            assertTrue("getColumnData", vComp.compare(null, treeNode1, treeNode2) == 0);
            assertTrue("getColumnData", vComp.compare(null, treeNode2, treeNode1) == 0);
            assertTrue("getColumnData", vComp.compare(null, treeNode1, treeNode1) == 0);
        }

        // Testing percentage provider
        ITmfColumnPercentageProvider percentProvider = columnData.getPercentageProvider();
        if (columnData.getHeader().compareTo(LEVEL_COLUMN) == 0) {
            assertNull("getColumnData", percentProvider);
        } else if (columnData.getHeader().compareTo(EVENTS_COUNT_COLUMN) == 0) {
            double percentage = (double) treeNode1.getValues().getTotal() / parentNode.getValues().getTotal();
            assertEquals("getColumnData", percentage, percentProvider.getPercentage(treeNode1), DELTA);
        }
    }
}
 
Example #29
Source File: StringSortPageableTableExample.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	GridLayout layout = new GridLayout(2, false);
	shell.setLayout(layout);

	final List<String> items = createList();

	// 1) Create pageable table with 10 items per page
	// This SWT Component create internally a SWT Table+JFace TreeViewer
	int pageSize = 10;
	paginationTable = new PageableTable(shell, SWT.BORDER, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, pageSize);
	paginationTable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));

	// 2) Initialize the table viewer + SWT Table
	TableViewer viewer = paginationTable.getViewer();
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new LabelProvider());

	Table table = viewer.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(true);

	// 3) Create column by adding SortTableColumnSelectionListener listener
	// to sort the paginated table.
	TableViewerColumn col = createTableViewerColumn(viewer, "Name", 150);
	col.setLabelProvider(new ColumnLabelProvider() {
		@Override
		public String getText(Object element) {
			String p = (String) element;
			return p;
		}
	});

	// Call SortTableColumnSelectionListener with null property name because
	// it's a list of String.
	col.getColumn().addSelectionListener(new SortTableColumnSelectionListener(null));

	// 4) Set the page loader used to load a page (sublist of String)
	// according the page index selected, the page size etc.
	paginationTable.setPageLoader(new PageResultLoaderList<>(items));

	// 5) Set current page to 0 to display the first page
	paginationTable.setCurrentPage(0);

	Label lbl = new Label(shell, SWT.NONE);
	lbl.setText("Max rows per page: ");
	lbl.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));

	txt = new Text(shell, SWT.BORDER);
	txt.setText("10");
	GridData gd = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
	gd.widthHint = 30;
	txt.setLayoutData(gd);
	txt.addTraverseListener(e -> updatePageSize());
	txt.addListener(SWT.FocusOut, e -> updatePageSize());

	// paginationTable.getController().setPageSize(10);

	shell.setSize(550, 320);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example #30
Source File: TmfBaseColumnData.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Constructor with parameters
 *
 * @param h
 *            header of the column. The name will be shown at the top of the
 *            column.
 * @param w
 *            width of the column.
 * @param a
 *            alignment of the text
 * @param t
 *            text to shown as a tooltip when the cursor comes over the
 *            header
 * @param l
 *            provide all the column element
 * @param c
 *            used to compare element between them to be able to classify
 *            the content of the columns
 * @param p
 *            provide the percentage of a specific element
 */
public TmfBaseColumnData(String h, int w, int a, String t,
        ColumnLabelProvider l, ViewerComparator c,
        ITmfColumnPercentageProvider p) {
    fHeader = h;
    fWidth = w;
    fAlignment = a;
    fTooltip = t;
    fLabelProvider = l;
    fComparator = c;
    fPercentageProvider = p;
}