Пример #1
0
 private void drawEQImage(GC gc) {
   if (ibuffer != null) {
     synchronized (ibuffer) {
       if (AXIS_PADDING + (MINIMUM_UNIT_HEIGHT * size) > winYSize) {
         scroll.setMinSize(
             canvas.computeSize(SWT.DEFAULT, AXIS_PADDING + (MINIMUM_UNIT_HEIGHT * size)));
       } else {
         scroll.setMinSize(canvas.computeSize(SWT.DEFAULT, winYSize));
       }
       if (ibuffer.isDisposed() == false) {
         gc.drawImage(ibuffer, 0, 0);
       }
     }
   }
 }
Пример #2
0
  public void addDescriptionRow(String sectionName) {
    RowData rowdata = (RowData) descriptionGroup.getLayoutData();
    rowdata.height += 60;
    descriptionGroup.setLayoutData(new RowData(rowdata.width, rowdata.height));
    Rectangle rect = descriptionGroup.getBounds();
    rect.height += 60;
    descriptionGroup.setBounds(rect);

    /*Add the row*/
    Text prevText = sections.get(new Integer(secCount - 1)).getEndTokens();
    rect = prevText.getBounds();
    Text newText_1 = new Text(descriptionGroup, SWT.BORDER);
    newText_1.setBounds(10, rect.y + 40, 75, 20);
    newText_1.setFocus();

    Label lblNew = new Label(descriptionGroup, SWT.NONE);
    lblNew.setBounds(120, rect.y + 40, 145, 20);
    lblNew.setText(sectionName);

    Text newText_2 = new Text(descriptionGroup, SWT.BORDER);
    newText_2.setBounds(270, rect.y + 40, 115, 20);

    Text newText_3 = new Text(descriptionGroup, SWT.BORDER);
    newText_3.setBounds(420, rect.y + 40, 115, 20);

    Text newText_4 = new Text(descriptionGroup, SWT.BORDER);
    newText_4.setBounds(570, rect.y + 40, 115, 20);
    sections.put(
        new Integer(secCount), new SectionBean(newText_1, lblNew, newText_2, newText_3, newText_4));
    secCount++;

    descScrolledComposite.setMinSize(descriptionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  }
Пример #3
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    final ScrolledComposite sc =
        new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    Composite c = new Composite(sc, SWT.NONE);
    c.setLayout(new GridLayout(10, true));
    for (int i = 0; i < 300; i++) {
      Button b = new Button(c, SWT.PUSH);
      b.setText("Button " + i);
    }
    sc.setContent(c);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc.setShowFocusedControl(true);

    shell.setSize(300, 500);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Пример #4
0
  public void addExpressionRow(String expressionName) {
    RowData rowdata = (RowData) expressionGroup.getLayoutData();
    rowdata.height += 120;
    expressionGroup.setLayoutData(new RowData(rowdata.width, rowdata.height));
    Rectangle rect = expressionGroup.getBounds();
    rect.height += 120;
    expressionGroup.setBounds(rect);
    /*Create a row*/
    ExpressionBean expBean = expressions.get(new Integer(expCount - 1));
    Label previousLabel = expBean.getLabel();
    rect = previousLabel.getBounds();
    Label lblNew = new Label(expressionGroup, SWT.NONE);
    lblNew.setBounds(10, rect.y + 90, 120, 15);
    lblNew.setText(expressionName);
    lblNew.setFocus();

    Text previousText = expBean.getText();
    rect = previousText.getBounds();

    Text newText = new Text(expressionGroup, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    newText.setBounds(135, rect.y + 90, 550, 70);
    expressions.put(new Integer(expCount), new ExpressionBean(lblNew, newText));
    expCount++;
    expScrolledComposite.setMinSize(expressionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  }
Пример #5
0
  /**
   * Create contents of the wizard.
   *
   * @param parent
   */
  @Override
  public void createControl(Composite parent) {
    ScrolledComposite scrolledComposite =
        new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    setControl(scrolledComposite);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);

    Composite composite = new Composite(scrolledComposite, SWT.NONE);
    scrolledComposite.setSize(500, 500);
    composite.setLayout(new GridLayout(1, false));
    radioButtons = new Button[imNames.length];
    for (int i = 0; i < imNames.length; i++) {
      radioButtons[i] = new Button(composite, SWT.RADIO);
      radioButtons[i].setImage(
          sia.ui.org.eclipse.wb.swt.SWTResourceManager.getImage(
              ImportChooseIM.class,
              "/sia/ui/resources/ims/"
                  + Dictionaries.getInstance().getDataSources().get(imNames[i])
                  + ".png"));
      radioButtons[i].setText(imNames[i]);
      radioButtons[i].addSelectionListener((ImportWizard) getWizard());
    }

    scrolledComposite.setContent(composite);
    scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  }
  /**
   * Implement the user interface for the preference page. Returns a control that should be used as
   * the main control for the page.
   *
   * <p>User interface defined here supports the definition of preference settings used by the
   * management logic. {@inheritDoc}
   */
  protected Control createContents(Composite parent) {
    /** Add layer to parent widget */
    final ScrolledComposite scrollComposite =
        new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    final Composite composite = new Composite(scrollComposite, SWT.NONE);

    /** Define laout rules for widget placement */
    compositeGridData(composite, 1);
    // add widgets to composite
    createShowContainerCount(composite);
    createShortCutsArea(composite);
    // context sensitive help
    Plugin.getHelpSystem().setHelp(parent, ContextHelpIds.PREFPAGE_OBJECT_MAP);
    initPreferences();
    scrollComposite.setContent(composite);
    scrollComposite.setExpandHorizontal(true);
    scrollComposite.setExpandVertical(true);
    scrollComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    scrollComposite.addControlListener(
        new ControlAdapter() {
          public void controlResized(ControlEvent e) {
            scrollComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
          }
        });
    return scrollComposite;
  }
  @Override
  protected Control createDialogArea(final Composite parent) {
    // parent has GridLayout with 1 column

    ScrolledComposite scrolledComposite =
        new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    scrolledComposite.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));

    Composite mainArea = new Composite(scrolledComposite, SWT.NONE);

    scrolledComposite.setContent(mainArea);

    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 10;
    mainArea.setLayout(gridLayout);

    /*
     * createViewer(mainArea);
     */
    createWidgetRows(mainArea);

    // 1)
    // mainArea.setSize(mainArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    // 2)
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setMinSize(mainArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    return scrolledComposite;
  }
Пример #8
0
 private void dealParentLayout(Composite container) {
   if (container == null) return;
   if (!(container instanceof ScrolledComposite)) {
     dealParentLayout(container.getParent());
     return;
   }
   ScrolledComposite composite = (ScrolledComposite) container;
   Composite control = (Composite) composite.getContent();
   composite.setMinSize(control.computeSize(SWT.DEFAULT, SWT.DEFAULT));
   control.layout();
 }
Пример #9
0
  @Override
  protected Control createDialogArea(Composite parent) {
    updateTitle();
    final Composite composite = (Composite) super.createDialogArea(parent);
    composite.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));
    final ScrolledComposite scrolledComposite =
        new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setBackground(composite.getBackground());
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);

    final Composite content = new Composite(scrolledComposite, SWT.NONE);
    content.setBackground(composite.getBackground());
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(content);
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(content);

    try {
      if (view == null) {
        ECPSWTViewRenderer.INSTANCE.render(content, selection);
      } else {
        ECPSWTViewRenderer.INSTANCE.render(content, selection, view);
      }
    } catch (final ECPRendererException ex) {
      Activator.log(ex);
    }

    scrolledComposite.setContent(content);
    final Point point = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    content.setSize(point);
    scrolledComposite.setMinSize(point);

    objectChangeAdapter =
        new AdapterImpl() {

          /**
           * {@inheritDoc}
           *
           * @see
           *     org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
           */
          @Override
          public void notifyChanged(Notification msg) {
            super.notifyChanged(msg);
            updateTitle();
          }
        };
    selection.eAdapters().add(objectChangeAdapter);

    return composite;
  }
Пример #10
0
 private void updatePreviewSize() {
   Point minSize;
   Rectangle bounds = scroll.getClientArea();
   if (preview.isFitHorizontal()) {
     if (preview.isFitVertical()) minSize = new Point(0, 0); // Best fit
     else minSize = new Point(0, preview.computeSize(bounds.width, SWT.DEFAULT).y); // Fit to width
   } else {
     if (preview.isFitVertical())
       minSize = new Point(preview.computeSize(SWT.DEFAULT, bounds.height).x, 0); // Fit to height
     else minSize = preview.computeSize(SWT.DEFAULT, SWT.DEFAULT); // Custom
     // scale
   }
   scroll.setMinSize(minSize);
 }
