Пример #1
0
  @Override
  public void update(final ModelEvent event) {

    // Enable/Disable sort button
    if (event.part == ModelPart.OUTPUT
        || event.part == ModelPart.INPUT
        || event.part == ModelPart.SELECTED_VIEW_CONFIG) {

      if (model != null && model.getOutput() != null) {
        groupsButton.setEnabled(true);
        subsetButton.setEnabled(true);
      } else {
        groupsButton.setEnabled(false);
        subsetButton.setEnabled(false);
      }
    }

    // Update model
    if (event.part == ModelPart.MODEL) {
      model = (Model) event.data;
      reset();
    }

    if (event.part == ModelPart.SELECTED_VIEW_CONFIG) {
      subsetButton.setSelection(model.getViewConfig().isSubset());
    }

    if (event.part == ModelPart.SELECTED_ATTRIBUTE) {
      table.setSelectedAttribute((String) event.data);
    }
  }
 /** The table viewer selection has changed. Update the toolbar and menu enablements */
 private void handleSelection() {
   ISelection selection = tableViewer.getSelection();
   if (selection == null || !(selection instanceof IStructuredSelection)) {
     return;
   }
   IStructuredSelection structuredSelection = (IStructuredSelection) selection;
   List selectionList = structuredSelection.toList();
   boolean selectionEmpty = structuredSelection.isEmpty();
   boolean firstRowSelected = true;
   boolean lastRowSelected = true;
   if (!selectionEmpty) {
     SortFilterElement element = (SortFilterElement) selectionList.get(0);
     if (tableViewer.getElementAt(0).equals(element)) {
       firstRowSelected = true;
     } else {
       firstRowSelected = false;
     }
     element = (SortFilterElement) selectionList.get(selectionList.size() - 1);
     if (tableViewer.getElementAt(tableViewer.getTable().getItemCount() - 1).equals(element)) {
       lastRowSelected = true;
     } else {
       lastRowSelected = false;
     }
   }
   if (moveUpToolItem != null) {
     moveUpToolItem.setEnabled(!firstRowSelected && !selectionEmpty);
   }
   if (moveDownToolItem != null) {
     moveDownToolItem.setEnabled(!lastRowSelected && !selectionEmpty);
   }
 }
Пример #3
0
 @Override
 public void reset() {
   table.reset();
   groupsButton.setEnabled(false);
   subsetButton.setEnabled(false);
   ascendingButton.setEnabled(false);
   descendingButton.setEnabled(false);
 }
  private void updateToolItem() {
    final ToolItem item = (ToolItem) this.widget;

    final boolean shouldBeEnabled = isEnabled();

    // disabled command + visibility follows enablement == disposed
    if (item.isDisposed()) {
      return;
    }

    final String text = this.label;
    if ((this.icon == null || (this.mode & MODE_FORCE_TEXT) == MODE_FORCE_TEXT) && text != null) {
      item.setText(text);
    }

    final String toolTipText = getToolTipText(text);
    item.setToolTipText(toolTipText);

    if (item.getSelection() != this.checkedState) {
      item.setSelection(this.checkedState);
    }

    if (item.getEnabled() != shouldBeEnabled) {
      item.setEnabled(shouldBeEnabled);
    }
  }
Пример #5
0
  /** {@inheritDoc} */
  @Override
  public void createPartControl(final Composite parent) {
    toolBar = new ToolBar(parent, SWT.NONE);

    objectSelection = new ToolItem(toolBar, SWT.RADIO | SWT.NONE);
    objectSelection.setImage(MoreDreadUI.getDefault().getImage("/icons/SelectionModeObject.png"));
    objectSelection.setSelection(true);
    objectSelection.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent e) {
            MoreDreadUI.getDefault().getSceneHolder().setSelectionMode(SelectionMode.OBJECT);
          }
        });
    faceSelection = new ToolItem(toolBar, SWT.RADIO | SWT.NONE);
    faceSelection.setImage(MoreDreadUI.getDefault().getImage("/icons/SelectionModeFace.png"));
    faceSelection.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent e) {
            MoreDreadUI.getDefault().getSceneHolder().setSelectionMode(SelectionMode.FACE);
          }
        });
    faceSelection.setEnabled(false);
    edgeSelection = new ToolItem(toolBar, SWT.RADIO | SWT.NONE);
    edgeSelection.setImage(MoreDreadUI.getDefault().getImage("/icons/SelectionModeEdge.png"));
    edgeSelection.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent e) {
            MoreDreadUI.getDefault().getSceneHolder().setSelectionMode(SelectionMode.EDGE);
          }
        });
    edgeSelection.setEnabled(false);
    vertexSelection = new ToolItem(toolBar, SWT.RADIO | SWT.NONE);
    vertexSelection.setImage(MoreDreadUI.getDefault().getImage("/icons/SelectionModeVertex.png"));
    vertexSelection.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent e) {
            MoreDreadUI.getDefault().getSceneHolder().setSelectionMode(SelectionMode.VERTEX);
          }
        });
    vertexSelection.setEnabled(false);
    MoreDreadUI.getDefault().getSceneHolder().addSceneSelectionModeListener(this);
    MoreDreadUI.getDefault().getSceneHolder().addSceneSelectionChangeListener(this);
  }
Пример #6
0
 @Override
 public void commandChanged(CommandEvent commandEvent) {
   myItem.setEnabled(myCommand.getCommand().isEnabled());
   try {
     myItem.setToolTipText(myCommand.getCommand().getDescription());
   } catch (final NotDefinedException ex) {
     LogUtils.error(this, ex);
   }
 }
Пример #7
0
  @Override
  public void sceneSelectionChanged(final SceneSelectionChangeEvent event) {
    EnumSet<SelectionMode> supportedModes = null;
    if (event.getSelectedNodes().isEmpty()) {
      supportedModes = EnumSet.of(SelectionMode.OBJECT);
    } else {
      supportedModes = EnumSet.allOf(SelectionMode.class);

      for (final INode node : event.getSelectedNodes()) {
        supportedModes.retainAll(node.getSupportedSelectionModes());
      }
    }

    objectSelection.setEnabled(supportedModes.contains(SelectionMode.OBJECT));
    faceSelection.setEnabled(supportedModes.contains(SelectionMode.FACE));
    edgeSelection.setEnabled(supportedModes.contains(SelectionMode.EDGE));
    vertexSelection.setEnabled(supportedModes.contains(SelectionMode.VERTEX));
  }
  /**
   * Creates toolbar
   *
   * @param ancestor the parent composite
   */
  private void createToolBar(Composite ancestor) {
    Composite parent = new Composite(ancestor, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    parent.setLayout(layout);

    GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    parent.setLayoutData(gridData);

    // to simulate a vertical toolbar (not possible), create a separate toolbar for each button
    ToolBar toolBar = new ToolBar(parent, SWT.FLAT);
    Image imageUp = DiagramUIPluginImages.DESC_UP_PATH.createImage();
    moveUpToolItem = new ToolItem(toolBar, SWT.PUSH);
    moveUpToolItem.setEnabled(false);
    moveUpToolItem.setToolTipText(MOVE_UP_TOOL_TIP);
    moveUpToolItem.setImage(imageUp);
    moveUpToolItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            moveUpElements();
          }
        });
    ToolBar toolBarDown = new ToolBar(parent, SWT.FLAT);
    Image imageDown = DiagramUIPluginImages.DESC_DOWN_PATH.createImage();
    moveDownToolItem = new ToolItem(toolBarDown, SWT.PUSH);
    moveDownToolItem.setEnabled(false);
    moveDownToolItem.setToolTipText(MOVE_DOWN_TOOL_TIP);
    moveDownToolItem.setImage(imageDown);
    moveDownToolItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            moveDownElements();
          }
        });
  }
