private void createFeaturesToolbar(FormToolkit toolkit, Section section) {
    Composite headerComposite = toolkit.createComposite(section, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 0;
    rowLayout.marginBottom = 0;
    headerComposite.setLayout(rowLayout);
    headerComposite.setBackground(null);

    toolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
    toolBarManager.createControl(headerComposite);

    installAction = new InstallAction();
    installAction.setEnabled(false);
    toolBarManager.add(installAction);

    toolBarManager.add(new CheckForUpdatesAction());

    CommandContributionItem item =
        JBossCentralActivator.createContributionItem(
            getSite(), "org.jboss.tools.central.refreshDiscovery");
    toolBarManager.add(item);

    toolBarManager.update(true);

    section.setTextClient(headerComposite);
  }
 /**
  * To Manage the creation of an ancestor action to manage the visibilty of the ancestor Pane.
  *
  * @param ok boolean parameters if true the action is created if false the action is not created.
  * @param toolBarManager the ToolBarManager on which the action should be added
  */
 private void createAncestorPaneManagerAction(ToolBarManager toolBarManager, boolean ok) {
   if (ok) {
     toolBarManager.add(showHideAncestor);
     Separator separator = new Separator();
     toolBarManager.add(separator);
   }
 }
  private void initializeToolbars(Composite parent) {
    ToolBarManager tbm = CompareViewerPane.getToolBarManager(parent);
    if (tbm != null) {
      tbm.removeAll();

      // define groups
      tbm.add(new Separator("modes")); // $NON-NLS-1$
      tbm.add(new Separator("merge")); // $NON-NLS-1$
      tbm.add(new Separator("navigation")); // $NON-NLS-1$

      CompareConfiguration cc = getCompareConfiguration();

      if (cc.isRightEditable()) {
        fCopyLeftToRightAction =
            new Action() {
              public void run() {
                copy(true);
              }
            };
        Utilities.initAction(
            fCopyLeftToRightAction, getResourceBundle(), "action.CopyLeftToRight."); // $NON-NLS-1$
        tbm.appendToGroup("merge", fCopyLeftToRightAction); // $NON-NLS-1$
        fHandlerService.registerAction(
            fCopyLeftToRightAction, "org.eclipse.compare.copyAllLeftToRight"); // $NON-NLS-1$
      }

      if (cc.isLeftEditable()) {
        fCopyRightToLeftAction =
            new Action() {
              public void run() {
                copy(false);
              }
            };
        Utilities.initAction(
            fCopyRightToLeftAction, getResourceBundle(), "action.CopyRightToLeft."); // $NON-NLS-1$
        tbm.appendToGroup("merge", fCopyRightToLeftAction); // $NON-NLS-1$
        fHandlerService.registerAction(
            fCopyRightToLeftAction, "org.eclipse.compare.copyAllRightToLeft"); // $NON-NLS-1$
      }

      final ChangePropertyAction a =
          new ChangePropertyAction(
              fBundle,
              getCompareConfiguration(),
              "action.EnableAncestor.",
              ICompareUIConstants.PROP_ANCESTOR_VISIBLE); // $NON-NLS-1$
      a.setChecked(fAncestorVisible);
      fAncestorItem = new ActionContributionItem(a);
      fAncestorItem.setVisible(false);
      tbm.appendToGroup("modes", fAncestorItem); // $NON-NLS-1$
      tbm.getControl().addDisposeListener(a);

      createToolItems(tbm);
      updateToolItems();

      tbm.update(true);
    }
  }
  @Override
  protected void fillCoolBar(ICoolBarManager coolBar) {

    ToolBarManager toolBarManager = new ToolBarManager(SWT.ARROW_DOWN);
    coolBar.add(toolBarManager);

    toolBarManager.add(introAction);
    toolBarManager.add(saveAction);
  }
 @Override
 protected void createToolbarItems(ToolBarManager manager) {
   IAction action = getActionRegistry().getAction(IActionIDConstant.CV_ADD);
   manager.add(action);
   action = getActionRegistry().getAction(IActionIDConstant.CV_DELETE);
   manager.add(action);
   action = getActionRegistry().getAction(IActionIDConstant.CV_MOVE_UP);
   manager.add(action);
   action = getActionRegistry().getAction(IActionIDConstant.CV_MOVE_DOWN);
   manager.add(action);
 }
  protected void fillCoolBar(ICoolBarManager coolBar) {
    final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    coolBar.add(toolBarManager);

    toolBarManager.add(saveAction);

    toolBarManager.add(new Separator());

    toolBarManager.add(undoAction);

    toolBarManager.add(redoAction);

    toolBarManager.add(openglAction);
  }
 @Override
 protected void fillToolBar(ToolBarManager toolBar) {
   if (needsRefresh()) {
     IAction repositoryConfigRefresh = doCreateRefreshAction();
     toolBar.add(repositoryConfigRefresh);
   }
 }
Example #8
0
 public void addActions(IAction[] actions) {
   if (actions == null) return;
   for (int i = 0; i < actions.length; i++) {
     toolBarManager.add(createActionContributionItem(actions[i]));
   }
   toolBarManager.update(true);
 }
 /**
  * @param parentManager
  * @param itemModel
  * @param ci
  */
 private void addToManager(
     ToolBarManager parentManager, MToolBarElement model, IContributionItem ci) {
   MElementContainer<MUIElement> parent = model.getParent();
   // technically this shouldn't happen
   if (parent == null) {
     parentManager.add(ci);
   } else {
     int index = parent.getChildren().indexOf(model);
     // shouldn't be -1, but better safe than sorry
     if (index > parentManager.getSize() || index == -1) {
       parentManager.add(ci);
     } else {
       parentManager.insert(index, ci);
     }
   }
 }
Example #10
0
  @Override
  public void createPartControl(final Composite parent) {
    resizeAction =
        new Action("Resize", SWT.TOGGLE) {
          @Override
          public void run() {
            updatePreview(true);
          }
        };
    resizeAction.setImageDescriptor(
        Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "/icons/resize.png"));

    GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(parent);
    ToolBar toolbar = new ToolBar(parent, SWT.VERTICAL | SWT.FLAT);
    toolbar.setBackground(toolbar.getDisplay().getSystemColor(SWT.COLOR_GRAY));
    ToolBarManager toolbarManager = new ToolBarManager(toolbar);
    toolbarManager.add(resizeAction);
    GridDataFactory.fillDefaults()
        .grab(false, true)
        .align(SWT.BEGINNING, SWT.FILL)
        .applyTo(toolbar);
    toolbarManager.update(true);

    container = new Composite(parent, SWT.NONE);
    container.setLayout(new FillLayout());
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(container);

    getSite().getPage().addPartListener(trackRelevantEditorsPartListener);
    tryConnectTo(getSite().getPage().getActiveEditor());
  }
