protected void refresh() {
    // get number of items
    int totalItems = contentProvider.getTotalItemCount();

    // update actions based upon item count and current page number
    pageBackwardsAction.setEnabled(totalItems != -1 && contentProvider.pageOffset > 1);
    pageForwardAction.setEnabled(
        totalItems != -1 && contentProvider.pageOffset + contentProvider.pageLength >= totalItems);

    // update label
    if (oozieUrl == null) {
      setContentDescription("OOZIE Url not configured");
      table.setEnabled(false);
    } else if (totalItems != -1) {
      setContentDescription("Communications Error, check problems view");
      table.setEnabled(false);
    } else {
      int maxItemIdx =
          Math.min(totalItems, contentProvider.pageOffset + contentProvider.pageLength - 1);
      setContentDescription(
          String.format(
              "Showing Jobs %d to %d (%d in total)",
              contentProvider.pageOffset, maxItemIdx, totalItems));

      table.setEnabled(true);
    }

    viewer.refresh();
  }
Beispiel #2
0
 /** Updates the enabled state for each navigation button. */
 protected void updateNavigationButtons() {
   if (homeAction != null) {
     homeAction.setEnabled(canGoHome());
     backAction.setEnabled(canGoBack());
     forwardAction.setEnabled(canGoInto());
   }
 }
  protected void fillContextMenu(IMenuManager manager) {
    Action removeAction =
        new Action(PDEUIMessages.CategorySection_remove) {
          public void run() {
            doGlobalAction(ActionFactory.DELETE.getId());
          }
        };
    removeAction.setEnabled(isEditable());
    manager.add(removeAction);
    getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager);

    ISelection selection = fCategoryViewer.getSelection();
    if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
      final ISiteFeature[] features = getFeaturesFromSelection((IStructuredSelection) selection);
      if (features.length > 0) {
        manager.add(new Separator());
        Action synchronizeAction = new SynchronizePropertiesAction(features, fModel);
        manager.add(synchronizeAction);
        Action buildAction =
            new Action(PDEUIMessages.CategorySection_build) {
              public void run() {
                ((SiteEditor) getPage().getPDEEditor()).handleBuild(features);
              }
            };
        buildAction.setEnabled(isEditable());
        manager.add(buildAction);
      }
    }
  }
  private void makeActions() {
    fAddAction =
        new Action(PDEUIMessages.RequiresSection_add) {
          @Override
          public void run() {
            handleAdd();
          }
        };
    fAddAction.setEnabled(isEditable());
    fGoToAction =
        new Action(PDEUIMessages.ImportPackageSection_goToPackage) {
          @Override
          public void run() {
            handleGoToPackage(fPackageViewer.getSelection());
          }
        };
    fRemoveAction =
        new Action(PDEUIMessages.RequiresSection_delete) {
          @Override
          public void run() {
            handleRemove();
          }
        };
    fRemoveAction.setEnabled(isEditable());

    fPropertiesAction =
        new Action(PDEUIMessages.ExportPackageSection_propertyAction) {
          @Override
          public void run() {
            handleOpenProperties();
          }
        };
  }
  /**
   * @see
   *     com.vectrace.MercurialEclipse.views.AbstractRootView#createMenus(org.eclipse.jface.action.IMenuManager)
   */
  @Override
  protected void createMenus(IMenuManager mgr) {
    final Action openMergeEditorAction =
        new Action("Open in Merge Editor") {
          @Override
          public void run() {
            ResolveStatus selection = table.getSelection();
            if (selection != null) {
              openMergeEditor(selection);
            }
          }
        };

    final Action openEditorAction =
        new Action("Open in Default Editor") {
          @Override
          public void run() {
            IFile file = getSelection();
            if (file == null) {
              return;
            }
            ResourceUtils.openEditor(getSite().getPage(), file);
          }
        };

    final Action actionShowHistory =
        new Action("Show History") {
          @Override
          public void run() {
            IFile file = getSelection();
            if (file == null) {
              return;
            }
            TeamUI.getHistoryView().showHistoryFor(file);
          }
        };
    actionShowHistory.setImageDescriptor(MercurialEclipsePlugin.getImageDescriptor("history.gif"));

    // Contribute actions to popup menu
    final MenuManager menuMgr = new MenuManager();
    Menu menu = menuMgr.createContextMenu(table);
    menuMgr.addMenuListener(
        new IMenuListener() {
          public void menuAboutToShow(IMenuManager menuMgr1) {
            menuMgr1.add(openMergeEditorAction);
            menuMgr1.add(openEditorAction);
            menuMgr1.add(new Separator());
            menuMgr1.add(actionShowHistory);
            menuMgr1.add(new Separator());
            menuMgr1.add(markResolvedAction);
            menuMgr1.add(markUnresolvedAction);
            menuMgr1.add(new Separator());
            menuMgr1.add(completeAction);
            menuMgr1.add(abortAction);
          }
        });

    menuMgr.setRemoveAllWhenShown(true);
    table.getTableViewer().getControl().setMenu(menu);
  }
  /**
   * Updates the enabled state of the toolbar items.
   *
   * <p>This method is called whenever the state of the items needs updating.
   *
   * <p>Subclasses may extend this method, although this is generally not required.
   */
  protected void updateToolItems() {

    IMergeViewerContentProvider content = getMergeContentProvider();
    if (content == null) {
      return;
    }
    Object input = getInput();

    if (fCopyLeftToRightAction != null) {
      boolean enable = content.isRightEditable(input);
      // if (enable && input instanceof ICompareInput) {
      // ITypedElement e= ((ICompareInput) input).getLeft();
      // if (e == null)
      // enable= false;
      // }
      fCopyLeftToRightAction.setEnabled(enable);
    }

    if (fCopyRightToLeftAction != null) {
      boolean enable = content.isLeftEditable(input);
      // if (enable && input instanceof ICompareInput) {
      // ITypedElement e= ((ICompareInput) input).getRight();
      // if (e == null)
      // enable= false;
      // }
      fCopyRightToLeftAction.setEnabled(enable);
    }
  }
  /**
   * @param editingDomain
   * @param manager
   * @param selection
   */
  private void addDeleteActionToContextMenu(
      final EditingDomain editingDomain,
      final IMenuManager manager,
      final IStructuredSelection selection) {

    final Action deleteAction =
        new Action() {
          @Override
          public void run() {
            super.run();
            DeleteService deleteService = getViewModelContext().getService(DeleteService.class);
            if (deleteService == null) {
              /*
               * #getService(Class<?>) will report to the reportservice if it could not be found
               * Use Default
               */
              deleteService = new EMFDeleteServiceImpl();
            }
            for (final Object obj : selection.toList()) {
              deleteService.deleteElement(obj);
            }
            treeViewer.setSelection(
                new StructuredSelection(getViewModelContext().getDomainModel()));
          }
        };
    final String deleteImagePath = "icons/delete.png"; // $NON-NLS-1$
    deleteAction.setImageDescriptor(
        ImageDescriptor.createFromURL(
            Activator.getDefault().getBundle().getResource(deleteImagePath)));
    deleteAction.setText("Delete"); // $NON-NLS-1$
    manager.add(deleteAction);
  }
  /**
   * Parses the given accelerator text, and converts it to an accelerator key code.
   *
   * @param acceleratorText the accelerator text
   * @result the SWT key code, or 0 if there is no accelerator
   */
  private int convertAccelerator(String acceleratorText) {
    int accelerator = 0;
    StringTokenizer stok = new StringTokenizer(acceleratorText, "+"); // $NON-NLS-1$

    int keyCode = -1;

    boolean hasMoreTokens = stok.hasMoreTokens();
    while (hasMoreTokens) {
      String token = stok.nextToken();
      hasMoreTokens = stok.hasMoreTokens();
      // Every token except the last must be one of the modifiers
      // Ctrl, Shift, or Alt.
      if (hasMoreTokens) {
        int modifier = Action.findModifier(token);
        if (modifier != 0) {
          accelerator |= modifier;
        } else { // Leave if there are none
          return 0;
        }
      } else {
        keyCode = Action.findKeyCode(token);
      }
    }
    if (keyCode != -1) {
      accelerator |= keyCode;
    }
    return accelerator;
  }
  public Menu getMenu(Control parent) {
    if (fMenu != null) {
      fMenu.dispose();
    }

    fMenu = new Menu(parent);
    for (int i = 0; i < LOG_LEVEL_MESSAGES.length; i++) {
      final int logLevel = i;
      Action action =
          new Action(LOG_LEVEL_MESSAGES[i]) {
            public void run() {
              console.setLogLevel(logLevel);
            }
          };
      action.setChecked(console.getLogLevel() == i);
      addActionToMenu(fMenu, action);
    }
    new Separator().fill(fMenu, -1);
    for (int i = 0; i < LOG_LEVEL_MESSAGES.length; i++) {
      final int logLevel = i;
      Action action =
          new Action("IvyDE " + LOG_LEVEL_MESSAGES[i]) {
            public void run() {
              console.getIvyDEMessageLogger().setLogLevel(logLevel);
            }
          };
      action.setChecked(console.getIvyDEMessageLogger().getLogLevel() == i);
      addActionToMenu(fMenu, action);
    }
    return fMenu;
  }