Пример #9
0
  @Override
  protected void update(Model model) {

    // Check
    if (toolbar == null) return;

    // For each item
    for (final ToolItem item : toolbar.getItems()) {

      // Check group
      if (!(item.getData() instanceof MainMenuGroup)) {
        MainMenuItem mItem = (MainMenuItem) item.getData();
        item.setEnabled(mItem == null || mItem.isEnabled(model));
      }
    }
  }
 @Override
 public void doSetValue(Object value) {
   final Object oldValue = doGetValue();
   if (attribute.equals(Constants.ATTR_IMAGE)) {
     item.setImage((Image) value);
   } else if (attribute.equals(Constants.ATTR_TEXT)) {
     item.setText((String) value);
   } else if (attribute.equals(Constants.ATTR_TOOLTIP)) {
     if (item instanceof TableColumn) {
       ((TableColumn) item).setToolTipText((String) value);
     }
     if (item instanceof TreeColumn) {
       ((TreeColumn) item).setToolTipText((String) value);
     }
     if (item instanceof ToolItem) {
       ((ToolItem) item).setToolTipText((String) value);
     }
     if (item instanceof TabItem) {
       ((TabItem) item).setToolTipText((String) value);
     }
   } else if (attribute.equals(Constants.ATTR_ALIGNMENT)) {
     if (item instanceof TableColumn) {
       ((TableColumn) item).setAlignment((Integer) value);
     }
     if (item instanceof TreeColumn) {
       ((TreeColumn) item).setAlignment((Integer) value);
     }
   } else if (attribute.equals(Constants.ATTR_WIDTH)) {
     if (item instanceof TableColumn) {
       ((TableColumn) item).setWidth((Integer) value);
     }
     if (item instanceof TreeColumn) {
       ((TreeColumn) item).setWidth((Integer) value);
     }
     if (item instanceof ToolItem) {
       ((ToolItem) item).setWidth((Integer) value);
     }
   } else if (attribute.equals(Constants.ATTR_ENABLED)) {
     if (item instanceof ToolItem) {
       ((ToolItem) item).setEnabled(value == Boolean.TRUE);
     }
   }
   fireValueChange(Diffs.createValueDiff(oldValue, value));
 }
  protected ToolItem createRemoveItemTool(ToolBar toolbar) {
    ToolItem tool = new ToolItem(toolbar, SWT.PUSH);

    tool.setImage(
        PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    tool.setDisabledImage(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImage(ISharedImages.IMG_TOOL_DELETE_DISABLED));
    tool.setToolTipText("Remove");
    tool.setEnabled(false);
    tool.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            doRemove();
          }
        });

    return tool;
  }
Пример #12
0
  public Control createControl(Composite parent, int style) {
    toolbar = new ToolBar(parent, style);

    btnAdd = new ToolItem(toolbar, SWT.PUSH);
    btnAdd.setImage(
        PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    btnAdd.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            for (AddRemoveListener l : listeners) {
              l.addSelected();
            }
          }
        });

    btnRemove = new ToolItem(toolbar, SWT.PUSH);
    btnRemove.setImage(
        PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    btnRemove.setDisabledImage(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImage(ISharedImages.IMG_TOOL_DELETE_DISABLED));
    btnRemove.setToolTipText("Remove");
    btnRemove.setEnabled(false);
    btnRemove.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            for (AddRemoveListener l : listeners) {
              l.removeSelected();
            }
          }
        });

    return toolbar;
  }
Пример #13
0
  /**
   * Creates all items
   *
   * @param toolbar
   * @param items
   * @param label
   */
  private void createItems(ToolBar toolbar, List<MainMenuItem> items, String label) {

    // For each item
    for (final MainMenuItem item : items) {

      // Skip items that are not buttons
      if (!item.isButton()) {
        continue;
      }

      // Create group
      if (item instanceof MainMenuGroup) {

        MainMenuGroup group = (MainMenuGroup) item;
        if (!this.toolitems.isEmpty()) {
          ToolItem menuItem = new ToolItem(toolbar, SWT.SEPARATOR);
          menuItem.setEnabled(false);
          menuItem.setData(item);
          this.toolitems.add(menuItem);
        }

        createItems(
            toolbar,
            group.getItems(),
            label.length() != 0
                ? label + " -> " + group.getLabel()
                : group.getLabel()); // $NON-NLS-1$

        // Create separator
      } else if (item instanceof MainMenuSeparator) {

        if (!this.toolitems.isEmpty()) {
          ToolItem menuItem = new ToolItem(toolbar, SWT.SEPARATOR);
          this.toolitems.add(menuItem);
        }

        // Create item
      } else {

        ToolItem menuItem = new ToolItem(toolbar, SWT.PUSH);
        menuItem.setToolTipText(
            label.length() != 0
                ? label + " -> " + item.getLabel()
                : item.getLabel()); // $NON-NLS-1$
        if (item.getImage() != null) {
          menuItem.setImage(item.getImage());
          SWTUtil.createDisabledImage(menuItem);
        }
        menuItem.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(final SelectionEvent e) {
                item.action(getController());
              }
            });
        menuItem.setData(item);
        menuItem.setEnabled(false);
        this.toolitems.add(menuItem);
      }
    }
  }
  private void createControlsToolBar(CoolBar coolBar) {
    CoolItem controlsCoolItem = new CoolItem(coolBar, SWT.NONE);
    ToolBar controlsToolBar = new ToolBar(coolBar, SWT.FLAT | SWT.HORIZONTAL);

    runButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER);
    runButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_RUN_EXEC));
    runButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_RUN_EXEC));
    runButton.setToolTipText("Runs the Checked Scripts");
    runButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleRunButton();
          }
        });
    runButton.addListener(
        SWT.MouseUp,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            if (e.button == 3) {
              handleRunButton();
            }
          }
        });
    runButton.setEnabled(false);

    // Create and configure the "Abort" button
    abortButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER);
    abortButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_ABORT_STOP));
    abortButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_ABORT_STOP));
    abortButton.setToolTipText("Abort Currently Running Script");
    abortButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleAbortButton();
            abortBatchButton.setEnabled(false);
            abortButton.setEnabled(false);
            Timer timer = new Timer();
            timer.schedule(new EnabledAbortsTimer(), 30000);
          }
        });
    abortButton.addListener(
        SWT.MouseUp,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            if (e.button == 3) {
              handleAbortButton();
              abortBatchButton.setEnabled(false);
              abortButton.setEnabled(false);
              Timer timer = new Timer();
              timer.schedule(new EnabledAbortsTimer(), 30000);
            }
          }
        });
    abortButton.setEnabled(false);

    abortBatchButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER);
    abortBatchButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_BATCH_ABORT_STOP));
    abortBatchButton.setDisabledImage(
        ImageManager.getImage(OteTestManagerImage.UNSEL_BATCH_ABORT_STOP));
    abortBatchButton.setToolTipText("Abort Script Batch");
    abortBatchButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleBatchAbortButton();
            abortBatchButton.setEnabled(false);
            abortButton.setEnabled(false);
            Timer timer = new Timer();
            timer.schedule(new EnabledAbortsTimer(), 30000);
          }
        });
    abortBatchButton.addListener(
        SWT.MouseUp,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            if (e.button == 3) {
              handleBatchAbortButton();
              abortBatchButton.setEnabled(false);
              abortButton.setEnabled(false);
              Timer timer = new Timer();
              timer.schedule(new EnabledAbortsTimer(), 30000);
            }
          }
        });
    abortBatchButton.setEnabled(false);

    controlsToolBar.pack();

    Point size = controlsToolBar.getSize();
    controlsCoolItem.setControl(controlsToolBar);
    controlsCoolItem.setSize(controlsCoolItem.computeSize(size.x, size.y));
    controlsCoolItem.setMinimumSize(size);
  }