Пример #11
0
  private void handleOptionSelection() {
    // Get the selection from the tree list
    if (fTree == null) return;
    IStructuredSelection selection = (IStructuredSelection) fTree.getSelection();
    ToolListElement element = (ToolListElement) selection.getFirstElement();
    if (element != null) {
      displayPageForElement(element);
    }

    ScrollBar sb = containerSC.getHorizontalBar();
    if (sb != null && sb.isVisible()) {
      settingsPageContainer.pack(true);
      containerSC.setMinSize(settingsPageContainer.getSize());
      ((AbstractPage) page).resize();
    }
  }
Пример #12
0
  /** This is a callback that will allow us to create the viewer and initialize it. */
  public void createPartControl(Composite parent) {
    this.parent = parent;
    final ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    CrtVerViewComposite c = new CrtVerViewComposite(sc, SWT.NONE, this);
    sc.setContent(c);
    sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    c.setText();

    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(
            parent.getShell(),
            "org.jcryptool.visual.crtverification.views.CrtVerView"); //$NON-NLS-1$
  }
  /**
   * Creates and associates the required composites to present the parameters and the demo image for
   * the spatial operation.
   *
   * @param builder
   */
  @Override
  protected void createContents() {

    assert this.presenterFactory != null : "builder cannot not be null";

    GridLayout gridLayout = new GridLayout();
    setLayout(gridLayout);

    this.sash = new SashForm(this, SWT.NONE);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    gridData.verticalAlignment = GridData.FILL;
    this.sash.setLayoutData(gridData);

    this.dataScrollComposite = new ScrolledComposite(this.sash, SWT.BORDER | SWT.H_SCROLL);
    this.dataScrollComposite.setLayout(new FillLayout());

    this.dataComposite =
        (Composite) this.presenterFactory.createDataComposite(this.dataScrollComposite, SWT.BORDER);

    dataComposite.setLayoutData(gridData);

    this.dataScrollComposite.setContent(dataComposite);
    this.dataScrollComposite.setExpandHorizontal(true);
    this.dataScrollComposite.setExpandVertical(true);
    this.dataScrollComposite.setMinSize(dataComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    ScrolledComposite demoScrollComposite = new ScrolledComposite(sash, SWT.BORDER | SWT.H_SCROLL);
    demoScrollComposite.setLayout(new FillLayout());

    IImageOperation demoImages = this.presenterFactory.createDemoImages();

    this.demoComposite = new DemoComposite(demoScrollComposite, SWT.BORDER, demoImages);

    this.demoComposite.setLayoutData(gridData);

    demoScrollComposite.setContent(this.demoComposite);
    demoScrollComposite.setExpandHorizontal(true);
    demoScrollComposite.setExpandVertical(true);
    demoScrollComposite.setMinSize(demoComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    sash.setWeights(new int[] {70, 30});

    super.addPresenter((AggregatedPresenter) dataComposite);
  }
  /**
   * Creates the composite holding the details.
   *
   * @param parent the parent
   * @return the right panel/detail composite
   */
  protected ScrolledComposite createRightPanelContent(Composite parent) {
    rightPanel = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    rightPanel.setShowFocusedControl(true);
    rightPanel.setExpandVertical(true);
    rightPanel.setExpandHorizontal(true);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(rightPanel);
    rightPanel.setLayout(GridLayoutFactory.fillDefaults().create());
    rightPanel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));

    container = new Composite(rightPanel, SWT.FILL);
    container.setLayout(GridLayoutFactory.fillDefaults().create());
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(container);
    container.setBackground(rightPanel.getBackground());

    /* The header */
    final Composite header = new Composite(container, SWT.FILL);
    final GridLayout headerLayout = GridLayoutFactory.fillDefaults().create();
    headerLayout.marginWidth = 5;
    header.setLayout(headerLayout);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(header);
    header.setBackground(rightPanel.getBackground());

    final Label label = new Label(header, SWT.WRAP);
    label.setText("Details"); // $NON-NLS-1$
    detailsFont = new Font(label.getDisplay(), getDefaultFontName(label), 10, SWT.BOLD);
    label.setFont(detailsFont);
    label.setForeground(getTitleColor(parent));
    label.setBackground(header.getBackground());

    rightPanelContainerComposite = new Composite(container, SWT.FILL);
    rightPanelContainerComposite.setLayout(GridLayoutFactory.fillDefaults().create());
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.FILL)
        .grab(true, true)
        .applyTo(rightPanelContainerComposite);
    rightPanelContainerComposite.setBackground(rightPanel.getBackground());

    rightPanel.setContent(container);

    rightPanel.layout();
    container.layout();

    final Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    rightPanel.setMinSize(point);

    return rightPanel;
  }
Пример #15
0
  private void displayPageForElement(ToolListElement element) {
    selectedElement = element;
    settingsStore.setSelection(getAutotoolsCfg(), selectedElement);

    AbstractConfigurePropertyOptionsPage oldPage = currentSettingsPage;
    currentSettingsPage = null;

    // Create a new settings page if necessary
    List<AbstractConfigurePropertyOptionsPage> pages = getPagesForConfig();
    ListIterator<AbstractConfigurePropertyOptionsPage> iter = pages.listIterator();

    while (iter.hasNext()) {
      AbstractConfigurePropertyOptionsPage page = iter.next();
      if (page.getName().equals(element.getName())) {
        currentSettingsPage = page;
        break;
      }
    }
    if (currentSettingsPage == null) {
      if (element.getType() == IConfigureOption.TOOL) {
        currentSettingsPage = new AutotoolsToolPropertyOptionPage(element, getAutotoolsCfg());
      } else {
        currentSettingsPage = new AutotoolsCategoryPropertyOptionPage(element, getAutotoolsCfg());
      }
      pages.add(currentSettingsPage);
      currentSettingsPage.setContainer(this);
      if (currentSettingsPage.getControl() == null) {
        currentSettingsPage.createControl(settingsPageContainer);
      }
    }

    // Make all the other pages invisible
    Control[] children = settingsPageContainer.getChildren();
    Control currentControl = currentSettingsPage.getControl();
    for (int i = 0; i < children.length; i++) {
      if (children[i] != currentControl) children[i].setVisible(false);
    }
    currentSettingsPage.setVisible(true);
    currentSettingsPage.updateFields();

    if (oldPage != null && oldPage != currentSettingsPage) oldPage.setVisible(false);

    // Set the size of the scrolled area
    containerSC.setMinSize(currentSettingsPage.computeSize());
    settingsPageContainer.layout();
  }
 protected void setSize(Composite composite) {
   if (composite != null) {
     // Note: The font is set here in anticipation that the class inheriting
     //       this base class may add widgets to the dialog.   setSize
     //       is assumed to be called just before we go live.
     applyDialogFont(composite);
     Point minSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
     composite.setSize(minSize);
     // set scrollbar composite's min size so page is expandable but
     // has scrollbars when needed
     if (composite.getParent() instanceof ScrolledComposite) {
       ScrolledComposite sc1 = (ScrolledComposite) composite.getParent();
       sc1.setMinSize(minSize);
       sc1.setExpandHorizontal(true);
       sc1.setExpandVertical(true);
     }
   }
 }
