@Override
  protected Object createLowerView(Composite parent) {
    //	Tree viewer for variable structure ...
    fTree = new Tree(parent, SWT.BORDER);
    fTree.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // https://jira.jboss.org/browse/JBIDE-7107
            // update "OK" button enablement
            updateOkState();
          }
        });

    fTreeViewer = new TreeViewer(fTree);
    fTreeViewer.setContentProvider(treeContentProvider);
    fTreeViewer.setLabelProvider(new ModelTreeLabelProvider());
    fTreeViewer.setInput(null);
    fTreeViewer.setAutoExpandLevel(getAutoExpandLevel());
    // end tree viewer for variable structure
    GridData data = new GridData();
    data.grabExcessVerticalSpace = true;
    data.grabExcessHorizontalSpace = true;
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;
    data.minimumHeight = 200;
    fTree.setLayoutData(data);

    return fTree;
  }
Пример #2
0
  public TreeSources(ApplicationFactory factory, Composite parent) {
    super(parent);

    setLayout(new FillLayout());

    tree = factory.createTree(this, SWT.MULTI);
    tree.setLinesVisible(false);

    createMenu(tree, factory);

    tree.addMouseListener(
        new MouseAdapter() {
          @SuppressWarnings("unused")
          public void mouseDown(MouseEvent arg0) {
            clickMouse = true;
          }
        });

    tree.addTreeListener(
        new TreeAdapter() {
          @SuppressWarnings("unused")
          public void treeCollapsed(TreeEvent arg0) {
            clickMouse = false;
          }

          @SuppressWarnings("unused")
          public void treeExpanded(TreeEvent arg0) {
            clickMouse = false;
          }
        });

    tree.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent event) {
            if (!clickMouse) return;
            clickMouse = false;
            if (tree.getSelectionCount() < 1) return;
            TreeItem selectedItem = tree.getSelection()[0];
            TreeItem parentItem = selectedItem.getParentItem();
            if (parentItem == null) {
              new LoadGroupCategorySource(
                  TreeSources.this, new Worker[0], null, selectedItem.getText());
              creator.selectData(new Worker[0], null, selectedItem.getText());
              return;
            }

            String category = parentItem.getText();
            String name = selectedItem.getText();
            creator.setSource(null, category, name, false);
          }
        });
  }
  private void createDynamicGroup(Composite parent) {
    Composite c = new Composite(parent, SWT.NONE);
    c.setLayoutData(new GridData(GridData.FILL_BOTH));
    c.setLayout(new GridLayout(2, true));

    Label l1 = new Label(c, SWT.NONE);
    l1.setText("Templates");
    l1.setFont(parent.getFont());
    l1.setLayoutData(new GridData(GridData.BEGINNING));

    rightLabel = new Label(c, SWT.NONE);
    rightLabel.setFont(parent.getFont());
    rightLabel.setText("Description");
    rightLabel.setLayoutData(new GridData(GridData.BEGINNING));

    tree = new Tree(c, SWT.SINGLE | SWT.BORDER);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    tree.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            TreeItem[] tis = tree.getSelection();
            if (tis == null || tis.length == 0) return;

            String description = (String) tis[0].getData(K_DESC);
            if (description == null) {
              description = "";
            }
            choice = tis[0];
            right.setText(description);
            // switchTo((CWizardHandler) tis[0].getData(), (EntryDescriptor) tis[0].getData(DESC));
            setPageComplete(validatePage());
          }
        });

    right = new Text(c, SWT.WRAP | SWT.BORDER);
    right.setEditable(false);
    l1.setFont(parent.getFont());
    right.setLayoutData(new GridData(GridData.FILL_BOTH));

    loadData();
  }
Пример #4
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.swt.widgets.Control#pack(boolean)
  */
 @Override
 public void pack(boolean changed) {
   if (changed) {
     RootContainer root = RootContainer.getRoot(project);
     root.update();
     table.clearAll(true);
     table.setItemCount(0);
     if (tableSelectionListener != null) {
       table.removeSelectionListener(tableSelectionListener);
     }
     setupClasspathInfo(table, root);
     makeChecksConsistentWithChildren();
     expandAll(table.getItems());
     if (tableSelectionListener == null) {
       tableSelectionListener = new TableSelectionListener();
       table.addSelectionListener(tableSelectionListener);
     }
   }
   table.pack(changed);
   super.pack(changed);
 }
Пример #5
0
  private void initBaseSitTreeBlock(Composite container) {
    // BaseSiteTreeGroup
    groupBaseSite = new Group(container, SWT.BORDER);
    groupBaseSite.setText("基站名称");
    groupBaseSite.setLayoutData(BorderLayout.WEST);
    formToolkit.adapt(groupBaseSite);
    formToolkit.paintBordersFor(groupBaseSite);

    // BaseSiteTree
    treeBaseSite = new Tree(groupBaseSite, SWT.NONE);
    treeBaseSite.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {

            System.out.println(e.item.toString());
            TreeItem etim = (TreeItem) e.item;
            setBaseID(etim.getText());
          }
        });
    contextService.LoadBaseSiteTree(treeBaseSite);
    treeBaseSite.setBounds(10, 20, 200, 650);
    formToolkit.paintBordersFor(treeBaseSite);
  }