Пример #15
0
 private void setCancelEnabled(boolean enabled) {
   if (fStopButton != null && !fStopButton.isDisposed()) {
     fStopButton.setEnabled(enabled);
     if (enabled) fToolBar.setFocus();
   }
 }
Пример #16
0
 public void setRemoveEnabled(boolean enable) {
   btnRemove.setEnabled(enable);
 }
Пример #17
0
  void show(
      boolean owned,
      org.eclipse.swt.graphics.Point location,
      org.eclipse.swt.graphics.Point size,
      boolean addressBar,
      boolean menuBar,
      boolean statusBar,
      boolean toolBar) {
    final org.eclipse.swt.widgets.Shell shell = browser.getShell();
    if (owned) {
      if (location != null) {
        shell.setLocation(location);
      }
      if (size != null) {
        shell.setSize(shell.computeSize(size.x, size.y));
      }
    }
    org.eclipse.swt.layout.FormData data = null;
    if (toolBar) {
      toolbar = new org.eclipse.swt.widgets.ToolBar(parent, SWT.NONE);
      data = new org.eclipse.swt.layout.FormData();
      data.top = new org.eclipse.swt.layout.FormAttachment(0, 5);
      toolbar.setLayoutData(data);
      itemBack = new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemBack.setText(getResourceString("Back"));
      itemForward = new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemForward.setText(getResourceString("Forward"));
      final org.eclipse.swt.widgets.ToolItem itemStop =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemStop.setText(getResourceString("Stop"));
      final org.eclipse.swt.widgets.ToolItem itemRefresh =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemRefresh.setText(getResourceString("Refresh"));
      final org.eclipse.swt.widgets.ToolItem itemGo =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemGo.setText(getResourceString("Go"));
      itemBack.setEnabled(browser.isBackEnabled());
      itemForward.setEnabled(!browser.isForwardEnabled());
      org.eclipse.swt.widgets.Listener listener =
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event event) {
              org.eclipse.swt.widgets.ToolItem item =
                  (org.eclipse.swt.widgets.ToolItem) event.widget;
              if (item == itemBack) {
                browser.back();
              } else {
                if (item == itemForward) {
                  browser.forward();
                } else {
                  if (item == itemStop) {
                    browser.stop();
                  } else {
                    if (item == itemRefresh) {
                      browser.refresh();
                    } else {
                      if (item == itemGo) {
                        browser.setUrl(locationBar.getText());
                      }
                    }
                  }
                }
              }
            }
          };
      itemBack.addListener(SWT.Selection, listener);
      itemForward.addListener(SWT.Selection, listener);
      itemStop.addListener(SWT.Selection, listener);
      itemRefresh.addListener(SWT.Selection, listener);
      itemGo.addListener(SWT.Selection, listener);
      canvas = new org.eclipse.swt.widgets.Canvas(parent, SWT.NO_BACKGROUND);
      data = new org.eclipse.swt.layout.FormData();
      data.width = 24;
      data.height = 24;
      data.top = new org.eclipse.swt.layout.FormAttachment(0, 5);
      data.right = new org.eclipse.swt.layout.FormAttachment(100, -5);
      canvas.setLayoutData(data);
      final org.eclipse.swt.graphics.Rectangle rect = images[0].getBounds();
      canvas.addListener(
          SWT.Paint,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              org.eclipse.swt.graphics.Point pt =
                  ((org.eclipse.swt.widgets.Canvas) e.widget).getSize();
              e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0, pt.x, pt.y);
            }
          });
      canvas.addListener(
          SWT.MouseDown,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              browser.setUrl(getResourceString("Startup"));
            }
          });
      final org.eclipse.swt.widgets.Display display = parent.getDisplay();
      display.asyncExec(
          new java.lang.Runnable() {
            public void run() {
              if (canvas.isDisposed()) {
                return;
              }
              if (busy) {
                index++;
                if (index == images.length) {
                  index = 0;
                }
                canvas.redraw();
              }
              display.timerExec(150, this);
            }
          });
    }
    if (addressBar) {
      locationBar = new org.eclipse.swt.widgets.Text(parent, SWT.BORDER);
      data = new org.eclipse.swt.layout.FormData();
      if (toolbar != null) {
        data.top = new org.eclipse.swt.layout.FormAttachment(toolbar, 0, SWT.TOP);
        data.left = new org.eclipse.swt.layout.FormAttachment(toolbar, 5, SWT.RIGHT);
        data.right = new org.eclipse.swt.layout.FormAttachment(canvas, -5, SWT.DEFAULT);
      } else {
        data.top = new org.eclipse.swt.layout.FormAttachment(0, 0);
        data.left = new org.eclipse.swt.layout.FormAttachment(0, 0);
        data.right = new org.eclipse.swt.layout.FormAttachment(100, 0);
      }
      locationBar.setLayoutData(data);
      locationBar.addListener(
          SWT.DefaultSelection,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              browser.setUrl(locationBar.getText());
            }
          });
    }
    if (statusBar) {
      status = new org.eclipse.swt.widgets.Label(parent, SWT.NONE);
      progressBar = new org.eclipse.swt.widgets.ProgressBar(parent, SWT.NONE);
      data = new org.eclipse.swt.layout.FormData();
      data.left = new org.eclipse.swt.layout.FormAttachment(0, 5);
      data.right = new org.eclipse.swt.layout.FormAttachment(progressBar, 0, SWT.DEFAULT);
      data.bottom = new org.eclipse.swt.layout.FormAttachment(100, -5);
      status.setLayoutData(data);
      data = new org.eclipse.swt.layout.FormData();
      data.right = new org.eclipse.swt.layout.FormAttachment(100, -5);
      data.bottom = new org.eclipse.swt.layout.FormAttachment(100, -5);
      progressBar.setLayoutData(data);
      browser.addStatusTextListener(
          new org.eclipse.swt.browser.StatusTextListener() {
            public void changed(org.eclipse.swt.browser.StatusTextEvent event) {
              status.setText(event.text);
            }
          });
    }
    parent.setLayout(new org.eclipse.swt.layout.FormLayout());
    org.eclipse.swt.widgets.Control aboveBrowser =
        toolBar
            ? (org.eclipse.swt.widgets.Control) canvas
            : addressBar ? (org.eclipse.swt.widgets.Control) locationBar : null;
    data = new org.eclipse.swt.layout.FormData();
    data.left = new org.eclipse.swt.layout.FormAttachment(0, 0);
    data.top =
        aboveBrowser != null
            ? new org.eclipse.swt.layout.FormAttachment(aboveBrowser, 5, SWT.DEFAULT)
            : new org.eclipse.swt.layout.FormAttachment(0, 0);
    data.right = new org.eclipse.swt.layout.FormAttachment(100, 0);
    data.bottom =
        status != null
            ? new org.eclipse.swt.layout.FormAttachment(status, -5, SWT.DEFAULT)
            : new org.eclipse.swt.layout.FormAttachment(100, 0);
    browser.setLayoutData(data);
    if (statusBar || toolBar) {
      browser.addProgressListener(
          new org.eclipse.swt.browser.ProgressListener() {
            public void changed(org.eclipse.swt.browser.ProgressEvent event) {
              if (event.total == 0) {
                return;
              }
              int ratio = event.current * 100 / event.total;
              if (progressBar != null) {
                progressBar.setSelection(ratio);
              }
              busy = event.current != event.total;
              if (!busy) {
                index = 0;
                if (canvas != null) {
                  canvas.redraw();
                }
              }
            }

            public void completed(org.eclipse.swt.browser.ProgressEvent event) {
              if (progressBar != null) {
                progressBar.setSelection(0);
              }
              busy = false;
              index = 0;
              if (canvas != null) {
                itemBack.setEnabled(browser.isBackEnabled());
                itemForward.setEnabled(browser.isForwardEnabled());
                canvas.redraw();
              }
            }
          });
    }
    if (addressBar || statusBar || toolBar) {
      browser.addLocationListener(
          new org.eclipse.swt.browser.LocationListener() {
            public void changed(org.eclipse.swt.browser.LocationEvent event) {
              busy = true;
              if (event.top && locationBar != null) {
                locationBar.setText(event.location);
              }
            }

            public void changing(org.eclipse.swt.browser.LocationEvent event) {}
          });
    }
    if (title) {
      browser.addTitleListener(
          new org.eclipse.swt.browser.TitleListener() {
            public void changed(org.eclipse.swt.browser.TitleEvent event) {
              shell.setText(event.title + " - " + getResourceString("window.title"));
            }
          });
    }
    parent.layout(true);
    if (owned) {
      shell.open();
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls
   * (org.eclipse.swt.widgets.Composite,
   * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
   */
  @Override
  public void createControls(
      final Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {

    this.parent = parent;
    this.toolkit = new FormToolkit(parent.getDisplay());
    super.createControls(parent, aTabbedPropertySheetPage);

    if (form != null && !form.isDisposed()) {
      try {
        form.dispose();
      } catch (Exception e) {
        // ignore any expose exceptions
      }
    }
    form = null;

    if (parent.isDisposed()) return;

    parent.setLayout(new GridLayout());
    // parent.setLayout(new GridLayout(1, false));
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    form = toolkit.createForm(parent);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));
    form.setText(EditorMessages.propertiesDocumentationTitle);
    toolkit.decorateFormHeading(form);

    form.getBody().setLayout(new GridLayout(1, false));

    Composite sbody = form.getBody();

    ToolBar navBar = new ToolBar(sbody, SWT.NONE);
    toolkit.adapt(navBar);
    navBar.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
    final ToolItem back = new ToolItem(navBar, SWT.PUSH);
    back.setText("<");
    back.setEnabled(false);
    final ToolItem forward = new ToolItem(navBar, SWT.PUSH);
    forward.setText(">");
    forward.setEnabled(false);

    back.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            browser.back();
          }
        });
    forward.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            browser.forward();
          }
        });

    final LocationListener locationListener =
        new LocationListener() {
          public void changed(LocationEvent event) {
            Browser browser = (Browser) event.widget;
            back.setEnabled(browser.isBackEnabled());
            forward.setEnabled(browser.isForwardEnabled());
          }

          public void changing(LocationEvent event) {}
        };

    browser = new Browser(sbody, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    browser.setLayoutData(data);
    IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    URL url = helpSystem.resolve("org.fusesource.ide.help/index.html", true);
    browser.setUrl(url.toExternalForm());
    browser.addLocationListener(locationListener);

    // section.pack();
    // form.pack();
    form.layout(true, true);
    parent.layout(true, true);

    // in case of timing issues, lets do another layout just in case...
    Display.getCurrent()
        .asyncExec(
            new Runnable() {
              @Override
              public void run() {
                if (form != null && !form.isDisposed()) {
                  form.layout(true, true);
                }
                if (parent != null && !parent.isDisposed()) {
                  parent.layout(true, true);
                }
              }
            });
  }