Пример #17
0
  /**
   * Create contents of the dialog.
   *
   * @param parent
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    setMessage("Icon Selection");
    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));

    ScrolledComposite scrolledComposite =
        new ScrolledComposite(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);

    Composite composite = new Composite(scrolledComposite, SWT.NONE);
    composite.setLayout(new GridLayout(9, true));

    for (Descriptor i : IconRegistry.getRegisteredImages()) {
      Button btnCheckButton = new Button(composite, SWT.RADIO);
      btnCheckButton.setImage(IconRegistry.getImage(i.id));
      btnCheckButton.setData(i);

      btnCheckButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              Object source = e.getSource();
              if (source instanceof Button) {
                Button btn = (Button) source;
                Object data = btn.getData();
                if (data instanceof Descriptor) {
                  Descriptor desc = (Descriptor) data;
                  imageSelected = desc.id;
                }
              }
            }
          });
    }

    scrolledComposite.setContent(composite);
    scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    return area;
  }
  /**
   * Resizes the Section's client and updates the Property Viewer's {@link ScrolledComposite} to
   * account for GridLayouts in the client.
   */
  private void resizePropertyView() {
    // Disable re-drawing for the ScrolledComposite.
    scrollComposite.setRedraw(false);

    int verticalPadding = scrollComposite.getHorizontalBar().getSize().y;
    int horizontalPadding = scrollComposite.getVerticalBar().getSize().x;
    Rectangle clientArea = scrollComposite.getClientArea();
    Point clientAreaSize =
        new Point(clientArea.width - horizontalPadding, clientArea.height - verticalPadding);

    // Recompute the size of the first Composite in the ScrolledComposite
    // based on the width of the ScrolledComposite's client area.
    Point size = scrollCompositeClient.computeSize(clientAreaSize.x, clientAreaSize.y);

    // Update the size of the ScrolledComposite's client.
    scrollCompositeClient.setSize(size);

    // Set the minimum size at which the ScrolledComposite will start
    // drawing scroll bars. This should be the size of its client area minus
    // the spaces the scroll bars would consume.
    scrollComposite.setMinSize(clientAreaSize.x + 1, clientAreaSize.y + 1);

    // We need to call layout() so the ScrolledComposite will update.
    scrollComposite.layout();

    // Set the height hint for the Section's parent Composite. This keeps
    // the TableViewer from going beyond the bottom edge of the Properties
    // Viewer. We want to keep the add and delete buttons visible, and the
    // TableViewer already has its own scroll bars!
    Composite sectionParent = section.getParent();
    GridData gridData = (GridData) sectionParent.getLayoutData();
    GridLayout gridLayout = (GridLayout) sectionParent.getParent().getLayout();
    gridData.heightHint = sectionParent.getParent().getSize().y - gridLayout.marginTop;

    // The parent of the Section has a FillLayout. Its parent has a
    // GridLayout, but sometimes it does not update. Tell it to layout so
    // the Section's parent will update its size.
    section.getParent().getParent().layout();

    // Enable re-drawing for the ScrolledComposite.
    scrollComposite.setRedraw(true);

    return;
  }
  @Override
  protected void createWorkarea(Composite parent) {
    parent.setLayout(new FillLayout());
    final Color bgColor = LnfManager.getLnf().getColor(LnfKeyConstants.SUB_MODULE_BACKGROUND);

    final ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);
    scrolled.setBackground(bgColor);

    final Composite newParent = new Composite(scrolled, SWT.DOUBLE_BUFFERED);
    scrolled.setContent(newParent);
    newParent.setBackground(bgColor);

    basicCreatePartControl(newParent);
    afterBasicCreatePartControl(newParent);

    scrolled.setMinSize(newParent.computeSize(640, 480));
  }
 /** 刷新过滤器设置组件 */
 private void refresh() {
   filterNameTxt.setText("");
   andBtn.setSelection(true);
   orBtn.setSelection(false);
   btnIsTagged.setSelection(false);
   btnQT.setSelection(false);
   btnPT.setSelection(false);
   if (btnIsRemoveFromSrc != null) {
     btnIsRemoveFromSrc.setSelection(false);
   }
   for (Control ctl : conditionList) {
     if (!ctl.isDisposed()) {
       ctl.dispose();
     }
   }
   conditionList.clear();
   new DynaComposite(dynaComp, SWT.NONE);
   scroll.setMinSize(dynaComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
   dynaComp.layout();
 }
  /**
   * When any <code>ProgressReporterPanel</code> in this window is expanded or collapsed re-layout
   * the controls and window appropriately
   */
  public void isCollapsed(boolean value) {
    if (null != shell && false == shell.isDisposed()) {
      scrollable.setRedraw(false);
      Rectangle r = scrollable.getClientArea();
      scrollable.setMinSize(scrollChild.computeSize(r.width, SWT.DEFAULT));

      /*
       * Resizing to fit the panel if there is only one
       */
      if (pReporters.length == 1) {
        Point p = shell.computeSize(defaultShellWidth, SWT.DEFAULT);
        if (shell.getSize().y != p.y) {
          p.x = shell.getSize().x;
          shell.setSize(p);
        }
      }

      scrollable.layout();
      scrollable.setRedraw(true);
    }
  }
Пример #22
0
  private static void createEmoticonsGroup(final Composite main, String protocol) {
    final Group group = new Group(main, SWT.NONE);
    group.setLayoutData(new GridData(GridData.FILL_BOTH));
    group.setText("Emoticons");
    group.setLayout(new FillLayout());

    emoticonsScroll = new ScrolledComposite(group, SWT.V_SCROLL);
    emoticonsComposite = new Composite(emoticonsScroll, SWT.NONE);
    emoticonsComposite.setLayout(new GridLayout(4, false));

    createBoldLabel(emoticonsComposite, "Protocol:", gridData(2, 1));
    createProtoCombo(emoticonsComposite, protocol, main, group);

    for (final Emoticon emo : mep.emoticons) {
      EmoticonImage icon = emo.icons.get(protocol);
      if (icon == null) continue;

      createEmoticonNameLabel(emoticonsComposite, icon);

      createIconCombo(emoticonsComposite, icon);
      createFramesHolder(emoticonsComposite, icon);
    }

    emoticonsScroll.setContent(emoticonsComposite);
    emoticonsScroll.setExpandHorizontal(true);
    emoticonsScroll.setExpandVertical(true);
    emoticonsScroll.addControlListener(
        new ControlAdapter() {
          @Override
          public void controlResized(ControlEvent e) {
            Rectangle r = emoticonsScroll.getClientArea();
            emoticonsScroll.setMinSize(emoticonsComposite.computeSize(r.width, SWT.DEFAULT));
          }
        });

    //		emoticonsComposite.pack();
    emoticonsScroll.setMinSize(emoticonsComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT, false));
  }
  /**
   * Restores the layout properties stored in {@link #aboutToBeShown()} and changed in {@link
   * #resizePropertyView()}.
   */
  @Override
  public void aboutToBeHidden() {
    super.aboutToBeHidden();

    // If possible, we need to restore the settings clobbered in
    // resizeProperties();
    if (!scrollComposite.isDisposed()) {
      // Restore the GridData of the Section's parent.
      GridData gridData = (GridData) section.getParent().getLayoutData();
      gridData.heightHint = SWT.DEFAULT;

      // Restore the default size of the ScrolledComposite's client.
      Point size = scrollCompositeClient.computeSize(SWT.DEFAULT, SWT.DEFAULT);
      scrollCompositeClient.setSize(size);

      // Restore the min size of the ScrolledComposite.
      scrollComposite.setMinSize(scrollMinWidth, scrollMinHeight);

      // Re-layout the ScrolledComposite.
      scrollComposite.layout();
    }

    return;
  }
Пример #24
0
  public ECContentReal(Composite parent, int style, ECView view) {
    super(parent, style);
    this.view = view;

    this.setLayout(new FillLayout());

    ScrolledComposite scrolledComposite = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    content = new Composite(scrolledComposite, SWT.NONE);

    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.verticalSpacing = 2;
    content.setLayout(gridLayout);

    createCompositeIntro();
    createGroupCurve();
    createGroupSettings();

    scrolledComposite.setContent(content);
    scrolledComposite.setMinSize(content.computeSize(862, 664));

    createGroupAttributesR();

    Display.getCurrent()
        .asyncExec(
            new Runnable() {
              public void run() {
                try {
                  Thread.sleep(10);
                } catch (InterruptedException e) {
                }
                updateCurve(true);
              }
            });
  }
Пример #25
0
  public void addNomenclatureRow(String name) {

    RowData rowdata = (RowData) nomenclatureGroup.getLayoutData();
    rowdata.height += 30;
    nomenclatureGroup.setLayoutData(new RowData(rowdata.width, rowdata.height));
    Rectangle rect = nomenclatureGroup.getBounds();
    rect.height += 30;
    nomenclatureGroup.setBounds(rect);

    /*Create a row*/

    NomenclatureBean nbean = nomenclatures.get(new Integer(nomenCount - 1));
    Label previousLabel = nbean.getLabel();
    rect = previousLabel.getBounds();
    rect.y += 45;

    Label lblNew = new Label(nomenclatureGroup, SWT.NONE);
    lblNew.setBounds(rect);
    lblNew.setText(name);
    lblNew.setFocus();

    /* Create the first group*/
    Group prevGroup = nbean.getParent();
    rect = prevGroup.getBounds();
    Group group_1 = new Group(nomenclatureGroup, SWT.NONE);
    group_1.setBounds(100, rect.y + 45, 182, 40);

    Button buttonYes_1 = new Button(group_1, SWT.RADIO);
    buttonYes_1.setText("Yes");
    buttonYes_1.setBounds(10, 13, 39, 16);

    Button buttonNo_1 = new Button(group_1, SWT.RADIO);
    buttonNo_1.setText("No");
    buttonNo_1.setBounds(55, 13, 39, 16);

    Text text1 = new Text(group_1, SWT.BORDER);
    text1.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_1, buttonYes_1, buttonNo_1, text1, lblNew));
    nomenCount++;
    ///////////////////////////////////

    /*Create the second group */
    Group group_2 = new Group(nomenclatureGroup, SWT.NONE);
    group_2.setBounds(300, rect.y + 45, 182, 40);

    Button buttonYes_2 = new Button(group_2, SWT.RADIO);
    buttonYes_2.setText("Yes");
    buttonYes_2.setBounds(10, 13, 39, 16);

    Button buttonNo_2 = new Button(group_2, SWT.RADIO);
    buttonNo_2.setText("No");
    buttonNo_2.setBounds(55, 13, 39, 16);

    Text text2 = new Text(group_2, SWT.BORDER);
    text2.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_2, buttonYes_2, buttonNo_2, text2, lblNew));
    nomenCount++;

    /* Create the third group */
    Group group_3 = new Group(nomenclatureGroup, SWT.NONE);
    group_3.setBounds(500, rect.y + 45, 182, 40);

    Button buttonYes_3 = new Button(group_3, SWT.RADIO);
    buttonYes_3.setText("Yes");
    buttonYes_3.setBounds(10, 13, 39, 16);

    Button buttonNo_3 = new Button(group_3, SWT.RADIO);
    buttonNo_3.setText("No");
    buttonNo_3.setBounds(55, 13, 39, 16);

    Text text3 = new Text(group_3, SWT.BORDER);
    text3.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_3, buttonYes_3, buttonNo_3, text3, lblNew));
    nomenCount++;
    nomenScrolledComposite.setMinSize(nomenclatureGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  }