Пример #6
0
  /**
   * Create the main content for this information control.
   *
   * @param parent The parent composite
   * @return The control representing the main content.
   * @since 3.2
   */
  protected Control createDialogArea(Composite parent) {
    setfTreeViewer(createTreeViewer(parent, fTreeStyle));

    final Tree tree = getfTreeViewer().getTree();
    tree.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent e) {
            if (e.character == 0x1B) // ESC
            dispose();
          }

          public void keyReleased(KeyEvent e) {
            // do nothing
          }
        });

    tree.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            // do nothing
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            gotoSelectedElement();
          }
        });

    tree.addMouseMoveListener(
        new MouseMoveListener() {
          TreeItem fLastItem = null;

          public void mouseMove(MouseEvent e) {
            if (tree.equals(e.getSource())) {
              Object o = tree.getItem(new Point(e.x, e.y));
              if (o instanceof TreeItem) {
                Rectangle clientArea = tree.getClientArea();
                if (!o.equals(fLastItem)) {
                  fLastItem = (TreeItem) o;
                  tree.setSelection(new TreeItem[] {fLastItem});
                } else if (e.y - clientArea.y < tree.getItemHeight() / 4) {
                  // Scroll up
                  Point p = tree.toDisplay(e.x, e.y);
                  Item item = getfTreeViewer().scrollUp(p.x, p.y);
                  if (item instanceof TreeItem) {
                    fLastItem = (TreeItem) item;
                    tree.setSelection(new TreeItem[] {fLastItem});
                  }
                } else if (clientArea.y + clientArea.height - e.y < tree.getItemHeight() / 4) {
                  // Scroll down
                  Point p = tree.toDisplay(e.x, e.y);
                  Item item = getfTreeViewer().scrollDown(p.x, p.y);
                  if (item instanceof TreeItem) {
                    fLastItem = (TreeItem) item;
                    tree.setSelection(new TreeItem[] {fLastItem});
                  }
                }
              }
            }
          }
        });

    tree.addMouseListener(
        new MouseAdapter() {
          public void mouseUp(MouseEvent e) {

            if (tree.getSelectionCount() < 1) return;

            if (e.button != 1) return;

            if (tree.equals(e.getSource())) {
              Object o = tree.getItem(new Point(e.x, e.y));
              TreeItem selection = tree.getSelection()[0];
              if (selection.equals(o)) gotoSelectedElement();
            }
          }
        });

    installFilter();

    addDisposeListener(this);
    return getfTreeViewer().getControl();
  }
  public ContactTab(final Composite composite) {
    super(composite, 0);
    this.setLayout(new GridLayout(1, false));

    Composite containerHeaderSession = new Composite(this, SWT.NONE);
    containerHeaderSession.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    containerHeaderSession.setLayout(new GridLayout(2, false));
    final Combo comboSession = new Combo(containerHeaderSession, SWT.DROP_DOWN | SWT.READ_ONLY);
    comboSession.add("分类1");
    comboSession.add("分类2");
    comboSession.add("分类3");
    comboSession.add("分类4");
    comboSession.select(0);
    final Label labelHeader1 = new Label(containerHeaderSession, SWT.NONE);
    labelHeader1.setText("共1人");

    tree =
        new Tree(
            this, /*SWT.CHECK | */
            SWT.VIRTUAL
                | SWT.MULTI
                | SWT.BORDER
                | SWT.FULL_SELECTION
                | SWT.H_SCROLL
                | SWT.V_SCROLL);
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    // tree.setRedraw(true);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    for (int i = 0; i < titles.length; i++) {
      TreeColumn column = new TreeColumn(tree, SWT.NONE);
      column.setText(titles[i]);
    }
    tree.addTreeListener(
        new TreeAdapter() {
          @Override
          public void treeCollapsed(TreeEvent e) {
            super.treeCollapsed(e);
            expand();
          }

          @Override
          public void treeExpanded(TreeEvent e) {
            super.treeExpanded(e);
            expand();
          }

          private void expand() {
            // System.out.println("expand...");
            isExpanding = true;
            Display.getDefault()
                .timerExec(
                    500,
                    new Runnable() {
                      public void run() {
                        isExpanding = false;
                        // System.out.println("isGroupClick: " + isGroupClick);
                      }
                    });
          }
        });
    tree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent event) {
            super.mouseDown(event);
          }

          @Override
          public void mouseDoubleClick(MouseEvent event) {
            super.mouseDoubleClick(event);
            Point point = new Point(event.x, event.y);
            TreeItem item = tree.getItem(point);
            // System.out.println("Mouse double click: " + item);
            if (item != null && item.getData() != null && isExpanding == false) {
              ContactInfoDialog dialog =
                  new ContactInfoDialog(getParent().getShell(), ContactInfoComposite.TYPE_EDIT);
              ContactInfo info = (ContactInfo) item.getData();
              dialog.setData(info);
              if (dialog.open() == ContactInfoDialog.OK) {
                AppData.getInstance().getMainWin().refreshContactData(true);
              }
            }
          }
        });
    tree.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            if (event.detail == SWT.CHECK) {
              TreeItem item = (TreeItem) event.item;
              boolean checked = item.getChecked();
              UIUtil.checkItems(item, checked);
              UIUtil.checkPath(item.getParentItem(), checked, false);
            } else {
              TreeItem item = (TreeItem) event.item;
              ContactInfo info = null;
              if (item != null && item.getData() != null) {
                info = (ContactInfo) item.getData();
              }
              AppData.getInstance().getMainWin().showDetail(info);
            }
          }
        });

    setupPopupMenu();

    Composite containerHeaderEdit = new Composite(this, SWT.NONE);
    containerHeaderEdit.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    containerHeaderEdit.setLayout(new GridLayout(7, false));

    final Label labelCatalog = new Label(containerHeaderEdit, SWT.PUSH);
    labelCatalog.setText("小类:");
    final Combo comboCatalog = new Combo(containerHeaderEdit, SWT.DROP_DOWN | SWT.READ_ONLY);
    comboCatalog.add("小类1");
    comboCatalog.add("小类2");
    final Label labelSearch = new Label(containerHeaderEdit, SWT.PUSH);
    labelSearch.setText("联系人搜索:");
    final Text textSearch = new Text(containerHeaderEdit, SWT.BORDER);
    textSearch.setLayoutData(new GridData(150, SWT.DEFAULT));

    final Button buttonAdd = new Button(containerHeaderEdit, SWT.PUSH);
    buttonAdd.setText("新增...");
    buttonAdd.setLayoutData(new GridData(100, SWT.DEFAULT));
    buttonAdd.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            AppData.getInstance().getMainWin().addContact();
          }
        });
    final Button buttonImport = new Button(containerHeaderEdit, SWT.PUSH);
    buttonImport.setText("导入...");
    buttonImport.setLayoutData(new GridData(100, SWT.DEFAULT));
    final Button buttonExport = new Button(containerHeaderEdit, SWT.PUSH);
    buttonExport.setText("导出...");
    buttonExport.setLayoutData(new GridData(100, SWT.DEFAULT));

    if (!USE_PACK) {
      for (int i = 0; i < titles.length; i++) {
        if (i == 0) {
          tree.getColumn(i).setWidth(200);
        } else {
          tree.getColumn(i).setWidth(100);
        }
      }
    }
    if (USE_VIRTUAL) {
      tree.addListener(
          SWT.SetData,
          new Listener() {
            @Override
            public void handleEvent(Event event) {
              TreeItem item = (TreeItem) event.item;
              TreeItem parentItem = item.getParentItem();
              String text = null;
              if (parentItem == null) {
                ContactGroupInfo groupInfo = groupInfoList.get(tree.indexOf(item));
                text = groupInfo.getGroupName() + " (共" + groupInfo.getSize() + "人)";
                item.setText(text);
                item.setItemCount(groupInfo.getSize());
                item.setExpanded(true);
              } else {
                ContactGroupInfo groupInfo = groupInfoList.get(tree.indexOf(parentItem));
                ContactInfo info = results.get(groupInfo.getIndex(parentItem.indexOf(item)));
                fillItem(item, info);
              }
              if (USE_PACK) {
                packTable();
              }
            }
          });
    }
    reloadData(false);
  }