Example #11
0
  private Control createToolBar(Composite parent) {
    toolBar = new ToolBarManager();

    picker = new ColorPicker(configurer.getPopupStyle(), configurer.getPalette());
    configureColorPicker(picker);

    toolBar.add(picker);
    toolBar.createControl(parent);
    return toolBar.getControl();
  }
  @Override
  protected void contributeEditorCommands(ToolBarManager toolBarManager) {
    super.contributeEditorCommands(toolBarManager);

    toolBarManager.add(new Separator());
    toolBarManager.add(
        new ControlContribution("DDLFormat") {
          @Override
          protected Control createControl(Composite parent) {
            final Combo ddlFormatCombo =
                new Combo(parent, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
            ddlFormatCombo.setToolTipText("DDL Format");
            for (OracleDDLFormat format : OracleDDLFormat.values()) {
              ddlFormatCombo.add(format.getTitle());
              if (format == ddlFormat) {
                ddlFormatCombo.select(ddlFormatCombo.getItemCount() - 1);
              }
            }
            ddlFormatCombo.addSelectionListener(
                new SelectionAdapter() {
                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    for (OracleDDLFormat format : OracleDDLFormat.values()) {
                      if (format.ordinal() == ddlFormatCombo.getSelectionIndex()) {
                        ddlFormat = format;
                        getEditorInput()
                            .getDatabaseObject()
                            .getDataSource()
                            .getContainer()
                            .getPreferenceStore()
                            .setValue(OracleConstants.PREF_KEY_DDL_FORMAT, ddlFormat.name());
                        refreshPart(this, true);
                        break;
                      }
                    }
                  }
                });
            return ddlFormatCombo;
          }
        });
  }
  private void createSectionToolbar(Section section, FormToolkit toolkit) {
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolbar = toolBarManager.createControl(section);
    final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
    toolbar.setCursor(handCursor);
    // Cursor needs to be explicitly disposed
    toolbar.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            if (handCursor.isDisposed() == false) {
              handCursor.dispose();
            }
          }
        });
    fNewPluginAction = new NewPluginAction();
    fNewFragmentAction = new NewFragmentAction();
    toolBarManager.add(fNewPluginAction);
    toolBarManager.add(fNewFragmentAction);

    toolBarManager.update(true);
    section.setTextClient(toolbar);
  }
    /*
     * @see edu.berkeley.eduride.isa.ui.text.java.hover.AbstractAnnotationHover.AnnotationInfo#fillToolBar(org.eclipse.jface.action.ToolBarManager)
     */
    public void fillToolBar(ToolBarManager manager, IInformationControl infoControl) {
      super.fillToolBar(manager, infoControl);
      if (!(annotation instanceof IJavaAnnotation)) return;

      IJavaAnnotation javaAnnotation = (IJavaAnnotation) annotation;

      String optionId = JavaCore.getOptionForConfigurableSeverity(javaAnnotation.getId());
      if (optionId != null) {
        IJavaProject javaProject = javaAnnotation.getCompilationUnit().getJavaProject();
        boolean isJavadocProblem = (javaAnnotation.getId() & IProblem.Javadoc) != 0;
        ConfigureProblemSeverityAction problemSeverityAction =
            new ConfigureProblemSeverityAction(
                javaProject, optionId, isJavadocProblem, infoControl);
        manager.add(problemSeverityAction);
      }
    }
  private void createMemoryBlocksTreeViewPane(Composite parent) {

    fMemBlkViewer = new MemoryBlocksTreeViewPane(this);
    fViewPanes.put(MemoryBlocksTreeViewPane.PANE_ID, fMemBlkViewer);
    ViewForm viewerViewForm = new ViewForm(parent, SWT.NONE);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(
            viewerViewForm, IDebugUIConstants.PLUGIN_ID + ".MemoryView_context"); // $NON-NLS-1$
    fViewPaneControls.put(MemoryBlocksTreeViewPane.PANE_ID, viewerViewForm);
    fWeights.add(Integer.valueOf(15));

    fMemBlkViewer.addSelectionListener(fSelectionProvider);

    Control viewerControl =
        fMemBlkViewer.createViewPane(
            viewerViewForm,
            MemoryBlocksTreeViewPane.PANE_ID,
            DebugUIMessages.MemoryView_Memory_monitors);
    viewerViewForm.setContent(viewerControl);

    ISelection selection = fMemBlkViewer.getSelectionProvider().getSelection();
    if (selection != null) fSelectionProvider.setSelection(selection);

    ToolBarManager viewerToolBarMgr = new ToolBarManager(SWT.FLAT);
    IAction[] actions = fMemBlkViewer.getActions();
    for (int i = 0; i < actions.length; i++) {
      viewerToolBarMgr.add(actions[i]);
    }
    ToolBar viewerToolbar = viewerToolBarMgr.createControl(viewerViewForm);
    viewerViewForm.setTopRight(viewerToolbar);

    Label viewerLabel = new Label(viewerViewForm, SWT.WRAP);
    viewerLabel.setText(DebugUIMessages.MemoryView_Memory_monitors);
    viewerViewForm.setTopLeft(viewerLabel);

    fMemBlkViewer
        .getControl()
        .addFocusListener(
            new FocusAdapter() {
              @Override
              public void focusGained(FocusEvent e) {
                fActivePaneId = fMemBlkViewer.getId();
              }
            });
  }