Beispiel #10
0
  @Override
  protected void createFormContent(IManagedForm mform) {
    mform.getForm().setText("Properties");
    final ScrolledForm form = mform.getForm();
    FormToolkit toolkit = new FormToolkit(getShell().getDisplay());

    GridLayout layout = new GridLayout();
    form.getBody().setLayout(layout);

    final String href = getHelpResource();
    if (href != null) {
      IToolBarManager manager = form.getToolBarManager();
      Action helpAction = new Action("help") { // $NON-NLS-1$
            public void run() {
              BusyIndicator.showWhile(
                  form.getDisplay(),
                  new Runnable() {
                    public void run() {
                      PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(href);
                    }
                  });
            }
          };
      helpAction.setToolTipText(PDEUIMessages.PDEFormPage_help);
      helpAction.setImageDescriptor(PDEPluginImages.DESC_HELP);
      manager.add(helpAction);
      form.updateToolBar();
    }
  }
Beispiel #11
0
  private void makeActions() {
    final MeclipseView mView = this;
    connection =
        new Action() {

          public void run() {

            ConnectionWizard wizard = new ConnectionWizard();
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

            WizardDialog dialog = new WizardDialog(shell, wizard);
            dialog.create();
            dialog.open();
            mView.refreshMe();
          }
        };

    connection.setText(getCaption("connection.new"));
    connection.setToolTipText(getCaption("connection.new"));
    connection.setImageDescriptor(Images.getDescriptor(Images.PageCommit));

    doubleClickAction =
        new Action() {
          public void run() {
            ISelection selection = viewer.getSelection();
            TreeObject obj = (TreeObject) ((IStructuredSelection) selection).getFirstElement();
            obj.doubleClickAction();
          }
        };
  }
  void executeCommand(String cmdLine) {
    clearStatus();

    IOSGiFrameworkConsole console =
        (IOSGiFrameworkConsole)
            getServer().getOriginal().loadAdapter(IOSGiFrameworkConsole.class, null);

    if (console == null) {
      IStatus status =
          EditorUIPlugin.newErrorStatus("Console editor part is not integrated with the runtime.");
      EditorUIPlugin.log(status);
      setStatus(status);
      return;
    }

    try {
      String result = console.executeCommand(cmdLine);
      manifestText.append("osgi> " + cmdLine + "\n");
      manifestText.append(result + "\n");
      forwardAction.setEnabled(history.canForward());
      backAction.setEnabled(history.canBack());
      toolBarManager.update(true);
      manifestText.setTopIndex(manifestText.getLineCount() - 1);
    } catch (CoreException e) {
      EditorUIPlugin.log(e);
      setStatus(
          EditorUIPlugin.newErrorStatus("Failed to execute command. See Error Log for details."));
    }

    commandText.setText("");
  }