Пример #8
0
  @Override
  public void createPartControl(final Composite parent) {
    final GridData gridData1 = new GridData();
    gridData1.horizontalAlignment = FILL;
    gridData1.verticalAlignment = GridData.CENTER;
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    final GridData gridData = new GridData();
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = FILL;
    gridData.verticalAlignment = FILL;
    gridData.grabExcessHorizontalSpace = true;
    final Composite top = new Composite(parent, SWT.NONE);
    top.setLayout(gridLayout);
    labelTitre = new Label(top, SWT.NONE);
    labelTitre.setText("Navigateur");
    labelTitre.setLayoutData(gridData1);
    tree = new Tree(top, SWT.MULTI);
    tree.setLayoutData(gridData);
    treeViewer = new TreeViewer(tree);
    getSite().setSelectionProvider(treeViewer);
    final Image fondImage = ImageReg.getImg(IMG_VIEW_BG);
    tree.setBackgroundImage(fondImage);
    tree.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent element) {
            labelTitre.setText(tree.getSelection()[0].getText());
            try {
              getViewSite().getPage().showView(NAVIGATOR_VIEW_ID);
            } catch (PartInitException e) {
              e.printStackTrace();
            }
          }
        });

    applyNavigatorDoubleClick(tree, getSite().getWorkbenchWindow());

    treeViewer.setLabelProvider(new NavigatorLabelProvider());
    treeViewer.setContentProvider(createContentProvider());

    final ProjectManager manager = getProjectManager();
    manager.addProjectManagerListener(this);
    treeViewer.setInput(manager);
    defineWorkbenchPopupMenu(getSite(), treeViewer);
    initDragAndDrop();

    applyTooltipNavigator(tree);

    final TreeEditor editor = new TreeEditor(tree);
    editor.horizontalAlignment = SWT.CENTER;
    editor.grabHorizontal = true;
    editor.grabVertical = true;

    tree.addKeyListener(new TreeEditing(tree, editor));

    final Clipboard clipboard = new Clipboard(getSite().getShell().getDisplay());
    final IActionBars bars = getViewSite().getActionBars();
    bars.setGlobalActionHandler(CUT.getId(), new CutStepAction(treeViewer, clipboard));
    bars.setGlobalActionHandler(COPY.getId(), new CopyStepAction(treeViewer, clipboard));
    bars.setGlobalActionHandler(PASTE.getId(), new PasteTreeGadgetAction(treeViewer, clipboard));
  }
  public void display() throws Exception {
    /*
     * Create the display and shell.
     */
    display = new Display();
    final Shell shell = new Shell(display);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 3;
    shell.setLayout(layout);
    /*
     * Create a toolbar
     */
    {
      ToolBar toolbar = new ToolBar(shell, SWT.FLAT | SWT.RIGHT | SWT.NO_FOCUS);
      toolbar.setForeground(display.getSystemColor(SWT.COLOR_RED));
      toolbar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
      ToolItem item = new ToolItem(toolbar, SWT.PUSH);
      item.setText("File");
      item = new ToolItem(toolbar, SWT.PUSH);
      item.setText("Edit");
      item = new ToolItem(toolbar, SWT.PUSH);
      item.setText("Help");
    }

    if (styleSheetStream == null) {
      // Create Styles themes
      createThemesStyleComposite(shell);
    }

    /*
     * Create a sash form.
     */
    SashForm form = new SashForm(shell, SWT.NONE);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));
    /*
     * Create the buddylist tree.
     */
    {
      tree = new Tree(form, SWT.SINGLE);
      tree.addSelectionListener(
          new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
              if (((TreeItem) e.item).getParentItem() != null) {
                try {
                  createChatControl(e.item);
                } catch (Exception ex) {
                  ex.printStackTrace();
                }
              }
            }

            public void widgetSelected(SelectionEvent e) {}
          });
      for (int i = 0; i < GROUPS.length; i++) {
        String g = GROUPS[i];
        TreeItem parentItem = new TreeItem(tree, SWT.NONE);
        parentItem.setText(g);
        for (int j = 0; j < NAMES.length; j++) {
          String n = NAMES[j];
          TreeItem item = new TreeItem(parentItem, SWT.NONE);
          item.setText(n);
        }
        parentItem.setExpanded(true);
      }
    }
    /*
     * Add the tabfolder
     */
    {
      tabFolder = new CTabFolder(form, SWT.CLOSE);
      tabFolder.setUnselectedCloseVisible(true);
      tabFolder.setUnselectedImageVisible(true);
      form.setWeights(new int[] {30, 70});
      // open a couple chats
      createChatControl(tree.getItem(0).getItems()[0]);
      createChatControl(tree.getItem(0).getItems()[1]);
      tabFolder.setSelection(tabFolder.getItem(0));
    }
    /*
     * Create a statusbar
     */
    {
      CLabel statusbar = new CLabel(shell, SWT.NONE);
      GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
      statusbar.setLayoutData(gd);
      statusbar.setText("Samantha Daryn is online");
    }
    /*
     * StyleHelper is used to parse and apply styles.
     */
    engine = getCSSEngine();
    if (styleSheetStream != null) {
      engine.parseStyleSheet(styleSheetStream);
      engine.applyStyles(shell, true);
    }
    /*
     * Now we open the shell.
     */
    shell.setSize(new Point(600, 600));
    shell.open();
    shell.setText("CSS Instant Messaging");
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  /**
   * Create contents of the dialog.
   *
   * @param parent
   */
  protected Control createDialogArea(Composite parent) {
    final Composite container = (Composite) super.createDialogArea(parent);
    treeViewer = new TreeViewer(container, SWT.BORDER);
    Tree treeResrouceProviders = treeViewer.getTree();
    treeResrouceProviders.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            updateSelectedElement();
            updateOKButtonStatus();
          }
        });

    treeResrouceProviders.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    treeViewer.setContentProvider(
        new ITreeContentProvider() {
          public Object[] getChildren(Object o) {
            return createTreeItemList(o);
          }

          private Object[] createTreeItemList(Object o) {
            List<Object> list = new ArrayList<Object>();
            if (o instanceof IDeveloperStudioProviderData[]) {
              IDeveloperStudioProviderData[] oo = (IDeveloperStudioProviderData[]) o;
              for (IDeveloperStudioProviderData data : oo) {
                IDeveloperStudioProvider provider = data.getProvider();
                if (isChildElementsPresent(provider)) {
                  list.add(data);
                }
              }
            } else if (o instanceof IDeveloperStudioProvider
                || o instanceof IDeveloperStudioProviderData) {
              IDeveloperStudioProvider provider =
                  o instanceof IDeveloperStudioProvider
                      ? (IDeveloperStudioProvider) o
                      : ((IDeveloperStudioProviderData) o).getProvider();
              IDeveloperStudioElement[] resources = provider.getElements(getFilters());
              if (resources != null) {
                list.addAll(Arrays.asList(resources));
              }
              IDeveloperStudioProvider[] categories = provider.getCategories(getFilters());
              if (categories != null) {
                list.addAll(Arrays.asList(categories));
              }
            } else if (o instanceof IDeveloperStudioElement) {
              IDeveloperStudioElement element = (IDeveloperStudioElement) o;
              list.addAll(Arrays.asList(element.getChildren(getFilters())));
            }
            return list.toArray();
          }

          private boolean isChildElementsPresent(IDeveloperStudioProvider provider) {
            IDeveloperStudioElement[] resources = provider.getElements(getFilters());
            IDeveloperStudioProvider[] categories = provider.getCategories(getFilters());
            return (resources != null && resources.length > 0)
                || (categories != null && categories.length > 0);
          }

          public Object getParent(Object arg0) {
            return null;
          }

          public boolean hasChildren(Object o) {
            if (o instanceof IDeveloperStudioProviderData[]) {
              return ((IDeveloperStudioProviderData[]) o).length > 0;
            } else if (o instanceof IDeveloperStudioProviderData) {
              IDeveloperStudioProviderData provider = (IDeveloperStudioProviderData) o;
              return isChildElementsPresent(provider.getProvider());
            } else if (o instanceof IDeveloperStudioProvider) {
              IDeveloperStudioProvider provider = (IDeveloperStudioProvider) o;
              return isChildElementsPresent(provider);
            } else if (o instanceof IDeveloperStudioElement) {
              IDeveloperStudioElement element = (IDeveloperStudioElement) o;
              return element.hasChildren(getFilters());
            }
            return false;
          }

          public Object[] getElements(Object o) {
            return getChildren(o);
          }

          public void dispose() {
            // TODO Auto-generated method stub
          }

          public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
            // TODO Auto-generated method stub
          }
        });
    treeViewer.setLabelProvider(
        new ILabelProvider() {
          public Image getImage(Object o) {
            if (o instanceof IDeveloperStudioProviderData) {
              IDeveloperStudioProviderData oo = (IDeveloperStudioProviderData) o;
              if (oo.getProvider().getIcon() != null) {
                return oo.getProvider().getIcon().createImage();
              }
            } else if (o instanceof IDeveloperStudioProvider) {
              IDeveloperStudioProvider provider = (IDeveloperStudioProvider) o;
              if (provider.getIcon() != null) {
                return provider.getIcon().createImage();
              }
            } else if (o instanceof IDeveloperStudioElement) {
              IDeveloperStudioElement resource = (IDeveloperStudioElement) o;
              if (resource.getIcon() != null) {
                return resource.getIcon().createImage();
              }
            }
            return null;
          }

          public String getText(Object o) {
            if (o instanceof IDeveloperStudioProviderData) {
              IDeveloperStudioProviderData oo = (IDeveloperStudioProviderData) o;
              return oo.getName();
            } else if (o instanceof IDeveloperStudioProvider) {
              IDeveloperStudioProvider provider = (IDeveloperStudioProvider) o;
              return provider.getText();
            } else if (o instanceof IDeveloperStudioElement) {
              IDeveloperStudioElement resource = (IDeveloperStudioElement) o;
              return resource.getText();
            }
            return null;
          }

          public void addListener(ILabelProviderListener arg0) {}

          public void dispose() {}

          public boolean isLabelProperty(Object arg0, String arg1) {
            return false;
          }

          public void removeListener(ILabelProviderListener arg0) {}
        });
    List<Object> list = new ArrayList<Object>();

    List<Class<?>> typesList = Arrays.asList(type);

    // IRegistryFile.class, IEsbEndpoint.class, IEsbSequence.class, IEsbLocalEntry.class
    if (typesList.contains(IRegistryFile.class)) {
      list.addAll(Arrays.asList(RegistryManager.getResourceProviders(true)));
    }

    if (typesList.contains(IEsbEndpoint.class)) {
      list.addAll(Arrays.asList(EsbConfigurationManager.getEndpointProviders(true)));
    }

    if (typesList.contains(IEsbSequence.class)) {
      list.addAll(Arrays.asList(EsbConfigurationManager.getSequenceProviders(true)));
    }

    if (typesList.contains(IEsbLocalEntry.class)) {
      list.addAll(Arrays.asList(EsbConfigurationManager.getLocalEntryProviders(true)));
    }

    treeViewer.setInput(list.toArray(new IDeveloperStudioProviderData[] {}));

    if (showOpenResourceCheckBox) {
      chkOpenResource = new Button(container, SWT.CHECK);
      chkOpenResource.setText("Open the resource for editing");
    }

    if (showCreateNewResourceLink) {
      createNewLink = new Link(container, SWT.NONE);
      createNewLink.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              openNewResourceTemplateDialog();
            }
          });
      createNewLink.setText("<a>Create && point to a new DataMapper Configuration. </a>");
    }

    return container;
  }