Example #16
0
  /**
   * Create the button that clears the text.
   *
   * @param parent parent <code>Composite</code> of toolbar button
   */
  private void createClearText(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.HORIZONTAL);
    filterToolBar = new ToolBarManager(toolBar);

    IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) { // $NON-NLS-1$
          /*
           * (non-Javadoc)
           *
           * @see org.eclipse.jface.action.Action#run()
           */
          public void run() {
            clearText();
          }
        };

    clearTextAction.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip);
    clearTextAction.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON));
    clearTextAction.setDisabledImageDescriptor(
        JFaceResources.getImageRegistry().getDescriptor(DCLEAR_ICON));

    filterToolBar.add(clearTextAction);
  }
Example #17
0
  protected void createSectionToolbar(Section section, FormToolkit toolkit) {
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolbar = toolBarManager.createControl(section);
    final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
    toolbar.setCursor(handCursor);
    // Cursor needs to be explicitly disposed
    toolbar.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent e) {
            if ((handCursor != null) && (handCursor.isDisposed() == false)) {
              handCursor.dispose();
            }
          }
        });

    // save
    ActionContributionItem saveMenuAction =
        new ActionContributionItem(ActionFactory.SAVE.create(getEditorSite().getWorkbenchWindow()));
    toolBarManager.add(saveMenuAction);
    toolBarManager.update(true);

    section.setTextClient(toolbar);
  }
  /**
   * Adds the header to a parent composite.
   *
   * @param parent the parent
   */
  protected void createHeader(Composite parent) {
    final Composite headerComposite = new Composite(parent, SWT.NONE);
    final GridLayout headerLayout = GridLayoutFactory.fillDefaults().create();
    headerComposite.setLayout(headerLayout);
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.FILL)
        .grab(true, false)
        .applyTo(headerComposite);
    headerBgColor = new Color(parent.getDisplay(), new RGB(220, 240, 247));
    headerComposite.setBackground(headerBgColor);

    final EObject modelElement = getViewModelContext().getDomainModel();
    final EditingDomain editingDomain =
        AdapterFactoryEditingDomain.getEditingDomainFor(modelElement);

    /* The header of the composite */
    if (modelElement.eContainer() == null && !DynamicEObjectImpl.class.isInstance(modelElement)) {

      final Composite header = getPageHeader(headerComposite);
      final List<Action> actions = readToolbarActions(modelElement, editingDomain);

      final ToolBar toolBar = new ToolBar(header, SWT.FLAT | SWT.RIGHT);
      final FormData formData = new FormData();
      formData.right = new FormAttachment(100, 0);
      toolBar.setLayoutData(formData);
      toolBar.layout();
      final ToolBarManager toolBarManager = new ToolBarManager(toolBar);

      /* Add actions to header */
      for (final Action action : actions) {
        toolBarManager.add(action);
      }
      toolBarManager.update(true);
      header.layout();
    }
  }
 /**
  * Create the composite.
  *
  * @param parent a widget which will be the parent of the new instance (cannot be null)
  * @param style the style of widget to construct
  */
 public VisualisationDiffToolBar(Composite parent, int style) {
   super(parent, style);
   createActions();
   setLayout(new FormLayout());
   /** Left Tool Bar */
   Composite leftToolBarComposite = new Composite(this, SWT.NONE);
   leftToolBarComposite.setLayout(new FormLayout());
   FormData fdleftToolBarComposite = new FormData();
   fdleftToolBarComposite.top = new FormAttachment(0);
   fdleftToolBarComposite.left = new FormAttachment(0);
   leftToolBarComposite.setLayoutData(fdleftToolBarComposite);
   ToolBar leftToolBar = new ToolBar(leftToolBarComposite, SWT.FLAT | SWT.RIGHT);
   FormData fdleftToolBar = new FormData();
   fdleftToolBar.top = new FormAttachment(0);
   leftToolBar.setLayoutData(fdleftToolBar);
   visualizationType = new ToolItem(leftToolBar, SWT.NONE);
   visualizationType.setImage(
       ResourceManager.getPluginImage(
           "org.eclipse.emf.compare.ui.2", "iconsMainTBar/differencesIcon.gif"));
   visualizationType.setText("Visualizatin of Structural Differences");
   // lblNewLabel.setImage(ResourceManager.getPluginImage("org.eclipse.emf.compare.ui.2",
   // "icons/next_nav_into.gif"));
   leftToolBar.update();
   /** RighToolBar */
   ToolBar righToolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT);
   FormData fdRighToolBar = new FormData();
   fdRighToolBar.top = new FormAttachment(0);
   fdRighToolBar.right = new FormAttachment(100);
   righToolBar.setLayoutData(fdRighToolBar);
   ToolBarManager righToolBarManager = new ToolBarManager(righToolBar);
   createAncestorPaneManagerAction(righToolBarManager, EMFCompareConfiguration.fThreeWay);
   righToolBarManager.add(copyAlltoRight);
   righToolBarManager.add(copyAlltoLeft);
   righToolBarManager.add(copyLeftTorRight);
   righToolBarManager.add(copyRightToLeft);
   righToolBarManager.add(new Separator());
   righToolBarManager.add(nextChange);
   righToolBarManager.add(previousChange);
   righToolBar.update();
   righToolBarManager.update(true);
 }
  /* (non-Javadoc)
   * @see com.hundsun.ares.studio.jres.ui.pages.ColumnViewerBlock#createButtons(com.hundsun.ares.studio.jres.ui.actions.ButtonGroupManager)
   */
  @Override
  protected void createToolbarItems(ToolBarManager manager) {
    // 创建详细表的操作列表
    IAction action = getActionRegistry().getAction(IActionIDConstant.CV_ADD);
    manager.add(action);

    action = getActionRegistry().getAction(IMetadataActionIDConstant.CV_BATCH_ADD);
    manager.add(action);

    action = getActionRegistry().getAction(IMetadataActionIDConstant.CV_RECOVER_FUNCTIONS);
    manager.add(action);

    action = getActionRegistry().getAction(IActionIDConstant.CV_DELETE);
    manager.add(action);

    action = getActionRegistry().getAction(IActionIDConstant.CV_MOVE_UP);
    manager.add(action);

    action = getActionRegistry().getAction(IActionIDConstant.CV_MOVE_DOWN);
    manager.add(action);
  }
 protected ToolBarManager createToolBarManager(int style) {
   ToolBarManager tool_bar_manager = new ToolBarManager(style);
   tool_bar_manager.add(status_action);
   return tool_bar_manager;
 }
  /**
   * Get the toolbar for the container
   *
   * @return Control
   */
  Control getContainerToolBar(Composite composite) {

    final ToolBarManager historyManager = new ToolBarManager(SWT.HORIZONTAL | SWT.FLAT);
    historyManager.createControl(composite);

    history.createHistoryControls(historyManager.getControl(), historyManager);

    Action popupMenuAction =
        new Action() {
          @Override
          public ImageDescriptor getImageDescriptor() {
            return WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU);
          }

          @Override
          public void run() {
            MenuManager manager = new MenuManager();
            manager.add(
                new Action() {
                  @Override
                  public void run() {

                    sash.addFocusListener(
                        new FocusAdapter() {
                          @Override
                          public void focusGained(FocusEvent e) {
                            sash.setBackground(
                                sash.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
                          }

                          @Override
                          public void focusLost(FocusEvent e) {
                            sash.setBackground(
                                sash.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
                          }
                        });
                    sash.setFocus();
                  }

                  @Override
                  public String getText() {
                    return WorkbenchMessages.FilteredPreferenceDialog_Resize;
                  }
                });
            manager.add(
                new Action() {
                  @Override
                  public void run() {
                    activeKeyScrolling();
                  }

                  @Override
                  public String getText() {
                    return WorkbenchMessages.FilteredPreferenceDialog_Key_Scrolling;
                  }
                });
            Menu menu = manager.createContextMenu(getShell());
            Rectangle bounds = historyManager.getControl().getBounds();
            Point topLeft = new Point(bounds.x + bounds.width, bounds.y + bounds.height);
            topLeft = historyManager.getControl().toDisplay(topLeft);
            menu.setLocation(topLeft.x, topLeft.y);
            menu.setVisible(true);
          }
        };
    popupMenuAction.setToolTipText(WorkbenchMessages.FilteredPreferenceDialog_FilterToolTip);
    historyManager.add(popupMenuAction);
    IHandlerService service = PlatformUI.getWorkbench().getService(IHandlerService.class);
    showViewHandler =
        service.activateHandler(
            IWorkbenchCommandConstants.WINDOW_SHOW_VIEW_MENU,
            new ActionHandler(popupMenuAction),
            new ActiveShellExpression(getShell()));

    historyManager.update(false);

    return historyManager.getControl();
  }
  /**
   * Add a new (SQL) Execution Tab
   *
   * @param AbstractSQLExecution
   */
  public void addSQLExecution(AbstractSQLExecution sqlExecution) {

    if (_tabFolder == null || _tabFolder.isDisposed()) {

      clearParent();

      // create tab folder for different sessions
      _tabFolder = new TabFolder(_parent, SWT.NULL);

      _parent.layout();
      _parent.redraw();
    }

    // create tab
    _lastTabNumber = _lastTabNumber + 1;
    final TabItem tabItem = new TabItem(_tabFolder, SWT.NULL);

    // set tab text & tooltip
    String labelText = "" + _lastTabNumber;
    tabItem.setText(labelText);
    tabItem.setData("tabLabel", labelText);
    tabItem.setToolTipText(TextUtil.getWrappedText(sqlExecution.getSqlStatement()));

    // create composite for our result
    Composite composite = new Composite(_tabFolder, SWT.NULL);

    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginLeft = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;

    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

    tabItem.setControl(composite);
    tabItem.setData(sqlExecution);

    tabItem.addDisposeListener(
        new DisposeListener() {

          public void widgetDisposed(final DisposeEvent e) {

            BusyIndicator.showWhile(
                Display.getCurrent(),
                new Runnable() {

                  public void run() {

                    // stop all sql execution if still running
                    TabItem tabItem = (TabItem) e.getSource();
                    AbstractSQLExecution sqlExecution = (AbstractSQLExecution) tabItem.getData();
                    sqlExecution.stop();
                    tabItem.setData(null);

                    if (_tabFolder != null && !_tabFolder.isDisposed()) {

                      if (_tabFolder.getItemCount() == 0) {
                        // this is last tab..
                        clearParent();
                        setDefaultMessage();
                      }

                    } else if (_tabFolder.isDisposed()) {
                      clearParent();
                      setDefaultMessage();
                    }
                  }
                });
          }
        });

    // add sql statement, first create temp label to calculate correct size

    String sqlStatement = sqlExecution.getSqlStatement();

    int labelHeight = 60;
    int labelStyle = SWT.WRAP | SWT.MULTI;

    Text tmpLabel = new Text(composite, labelStyle);
    tmpLabel.setText(TextUtil.removeLineBreaks(sqlExecution.getSqlStatement()));
    tmpLabel.setLayoutData(new FillLayout());
    int parentWidth = _parent.getClientArea().width;
    Point idealSize = tmpLabel.computeSize(parentWidth - 30, SWT.DEFAULT);

    if (idealSize.y <= 60) {
      // we don't need a scroll bar. minimize
      labelHeight = idealSize.y;
    } else {
      // we need a scroll bar
      labelStyle = SWT.WRAP | SWT.MULTI | SWT.V_SCROLL;
    }

    tmpLabel.dispose();

    // now create real label
    // create spanned cell for table data

    Composite headerComposite = new Composite(composite, SWT.FILL);
    headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

    GridLayout hLayout = new GridLayout();
    hLayout.numColumns = 2;
    hLayout.marginLeft = 0;
    hLayout.horizontalSpacing = 0;
    hLayout.verticalSpacing = 0;
    hLayout.marginWidth = 0;
    hLayout.marginHeight = 0;

    headerComposite.setLayout(hLayout);

    Text label = new Text(headerComposite, labelStyle);
    label.setEditable(false);
    label.setBackground(_parent.getBackground());
    label.setText(TextUtil.removeLineBreaks(sqlStatement));
    label.setToolTipText(TextUtil.getWrappedText(sqlStatement));

    GridData labelGridData = new GridData(SWT.FILL, SWT.TOP, true, false);
    labelGridData.heightHint = labelHeight;
    label.setLayoutData(labelGridData);

    // add action bar

    ToolBarManager toolBarMgr = new ToolBarManager(SWT.FLAT);
    toolBarMgr.createControl(headerComposite);
    toolBarMgr.add(new CloseSQLResultTab(tabItem));
    toolBarMgr.update(true);
    GridData gid = new GridData();
    gid.horizontalAlignment = SWT.RIGHT;
    gid.verticalAlignment = SWT.TOP;
    toolBarMgr.getControl().setLayoutData(gid);

    // add detail composite to show progress bar and results
    Composite detailComposite = new Composite(composite, SWT.FILL);
    detailComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    sqlExecution.setComposite(detailComposite);
    sqlExecution.setParentTab(tabItem);
    sqlExecution.startExecution();

    // set new tab as the active one
    _tabFolder.setSelection(_tabFolder.getItemCount() - 1);

    // refresh view
    composite.layout();
    _tabFolder.layout();
    _tabFolder.redraw();

    // bring this view to top of the view stack
    getSite().getPage().bringToTop(this);
  }
Example #24
0
  /** @see org.eclipse.jface.window.ApplicationWindow#createToolBarManager(int) */
  protected ToolBarManager createToolBarManager(final int style) {
    ToolBarManager toolBar = new ToolBarManager(style);

    toolBar.add(ActionManager.getNewWikiAction());
    toolBar.add(ActionManager.getOpenAction());
    toolBar.add(ActionManager.getSaveWikiAction());
    toolBar.add(new Separator());
    toolBar.add(ActionManager.getPrintAction());
    toolBar.add(new Separator());
    toolBar.add(ActionManager.getNewWikiWordAction());
    toolBar.add(ActionManager.getDeleteWikiWordAction());
    toolBar.add(new Separator());
    toolBar.add(ActionManager.getMoveUpAction());
    toolBar.add(ActionManager.getMoveDownAction());
    toolBar.add(ActionManager.getMoveBackAction());
    toolBar.add(ActionManager.getMoveForwardAction());

    return toolBar;
  }
  /**
   * Creates the history toolbar and initializes <code>historyToolbar</code>.
   *
   * @param historyBar
   * @param manager
   * @return the control of the history toolbar
   */
  public ToolBar createHistoryControls(ToolBar historyBar, ToolBarManager manager) {

    historyToolbar = manager;
    /** Superclass of the two for-/backward actions for the history. */
    abstract class HistoryNavigationAction extends Action implements IMenuCreator {
      private Menu lastMenu;

      protected static final int MAX_ENTRIES = 5;

      HistoryNavigationAction() {
        super("", IAction.AS_DROP_DOWN_MENU); // $NON-NLS-1$
      }

      public IMenuCreator getMenuCreator() {
        return this;
      }

      public void dispose() {
        if (lastMenu != null) {
          lastMenu.dispose();
          lastMenu = null;
        }
      }

      public Menu getMenu(Control parent) {
        if (lastMenu != null) {
          lastMenu.dispose();
        }
        lastMenu = new Menu(parent);
        createEntries(lastMenu);
        return lastMenu;
      }

      public Menu getMenu(Menu parent) {
        return null;
      }

      protected void addActionToMenu(Menu parent, IAction action) {
        ActionContributionItem item = new ActionContributionItem(action);
        item.fill(parent, -1);
      }

      protected abstract void createEntries(Menu menu);
    }

    /**
     * Menu entry for the toolbar dropdowns. Instances are direct-jump entries in the navigation
     * history.
     */
    class HistoryItemAction extends Action {

      private final int index;

      HistoryItemAction(int index, String label) {
        super(label, IAction.AS_PUSH_BUTTON);
        this.index = index;
      }

      public void run() {
        jumpToHistory(index);
      }
    }

    HistoryNavigationAction backward =
        new HistoryNavigationAction() {
          public void run() {
            jumpToHistory(historyIndex - 1);
          }

          public boolean isEnabled() {
            boolean enabled = historyIndex > 0;
            if (enabled) {
              setToolTipText(
                  NLS.bind(
                      WorkbenchMessages.get().NavigationHistoryAction_backward_toolTipName,
                      getHistoryEntry(historyIndex - 1).getLabel()));
            }
            return enabled;
          }

          protected void createEntries(Menu menu) {
            int limit = Math.max(0, historyIndex - MAX_ENTRIES);
            for (int i = historyIndex - 1; i >= limit; i--) {
              IAction action = new HistoryItemAction(i, getHistoryEntry(i).getLabel());
              addActionToMenu(menu, action);
            }
          }
        };
    backward.setText(WorkbenchMessages.get().NavigationHistoryAction_backward_text);
    backward.setActionDefinitionId("org.eclipse.ui.navigate.backwardHistory"); // $NON-NLS-1$
    backward.setImageDescriptor(
        WorkbenchPlugin.getDefault()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_TOOL_BACK));
    backward.setDisabledImageDescriptor(
        WorkbenchPlugin.getDefault()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_TOOL_BACK_DISABLED));
    registerKeybindings(backward);
    historyToolbar.add(backward);

    HistoryNavigationAction forward =
        new HistoryNavigationAction() {
          public void run() {
            jumpToHistory(historyIndex + 1);
          }

          public boolean isEnabled() {
            boolean enabled = historyIndex < history.size() - 1;
            if (enabled) {
              setToolTipText(
                  NLS.bind(
                      WorkbenchMessages.get().NavigationHistoryAction_forward_toolTipName,
                      getHistoryEntry(historyIndex + 1).getLabel()));
            }
            return enabled;
          }

          protected void createEntries(Menu menu) {
            int limit = Math.min(history.size(), historyIndex + MAX_ENTRIES + 1);
            for (int i = historyIndex + 1; i < limit; i++) {
              IAction action = new HistoryItemAction(i, getHistoryEntry(i).getLabel());
              addActionToMenu(menu, action);
            }
          }
        };
    forward.setText(WorkbenchMessages.get().NavigationHistoryAction_forward_text);
    forward.setActionDefinitionId("org.eclipse.ui.navigate.forwardHistory"); // $NON-NLS-1$
    forward.setImageDescriptor(
        WorkbenchPlugin.getDefault()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD));
    forward.setDisabledImageDescriptor(
        WorkbenchPlugin.getDefault()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD_DISABLED));
    registerKeybindings(forward);
    historyToolbar.add(forward);

    return historyBar;
  }
