Example usage for org.eclipse.jface.viewers TableViewer TableViewer

List of usage examples for org.eclipse.jface.viewers TableViewer TableViewer

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers TableViewer TableViewer.

Prototype

public TableViewer(Table table) 

Source Link

Document

Creates a table viewer on the given table control.

Usage

From source file:ch.opentrainingcenter.client.views.dialoge.SearchDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    setTitle(Messages.SearchDialog_SEARCH);

    setMessage(Messages.SearchDialog_SEARCH_DESCRIPTION);
    setTitleImage(Activator.getImageDescriptor(IImageKeys.SEARCH_WIZ).createImage());
    final Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(separator);

    final Composite search = new Composite(parent, SWT.NONE);

    GridLayoutFactory.swtDefaults().numColumns(3).applyTo(search);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(search);

    final Label beschreibung = new Label(search, SWT.NONE);
    beschreibung.setText(Messages.SearchDialog_SEARCH_DESC_LABEL);
    GridDataFactory.swtDefaults().grab(false, false).applyTo(beschreibung);

    beschreibungSearch = new Text(search, SWT.NONE);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).span(2, 1)
            .applyTo(beschreibungSearch);
    beschreibungSearch.addKeyListener(new KeyAdapter() {
        @Override//from w  w w  .  j a  v  a2  s. c om
        public void keyReleased(final KeyEvent e) {
            update();
        }
    });

    final Label minDistanz = new Label(search, SWT.NONE);
    minDistanz.setText(Messages.SearchDialog_SEARCH_DIST_LABEL);
    GridDataFactory.swtDefaults().grab(false, false).applyTo(minDistanz);

    scale = new Scale(search, SWT.BORDER);
    GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(scale);

    scale.setMaximum(80);
    scale.setPageIncrement(5);
    scale.setSelection(0);
    scale.setIncrement(5);
    scale.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            super.widgetSelected(e);
            update();

        }
    });

    scaleLabel = new Label(search, SWT.NONE);
    scaleLabel.setText(scale.getSelection() + Messages.SearchDialog_COMMON_KM);
    GridDataFactory.swtDefaults().grab(false, false).hint(50, 20).applyTo(scaleLabel);

    // sportart
    final Composite sport = new Composite(search, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(3).applyTo(sport);
    GridDataFactory.swtDefaults().grab(true, true).span(3, 1).align(SWT.FILL, SWT.FILL).applyTo(sport);
    runButton = new Button(sport, SWT.CHECK);
    runButton.setText(Sport.RUNNING.getTranslated());
    runButton.setVisible(running);
    runButton.setSelection(running);
    runButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            super.widgetSelected(e);
            update();

        }
    });

    bikeButton = new Button(sport, SWT.CHECK);
    bikeButton.setText(Sport.BIKING.getTranslated());
    bikeButton.setVisible(biking);
    bikeButton.setSelection(biking);
    bikeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            super.widgetSelected(e);
            update();

        }
    });

    otherButton = new Button(sport, SWT.CHECK);
    otherButton.setText(Sport.OTHER.getTranslated());
    otherButton.setVisible(other);
    otherButton.setSelection(biking);
    otherButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            super.widgetSelected(e);
            update();

        }
    });

    // Strecke
    final Composite strecke = new Composite(search, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(3).applyTo(strecke);
    final Label l = new Label(strecke, SWT.NONE);
    l.setText(Messages.STRECKE);
    GridDataFactory.swtDefaults().grab(true, true).span(3, 1).align(SWT.FILL, SWT.FILL).applyTo(strecke);

    comboStrecke = new ComboViewer(strecke);
    comboStrecke.setContentProvider(ArrayContentProvider.getInstance());
    comboStrecke.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(final Object element) {
            String label = ""; //$NON-NLS-1$
            if (element instanceof IRoute) {
                final IRoute route = (IRoute) element;
                label = route.getName();
            }
            return label;
        }
    });
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL)
            .applyTo(comboStrecke.getControl());

    final List<IRoute> all = cache.getAll();
    comboStrecke.setInput(all);

    comboStrecke.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            final StructuredSelection selection = (StructuredSelection) event.getSelection();
            final IRoute route = (IRoute) selection.getFirstElement();
            referenzTrainingId = route.getId();
            update();
        }
    });

    // result ---------------------------
    final Composite result = new Composite(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().applyTo(result);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(result);
    viewer = new TableViewer(result);
    comparator = new SearchDialogComparator();
    viewer.setComparator(comparator);

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

    viewer.setContentProvider(new ArrayContentProvider());
    // viewer.setLabelProvider(new TrainingLabelProvider());
    createColumns(result, viewer);

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent selection) {
            updateButton();
        }

    });

    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(viewer.getControl());

    update();
    return search;
}