Пример #11
0
  @Override
  protected void addToMainPage(Composite container) {
    super.addToMainPage(container);

    Group optionsGroup = new Group(container, SWT.NONE);
    optionsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    optionsGroup.setLayout(new GridLayout(1, true));
    optionsGroup.setText(
        MakeUIPlugin.getResourceString(
            "WizardMakeProjectConversion.projectOptions.title")); //$NON-NLS-1$
    Composite c = new Composite(optionsGroup, SWT.NONE);
    c.setLayoutData(new GridData(GridData.FILL_BOTH));
    c.setLayout(new GridLayout(2, true));

    specifyProjectTypeButton = new Button(c, SWT.CHECK);
    specifyProjectTypeButton.setText(
        MakeUIPlugin.getResourceString(
            "WizardMakeProjectConversion.projectOptions.projectType")); //$NON-NLS-1$
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    specifyProjectTypeButton.setLayoutData(gd);
    specifyProjectTypeButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            enableProjectTypeControls(specifyProjectTypeButton.getSelection());
          }
        });

    left_label = new Label(c, SWT.NONE);
    left_label.setText(
        MakeUIPlugin.getResourceString(
            "WizardMakeProjectConversion.projectOptions.projectTypeTable")); //$NON-NLS-1$
    left_label.setFont(container.getFont());
    left_label.setLayoutData(new GridData(GridData.BEGINNING));

    right_label = new Label(c, SWT.NONE);
    right_label.setFont(container.getFont());
    right_label.setLayoutData(new GridData(GridData.BEGINNING));

    tree = new Tree(c, SWT.SINGLE | SWT.BORDER);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    tree.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            TreeItem[] tis = tree.getSelection();
            if (tis == null || tis.length == 0) return;
            switchTo(
                (CWizardHandler) tis[0].getData(),
                (EntryDescriptor) tis[0].getData(CDTMainWizardPage.DESC));
          }
        });
    right = new Composite(c, SWT.NONE);
    right.setLayoutData(new GridData(GridData.FILL_BOTH));
    right.setLayout(new PageLayout());

    show_sup = new Button(c, SWT.CHECK);
    show_sup.setSelection(true);
    show_sup.setText(
        MakeUIPlugin.getResourceString(
            "WizardMakeProjectConversion.projectOptions.showSuppressed")); //$NON-NLS-1$
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    show_sup.setLayoutData(gd);
    final IWizardItemsListListener filter =
        new IWizardItemsListListener() {

          // Show only category
          public List<EntryDescriptor> filterItems(List<? extends EntryDescriptor> items) {
            List<EntryDescriptor> results = new ArrayList<EntryDescriptor>();

            for (EntryDescriptor entry : items) {
              if (entry.isCategory()) {
                results.add(entry);
              }
            }

            return results;
          }

          public boolean isCurrent() {
            return true;
          }

          public void toolChainListChanged(int count) {
            // Do nothing
          }
        };

    show_sup.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (h_selected != null) h_selected.setSupportedOnly(show_sup.getSelection());
            switchTo(
                CDTMainWizardPage.updateData(tree, right, show_sup, filter, null),
                CDTMainWizardPage.getDescriptor(tree));
          }
        });

    CDTPrefUtil.readPreferredTCs();
    switchTo(
        CDTMainWizardPage.updateData(tree, right, show_sup, filter, null),
        CDTMainWizardPage.getDescriptor(tree));

    specifyProjectTypeButton.setSelection(true);
    enableProjectTypeControls(true);
  }
Пример #12
0
  private Section createFileSection(Composite container) {
    Section filesSection =
        toolkit.createSection(
            container, ExpandableComposite.TITLE_BAR | ExpandableComposite.CLIENT_INDENT);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(filesSection);
    Composite filesArea = toolkit.createComposite(filesSection);
    filesSection.setClient(filesArea);
    toolkit.paintBordersFor(filesArea);
    GridLayoutFactory.fillDefaults().extendedMargins(2, 2, 2, 2).applyTo(filesArea);

    ToolBar filesToolbar = new ToolBar(filesSection, SWT.FLAT);

    filesSection.setTextClient(filesToolbar);

    PatternFilter patternFilter =
        new PatternFilter() {
          @Override
          protected boolean isLeafMatch(Viewer viewer, Object element) {
            if (element instanceof CommitItem) {
              CommitItem commitItem = (CommitItem) element;
              return wordMatches(commitItem.path);
            }
            return super.isLeafMatch(viewer, element);
          }
        };
    patternFilter.setIncludeLeadingWildcard(true);
    FilteredCheckboxTree resourcesTreeComposite =
        new FilteredCheckboxTree(filesArea, toolkit, SWT.FULL_SELECTION, patternFilter) {
          @Override
          protected WorkbenchJob doCreateRefreshJob() {
            // workaround for file filter not having an explicit change
            // listener
            WorkbenchJob filterJob = super.doCreateRefreshJob();
            filterJob.addJobChangeListener(
                new JobChangeAdapter() {
                  public void done(IJobChangeEvent event) {
                    if (event.getResult().isOK()) {
                      getDisplay()
                          .asyncExec(
                              new Runnable() {
                                public void run() {
                                  updateFileSectionText();
                                }
                              });
                    }
                  }
                });
            return filterJob;
          }
        };
    Tree resourcesTree = resourcesTreeComposite.getViewer().getTree();
    resourcesTree.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
    resourcesTreeComposite.setLayoutData(
        GridDataFactory.fillDefaults().hint(600, 200).grab(true, true).create());

    resourcesTree.addSelectionListener(new CommitItemSelectionListener());

    resourcesTree.setHeaderVisible(true);
    TreeColumn statCol = new TreeColumn(resourcesTree, SWT.LEFT);
    statCol.setText(UIText.CommitDialog_Status);
    statCol.setWidth(150);
    statCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByStatus));

    TreeColumn resourceCol = new TreeColumn(resourcesTree, SWT.LEFT);
    resourceCol.setText(UIText.CommitDialog_Path);
    resourceCol.setWidth(415);
    resourceCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByFile));

    filesViewer = resourcesTreeComposite.getCheckboxTreeViewer();
    new TreeViewerColumn(filesViewer, statCol).setLabelProvider(createStatusLabelProvider());
    new TreeViewerColumn(filesViewer, resourceCol).setLabelProvider(new CommitPathLabelProvider());
    ColumnViewerToolTipSupport.enableFor(filesViewer);
    filesViewer.setContentProvider(new CommitFileContentProvider());
    filesViewer.setUseHashlookup(true);
    IDialogSettings settings = org.eclipse.egit.ui.Activator.getDefault().getDialogSettings();
    if (settings.get(SHOW_UNTRACKED_PREF) != null) {
      // note, no matter how the dialog settings are, if
      // the preferences force us to include untracked files
      // we must show them
      showUntracked =
          Boolean.valueOf(settings.get(SHOW_UNTRACKED_PREF)).booleanValue()
              || getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
    }

    filesViewer.addFilter(new CommitItemFilter());
    filesViewer.setInput(items.toArray());
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(createContextMenuListener());
    filesViewer.getTree().setMenu(menuManager.createContextMenu(filesViewer.getTree()));
    filesViewer.addCheckStateListener(
        new ICheckStateListener() {

          public void checkStateChanged(CheckStateChangedEvent event) {
            updateFileSectionText();
          }
        });

    showUntrackedItem = new ToolItem(filesToolbar, SWT.CHECK);
    Image showUntrackedImage = UIIcons.UNTRACKED_FILE.createImage();
    UIUtils.hookDisposal(showUntrackedItem, showUntrackedImage);
    showUntrackedItem.setImage(showUntrackedImage);
    showUntrackedItem.setToolTipText(UIText.CommitDialog_ShowUntrackedFiles);
    showUntrackedItem.setSelection(showUntracked);
    showUntrackedItem.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            showUntracked = showUntrackedItem.getSelection();
            filesViewer.refresh(true);
            updateFileSectionText();
            updateMessage();
          }
        });

    ToolItem checkAllItem = new ToolItem(filesToolbar, SWT.PUSH);
    Image checkImage = UIIcons.CHECK_ALL.createImage();
    UIUtils.hookDisposal(checkAllItem, checkImage);
    checkAllItem.setImage(checkImage);
    checkAllItem.setToolTipText(UIText.CommitDialog_SelectAll);
    checkAllItem.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            filesViewer.setAllChecked(true);
            updateFileSectionText();
            updateMessage();
          }
        });

    ToolItem uncheckAllItem = new ToolItem(filesToolbar, SWT.PUSH);
    Image uncheckImage = UIIcons.UNCHECK_ALL.createImage();
    UIUtils.hookDisposal(uncheckAllItem, uncheckImage);
    uncheckAllItem.setImage(uncheckImage);
    uncheckAllItem.setToolTipText(UIText.CommitDialog_DeselectAll);
    uncheckAllItem.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            filesViewer.setAllChecked(false);
            updateFileSectionText();
            updateMessage();
          }
        });

    if (!allowToChangeSelection) {
      amendingItem.setSelection(false);
      amendingItem.setEnabled(false);
      showUntrackedItem.setSelection(false);
      showUntrackedItem.setEnabled(false);
      checkAllItem.setEnabled(false);
      uncheckAllItem.setEnabled(false);

      filesViewer.addCheckStateListener(
          new ICheckStateListener() {

            public void checkStateChanged(CheckStateChangedEvent event) {
              if (!event.getChecked()) filesViewer.setAllChecked(true);
              updateFileSectionText();
            }
          });
      filesViewer.setAllChecked(true);
    } else {
      final boolean includeUntracked =
          getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
      for (CommitItem item : items) {
        if (!preselectAll && !preselectedFiles.contains(item.path)) continue;
        if (item.status == Status.ASSUME_UNCHANGED) continue;
        if (!includeUntracked && item.status == Status.UNTRACKED) continue;
        filesViewer.setChecked(item, true);
      }
    }
    statCol.pack();
    resourceCol.pack();
    return filesSection;
  }
