コード例 #1
0
  @Override
  protected Control createControl(Composite parent) {
    super.createControl(parent);
    ToolBar buttons = new ToolBar(parent, SWT.FLAT | SWT.WRAP);

    ToolItem changeImage = new ToolItem(buttons, SWT.PUSH);
    changeImage.setImage(
        JaspersoftStudioPlugin.getInstance().getImage("icons/resources/equalizer--arrow.png"));
    changeImage.setToolTipText("Set exporter properties");
    changeImage.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            createPopupMenu();
            if (popupMenu.isVisible()) {
              popupMenu.setVisible(false);
            } else {
              locatePopupMenu(popupMenu);
              popupMenu.setVisible(true);
            }
          }
        });

    return buttons;
  }
コード例 #2
0
  /**
   * Create on the table manger the toolbar actions for the outline. The actions are created only if
   * the toolbar manager dosen't contains them already. Actually the added action are the one the
   * show the standard outline and the one to show the thumbnail of the report.
   *
   * @param tbm the toolbar manager for the outline.
   */
  public void registerToolbarAction(IToolBarManager tbm) {
    IContributionItem items[] = tbm.getItems();
    HashSet<String> existingItems = new HashSet<String>();
    for (IContributionItem item : items) {
      existingItems.add(item.getId());
    }

    showOutlineAction =
        new Action() {
          @Override
          public void run() {
            showPage(ID_ACTION_OUTLINE);
          }
        };
    showOutlineAction.setId(ID_ACTION_OUTLINE);
    showOutlineAction.setImageDescriptor(
        JaspersoftStudioPlugin.getInstance()
            .getImageDescriptor("icons/outline.gif")); // $NON-NLS-1$
    showOutlineAction.setToolTipText(Messages.JDReportOutlineView_show_outline_tool_tip);
    if (!existingItems.contains(ID_ACTION_OUTLINE)) {
      ActionContributionItem showOutlineItem = new ActionContributionItem(showOutlineAction);
      showOutlineItem.setVisible(true);
      tbm.add(showOutlineItem);
    }

    showOverviewAction =
        new Action() {
          @Override
          public void run() {
            showPage(ID_ACTION_OVERVIEW);
          }
        };
    showOverviewAction.setId(ID_ACTION_OVERVIEW);
    showOverviewAction.setImageDescriptor(
        JaspersoftStudioPlugin.getInstance()
            .getImageDescriptor("icons/overview.gif")); // $NON-NLS-1$
    showOverviewAction.setToolTipText(Messages.JDReportOutlineView_show_overview_tool_tip);
    if (!existingItems.contains(ID_ACTION_OVERVIEW)) {
      ActionContributionItem showOverviewItem = new ActionContributionItem(showOverviewAction);
      showOverviewItem.setVisible(true);
      tbm.add(showOverviewItem);
    }
  }