Пример #19
0
  private void createHAGroup(Composite container) {
    final Group group = new Group(container, SWT.NONE);
    group.setText(Messages.OPT_TAB_GROUP_HA);

    // layout
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginTop = 0;
    layout.marginBottom = 10;
    layout.verticalSpacing = 0;
    group.setLayout(layout);
    group.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Toolbar
    ToolBar toolBar = new ToolBar(group, SWT.NONE);
    // add
    ToolItem itemAdd = new ToolItem(toolBar, SWT.FLAT);
    itemAdd.setImage(Images.get(ImageKeys.IMG_ADD));
    itemAdd.setDisabledImage(Images.get(ImageKeys.IMG_ADD_GRAY));
    itemAdd.setToolTipText(Messages.OPT_TAB_GROUP_HA_ADD_BTN_TOOLTIP);
    itemAdd.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unchecked")
          public void widgetSelected(SelectionEvent e) {
            Display.getDefault()
                .asyncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        ServerURI uri = new ServerURI(Constants.TCP_SERVER_URI);
                        ((List<ServerURI>) viewer.getInput()).add(uri);
                        viewer.refresh();

                        // select the added uri
                        viewer.setSelection(new StructuredSelection(uri));

                        viewer.editElement(uri, 1);
                      }
                    });
          }
        });

    // remove
    final ToolItem itemRemove = new ToolItem(toolBar, SWT.FLAT);
    itemRemove.setImage(Images.get(ImageKeys.IMG_REMOVE));
    itemRemove.setDisabledImage(Images.get(ImageKeys.IMG_REMOVE_GRAY));
    itemRemove.setToolTipText(Messages.OPT_TAB_GROUP_HA_RM_BTN_TOOLTIP);
    itemRemove.setEnabled(false);
    itemRemove.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unchecked")
          public void widgetSelected(SelectionEvent e) {
            Display.getDefault()
                .asyncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        StructuredSelection selection = (StructuredSelection) viewer.getSelection();
                        List<ServerURI> input = ((List<ServerURI>) viewer.getInput());
                        int index = -1;
                        for (ServerURI uri : (List<ServerURI>) selection.toList()) {
                          if (index == -1) {
                            index = input.indexOf(uri);
                          }
                          input.remove(uri);
                        }

                        viewer.refresh();

                        // select previous index
                        if (!input.isEmpty()) {
                          index = index - 1 >= 0 ? index - 1 : 0;
                          viewer.setSelection(new StructuredSelection(input.get(index)));
                        }
                      }
                    });
          }
        });

    // clear
    ToolItem itemClear = new ToolItem(toolBar, SWT.FLAT);
    itemClear.setImage(Images.get(ImageKeys.IMG_CLEAR));
    // itemClear.setDisabledImage(Images.get("clear_gray"));
    itemClear.setToolTipText(Messages.OPT_TAB_GROUP_HA_CLEAR_BTN_TOOLTIP);
    itemClear.setEnabled(true);
    itemClear.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unchecked")
          public void widgetSelected(SelectionEvent e) {
            Display.getDefault()
                .asyncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        ((List<ServerURI>) viewer.getInput()).clear();
                        viewer.refresh();
                      }
                    });
          }
        });

    // Table viewer
    Composite composite = new Composite(group, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Note: using V_SCROLL | NO_SCROLL to force disable H_SCROLL
    TableViewerBuilder builder =
        new TableViewerBuilder(
                composite,
                SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.NO_SCROLL | SWT.BORDER)
            .selectionChangedListener(
                new ISelectionChangedListener() {
                  public void selectionChanged(SelectionChangedEvent event) {
                    Display.getDefault()
                        .asyncExec(
                            new Runnable() {
                              @Override
                              public void run() {
                                itemRemove.setEnabled(!viewer.getSelection().isEmpty());
                              }
                            });
                  }
                })
            .makeEditable()
            .input(connection.getOptions().getServerURIs());

    // build the table viewer
    viewer = builder.build();

    // table columns
    // First extra column to display error message
    builder.columnBuilder("", SWT.LEFT).pixelWidth(20).emptyCellLabelProvider().build();
    builder
        .columnBuilder(Messages.OPT_TAB_GROUP_HA_SERVER_URIS, SWT.LEFT)
        .percentWidth(90)
        .cellLabelProvider(
            new ColumnLabelProvider() {
              @Override
              public String getText(Object element) {
                return ((ServerURI) element).getValue();
              }

              @Override
              public String getToolTipText(Object element) {
                return Messages.TOOLTIP_DBCLICK_TO_EDIT;
              }
            })
        .editingSupport(new ServerUriCellEditor(viewer))
        .build();

    viewer.refresh();

    // initial state
    Widgets.enable(group, connection.getOptions().isHaEnabled());
    haViewUpdater =
        new ViewUpdater<Boolean>() {
          @Override
          public void update(Boolean selected) {
            Widgets.enable(group, selected);
            viewer.refresh();
          }
        };
  }