From source file:ch.unibe.iam.scg.archie.controller.TableFactory.java

License:Open Source License

/**
 * Creates a tableviewer from the given provider.
 * /* w  w w .j  a  va  2s .  c  o  m*/
 * @param parent
 *            Composite that holds the table.
 * @param dataset
 * @param labelProvider
 * @param contentProvider
 * @return Table
 */
public TableViewer createTableFromData(final Composite parent, final DataSet dataset,
        final ILabelProvider labelProvider, final IContentProvider contentProvider) {
    Table table = this.createTable(parent, dataset);

    // Create table viewer and set providers.
    TableViewer tableViewer = new TableViewer(table);

    // Set providers.
    tableViewer.setLabelProvider(labelProvider);
    tableViewer.setContentProvider(contentProvider);

    // Invoke the inputChanged method after a content provider is set.
    tableViewer.setInput(table);

    // add column sorters.
    this.addColumnSort(tableViewer);

    return tableViewer;
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.editor.ApplicationDetailsPart.java

License:Open Source License

private TableViewer createTableViewer(Composite parent, String[] columnNames, String[] columnTooltips,
        int[] columnWeights) {

    // Composite container = toolkit.createComposite(parent);
    // GridDataFactory.fillDefaults().grab(true, true).applyTo(container);
    // TableColumnLayout layout = new TableColumnLayout();
    // container.setLayout(layout);

    Table table = toolkit.createTable(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
    table.setHeaderVisible(true);// w  ww.  ja va 2  s  .  c  o  m

    for (int i = 0; i < columnNames.length; i++) {
        TableColumn col = new TableColumn(table, SWT.NONE);
        col.setWidth(columnWeights[i]);
        col.setText(columnNames[i]);
        if (columnTooltips == null) {
            col.setToolTipText(null);
        } else {
            col.setToolTipText(columnTooltips[i]);
        }
        // layout.setColumnData(col, new
        // ColumnWeightData(columnWeights[i]));
    }

    TableViewer tableViewer = new TableViewer(table);
    tableViewer.setColumnProperties(columnNames);
    return tableViewer;
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.editor.ApplicationMasterPart.java

License:Open Source License

private void createApplicationsSection() {
    Section section = getSection();//from w w  w .ja  va  2s. c o  m
    section.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(section);
    section.setText(Messages.COMMONTXT_APPLICATIONS);
    section.setDescription(Messages.ApplicationMasterPart_TEXT_APP_DESCRIP);

    Composite client = toolkit.createComposite(section);
    client.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(client);
    section.setClient(client);

    Composite headerComposite = toolkit.createComposite(section, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 0;
    rowLayout.marginBottom = 0;
    headerComposite.setLayout(rowLayout);
    headerComposite.setBackground(null);

    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    toolBarManager.createControl(headerComposite);

    applicationsViewer = new TableViewer(toolkit.createTable(client, SWT.NONE));
    applicationsViewer.setContentProvider(new TreeContentProvider());
    applicationsViewer.setLabelProvider(new ServerLabelProvider() {
        @Override
        public Image getImage(Object element) {
            Image image = super.getImage(element);

            if (element instanceof IModule) {
                IModule module = (IModule) element;
                DockerFoundryApplicationModule appModule = editorPage.getCloudServer()
                        .getExistingCloudModule(module);
                if (appModule != null && appModule.getErrorMessage() != null) {
                    return DockerFoundryImages.getImage(new DecorationOverlayIcon(image,
                            DockerFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT));
                }
            }

            return image;
        }

        @Override
        public String getText(Object element) {
            // This is the WTP module name (usually, it's the workspace
            // project name)
            String moduleName = super.getText(element);

            // However, the user has the option to specify a different name
            // when pushing an app, which is used as the cf app name. If
            // they are different, and the
            // corresponding workspace project is accessible, show both.
            // Otherwise, show the cf app name.

            if (element instanceof IModule) {

                IModule module = (IModule) element;

                // Find the corresponding Cloud Foundry-aware application
                // Module.
                DockerFoundryApplicationModule appModule = cloudServer
                        .getExistingCloudModule((IModule) element);

                if (appModule != null) {
                    String cfAppName = appModule.getDeployedApplicationName();

                    if (cfAppName != null) {

                        // Be sure not to show a null WTP module name,
                        // although
                        // that should not be encountered
                        if (moduleName != null && !cfAppName.equals(moduleName)
                                && DockerFoundryProperties.isModuleProjectAccessible
                                        .testProperty(new IModule[] { module }, cloudServer)) {
                            moduleName = cfAppName + " (" + moduleName + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                        } else {
                            moduleName = cfAppName;
                        }
                    }
                }
            }

            return moduleName;
        }

    });
    applicationsViewer.setInput(new CloudApplication[0]);
    applicationsViewer.setSorter(new DockerFoundryViewerSorter());

    applicationsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            IModule module = (IModule) selection.getFirstElement();

            if (currentModule != module) {
                currentModule = module;
                getManagedForm().fireSelectionChanged(ApplicationMasterPart.this, selection);
            }
        }
    });
    GridDataFactory.fillDefaults().grab(true, true).hint(250, SWT.DEFAULT)
            .applyTo(applicationsViewer.getControl());

    int ops = DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;
    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
    ApplicationViewersDropAdapter listener = new ApplicationViewersDropAdapter(applicationsViewer);
    applicationsViewer.addDropSupport(ops, transfers, listener);

    // create context menu
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            fillApplicationsContextMenu(manager);
        }
    });

    Menu menu = menuManager.createContextMenu(applicationsViewer.getControl());
    applicationsViewer.getControl().setMenu(menu);
    editorPage.getSite().registerContextMenu(menuManager, applicationsViewer);

    Action addRemoveApplicationAction = new Action(Messages.ApplicationMasterPart_TEXT_ADD_REMOVE,
            ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_MODIFY_MODULES)) {
        @Override
        public void run() {
            ModifyModulesWizard wizard = new ModifyModulesWizard(cloudServer.getServerOriginal());
            WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
            dialog.open();
        }
    };
    toolBarManager.add(addRemoveApplicationAction);

    // Fix for STS-2996. Moved from CloudFoundryApplicationsEditorPage
    toolBarManager.add(RefreshEditorAction.getRefreshAction(editorPage, null));
    toolBarManager.update(true);
    section.setTextClient(headerComposite);

    getManagedForm().getToolkit().paintBordersFor(client);
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.editor.ApplicationMasterPart.java