Пример #13
0
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   */
  public RecoverData(Composite parent, int style) {
    super(parent, style);
    setLayout(new GridLayout(3, false));

    tree = new Tree(this, SWT.BORDER);
    GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 2);
    gd_tree.widthHint = 150;
    tree.setLayoutData(gd_tree);
    tree.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            table.removeAll();
            table.setItemCount(0);

            Display.getDefault()
                .syncExec(
                    new Runnable() {

                      @Override
                      public void run() {
                        populateTable(tree);
                      }
                    });
          }
        });

    ScrolledComposite scrolledComposite =
        new ScrolledComposite(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    GridData gd_scrolledComposite = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    gd_scrolledComposite.widthHint = 140;
    gd_scrolledComposite.heightHint = 56;
    scrolledComposite.setLayoutData(gd_scrolledComposite);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);

    table = new Table(scrolledComposite, SWT.BORDER | SWT.FULL_SELECTION);
    table.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            TableItem row = table.getItem(table.getSelectionIndex());
            final String path = row.getText(2);
            Display.getDefault()
                .syncExec(
                    new Runnable() {

                      @Override
                      public void run() {
                        // hex.ViewHexDump(path);
                        showHexDump(path);
                        showPic(path);
                      }
                    });
          }
        });

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

    TableColumn tblclmnFileName = new TableColumn(table, SWT.NONE);
    tblclmnFileName.setWidth(100);
    tblclmnFileName.setText("File Name");

    TableColumn tblclmnSize = new TableColumn(table, SWT.NONE);
    tblclmnSize.setWidth(50);
    tblclmnSize.setText("Size");

    TableColumn tblclmnPath = new TableColumn(table, SWT.NONE);
    tblclmnPath.setWidth(-245);
    tblclmnPath.setText("Path");

    scrolledComposite.setContent(table);
    scrolledComposite.setMinSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    canvas = new Canvas(this, SWT.BORDER);
    canvas.setLayout(new GridLayout(1, false));
    GridData gd_scrolledComposite_1 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_scrolledComposite_1.widthHint = 119;
    canvas.setLayoutData(gd_scrolledComposite_1);

    label = new Label(canvas, SWT.BORDER);
    label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    hexview = new HexViewer(this, SWT.NONE);
    hexview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1));
  }
Пример #14
0
  /**
   * Create contents of the wizard.
   *
   * @param parent
   */
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    setControl(container);
    container.setLayout(new FormLayout());

    treeViewer = new TreeViewer(container, SWT.BORDER);
    final Tree tree_Collection = treeViewer.getTree();

    tree_Collection.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            str = treeViewer.getTree().getSelection()[0].getText();
          }
        });
    FormData fd_tree_Collection = new FormData();
    fd_tree_Collection.top = new FormAttachment(0, 3);
    fd_tree_Collection.right = new FormAttachment(100);
    fd_tree_Collection.left = new FormAttachment(0, 3);
    tree_Collection.setLayoutData(fd_tree_Collection);

    tree_Collection.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDoubleClick(MouseEvent e) {
            TreeItem[] items = treeViewer.getTree().getSelection();
            if (items[0].getExpanded()) {
              items[0].setExpanded(false);
            } else {
              treeViewer.expandToLevel(items[0].getData(), 1);
            }
            if (items[0].getText().equals("/...")) {
              String[] list;

              ExportActionWizard tes = (ExportActionWizard) getWizard();
              list = tes.str.split("/");
              String str = " /";
              for (int i = 1; i < (list.length) - 1; i++) {
                str += list[i] + "/";
              }
              tes.str = str;
              treeViewer.setInput(createDummyModel());
              treeViewer.expandToLevel(2);
            }
          }
        });

    treeViewer.setContentProvider(new CopyViewContentProvider());
    treeViewer.setLabelProvider(new CopyViewLabelProvider());
    treeViewer.setSorter(new NameSorter());

    Composite composite = new Composite(container, SWT.NONE);
    fd_tree_Collection.bottom = new FormAttachment(composite, -1);
    FormData fd_composite = new FormData();
    fd_composite.bottom = new FormAttachment(100, -10);
    fd_composite.top = new FormAttachment(100, -36);
    fd_composite.left = new FormAttachment(0, 14);
    fd_composite.right = new FormAttachment(100);
    composite.setLayoutData(fd_composite);
    composite.setLayout(new GridLayout(2, true));

    btnall = new Button(composite, SWT.RADIO);
    btnall.setSelection(true);
    btnall.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnall.setText("All Entries");

    btnsome = new Button(composite, SWT.RADIO);
    btnsome.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnsome.setText("Some Entries(Query)");

    initTree();
  }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 3;
    // layout.verticalSpacing = 5;

    Label label = new Label(container, SWT.NULL);
    label.setText(Messages.CmsisCodeTemplateNewWizardPage_Project);
    projectText = new Text(container, SWT.BORDER | SWT.SINGLE);
    projectText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    projectText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            projectChanged();
          }
        });
    projectBrowse = new Button(container, SWT.PUSH);
    projectBrowse.setText(Messages.CmsisCodeTemplate_Browse);
    projectBrowse.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleProjectBrowse();
          }
        });

    fViewer =
        new TreeViewer(
            container, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    Tree tree = fViewer.getTree();
    GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
    gd_tree.heightHint = 300;
    tree.setLayoutData(gd_tree);
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    tree.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            Object obj = e.item.getData();
            if (obj instanceof ICpCodeTemplate) {
              selectedCodeTemplate = (ICpCodeTemplate) obj;
              String[] codeTemplates = selectedCodeTemplate.getCodeTemplates();
              if (codeTemplates.length == 0) {
                fileText.setEditable(false);
                fileText.setText(CmsisConstants.EMPTY_STRING);
                return;
              }
              fileText.setEditable(true);
              StringBuilder sb = new StringBuilder(Utils.extractFileName(codeTemplates[0]));
              for (int i = 1; i < codeTemplates.length; i++) {
                fileText.setEditable(false);
                sb.append(' ');
                sb.append(Utils.extractFileName(codeTemplates[i]));
              }
              fileText.setText(sb.toString());
            }
          }
        });

    TreeViewerColumn column0 = new TreeViewerColumn(fViewer, SWT.LEFT);
    column0.getColumn().setText(Messages.CmsisCodeTemplate_Component);
    column0.getColumn().setWidth(200);
    column0.setLabelProvider(new ComponentColumnLabelProvider());

    TreeViewerColumn column1 = new TreeViewerColumn(fViewer, SWT.LEFT);
    column1.getColumn().setText(Messages.CmsisCodeTemplate_Name);
    column1.getColumn().setWidth(320);
    column1.setLabelProvider(new NameColumnLabelProvider());

    fViewer.setContentProvider(new CodeTemplateContentProvider());

    IRteProject rteProject = getRteProject();
    if (rteProject != null) {
      ICpCodeTemplate codeTemplate = rteProject.getRteConfiguration().getCmsisCodeTemplate();
      fViewer.setInput(codeTemplate);
      fViewer.getControl().setFocus();
    }

    label = new Label(container, SWT.NULL);
    label.setText(Messages.CmsisCodeTemplate_Location);
    containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
    containerText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    containerText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            dialogChanged();
          }
        });
    containerBrowse = new Button(container, SWT.PUSH);
    containerBrowse.setText(Messages.CmsisCodeTemplate_Browse);
    containerBrowse.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleContainerBrowse();
          }
        });

    label = new Label(container, SWT.NULL);
    label.setText(Messages.CmsisCodeTemplate_FileName);
    fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
    fileText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fileText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            dialogChanged();
          }
        });

    initialize();
    projectChanged();
    setControl(container);
    new Label(container, SWT.NONE);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(parent.getParent(), IHelpContextIds.CODE_TEMPLATE_WIZARD);
  }