Example #26
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
   */
  @Override
  protected void createFormContent(IManagedForm managedForm) {
    this.mForm = managedForm;
    // form
    ScrolledForm form = managedForm.getForm();
    this.toolkit = OpenDartsFormsToolkit.getToolkit();
    form.setText(this.game.getName());
    this.toolkit.decorateFormHeading(form.getForm());

    GridDataFactory playerData;
    GridDataFactory scoreData;
    scoreData = GridDataFactory.fillDefaults().grab(true, false).span(2, 1);

    List<IPlayer> players = this.game.getPlayers();
    boolean twoPlayer = (players.size() == 2);
    // body
    int nbCol;
    int tableSpan;
    if (twoPlayer) {
      nbCol = 4;
      tableSpan = 2;
      playerData = GridDataFactory.fillDefaults().grab(false, true);
      scoreData = GridDataFactory.fillDefaults().grab(true, false).span(2, 1);
    } else {
      nbCol = players.size();
      tableSpan = nbCol;
      playerData = GridDataFactory.fillDefaults().grab(false, true);
      scoreData = GridDataFactory.fillDefaults().grab(true, false);
    }
    this.body = form.getBody();
    GridLayoutFactory.fillDefaults()
        .margins(5, 5)
        .numColumns(nbCol)
        .equalWidth(true)
        .applyTo(this.body);

    if (twoPlayer) {
      // First Player Status
      Composite cmpPlayerOne = this.createPlayerComposite(this.body, this.game.getFirstPlayer());
      playerData.copy().applyTo(cmpPlayerOne);
    } else {
      // create multi player stats
    }

    // Score
    Composite cmpScore = this.createScoreTableComposite(this.body);
    GridDataFactory.fillDefaults().grab(true, true).span(tableSpan, 1).applyTo(cmpScore);

    if (twoPlayer) {
      // Second Player Status
      Composite cmpPlayerTwo = this.createPlayerComposite(this.body, this.game.getSecondPlayer());
      playerData.copy().applyTo(cmpPlayerTwo);
    }

    // Left score
    Composite leftScoreMain = this.createLeftScoreComposite(nbCol, scoreData);
    GridDataFactory.fillDefaults().grab(true, false).span(nbCol, 1).applyTo(leftScoreMain);

    // Toolbar
    ToolBarManager manager = (ToolBarManager) form.getToolBarManager();
    IMenuService menuService = (IMenuService) this.getSite().getService(IMenuService.class);
    menuService.populateContributionManager(manager, "toolbar:openwis.editor.game.toolbar");
    manager.add(
        new ControlContribution("openwis.editor.game.toolbar.help") {
          @Override
          protected Control createControl(Composite parent) {
            Label helpLabel = new Label(parent, SWT.NONE);
            helpLabel.setImage(ProtoPlugin.getImage("/icons/actions/help.png"));
            ToolTip toolTip = new ShortcutsTooltip(helpLabel);
            toolTip.setPopupDelay(0);
            return helpLabel;
          }
        });
    manager.update(true);

    // Register listener
    this.game.addListener(this);

    // initialize game
    for (TableViewer viewer : this.scoreViewers.values()) {
      viewer.setInput(this.game);
    }
    this.handlePlayer(this.game.getCurrentPlayer(), this.game.getCurrentEntry());
  }
