Пример #1
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);
    }
  }