Пример #16
0
  @Override
  protected Control createDialogArea(final Composite parent) {

    final Composite composite = (Composite) super.createDialogArea(parent);
    final Tree functionClausesTree;

    final Label label = new Label(composite, SWT.WRAP);
    label.setText("Please select the function clause which against should fold!");
    final GridData minToksData =
        new GridData(
            GridData.GRAB_HORIZONTAL
                | GridData.GRAB_VERTICAL
                | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_CENTER);
    minToksData.widthHint =
        convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    label.setLayoutData(minToksData);
    label.setFont(parent.getFont());

    functionClausesTree = new Tree(composite, SWT.BORDER);
    final GridData treeData =
        new GridData(
            GridData.GRAB_HORIZONTAL
                | GridData.GRAB_VERTICAL
                | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_CENTER);
    treeData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    functionClausesTree.setLayoutData(treeData);

    try {
      final Collection<IErlModule> erlmodules =
          ErlangEngine.getInstance()
              .getModelUtilService()
              .getProject(GlobalParameters.getWranglerSelection().getErlElement())
              .getModules();

      for (final IErlModule m : erlmodules) {
        // must refresh the scanner!
        if (
        /* !m.isStructureKnown() */ true) {
          // FIXME: not permitted operation
          m.open(null);
        }

        final TreeItem moduleName = new TreeItem(functionClausesTree, 0);
        moduleName.setText(m.getModuleName());
        moduleName.setData(m);
        final List<IErlFunction> functions = filterFunctions(m.getChildren());
        for (final IErlFunction f : functions) {
          final TreeItem functionName = new TreeItem(moduleName, 0);
          functionName.setText(f.getNameWithArity());
          final List<IErlFunctionClause> clauses = filterClauses(f.getChildren());
          functionName.setData(f);
          for (final IErlFunctionClause c : clauses) {
            final TreeItem clauseName = new TreeItem(functionName, 0);
            clauseName.setText(String.valueOf(c.getName()));
            clauseName.setData(c);
          }
        }
      }

      // listen to treeitem selection
      functionClausesTree.addSelectionListener(
          new SelectionListener() {

            @Override
            public void widgetDefaultSelected(final SelectionEvent e) {}

            // if a function or a function clause is selected, then
            // highlight it
            // and store the selection
            @Override
            public void widgetSelected(final SelectionEvent e) {

              final TreeItem[] selectedItems = functionClausesTree.getSelection();

              if (selectedItems.length > 0) {
                final TreeItem treeItem = selectedItems[0];
                final Object data = treeItem.getData();
                if (data instanceof IErlFunctionClause) {
                  // enable the ok button
                  okButton.setEnabled(true);

                  // highlight
                  WranglerUtils.highlightSelection((IErlFunctionClause) data);

                  // store
                  functionClause = (IErlFunctionClause) data;
                } else {
                  okButton.setEnabled(false);
                }
              }
            }
          });
    } catch (final ErlModelException e) {
      ErlLogger.error(e);
    }

    applyDialogFont(composite);
    return composite;
  }
    @Override
    protected void createContent(Composite parent) {
      fSashForm = new SashForm(parent, parent.getStyle());
      fSashForm.setOrientation(SWT.VERTICAL);

      // update presentation context
      AbstractDebugView view = getViewToEmulate();
      fContext = new PresentationContext(TCFModel.ID_EXPRESSION_HOVER);
      if (view != null) {
        // copy over properties
        IPresentationContext copy = ((TreeModelViewer) view.getViewer()).getPresentationContext();
        try {
          String[] properties = copy.getProperties();
          for (int i = 0; i < properties.length; i++) {
            String key = properties[i];
            fContext.setProperty(key, copy.getProperty(key));
          }
        } catch (NoSuchMethodError e) {
          // ignore
        }
      }

      fViewer =
          new TreeModelViewer(fSashForm, SWT.MULTI | SWT.VIRTUAL | SWT.FULL_SELECTION, fContext);
      fViewer.setAutoExpandLevel(fExpansionLevel);

      if (view != null) {
        // copy over filters
        StructuredViewer structuredViewer = (StructuredViewer) view.getViewer();
        if (structuredViewer != null) {
          ViewerFilter[] filters = structuredViewer.getFilters();
          for (int i = 0; i < filters.length; i++) {
            fViewer.addFilter(filters[i]);
          }
        }
      }
      fInputService = new ViewerInputService(fViewer, this);
      fTree = fViewer.getTree();

      if (fShowDetailPane) {
        fDetailPaneComposite = SWTFactory.createComposite(fSashForm, 1, 1, GridData.FILL_BOTH);
        Layout layout = fDetailPaneComposite.getLayout();
        if (layout instanceof GridLayout) {
          GridLayout gl = (GridLayout) layout;
          gl.marginHeight = 0;
          gl.marginWidth = 0;
        }

        fDetailPane = new DetailPaneProxy(new DetailPaneContainer());
        fDetailPane.display(null); // Bring up the default pane so the
        // user doesn't see an empty
        // composite

        fTree.addSelectionListener(
            new SelectionListener() {
              public void widgetSelected(SelectionEvent e) {
                fDetailPane.display((IStructuredSelection) fViewer.getSelection());
              }

              public void widgetDefaultSelected(SelectionEvent e) {}
            });
      }

      initSashWeights();

      // add update listener to auto-select and display details of root
      // expression
      fViewer.addViewerUpdateListener(
          new IViewerUpdateListener() {
            public void viewerUpdatesComplete() {
              fViewer
                  .getDisplay()
                  .timerExec(
                      100,
                      new Runnable() {
                        public void run() {
                          if (fViewer.getControl().isDisposed()) return;
                          TreeSelection selection = (TreeSelection) fViewer.getSelection();
                          if (selection.isEmpty())
                            selection = new TreeSelection(fViewer.getTopElementPath());
                          fViewer.setSelection(selection);
                          if (fDetailPane != null) fDetailPane.display(selection);
                        }
                      });
            }

            public void viewerUpdatesBegin() {}

            public void updateStarted(IViewerUpdate update) {}

            public void updateComplete(IViewerUpdate update) {}
          });

      setBackgroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    }