Пример #20
0
 /** Enable sorting. */
 protected void enableSorting() {
   ascendingButton.setEnabled(true);
   descendingButton.setEnabled(true);
 }
Пример #21
0
  private Composite createMessageAndPersonArea(Composite container) {

    Composite messageAndPersonArea = toolkit.createComposite(container);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(messageAndPersonArea);
    GridLayoutFactory.swtDefaults().margins(0, 0).spacing(0, 0).applyTo(messageAndPersonArea);

    Section messageSection =
        toolkit.createSection(
            messageAndPersonArea,
            ExpandableComposite.TITLE_BAR | ExpandableComposite.CLIENT_INDENT);
    messageSection.setText(UIText.CommitDialog_CommitMessage);
    Composite messageArea = toolkit.createComposite(messageSection);
    GridLayoutFactory.fillDefaults().spacing(0, 0).extendedMargins(2, 2, 2, 2).applyTo(messageArea);
    toolkit.paintBordersFor(messageArea);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(messageSection);
    GridLayoutFactory.swtDefaults().applyTo(messageSection);

    Composite headerArea = new Composite(messageSection, SWT.NONE);
    GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(2).applyTo(headerArea);

    ToolBar messageToolbar = new ToolBar(headerArea, SWT.FLAT | SWT.HORIZONTAL);
    GridDataFactory.fillDefaults()
        .align(SWT.END, SWT.FILL)
        .grab(true, false)
        .applyTo(messageToolbar);

    addMessageDropDown(headerArea);

    messageSection.setTextClient(headerArea);

    final CommitProposalProcessor commitProposalProcessor =
        new CommitProposalProcessor() {
          @Override
          protected Collection<String> computeFileNameProposals() {
            return getFileList();
          }

          @Override
          protected Collection<String> computeMessageProposals() {
            return CommitMessageHistory.getCommitHistory();
          }
        };
    commitText =
        new CommitMessageArea(messageArea, commitMessage, SWT.NONE) {
          @Override
          protected CommitProposalProcessor getCommitProposalProcessor() {
            return commitProposalProcessor;
          }
        };
    commitText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    messageSection.setClient(messageArea);
    Point size = commitText.getTextWidget().getSize();
    int minHeight = commitText.getTextWidget().getLineHeight() * 3;
    commitText.setLayoutData(
        GridDataFactory.fillDefaults()
            .grab(true, true)
            .hint(size)
            .minSize(size.x, minHeight)
            .align(SWT.FILL, SWT.FILL)
            .create());

    UIUtils.addBulbDecorator(commitText.getTextWidget(), UIText.CommitDialog_ContentAssist);

    Composite personArea = toolkit.createComposite(messageAndPersonArea);
    toolkit.paintBordersFor(personArea);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(personArea);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(personArea);

    toolkit
        .createLabel(personArea, UIText.CommitDialog_Author)
        .setForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE));
    authorText = toolkit.createText(personArea, null);
    authorText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    authorText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    if (repository != null
        && repository.getRepositoryState().equals(RepositoryState.CHERRY_PICKING_RESOLVED))
      authorText.setEnabled(false);

    toolkit
        .createLabel(personArea, UIText.CommitDialog_Committer)
        .setForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE));
    committerText = toolkit.createText(personArea, null);
    committerText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    if (committer != null) committerText.setText(committer);

    amendingItem = new ToolItem(messageToolbar, SWT.CHECK);
    amendingItem.setSelection(amending);
    if (amending) amendingItem.setEnabled(false); // if already set, don't allow any
    // changes
    else if (!amendAllowed) amendingItem.setEnabled(false);
    amendingItem.setToolTipText(UIText.CommitDialog_AmendPreviousCommit);
    Image amendImage = UIIcons.AMEND_COMMIT.createImage();
    UIUtils.hookDisposal(amendingItem, amendImage);
    amendingItem.setImage(amendImage);

    signedOffItem = new ToolItem(messageToolbar, SWT.CHECK);

    signedOffItem.setToolTipText(UIText.CommitDialog_AddSOB);
    Image signedOffImage = UIIcons.SIGNED_OFF.createImage();
    UIUtils.hookDisposal(signedOffItem, signedOffImage);
    signedOffItem.setImage(signedOffImage);

    changeIdItem = new ToolItem(messageToolbar, SWT.CHECK);
    Image changeIdImage = UIIcons.GERRIT.createImage();
    UIUtils.hookDisposal(changeIdItem, changeIdImage);
    changeIdItem.setImage(changeIdImage);
    changeIdItem.setToolTipText(UIText.CommitDialog_AddChangeIdLabel);

    final ICommitMessageComponentNotifications listener =
        new ICommitMessageComponentNotifications() {

          public void updateSignedOffToggleSelection(boolean selection) {
            signedOffItem.setSelection(selection);
          }

          public void updateChangeIdToggleSelection(boolean selection) {
            changeIdItem.setSelection(selection);
          }

          public void statusUpdated() {
            updateMessage();
          }
        };

    commitMessageComponent = new CommitMessageComponent(repository, listener);
    commitMessageComponent.enableListeners(false);
    commitMessageComponent.setDefaults();
    commitMessageComponent.attachControls(commitText, authorText, committerText);
    commitMessageComponent.setCommitMessage(commitMessage);
    commitMessageComponent.setAuthor(author);
    commitMessageComponent.setCommitter(committer);
    commitMessageComponent.setAmending(amending);
    commitMessageComponent.setFilesToCommit(getFileList());

    amendingItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            commitMessageComponent.setAmendingButtonSelection(amendingItem.getSelection());
          }
        });

    changeIdItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            commitMessageComponent.setChangeIdButtonSelection(changeIdItem.getSelection());
          }
        });

    signedOffItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            commitMessageComponent.setSignedOffButtonSelection(signedOffItem.getSelection());
          }
        });

    commitMessageComponent.updateUI();
    commitMessageComponent.enableListeners(true);

    return messageAndPersonArea;
  }