License:Open Source License

private void createServicesSection() {
    servicesSection = toolkit.createSection(getSection().getParent(),
            Section.TITLE_BAR | Section.DESCRIPTION | Section.TWISTIE);
    servicesSection.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(servicesSection);
    servicesSection.setText(Messages.COMMONTXT_SERVICES);
    servicesSection.setExpanded(true);//from   w  w  w .  ja va 2 s . c  om
    servicesSection.setDescription(Messages.ApplicationMasterPart_TEXT_SERVICES_DESCRIP);
    // NOTE:Comment out as keeping section collapsed by default causes zero
    // height tables if no services are provided
    // servicesSection.addExpansionListener(new ExpansionAdapter() {
    //
    // @Override
    // public void expansionStateChanged(ExpansionEvent e) {
    // userExpanded = true;
    // }
    // });

    Composite client = toolkit.createComposite(servicesSection);
    client.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(client);
    servicesSection.setClient(client);

    Composite headerComposite = toolkit.createComposite(servicesSection, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 0;
    rowLayout.marginBottom = 0;
    headerComposite.setLayout(rowLayout);
    headerComposite.setBackground(null);

    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    toolBarManager.createControl(headerComposite);

    servicesViewer = new TableViewer(toolkit.createTable(client, SWT.MULTI));
    new ServiceViewerConfigurator().configureViewer(servicesViewer);

    servicesViewer.setContentProvider(new TreeContentProvider());
    servicesViewer.setLabelProvider(new ServicesTreeLabelProvider(servicesViewer) {

        protected Image getColumnImage(CloudService service, ServiceViewColumn column) {
            return null;
        }

    });
    servicesViewer.setSorter(new ServiceViewerSorter(servicesViewer) {

        @Override
        protected int compare(DockerApplicationService service1, DockerApplicationService service2,
                ServiceViewColumn sortColumn) {

            return super.compare(service1, service2, sortColumn);
        }

    });
    DockerApplicationService[] servicesArray = new DockerApplicationService[this.services.size()];
    this.services.toArray(servicesArray);
    servicesViewer.setInput(servicesArray);
    //      servicesViewer.setInput(this.services);

    GridDataFactory.fillDefaults().grab(true, true).applyTo(servicesViewer.getControl());

    //      Action addServiceAction = new Action(Messages.COMMONTXT_ADD_SERVICE, CloudFoundryImages.NEW_SERVICE) {
    //         @Override
    //         public void run() {
    //            CloudFoundryServiceWizard wizard = new CloudFoundryServiceWizard(cloudServer);
    //            WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
    //            wizard.setParent(dialog);
    //            dialog.setPageSize(900, 600);
    //            dialog.setBlockOnOpen(true);
    //            dialog.open();
    //         }
    //      };
    //      toolBarManager.add(addServiceAction);
    //      toolBarManager.update(true);
    servicesSection.setTextClient(headerComposite);

    // create context menu
    //      MenuManager menuManager = new MenuManager();
    //      menuManager.setRemoveAllWhenShown(true);
    //      menuManager.addMenuListener(new IMenuListener() {
    //
    //         public void menuAboutToShow(IMenuManager manager) {
    //            fillServicesContextMenu(manager);
    //         }
    //      });

    //      Menu menu = menuManager.createContextMenu(servicesViewer.getControl());
    //      servicesViewer.getControl().setMenu(menu);
    //      editorPage.getSite().registerContextMenu(menuManager, servicesViewer);

    // Create drag source on the table
    int ops = DND.DROP_COPY;
    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
    DragSourceAdapter listener = new DragSourceAdapter() {
        @Override
        public void dragSetData(DragSourceEvent event) {
            IStructuredSelection selection = (IStructuredSelection) servicesViewer.getSelection();
            event.data = selection.getFirstElement();
            LocalSelectionTransfer.getTransfer().setSelection(selection);
        }

        @Override
        public void dragStart(DragSourceEvent event) {
            if (event.detail == DND.DROP_NONE || event.detail == DND.DROP_DEFAULT) {
                event.detail = DND.DROP_COPY;
            }
            dragSetData(event);
        }

    };
    servicesViewer.addDragSupport(ops, transfers, listener);

    getManagedForm().getToolkit().paintBordersFor(client);

}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.EnvironmentVariablesPart.java

License:Open Source License

public Control createPart(Composite parent) {
    Composite commonArea = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(commonArea);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(commonArea);

    Composite tableParent = new Composite(commonArea, SWT.NONE);

    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(tableParent);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tableParent);

    Table table = new Table(tableParent, SWT.BORDER | SWT.MULTI);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
    envVariablesViewer = new TableViewer(table);
    //      Listener actionEnabler = new Listener() {
    //         @Override
    //         public void handleEvent(Event event) {
    //            setEnabledDisabled();
    //         }//from ww  w  . jav a2  s .  c om
    //      };

    //      table.addListener(SWT.Selection, actionEnabler);
    //      table.addListener(SWT.FocusOut, actionEnabler);
    envVariablesViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof Collection) {
                return ((Collection<?>) inputElement).toArray(new Object[0]);
            }
            return null;
        }

        public void dispose() {

        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {

        }

    });

    envVariablesViewer.setLabelProvider(new EnvVarLabelProvider(envVariablesViewer));

    table.setHeaderVisible(true);

    new TableResizeHelper(envVariablesViewer).enableResizing();

    int columnIndex = 0;
    ViewColumn[] columns = ViewColumn.values();
    String[] columnProperties = new String[columns.length];

    for (ViewColumn column : columns) {
        columnProperties[columnIndex] = column.name();
        TableColumn tableColumn = new TableColumn(table, SWT.NONE, columnIndex++);
        tableColumn.setData(column);
        tableColumn.setText(column.name());
        tableColumn.setWidth(column.getWidth());
    }

    envVariablesViewer.setColumnProperties(columnProperties);

    //      addEditButtons(commonArea);
    return commonArea;
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.wizards.MappedURLsWizardPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(10, LayoutConstants.getSpacing().y)
            .applyTo(composite);//w  w w . j a v  a 2 s .co m

    Label label = new Label(composite, SWT.NONE);
    label.setText(Messages.MappedURLsWizardPage_LABEL_APP_URI);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(label);

    Table table = new Table(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);

    viewer = new TableViewer(table);
    viewer.setContentProvider(new URIsContentProvider());
    viewer.setInput(urls);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            removeButton.setEnabled(!selection.isEmpty());
            editButton.setEnabled(!selection.isEmpty() && selection instanceof IStructuredSelection
                    && ((IStructuredSelection) selection).toArray().length == 1);
        }
    });

    Composite buttonComposite = new Composite(composite, SWT.NONE);
    GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(buttonComposite);
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.FILL).applyTo(buttonComposite);

    addButton = new Button(buttonComposite, SWT.PUSH);
    addButton.setText(Messages.COMMONTXT_ADD);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, false).applyTo(addButton);
    addButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            ApplicationURLWizard wizard = new ApplicationURLWizard(cloudServer, null);
            WizardDialog dialog = new WizardDialog(addButton.getShell(), wizard);
            if (dialog.open() == Dialog.OK) {
                String newURI = wizard.getUrl();
                urls.add(newURI);
                update();
            }
        }
    });

    editButton = new Button(buttonComposite, SWT.PUSH);
    editButton.setText(Messages.COMMONTXT_EDIT);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, false).applyTo(editButton);
    editButton.setEnabled(false);
    editButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            String url = (String) selection.getFirstElement();

            ApplicationURLWizard wizard = new ApplicationURLWizard(cloudServer, url);
            WizardDialog dialog = new WizardDialog(addButton.getShell(), wizard);
            if (dialog.open() == Dialog.OK) {
                String newURI = wizard.getUrl();
                urls.remove(url);
                urls.add(newURI);
                update();
            }
        }
    });

    removeButton = new Button(buttonComposite, SWT.PUSH);
    removeButton.setText(Messages.COMMONTXT_REMOVE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, false).applyTo(addButton);
    removeButton.setEnabled(false);
    removeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            Object[] selectedURLs = selection.toArray();
            for (Object selectedURL : selectedURLs) {
                urls.remove(selectedURL);
                update();
            }
        }
    });

    Dialog.applyDialogFont(composite);
    setControl(composite);
}