Beispiel #13
0
  protected void createToolBarActions(IManagedForm managedForm) {
    final ScrolledForm form = managedForm.getForm();

    Action haction = new Action("hor", IAction.AS_RADIO_BUTTON) { // $NON-NLS-1$
          public void run() {
            sashForm.setOrientation(SWT.HORIZONTAL);
            form.reflow(true);
          }
        };
    haction.setChecked(true);
    haction.setToolTipText(PDEUIMessages.DetailsBlock_horizontal);
    haction.setImageDescriptor(PDEPluginImages.DESC_HORIZONTAL);
    haction.setDisabledImageDescriptor(PDEPluginImages.DESC_HORIZONTAL_DISABLED);

    Action vaction = new Action("ver", IAction.AS_RADIO_BUTTON) { // $NON-NLS-1$
          public void run() {
            sashForm.setOrientation(SWT.VERTICAL);
            form.reflow(true);
          }
        };
    vaction.setChecked(false);
    vaction.setToolTipText(PDEUIMessages.DetailsBlock_vertical);
    vaction.setImageDescriptor(PDEPluginImages.DESC_VERTICAL);
    vaction.setDisabledImageDescriptor(PDEPluginImages.DESC_VERTICAL_DISABLED);
    form.getToolBarManager().add(haction);
    form.getToolBarManager().add(vaction);
  }
Beispiel #14
0
 private void add(Action action, String imageName) {
   action.setId(action.getText());
   action.setImageDescriptor(
       PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(imageName));
   IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
   mgr.add(action);
 }