Пример #22
0
  private Section createFileSection(Composite container) {
    Section filesSection =
        toolkit.createSection(
            container, ExpandableComposite.TITLE_BAR | ExpandableComposite.CLIENT_INDENT);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(filesSection);
    Composite filesArea = toolkit.createComposite(filesSection);
    filesSection.setClient(filesArea);
    toolkit.paintBordersFor(filesArea);
    GridLayoutFactory.fillDefaults().extendedMargins(2, 2, 2, 2).applyTo(filesArea);

    ToolBar filesToolbar = new ToolBar(filesSection, SWT.FLAT);

    filesSection.setTextClient(filesToolbar);

    PatternFilter patternFilter =
        new PatternFilter() {
          @Override
          protected boolean isLeafMatch(Viewer viewer, Object element) {
            if (element instanceof CommitItem) {
              CommitItem commitItem = (CommitItem) element;
              return wordMatches(commitItem.path);
            }
            return super.isLeafMatch(viewer, element);
          }
        };
    patternFilter.setIncludeLeadingWildcard(true);
    FilteredCheckboxTree resourcesTreeComposite =
        new FilteredCheckboxTree(filesArea, toolkit, SWT.FULL_SELECTION, patternFilter) {
          @Override
          protected WorkbenchJob doCreateRefreshJob() {
            // workaround for file filter not having an explicit change
            // listener
            WorkbenchJob filterJob = super.doCreateRefreshJob();
            filterJob.addJobChangeListener(
                new JobChangeAdapter() {
                  public void done(IJobChangeEvent event) {
                    if (event.getResult().isOK()) {
                      getDisplay()
                          .asyncExec(
                              new Runnable() {
                                public void run() {
                                  updateFileSectionText();
                                }
                              });
                    }
                  }
                });
            return filterJob;
          }
        };
    Tree resourcesTree = resourcesTreeComposite.getViewer().getTree();
    resourcesTree.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
    resourcesTreeComposite.setLayoutData(
        GridDataFactory.fillDefaults().hint(600, 200).grab(true, true).create());

    resourcesTree.addSelectionListener(new CommitItemSelectionListener());

    resourcesTree.setHeaderVisible(true);
    TreeColumn statCol = new TreeColumn(resourcesTree, SWT.LEFT);
    statCol.setText(UIText.CommitDialog_Status);
    statCol.setWidth(150);
    statCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByStatus));

    TreeColumn resourceCol = new TreeColumn(resourcesTree, SWT.LEFT);
    resourceCol.setText(UIText.CommitDialog_Path);
    resourceCol.setWidth(415);
    resourceCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByFile));

    filesViewer = resourcesTreeComposite.getCheckboxTreeViewer();
    new TreeViewerColumn(filesViewer, statCol).setLabelProvider(createStatusLabelProvider());
    new TreeViewerColumn(filesViewer, resourceCol).setLabelProvider(new CommitPathLabelProvider());
    ColumnViewerToolTipSupport.enableFor(filesViewer);
    filesViewer.setContentProvider(new CommitFileContentProvider());
    filesViewer.setUseHashlookup(true);
    IDialogSettings settings = org.eclipse.egit.ui.Activator.getDefault().getDialogSettings();
    if (settings.get(SHOW_UNTRACKED_PREF) != null) {
      // note, no matter how the dialog settings are, if
      // the preferences force us to include untracked files
      // we must show them
      showUntracked =
          Boolean.valueOf(settings.get(SHOW_UNTRACKED_PREF)).booleanValue()
              || getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
    }

    filesViewer.addFilter(new CommitItemFilter());
    filesViewer.setInput(items.toArray());
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(createContextMenuListener());
    filesViewer.getTree().setMenu(menuManager.createContextMenu(filesViewer.getTree()));
    filesViewer.addCheckStateListener(
        new ICheckStateListener() {

          public void checkStateChanged(CheckStateChangedEvent event) {
            updateFileSectionText();
          }
        });

    showUntrackedItem = new ToolItem(filesToolbar, SWT.CHECK);
    Image showUntrackedImage = UIIcons.UNTRACKED_FILE.createImage();
    UIUtils.hookDisposal(showUntrackedItem, showUntrackedImage);
    showUntrackedItem.setImage(showUntrackedImage);
    showUntrackedItem.setToolTipText(UIText.CommitDialog_ShowUntrackedFiles);
    showUntrackedItem.setSelection(showUntracked);
    showUntrackedItem.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            showUntracked = showUntrackedItem.getSelection();
            filesViewer.refresh(true);
            updateFileSectionText();
            updateMessage();
          }
        });

    ToolItem checkAllItem = new ToolItem(filesToolbar, SWT.PUSH);
    Image checkImage = UIIcons.CHECK_ALL.createImage();
    UIUtils.hookDisposal(checkAllItem, checkImage);
    checkAllItem.setImage(checkImage);
    checkAllItem.setToolTipText(UIText.CommitDialog_SelectAll);
    checkAllItem.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            filesViewer.setAllChecked(true);
            updateFileSectionText();
            updateMessage();
          }
        });

    ToolItem uncheckAllItem = new ToolItem(filesToolbar, SWT.PUSH);
    Image uncheckImage = UIIcons.UNCHECK_ALL.createImage();
    UIUtils.hookDisposal(uncheckAllItem, uncheckImage);
    uncheckAllItem.setImage(uncheckImage);
    uncheckAllItem.setToolTipText(UIText.CommitDialog_DeselectAll);
    uncheckAllItem.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            filesViewer.setAllChecked(false);
            updateFileSectionText();
            updateMessage();
          }
        });

    if (!allowToChangeSelection) {
      amendingItem.setSelection(false);
      amendingItem.setEnabled(false);
      showUntrackedItem.setSelection(false);
      showUntrackedItem.setEnabled(false);
      checkAllItem.setEnabled(false);
      uncheckAllItem.setEnabled(false);

      filesViewer.addCheckStateListener(
          new ICheckStateListener() {

            public void checkStateChanged(CheckStateChangedEvent event) {
              if (!event.getChecked()) filesViewer.setAllChecked(true);
              updateFileSectionText();
            }
          });
      filesViewer.setAllChecked(true);
    } else {
      final boolean includeUntracked =
          getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
      for (CommitItem item : items) {
        if (!preselectAll && !preselectedFiles.contains(item.path)) continue;
        if (item.status == Status.ASSUME_UNCHANGED) continue;
        if (!includeUntracked && item.status == Status.UNTRACKED) continue;
        filesViewer.setChecked(item, true);
      }
    }
    statCol.pack();
    resourceCol.pack();
    return filesSection;
  }
  /**
   * Create contents of the dialog.
   *
   * @param parent
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    setTitle("");
    parent.setToolTipText("hghkhj");
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    CTabFolder tabFolder = new CTabFolder(container, SWT.BORDER);
    tabFolder.setTabHeight(22);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tabFolder.setSelectionBackground(
        Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));

    CTabItem tbtmNewItem = new CTabItem(tabFolder, SWT.NONE);
    tbtmNewItem.setText("Main");

    Composite composite = new Composite(tabFolder, SWT.NONE);
    tbtmNewItem.setControl(composite);
    composite.setLayout(new GridLayout(2, false));

    Label lblNewLabel = new Label(composite, SWT.NONE);
    lblNewLabel.setText("Id:");

    idText = new Text(composite, SWT.BORDER);

    idText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblNewLabel_1 = new Label(composite, SWT.NONE);
    lblNewLabel_1.setText("Source Ref:");

    sourceRefViewer = new ComboViewer(composite, SWT.READ_ONLY);
    Combo combo = sourceRefViewer.getCombo();
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    sourceRefViewer.setContentProvider(new ArrayContentProvider());
    sourceRefViewer.setLabelProvider(new IDataLabelProvider());

    Label lblNewLabel_2 = new Label(composite, SWT.NONE);
    lblNewLabel_2.setText("Target Ref:");

    targetRefViewer = new ComboViewer(composite, SWT.READ_ONLY);
    Combo combo_1 = targetRefViewer.getCombo();
    combo_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    targetRefViewer.setContentProvider(new ArrayContentProvider());
    targetRefViewer.setLabelProvider(new IDataLabelProvider());

    Label lblNewLabel_3 = new Label(composite, SWT.NONE);
    lblNewLabel_3.setText("Transformation:");

    transformationText = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.MULTI);
    transformationText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));

    CTabItem tbtmNewItem_1 = new CTabItem(tabFolder, SWT.NONE);
    tbtmNewItem_1.setText("Assignments");

    Composite composite_1 = new Composite(tabFolder, SWT.NONE);
    tbtmNewItem_1.setControl(composite_1);
    composite_1.setLayout(new GridLayout(1, true));

    ToolBar toolBar = new ToolBar(composite_1, SWT.FLAT | SWT.RIGHT);
    toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));

    ToolItem addItem = new ToolItem(toolBar, SWT.NONE);
    addItem.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unchecked")
          @Override
          public void widgetSelected(SelectionEvent e) {
            Shell newshell = new Shell(getParentShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
            AssignmentDialog dialog = new AssignmentDialog(newshell);
            String determinedId =
                IdUtil.getNextParentedIdInList(
                    (List<BaseElement>) assignmentsViewer.getInput(), "A", idText.getText());
            dialog.setDeterminedId(determinedId);
            if (dialog.open() == Window.OK) {
              ((List<Assignment>) assignmentsViewer.getInput()).add(dialog.getResult());
              try {
                idHandler.addId(dialog.getResult());
              } catch (IdAlreadyExistException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
              assignmentsViewer.refresh(true);
            }
          }
        });

    addItem.setText("New");

    final ToolItem editItem = new ToolItem(toolBar, SWT.NONE);
    editItem.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unchecked")
          @Override
          public void widgetSelected(SelectionEvent e) {
            AssignmentDialog dialog = new AssignmentDialog(getShell());
            String determinedId =
                IdUtil.getNextParentedIdInList(
                    (List<BaseElement>) assignmentsViewer.getInput(), "A", idText.getText());
            dialog.setDeterminedId(determinedId);
            IStructuredSelection selection =
                (IStructuredSelection) assignmentsViewer.getSelection();
            if (dialog.open((Assignment) selection.getFirstElement()) == Window.OK) {
              int index = assignmentsViewer.getTable().getSelectionIndex();
              try {
                idHandler.removeId((BaseElement) selection.getFirstElement());
              } catch (IdNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
              ((List<Assignment>) assignmentsViewer.getInput()).remove(selection.getFirstElement());

              ((List<Assignment>) assignmentsViewer.getInput()).add(index, dialog.getResult());
              try {
                idHandler.addId(dialog.getResult());
              } catch (IdAlreadyExistException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
              assignmentsViewer.refresh(true);
              // ModelIdProcessor.refreshModelIds(EcoreUtil.getURI(getDiagram()));
            }
          }
        });
    editItem.setText("Edit");
    editItem.setEnabled(false);

    final ToolItem deleteItem = new ToolItem(toolBar, SWT.NONE);
    deleteItem.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unchecked")
          @Override
          public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection =
                (IStructuredSelection) assignmentsViewer.getSelection();
            try {
              idHandler.removeId((BaseElement) selection.getFirstElement());
            } catch (IdNotFoundException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
            ((List<Assignment>) assignmentsViewer.getInput()).remove(selection.getFirstElement());
            assignmentsViewer.refresh(true);
            // ModelIdProcessor.refreshModelIds(EcoreUtil.getURI(getDiagram()));
          }
        });
    deleteItem.setText("Delete");
    deleteItem.setEnabled(false);

    final ToolItem upItem = new ToolItem(toolBar, SWT.NONE);
    upItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection =
                (IStructuredSelection) assignmentsViewer.getSelection();
            Assignment selected = (Assignment) selection.getFirstElement();
            List<Assignment> list = (List<Assignment>) assignmentsViewer.getInput();
            int index = list.indexOf(selected);
            list.remove(selected);
            list.add(index - 1, selected);
            assignmentsViewer.setSelection(new StructuredSelection(selected));
            assignmentsViewer.refresh(true);
          }
        });
    upItem.setEnabled(false);
    upItem.setText("Up");

    final ToolItem downItem = new ToolItem(toolBar, SWT.NONE);
    downItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection =
                (IStructuredSelection) assignmentsViewer.getSelection();
            Assignment selected = (Assignment) selection.getFirstElement();
            List<Assignment> list = (List<Assignment>) assignmentsViewer.getInput();
            int index = list.indexOf(selected);
            list.remove(selected);
            list.add(index + 1, selected);
            assignmentsViewer.setSelection(new StructuredSelection(selected));
            assignmentsViewer.refresh(true);
          }
        });
    downItem.setEnabled(false);
    downItem.setText("Down");

    Composite composite_2 = new Composite(composite_1, SWT.NONE);
    composite_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    // composite_2.setLayout(new GridLayout(1, false));

    assignmentsViewer = new TableViewer(composite_2, SWT.BORDER | SWT.FULL_SELECTION);
    assignmentsViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            if (event.getSelection() == null) {
              editItem.setEnabled(false);
              deleteItem.setEnabled(false);
              upItem.setEnabled(false);
              downItem.setEnabled(false);
            } else {
              editItem.setEnabled(true);
              deleteItem.setEnabled(true);
              List<Assignment> list = (List<Assignment>) assignmentsViewer.getInput();
              Assignment selected =
                  (Assignment) (((StructuredSelection) event.getSelection()).getFirstElement());
              if (list.indexOf(selected) == 0) {
                upItem.setEnabled(false);
                downItem.setEnabled(true);
              } else if (list.indexOf(selected) == list.size() - 1) {
                upItem.setEnabled(true);
                downItem.setEnabled(false);
              } else {
                upItem.setEnabled(true);
                downItem.setEnabled(true);
              }
            }
          }
        });
    table = assignmentsViewer.getTable();
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 0, 1));
    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    TableViewerColumn tableViewerColumn = new TableViewerColumn(assignmentsViewer, SWT.NONE);
    TableColumn tblclmnNewColumn = tableViewerColumn.getColumn();
    tblclmnNewColumn.setWidth(new Double(table.getSize().x * 0.2).intValue());
    tblclmnNewColumn.setResizable(true);
    tblclmnNewColumn.setText("Id");

    TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(assignmentsViewer, SWT.NONE);
    TableColumn tblclmnNewColumn_1 = tableViewerColumn_1.getColumn();
    tblclmnNewColumn_1.setWidth(new Double(table.getSize().x * 0.4).intValue());
    tblclmnNewColumn_1.setResizable(true);
    tblclmnNewColumn_1.setText("From");

    TableViewerColumn tableViewerColumn_2 = new TableViewerColumn(assignmentsViewer, SWT.NONE);
    TableColumn tblclmnNewColumn_2 = tableViewerColumn_2.getColumn();
    tblclmnNewColumn_2.setResizable(true);
    tblclmnNewColumn_2.setWidth(new Double(table.getSize().x * 0.4).intValue());
    tblclmnNewColumn_2.setText("To");
    TableColumnLayout tableColumnLayout = new TableColumnLayout();

    tableColumnLayout.setColumnData(tblclmnNewColumn, new ColumnWeightData(20, 50, true));
    tableColumnLayout.setColumnData(tblclmnNewColumn_1, new ColumnWeightData(40, 50, true));
    tableColumnLayout.setColumnData(tblclmnNewColumn_2, new ColumnWeightData(40, 50, true));
    composite_2.setLayout(tableColumnLayout);

    assignmentsViewer.setContentProvider(new ArrayContentProvider());
    assignmentsViewer.setLabelProvider(new AssignmentLabelProvider());

    VariableSupport.decorateTextWithVariableSupport(transformationText);
    transformationText.setFont(FontUtil.INSTANCE.getExpressionFont());
    new Label(composite, SWT.NONE);
    init();
    return area;
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.action.ContributionItem#update(java.lang.String)
   */
  public void update(String id) {
    if (widget != null) {
      if (widget instanceof MenuItem) {
        MenuItem item = (MenuItem) widget;

        String text = label;
        if (text == null) {
          if (command != null) {
            try {
              text = command.getCommand().getName();
            } catch (NotDefinedException e) {
              WorkbenchPlugin.log(
                  "Update item failed " //$NON-NLS-1$
                      + getId(),
                  e);
            }
          }
        }
        // TODO: [bm] key bindings
        //				text = updateMnemonic(text);
        //
        //				String keyBindingText = null;
        //				if (command != null) {
        //					TriggerSequence[] bindings = bindingService
        //							.getActiveBindingsFor(command);
        //					if (bindings.length > 0) {
        //						keyBindingText = bindings[0].format();
        //					}
        //				}
        //				if (text != null) {
        //					if (keyBindingText == null) {
        item.setText(text);
        //					} else {
        //						item.setText(text + '\t' + keyBindingText);
        //					}
        //				}

        updateIcons();
        if (item.getSelection() != checkedState) {
          item.setSelection(checkedState);
        }

        boolean shouldBeEnabled = isEnabled();
        if (item.getEnabled() != shouldBeEnabled) {
          item.setEnabled(shouldBeEnabled);
        }
      } else if (widget instanceof ToolItem) {
        ToolItem item = (ToolItem) widget;

        if (icon != null) {
          updateIcons();
        } else if (label != null) {
          item.setText(label);
        }

        if (tooltip != null) item.setToolTipText(tooltip);
        else {
          String text = label;
          if (text == null) {
            if (command != null) {
              try {
                text = command.getCommand().getName();
              } catch (NotDefinedException e) {
                WorkbenchPlugin.log(
                    "Update item failed " //$NON-NLS-1$
                        + getId(),
                    e);
              }
            }
          }
          if (text != null) {
            item.setToolTipText(text);
          }
        }

        if (item.getSelection() != checkedState) {
          item.setSelection(checkedState);
        }

        boolean shouldBeEnabled = isEnabled();
        if (item.getEnabled() != shouldBeEnabled) {
          item.setEnabled(shouldBeEnabled);
        }
      }
    }
  }
Пример #25
0
 public void setAddEnabled(boolean enable) {
   btnAdd.setEnabled(enable);
 }