示例#1
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#createViewer(org.eclipse.swt.widgets.Composite)
   */
  protected StructuredViewer createViewer(Composite parent) {
    // Creates the viewer of this part dependent on the current layout.
    StructuredViewer viewer;
    if (isInListState()) viewer = createTableViewer(parent);
    else viewer = createTreeViewer(parent);

    fWrappedViewer.setViewer(viewer);
    return fWrappedViewer;
  }
示例#2
0
 private void createSelectAllAction() {
   IActionBars actionBars = getViewSite().getActionBars();
   if (isInListState()) {
     fSelectAllAction = new SelectAllAction((TableViewer) fWrappedViewer.getViewer());
     actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);
   } else {
     actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), null);
     fSelectAllAction = null;
   }
   actionBars.updateActionBars();
 }
示例#3
0
  private void switchViewer(int state) {
    // Indicate which viewer is to be used
    if (fCurrViewState == state) return;
    else {
      fCurrViewState = state;
      IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();
      store.setValue(getViewSite().getId() + TAG_VIEW_STATE, state);
    }

    // get the information from the existing viewer
    StructuredViewer viewer = fWrappedViewer.getViewer();
    Object object = viewer.getInput();
    ISelection selection = viewer.getSelection();

    // create and set up the new viewer
    Control control = createViewer(fWrappedViewer.getControl().getParent()).getControl();

    setUpViewer(fWrappedViewer);

    createSelectAllAction();

    // add the selection information from old viewer
    fWrappedViewer.setViewerInput(object);
    fWrappedViewer.getControl().setFocus();
    fWrappedViewer.setSelection(selection, true);

    // dispose old viewer
    viewer.getContentProvider().dispose();
    viewer.getControl().dispose();

    // layout the new viewer
    if (control != null && !control.isDisposed()) {
      control.setVisible(true);
      control.getParent().layout(true);
    }
  }
示例#4
0
  /*
   * Overridden from JavaBrowsingPart to handel LogicalPackages and tree
   * structure.
   *
   * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#adjustInputAndSetSelection(org.eclipse.jdt.core.IJavaElement)
   */
  void adjustInputAndSetSelection(IModelElement je) {

    IModelElement jElementToSelect = findElementToSelect(je);
    LogicalPackagesProvider p = (LogicalPackagesProvider) fWrappedViewer.getContentProvider();

    Object elementToSelect = jElementToSelect;
    if (jElementToSelect != null
        && jElementToSelect.getElementType() == IModelElement.SCRIPT_FOLDER) {
      IScriptFolder pkgFragment = (IScriptFolder) jElementToSelect;
      elementToSelect = p.findLogicalPackage(pkgFragment);
      if (elementToSelect == null) elementToSelect = pkgFragment;
    }

    IModelElement newInput = findInputForJavaElement(je);
    if (elementToSelect == null && !isValidInput(newInput)) setInput(null);
    else if (elementToSelect == null || getViewer().testFindItem(elementToSelect) == null) {

      // optimization, if you are in the same project but expansion hasn't
      // happened
      Object input = getViewer().getInput();
      if (elementToSelect != null && newInput != null) {
        if (newInput.equals(input)) {
          getViewer().reveal(elementToSelect);
          // Adjust input to selection
        } else {
          setInput(newInput);
          getViewer().reveal(elementToSelect);
        }
      } else setInput(newInput);

      if (elementToSelect instanceof IScriptFolder) {
        IScriptFolder pkgFragment = (IScriptFolder) elementToSelect;
        elementToSelect = p.findLogicalPackage(pkgFragment);
        if (elementToSelect == null) elementToSelect = pkgFragment;
      }
    }

    ISelection selection;
    if (elementToSelect != null) selection = new StructuredSelection(elementToSelect);
    else selection = StructuredSelection.EMPTY;
    setSelection(selection, true);
  }
示例#5
0
 private void setViewerWrapperInput(Object input) {
   fWrappedViewer.setViewerInput(input);
 }
示例#6
0
 /**
  * Overrides the createContentProvider from JavaBrowsingPart Creates the content provider of this
  * part.
  */
 protected IContentProvider createContentProvider() {
   if (isInListState()) return new PackagesViewFlatContentProvider(fWrappedViewer.getViewer());
   else return new PackagesViewHierarchicalContentProvider(fWrappedViewer.getViewer());
 }