Example #27
0
  @Override
  protected IInformationControl doCreateInformationControl(final Shell parent) {
    if (BrowserInformationControl.isAvailable(parent)) {
      final ToolBarManager tbm = new ToolBarManager(SWT.FLAT);

      final String font = JFaceResources.DIALOG_FONT;
      final BrowserInformationControl control = new BrowserInformationControl(parent, font, tbm);

      final PresenterControlCreator.BackAction backAction =
          new PresenterControlCreator.BackAction(control);
      backAction.setEnabled(false);
      tbm.add(backAction);
      final PresenterControlCreator.ForwardAction forwardAction =
          new PresenterControlCreator.ForwardAction(control);
      tbm.add(forwardAction);
      forwardAction.setEnabled(false);

      final PresenterControlCreator.ShowInEdocViewAction showInEdocViewAction =
          new PresenterControlCreator.ShowInEdocViewAction(control);
      tbm.add(showInEdocViewAction);
      final OpenDeclarationAction openDeclarationAction =
          new OpenDeclarationAction(control, editor);
      tbm.add(openDeclarationAction);

      final SimpleSelectionProvider selectionProvider = new SimpleSelectionProvider();
      final OpenEdocInExternalBrowserAction openEdocInExternalBrowserAction =
          new OpenEdocInExternalBrowserAction(editor.getSite(), null);
      openEdocInExternalBrowserAction.setSpecialSelectionProvider(selectionProvider);
      selectionProvider.addSelectionChangedListener(openEdocInExternalBrowserAction);
      final ImageDescriptor descriptor = ErlideImage.OBJS_EXTERNALBROWSER.getDescriptor();
      openEdocInExternalBrowserAction.setImageDescriptor(descriptor);
      openEdocInExternalBrowserAction.setDisabledImageDescriptor(descriptor);
      selectionProvider.setSelection(new StructuredSelection());
      tbm.add(openEdocInExternalBrowserAction);

      // OpenExternalBrowserAction openExternalJavadocAction = new
      // OpenExternalBrowserAction(
      // parent.getDisplay(), selectionProvider);
      // selectionProvider
      // .addSelectionChangedListener(openExternalJavadocAction);
      // selectionProvider.setSelection(new
      // StructuredSelection());
      // tbm.add(openExternalJavadocAction);

      final IInputChangedListener inputChangeListener =
          new IInputChangedListener() {
            @Override
            public void inputChanged(final Object newInput) {
              backAction.update();
              forwardAction.update();
              if (newInput == null) {
                selectionProvider.setSelection(new StructuredSelection());
              } else if (newInput instanceof BrowserInformationControlInput) {
                final BrowserInformationControlInput input =
                    (BrowserInformationControlInput) newInput;
                final Object inputElement = input.getInputElement();
                selectionProvider.setSelection(new StructuredSelection(inputElement));
                final boolean hasInputElement = inputElement != null;
                showInEdocViewAction.setEnabled(hasInputElement);
                openDeclarationAction.setEnabled(hasInputElement);
                openEdocInExternalBrowserAction.setInput(newInput);
                openEdocInExternalBrowserAction.setEnabled(hasInputElement);
              }
            }
          };
      control.addInputChangeListener(inputChangeListener);

      tbm.update(true);

      control.addLocationListener(new HandleEdocLinksLocationListener(control));

      return control;
    }
    return new DefaultInformationControl(
        parent, EditorsUI.getTooltipAffordanceString(), new ErlInformationPresenter(true));
  }
 /** Add menu items to the toolbar for the enriched version of the control. */
 private void fillToolbar(ToolBarManager tbm, BrowserInformationControl infoControl) {
   tbm.add(new OpenDeclarationAction(infoControl));
 }
  private void createDialogUI(Composite parent) {
    GridLayoutFactory.fillDefaults().margins(12, 6).applyTo(parent);

    SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
    GridDataFactory.fillDefaults()
        .grab(true, true)
        .align(SWT.FILL, SWT.FILL)
        .hint(725, 360)
        .applyTo(sashForm);

    Composite leftComposite = new Composite(sashForm, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(leftComposite);
    GridDataFactory.swtDefaults()
        .grab(false, true)
        .align(SWT.FILL, SWT.FILL)
        .applyTo(leftComposite);

    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolBar = toolBarManager.createControl(leftComposite);
    toolBar.setBackground(parent.getBackground());
    GridDataFactory.swtDefaults().grab(true, false).align(SWT.BEGINNING, SWT.FILL).applyTo(toolBar);

    launchesViewer = new TableViewer(leftComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
    launchesViewer.setLabelProvider(
        new DelegatingStyledCellLabelProvider(new LaunchConfigLabelProvider()));
    launchesViewer.setComparator(new ViewerComparator(String.CASE_INSENSITIVE_ORDER));
    launchesViewer.setContentProvider(new LaunchConfigContentProvider());
    launchesViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
    launchesViewer.getTable().setFocus();
    launchesViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            handleSelectedConfigChanged();
          }
        });

    GridDataFactory.swtDefaults()
        .grab(false, true)
        .align(SWT.FILL, SWT.FILL)
        .hint(50, 50)
        .applyTo(launchesViewer.getControl());

    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();

    for (final ILaunchConfigurationType configType : manager.getLaunchConfigurationTypes()) {
      CreateLaunchAction action = new CreateLaunchAction(this, configType);

      toolBarManager.add(action);
    }

    // toolBarManager.add(new Separator());
    toolBarManager.add(getDeleteAction());

    toolBarManager.update(true);

    configUI = new Composite(sashForm, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(configUI);
    GridDataFactory.swtDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.BEGINNING)
        .applyTo(configUI);

    toolBar.pack();
    Label toolbarSpacer = new Label(configUI, SWT.NONE);
    GridDataFactory.swtDefaults().hint(SWT.NONE, toolBar.getSize().y).applyTo(toolbarSpacer);

    Composite nameComposite = new Composite(configUI, SWT.NONE);
    GridDataFactory.swtDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.FILL)
        .applyTo(nameComposite);
    GridLayoutFactory.swtDefaults().margins(6, 0).applyTo(nameComposite);

    configNameText = new Text(nameComposite, SWT.SINGLE | SWT.BORDER);
    GridDataFactory.swtDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.CENTER)
        .applyTo(configNameText);
    configNameText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            if (workingCopy != null) {
              workingCopy.rename(configNameText.getText());
            }
          }
        });

    launchConfigArea = new ScrolledComposite(configUI, SWT.V_SCROLL);
    GridDataFactory.swtDefaults()
        .grab(true, true)
        .align(SWT.FILL, SWT.FILL)
        .applyTo(launchConfigArea);
    launchConfigArea.setExpandVertical(false);
    launchConfigArea.setExpandHorizontal(true);

    configNameText.setVisible(false);

    sashForm.setWeights(new int[] {33, 67});

    selectLaunchConfigFromPage();
  }
