示例#1
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void setStatusLineManager(ISelection selection) {
    IStatusLineManager statusLineManager =
        currentViewer != null && currentViewer == contentOutlineViewer
            ? contentOutlineStatusLineManager
            : getActionBars().getStatusLineManager();

    if (statusLineManager != null) {
      if (selection instanceof IStructuredSelection) {
        Collection<?> collection = ((IStructuredSelection) selection).toList();
        switch (collection.size()) {
          case 0:
            {
              statusLineManager.setMessage(getString("_UI_NoObjectSelected"));
              break;
            }
          case 1:
            {
              String text =
                  new AdapterFactoryItemDelegator(adapterFactory)
                      .getText(collection.iterator().next());
              statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text));
              break;
            }
          default:
            {
              statusLineManager.setMessage(
                  getString("_UI_MultiObjectSelected", Integer.toString(collection.size())));
              break;
            }
        }
      } else {
        statusLineManager.setMessage("");
      }
    }
  }
  public void dispose() {
    getSite()
        .getWorkbenchWindow()
        .getSelectionService()
        .removePostSelectionListener(getSelectionServiceListener());
    if (fDoubleClickProvider != null) {
      getTreeViewer().removeDoubleClickListener(fDoubleClickProvider);
    }

    // dispose menu controls
    if (fContextMenu != null) {
      fContextMenu.dispose();
    }
    if (fContextMenuManager != null) {
      fContextMenuManager.removeMenuListener(fGroupAdder);
      fContextMenuManager.removeAll();
      fContextMenuManager.dispose();
    }

    fDropTarget.dispose();
    fDragSource.dispose();

    IStatusLineManager statusLineManager = getSite().getActionBars().getStatusLineManager();
    if (statusLineManager != null) {
      statusLineManager.setMessage(null);
    }
    unconfigure();
    super.dispose();
  }
 private static void showMessage(Shell shell, IActionBars actionBars, String msg) {
   if (actionBars != null) {
     IStatusLineManager statusLine = actionBars.getStatusLineManager();
     if (statusLine != null) statusLine.setMessage(msg);
   }
   shell.getDisplay().beep();
 }
 private void setStatusBarMessage(String message) {
   IEditorActionBarContributor contributor = fEditor.getEditorSite().getActionBarContributor();
   if (contributor instanceof EditorActionBarContributor) {
     IStatusLineManager manager =
         ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
     manager.setMessage(message);
   }
 }
  /** @param aSelection The current selection from the {@link CommonViewer} */
  protected void updateStatusBar(ISelection aSelection) {

    Image img = null;
    if (aSelection != null && !aSelection.isEmpty() && aSelection instanceof IStructuredSelection) {
      img = labelProvider.getImage(((IStructuredSelection) aSelection).getFirstElement());
    }

    statusLineManager.setMessage(img, commonDescriptionProvider.getDescription(aSelection));
  }
 void updateStatusLine(IStatusLineManager mgr, ISelection selection) {
   String text = null;
   Image image = null;
   ILabelProvider statusLineLabelProvider =
       getConfiguration().getStatusLineLabelProvider(getTreeViewer());
   if (statusLineLabelProvider != null
       && selection instanceof IStructuredSelection
       && !selection.isEmpty()) {
     Object firstElement = ((IStructuredSelection) selection).getFirstElement();
     text = statusLineLabelProvider.getText(firstElement);
     image = statusLineLabelProvider.getImage(firstElement);
   }
   if (image == null) {
     mgr.setMessage(text);
   } else {
     mgr.setMessage(image, text);
   }
 }