Пример #26
0
  /** @wbp.parser.entryPoint */
  public void showType2Document() {
    final Display display = Display.getDefault();

    shlTypeDocument = new Shell(display);
    shlTypeDocument.setText("Type 2 Document");
    shlTypeDocument.setSize(780, 634);
    shlTypeDocument.setLocation(display.getBounds().x + 200, display.getBounds().y + 100);

    Composite composite = new Composite(shlTypeDocument, SWT.NONE);
    composite.setBounds(0, 0, 759, 557);

    TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
    tabFolder.setBounds(10, 10, 742, 545);

    TabItem tbtmText = new TabItem(tabFolder, SWT.NONE);
    tbtmText.setText("Text");

    Group grpText = new Group(tabFolder, SWT.NONE);
    grpText.setText("Text");
    tbtmText.setControl(grpText);
    // The first tab!  --> Text
    Label lblLeadingIndentionOf = new Label(grpText, SWT.NONE);
    lblLeadingIndentionOf.setBounds(10, 82, 374, 15);
    lblLeadingIndentionOf.setText("Leading indention of other paragraph:");

    text = new Text(grpText, SWT.BORDER);
    text.setBounds(422, 79, 76, 21);

    Label lblCharacters = new Label(grpText, SWT.NONE);
    lblCharacters.setBounds(504, 82, 85, 15);
    lblCharacters.setText("characters");

    Label lblSpacingBetweenCharacters = new Label(grpText, SWT.NONE);
    lblSpacingBetweenCharacters.setBounds(10, 116, 374, 15);
    lblSpacingBetweenCharacters.setText("Spacing between paragraphs:");

    text_1 = new Text(grpText, SWT.BORDER);
    text_1.setBounds(422, 113, 76, 21);

    Label lblLines = new Label(grpText, SWT.NONE);
    lblLines.setBounds(504, 116, 85, 15);
    lblLines.setText("lines");

    Label lblstParagraph = new Label(grpText, SWT.NONE);
    lblstParagraph.setBounds(10, 47, 374, 15);
    lblstParagraph.setText("1st Paragraph:");

    text_2 = new Text(grpText, SWT.BORDER);
    text_2.setBounds(422, 47, 76, 21);

    Label label_2 = new Label(grpText, SWT.NONE);
    label_2.setBounds(504, 47, 85, 15);
    label_2.setText("characters");

    Label lblEstimatedAverageLengths = new Label(grpText, SWT.NONE);
    lblEstimatedAverageLengths.setBounds(10, 154, 374, 15);
    lblEstimatedAverageLengths.setText("Estimated average length(s) of a line:");

    text_3 = new Text(grpText, SWT.BORDER);
    text_3.setBounds(422, 148, 76, 21);

    Label label_3 = new Label(grpText, SWT.NONE);
    label_3.setBounds(504, 154, 85, 15);
    label_3.setText("characters");

    Label lblPageNumberForms = new Label(grpText, SWT.NONE);
    lblPageNumberForms.setBounds(10, 194, 141, 15);
    lblPageNumberForms.setText("Page number forms:");

    text_4 = new Text(grpText, SWT.BORDER);
    text_4.setBounds(161, 191, 477, 21);

    Label lblSectionHeadings = new Label(grpText, SWT.NONE);
    lblSectionHeadings.setBounds(10, 237, 141, 15);
    lblSectionHeadings.setText("Section headings:");

    Button btnCapitalized = new Button(grpText, SWT.RADIO);
    btnCapitalized.setBounds(169, 236, 90, 16);
    btnCapitalized.setText("Capitalized");

    Button btnAllCapital = new Button(grpText, SWT.RADIO);
    btnAllCapital.setBounds(263, 237, 90, 16);
    btnAllCapital.setText("ALL CAPITAL");

    text_5 = new Text(grpText, SWT.BORDER);
    text_5.setBounds(366, 231, 272, 21);

    Label lblFooterTokens = new Label(grpText, SWT.NONE);
    lblFooterTokens.setBounds(10, 283, 85, 15);
    lblFooterTokens.setText("Footer tokens:");

    Button btnHasFooters = new Button(grpText, SWT.CHECK);
    btnHasFooters.setBounds(123, 282, 93, 16);
    btnHasFooters.setText("Has footers");

    text_6 = new Text(grpText, SWT.BORDER);
    text_6.setBounds(222, 280, 98, 21);

    Label lblHeaderTokens = new Label(grpText, SWT.NONE);
    lblHeaderTokens.setBounds(337, 283, 85, 15);
    lblHeaderTokens.setText("Header tokens:");

    Button btnHasHeaders = new Button(grpText, SWT.CHECK);
    btnHasHeaders.setBounds(428, 282, 93, 16);
    btnHasHeaders.setText("Has headers");

    text_7 = new Text(grpText, SWT.BORDER);
    text_7.setBounds(523, 277, 98, 21);

    textBean =
        new TextBean(
            text_2,
            text,
            text_1,
            text_3,
            text_4,
            btnCapitalized,
            btnAllCapital,
            text_5,
            new SpecialBean(btnHasFooters, btnHasHeaders, text_6, text_7));

    TabItem tbtmNomenclature = new TabItem(tabFolder, SWT.NONE);
    tbtmNomenclature.setText("Nomenclature");

    Group grpNomenclature = new Group(tabFolder, SWT.NONE);
    grpNomenclature.setText("Nomenclature");
    tbtmNomenclature.setControl(grpNomenclature);

    Label lblWhatIsIn = new Label(grpNomenclature, SWT.NONE);
    lblWhatIsIn.setBounds(10, 28, 111, 15);
    lblWhatIsIn.setText("What is in a name?");

    Label lblFamily = new Label(grpNomenclature, SWT.NONE);
    lblFamily.setBounds(233, 28, 55, 15);
    lblFamily.setText("Family");

    Label lblGenus = new Label(grpNomenclature, SWT.NONE);
    lblGenus.setBounds(399, 28, 55, 15);
    lblGenus.setText("Genus");

    Label lblSpecies = new Label(grpNomenclature, SWT.NONE);
    lblSpecies.setBounds(569, 28, 55, 15);
    lblSpecies.setText("Species");

    nomenScrolledComposite =
        new ScrolledComposite(grpNomenclature, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    nomenScrolledComposite.setBounds(10, 53, 714, 278);
    nomenScrolledComposite.setExpandHorizontal(true);
    nomenScrolledComposite.setExpandVertical(true);

    nomenclatureGroup = new Group(nomenScrolledComposite, SWT.NONE);
    nomenclatureGroup.setLayoutData(new RowData());

    Label lblName = new Label(nomenclatureGroup, SWT.NONE);
    lblName.setBounds(10, 20, 75, 15);
    lblName.setText("Name");

    Group group_2 = new Group(nomenclatureGroup, SWT.NONE);
    group_2.setBounds(100, 10, 182, 40);

    Button button = new Button(group_2, SWT.RADIO);
    button.setText("Yes");
    button.setBounds(10, 13, 39, 16);

    Button button_1 = new Button(group_2, SWT.RADIO);
    button_1.setText("No");
    button_1.setBounds(55, 13, 39, 16);

    text_14 = new Text(group_2, SWT.BORDER);
    text_14.setBounds(100, 11, 76, 21);
    nomenclatures.put(
        new Integer(nomenCount), new NomenclatureBean(group_2, button, button_1, text_14, lblName));
    nomenCount++;

    Group group_1 = new Group(nomenclatureGroup, SWT.NONE);
    group_1.setBounds(300, 10, 182, 40);

    Button button_2 = new Button(group_1, SWT.RADIO);
    button_2.setText("Yes");
    button_2.setBounds(10, 13, 39, 16);

    Button button_3 = new Button(group_1, SWT.RADIO);
    button_3.setText("No");
    button_3.setBounds(55, 13, 39, 16);

    text_15 = new Text(group_1, SWT.BORDER);
    text_15.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_1, button_2, button_3, text_15, lblName));
    nomenCount++;

    ///////////////
    Group group_4 = new Group(nomenclatureGroup, SWT.NONE);
    group_4.setBounds(500, 10, 182, 40);

    Button button_4 = new Button(group_4, SWT.RADIO);
    button_4.setText("Yes");
    button_4.setBounds(10, 13, 39, 16);

    Button button_5 = new Button(group_4, SWT.RADIO);
    button_5.setText("No");
    button_5.setBounds(55, 13, 39, 16);

    text_16 = new Text(group_4, SWT.BORDER);
    text_16.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_4, button_4, button_5, text_16, lblName));
    nomenCount++;

    String[] nomenclatureArray = {"Authors", "Date", "Publication", "Taxon Rank"};
    for (String name : nomenclatureArray) {
      addNomenclatureRow(name);
    }

    nomenScrolledComposite.setContent(nomenclatureGroup);
    // When you add a row, reset the size of scrolledComposite
    nomenScrolledComposite.setMinSize(nomenclatureGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Button btnAddARow = new Button(grpNomenclature, SWT.NONE);
    btnAddARow.setBounds(10, 337, 75, 25);
    btnAddARow.setText("Add a Row");
    btnAddARow.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = null;
            showInputBox();
            if (identifier != null && !identifier.equals("")) {
              addNomenclatureRow(identifier);
            }
          }
        });

    TabItem tbtmExpressions = new TabItem(tabFolder, SWT.NONE);
    tbtmExpressions.setText("Expressions");

    Group grpExpressionsUsedIn = new Group(tabFolder, SWT.NONE);
    grpExpressionsUsedIn.setText("Expressions used in Nomenclature");
    tbtmExpressions.setControl(grpExpressionsUsedIn);

    Label lblUseCapLetters = new Label(grpExpressionsUsedIn, SWT.NONE);
    lblUseCapLetters.setBounds(10, 22, 426, 15);
    lblUseCapLetters.setText("Use CAP words for fixed tokens; use small letters for variables");

    Label lblHononyms = new Label(grpExpressionsUsedIn, SWT.NONE);
    lblHononyms.setBounds(348, 22, 99, 15);
    lblHononyms.setText("Hononyms:");

    expScrolledComposite =
        new ScrolledComposite(grpExpressionsUsedIn, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    expScrolledComposite.setBounds(10, 43, 714, 440);
    expScrolledComposite.setExpandHorizontal(true);
    expScrolledComposite.setExpandVertical(true);

    expressionGroup = new Group(expScrolledComposite, SWT.NONE);
    expressionGroup.setLayoutData(new RowData());

    // count of number of rows
    expCount = 0;
    Label lblSpecialTokensUsed = new Label(expressionGroup, SWT.NONE);
    lblSpecialTokensUsed.setBounds(10, 20, 120, 15);
    lblSpecialTokensUsed.setText("Special tokens used:");

    text_29 = new Text(expressionGroup, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_29.setBounds(135, 20, 550, 70);

    expressions.put(new Integer(expCount), new ExpressionBean(lblSpecialTokensUsed, text_29));
    expCount++;

    String[] expressionArray = {"Minor Amendment:", "Past name:", "Name origin:", "Homonyms:"};
    for (String name : expressionArray) {
      addExpressionRow(name);
    }

    expScrolledComposite.setContent(expressionGroup);
    expScrolledComposite.setMinSize(expressionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Button btnAddARow_2 = new Button(grpExpressionsUsedIn, SWT.NONE);
    btnAddARow_2.setBounds(10, 489, 75, 25);
    btnAddARow_2.setText("Add a row");
    btnAddARow_2.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = null;
            showInputBox();
            if (identifier != null && !identifier.equals("")) {
              addExpressionRow(identifier);
            }
          }
        });

    TabItem tbtmDescription = new TabItem(tabFolder, SWT.NONE);
    tbtmDescription.setText("Description");

    Group grpMorphologicalDescriptions = new Group(tabFolder, SWT.NONE);
    tbtmDescription.setControl(grpMorphologicalDescriptions);

    Label lblAllInOne = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblAllInOne.setBounds(10, 53, 160, 15);
    lblAllInOne.setText("All in one paragraph");

    Button btnYes = new Button(grpMorphologicalDescriptions, SWT.RADIO);
    btnYes.setBounds(241, 52, 90, 16);
    btnYes.setText("Yes");

    Button btnNo = new Button(grpMorphologicalDescriptions, SWT.RADIO);
    btnNo.setBounds(378, 52, 90, 16);
    btnNo.setText("No");

    Label lblOtherInformationMay = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblOtherInformationMay.setBounds(10, 85, 438, 15);
    lblOtherInformationMay.setText(
        "Other information may also be included in a description paragraph:");

    Combo combo = new Combo(grpMorphologicalDescriptions, SWT.NONE);
    combo.setItems(new String[] {"Nomenclature", "Habitat", "Distribution", "Discussion", "Other"});
    combo.setBounds(496, 82, 177, 23);

    descriptionBean = new DescriptionBean(btnYes, btnNo, combo, sections);

    Label lblMorphological = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblMorphological.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblMorphological.setBounds(10, 25, 242, 15);
    lblMorphological.setText("Morphological Descriptions: ");

    Label lblOrder = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblOrder.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblOrder.setBounds(22, 142, 55, 15);
    lblOrder.setText("Order");

    Label lblSection = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblSection.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblSection.setBounds(140, 142, 55, 15);
    lblSection.setText("Section");

    Label lblStartTokens = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblStartTokens.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblStartTokens.setBounds(285, 142, 90, 15);
    lblStartTokens.setText("Start tokens");

    Label lblEndTokens = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblEndTokens.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblEndTokens.setBounds(443, 142, 68, 15);
    lblEndTokens.setText("End tokens");

    Label lblEmbeddedTokens = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblEmbeddedTokens.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblEmbeddedTokens.setBounds(592, 142, 132, 15);
    lblEmbeddedTokens.setText("Embedded tokens");

    descScrolledComposite =
        new ScrolledComposite(
            grpMorphologicalDescriptions, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    descScrolledComposite.setBounds(10, 169, 714, 310);
    descScrolledComposite.setExpandHorizontal(true);
    descScrolledComposite.setExpandVertical(true);

    descriptionGroup = new Group(descScrolledComposite, SWT.NONE);
    descriptionGroup.setLayoutData(new RowData());

    text_33 = new Text(descriptionGroup, SWT.BORDER);
    text_33.setBounds(10, 20, 75, 20);

    Label lblNomenclature = new Label(descriptionGroup, SWT.NONE);
    lblNomenclature.setBounds(120, 20, 145, 20);
    lblNomenclature.setText("Nomenclature");

    text_40 = new Text(descriptionGroup, SWT.BORDER);
    text_40.setBounds(270, 20, 115, 20);

    text_41 = new Text(descriptionGroup, SWT.BORDER);
    text_41.setBounds(420, 20, 115, 20);

    text_42 = new Text(descriptionGroup, SWT.BORDER);
    text_42.setBounds(570, 20, 115, 20);

    sections.put(
        new Integer(secCount),
        new SectionBean(text_33, lblNomenclature, text_40, text_41, text_42));
    secCount++;

    String[] sectionArray = {
      "Morph. description", "Habitat", "Distribution", "Discussion", "Keys", "References"
    };
    for (String name : sectionArray) {
      addDescriptionRow(name);
    }

    descScrolledComposite.setContent(descriptionGroup);
    descScrolledComposite.setMinSize(descriptionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Button btnAddARow_1 = new Button(grpMorphologicalDescriptions, SWT.NONE);
    btnAddARow_1.setBounds(10, 482, 75, 25);
    btnAddARow_1.setText("Add a row");
    btnAddARow_1.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = null;
            showInputBox();
            if (identifier != null && !identifier.equals("")) {
              addDescriptionRow(identifier);
            }
          }
        });

    Label lblSectionIndicationsAnd = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblSectionIndicationsAnd.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblSectionIndicationsAnd.setBounds(10, 116, 222, 15);
    lblSectionIndicationsAnd.setText("Section indications and order:");

    TabItem tbtmSpecial = new TabItem(tabFolder, SWT.NONE);
    tbtmSpecial.setText("Special");

    Group grpSpecialSections = new Group(tabFolder, SWT.NONE);
    grpSpecialSections.setText("Special Sections");
    tbtmSpecial.setControl(grpSpecialSections);

    Label lblGlossaries = new Label(grpSpecialSections, SWT.NONE);
    lblGlossaries.setBounds(10, 51, 55, 15);
    lblGlossaries.setText("Glossaries:");

    Button btnHasGlossaries = new Button(grpSpecialSections, SWT.CHECK);
    btnHasGlossaries.setBounds(96, 51, 93, 16);
    btnHasGlossaries.setText("has glossaries");

    Label lblGlossaryHeading = new Label(grpSpecialSections, SWT.NONE);
    lblGlossaryHeading.setBounds(257, 51, 93, 15);
    lblGlossaryHeading.setText("Glossary heading");

    text_9 = new Text(grpSpecialSections, SWT.BORDER);
    text_9.setBounds(377, 48, 76, 21);

    Label lblReferences = new Label(grpSpecialSections, SWT.NONE);
    lblReferences.setBounds(10, 102, 69, 15);
    lblReferences.setText("References :");

    Button btnHasReferences = new Button(grpSpecialSections, SWT.CHECK);
    btnHasReferences.setBounds(96, 102, 93, 16);
    btnHasReferences.setText("has references");

    Label lblReferencesHeading = new Label(grpSpecialSections, SWT.NONE);
    lblReferencesHeading.setBounds(257, 102, 114, 15);
    lblReferencesHeading.setText("References heading:");

    text_10 = new Text(grpSpecialSections, SWT.BORDER);
    text_10.setBounds(377, 99, 76, 21);
    special = new SpecialBean(btnHasGlossaries, btnHasReferences, text_9, text_10);

    TabItem tbtmAbbreviations = new TabItem(tabFolder, SWT.NONE);
    tbtmAbbreviations.setText("Abbreviations");

    Group grpAbbreviationsUsedIn = new Group(tabFolder, SWT.NONE);
    tbtmAbbreviations.setControl(grpAbbreviationsUsedIn);

    text_11 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    text_11.setBounds(10, 52, 691, 69);
    abbreviations.put("Text", text_11);

    Label lblAbbreviationsUsedIn = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn.setBounds(10, 31, 272, 15);
    lblAbbreviationsUsedIn.setText("Abbreviations used in text:");

    Label lblAbbreviationsUsedIn_1 = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn_1.setBounds(10, 150, 272, 15);
    lblAbbreviationsUsedIn_1.setText("Abbreviations used in bibliographical citations:");

    text_12 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_12.setBounds(10, 175, 691, 69);
    abbreviations.put("Bibliographical Citations", text_12);

    Label lblAbbreviationsUsedIn_2 = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn_2.setBounds(10, 275, 272, 15);
    lblAbbreviationsUsedIn_2.setText("Abbreviations used in authorities:");

    text_13 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_13.setBounds(10, 296, 691, 69);
    abbreviations.put("Authorities", text_13);

    Label lblAbbreviationsUsedIn_3 = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn_3.setBounds(10, 395, 204, 15);
    lblAbbreviationsUsedIn_3.setText("Abbreviations used in others:");

    text_8 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_8.setBounds(10, 416, 691, 69);
    abbreviations.put("Others", text_8);
    final Type2Bean bean =
        new Type2Bean(
            textBean, nomenclatures, expressions, descriptionBean, special, abbreviations);
    Button btnSave = new Button(shlTypeDocument, SWT.NONE);
    btnSave.setBounds(670, 563, 75, 25);
    btnSave.setText("Save");
    btnSave.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            try {
              if (configDb.saveType2Details(bean)) {
                ApplicationUtilities.showPopUpWindow(
                    ApplicationUtilities.getProperty("popup.info.savetype3"),
                    ApplicationUtilities.getProperty("popup.header.info"),
                    SWT.ICON_INFORMATION);
                shlTypeDocument.dispose();
              }
            } catch (SQLException exe) {

            }
          }
        });

    /* Load previously saved details here */
    try {
      configDb.retrieveType2Details(bean, this);
    } catch (SQLException exe) {
      exe.printStackTrace();
    }

    shlTypeDocument.open();
    shlTypeDocument.layout();
    while (!shlTypeDocument.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
  /**
   * @param composite
   * @return
   */
  private Composite createLiteralsConfigurationComposite(final Composite composite) {

    final ScrolledComposite scrolledComposite = new ScrolledComposite(composite, SWT.V_SCROLL);
    scrolledComposite.setLayout(new FillLayout());

    final Composite typeComposite = new Composite(scrolledComposite, SWT.NONE);
    typeComposite.setLayout(new GridLayout(1, false));
    DynamicAddRemoveLineComposite literalsComposite =
        new DynamicAddRemoveLineComposite(typeComposite, SWT.NONE) {
          @Override
          protected void lineRemoved(int i) {
            literals.remove(i);

            getShell().pack(true);
            getShell().layout(true, true);

            scrolledComposite.setMinSize(typeComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            scrolledComposite.setAlwaysShowScrollBars(false);
            scrolledComposite.setExpandHorizontal(true);
            scrolledComposite.setExpandVertical(true);
            scrolledComposite.setContent(typeComposite);

            getContainer().updateButtons();
          }

          @Override
          protected void lineAdded(int i) {

            getShell().pack(true);
            getShell().layout(true, true);

            scrolledComposite.setMinSize(typeComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            scrolledComposite.setAlwaysShowScrollBars(false);
            scrolledComposite.setExpandHorizontal(true);
            scrolledComposite.setExpandVertical(true);
            scrolledComposite.setContent(typeComposite);
            if (getContainer().getCurrentPage() != null) {
              getContainer().updateButtons();
            }
          }

          @Override
          protected Button createAddButton(Composite parent) {
            Button button = new Button(parent, SWT.FLAT);
            button.setText(Messages.addALiteral);
            return button;
          }

          @Override
          protected TabbedPropertySheetWidgetFactory getWidgetFactory() {
            return null;
          }

          @Override
          protected Composite getTopComposite() {
            return scrolledComposite;
          }

          @SuppressWarnings("restriction")
          @Override
          protected Control createLineComposite(Composite parent, Object object) {
            SimulationLiteral literal;
            if (object == null) {
              literal = SimulationFactory.eINSTANCE.createSimulationLiteral();
              literals.add(literal);
            } else {
              literal = (SimulationLiteral) object;
            }
            Composite composite = new Composite(parent, SWT.NONE);
            composite.setLayout(new GridLayout(4, false));
            Label literalLabel = new Label(composite, SWT.NONE);
            literalLabel.setText(Messages.dataNameLabel);
            Text literalText = new Text(composite, SWT.BORDER);
            literalText.setLayoutData(
                GridDataFactory.swtDefaults()
                    .align(SWT.FILL, SWT.CENTER)
                    .grab(false, false)
                    .hint(200, SWT.DEFAULT)
                    .create());
            // literalText.addModifyListener(updateButtonModifyListener) ;
            Label probaLabel = new Label(composite, SWT.NONE);
            probaLabel.setText(Messages.AddSimulationDataWizardPage_probability);
            Text probaText = new Text(composite, SWT.BORDER);
            probaText.setLayoutData(
                GridDataFactory.swtDefaults()
                    .align(SWT.FILL, SWT.CENTER)
                    .grab(false, false)
                    .hint(60, SWT.DEFAULT)
                    .create());
            //                ControlDecoration controlDecoration = new ControlDecoration(probaText,
            // SWT.LEFT|SWT.TOP);
            //                FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
            //                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
            //                controlDecoration.setImage(fieldDecoration.getImage());
            //                controlDecoration.setDescriptionText(Messages.mustBeAPercentage);
            context.bindValue(
                SWTObservables.observeText(literalText, SWT.Modify),
                EMFObservables.observeValue(
                    literal, SimulationPackage.Literals.SIMULATION_LITERAL__VALUE));
            UpdateValueStrategy targetToModel = new UpdateValueStrategy();
            targetToModel.setConverter(
                StringToNumberConverter.toDouble(BonitaNumberFormat.getPercentInstance(), true));
            targetToModel.setAfterGetValidator(
                new ProbabilityValidator(
                    new StringToDoubleValidator(
                        StringToNumberConverter.toDouble(
                            BonitaNumberFormat.getPercentInstance(), false))));
            Binding provider =
                context.bindValue(
                    SWTObservables.observeText(probaText, SWT.Modify),
                    EMFObservables.observeValue(
                        literal, SimulationPackage.Literals.SIMULATION_LITERAL__PROBABILITY),
                    targetToModel,
                    new UpdateValueStrategy()
                        .setConverter(
                            NumberToStringConverter.fromDouble(
                                BonitaNumberFormat.getPercentInstance(), false)));

            ControlDecorationSupport.create(provider, SWT.TOP | SWT.LEFT);
            probaText.addModifyListener(
                new ModifyListener() {

                  @Override
                  public void modifyText(ModifyEvent e) {
                    if (getContainer().getCurrentPage() != null) {
                      getContainer().updateButtons();
                    }
                  }
                });
            return composite;
          }
        };
    for (SimulationLiteral literal : literals) {
      literalsComposite.addLine(literal);
    }
    literalsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    scrolledComposite.setMinSize(typeComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    scrolledComposite.setAlwaysShowScrollBars(false);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setContent(typeComposite);
    return scrolledComposite;
  }
  /**
   * @param composite
   * @return
   */
  private Composite createNumberConfigurationComposite(final Composite composite) {

    final ScrolledComposite scrolledComposite = new ScrolledComposite(composite, SWT.V_SCROLL);
    scrolledComposite.setLayout(new FillLayout());
    final Composite typeComposite = new Composite(scrolledComposite, SWT.NONE);
    typeComposite.setLayout(new GridLayout(1, false));
    DynamicAddRemoveLineComposite literalsComposite =
        new DynamicAddRemoveLineComposite(typeComposite, SWT.NONE) {
          @Override
          protected void lineRemoved(int i) {
            ranges.remove(i);

            getShell().pack(true);
            getShell().layout(true, true);

            scrolledComposite.setMinSize(typeComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            scrolledComposite.setAlwaysShowScrollBars(false);
            scrolledComposite.setExpandHorizontal(true);
            scrolledComposite.setExpandVertical(true);
            scrolledComposite.setContent(typeComposite);
            if (getContainer().getCurrentPage() != null) {
              getContainer().updateButtons();
            }
          }

          @Override
          protected void lineAdded(int i) {
            getShell().pack(true);
            getShell().layout(true, true);

            scrolledComposite.setMinSize(typeComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            scrolledComposite.setAlwaysShowScrollBars(false);
            scrolledComposite.setExpandHorizontal(true);
            scrolledComposite.setExpandVertical(true);
            scrolledComposite.setContent(typeComposite);
            if (getContainer().getCurrentPage() != null) {
              getContainer().updateButtons();
            }
          }

          @Override
          protected Button createAddButton(Composite parent) {
            Button button = new Button(parent, SWT.FLAT);
            button.setText(Messages.addARange);
            return button;
          }

          @Override
          protected TabbedPropertySheetWidgetFactory getWidgetFactory() {
            return null;
          }

          @Override
          protected Composite getTopComposite() {
            return scrolledComposite;
          }

          @Override
          protected Control createLineComposite(Composite parent, Object object) {
            SimulationNumberRange range;
            if (object == null) {
              range = SimulationFactory.eINSTANCE.createSimulationNumberRange();
              ranges.add(range);
            } else {
              range = (SimulationNumberRange) object;
            }
            Composite composite = new Composite(parent, SWT.NONE);
            composite.setLayout(new GridLayout(6, false));
            // min
            Label minLabel = new Label(composite, SWT.NONE);
            minLabel.setText(Messages.AddSimulationDataWizardPage_min);
            Text minText = new Text(composite, SWT.BORDER);
            minText.setLayoutData(
                GridDataFactory.swtDefaults()
                    .align(SWT.FILL, SWT.CENTER)
                    .hint(100, SWT.DEFAULT)
                    .create());
            ControlDecoration minControlDecoration =
                new ControlDecoration(minText, SWT.LEFT | SWT.TOP);
            FieldDecoration fieldDecoration =
                FieldDecorationRegistry.getDefault()
                    .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
            minControlDecoration.setImage(fieldDecoration.getImage());
            minControlDecoration.setDescriptionText(Messages.mustBeANumber);
            // max
            Label maxLiteral = new Label(composite, SWT.NONE);
            maxLiteral.setText(Messages.AddSimulationDataWizardPage_max);
            Text maxText = new Text(composite, SWT.BORDER);
            maxText.setLayoutData(
                GridDataFactory.swtDefaults()
                    .align(SWT.FILL, SWT.CENTER)
                    .hint(100, SWT.DEFAULT)
                    .create());
            ControlDecoration maxControlDecoration =
                new ControlDecoration(maxText, SWT.LEFT | SWT.TOP);
            fieldDecoration =
                FieldDecorationRegistry.getDefault()
                    .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
            maxControlDecoration.setImage(fieldDecoration.getImage());
            maxControlDecoration.setDescriptionText(Messages.mustBeANumber);
            // proba
            Label probaLabel = new Label(composite, SWT.NONE);
            probaLabel.setText(Messages.AddSimulationDataWizardPage_probability);
            Text probaText = new Text(composite, SWT.BORDER);
            probaText.setLayoutData(
                GridDataFactory.swtDefaults()
                    .align(SWT.FILL, SWT.CENTER)
                    .hint(40, SWT.DEFAULT)
                    .create());
            //                ControlDecoration controlDecoration = new ControlDecoration(probaText,
            // SWT.LEFT|SWT.TOP);
            //                fieldDecoration = FieldDecorationRegistry.getDefault()
            //                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
            //                controlDecoration.setImage(fieldDecoration.getImage());
            //                controlDecoration.setDescriptionText(Messages.mustBeAPercentage);
            // repartitionType

            //				Label repartitionLabel = new Label(composite, SWT.NONE);
            //				repartitionLabel.setText(Messages.AddSimulationDataWizardPage_repartition);
            //				ComboViewer comboViewer = new ComboViewer(new Combo(composite, SWT.READ_ONLY));
            //				comboViewer.setContentProvider(ArrayContentProvider.getInstance());
            //				comboViewer.setLabelProvider(new LabelProvider(){
            //					@Override
            //					public String getText(Object element) {
            //						return ((RepartitionType)element).getName();
            //					}
            //				});
            //				comboViewer.setInput(RepartitionType.VALUES);

            context.bindValue(
                SWTObservables.observeText(minText, SWT.Modify),
                EMFObservables.observeValue(
                    range, SimulationPackage.Literals.SIMULATION_NUMBER_RANGE__MIN),
                new UpdateValueStrategy()
                    .setConverter(StringToNumberConverter.toLong(false))
                    .setAfterGetValidator(
                        new WrappingValidator(
                            minControlDecoration,
                            new StringToLongValidator(StringToNumberConverter.toLong(false)))),
                new UpdateValueStrategy().setConverter(NumberToStringConverter.fromLong(false)));
            context.bindValue(
                SWTObservables.observeText(maxText, SWT.Modify),
                EMFObservables.observeValue(
                    range, SimulationPackage.Literals.SIMULATION_NUMBER_RANGE__MAX),
                new UpdateValueStrategy()
                    .setConverter(StringToNumberConverter.toLong(false))
                    .setAfterGetValidator(
                        new WrappingValidator(
                            maxControlDecoration,
                            new StringToLongValidator(StringToNumberConverter.toLong(false)))),
                new UpdateValueStrategy().setConverter(NumberToStringConverter.fromLong(false)));
            UpdateValueStrategy targetToModel = new UpdateValueStrategy();
            targetToModel.setConverter(
                StringToNumberConverter.toDouble(BonitaNumberFormat.getPercentInstance(), true));
            targetToModel.setAfterGetValidator(
                new ProbabilityValidator(
                    new StringToDoubleValidator(
                        StringToNumberConverter.toDouble(
                            BonitaNumberFormat.getPercentInstance(), false))));
            Binding provider =
                context.bindValue(
                    SWTObservables.observeText(probaText, SWT.Modify),
                    EMFObservables.observeValue(
                        range, SimulationPackage.Literals.SIMULATION_NUMBER_RANGE__PROBABILITY),
                    targetToModel,
                    new UpdateValueStrategy()
                        .setConverter(
                            NumberToStringConverter.fromDouble(
                                BonitaNumberFormat.getPercentInstance(), false)));
            // context.bindValue(ViewersObservables.observeSingleSelection(comboViewer),
            // EMFObservables.observeValue(range,
            // SimulationPackage.Literals.SIMULATION_NUMBER_RANGE__REPARTITION_TYPE));

            //				minText.addModifyListener(updateButtonModifyListener);
            //				maxText.addModifyListener(updateButtonModifyListener) ;
            //				probaText.addModifyListener(updateButtonModifyListener) ;
            ControlDecorationSupport.create(provider, SWT.TOP | SWT.LEFT);

            return composite;
          }
        };
    for (SimulationNumberRange range : ranges) {
      literalsComposite.addLine(range);
    }
    literalsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    scrolledComposite.setMinSize(typeComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    scrolledComposite.setAlwaysShowScrollBars(false);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setContent(typeComposite);
    return scrolledComposite;
  }
Пример #29
0
  /** Creates the display area for this form */
  private void createDisplayArea() {
    // create the top level layout for the form
    GridLayout layout = new GridLayout();
    layout.marginHeight = MARGIN_HEIGHT;
    layout.marginWidth = MARGIN_WIDTH;
    layout.verticalSpacing = VERTICAL_SPACING;
    layout.horizontalSpacing = HORIZONTAL_SPACING;
    GridData data = new GridData(GridData.FILL_BOTH);
    setLayout(layout);
    setLayoutData(data);
    // set the background color to white
    Color white = getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
    setBackground(white);

    // add an alerts and actions section
    AlertsActionsSection alerts = new AlertsActionsSection(this, SWT.NONE, context);

    alerts.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // add a two column contianer for the form sections. The first
    // column will display the DeviceHierarchy section and the second
    // column will display the primary and secondary pattern sections.
    Composite formContainer = new Composite(this, SWT.NONE);
    GridLayout formLayout = new GridLayout(2, false);
    formLayout.marginWidth = 0;
    formLayout.marginHeight = 0;
    formLayout.horizontalSpacing = HORIZONTAL_SPACING;
    GridData formData = new GridData(GridData.FILL_BOTH);
    formContainer.setLayout(formLayout);
    formContainer.setLayoutData(formData);
    formContainer.setBackground(white);

    // add the hierarchy section to the formContainer
    deviceHierarchySection = new DeviceHierarchySection(formContainer, SWT.NONE, context);
    GridData hierarchyData = new GridData(GridData.FILL_VERTICAL);
    deviceHierarchySection.setLayoutData(hierarchyData);

    // add a scroll area for the patterns sections
    ScrolledComposite controlsScroller =
        new ScrolledComposite(formContainer, SWT.H_SCROLL | SWT.V_SCROLL);
    controlsScroller.setLayout(new FillLayout());
    controlsScroller.setLayoutData(new GridData(GridData.FILL_BOTH));
    controlsScroller.setExpandHorizontal(true);
    controlsScroller.setExpandVertical(true);
    controlsScroller.setAlwaysShowScrollBars(false);
    controlsScroller.setBackground(white);

    // add the container for the patterns sections
    Composite patternContainer = new Composite(controlsScroller, SWT.NONE);
    GridLayout patternLayout = new GridLayout();
    patternLayout.marginHeight = 0;
    patternLayout.marginWidth = 0;
    patternLayout.verticalSpacing = VERTICAL_SPACING;
    GridData patternData = new GridData(GridData.FILL_BOTH);
    patternContainer.setLayout(patternLayout);
    patternContainer.setLayoutData(patternData);
    patternContainer.setBackground(white);

    // Add the primary patterns section
    PrimaryPatternsSection primaryPatterns =
        new PrimaryPatternsSection(patternContainer, SWT.NONE, context);
    primaryPatterns.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Add the secondary patterns section
    SecondaryPatternsSection secondaryPatterns =
        new SecondaryPatternsSection(patternContainer, SWT.NONE, context);
    secondaryPatterns.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    createRestoreMechanism(patternContainer);

    TACPatternsSection TACPatterns = new TACPatternsSection(patternContainer, SWT.NONE, context);
    TACPatterns.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    patternContainer.setSize(patternContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    patternContainer.layout();
    controlsScroller.setMinSize(patternContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    controlsScroller.setContent(patternContainer);

    layout();
  }
Пример #30
0
  private void build() {
    if (legend_panel == null || legend_panel.isDisposed()) {

      return;
    }

    for (Control c : legend_panel.getChildren()) {

      c.dispose();
    }

    List<String> configs = new ArrayList<String>();
    List<String> texts = new ArrayList<String>();
    List<Color> colors = new ArrayList<Color>();

    TagManager tm = TagManagerFactory.getTagManager();

    List<TagType> tag_types = tm.getTagTypes();

    tag_types = TagUIUtils.sortTagTypes(tag_types);

    List<TagFeatureRateLimit> visible_tags = new ArrayList<TagFeatureRateLimit>();

    for (TagType tag_type : tag_types) {

      if (tag_type.hasTagTypeFeature(TagFeature.TF_RATE_LIMIT)) {

        List<Tag> tags = tag_type.getTags();

        tags = TagUIUtils.sortTags(tags);

        for (Tag tag : tags) {

          if (!tag.isVisible()) {

            continue;
          }

          TagFeatureRateLimit rl = (TagFeatureRateLimit) tag;

          if (!rl.supportsTagRates()) {

            continue;
          }

          String config_key = "TagStatsView.cc." + tag_type.getTagType() + "." + tag.getTagID();

          configs.add(config_key);

          texts.add(tag.getTagName(true));

          Color tt_colour;

          int[] rgb = tag.getColor();

          if (rgb == null) {

            tt_colour = Colors.blues[Colors.BLUES_DARKEST];

          } else {

            tt_colour = ColorCache.getColor(legend_panel.getDisplay(), rgb);
          }

          colors.add(tt_colour);

          visible_tags.add(rl);
        }
      }
    }

    final Color[] color_array = colors.toArray(new Color[colors.size()]);
    final String[] text_array = texts.toArray(new String[texts.size()]);

    final List<ValueSourceImpl> sources = new ArrayList<ValueSourceImpl>();

    List<int[]> history_records = new ArrayList<int[]>();
    int history_record_max = 0;

    for (int i = 0; i < visible_tags.size(); i++) {

      final TagFeatureRateLimit tag = visible_tags.get(i);

      tag.setRecentHistoryRetention(true);

      int[][] history = tag.getRecentHistory();

      history_record_max = Math.max(history[0].length, history_record_max);

      history_records.add(history[0]);
      history_records.add(history[1]);

      sources.add(new ValueSourceImpl(tag, text_array[i], i, color_array, true));
      sources.add(new ValueSourceImpl(tag, text_array[i], i, color_array, false));
    }
    ;

    ValueFormater formatter =
        new ValueFormater() {
          public String format(int value) {
            return DisplayFormatters.formatByteCountToKiBEtcPerSec(value);
          }
        };

    if (mpg != null) {

      mpg.dispose();
    }

    final MultiPlotGraphic f_mpg =
        mpg =
            MultiPlotGraphic.getInstance(
                sources.toArray(new ValueSource[sources.size()]), formatter);

    int[][] history = new int[history_records.size()][];

    for (int i = 0; i < history.length; i++) {
      int[] hist = history_records.get(i);
      int hist_len = hist.length;

      if (hist_len == history_record_max) {
        history[i] = hist;
      } else {
        int[] temp = new int[history_record_max];
        System.arraycopy(hist, 0, temp, history_record_max - hist_len, hist_len);
        history[i] = temp;
      }
    }

    mpg.reset(history);

    GridData gridData;

    if (color_array.length > 0) {

      gridData = new GridData(GridData.FILL_VERTICAL);
      gridData.verticalAlignment = SWT.CENTER;

      Legend.createLegendComposite(
          legend_panel,
          color_array,
          configs.toArray(new String[configs.size()]),
          text_array,
          gridData,
          false,
          new Legend.LegendListener() {
            private int hover_index = -1;

            public void hoverChange(boolean entry, int index) {
              if (hover_index != -1) {

                for (int i = hover_index * 2; i < hover_index * 2 + 2; i++) {

                  sources.get(i).setHover(false);
                }
              }

              if (entry) {

                hover_index = index;

                for (int i = hover_index * 2; i < hover_index * 2 + 2; i++) {

                  sources.get(i).setHover(true);
                }
              }

              f_mpg.refresh(true);
            }

            public void visibilityChange(boolean visible, int index) {
              for (int i = index * 2; i < index * 2 + 2; i++) {

                sources.get(i).setVisible(visible);
              }

              f_mpg.refresh(true);
            }
          });
    } else {

      gridData = new GridData(GridData.FILL_HORIZONTAL);
      gridData.verticalAlignment = SWT.TOP;

      Label lab = new Label(legend_panel, SWT.NULL);
      lab.setText(MessageText.getString("tag.stats.none.defined"));

      lab.setLayoutData(gridData);
    }

    legend_panel_sc.setMinSize(legend_panel.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    // speed

    for (Control c : speed_panel.getChildren()) {

      c.dispose();
    }

    Canvas speed_canvas = new Canvas(speed_panel, SWT.NO_BACKGROUND);
    gridData = new GridData(GridData.FILL_BOTH);
    speed_canvas.setLayoutData(gridData);

    mpg.initialize(speed_canvas, true);

    panel.layout(true, true);
  }