Example #30
0
  protected void createDefaultActions() {
    toolBarManager.removeAll();
    if ((gridStyle & IGridViewer.NoToolBar) == 0) {
      if ((gridStyle & IGridViewer.fullEditable) != 0) {
        Element element = null;
        try {
          // element =
          // LoadSchemaManager.getSchemaManager().getElement(
          // data);
          element = CompositeMapUtil.getElement(data);
        } catch (Exception e) {
          // do nothing
        }
        if (element != null && element.isArray()) {
          final QualifiedName qName = element.getElementType().getQName();
          Action addAction = new AddElementAction(this, data, qName, ActionListener.NONE);
          addAction.setText("");
          addAction.setHoverImageDescriptor(
              AuroraPlugin.getImageDescriptor(LocaleMessage.getString("add.icon")));

          Action removeAction = new RemoveElementAction(this, ActionListener.DefaultImage);
          Action refreshAction = new RefreshAction(this, ActionListener.DefaultImage);
          toolBarManager.add(createActionContributionItem(addAction));
          toolBarManager.add(createActionContributionItem(refreshAction));
          toolBarManager.add(createActionContributionItem(removeAction));
          toolBarManager.update(true);
          tableViewer
              .getTable()
              .addKeyListener(
                  new KeyListener() {
                    public void keyPressed(KeyEvent e) {
                      if (e.keyCode == SWT.DEL) {
                        removeElement();
                      }
                    }

                    public void keyReleased(KeyEvent e) {}
                  });
        }
      }
    }
    if ((gridStyle & IGridViewer.isMulti) != 0) {

      Action allCheckAction =
          new Action(
              LocaleMessage.getString("all.checed"),
              AuroraPlugin.getImageDescriptor(LocaleMessage.getString("checked.icon"))) {
            public void run() {
              setAllChecked(tableViewer.getTable(), true);
            }
          };
      Action unAllCheckAction =
          new Action(
              LocaleMessage.getString("non.checed"),
              AuroraPlugin.getImageDescriptor(LocaleMessage.getString("unchecked.icon"))) {
            public void run() {
              setAllChecked(tableViewer.getTable(), false);
            }
          };
      toolBarManager.add(createActionContributionItem(allCheckAction));
      toolBarManager.add(createActionContributionItem(unAllCheckAction));
      toolBarManager.update(true);
    }
  }