示例#7
0
  /**
   * Here, all the editors available will be gotten and searched (if possible).
   *
   * <p>Note that editors that are not in the workspace may not be searched (it should be possible
   * to do, but one may have to reimplement large portions of the search for that to work).
   */
  public static void findInOpenDocuments(
      final String searchText,
      final boolean caseSensitive,
      final boolean wholeWord,
      final boolean isRegEx,
      IStatusLineManager statusLineManager) {

    IWorkbenchWindow window = EditorUtils.getActiveWorkbenchWindow();
    if (window == null) {
      if (statusLineManager != null)
        statusLineManager.setErrorMessage("Active workbench window is null.");
      return;
    }
    IWorkbenchPage activePage = window.getActivePage();
    if (activePage == null) {
      if (statusLineManager != null) statusLineManager.setErrorMessage("Active page is null.");
      return;
    }
    IEditorReference editorsArray[] = activePage.getEditorReferences();

    final List<IFile> files = new ArrayList<IFile>();
    for (int i = 0; i < editorsArray.length; i++) {
      IEditorPart realEditor = editorsArray[i].getEditor(true);
      if (realEditor != null) {
        if (realEditor instanceof MultiPageEditorPart) {
          try {
            Method getPageCount = MultiPageEditorPart.class.getDeclaredMethod("getPageCount");
            getPageCount.setAccessible(true);
            Method getEditor = MultiPageEditorPart.class.getDeclaredMethod("getEditor", int.class);
            getEditor.setAccessible(true);

            Integer pageCount = (Integer) getPageCount.invoke(realEditor);
            for (int j = 0; j < pageCount; j++) {
              IEditorPart part = (IEditorPart) getEditor.invoke(realEditor, j);
              if (part != null) {
                IEditorInput input = part.getEditorInput();
                if (input != null) {
                  IFile file = (IFile) input.getAdapter(IFile.class);
                  if (file != null) {
                    files.add(file);
                  }
                }
              }
            }
          } catch (Throwable e1) {
            // Log it but keep going on.
            Log.log(e1);
          }

        } else {
          IEditorInput input = realEditor.getEditorInput();
          if (input != null) {
            IFile file = (IFile) input.getAdapter(IFile.class);
            if (file != null) {
              files.add(file);
            } else {
              // it has input, but it's not adaptable to an IFile!
              if (statusLineManager != null)
                statusLineManager.setMessage(
                    "Warning: Editors not in the workspace cannot be searched.");
              // but we keep on going...
            }
          }
        }
      }
    }

    if (files.size() == 0) {
      if (statusLineManager != null)
        statusLineManager.setMessage(
            "No file was found to perform the search (editors not in the workspace cannot be searched).");
      return;
    }

    try {
      ISearchQuery query =
          TextSearchQueryProvider.getPreferred()
              .createQuery(
                  new TextSearchInput() {

                    public boolean isRegExSearch() {
                      return isRegEx;
                    }

                    public boolean isCaseSensitiveSearch() {
                      return caseSensitive;
                    }

                    public String getSearchText() {
                      return searchText;
                    }

                    public FileTextSearchScope getScope() {
                      return FileTextSearchScope.newSearchScope(
                          files.toArray(new IResource[files.size()]), new String[] {"*"}, true);
                    }
                  });
      NewSearchUI.runQueryInBackground(query);
    } catch (CoreException e1) {
      Log.log(e1);
    }
  }
示例#8
0
 /**
  * Updates the StatusLine (the line right at the bottom with an image and a text string.
  *
  * @param imageFile - e.g. "/icons/signon.gif"
  * @param text - String to display next to the image
  */
 public static void updateStatusLine(String imageFile, String text) {
   IStatusLineManager slm = getStatusLine();
   Image signOnImage = new Image(null, getInputStream(imageFile));
   slm.setMessage(signOnImage, text);
   slm.update(true);
 }
  /*
   * @see EditorActionBarContributor#setActiveEditor(IEditorPart)
   */
  @Override
  public void setActiveEditor(IEditorPart part) {

    super.setActiveEditor(part);

    ITextEditor textEditor = null;
    if (part instanceof ITextEditor) textEditor = (ITextEditor) part;

    fTogglePresentation.setEditor(textEditor);
    fToggleMarkOccurrencesAction.setEditor(textEditor);

    fGotoMatchingBracket.setAction(
        getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
    fShowOutline.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.SHOW_OUTLINE));
    fOpenHierarchy.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.OPEN_HIERARCHY));
    fOpenStructure.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.OPEN_STRUCTURE));

    fStructureSelectEnclosingAction.setAction(
        getAction(textEditor, StructureSelectionAction.ENCLOSING));
    fStructureSelectNextAction.setAction(getAction(textEditor, StructureSelectionAction.NEXT));
    fStructureSelectPreviousAction.setAction(
        getAction(textEditor, StructureSelectionAction.PREVIOUS));
    fStructureSelectHistoryAction.setAction(
        getAction(textEditor, StructureSelectionAction.HISTORY));

    fGotoNextMemberAction.setAction(
        getAction(textEditor, GoToNextPreviousMemberAction.NEXT_MEMBER));
    fGotoPreviousMemberAction.setAction(
        getAction(textEditor, GoToNextPreviousMemberAction.PREVIOUS_MEMBER));

    fRemoveOccurrenceAnnotationsAction.setAction(
        getAction(textEditor, "RemoveOccurrenceAnnotations")); // $NON-NLS-1$
    fRetargetShowInformationAction.setAction(
        getAction(textEditor, ITextEditorActionConstants.SHOW_INFORMATION));

    if (part instanceof JavaEditor) {
      JavaEditor javaEditor = (JavaEditor) part;
      javaEditor.getActionGroup().fillActionBars(getActionBars());
      FoldingActionGroup foldingActions = javaEditor.getFoldingActionGroup();
      if (foldingActions != null) foldingActions.updateActionBars();
    }

    IActionBars actionBars = getActionBars();
    IStatusLineManager manager = actionBars.getStatusLineManager();
    manager.setMessage(null);
    manager.setErrorMessage(null);

    /** The global actions to be connected with editor actions */
    IAction action = getAction(textEditor, ITextEditorActionConstants.NEXT);
    actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, action);
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, action);
    action = getAction(textEditor, ITextEditorActionConstants.PREVIOUS);
    actionBars.setGlobalActionHandler(
        ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, action);
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, action);
    action = getAction(textEditor, IJavaEditorActionConstants.COPY_QUALIFIED_NAME);
    actionBars.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, action);

    actionBars.setGlobalActionHandler(
        IJavaEditorActionDefinitionIds.SHOW_IN_BREADCRUMB,
        getAction(textEditor, IJavaEditorActionDefinitionIds.SHOW_IN_BREADCRUMB));
    actionBars.setGlobalActionHandler(
        "org.eclipse.jdt.internal.ui.actions.OpenHyperlink",
        getAction(textEditor, ITextEditorActionConstants.OPEN_HYPERLINK)); // $NON-NLS-1$
  }
 private void updateStatus(String text) {
   IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
   statusLineManager.setMessage(text);
 }