Пример #18
0
  public void createControl(Composite parent) {
    final RepositoryUtil util = Activator.getDefault().getRepositoryUtil();
    Composite main = new Composite(parent, SWT.NONE);
    // use zero spacing to save some real estate here
    GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(main);

    final Button internalModeButton = new Button(main, SWT.CHECK);
    internalModeButton.setText(UIText.ExistingOrNewPage_InternalModeCheckbox);
    internalModeButton.setToolTipText(UIText.ExistingOrNewPage_CreationInWorkspaceWarningTooltip);
    internalModeButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            internalMode = internalModeButton.getSelection();
            updateControls();
          }
        });

    externalComposite = new Composite(main, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(externalComposite);
    externalComposite.setLayout(new GridLayout(3, false));

    new Label(externalComposite, SWT.NONE)
        .setText(UIText.ExistingOrNewPage_ExistingRepositoryLabel);
    final Combo existingRepoCombo = new Combo(externalComposite, SWT.READ_ONLY);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(existingRepoCombo);
    final ComboViewer v = new ComboViewer(existingRepoCombo);
    v.setContentProvider(new RepoComboContentProvider());
    v.setLabelProvider(new RepoComboLabelProvider());
    v.setInput(new Object());
    // the default ViewerSorter seems to do the right thing
    // i.e. sort as String
    v.setSorter(new ViewerSorter());

    existingRepoCombo.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            selectedRepository = null;
            IStructuredSelection sel = (IStructuredSelection) v.getSelection();
            setRepository((Repository) sel.getFirstElement());
            updateControls();
          }
        });

    Button createRepoWizard = new Button(externalComposite, SWT.PUSH);
    createRepoWizard.setText(UIText.ExistingOrNewPage_CreateRepositoryButton);
    createRepoWizard.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            NewRepositoryWizard wiz = new NewRepositoryWizard(true);
            if (new WizardDialog(getShell(), wiz).open() == Window.OK) {
              v.refresh();
              selectedRepository = wiz.getCreatedRepository();
              v.setSelection(new StructuredSelection(selectedRepository));
              updateControls();
            }
          }
        });

    new Label(externalComposite, SWT.NONE).setText(UIText.ExistingOrNewPage_WorkingDirectoryLabel);
    workDir = new Text(externalComposite, SWT.BORDER | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(workDir);
    GridDataFactory.fillDefaults().applyTo(workDir);
    // leave the space between the "Create" and "Browse" buttons empty (i.e.
    // do not fill to the right border
    new Label(externalComposite, SWT.NONE);

    new Label(externalComposite, SWT.NONE).setText(UIText.ExistingOrNewPage_RelativePathLabel);
    relPath = new Text(externalComposite, SWT.BORDER);
    relPath.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            updateControls();
          }
        });

    GridDataFactory.fillDefaults().grab(true, false).applyTo(relPath);
    browseRepository = new Button(externalComposite, SWT.PUSH);
    browseRepository.setEnabled(false);
    browseRepository.setText(UIText.ExistingOrNewPage_BrowseRepositoryButton);
    browseRepository.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            dlg.setFilterPath(selectedRepository.getWorkTree().getPath());
            String directory = dlg.open();
            if (directory != null) {
              setRelativePath(directory);
              updateControls();
            }
          }
        });

    Table projectMoveTable =
        new Table(externalComposite, SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK | SWT.BORDER);
    projectMoveViewer = new CheckboxTableViewer(projectMoveTable);
    GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(projectMoveTable);

    TableColumn tc;
    tc = new TableColumn(projectMoveTable, SWT.NONE);
    tc.setText(UIText.ExistingOrNewPage_ProjectNameColumnHeader);
    tc.setWidth(100);

    tc = new TableColumn(projectMoveTable, SWT.NONE);
    tc.setText(UIText.ExistingOrNewPage_CurrentLocationColumnHeader);
    tc.setWidth(250);

    tc = new TableColumn(projectMoveTable, SWT.NONE);
    tc.setText(UIText.ExistingOrNewPage_NewLocationTargetHeader);
    tc.setWidth(350);

    projectMoveTable.setHeaderVisible(true);
    projectMoveViewer.setContentProvider(ArrayContentProvider.getInstance());
    projectMoveViewer.setLabelProvider(moveProjectsLabelProvider);
    projectMoveViewer.setInput(myWizard.projects);
    projectMoveViewer.addCheckStateListener(
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            updateControls();
          }
        });
    TableItem[] children = projectMoveViewer.getTable().getItems();
    for (int i = 0; i < children.length; i++) {
      TableItem item = children[i];
      IProject data = (IProject) item.getData();
      RepositoryFinder repositoryFinder = new RepositoryFinder(data);
      repositoryFinder.setFindInChildren(false);
      try {
        Collection<RepositoryMapping> find = repositoryFinder.find(new NullProgressMonitor());
        if (find.size() != 1) item.setChecked(true);
      } catch (CoreException e1) {
        item.setText(2, e1.getMessage());
      }
    }

    parentRepoComposite = new Composite(main, SWT.NONE);
    parentRepoComposite.setLayout(new GridLayout(3, false));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parentRepoComposite);

    tree = new Tree(parentRepoComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);
    viewer = new CheckboxTreeViewer(tree);
    tree.setHeaderVisible(true);
    tree.setLayout(new GridLayout());
    tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 1).create());
    viewer.addCheckStateListener(
        new ICheckStateListener() {

          public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
              ProjectAndRepo checkable = (ProjectAndRepo) event.getElement();
              for (TreeItem ti : tree.getItems()) {
                if (ti.getItemCount() > 0
                    || ((ProjectAndRepo) ti.getData()).getRepo().equals("")) // $NON-NLS-1$
                ti.setChecked(false);
                for (TreeItem subTi : ti.getItems()) {
                  IProject project = ((ProjectAndRepo) subTi.getData()).getProject();
                  if (checkable.getProject() != null
                      && !subTi.getData().equals(checkable)
                      && checkable.getProject().equals(project)) subTi.setChecked(false);
                }
              }
            }
          }
        });
    TreeColumn c1 = new TreeColumn(tree, SWT.NONE);
    c1.setText(UIText.ExistingOrNewPage_HeaderProject);
    c1.setWidth(100);
    TreeColumn c2 = new TreeColumn(tree, SWT.NONE);
    c2.setText(UIText.ExistingOrNewPage_HeaderLocation);
    c2.setWidth(400);
    TreeColumn c3 = new TreeColumn(tree, SWT.NONE);
    c3.setText(UIText.ExistingOrNewPage_HeaderRepository);
    c3.setWidth(200);
    boolean allProjectsInExistingRepos = true;
    for (IProject project : myWizard.projects) {
      RepositoryFinder repositoryFinder = new RepositoryFinder(project);
      repositoryFinder.setFindInChildren(false);
      try {
        Collection<RepositoryMapping> mappings;
        mappings = repositoryFinder.find(new NullProgressMonitor());
        Iterator<RepositoryMapping> mi = mappings.iterator();
        RepositoryMapping m = mi.hasNext() ? mi.next() : null;
        if (m == null) {
          // no mapping found, enable repository creation
          TreeItem treeItem = new TreeItem(tree, SWT.NONE);
          updateProjectTreeItem(treeItem, project);
          treeItem.setText(1, project.getLocation().toOSString());
          treeItem.setText(2, ""); // $NON-NLS-1$
          treeItem.setData(new ProjectAndRepo(project, "")); // $NON-NLS-1$
          allProjectsInExistingRepos = false;
        } else if (!mi.hasNext()) {
          // exactly one mapping found
          TreeItem treeItem = new TreeItem(tree, SWT.NONE);
          updateProjectTreeItem(treeItem, project);
          treeItem.setText(1, project.getLocation().toOSString());
          fillTreeItemWithGitDirectory(m, treeItem, false);
          treeItem.setData(new ProjectAndRepo(project, m.getGitDirAbsolutePath().toOSString()));
          treeItem.setChecked(true);
        } else {
          TreeItem treeItem = new TreeItem(tree, SWT.NONE);
          updateProjectTreeItem(treeItem, project);
          treeItem.setText(1, project.getLocation().toOSString());
          treeItem.setData(new ProjectAndRepo(project, "")); // $NON-NLS-1$

          TreeItem treeItem2 = new TreeItem(treeItem, SWT.NONE);
          updateProjectTreeItem(treeItem2, project);
          fillTreeItemWithGitDirectory(m, treeItem2, true);
          treeItem2.setData(new ProjectAndRepo(project, m.getGitDirAbsolutePath().toOSString()));
          while (mi.hasNext()) { // fill in additional mappings
            m = mi.next();
            treeItem2 = new TreeItem(treeItem, SWT.NONE);
            updateProjectTreeItem(treeItem2, project);
            fillTreeItemWithGitDirectory(m, treeItem2, true);
            treeItem2.setData(
                new ProjectAndRepo(
                    m.getContainer().getProject(), m.getGitDirAbsolutePath().toOSString()));
          }
          treeItem.setExpanded(true);
          allProjectsInExistingRepos = false;
        }
      } catch (CoreException e) {
        TreeItem treeItem2 = new TreeItem(tree, SWT.BOLD | SWT.ITALIC);
        treeItem2.setText(e.getMessage());
      }
    }

    createRepo = new Button(parentRepoComposite, SWT.PUSH);
    createRepo.setLayoutData(GridDataFactory.fillDefaults().create());
    createRepo.setText(UIText.ExistingOrNewPage_CreateButton);
    createRepo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            File gitDir = new File(repositoryToCreate.getText(), Constants.DOT_GIT);
            try {
              Repository repository = FileRepositoryBuilder.create(gitDir);
              repository.create();
              for (IProject project : getProjects(false).keySet()) {
                // If we don't refresh the project directories right
                // now we won't later know that a .git directory
                // exists within it and we won't mark the .git
                // directory as a team-private member. Failure
                // to do so might allow someone to delete
                // the .git directory without us stopping them.
                // (Half lie, we should optimize so we do not
                // refresh when the .git is not within the project)
                //
                if (!gitDir.toString().contains("..")) // $NON-NLS-1$
                project.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
              }
              util.addConfiguredRepository(gitDir);
            } catch (IOException e1) {
              String msg =
                  NLS.bind(
                      UIText.ExistingOrNewPage_ErrorFailedToCreateRepository, gitDir.toString());
              org.eclipse.egit.ui.Activator.handleError(msg, e1, true);
            } catch (CoreException e2) {
              String msg =
                  NLS.bind(UIText.ExistingOrNewPage_ErrorFailedToRefreshRepository, gitDir);
              org.eclipse.egit.ui.Activator.handleError(msg, e2, true);
            }
            for (TreeItem ti : tree.getSelection()) {
              IPath projectPath = new Path(ti.getText(1));
              IPath gitPath = new Path(gitDir.toString());
              IPath relative = gitPath.makeRelativeTo(projectPath);
              ti.setText(2, relative.toOSString());
              ((ProjectAndRepo) ti.getData()).repo = gitDir.toString();
              ti.setChecked(true);
            }
            updateControls();
          }
        });
    repositoryToCreate = new Text(parentRepoComposite, SWT.SINGLE | SWT.BORDER);
    repositoryToCreate.setLayoutData(
        GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create());
    repositoryToCreate.addListener(
        SWT.Modify,
        new Listener() {
          public void handleEvent(Event e) {
            if (repositoryToCreate.getText().equals("")) { // $NON-NLS-1$
              createRepo.setEnabled(false);
              return;
            }
            IPath fromOSString = Path.fromOSString(repositoryToCreate.getText());
            createRepo.setEnabled(
                minumumPath.matchingFirstSegments(fromOSString) == fromOSString.segmentCount());
          }
        });
    dotGitSegment = new Label(parentRepoComposite, SWT.NONE);
    dotGitSegment.setEnabled(false);
    dotGitSegment.setText(File.separatorChar + Constants.DOT_GIT);
    dotGitSegment.setLayoutData(
        GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create());

    tree.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            tree.select((TreeItem) e.item);
            updateControls();
          }
        });

    Dialog.applyDialogFont(main);
    setControl(main);

    if (allProjectsInExistingRepos) {
      internalMode = true;
      internalModeButton.setSelection(true);
      updateControls();
    }
  }
  public RepositoryDirectoryInterface open() {
    dircolor = GUIResource.getInstance().getColorDirectory();

    Shell parent = getParent();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    shell.setText(BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.Main.Title"));

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);

    // Tree
    wTree = new Tree(shell, SWT.SINGLE | SWT.BORDER);
    props.setLook(wTree);

    try {
      // We're terrible and load the entire repository, disable lazy loading if set
      if (rep instanceof RepositoryExtended) {
        RepositoryExtended repositoryExtended = (RepositoryExtended) this.rep;
        repositoryTree = repositoryExtended.loadRepositoryDirectoryTree(true);
      } else {
        repositoryTree = this.rep.loadRepositoryDirectoryTree();
      }
    } catch (KettleException e) {
      new ErrorDialog(
          shell,
          BaseMessages.getString(
              PKG, "SelectDirectoryDialog.Dialog.ErrorRefreshingDirectoryTree.Title"),
          BaseMessages.getString(
              PKG, "SelectDirectoryDialog.Dialog.ErrorRefreshingDirectoryTree.Message"),
          e);
      return null;
    }

    if (!getData()) {
      return null;
    }

    // Buttons
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));

    wRefresh = new Button(shell, SWT.PUSH);
    wRefresh.setText(BaseMessages.getString(PKG, "System.Button.Refresh"));

    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));

    FormData fdTree = new FormData();
    FormData fdOK = new FormData();
    FormData fdRefresh = new FormData();
    FormData fdCancel = new FormData();

    int margin = 10;

    fdTree.left = new FormAttachment(0, 0); // To the right of the label
    fdTree.top = new FormAttachment(0, 0);
    fdTree.right = new FormAttachment(100, 0);
    fdTree.bottom = new FormAttachment(100, -50);
    wTree.setLayoutData(fdTree);

    fdOK.left = new FormAttachment(wTree, 0, SWT.CENTER);
    fdOK.bottom = new FormAttachment(100, -margin);
    wOK.setLayoutData(fdOK);

    fdRefresh.left = new FormAttachment(wOK, 10);
    fdRefresh.bottom = new FormAttachment(100, -margin);
    wRefresh.setLayoutData(fdRefresh);

    fdCancel.left = new FormAttachment(wRefresh, 10);
    fdCancel.bottom = new FormAttachment(100, -margin);
    wCancel.setLayoutData(fdCancel);

    // Add listeners
    wCancel.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            dispose();
          }
        });

    // Add listeners
    wOK.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            handleOK();
          }
        });

    wTree.addSelectionListener(
        new SelectionAdapter() {
          private String getSelectedPath(SelectionEvent selectionEvent) {
            TreeItem treeItem = (TreeItem) selectionEvent.item;
            String path;
            if (treeItem.getParentItem() == null) {
              path = treeItem.getText();
            } else {
              path = ConstUI.getTreePath(treeItem, 0);
            }
            return path;
          }

          private boolean isSelectedPathRestricted(SelectionEvent selectionEvent) {
            String path = getSelectedPath(selectionEvent);
            boolean isRestricted = isRestrictedPath(path);
            return isRestricted;
          }

          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            if (isSelectedPathRestricted(selectionEvent)) {
              return;
            }
            handleOK();
          }

          public void widgetSelected(SelectionEvent selectionEvent) {
            boolean restricted = isSelectedPathRestricted(selectionEvent);
            wOK.setEnabled(!restricted);
          }
        });

    wRefresh.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            getData();
          }
        });

    wTree.addMenuDetectListener(
        new MenuDetectListener() {
          public void menuDetected(MenuDetectEvent e) {
            setTreeMenu();
          }
        });

    BaseStepDialog.setSize(shell);

    shell.open();
    Display display = parent.getDisplay();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return selection;
  }
  /**
   * Create the main content for this information control.
   *
   * @param parent The parent composite
   * @return The control representing the main content.
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    fTreeViewer = createTreeViewer(parent, fTreeStyle);

    DartX.todo();
    //    fCustomFiltersActionGroup = new CustomFiltersActionGroup(getId(),
    //        fTreeViewer);

    final Tree tree = fTreeViewer.getTree();
    tree.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.character == 0x1B) {
              dispose();
            }
          }

          @Override
          public void keyReleased(KeyEvent e) {
            // do nothing
          }
        });

    tree.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            gotoSelectedElement();
          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            // do nothing
          }
        });

    tree.addMouseMoveListener(
        new MouseMoveListener() {
          TreeItem fLastItem = null;

          @Override
          public void mouseMove(MouseEvent e) {
            if (tree.equals(e.getSource())) {
              Object o = tree.getItem(new Point(e.x, e.y));
              if (o instanceof TreeItem) {
                if (!o.equals(fLastItem)) {
                  fLastItem = (TreeItem) o;
                  tree.setSelection(new TreeItem[] {fLastItem});
                }
              }
            }
          }
        });

    tree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {

            if (tree.getSelectionCount() < 1) {
              return;
            }

            if (e.button != 1) {
              return;
            }

            if (tree.equals(e.getSource())) {
              Object o = tree.getItem(new Point(e.x, e.y));
              TreeItem selection = tree.getSelection()[0];
              if (selection.equals(o)) {
                gotoSelectedElement();
              }
            }
          }
        });

    installFilter();

    addDisposeListener(this);
    return fTreeViewer.getControl();
  }