Exemplo n.º 1
0
    public AssistantEditingSupport() {
      super(viewer);

      this.editor = new ComboBoxViewerCellEditor(viewer.getTree());
      this.editor.setContentProvider(new ArrayContentProvider());
      this.editor.setLabelProvider(new ViewLabelProvider());

      List<String> strings = new ArrayList<String>();
      for (IFormatAssistant assistant : AssistantFactory.getInstance().getAssistances()) {
        String name = ((FormatAssistant) assistant).getNameExtension();
        strings.add(name);
      }

      this.editor.setInput(strings.toArray());
    }
Exemplo n.º 2
0
  public void createPartControl(Composite parent) {
    viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);

    RepositoryViewContentProvider provider =
        new RepositoryViewContentProvider(
            AssistantFactory.getInstance().getRepositoryManager(), getViewSite());
    viewer.setContentProvider(provider);
    viewer.setSorter(new NameSorter());
    viewer.setInput(getViewSite());
    viewer.getTree().setHeaderVisible(true);

    viewer.setSelection(
        new StructuredSelection(AssistantFactory.getInstance().getRepositoryManager()), true);
    new AdapterFactoryTreeEditor(viewer.getTree(), adapterFactory);

    TreeViewerColumn nameColumn = new TreeViewerColumn(viewer, SWT.NONE);
    nameColumn.getColumn().setText("Name");
    nameColumn.getColumn().setWidth(300);
    nameColumn.setLabelProvider(
        new DelegatingStyledCellLabelProvider(new ColumnOneViewLabelProvider()));

    TreeViewerColumn assistedByColumn = new TreeViewerColumn(viewer, SWT.NONE);
    assistedByColumn.getColumn().setText("Assistant");
    assistedByColumn.getColumn().setWidth(100);
    assistedByColumn.getColumn().setAlignment(SWT.LEFT);
    assistedByColumn.setLabelProvider(
        new DelegatingStyledCellLabelProvider(new ColumnTwoViewLabelProvider()));
    assistedByColumn.setEditingSupport(new AssistantEditingSupport());

    TreeViewerColumn uriColumn = new TreeViewerColumn(viewer, SWT.NONE);
    uriColumn.getColumn().setText("Uri");
    uriColumn.getColumn().setWidth(400);
    uriColumn.getColumn().setAlignment(SWT.LEFT);
    uriColumn.setLabelProvider(
        new DelegatingStyledCellLabelProvider(new ColumnThreeViewLabelProvider()));

    initializeEditingDomain();

    EContentAdapter adapter =
        new EContentAdapter() {
          public void notifyChanged(Notification notification) {
            super.notifyChanged(notification);
            refresh();
          }
        };

    AssistantFactory.getInstance().getRepositoryManager().eAdapters().add(adapter);

    RepositoryViewFilter filter = new RepositoryViewFilter();
    ViewerFilter[] filters = {filter};
    viewer.setFilters(filters);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "extremo.ui.viewer");

    // Connection with properties view
    getSite().setSelectionProvider(viewer);
    getViewSite().setSelectionProvider(viewer);

    makeActions();
    hookContextMenu();
    hookDoubleClickAction();
    contributeToActionBars();
  }