示例#11
0
 public static void setSuccessfullyImported() {
   statusline.setMessage(
       Activator.getImageDescriptor("icons/info.png").createImage(),
       NLS.bind(Messages.StatusLine_Encrypted, remainingHddSpace()));
 }
示例#12
0
  public void createPartControl(Composite parent) {
    statusline = getViewSite().getActionBars().getStatusLineManager();
    statusline.setMessage(
        Activator.getImageDescriptor("icons/info.png").createImage(),
        Messages.StatusLine_DropFilesHint);
    makeActions();

    ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);
    Composite content = new Composite(scrolledComposite, SWT.NONE);
    content.setLayout(new GridLayout(1, false));
    scrolledComposite.setContent(content);

    toolBarManager = new ToolBarManager();
    toolBarManager.add(encryptFilesAction);
    toolBarManager.add(newFolderAction);
    toolBarManager.add(new Separator("static"));
    toolBarManager.add(exportSelectionAction);
    toolBarManager.add(renameAction);
    toolBarManager.add(deleteSelectionAction);
    toolBarManager.add(new Separator("static"));
    toolBarManager.add(expandAllAction);
    toolBarManager.add(collapseAllAction);

    ToolBar toolbar = toolBarManager.createControl(content);
    toolbar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));

    // Create the tree viewer as a child of the composite parent
    treeViewer =
        new TreeViewer(
            content, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);

    // Anpassungen für TreeTable
    tree = treeViewer.getTree();

    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    treeViewer.getControl().setLayoutData(gridData);

    treeViewer.setUseHashlookup(true);

    /** * Tree table specific code starts ** */
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);

    for (SteadyTableIdentifier identifier : SteadyTableIdentifier.values()) {
      new TreeColumn(tree, SWT.NONE).setText(Messages.getSteadyTableColumnTitle(identifier));
      tree.getColumn(identifier.ordinal()).setWidth(identifier.columnWidth);
    }

    /** * Tree table specific code ends ** */

    // layout the tree viewer below the text field
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    treeViewer.getControl().setLayoutData(gridData);

    treeViewer.setContentProvider(new SteadyTreeTableContentProvider());
    treeViewer.setLabelProvider(new SteadyTreeTableLabelProvider());

    root = getInitialInput();
    treeViewer.setInput(root);
    treeViewer.expandToLevel(1);

    // Drag-Part //////////////////////////////////////////////////////////
    DragSource source = new DragSource(tree, DND.DROP_COPY | DND.DROP_MOVE);
    source.setTransfer(new Transfer[] {TextTransfer.getInstance()});
    source.addDragListener(new TreeDragSourceListener(tree));

    // Drop-Part //////////////////////////////////////////////////////////
    DropTarget dropTarget = new DropTarget(tree, DND.DROP_COPY | DND.DROP_DEFAULT);
    dropTarget.setTransfer(new Transfer[] {TextTransfer.getInstance(), FileTransfer.getInstance()});
    dropTarget.addDropListener(new TreeDropTargetAdapter(treeViewer, root));

    addListeners();
    createContextMenu();
    createFiltersAndSorters();
  }