From source file:cn.edu.pku.ogeditor.properties.ObjectsSection.java

License:Open Source License

public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    Composite container = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;//  w ww  .  j ava  2s  .c o m
    // composite.setLayout(new FillLayout());

    CLabel listLabel = getWidgetFactory().createCLabel(container, "All detectable objects:"); //$NON-NLS-1$

    Table table = new Table(container, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
    TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setText("URIs");
    column1.setWidth(400);
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setWidth(LABEL_LENGTH);
    column2.setText("RFID");
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setWidth(LABEL_LENGTH);
    column3.setText("TYPE");
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    viewer = new TableViewer(table);
    viewer.setContentProvider(new TableContentProvider());
    viewer.setLabelProvider(new TableLabelProvider());

    //      objects = new ObjectsListModel();
    //      viewer.setInput(objects);
    //
    //      objects.add(new ObjectInfo("http://object1", "001", "light"));
    //      objects.add(new ObjectInfo("http://object2", "002", "air-conditioning"));
    //      objects.add(new ObjectInfo("http://object3", "003", "screen"));

    Button button = getWidgetFactory().createButton(container, "Edit", SWT.PUSH);

    data = new FormData();
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    data.top = new FormAttachment(0);
    listLabel.setLayoutData(data);

    data = new FormData();
    data.left = new FormAttachment(listLabel, 0, SWT.LEFT);
    data.right = new FormAttachment(90);
    data.top = new FormAttachment(listLabel, 0, SWT.BOTTOM);
    data.bottom = new FormAttachment(listLabel, 180, SWT.BOTTOM);

    table.setLayoutData(data);

    data = new FormData();
    data.left = new FormAttachment(table);
    data.right = new FormAttachment(100);
    data.top = new FormAttachment(table, 0, SWT.TOP);
    button.setLayoutData(data);
    button.addSelectionListener(new ButtonListener());
}