Beispiel #15
0
  private void addCreateSecurityButton(ToolBar toolBar) {
    Action createSecurity =
        new Action() {
          @Override
          public void run() {
            Security newSecurity = new Security();
            newSecurity.setFeed(QuoteFeed.MANUAL);
            Dialog dialog =
                new WizardDialog(
                    getClientEditor().getSite().getShell(),
                    new EditSecurityWizard(getClient(), newSecurity));
            if (dialog.open() == Dialog.OK) {
              markDirty();
              getClient().addSecurity(newSecurity);

              if (watchlist != null) watchlist.getSecurities().add(newSecurity);

              setSecurityTableInput();
              securities.updateQuotes(newSecurity);
            }
          }
        };
    createSecurity.setImageDescriptor(PortfolioPlugin.descriptor(PortfolioPlugin.IMG_PLUS));
    createSecurity.setToolTipText(Messages.SecurityMenuAddNewSecurity);

    new ActionContributionItem(createSecurity).fill(toolBar, -1);
  }
  private void addActionsForSelection(IMenuManager menuManager) {
    IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();

    if (selection.size() == 1) {
      Object element = selection.getFirstElement();

      if (!(element instanceof IMarker)) {
        return;
      }

      final IMarker marker = (IMarker) element;

      IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry().getResolutions(marker);

      for (final IMarkerResolution resolution : resolutions) {
        Action action =
            new Action(escapeSpecialChars(resolution.getLabel())) {
              @Override
              public void run() {
                resolution.run(marker);
              }
            };

        if (resolution instanceof IMarkerResolution2) {
          IMarkerResolution2 resolution2 = (IMarkerResolution2) resolution;
          Image image = resolution2.getImage();
          if (image != null) {
            action.setImageDescriptor(ImageDescriptor.createFromImage(image));
          }
        }

        menuManager.add(action);
      }
    }
  }
 @Override
 protected void configureAction(Action action) {
   action.setText(Messages.FilterTerminalRulesContribution_title);
   action.setDescription(Messages.FilterTerminalRulesContribution_description);
   action.setToolTipText(Messages.FilterTerminalRulesContribution_tooltip);
   action.setImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
   action.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
 }
 @Override
 protected void configureAction(Action action) {
   action.setText(Messages.HideReturnTypesAction_title);
   action.setToolTipText(Messages.HideReturnTypesAction_tooltip);
   action.setDescription(Messages.HideReturnTypesAction_description);
   action.setImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
   action.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
 }
 static void toggle(IAction action, ITextEditor editor) {
   StyledText text = (StyledText) editor.getAdapter(Control.class);
   boolean currentWrap = text.getWordWrap();
   text.setWordWrap(!currentWrap);
   if (action instanceof Action) {
     Action act = (Action) action;
     act.setChecked(!currentWrap);
   }
 }
  /**
   * Maps the localized modifier name to a code in the same manner as #findModifier.
   *
   * @param modifierName the modifier name
   * @return the SWT modifier bit, or <code>0</code> if no match was found
   */
  private static final int findLocalizedModifier(String modifierName) {
    if (modifierName == null) return 0;

    if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.CTRL))) return SWT.CTRL;
    if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.SHIFT))) return SWT.SHIFT;
    if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.ALT))) return SWT.ALT;
    if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.COMMAND))) return SWT.COMMAND;

    return 0;
  }
