Exemplo n.º 1
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.xmind.ui.properties.PropertyEditor#setBackground(org.eclipse.swt.
  * graphics.Color)
  */
 @Override
 public void setBackground(Color color) {
   super.setBackground(color);
   if (getControl() != null && !getControl().isDisposed()) getControl().setBackground(color);
   if (toolBar != null && toolBar.getControl() != null && !toolBar.getControl().isDisposed())
     toolBar.getControl().setBackground(color);
 }
Exemplo n.º 2
0
 /**
  * Set the background for the widgets that support the filter text area.
  *
  * @param background background <code>Color</code> to set
  */
 public void setBackground(Color background) {
   super.setBackground(background);
   if (filterComposite != null) {
     filterComposite.setBackground(background);
   }
   if (filterToolBar != null && filterToolBar.getControl() != null) {
     filterToolBar.getControl().setBackground(background);
   }
 }
        public void handleEvent(Event event) {
          // Ensure that this event is for a MMenuItem
          if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MToolBarElement)) return;

          MToolBarElement itemModel =
              (MToolBarElement) event.getProperty(UIEvents.EventTags.ELEMENT);
          String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME);
          if (UIEvents.UIElement.TOBERENDERED.equals(attName)) {
            Object obj = itemModel.getParent();
            if (!(obj instanceof MToolBar)) {
              return;
            }
            ToolBarManager parent = getManager((MToolBar) obj);
            if (itemModel.isToBeRendered()) {
              if (parent != null) {
                modelProcessSwitch(parent, itemModel);
                parent.update(true);
                ToolBar tb = parent.getControl();
                if (tb != null && !tb.isDisposed()) {
                  tb.pack(true);
                  tb.getShell().layout(new Control[] {tb}, SWT.DEFER);
                }
              }
            } else {
              IContributionItem ici = modelToContribution.remove(itemModel);
              if (ici != null && parent != null) {
                parent.remove(ici);
              }
              if (ici != null) {
                ici.dispose();
              }
            }
          } else if (UIEvents.UIElement.VISIBLE.equals(attName)) {
            IContributionItem ici = getContribution(itemModel);
            if (ici == null) {
              return;
            }
            ici.setVisible(itemModel.isVisible());
            ToolBarManager parent = (ToolBarManager) ((ContributionItem) ici).getParent();
            if (parent != null) {
              parent.markDirty();
              parent.update(true);
              // MUIElement tbModel = itemModel.getParent();
              // disposeToolbarIfNecessary((MToolBar) tbModel);
              ToolBar tb = parent.getControl();
              if (tb != null && !tb.isDisposed()) {
                tb.pack(true);
                tb.getShell().layout(new Control[] {tb}, SWT.DEFER);
              }
            }
          }
        }
Exemplo n.º 4
0
  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);
    }
  }
Exemplo n.º 5
0
  /**
   * Create the filter controls. By default, a text and corresponding tool bar button that clears
   * the contents of the text is created. Subclasses may override.
   *
   * @param parent parent <code>Composite</code> of the filter controls
   * @return the <code>Composite</code> that contains the filter controls
   */
  protected Composite createFilterControls(Composite parent) {
    createFilterText(parent);
    createClearText(parent);

    filterToolBar.update(false);
    // initially there is no text to clear
    filterToolBar.getControl().setVisible(false);
    return parent;
  }
Exemplo n.º 6
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();
  }
Exemplo n.º 7
0
  public Composite createViewer(Composite parent) throws ApplicationException {

    container = createContainer(parent);
    filterText = createSerchBar();
    viewForm = createViewForm();
    toolBarManager = createToolBar();
    tableViewer = createTableViewer();

    if ((gridStyle & IGridViewer.NoToolBar) == 0) viewForm.setTopLeft(toolBarManager.getControl());
    viewForm.setContent(tableViewer.getControl());
    container.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            selection = beforeDispose();
          }
        });
    if (data != null) {
      setData(data);
    }
    return container;
  }
Exemplo n.º 8
0
  private void internalRefresh(Object input) {

    IMergeViewerContentProvider content = getMergeContentProvider();
    if (content == null) {
      return;
    }
    Object ancestor = content.getAncestorContent(input);
    boolean oldFlag = fIsThreeWay;
    if (Utilities.isHunk(input)) {
      fIsThreeWay = true;
    } else if (input instanceof ICompareInput)
      fIsThreeWay = (((ICompareInput) input).getKind() & Differencer.DIRECTION_MASK) != 0;
    else fIsThreeWay = ancestor != null;

    if (fAncestorItem != null) fAncestorItem.setVisible(fIsThreeWay);

    if (fAncestorVisible && oldFlag != fIsThreeWay) fComposite.layout(true);

    Object left = content.getLeftContent(input);
    Object right = content.getRightContent(input);
    updateContent(ancestor, left, right);

    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=453799
    // Content provider may be disposed after call to updateContent()
    content = getMergeContentProvider();
    if (content == null) {
      return;
    }

    updateHeader();
    ToolBarManager tbm = CompareViewerPane.getToolBarManager(fComposite.getParent());
    if (tbm != null) {
      updateToolItems();
      tbm.update(true);
      tbm.getControl().getParent().layout(true);
    }
  }
  /**
   * 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();
  }
Exemplo n.º 10
0
  /**
   * 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);
  }
Exemplo n.º 11
0
 /**
  * @param site
  * @param id
  * @return tooltip
  */
 public static ToolbarTooltip install(IViewSite site, String id) {
   ToolBarManager toolBarManager = (ToolBarManager) site.getActionBars().getToolBarManager();
   final ToolBar control = toolBarManager.getControl();
   return new ToolbarTooltip(control, id);
 }
Exemplo n.º 12
0
 protected void updateToolbar(boolean visible) {
   if (filterToolBar != null) {
     filterToolBar.getControl().setVisible(visible);
   }
 }