From source file:co.turnus.analysis.profiler.orcc.ui.widget.BufferSizeTableWidget.java

License:Open Source License

public BufferSizeTableWidget(Composite parent, AbstractLaunchTab owner) {
    super(ORCC_FIFO_MAPPING, "Buffer Size Mapping Table", "Define the buffer size for each connection",
            new HashMap<String, String>(), 1, parent, owner);

    Label lbl = new Label(getComposite(), SWT.NONE);
    lbl.setFont(getFont());/*from   w w w . j  a v a2  s .co  m*/
    lbl.setText("Custum FIFO connections buffer size:");
    lbl.setToolTipText(toolTip);
    lbl.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));

    mapping = getValue();
    connections = new HashSet<Connection>();

    table = new Table(getComposite(), SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    viewer = new TableViewer(table);
    comparator = new ContentComparator();
    viewer.setComparator(comparator);

    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 3;
    gridData.heightHint = 300;
    table.setLayoutData(gridData);

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

    // column: source actor
    TableColumn column = new TableColumn(table, SWT.LEFT, SRC_ACTOR);
    column.setText(columnNames[SRC_ACTOR]);
    column.setWidth(100);
    column.addSelectionListener(getSelectionAdapter(column, SRC_ACTOR));

    // column: source port
    column = new TableColumn(table, SWT.LEFT, SRC_PORT);
    column.setText(columnNames[SRC_PORT]);
    column.setWidth(100);
    column.addSelectionListener(getSelectionAdapter(column, SRC_PORT));

    // column: target actor
    column = new TableColumn(table, SWT.LEFT, TGT_ACTOR);
    column.setText(columnNames[TGT_ACTOR]);
    column.setWidth(100);
    column.addSelectionListener(getSelectionAdapter(column, TGT_ACTOR));

    // column: target port
    column = new TableColumn(table, SWT.LEFT, TGT_PORT);
    column.setText(columnNames[TGT_PORT]);
    column.setWidth(100);
    column.addSelectionListener(getSelectionAdapter(column, TGT_PORT));

    // column: size
    column = new TableColumn(table, SWT.LEFT, SIZE);
    column.setText(columnNames[SIZE]);
    column.setWidth(100);
    column.addSelectionListener(getSelectionAdapter(column, SIZE));

    // create the table viewer
    viewer.setUseHashlookup(true);
    viewer.setColumnProperties(columnNames);
    viewer.setContentProvider(new ContentProvider());
    viewer.setLabelProvider(new TableLabelProvider());

    // Create the cell editors
    CellEditor[] editors = new CellEditor[columnNames.length];
    editors[SIZE] = new TextCellEditor(table);
    // set the editors
    viewer.setCellEditors(editors);
    viewer.setCellModifier(new CellModifier());

    // reload from XDF and clear mapping buttons
    Composite composite = new Composite(getComposite(), SWT.SHADOW_NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));

    Button realodXdfMappingButton = new Button(composite, SWT.PUSH);
    realodXdfMappingButton.setFont(getFont());
    realodXdfMappingButton.setLayoutData(new GridData(SWT.BORDER, SWT.CENTER, false, false));
    realodXdfMappingButton.setText("Reload from XDF");
    realodXdfMappingButton.addSelectionListener(new RealoadXdfBuffonListener());

    Button clearButton = new Button(composite, SWT.PUSH);
    clearButton.setFont(getFont());
    clearButton.setLayoutData(new GridData(SWT.BORDER, SWT.CENTER, false, false));
    clearButton.setText("Clear All");
    clearButton.addSelectionListener(new ClearButtonListener());
}