Beispiel #21
0
 protected void createActions() {
   super.createActions();
   final Action action =
       new ContentAssistAction(
           ResourceBundle.getBundle(GroovyEditor.class.getPackage().getName() + ".messages"),
           "ContentAssistProposal.",
           this);
   action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
   setAction("ContentAssist", action);
 }
  private void hookPopupMenu() {
    MenuManager menuMgr = new MenuManager("#PopupMenu"); // $NON-NLS-1$
    Menu menu = menuMgr.createContextMenu(rtTypeListViewer.getList());
    rtTypeListViewer.getControl().setMenu(menu);

    Action act = this.unlinkAction;
    act.setText(Messages.getString("RTCTypeToRTTypeWidget.24")); // $NON-NLS-1$
    act.setEnabled(false);
    menuMgr.add(act);
  }
 private ActionContributionItem buildRestoreModelACI() {
   Action action =
       new Action("Restore model", IAction.AS_PUSH_BUTTON) {
         @Override
         public void run() {
           TreeContentProviderUiTest.this.restoreModel();
         }
       };
   action.setToolTipText("Restore the model");
   return new ActionContributionItem(action);
 }
 private void setAncestorVisibility(boolean visible, boolean enabled) {
   if (fAncestorItem != null) {
     Action action = (Action) fAncestorItem.getAction();
     if (action != null) {
       action.setChecked(visible);
       action.setEnabled(enabled);
     }
   }
   getCompareConfiguration()
       .setProperty(ICompareUIConstants.PROP_ANCESTOR_VISIBLE, new Boolean(visible));
 }
  @Override
  protected void addButtons(final ToolBar toolBar) {
    AbstractDropDown dropdown =
        new AbstractDropDown(toolBar, getClient().getBaseCurrency()) {
          @Override
          public void menuAboutToShow(IMenuManager manager) {
            List<CurrencyUnit> available = CurrencyUnit.getAvailableCurrencyUnits();
            Collections.sort(available);
            for (final CurrencyUnit unit : available) {
              Action action =
                  new Action(unit.getLabel()) {
                    @Override
                    public void run() {
                      setLabel(unit.getCurrencyCode());
                      getClient().setBaseCurrency(unit.getCurrencyCode());
                    }
                  };
              action.setChecked(getClient().getBaseCurrency().equals(unit.getCurrencyCode()));
              manager.add(action);
            }
          }
        };
    currencyChangeListener = e -> dropdown.setLabel(e.getNewValue().toString());
    getClient().addPropertyChangeListener("baseCurrency", currencyChangeListener); // $NON-NLS-1$

    Action export =
        new Action() {
          @Override
          public void run() {
            new TableViewerCSVExporter(assetViewer.getTableViewer()) //
                .export(Messages.LabelStatementOfAssets + ".csv"); // $NON-NLS-1$
          }
        };
    export.setImageDescriptor(Images.EXPORT.descriptor());
    export.setToolTipText(Messages.MenuExportData);
    new ActionContributionItem(export).fill(toolBar, -1);

    Action save =
        new Action() {
          @Override
          public void run() {
            assetViewer.showSaveMenu(getActiveShell());
          }
        };
    save.setImageDescriptor(Images.SAVE.descriptor());
    save.setToolTipText(Messages.MenuSaveColumns);
    new ActionContributionItem(save).fill(toolBar, -1);

    Action config =
        new Action() {
          @Override
          public void run() {
            assetViewer.showConfigMenu(toolBar.getShell());
          }
        };
    config.setImageDescriptor(Images.CONFIG.descriptor());
    config.setToolTipText(Messages.MenuShowHideColumns);
    new ActionContributionItem(config).fill(toolBar, -1);
  }
 private void makeActions() {
   actionTestQuery =
       new Action() {
         public void run() {
           testQuery();
         }
       };
   actionTestQuery.setText("Test Query");
   actionTestQuery.setToolTipText("Test Query");
   actionTestQuery.setImageDescriptor(
       SmartRule1Plugin.getImageDescriptor("/icons/db_execute.gif"));
 }
Beispiel #27
0
 private boolean toggle(Action action, boolean input) {
   action.setChecked(!action.isChecked());
   IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
   for (IContributionItem item : mgr.getItems()) {
     if (item instanceof ActionContributionItem
         && ((ActionContributionItem) item).getAction() == action) {
       action.setChecked(!action.isChecked());
       return !input;
     }
   }
   return input;
 }
  private ActionHandler createQuickFixActionHandler(
      final ITextOperationTarget textOperationTarget) {
    Action quickFixAction =
        new Action() {

          public void run() {
            textOperationTarget.doOperation(ISourceViewer.QUICK_ASSIST);
          }
        };
    quickFixAction.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST);
    return new ActionHandler(quickFixAction);
  }
Beispiel #29
0
 /**
  * Adds a home button to the toolbar
  *
  * @param toolBar
  */
 private void setupToolbarButtons(IToolBarManager toolBar) {
   Action homeButton =
       new Action() {
         @Override
         public void run() {
           webEngine.load(homeLocation);
         }
       };
   homeButton.setText("Home");
   homeButton.setImageDescriptor(Activator.getImageDescriptor("icons/home.png"));
   toolBar.add(homeButton);
 }
 /**
  * Creates a button for an action.
  *
  * @param action the action
  */
 protected void createButtonForAction(final Action action) {
   Button selectButton = getToolkit().createButton(composite, "", SWT.PUSH);
   selectButton.setImage(action.getImageDescriptor().createImage());
   selectButton.setToolTipText(action.getToolTipText());
   selectButton.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetSelected(SelectionEvent e) {
           action.run();
         }
       });
 }