Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.TableViewer


        Composite composite = toolkit.createComposite(section);
        section.setClient(composite);

        table = toolkit.createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);

        viewer = new TableViewer(table);
        viewer.setContentProvider(new ArrayContentProvider());
        viewer.setLabelProvider(new PrivatePackageTableLabelProvider());

        // Listeners
        viewer.addSelectionChangedListener(new ISelectionChangedListener() {
View Full Code Here


     *            number of columns to span
     */
    protected void createSuperInterfacesControls(Composite composite, int nColumns) {
        final String INTERFACE = "interface"; //$NON-NLS-1$
        fSuperInterfacesDialogField.doFillIntoGrid(composite, nColumns);
        final TableViewer tableViewer = fSuperInterfacesDialogField.getTableViewer();
        tableViewer.setColumnProperties(new String[] {
            INTERFACE
        });

        TableTextCellEditor cellEditor = new TableTextCellEditor(tableViewer, 0) {
            @Override
            protected void doSetFocus() {
                if (text != null) {
                    text.setFocus();
                    text.setSelection(text.getText().length());
                    checkSelection();
                    checkDeleteable();
                    checkSelectable();
                }
            }
        };
        JavaTypeCompletionProcessor superInterfaceCompletionProcessor = new JavaTypeCompletionProcessor(false, false, true);
        superInterfaceCompletionProcessor.setCompletionContextRequestor(new CompletionContextRequestor() {
            @Override
            public StubTypeContext getStubTypeContext() {
                return getSuperInterfacesStubTypeContext();
            }
        });
        SubjectControlContentAssistant contentAssistant = ControlContentAssistHelper.createJavaContentAssistant(superInterfaceCompletionProcessor);
        Text cellEditorText = cellEditor.getText();
        ContentAssistHandler.createHandlerForText(cellEditorText, contentAssistant);
        TextFieldNavigationHandler.install(cellEditorText);
        cellEditor.setContentAssistant(contentAssistant);

        tableViewer.setCellEditors(new CellEditor[] {
            cellEditor
        });
        tableViewer.setCellModifier(new ICellModifier() {
            public void modify(Object element, String property, Object value) {
                Object el = element;
                if (el instanceof Item)
                    el = ((Item) el).getData();

                ((InterfaceWrapper) el).interfaceName = (String) value;
                fSuperInterfacesDialogField.elementChanged((InterfaceWrapper) el);
            }

            public Object getValue(Object element, String property) {
                return ((InterfaceWrapper) element).interfaceName;
            }

            public boolean canModify(Object element, String property) {
                return true;
            }
        });
        tableViewer.getTable().addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent event) {
                if (event.keyCode == SWT.F2 && event.stateMask == 0) {
                    ISelection selection = tableViewer.getSelection();
                    if (!(selection instanceof IStructuredSelection))
                        return;
                    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                    tableViewer.editElement(structuredSelection.getFirstElement(), 0);
                }
            }
        });
        GridData gd = (GridData) fSuperInterfacesDialogField.getListControl(null).getLayoutData();
        if (fTypeKind == CLASS_TYPE) {
View Full Code Here

        Label lblDirect = new Label(container, SWT.NONE);
        lblDirect.setFont(JFaceResources.getBannerFont());
        lblDirect.setText("Direct Dependencies:");

        Table tblDirect = new Table(container, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
        viewerDirect = new TableViewer(tblDirect);
        viewerDirect.setContentProvider(ArrayContentProvider.getInstance());
        viewerDirect.setLabelProvider(new ResourceDescriptorLabelProvider());

        createHelpLabel(container, "The above dependencies will be added to the project and, if necessary, to the JPM4J local index.");
View Full Code Here

        sectRequired.setLayoutData(gd);

        Table tblRequired = toolkit.createTable(sectRequired, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL);
        sectRequired.setClient(tblRequired);

        requiredViewer = new TableViewer(tblRequired);
        requiredViewer.setContentProvider(ArrayContentProvider.getInstance());
        requiredViewer.setLabelProvider(new ResourceLabelProvider());
        requiredViewer.setSorter(new BundleSorter());

        requiredViewer.addSelectionChangedListener(new ISelectionChangedListener() {
View Full Code Here

        lblSelectedPackages.setText("Selected Packages:");

        tblAvailable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
        tblAvailable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

        availableViewer = new TableViewer(tblAvailable);
        availableViewer.setContentProvider(ArrayContentProvider.getInstance());
        availableViewer.setLabelProvider(new PackageNameLabelProvider());
        availableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            public void selectionChanged(SelectionChangedEvent event) {
                updateUI();
            }
        });
        availableViewer.addDoubleClickListener(new IDoubleClickListener() {
            public void doubleClick(DoubleClickEvent event) {
                doAddSelection();
            }
        });

        Composite composite_1 = new Composite(composite, SWT.NONE);
        GridLayout gl_composite_1 = new GridLayout(1, false);
        gl_composite_1.marginWidth = 0;
        gl_composite_1.marginHeight = 0;
        composite_1.setLayout(gl_composite_1);

        btnAdd = new Button(composite_1, SWT.NONE);
        btnAdd.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        btnAdd.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                doAddSelection();
            }
        });
        btnAdd.setText("Add ->");
        btnAdd.setEnabled(false);

        btnAddAll = new Button(composite_1, SWT.NONE);
        btnAddAll.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        btnAddAll.setText("Add All ->");
        btnAddAll.setEnabled(false);
        btnAddAll.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                doAddAll();
            }
        });

        btnRemove = new Button(composite_1, SWT.NONE);
        btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        btnRemove.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                doRemoveSelection();
            }
        });

        btnRemove.setText("<- Remove");
        btnRemove.setEnabled(false);

        btnRemoveAll = new Button(composite_1, SWT.NONE);
        btnRemoveAll.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        btnRemoveAll.setText("<- Remove All");
        btnRemoveAll.setEnabled(false);
        btnRemoveAll.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                doRemoveAll();
            }
        });

        tblSelected = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
        tblSelected.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

        selectedViewer = new TableViewer(tblSelected);
        selectedViewer.setContentProvider(ArrayContentProvider.getInstance());
        selectedViewer.setLabelProvider(new PackageNameLabelProvider());
        selectedViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            public void selectionChanged(SelectionChangedEvent event) {
                updateUI();
View Full Code Here

    minWidth= computeMinimumColumnWidth(gc, columnValue);
    columnLayout.setColumnData(column2, new ColumnWeightData(3, minWidth, true));
   
    gc.dispose();

    fTableViewer= new TableViewer(table);
    fTableViewer.setLabelProvider(new TemplateLabelProvider());
    fTableViewer.setContentProvider(new TemplateContentProvider());

    fTableViewer.setComparator(new ViewerComparator() {
      public int compare(Viewer viewer, Object object1, Object object2) {
View Full Code Here

    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) {
View Full Code Here

      TableColumn column = new TableColumn(table, SWT.NONE);
      column.setText(columnNames[i]);
      layout.setColumnData(column, new ColumnWeightData(columnWeights[i]));
    }

    TableViewer tableViewer = new TableViewer(table);
    tableViewer.setColumnProperties(columnNames);
    return tableViewer;
  }
View Full Code Here

    getShell().setText(Messages.ManageCloudDialog_TEXT_MANAGE_CLOUD_URL);
    Composite composite = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
    GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(2).equalWidth(false).applyTo(composite);

    final TableViewer viewer = createTableViewer(composite, new String[] { Messages.ManageCloudDialog_TEXT_SERVER_TYPE, Messages.ManageCloudDialog_TEXT_URL }, new int[] { 35,
        55 });

    viewer.setContentProvider(new IStructuredContentProvider() {

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

      public void dispose() {
      }

      public Object[] getElements(Object inputElement) {
        Collections.sort(cloudUrls, new Comparator<CloudServerURL>() {
          public int compare(CloudServerURL o1, CloudServerURL o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });
        return cloudUrls.toArray();
      }
    });
    cloudUrls = CloudUiUtil.getAllUrls(serverTypeId);
    viewer.setInput(cloudUrls.toArray());

    viewer.setLabelProvider(new ITableLabelProvider() {

      public void removeListener(ILabelProviderListener listener) {
      }

      public boolean isLabelProperty(Object element, String property) {
        return false;
      }

      public void dispose() {
      }

      public void addListener(ILabelProviderListener listener) {
      }

      public String getColumnText(Object element, int columnIndex) {
        if (element instanceof CloudServerURL) {
          CloudServerURL cloudUrl = (CloudServerURL) element;
          if (columnIndex == 0) {
            return cloudUrl.getName();
          }
          else if (columnIndex == 1) {
            return cloudUrl.getUrl();
          }
        }

        return null;
      }

      public Image getColumnImage(Object element, int columnIndex) {
        return null;
      }
    });

    Composite buttonComposite = new Composite(composite, SWT.NONE);
    GridDataFactory.fillDefaults().grab(false, true).applyTo(buttonComposite);
    GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(buttonComposite);

    final Button addButton = new Button(buttonComposite, SWT.PUSH);
    GridDataFactory.fillDefaults().applyTo(addButton);
    addButton.setText(Messages.COMMONTXT_ADD);
    addButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        CloudServerURL cloudURL = promptForCloudURL(serverTypeId, e.display.getActiveShell(), cloudUrls, null,
            null);
        if (cloudURL != null) {
          addURL(cloudURL);
          viewer.refresh(true);
        }
      }
    });

    final Button editButton = new Button(buttonComposite, SWT.PUSH);
    GridDataFactory.fillDefaults().applyTo(editButton);
    editButton.setText(Messages.COMMONTXT_EDIT);
    editButton.setEnabled(false);
    editButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        ISelection selection = viewer.getSelection();
        if (selection instanceof IStructuredSelection) {
          IStructuredSelection sSelection = (IStructuredSelection) selection;
          Object element = sSelection.getFirstElement();
          if (element instanceof CloudServerURL) {
            CloudServerURL cloudUrl = (CloudServerURL) element;

            if (cloudUrl.getUserDefined()) {
              cloudUrls.remove(cloudUrl);
              CloudServerURL newUrl = promptForCloudURL(serverTypeId, e.display.getActiveShell(),
                  cloudUrls, cloudUrl.getUrl(), cloudUrl.getName());
              if (newUrl != null) {

                if (cloudUrl.getUrl().equals(newUrl.getUrl()) || canUpdateUrl(cloudUrl, newUrl)) {
                  addURL(newUrl);
                }
                else {
                  addURL(cloudUrl);
                }
              }
              else {
                addURL(cloudUrl);
              }
            }
            else {
              CloudServerURL url = CloudUiUtil.getWildcardUrl(cloudUrl, cloudUrls, getShell());
              if (url != null) {
                addURL(url);
              }
            }
            viewer.refresh(true);
          }
        }
      }
    });

    final Button removeButton = new Button(buttonComposite, SWT.PUSH);
    GridDataFactory.fillDefaults().applyTo(removeButton);
    removeButton.setText(Messages.COMMONTXT_REMOVE);
    removeButton.setEnabled(false);
    removeButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        ISelection selection = viewer.getSelection();
        if (selection instanceof IStructuredSelection) {
          IStructuredSelection sSelection = (IStructuredSelection) selection;
          Object[] selectedItems = sSelection.toArray();
          for (Object selectedItem : selectedItems) {
            if (selectedItem instanceof CloudServerURL) {
              CloudServerURL cloudUrl = (CloudServerURL) selectedItem;
              removeCloudUrl(cloudUrl);
            }
          }
        }
        viewer.refresh(true);
      }

    });

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

      public void selectionChanged(SelectionChangedEvent event) {
        ISelection selection = event.getSelection();
        if (selection instanceof IStructuredSelection) {
          boolean editEnabled = true;
View Full Code Here

    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();
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.viewers.TableViewer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.