From source file:co.turnus.ui.editor.BufferSizeEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;//from  w  ww  .j  a  v  a 2s  .  c  om
    parent.setLayout(gridLayout);

    String network = document.getDocumentElement().getAttribute(BXDF_NETWORK);
    Label lbl = new Label(parent, SWT.NONE);
    lbl.setFont(parent.getFont());
    lbl.setText("Buffer size configuration for the network: \"" + network + "\"");
    lbl.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    lbl = new Label(composite, SWT.NONE);
    lbl.setFont(parent.getFont());
    lbl.setText("Default buffer size: ");
    lbl.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));

    int size = Integer.parseInt(document.getDocumentElement().getAttribute(BXDF_DEFAULT_SIZE));
    defaultSize = new Spinner(composite, SWT.NONE);
    defaultSize.setMinimum(0);
    defaultSize.setMaximum(Integer.MAX_VALUE);
    defaultSize.setIncrement(1);
    defaultSize.setSelection(size);
    defaultSize.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            document.getDocumentElement().setAttribute(BXDF_DEFAULT_SIZE, defaultSize.getText());
            setDirty(true);
        }
    });

    table = new Table(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    viewer = new TableViewer(table);
    comparator = new ContentComparator();
    viewer.setComparator(comparator);

    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 3;
    gridData.heightHint = 300;
    table.setLayoutData(gridData);

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

    // column: source actor
    TableColumn column = new TableColumn(table, SWT.LEFT, SRC_ACTOR);
    column.setText(columnNames[SRC_ACTOR]);
    column.setWidth(100);
    column.addSelectionListener(getSelectionAdapter(column, SRC_ACTOR));

    // column: source port
    column = new TableColumn(table, SWT.LEFT, SRC_PORT);
    column.setText(columnNames[SRC_PORT]);
    column.setWidth(100);
    column.addSelectionListener(getSelectionAdapter(column, SRC_PORT));

    // column: target actor
    column = new TableColumn(table, SWT.LEFT, TGT_ACTOR);
    column.setText(columnNames[TGT_ACTOR]);
    column.setWidth(100);
    column.addSelectionListener(getSelectionAdapter(column, TGT_ACTOR));

    // column: target port
    column = new TableColumn(table, SWT.LEFT, TGT_PORT);
    column.setText(columnNames[TGT_PORT]);
    column.setWidth(100);
    column.addSelectionListener(getSelectionAdapter(column, TGT_PORT));

    // column: size
    column = new TableColumn(table, SWT.LEFT, SIZE);
    column.setText(columnNames[SIZE]);
    column.setWidth(100);
    column.addSelectionListener(getSelectionAdapter(column, SIZE));

    // create the table viewer
    viewer.setUseHashlookup(true);
    viewer.setColumnProperties(columnNames);
    viewer.setContentProvider(new ContentProvider());
    viewer.setLabelProvider(new TableLabelProvider());

    // Create the cell editors
    CellEditor[] editors = new CellEditor[columnNames.length];
    editors[SIZE] = new TextCellEditor(table);
    // set the editors
    viewer.setCellEditors(editors);
    viewer.setCellModifier(new CellModifier());

    viewer.setInput(document);
}