예제 #1
0
  protected void addCheckboxes() {
    for (T item : itemList) {
      if (isItemVisible(item)) {
        boolean selected = preSelectedElements.contains(item);
        if (LOG.isDebugEnabled()) {
          LOG.debug(item.toString() + " is visible, select state is: " + selected);
        }
        Button checkbox = new Button(innerComposite, SWT.CHECK);
        checkbox.setText(getLabel(item));
        checkbox.setData(item);
        checkbox.addSelectionListener(organizationListener);
        if (selected) {
          checkbox.setSelection(true);
          selectedElement = item;
          selectedElementSet.add(item);
        }
        if (itemList.size() == 1) {
          checkbox.setSelection(true);
          selectedElement = item;
          selectedElementSet.add(item);
        }
        checkboxMap.put(item, checkbox);
      }
    }

    scrolledComposite.setVisible(true);
    Point size = innerComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    size.y += itemList.size() * 2;
    innerComposite.setSize(size);
    group.layout();
  }
예제 #2
0
파일: View.java 프로젝트: harinis/kosha
  @Override
  public void createPartControl(Composite parent) {
    {
      GridLayout parentLayout = new GridLayout();
      parentLayout.makeColumnsEqualWidth = true;
      parent.setLayout(parentLayout);
      parent.setSize(557, 321);
      {
        composite1 = new Composite(parent, SWT.NONE);
        GridLayout composite1Layout = new GridLayout();
        composite1Layout.makeColumnsEqualWidth = true;
        GridData composite1LData = new GridData();
        composite1LData.grabExcessHorizontalSpace = true;
        composite1LData.horizontalAlignment = GridData.FILL;
        composite1LData.verticalAlignment = GridData.FILL;
        composite1.setLayoutData(composite1LData);
        composite1.setLayout(composite1Layout);
        {
          statusLbl = new Label(composite1, SWT.NONE);
          GridData statusLblLData = new GridData();
          statusLblLData.grabExcessHorizontalSpace = true;
          statusLblLData.horizontalAlignment = GridData.FILL;
          statusLbl.setLayoutData(statusLblLData);
          statusLbl.setText("sdfsdfsdf");
        }
      }
      {
        group1 = new Group(parent, SWT.NONE);
        GridLayout group1Layout = new GridLayout();
        group1Layout.makeColumnsEqualWidth = true;
        group1.setLayout(group1Layout);
        GridData group1LData = new GridData();
        group1LData.verticalAlignment = GridData.FILL;
        group1LData.horizontalAlignment = GridData.FILL;
        group1LData.grabExcessHorizontalSpace = true;
        group1LData.grabExcessVerticalSpace = true;
        group1.setLayoutData(group1LData);
        group1.setText("Notes");
        {
          notesTxt = new Text(group1, SWT.MULTI | SWT.WRAP | SWT.BORDER);
          GridData text1LData = new GridData();
          text1LData.grabExcessHorizontalSpace = true;
          text1LData.horizontalAlignment = GridData.FILL;
          text1LData.verticalAlignment = GridData.FILL;
          text1LData.grabExcessVerticalSpace = true;
          notesTxt.setLayoutData(text1LData);
        }
      }
      {
        archiveBtn = new Button(parent, SWT.PUSH | SWT.CENTER);
        GridData button1LData = new GridData();
        button1LData.horizontalAlignment = GridData.FILL;
        button1LData.grabExcessHorizontalSpace = true;
        archiveBtn.setLayoutData(button1LData);
        archiveBtn.setText("Archive");
      }
    }

    new KController(this);
  }
예제 #3
0
 @Override
 protected Control createDialogArea(Composite parent) {
   Composite composite = (Composite) super.createDialogArea(parent);
   createFileNameFields(composite);
   createPropsFields(composite);
   setData();
   composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
   return composite;
 }
  protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    panel = new SbbClassesPanel(composite, 0);
    panel.createSbbLocalObject(createLocalInterface);
    panel.createActivityContextInterface(createActivityContextInterface);
    // ammendonca: See http://code.google.com/p/restcomm/issues/detail?id=2548
    // panel.disableSbbLocalObject(true);
    composite.setSize(640, 480);
    return composite;
  }
 @Override
 protected Control createContents(Composite parent) {
   ((Shell) parent).setText(this.getClass().getSimpleName());
   parent.setSize(800, 400);
   parent.setLayout(new GridLayout());
   Composite mainPanel = new Composite(parent, SWT.NONE);
   mainPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
   mainPanel.setLayout(new GridLayout());
   this.buildTreePanel(mainPanel);
   this.buildControlPanel(mainPanel);
   return mainPanel;
 }
예제 #6
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;
  }
예제 #7
0
  private void fillBuddies(Composite composite) {

    List buddies = getBuddies();

    showNoBuddiesPanel(buddies.size() == 0);

    for (Iterator iterator = buddies.iterator(); iterator.hasNext(); ) {
      VuzeBuddySWT vuzeBuddy = (VuzeBuddySWT) iterator.next();
      createBuddyControls(composite, vuzeBuddy);
    }
    composite.layout();
    Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    composite.setSize(size);
  }
 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);
     }
   }
 }
  /**
   * 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;
  }
예제 #10
0
  /** Performs layouting. */
  private void layout() {

    // Disable redrawing
    toolbar.setRedraw(false);

    // Adjust size of items and composite
    Rectangle bounds = toolbar.getBounds();
    int remaining = toolbar.getBounds().width;
    for (final ToolItem item : toolitems) {
      remaining -= item.getBounds().width;
    }
    remaining -= OFFSET;
    infoComposite.setSize(remaining, bounds.height);
    infoItem.setWidth(remaining);
    int locationY = (infoComposite.getBounds().height - labelSelected.getBounds().height) / 2;

    // Layout label
    int locationX = remaining - labelApplied.getSize().x;
    labelApplied.setLocation(locationX, locationY);
    if (locationX < 0) labelApplied.setVisible(false);
    else labelApplied.setVisible(true);

    // Layout label
    locationX -= labelSelected.getSize().x + OFFSET;
    labelSelected.setLocation(locationX, locationY);
    if (locationX < 0) labelSelected.setVisible(false);
    else labelSelected.setVisible(true);

    // Layout label
    locationX -= labelTransformations.getSize().x + OFFSET;
    labelTransformations.setLocation(locationX, locationY);
    if (locationX < 0) labelTransformations.setVisible(false);
    else labelTransformations.setVisible(true);

    // Layout label
    locationX -= labelAttribute.getSize().x + OFFSET;
    labelAttribute.setLocation(locationX, locationY);
    if (locationX < 0) labelAttribute.setVisible(false);
    else labelAttribute.setVisible(true);

    // Redraw
    toolbar.setRedraw(true);
  }
  public void createControl(Composite parent) {
    LogUtil.logInfo("creating control"); // $NON-NLS-1$
    Composite pageComposite = new Composite(parent, SWT.NULL);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    gridLayout.makeColumnsEqualWidth = true;
    pageComposite.setLayout(gridLayout);
    GridData gridData = new GridData();
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    pageComposite.setLayoutData(gridData);
    createParametersGroup(pageComposite);

    defaultRadioButton.setSelection(true);
    registerListeners();
    pageComposite.setSize(new Point(300, 200));
    pageComposite.setLayout(new GridLayout());
    setControl(pageComposite);
    setPageComplete(false);
  }
  @Override
  public void createControl(Composite parent) {
    creatingControl = true;
    // Create page
    final Composite mainPanel = new Composite(parent, SWT.NONE);

    mainPanel.setLayout(new GridLayout(1, false));
    mainPanel.setLayoutData(
        new GridData()); // GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
    mainPanel.setSize(mainPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    setControl(mainPanel);

    // Create Bottom Composite
    Composite upperPanel =
        WidgetFactory.createPanel(mainPanel, SWT.NONE, GridData.FILL_HORIZONTAL, 2, 2);
    upperPanel.setLayout(new GridLayout(2, false));

    setMessage(INITIAL_MESSAGE);

    Label selectedFileLabel = new Label(upperPanel, SWT.NONE);
    selectedFileLabel.setText(getString("selectedFile")); // $NON-NLS-1$

    selectedFileText = new Text(upperPanel, SWT.BORDER); // , SWT.BORDER | SWT.SINGLE);
    selectedFileText.setBackground(
        Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
    selectedFileText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
    selectedFileText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    selectedFileText.setEditable(false);

    createFilePreviewOptionsGroup(mainPanel);

    createColumnOptionsRadioGroup(mainPanel);

    createFileContentsGroup(mainPanel);

    creatingControl = false;

    setPageComplete(false);
  }
  /** Run the test */
  @Override
  protected void runTest() throws CoreException, WorkbenchException {

    tagIfNecessary(tagString, Dimension.ELAPSED_PROCESS);

    widgetFactory.init();
    final Composite widget = widgetFactory.getControl();
    Rectangle initialBounds = widget.getBounds();
    final Point maxSize = widgetFactory.getMaxSize();

    waitForBackgroundJobs();
    processEvents();
    for (int j = 0; j < 50; j++) {

      startMeasuring();
      for (int i = 0; i < 2; i++) {

        for (int xIteration = 0; xIteration < xIterations; xIteration += 5) {

          for (int yIteration = 0; yIteration < yIterations; yIteration++) {
            // Avoid giving the same x value twice in a row in order
            // to make it hard to cache
            int xSize = maxSize.x * ((xIteration + yIteration) % xIterations) / xIterations;
            int ySize = maxSize.y * yIteration / yIterations;

            widget.setSize(xSize, ySize);

            processEvents();
          }
        }
      }
      stopMeasuring();
    }
    commitMeasurements();
    assertPerformance();

    widget.setBounds(initialBounds);
    widgetFactory.done();
  }
  /**
   * 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;
  }
예제 #15
0
  private void initGUI() {
    try {

      this.setOrientation(SWT.VERTICAL);

      this.setBackground(MainGui.cHART_DARKER);
      Color innerBgColor = MainGui.cHART_LIGHT;

      this.addDisposeListener(
          new DisposeListener() {

            public void widgetDisposed(DisposeEvent evt) {
              rootShellClosed(evt);
            }
          });

      this.addListener(
          SWT.Hide,
          new Listener() {

            @Override
            public void handleEvent(Event event) {
              ChartsComposite.this.shutDownDisplay();
            }
          });

      {
        try {
          // Set cross-platform Java L&F (also called "Metal")
          UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (UnsupportedLookAndFeelException e) {
          LOGGER.error(e);
        } catch (ClassNotFoundException e) {
          LOGGER.error(e);
        } catch (InstantiationException e) {
          LOGGER.error(e);
        } catch (IllegalAccessException e) {
          LOGGER.error(e);
        }

        mainChartComposite = new Composite(this, SWT.EMBEDDED | SWT.NO_BACKGROUND);
        final Frame chartFrame = SWT_AWT.new_Frame(mainChartComposite);
        final Panel rootHeavyPanel = new Panel();
        rootHeavyPanel.setLayout(new BorderLayout());
        chartFrame.add(rootHeavyPanel);

        mainChartWraper =
            new ChartMain(ChartsComposite.DEFAULT_START_DATE, JFreeChartTimePeriod.DAY);
        mainChartPanel =
            new ChartPanel(
                mainChartWraper.initChart(stripedCloseFunction), true, true, true, false, true) {
              private static final long serialVersionUID = 1L;

              @Override
              public void restoreAutoBounds() {
                // Do nothing (disable mouse left drag zoom)
              }
            };
        mainChartPanel.setMouseZoomable(false, false);
        mainChartPanel.setMinimumDrawWidth(0);
        mainChartPanel.setMinimumDrawHeight(0);
        mainChartPanel.setMaximumDrawWidth(Display.getCurrent().getClientArea().width);
        mainChartPanel.setMaximumDrawHeight(Display.getCurrent().getClientArea().height);

        mainChartPanel.getPopupMenu().addSeparator();
        JMenuItem deleteVLines = new JMenuItem("Remove vertical lines");
        deleteVLines.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                chartDisplayStrategy.removeVLines();
              }
            });
        mainChartPanel.getPopupMenu().add(deleteVLines);
        JMenuItem deleteHLines = new JMenuItem("Remove horizontal lines");
        deleteHLines.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                chartDisplayStrategy.removeHLines();
              }
            });
        mainChartPanel.getPopupMenu().add(deleteHLines);

        mainChartPanel.getPopupMenu().addSeparator();
        JMenuItem lookAndFeelInfoItem = new JMenuItem("Look and feel Info");
        lookAndFeelInfoItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                LOGGER.info(UIManager.getLookAndFeel());
              }
            });
        mainChartPanel.getPopupMenu().add(lookAndFeelInfoItem);

        mainChartPanel.addMouseListener(
            new ClickListener() {

              @Override
              public void singleClick(final MouseEvent event) {

                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            Boolean isSlidingArea =
                                getMainChartWraper()
                                    .isSlidingArea(
                                        mainChartComposite.getSize().y, event.getPoint().y);
                            if (isSlidingArea) return;

                            int button = event.getButton();
                            if (button == MouseEvent.BUTTON1) {
                              Point2D clickPoint =
                                  mainChartPanel.translateScreenToJava2D(event.getPoint());
                              Rectangle2D plotArea = mainChartPanel.getScreenDataArea();

                              if (plotArea.getMaxY() > clickPoint.getY()
                                  && clickPoint.getY() > plotArea.getY()
                                  && plotArea.getMaxX() > clickPoint.getX()
                                  && clickPoint.getX() > plotArea.getX()) {
                                chartDisplayStrategy.addVLineAt(clickPoint, plotArea);
                              }
                            }
                          }
                        });
              }

              @Override
              public void doubleClick(final MouseEvent event) {

                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            Boolean isSlidingArea =
                                getMainChartWraper()
                                    .isSlidingArea(
                                        mainChartComposite.getSize().y, event.getPoint().y);
                            if (isSlidingArea) return;

                            int button = event.getButton();
                            if (button == MouseEvent.BUTTON1) {
                              Point2D clickPoint = getPointCoordinates(event.getPoint());
                              Rectangle2D plotArea = mainChartPanel.getScreenDataArea();

                              if (plotArea.getMaxY() > clickPoint.getY()
                                  && clickPoint.getY() > plotArea.getY()
                                  && plotArea.getMaxX() > clickPoint.getX()
                                  && clickPoint.getX() > plotArea.getX()) {
                                chartDisplayStrategy.removeVLineAt(clickPoint, plotArea);
                                chartDisplayStrategy.removeHLineAt(clickPoint, plotArea);
                              }
                            }
                          }
                        });
              }
            });

        // Slider
        chartPanelFocusGain = false;
        mainChartPanel.addMouseListener(
            new MouseAdapter() {

              @Override
              public void mouseEntered(MouseEvent e) {
                chartPanelFocusGain = true;
              }

              @Override
              public void mouseExited(MouseEvent e) {
                chartPanelFocusGain = false;
              }

              @Override
              public void mousePressed(final MouseEvent e) {
                panelClickPosition = e.getPoint();
                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            Boolean isSlidingArea =
                                getMainChartWraper()
                                    .isSlidingArea(mainChartComposite.getSize().y, e.getPoint().y);
                            if (isSlidingArea) {
                              isInPanelChartSlider = true;
                            } else {
                              isInPanelChartSlider = false;
                            }
                          }
                        });
              }

              @Override
              public void mouseReleased(final MouseEvent e) {
                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            if (isInPanelChartSlider != null
                                && isInPanelChartSlider
                                && panelClickPosition != null) {
                              int indicChartSlideIncrement =
                                  (int)
                                      ((((double) panelClickPosition.y - e.getPoint().y)
                                              / (double) mainChartComposite.getSize().y)
                                          * 100);
                              chartDisplayStrategy.slideChart(indicChartSlideIncrement);
                            }
                            isInPanelChartSlider = false;
                          }
                        });
              }
            });

        // focus bizz (useful?)
        mainChartPanel.addMouseMotionListener(
            new MouseMotionListener() {

              @Override
              public void mouseMoved(final MouseEvent e) {

                // Sliding
                if (!closeRequested) {
                  Display.getDefault()
                      .asyncExec(
                          new Runnable() {

                            @Override
                            public void run() {

                              if (!closeRequested) {
                                try {
                                  Cursor cursor = ChartsComposite.this.getCursor();
                                  if (cursor == null
                                      || (!cursor.equals(CursorFactory.getCursor(SWT.CURSOR_WAIT))
                                          && !cursor.equals(
                                              CursorFactory.getCursor(SWT.CURSOR_APPSTARTING)))) {
                                    Boolean isSlidingArea =
                                        getMainChartWraper()
                                            .isSlidingArea(
                                                mainChartComposite.getSize().y, e.getPoint().y);
                                    if (isSlidingArea) {
                                      ChartsComposite.this.setCursor(
                                          CursorFactory.getCursor(SWT.CURSOR_SIZENS));
                                    } else {
                                      ChartsComposite.this.setCursor(
                                          CursorFactory.getCursor(SWT.CURSOR_ARROW));
                                    }
                                  }

                                } catch (Throwable e) {
                                  try {
                                    ChartsComposite.this.setCursor(
                                        CursorFactory.getCursor(SWT.CURSOR_ARROW));
                                  } catch (Throwable e1) {
                                    LOGGER.warn(e1, e1);
                                  }
                                  LOGGER.warn(e, e);
                                }
                              }
                            }
                          });
                }

                // Gain focus mgt
                if (!closeRequested) {
                  Display.getDefault()
                      .asyncExec(
                          new Runnable() {
                            public void run() {
                              try {
                                if (!closeRequested) {
                                  if (!mainChartComposite.isDisposed()
                                      && !mainChartComposite.isFocusControl()) {
                                    int cpt = 0;
                                    while (chartPanelFocusGain && cpt < 200) {
                                      Thread.sleep(10);
                                      cpt++;
                                    }
                                    if (chartPanelFocusGain && !mainChartComposite.isDisposed()) {
                                      mainChartComposite.forceFocus();
                                    }
                                  }
                                }
                              } catch (Throwable e) {
                                LOGGER.warn(e, e);
                              }
                            }
                          });
                }
              }

              @Override
              public void mouseDragged(MouseEvent e) {
                // Nothing
              }
            });

        mainChartComposite.addKeyListener(
            new org.eclipse.swt.events.KeyListener() {

              @Override
              public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
                if (((e.stateMask & SWT.CTRL) == SWT.CTRL)
                    && ((e.stateMask & SWT.ALT) == SWT.ALT)
                    && (e.keyCode == 'p')) {
                  try {
                    chartDisplayStrategy.exportBarChartPng();
                  } catch (InvalidParameterException exception) {
                    chartDisplayStrategy.showPopupDialog(exception.getMessage(), "Ok", null, null);
                  }
                }
                if (e.keyCode == SWT.ARROW_UP) {
                  chartDisplayStrategy.slideChart(+1);
                }
                if (e.keyCode == SWT.ARROW_DOWN) {
                  chartDisplayStrategy.slideChart(-1);
                }
              }

              @Override
              public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
                //
              }
            });

        mainChartComposite.addMouseTrackListener(
            new MouseTrackListener() {

              @Override
              public void mouseHover(org.eclipse.swt.events.MouseEvent e) {}

              @Override
              public void mouseExit(org.eclipse.swt.events.MouseEvent e) {}

              @Override
              public void mouseEnter(org.eclipse.swt.events.MouseEvent e) {
                mainChartPanel.requestFocusInWindow();
              }
            });

        rootHeavyPanel.add(mainChartPanel);
        chartFrame.pack();
        chartFrame.setVisible(true);
      }
      {
        chartBoutonsGroup = new Group(this, SWT.NONE);
        chartBoutonsGroup.setBackground(innerBgColor);
        GridLayout portfolioBoutonsGroupLayout = new GridLayout();
        portfolioBoutonsGroupLayout.numColumns = 1;
        portfolioBoutonsGroupLayout.verticalSpacing = 0;
        portfolioBoutonsGroupLayout.marginHeight = 0;
        chartBoutonsGroup.setLayout(portfolioBoutonsGroupLayout);
        GridData portfolioInfosGroupData = new GridData(GridData.FILL_HORIZONTAL);
        chartBoutonsGroup.setLayoutData(portfolioInfosGroupData);

        chartBoutonsGroup.setText("Portfolios charting : ");
        chartBoutonsGroup.setFont(MainGui.DEFAULTFONT);
        chartBoutonsGroup.setBackground(innerBgColor);

        {
          popusGroup = new Group(chartBoutonsGroup, SWT.NONE);
          GridData popusGroupData = new GridData(SWT.FILL, SWT.FILL, true, false);
          popusGroup.setLayoutData(popusGroupData);
          popusGroup.setBackground(innerBgColor);
          RowLayout popusGroupL = new RowLayout(SWT.HORIZONTAL);
          popusGroupL.justify = true;
          popusGroupL.fill = true;
          popusGroupL.wrap = false;
          popusGroupL.marginHeight = 0;
          popusGroup.setLayout(popusGroupL);
        }

        // Sliding
        {
          slidingGroup = new Group(chartBoutonsGroup, SWT.NONE);
          GridData slidingGroupData = new GridData(SWT.FILL, SWT.FILL, true, false);
          slidingGroup.setLayoutData(slidingGroupData);
          slidingGroup.setBackground(innerBgColor);
          GridLayout slidingGroupL = new GridLayout();
          slidingGroupL.numColumns = 5;
          slidingGroupL.marginHeight = 0;
          slidingGroupL.verticalSpacing = 0;
          slidingGroup.setLayout(slidingGroupL);
          /// start
          {
            startDateLabel = new Label(slidingGroup, SWT.NONE);
            GridData startOneYearBackData = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
            startOneYearBackData.horizontalSpan = 2;
            startDateLabel.setLayoutData(startOneYearBackData);
            startDateLabel.setText(
                DateFormat.getDateInstance(DateFormat.MEDIUM).format(slidingStartDate) + "");
            startDateLabel.setBackground(innerBgColor);
            startDateLabel.setFont(MainGui.DEFAULTFONT);
          }
          /// sliding sliders
          Composite slidingSliderGroup = new Composite(slidingGroup, SWT.NONE);
          slidingSliderGroup.setSize(1000, SWT.DEFAULT);
          GridData slidersGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
          slidersGridData.verticalSpan = 2;
          slidingSliderGroup.setLayoutData(slidersGridData);
          slidingSliderGroup.setBackground(innerBgColor);
          slidingSliderGroup.setForeground(innerBgColor);
          FillLayout slidingSliderGroupL = new FillLayout(SWT.VERTICAL);
          slidingSliderGroup.setLayout(slidingSliderGroupL);
          {
            sliderStartDate = new Slider(slidingSliderGroup, SWT.HORIZONTAL);
            sliderStartDate.setThumb(1);
            sliderStartDate.setMaximum(100);
            sliderStartDate.addListener(
                SWT.MouseExit,
                new Listener() {

                  public void handleEvent(Event arg0) {
                    sliderChangesApply();
                  }
                });
          }
          {
            sliderEndDate = new Slider(slidingSliderGroup, SWT.HORIZONTAL);
            sliderEndDate.setThumb(1);
            sliderEndDate.setMinimum(0);
            sliderEndDate.setSelection(100);
            sliderEndDate.addListener(
                SWT.MouseExit,
                new Listener() {

                  public void handleEvent(Event arg0) {
                    sliderChangesApply();
                  }
                });
          }
          // end
          {
            endDateLabel = new Label(slidingGroup, SWT.NONE);
            GridData endOneYearBackData = new GridData(SWT.END, SWT.FILL, false, false);
            endOneYearBackData.horizontalSpan = 2;
            endDateLabel.setLayoutData(endOneYearBackData);
            endDateLabel.setText(
                DateFormat.getDateInstance(DateFormat.MEDIUM).format(slidingEndDate));
            endDateLabel.setBackground(innerBgColor);
            endDateLabel.setFont(MainGui.DEFAULTFONT);
          }

          // but start
          {
            Button startOneYearBack = new Button(slidingGroup, SWT.ARROW | SWT.LEFT);
            GridData startOneYearBackData = new GridData(SWT.END, SWT.FILL, false, true);
            startOneYearBack.setLayoutData(startOneYearBackData);
            startOneYearBack.setToolTipText("Move start date one year backward.");
            startOneYearBack.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingStartDate);
                    calendar.add(Calendar.YEAR, -1);
                    firstStartDate = calendar.getTime();
                    sliderStartDate.setSelection(0);
                    startSliderUpdateConditional(
                        sliderStartDate, startDateLabel, sliderEndDate, endDateLabel);
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            startOneYearBack.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }

          {
            Button startOneYearForward = new Button(slidingGroup, SWT.ARROW | SWT.RIGHT);
            GridData startOneYearBackData = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
            startOneYearForward.setLayoutData(startOneYearBackData);
            startOneYearForward.setToolTipText("Move start date one year forward.");
            startOneYearForward.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingStartDate);
                    calendar.add(Calendar.YEAR, +1);
                    if (calendar.getTime().before(slidingEndDate)) {
                      firstStartDate = calendar.getTime();
                      sliderStartDate.setSelection(0);
                      startSliderUpdateConditional(
                          sliderStartDate, startDateLabel, sliderEndDate, endDateLabel);
                    } else {
                      chartDisplayStrategy.showPopupDialog(
                          "To move the start date further forward, you will need to move the end date first.",
                          "Ok",
                          null,
                          null);
                    }
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            startOneYearForward.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }
          /// but end

          {
            Button endOneYearBack = new Button(slidingGroup, SWT.ARROW | SWT.LEFT);
            GridData endOneYearBackData = new GridData(SWT.END, SWT.FILL, false, true);
            endOneYearBack.setLayoutData(endOneYearBackData);
            endOneYearBack.setToolTipText("Move end date one year backward.");
            endOneYearBack.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingEndDate);
                    calendar.add(Calendar.YEAR, -1);
                    if (calendar.getTime().after(slidingStartDate)) {
                      lastEndDate = calendar.getTime();
                      sliderEndDate.setSelection(100);
                      endSliderUpdateConditional(
                          sliderEndDate, endDateLabel, sliderStartDate, startDateLabel);
                    } else {
                      chartDisplayStrategy.showPopupDialog(
                          "To move the end date further backward, you will need to move the start date first.",
                          "Ok",
                          null,
                          null);
                    }
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            endOneYearBack.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }
          {
            Button endOneYearForward = new Button(slidingGroup, SWT.ARROW | SWT.RIGHT);
            GridData endOneYearBackData = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
            endOneYearForward.setLayoutData(endOneYearBackData);
            endOneYearForward.setToolTipText("Move end date one year forward.");
            endOneYearForward.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingEndDate);
                    calendar.add(Calendar.YEAR, +1);
                    Date newDate = EventSignalConfig.getNewDate();
                    if (calendar.getTime().after(newDate)) {
                      calendar.setTime(newDate);
                    }
                    lastEndDate = calendar.getTime();
                    sliderEndDate.setSelection(100);
                    endSliderUpdateConditional(
                        sliderEndDate, endDateLabel, sliderStartDate, startDateLabel);
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            endOneYearForward.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }

          sliderStartDate.addListener(
              SWT.Selection,
              new Listener() {
                public void handleEvent(Event event) {
                  startSliderUpdateConditional(
                      sliderStartDate, startDateLabel, sliderEndDate, endDateLabel);
                }
              });

          sliderEndDate.addListener(
              SWT.Selection,
              new Listener() {

                public void handleEvent(Event event) {
                  endSliderUpdateConditional(
                      sliderEndDate, endDateLabel, sliderStartDate, startDateLabel);
                }
              });

          slidingGroup.layout();
        }
      }

      this.layout();
      this.pack();

    } catch (Exception e) {
      LOGGER.error("", e);
    }
  }
예제 #16
0
  /**
   * 建立Page外觀View
   *
   * @param composite
   */
  private void buildPage(Composite composite) {
    selectComposite = new Composite(composite, SWT.NONE);

    //		addLibBtn = new Button(composite, SWT.PUSH);
    //		addLibBtn.setText("Add Tag Library");
    //		addLibBtn.setLocation(getBoundsPoint(detAllBtn).x + 20, 10);
    //		addLibBtn.pack();
    //		addLibBtn.addSelectionListener(new SelectionAdapter() {
    //			@Override
    //			public void widgetSelected(SelectionEvent e) {
    //				ISelectionService selectionService =
    // Workbench.getInstance().getActiveWorkbenchWindow().getSelectionService();
    //				ISelection selection = selectionService.getSelection();
    //				IProject project = null;
    //				if(selection instanceof IStructuredSelection) {
    //				    Object element = ((IStructuredSelection)selection).getFirstElement();
    //				    if (element instanceof IResource) {
    //				        project= ((IResource)element).getProject();
    //				    } else if (element instanceof PackageFragmentRootContainer) {
    //				        IJavaProject jProject = ((PackageFragmentRootContainer)element).getJavaProject();
    //				        project = jProject.getProject();
    //				    } else if (element instanceof IJavaElement) {
    //				        IJavaProject jProject= ((IJavaElement)element).getJavaProject();
    //				        project = jProject.getProject();
    //				    }
    //				} else if (selection instanceof ITextSelection) {
    //				    System.out.println("Fail");
    //				    return;
    //				}
    //				File lib = new File(project.getLocation().toFile().getPath() + "/lib");
    //				if(!lib.exists())
    //					lib.mkdir();
    //				File jar = new File(project.getLocation().toFile().getPath() + "/lib/Tag.jar");
    //				JarFileMaker jarFileMaker = new JarFileMaker();
    //				File test = new File("bin");
    //				jarFileMaker.createJarFile(jar, test, "ntut.csie.robusta.agile.exception");
    //			}
    //		});

    // 上半部,選擇要偵測的Smell群組
    smellTypeGroup = new Group(selectComposite, SWT.NONE);
    smellTypeGroup.setText(resource.getString("settingPage.smell.type"));
    smellTypeGroup.setLocation(10, 5);

    // 是否要選擇性偵測的Button
    checkbox_DetectAllSmells = new Button(smellTypeGroup, SWT.CHECK);
    checkbox_DetectAllSmells.setText(resource.getString("check.all.smell"));
    checkbox_DetectAllSmells.setLocation(10, 20);
    checkbox_DetectAllSmells.pack();
    checkbox_DetectAllSmells.setSelection(isDetectingAllSmells);
    checkbox_DetectAllSmells.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            isDetectingAllSmells = !isDetectingAllSmells;
            setUserSetting();
          }
        });

    // 選擇EH Smell List
    smellList =
        new Table(
            smellTypeGroup,
            SWT.CHECK | SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.HIDE_SELECTION);
    smellList.setLocation(
        checkbox_DetectAllSmells.getBounds().x,
        checkbox_DetectAllSmells.getBounds().y + checkbox_DetectAllSmells.getBounds().height);
    smellList.setFont(new Font(composite.getDisplay(), "Arial", 11, SWT.NONE));
    smellList.setLinesVisible(true);
    smellList.setHeaderVisible(true);
    smellList.setItemCount(7);

    final TableColumn smellColumn = new TableColumn(smellList, SWT.NONE);
    String smellColumnDisplayText = resource.getString("settingPage.smell.type");
    smellColumn.setText(smellColumnDisplayText);
    smellColumn.setWidth(smellColumnDisplayText.length() * 9);
    // 自動調整bad smell Type Column的大小
    smellColumn.pack();
    final TableColumn descColumn = new TableColumn(smellList, SWT.NONE);
    descColumn.setText(resource.getString("settingPage.smell.description"));

    for (int i = 0; i < RLMarkerAttribute.CS_TOTAL_TYPE.length; i++) {
      TableItem item = smellList.getItem(i);
      item.setText(0, RLMarkerAttribute.CS_TOTAL_TYPE[i].replace('_', ' '));
      item.setFont(0, new Font(composite.getDisplay(), "Arial", 11, SWT.BOLD));
      item.setText(1, descText[i]);
    }
    // 自動調整bad smell Description Column的大小
    descColumn.pack();

    // 自動調整設定主頁面上半部視窗的大小
    smellList.pack();
    smellTypeGroup.pack();

    // Template Group
    templateCodeGroup = new Group(selectComposite, SWT.NONE);
    templateCodeGroup.setText(resource.getString("settingPage.codeExample"));
    templateCodeGroup.setLocation(10, getLowerRightCoordinate(smellTypeGroup).y + 5);

    // 是否要醒目標記程式碼
    checkbox_HighlightSmellCode = new Button(templateCodeGroup, SWT.CHECK);
    checkbox_HighlightSmellCode.setText(resource.getString("settingPage.codeExample.highlight"));
    checkbox_HighlightSmellCode.setLocation(10, 20);
    checkbox_HighlightSmellCode.pack();
    checkbox_HighlightSmellCode.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            isShowWarning = checkbox_HighlightSmellCode.getSelection();

            int index = smellList.getSelectionIndex();
            if (index != -1) {
              changeTemplateText(index);
            }
          }
        });

    // Template Text
    templateCode = new StyledText(templateCodeGroup, SWT.BORDER | SWT.V_SCROLL);
    templateCode.setBounds(
        10, this.getLowerRightCoordinate(checkbox_HighlightSmellCode).y, 500, 170);
    templateCode.setText("");
    Font font = new Font(composite.getDisplay(), "Courier New", 14, SWT.NORMAL);
    templateCode.setFont(font);
    templateCodeGroup.pack();

    // 自動調整設定主頁面Container的大小
    selectComposite.pack();
    selectComposite.setSize(
        getLowerRightCoordinate(smellTypeGroup).x + 15, selectComposite.getBounds().height);
  }
예제 #17
0
  public void createControl(Composite parent) {
    fViewerContainer = new Composite(parent, SWT.NULL);
    fViewerContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
    fViewerContainer.setSize(100, 100);
    fViewerContainer.setLayout(new FillLayout());

    fTreeViewer = new TreeViewer(fViewerContainer, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);

    fTreeViewer.setContentProvider(
        new ITreeContentProvider() {

          public void dispose() {}

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            viewer.refresh();
          }

          public Object[] getChildren(Object parentElement) {
            return new Object[0];
          }

          public Object getParent(Object element) {
            return null;
          }

          public boolean hasChildren(Object element) {
            return false;
          }

          public Object[] getElements(Object inputElement) {

            if (fQuery == null) return new Object[0];
            else {
              return ((MemorySearchResult) fQuery.getSearchResult()).getMatches();
            }
          }
        });

    fTreeViewer.setInput(new Object());
    fTreeViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          public void selectionChanged(final SelectionChangedEvent event) {
            if (event.getSelection() instanceof StructuredSelection) {
              IMemoryRenderingContainer containers[] =
                  ((IMemorySearchQuery) fQuery).getMemoryView().getMemoryRenderingContainers();
              MemoryMatch match =
                  (MemoryMatch) ((StructuredSelection) event.getSelection()).getFirstElement();
              if (match != null) {
                for (int i = 0; i < containers.length; i++) {
                  IMemoryRendering rendering = containers[i].getActiveRendering();
                  if (rendering instanceof IRepositionableMemoryRendering) {
                    try {
                      ((IRepositionableMemoryRendering) rendering)
                          .goToAddress(match.getStartAddress());
                    } catch (DebugException e) {
                      MemorySearchPlugin.logError(
                          Messages.getString(
                              "MemorySearchResultsPage.RepositioningMemoryViewFailed"),
                          e); //$NON-NLS-1$
                    }
                  }

                  if (rendering != null) {
                    // Temporary, until platform accepts/adds new interface for setting the
                    // selection
                    try {
                      Method m =
                          rendering
                              .getClass()
                              .getMethod(
                                  "setSelection",
                                  new Class[] {BigInteger.class, BigInteger.class}); // $NON-NLS-1$
                      if (m != null)
                        m.invoke(rendering, match.getStartAddress(), match.getEndAddress());
                    } catch (Exception e) {
                      // do nothing
                    }
                  }
                }
              }
            }
          }
        });

    fTreeViewer.setLabelProvider(
        new ILabelProvider() {

          public String getText(Object element) {
            if (element instanceof MemoryMatch)
              return "0x" + ((MemoryMatch) element).getStartAddress().toString(16); // $NON-NLS-1$

            return element.toString();
          }

          public Image getImage(Object element) {
            return null;
          }

          public void addListener(ILabelProviderListener listener) {}

          public void dispose() {}

          public boolean isLabelProperty(Object element, String property) {
            return false;
          }

          public void removeListener(ILabelProviderListener listener) {}
        });

    fQueryListener = createQueryListener();

    NewSearchUI.addQueryListener(fQueryListener);
  }
예제 #18
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();
  }
 protected Control createContents(Composite parent) {
   getShell().setText("Action/Contribution Example");
   parent.setSize(290, 150);
   aci.fill(parent);
   return parent;
 }
  public void createControl(Composite parent) {
    IBlackboard blackboard = getStyleBlackboard();
    LegendStyle style = null;
    if (blackboard != null) {
      style = (LegendStyle) blackboard.get(LegendStyleContent.ID);
    }

    if (style == null) {
      style = LegendStyleContent.createDefault();
      if (blackboard != null) {
        blackboard.put(LegendStyleContent.ID, style);
        ((StyleBlackboard) blackboard).setSelected(new String[] {LegendStyleContent.ID});
      }
    }

    ScrolledComposite scrollComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    Composite composite = new Composite(scrollComposite, SWT.BORDER);

    GridLayout layout = new GridLayout(2, true);
    composite.setLayout(layout);

    GridData layoutData = null;

    Label verticalMarginLabel = new Label(composite, SWT.NONE);
    verticalMarginLabel.setText(Messages.LegendGraphicStyleConfigurator_vertical_margin);
    verticalMarginLabel.setLayoutData(layoutData);
    verticalMargin = new Text(composite, SWT.BORDER);
    verticalMargin.setLayoutData(layoutData);

    Label horizontalMarginLabel = new Label(composite, SWT.NONE);
    horizontalMarginLabel.setLayoutData(layoutData);
    horizontalMarginLabel.setText(Messages.LegendGraphicStyleConfigurator_horizontal_margin);
    horizontalMargin = new Text(composite, SWT.BORDER);
    horizontalMargin.setLayoutData(layoutData);

    Label verticalSpacingLabel = new Label(composite, SWT.NONE);
    verticalSpacingLabel.setLayoutData(layoutData);
    verticalSpacingLabel.setText(Messages.LegendGraphicStyleConfigurator_vertical_spacing);
    verticalSpacing = new Text(composite, SWT.BORDER);
    verticalSpacing.setLayoutData(layoutData);

    Label horizontalSpacingLabel = new Label(composite, SWT.NONE);
    horizontalSpacingLabel.setLayoutData(layoutData);
    horizontalSpacingLabel.setText(Messages.LegendGraphicStyleConfigurator_horizontal_spacing);
    horizontalSpacing = new Text(composite, SWT.BORDER);
    horizontalSpacing.setLayoutData(layoutData);

    Label indentSizeLabel = new Label(composite, SWT.NONE);
    indentSizeLabel.setLayoutData(layoutData);
    indentSizeLabel.setText(Messages.LegendGraphicStyleConfigurator_indent_size);
    indentSize = new Text(composite, SWT.BORDER);
    indentSize.setLayoutData(layoutData);

    Label fontColourLabel = new Label(composite, SWT.NONE);
    fontColourLabel.setLayoutData(layoutData);
    fontColourLabel.setText(Messages.LegendGraphicStyleConfigurator_font_colour);
    fontColour = new ColorEditor(composite);

    Label backgroundColourLabel = new Label(composite, SWT.NONE);
    backgroundColourLabel.setLayoutData(layoutData);
    backgroundColourLabel.setText(Messages.LegendGraphicStyleConfigurator_background_colour);
    backgroundColour = new ColorEditor(composite);

    composite.layout();
    Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    composite.setSize(size);
    scrollComposite.setContent(composite);

    verticalMargin.setText(Integer.toString(style.verticalMargin));
    horizontalMargin.setText(Integer.toString(style.horizontalMargin));
    verticalSpacing.setText(Integer.toString(style.verticalSpacing));
    horizontalSpacing.setText(Integer.toString(style.horizontalSpacing));
    indentSize.setText(Integer.toString(style.indentSize));
    fontColour.setColorValue(
        new RGB(
            style.foregroundColour.getRed(),
            style.foregroundColour.getGreen(),
            style.foregroundColour.getBlue()));
    backgroundColour.setColorValue(
        new RGB(
            style.backgroundColour.getRed(),
            style.backgroundColour.getGreen(),
            style.backgroundColour.getBlue()));

    verticalMargin.addModifyListener(this);
    horizontalMargin.addModifyListener(this);
    verticalSpacing.addModifyListener(this);
    horizontalSpacing.addModifyListener(this);
    indentSize.addModifyListener(this);
    backgroundColour.addSelectionListener(this);
    fontColour.addSelectionListener(this);
  }
  /** Opens the Dialog Shell. Auto-generated code - any changes you make will disappear. */
  public void open() {
    try {
      preInitGUI();

      Shell parent = getParent();
      dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
      dialogShell.setText(getText());

      composite2 = new Composite(dialogShell, SWT.NULL);
      isLocalBtn = new Button(composite2, SWT.CHECK | SWT.LEFT);
      isAbstractBtn = new Button(composite2, SWT.CHECK | SWT.LEFT);
      repositoryIdTxt = new Text(composite2, SWT.BORDER);
      versionTxt = new Text(composite2, SWT.BORDER);
      identifierTxt = new Text(composite2, SWT.BORDER);
      versionLb = new Label(composite2, SWT.NULL);
      repositoryIdLb = new Label(composite2, SWT.NULL);
      idLb = new Label(composite2, SWT.NULL);
      composite3 = new Composite(dialogShell, SWT.NULL);
      cancel = new Button(composite3, SWT.PUSH | SWT.CENTER);
      enter = new Button(composite3, SWT.PUSH | SWT.CENTER);

      dialogShell.setText("Add Module");
      dialogShell.setSize(new org.eclipse.swt.graphics.Point(476, 145));

      GridData composite2LData = new GridData();
      composite2LData.verticalAlignment = GridData.CENTER;
      composite2LData.horizontalAlignment = GridData.BEGINNING;
      composite2LData.widthHint = 464;
      composite2LData.heightHint = 102;
      composite2LData.horizontalIndent = 0;
      composite2LData.horizontalSpan = 1;
      composite2LData.verticalSpan = 1;
      composite2LData.grabExcessHorizontalSpace = false;
      composite2LData.grabExcessVerticalSpace = false;
      composite2.setLayoutData(composite2LData);
      composite2.setSize(new org.eclipse.swt.graphics.Point(464, 102));

      FormData isLocalBtnLData = new FormData();
      isLocalBtnLData.height = 20;
      isLocalBtnLData.width = 70;
      isLocalBtnLData.left = new FormAttachment(519, 1000, 0);
      isLocalBtnLData.right = new FormAttachment(750, 1000, 0);
      isLocalBtnLData.top = new FormAttachment(700, 1000, 0);
      isLocalBtnLData.bottom = new FormAttachment(897, 1000, 0);
      isLocalBtn.setLayoutData(isLocalBtnLData);
      isLocalBtn.setText("is local");
      isLocalBtn.setSize(new org.eclipse.swt.graphics.Point(70, 20));
      final Font isLocalBtnfont = new Font(Display.getDefault(), "Tahoma", 8, 1);
      isLocalBtn.setFont(isLocalBtnfont);

      FormData isAbstractBtnLData = new FormData();
      isAbstractBtnLData.height = 20;
      isAbstractBtnLData.width = 100;
      isAbstractBtnLData.left = new FormAttachment(239, 1000, 0);
      isAbstractBtnLData.right = new FormAttachment(475, 1000, 0);
      isAbstractBtnLData.top = new FormAttachment(700, 1000, 0);
      isAbstractBtnLData.bottom = new FormAttachment(897, 1000, 0);
      isAbstractBtn.setLayoutData(isAbstractBtnLData);
      isAbstractBtn.setText("is abstract");
      isAbstractBtn.setSize(new org.eclipse.swt.graphics.Point(100, 20));
      isAbstractBtn.setFont(isLocalBtnfont);

      FormData repositoryIdTxtLData = new FormData();
      repositoryIdTxtLData.height = 13;
      repositoryIdTxtLData.width = 352;
      repositoryIdTxtLData.left = new FormAttachment(239, 1000, 0);
      repositoryIdTxtLData.right = new FormAttachment(996, 1000, 0);
      repositoryIdTxtLData.top = new FormAttachment(269, 1000, 0);
      repositoryIdTxtLData.bottom = new FormAttachment(465, 1000, 0);
      repositoryIdTxt.setLayoutData(repositoryIdTxtLData);
      repositoryIdTxt.setDoubleClickEnabled(false);
      final Font repositoryIdTxtfont = new Font(Display.getDefault(), "Tahoma", 7, 0);
      repositoryIdTxt.setFont(repositoryIdTxtfont);
      repositoryIdTxt.setEditable(false);
      repositoryIdTxt.setSize(new org.eclipse.swt.graphics.Point(352, 13));
      repositoryIdTxt.setEnabled(false);

      FormData versionTxtLData = new FormData();
      versionTxtLData.height = 13;
      versionTxtLData.width = 352;
      versionTxtLData.left = new FormAttachment(239, 1000, 0);
      versionTxtLData.right = new FormAttachment(996, 1000, 0);
      versionTxtLData.top = new FormAttachment(485, 1000, 0);
      versionTxtLData.bottom = new FormAttachment(691, 1000, 0);
      versionTxt.setLayoutData(versionTxtLData);
      versionTxt.setFont(repositoryIdTxtfont);
      versionTxt.setSize(new org.eclipse.swt.graphics.Point(352, 13));
      versionTxt.addKeyListener(
          new KeyAdapter() {
            public void keyReleased(KeyEvent evt) {
              versionTxtKeyReleased(evt);
            }
          });

      FormData identifierTxtLData = new FormData();
      identifierTxtLData.height = 13;
      identifierTxtLData.width = 352;
      identifierTxtLData.left = new FormAttachment(239, 1000, 0);
      identifierTxtLData.right = new FormAttachment(996, 1000, 0);
      identifierTxtLData.top = new FormAttachment(48, 1000, 0);
      identifierTxtLData.bottom = new FormAttachment(250, 1000, 0);
      identifierTxt.setLayoutData(identifierTxtLData);
      identifierTxt.setFont(repositoryIdTxtfont);
      identifierTxt.setSize(new org.eclipse.swt.graphics.Point(352, 13));
      identifierTxt.setFocus();
      identifierTxt.addKeyListener(
          new KeyAdapter() {
            public void keyReleased(KeyEvent evt) {
              identifierTxtKeyReleased(evt);
            }
          });

      FormData versionLbLData = new FormData();
      versionLbLData.height = 20;
      versionLbLData.width = 90;
      versionLbLData.left = new FormAttachment(11, 1000, 0);
      versionLbLData.right = new FormAttachment(245, 1000, 0);
      versionLbLData.top = new FormAttachment(485, 1000, 0);
      versionLbLData.bottom = new FormAttachment(681, 1000, 0);
      versionLb.setLayoutData(versionLbLData);
      versionLb.setText("Version:");
      versionLb.setSize(new org.eclipse.swt.graphics.Point(90, 20));
      versionLb.setFont(isLocalBtnfont);

      FormData repositoryIdLbLData = new FormData();
      repositoryIdLbLData.height = 20;
      repositoryIdLbLData.width = 90;
      repositoryIdLbLData.left = new FormAttachment(11, 1000, 0);
      repositoryIdLbLData.right = new FormAttachment(245, 1000, 0);
      repositoryIdLbLData.top = new FormAttachment(269, 1000, 0);
      repositoryIdLbLData.bottom = new FormAttachment(465, 1000, 0);
      repositoryIdLb.setLayoutData(repositoryIdLbLData);
      repositoryIdLb.setText("Repository ID:");
      repositoryIdLb.setSize(new org.eclipse.swt.graphics.Point(90, 20));
      repositoryIdLb.setFont(isLocalBtnfont);

      FormData idLbLData = new FormData();
      idLbLData.height = 20;
      idLbLData.width = 90;
      idLbLData.left = new FormAttachment(11, 1000, 0);
      idLbLData.right = new FormAttachment(245, 1000, 0);
      idLbLData.top = new FormAttachment(53, 1000, 0);
      idLbLData.bottom = new FormAttachment(250, 1000, 0);
      idLb.setLayoutData(idLbLData);
      idLb.setText("Identifier:");
      idLb.setSize(new org.eclipse.swt.graphics.Point(90, 20));
      idLb.setFont(isLocalBtnfont);
      FormLayout composite2Layout = new FormLayout();
      composite2.setLayout(composite2Layout);
      composite2Layout.marginWidth = 0;
      composite2Layout.marginHeight = 0;
      composite2Layout.spacing = 0;
      composite2.layout();

      GridData composite3LData = new GridData();
      composite3LData.verticalAlignment = GridData.CENTER;
      composite3LData.horizontalAlignment = GridData.BEGINNING;
      composite3LData.widthHint = 466;
      composite3LData.heightHint = 46;
      composite3LData.horizontalIndent = 0;
      composite3LData.horizontalSpan = 1;
      composite3LData.verticalSpan = 1;
      composite3LData.grabExcessHorizontalSpace = false;
      composite3LData.grabExcessVerticalSpace = false;
      composite3.setLayoutData(composite3LData);
      composite3.setSize(new org.eclipse.swt.graphics.Point(466, 46));

      FormData cancelLData = new FormData();
      cancelLData.height = 21;
      cancelLData.width = 80;
      cancelLData.left = new FormAttachment(816, 1000, 0);
      cancelLData.right = new FormAttachment(988, 1000, 0);
      cancelLData.top = new FormAttachment(6, 1000, 0);
      cancelLData.bottom = new FormAttachment(580, 1000, 0);
      cancel.setLayoutData(cancelLData);
      cancel.setText("CANCEL");
      cancel.setSize(new org.eclipse.swt.graphics.Point(80, 21));
      cancel.setFont(isLocalBtnfont);
      cancel.addMouseListener(
          new MouseAdapter() {
            public void mouseDown(MouseEvent evt) {
              cancelMouseDown(evt);
            }
          });

      FormData enterLData = new FormData();
      enterLData.height = 21;
      enterLData.width = 80;
      enterLData.left = new FormAttachment(623, 1000, 0);
      enterLData.right = new FormAttachment(795, 1000, 0);
      enterLData.top = new FormAttachment(6, 1000, 0);
      enterLData.bottom = new FormAttachment(580, 1000, 0);
      enter.setLayoutData(enterLData);
      enter.setText("ENTER");
      enter.setSize(new org.eclipse.swt.graphics.Point(80, 21));
      enter.setFont(isLocalBtnfont);
      enter.addMouseListener(
          new MouseAdapter() {
            public void mouseDown(MouseEvent evt) {
              enterMouseDown(evt);
            }
          });
      FormLayout composite3Layout = new FormLayout();
      composite3.setLayout(composite3Layout);
      composite3Layout.marginWidth = 0;
      composite3Layout.marginHeight = 0;
      composite3Layout.spacing = 0;
      composite3.layout();
      GridLayout dialogShellLayout = new GridLayout(1, true);
      dialogShell.setLayout(dialogShellLayout);
      dialogShellLayout.marginWidth = 5;
      dialogShellLayout.marginHeight = 5;
      dialogShellLayout.numColumns = 1;
      dialogShellLayout.makeColumnsEqualWidth = true;
      dialogShellLayout.horizontalSpacing = 5;
      dialogShellLayout.verticalSpacing = 5;
      dialogShell.layout();
      dialogShell.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {

              isLocalBtnfont.dispose();
              repositoryIdTxtfont.dispose();
            }
          });
      Rectangle bounds = dialogShell.computeTrim(0, 0, 476, 145);
      dialogShell.setSize(bounds.width, bounds.height);
      postInitGUI();
      dialogShell.open();
      Display display = dialogShell.getDisplay();
      while (!dialogShell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #22
0
 protected void recomputeSize() {
   Point point = top.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   top.setSize(point);
   scrollTop.setMinSize(point);
 }
  @Override
  public void createControl(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;

    container = new Composite(parent, SWT.NONE);
    container.setLayout(layout);
    container.setSize(300, 300);

    information = new Label(container, SWT.NONE);
    GridData ilayout = new GridData();
    ilayout.horizontalSpan = 3;
    information.setLayoutData(ilayout);
    information.setText("Specify the system actuator that compose the application:");

    // ---------------------- Table ---------------------------
    table = new Table(container, SWT.BORDER);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.horizontalSpan = 3;

    table.setLayoutData(data);
    table.setSize(290, 100);

    final TableColumn column = new TableColumn(table, SWT.NONE);
    column.setText("Signal");
    column.setWidth(130);

    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText("Actuator");
    column2.setWidth(100);

    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setText("Protocol");
    column3.setWidth(70);

    final TableColumn column4 = new TableColumn(table, SWT.NONE);
    column4.setText("Priority");
    column4.setWidth(70);

    final TableColumn column5 = new TableColumn(table, SWT.NONE);
    column5.setText("Periodic");
    column5.setWidth(70);

    final TableColumn column6 = new TableColumn(table, SWT.NONE);
    column6.setText("Period (ms)");
    column6.setWidth(70);

    Button btEditActuator = new Button(container, SWT.NONE);

    table.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            btEditActuator.setEnabled(true);
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            // TODO Auto-generated method stub
          }
        });

    table.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseUp(MouseEvent e) {
            // TODO Auto-generated method stub
          }

          @Override
          public void mouseDown(MouseEvent e) {
            // TODO Auto-generated method stub
          }

          @Override
          public void mouseDoubleClick(MouseEvent e) {
            editActuatorProperties(parent.getDisplay());
          }
        });

    btEditActuator.setText("Edit Actuator");
    btEditActuator.setEnabled(false);
    btEditActuator.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            switch (e.type) {
              case SWT.Selection:
                if (table.getSelectionIndex() > -1) editActuatorProperties(parent.getDisplay());
            }
          }
        });

    actuators = new ArrayList<>();

    setControl(container);
    setPageComplete(false);
  }
  @SuppressWarnings("nls")
  public void createControl(Composite parent) {
    this.parent = parent;
    parent.setLayout(new GridLayout());
    ScrolledComposite scrollComposite = new ScrolledComposite(parent, SWT.V_SCROLL);
    scrollComposite.setMinHeight(100);
    scrollComposite.setLayoutData(
        new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
    Composite c = new Composite(scrollComposite, SWT.None);
    c.setLayout(new GridLayout());
    c.setLayoutData(
        new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));

    // choose mapset
    Group chooseMapsetGroup = new Group(c, SWT.BORDER);
    GridLayout layout1 = new GridLayout(3, false);
    chooseMapsetGroup.setLayout(layout1);
    chooseMapsetGroup.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    chooseMapsetGroup.setText("Ruling / Affected mapset");

    Label mapsetLabel = new Label(chooseMapsetGroup, SWT.NONE);
    mapsetLabel.setText("wind file for active region:  ");
    windPathText = new Text(chooseMapsetGroup, SWT.BORDER);
    GridData gd = new GridData();
    gd.widthHint = 100;
    windPathText.setLayoutData(gd);
    windPathText.setEditable(false);

    final Button mapsetButton = new Button(chooseMapsetGroup, SWT.BORDER | SWT.PUSH);
    GridData gd2 = new GridData();
    gd2.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
    mapsetButton.setLayoutData(gd2);
    mapsetButton.setText("Browse");
    mapsetButton.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            CatalogJGrassMapsetTreeViewerDialog cDialog = new CatalogJGrassMapsetTreeViewerDialog();
            cDialog.open(mapsetButton.getShell());
            List<JGrassMapsetGeoResource> selectedLayers = cDialog.getSelectedLayers();
            if (selectedLayers == null || selectedLayers.size() == 0) {
              return;
            }
            jGrassMapsetGeoResource = selectedLayers.get(0);
            String windPath = jGrassMapsetGeoResource.getActiveRegionWindowPath();
            windPathText.setText(windPath);

            JGrassRegion jgR = jGrassMapsetGeoResource.getActiveRegionWindow();
            CoordinateReferenceSystem crs = jGrassMapsetGeoResource.getLocationCrs();

            commitToBlackboards(jgR, crs, windPath);
          }
        });

    // the group for the region
    Group regionGroup = new Group(c, SWT.BORDER);
    GridLayout layout2 = new GridLayout(2, true);
    regionGroup.setLayout(layout2);
    regionGroup.setText("Region settings");
    regionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    northLabel = new Label(regionGroup, SWT.NONE);
    northLabel.setText("north");
    northLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    northText = new Text(regionGroup, SWT.BORDER);
    northText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    southLabel = new Label(regionGroup, SWT.NONE);
    southLabel.setText("south");
    southLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    southText = new Text(regionGroup, SWT.BORDER);
    southText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    westLabel = new Label(regionGroup, SWT.NONE);
    westLabel.setText("west");
    westLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    westText = new Text(regionGroup, SWT.BORDER);
    westText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    eastLabel = new Label(regionGroup, SWT.NONE);
    eastLabel.setText("east");
    eastLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    eastText = new Text(regionGroup, SWT.BORDER);
    eastText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    rowsLabel = new Label(regionGroup, SWT.NONE);
    rowsLabel.setText("rows");
    rowsLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    rowsText = new Text(regionGroup, SWT.BORDER);
    rowsText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    colsLabel = new Label(regionGroup, SWT.NONE);
    colsLabel.setText("cols");
    colsLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    colsText = new Text(regionGroup, SWT.BORDER);
    colsText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    xresLabel = new Label(regionGroup, SWT.NONE);
    xresLabel.setText("xres");
    xresLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    xresText = new Text(regionGroup, SWT.BORDER);
    xresText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    yresLabel = new Label(regionGroup, SWT.NONE);
    yresLabel.setText("yres");
    yresLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    yresText = new Text(regionGroup, SWT.BORDER);
    yresText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    // the group for the style
    Group styleGroup = new Group(c, SWT.BORDER);
    GridLayout layout3 = new GridLayout(2, true);
    styleGroup.setLayout(layout3);
    styleGroup.setText("Style properties");
    styleGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    gridButton = new Button(styleGroup, SWT.BORDER | SWT.CHECK);
    gridButton.setText("visualize active region grid");
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gridData.horizontalSpan = 2;
    gridButton.setLayoutData(gridData);

    Label backgroundColourLabel = new Label(styleGroup, SWT.NONE);
    backgroundColourLabel.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    backgroundColourLabel.setText("background color");
    backgroundColour = new ColorEditor(styleGroup);
    backgroundColour
        .getButton()
        .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    Label backgroundAlphaLabel = new Label(styleGroup, SWT.NONE);
    backgroundAlphaLabel.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    backgroundAlphaLabel.setText("background alpha (0-1)");
    backgroundAlphaText = new Text(styleGroup, SWT.BORDER);
    backgroundAlphaText.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    Label foregroundColourLabel = new Label(styleGroup, SWT.NONE);
    foregroundColourLabel.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    foregroundColourLabel.setText("foreground color");
    foregroundColor = new ColorEditor(styleGroup);
    foregroundColor
        .getButton()
        .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    Label forgroundAlphaLabel = new Label(styleGroup, SWT.NONE);
    forgroundAlphaLabel.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    forgroundAlphaLabel.setText("foreground alpha (0-1)");
    forgroundAlphaText = new Text(styleGroup, SWT.BORDER);
    forgroundAlphaText.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    // the group for the set region to map
    final Group settoGroup = new Group(c, SWT.BORDER);
    GridLayout layout4 = new GridLayout(1, true);
    settoGroup.setLayout(layout4);
    settoGroup.setText("Set region to...");
    settoGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    rasterMapSetButton = new Button(settoGroup, SWT.NONE);
    rasterMapSetButton.setText("set region to raster map");
    rasterMapSetButton.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    rasterMapSetButton.addSelectionListener(
        new org.eclipse.swt.events.SelectionAdapter() {
          public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            JGRasterChooserDialog tree = new JGRasterChooserDialog(null);
            tree.open(settoGroup.getShell(), SWT.SINGLE);

            update(tree.getSelectedResources());
          }
        });
    featuresMapSetButton = new Button(settoGroup, SWT.NONE);
    featuresMapSetButton.setText("set region to vector map");
    featuresMapSetButton.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    featuresMapSetButton.addSelectionListener(
        new org.eclipse.swt.events.SelectionAdapter() {
          public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            FeatureChooserDialog tree = new FeatureChooserDialog();
            tree.open(settoGroup.getShell(), SWT.SINGLE);

            update(tree.getSelectedResources());
          }
        });
    resetToActiveButton = new Button(settoGroup, SWT.NONE);
    resetToActiveButton.setText("reset back to actual region");
    resetToActiveButton.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    resetToActiveButton.addSelectionListener(
        new org.eclipse.swt.events.SelectionAdapter() {
          public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            String windPath = windPathText.getText();
            try {
              JGrassRegion jgR = new JGrassRegion(windPath);
              setWidgetsToWindow(jgR);
            } catch (IOException e1) {
              e1.printStackTrace();
            }
          }
        });

    northText.addModifyListener(
        new org.eclipse.swt.events.ModifyListener() {

          public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
            if (isWorking) return;
            textModified(bound_type);
          }
        });
    southText.addModifyListener(
        new org.eclipse.swt.events.ModifyListener() {
          public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
            if (isWorking) return;
            textModified(bound_type);
          }
        });
    rowsText.addModifyListener(
        new org.eclipse.swt.events.ModifyListener() {
          public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
            if (isWorking) return;
            textModified(row_type);
          }
        });
    colsText.addModifyListener(
        new org.eclipse.swt.events.ModifyListener() {
          public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
            if (isWorking) return;
            textModified(row_type);
          }
        });
    westText.addModifyListener(
        new org.eclipse.swt.events.ModifyListener() {
          public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
            if (isWorking) return;
            textModified(bound_type);
          }
        });
    xresText.addModifyListener(
        new org.eclipse.swt.events.ModifyListener() {
          public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
            if (isWorking) return;
            textModified(res_type);
          }
        });
    eastText.addModifyListener(
        new org.eclipse.swt.events.ModifyListener() {
          public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
            if (isWorking) return;
            textModified(bound_type);
          }
        });
    yresText.addModifyListener(
        new org.eclipse.swt.events.ModifyListener() {
          public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
            if (isWorking) return;
            textModified(res_type);
          }
        });
    foregroundColor.addSelectionListener(this);
    backgroundColour.addSelectionListener(this);

    /*
     * layout
     */
    c.layout();
    Point size = c.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    c.setSize(size);
    scrollComposite.setContent(c);
  }
예제 #25
0
  @Override
  public Composite createUI(Composite parent) {
    this.display = WorkPart.display();
    Shell shell = new Shell(this.display);
    shell.setSize(50, 100);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    shell.setLayout(gridLayout);
    ProgressBar pb = new ProgressBar(shell, SWT.HORIZONTAL | SWT.INDETERMINATE);
    pb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label searching = new Label(shell, SWT.NONE);
    searching.setText("Searching...");
    shell.open();
    this.isSearching = true;
    new Thread() {
      public void run() {
        testTm_cz = RetrieveData.testTm_czConnection();
        testTm_lz = RetrieveData.testTm_lzConnection();
        testDeapp = RetrieveData.testDeappConnection();
        root = new TreeNode("Dataset explorer", null, false);
        studyTree = new StudyTree(root);
        topNodeController = new TopNodeController(root, dataType, studyTree);
        root = topNodeController.buildTree();
        topNode = dataType.getStudy().getTopNode();
        isSearching = false;
      }
    }.start();
    this.display = WorkPart.display();
    while (this.isSearching) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    shell.close();
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gd = new GridLayout();
    gd.numColumns = 1;
    gd.horizontalSpacing = 0;
    gd.verticalSpacing = 0;
    composite.setLayout(gd);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    ScrolledComposite scroller = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
    scroller.setLayoutData(new GridData(GridData.FILL_BOTH));
    gd = new GridLayout();
    gd.numColumns = 1;
    gd.horizontalSpacing = 0;
    gd.verticalSpacing = 0;
    scroller.setLayout(gd);
    scroller.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite scrolledComposite = new Composite(scroller, SWT.NONE);
    scroller.setContent(scrolledComposite);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.verticalSpacing = 10;
    scrolledComposite.setLayout(layout);
    scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

    this.topNode = this.dataType.getStudy().getTopNode();
    if (topNode != null && topNode.compareTo("") != 0) {
      viewer = new TreeViewer(scrolledComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
      viewer.setContentProvider(new StudyContentProvider());
      viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);

      viewer.setInput(this.studyTree);
      GridData gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalAlignment = SWT.FILL;
      gridData.verticalAlignment = SWT.FILL;
      gridData.grabExcessHorizontalSpace = true;
      gridData.grabExcessVerticalSpace = true;
      gridData.heightHint = 300;
      gridData.widthHint = 250;
      this.viewer.getControl().setLayoutData(gridData);
      viewer.setLabelProvider(
          new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
              return element.toString();
            }

            @Override
            public Color getBackground(Object element) {
              if (((TreeNode) element).isStudyRoot()) {
                return new Color(Display.getCurrent(), 237, 91, 67);
              }
              if (((TreeNode) element).isLabel()) {
                return new Color(Display.getCurrent(), 212, 212, 212);
              }
              return null;
            }
          });

      securityButton = new Button(scrolledComposite, SWT.CHECK);
      securityButton.setText("Security required");
      securityButton.addListener(
          SWT.Selection,
          new Listener() {

            @Override
            public void handleEvent(Event event) {
              security = securityButton.getSelection();
            }
          });

      /*indexesButton=new Button(scrolledComposite, SWT.CHECK);
      indexesButton.setText("Turn off the indexes during loaded (only for large datasets)");
      indexesButton.addListener(SWT.Selection, new Listener(){

      	@Override
      	public void handleEvent(Event event) {
      		indexes=indexesButton.getSelection();
      	}
      })*/ ;
    } else {
      Label label = new Label(scrolledComposite, SWT.NONE);
      label.setText("Please first choose a study node in the description data type");
    }

    Button button = new Button(scrolledComposite, SWT.PUSH);
    button.setText("Load");

    if (topNode != null && topNode.compareTo("") != 0) {
      if (this.testTm_cz && this.testTm_lz && this.testDeapp) {
        button.addListener(SWT.Selection, new LoadGeneExpressionDataListener(this, this.dataType));
        Label dbLabel = new Label(scrolledComposite, SWT.NONE);
        dbLabel.setText("You are connected to database '" + PreferencesHandler.getDb() + "'");
      } else {
        button.setEnabled(false);
        Label warn = new Label(scrolledComposite, SWT.NONE);
        warn.setText("Warning: connection to database is not possible");
      }
    } else {
      button.setEnabled(false);
    }
    scrolledComposite.setSize(scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    return composite;
  }
  public void createControl(Composite parent) {

    ScrolledComposite scrollComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    Composite c = new Composite(scrollComposite, SWT.None);
    c.setLayout(new GridLayout());
    c.setLayoutData(
        new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));

    GridData layoutData = null;
    Group chooseMapGroup = new Group(c, SWT.BORDER);
    GridLayout layout1 = new GridLayout(3, false);
    chooseMapGroup.setLayout(layout1);
    chooseMapGroup.setLayoutData(
        new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
    Label mapLabel = new Label(chooseMapGroup, SWT.NONE);
    mapLabel.setLayoutData(layoutData);
    mapLabel.setText(
        Messages.getString("LegendGraphicStyleConfigurator.map4legend")); // $NON-NLS-1$
    mapNameLabel = new Label(chooseMapGroup, SWT.BORDER);
    GridData gd = new GridData();
    gd.widthHint = 100;
    mapNameLabel.setLayoutData(gd);

    final Button mapButton = new Button(chooseMapGroup, SWT.BORDER | SWT.PUSH);
    GridData gd2 = new GridData();
    gd2.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
    mapButton.setLayoutData(gd2);
    mapButton.setText(Messages.getString("LegendGraphicStyleConfigurator.browse")); // $NON-NLS-1$
    mapButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            JGRasterChooserDialog cDialog = new JGRasterChooserDialog(null);
            cDialog.open(mapButton.getShell(), SWT.SINGLE);

            List<JGrassMapGeoResource> selectedResource = cDialog.getSelectedResources();
            JGrassMapGeoResource jGrassMapGeoResource = selectedResource.get(0);
            File mapFile = jGrassMapGeoResource.getMapFile();
            String name = mapFile.getName();
            mapNameLabel.setText(name);
            if (style == null) checkStyle();
            style.mapPath = mapFile.getAbsolutePath();
          }
        });

    Group propertiesGroup = new Group(c, SWT.BORDER);

    GridLayout layout2 = new GridLayout(2, true);
    propertiesGroup.setLayout(layout2);

    Label titleLabel = new Label(propertiesGroup, SWT.NONE);
    titleLabel.setLayoutData(layoutData);
    titleLabel.setText(Messages.getString("LegendGraphicStyleConfigurator.title")); // $NON-NLS-1$
    titleText = new Text(propertiesGroup, SWT.BORDER);
    titleText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    Label xposLabel = new Label(propertiesGroup, SWT.NONE);
    xposLabel.setLayoutData(layoutData);
    xposLabel.setText(Messages.getString("LegendGraphicStyleConfigurator.xpos")); // $NON-NLS-1$
    xposText = new Text(propertiesGroup, SWT.BORDER);
    xposText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    Label yposLabel = new Label(propertiesGroup, SWT.NONE);
    yposLabel.setLayoutData(layoutData);
    yposLabel.setText(Messages.getString("LegendGraphicStyleConfigurator.ypos")); // $NON-NLS-1$
    yposText = new Text(propertiesGroup, SWT.BORDER);
    yposText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    Label legWidthLabel = new Label(propertiesGroup, SWT.NONE);
    legWidthLabel.setLayoutData(layoutData);
    legWidthLabel.setText(
        Messages.getString("LegendGraphicStyleConfigurator.legendwidth")); // $NON-NLS-1$
    legWidthText = new Text(propertiesGroup, SWT.BORDER);
    legWidthText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    Label legHeightLabel = new Label(propertiesGroup, SWT.NONE);
    legHeightLabel.setLayoutData(layoutData);
    legHeightLabel.setText(
        Messages.getString("LegendGraphicStyleConfigurator.legendheight")); // $NON-NLS-1$
    legHeightText = new Text(propertiesGroup, SWT.BORDER);
    legHeightText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    Label boxWidthLabel = new Label(propertiesGroup, SWT.NONE);
    boxWidthLabel.setLayoutData(layoutData);
    boxWidthLabel.setText(
        Messages.getString("LegendGraphicStyleConfigurator.boxwidth")); // $NON-NLS-1$
    boxWidthText = new Text(propertiesGroup, SWT.BORDER);
    boxWidthText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    isroundedButton = new Button(propertiesGroup, SWT.BORDER | SWT.CHECK);
    isroundedButton.setText(
        Messages.getString("LegendGraphicStyleConfigurator.roundedrect")); // $NON-NLS-1$
    GridData gdata = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    gdata.horizontalSpan = 2;
    isroundedButton.setLayoutData(gdata);

    Label fontColourLabel = new Label(propertiesGroup, SWT.NONE);
    fontColourLabel.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    fontColourLabel.setText(
        Messages.getString("LegendGraphicStyleConfigurator.fontcolor")); // $NON-NLS-1$
    fontColour = new ColorEditor(propertiesGroup);

    Label backgroundColourLabel = new Label(propertiesGroup, SWT.NONE);
    backgroundColourLabel.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    backgroundColourLabel.setText(
        Messages.getString("LegendGraphicStyleConfigurator.backgroundcolor")); // $NON-NLS-1$
    backgroundColour = new ColorEditor(propertiesGroup);

    Label backgroundAlphaLabel = new Label(propertiesGroup, SWT.NONE);
    backgroundAlphaLabel.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    backgroundAlphaLabel.setText(
        Messages.getString("LegendGraphicStyleConfigurator.backgroundalpha")); // $NON-NLS-1$
    backgroundAlphaText = new Text(propertiesGroup, SWT.BORDER);
    backgroundAlphaText.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    Label foregroundColourLabel = new Label(propertiesGroup, SWT.NONE);
    foregroundColourLabel.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    foregroundColourLabel.setText(
        Messages.getString("LegendGraphicStyleConfigurator.foregroundcolor")); // $NON-NLS-1$
    foregroundColor = new ColorEditor(propertiesGroup);

    Label forgroundAlphaLabel = new Label(propertiesGroup, SWT.NONE);
    forgroundAlphaLabel.setLayoutData(layoutData);
    forgroundAlphaLabel.setText(
        Messages.getString("LegendGraphicStyleConfigurator.foregroundalpha")); // $NON-NLS-1$
    forgroundAlphaText = new Text(propertiesGroup, SWT.BORDER);
    forgroundAlphaText.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    c.layout();
    Point size = c.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    c.setSize(size);
    scrollComposite.setContent(c);

    titleText.addModifyListener(this);
    xposText.addModifyListener(this);
    yposText.addModifyListener(this);
    legWidthText.addModifyListener(this);
    legHeightText.addModifyListener(this);
    boxWidthText.addModifyListener(this);
    backgroundAlphaText.addModifyListener(this);
    forgroundAlphaText.addModifyListener(this);
    isroundedButton.addSelectionListener(this);
    foregroundColor.addSelectionListener(this);
    backgroundColour.addSelectionListener(this);
    fontColour.addSelectionListener(this);
  }
예제 #27
0
  public TitleBar(final Window parent, final int size, int flags) {
    this.flags = flags;

    composite = new Composite(parent.getContentPanel(), SWT.NONE);

    composite.setSize(parent.getSize().x, size);

    buttonListener =
        new Listener() {
          public void handleEvent(Event event) {
            if (event.type == SWT.MouseUp) {
              // If the click is still on the button.
              if (event.x >= 0 && event.x < size && event.y >= 0 && event.y < size) {
                if (event.widget == closeButton) {
                  parent.close();
                } else if (event.widget == restoreButton) {
                  dontSetX = true;
                  parent.setMaximized(!parent.isMaximized());
                } else if (event.widget == minimizeButton) {
                  parent.setMinimized(true);
                }
              }
            } else if (event.type == SWT.MouseEnter) {
              Label button = (Label) event.widget;

              button.setBackground(hoverColor);
            } else if (event.type == SWT.MouseExit) {
              Label button = (Label) event.widget;

              button.setBackground(normalColor);
            }
          }
        };

    addButtons();

    titleLabel = new Label(composite, SWT.NONE);
    FontData fd = titleLabel.getFont().getFontData()[0];
    fd.setHeight(14);
    titleLabel.setFont(new Font(Display.getDefault(), fd));

    titleGC = new GC(titleLabel);
    setTitle(parent.getTitle());

    iconLabel = new Label(composite, SWT.NONE);
    setIcon(parent.getIcon());

    dontSetX = true;
    wasRestored = true;
    wasMaximized = parent.isMaximized();

    ControlListener resizeListener =
        new ControlListener() {
          public void controlResized(ControlEvent e) {
            composite.setSize(parent.getClientArea().width, size);

            setTitleLocation();

            layoutButtons();

            if (parent.isMaximized()) {
              if (restoreButton != null) {
                restoreButton.setImage(restoreImage);
              }
            } else {
              if (wasMaximized && !dontSetX) {
                parent.setLocation(mouseX - parent.getSize().x / 2, parent.getLocation().y);
              }

              if (restoreButton != null) {
                restoreButton.setImage(maximizeImage);
              }
            }

            dontSetX = false;

            wasRestored = false;

            wasMaximized = false;

            if (parent.isFullscreen()) {
              if (minimizeButton != null) {
                minimizeButton.setEnabled(false); // .setVisible(false);
              }
              if (restoreButton != null) {
                restoreButton.setEnabled(false); // .setVisible(false);
              }
            } else {
              if (minimizeButton != null) {
                minimizeButton.setEnabled(true); // .setVisible(true);
              }
              if (restoreButton != null) {
                restoreButton.setEnabled(true); // .setVisible(true);
              }
            }
          }

          public void controlMoved(ControlEvent e) {}
        };

    parent.addControlListener(resizeListener);

    final Tracker tracker = new Tracker(parent.getShell(), SWT.NONE);

    tracker.addControlListener(
        new ControlListener() {
          public void controlResized(ControlEvent e) {}

          public void controlMoved(ControlEvent e) {
            if (parent.isMaximized()) {
              parent.setMaximized(false);
            }

            Point loc =
                new Point(
                    tracker.getRectangles()[0].x + 99999, tracker.getRectangles()[0].y + 99999);

            int dx = loc.x - startX;
            int dy = loc.y - startY;

            parent.setLocation(parent.getLocation().x + dx, parent.getLocation().y + dy);

            startX = loc.x;
            startY = loc.y;
          }
        });

    Listener moveListener =
        new Listener() {
          public void handleEvent(Event event) {
            if (!parent.isFullscreen()) {
              if (event.type == SWT.MouseDown) {
                dragging = true;

                Control control = (Control) event.widget;

                mouseX = event.x + parent.getBorderSize() + control.getLocation().x;
                mouseY = event.y + parent.getBorderSize() + control.getLocation().y;

                wasMaximized = parent.isMaximized();

                startX = 0;
                startY = 0;

                tracker.setRectangles(new Rectangle[] {new Rectangle(-99999, -99999, 0, 0)});
                tracker.open();

                tracker.close();
                dragging = false;

                if (parent.getLocation().y + mouseY <= 0) {
                  wasRestored = true;
                  parent.setMaximized(true);
                }
              } else if (event.type == SWT.MouseDoubleClick) {
                dontSetX = true;
                wasRestored = true;
                parent.setMaximized(!parent.isMaximized());
              }
            }
          }
        };

    titleLabel.addListener(SWT.MouseDown, moveListener);
    titleLabel.addListener(SWT.MouseDoubleClick, moveListener);
    composite.addListener(SWT.MouseDown, moveListener);
    composite.addListener(SWT.MouseDoubleClick, moveListener);

    parent.addWindowListener(
        new WindowListener() {
          public boolean titleChanged(String newTitle) {
            setTitle(newTitle);

            return true;
          }

          public boolean iconChanged(Image newIcon) {
            setIcon(newIcon);

            return true;
          }
        });

    composite.setBackgroundMode(SWT.INHERIT_DEFAULT);
  }
예제 #28
0
  @SuppressWarnings("unchecked")
  public void prepareForOpen() {
    Point contentsSize = contents.getSize();
    Point titleSize = new Point(0, 0);

    boolean showTitle = ((style & (SWT.CLOSE | SWT.TITLE)) != 0);
    if (showTitle) {
      if (titleLabel == null) {
        titleLabel = new Label(shell, SWT.NONE);
        titleLabel.setBackground(shell.getBackground());
        titleLabel.setForeground(shell.getForeground());
        FontData[] fds = shell.getFont().getFontData();
        for (int i = 0; i < fds.length; i++) {
          fds[i].setStyle(fds[i].getStyle() | SWT.BOLD);
        }
        final Font font = new Font(shell.getDisplay(), fds);
        titleLabel.addListener(
            SWT.Dispose,
            new Listener() {
              @Override
              public void handleEvent(Event event) {
                font.dispose();
              }
            });
        titleLabel.setFont(font);
        selectionControls.add(titleLabel);
      }
      String titleText = shell.getText();
      titleLabel.setText(titleText == null ? "" : titleText);
      titleLabel.pack();
      titleSize = titleLabel.getSize();

      final Image titleImage = shell.getImage();
      if (titleImageLabel == null && shell.getImage() != null) {
        titleImageLabel = new Canvas(shell, SWT.NONE);
        titleImageLabel.setBackground(shell.getBackground());
        titleImageLabel.setBounds(titleImage.getBounds());
        titleImageLabel.addListener(
            SWT.Paint,
            new Listener() {
              @Override
              public void handleEvent(Event event) {
                event.gc.drawImage(titleImage, 0, 0);
              }
            });
        Point tilSize = titleImageLabel.getSize();
        titleSize.x += tilSize.x + titleWidgetSpacing;
        if (tilSize.y > titleSize.y) titleSize.y = tilSize.y;
        selectionControls.add(titleImageLabel);
      }

      if (systemControlsBar == null && (style & SWT.CLOSE) != 0) {
        // Color closeFG = shell.getForeground(), closeBG = shell.getBackground();
        // Color closeFG = shell.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY), closeBG =
        // shell.getBackground();
        Color closeFG = shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND),
            closeBG = shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
        final Image closeImage = createCloseImage(shell.getDisplay(), closeBG, closeFG);
        shell.addListener(
            SWT.Dispose,
            new Listener() {
              @Override
              public void handleEvent(Event event) {
                closeImage.dispose();
              }
            });
        systemControlsBar = new ToolBar(shell, SWT.FLAT);
        systemControlsBar.setBackground(closeBG);
        systemControlsBar.setForeground(closeFG);
        ToolItem closeItem = new ToolItem(systemControlsBar, SWT.PUSH);
        closeItem.setImage(closeImage);
        closeItem.addListener(
            SWT.Selection,
            new Listener() {
              @Override
              public void handleEvent(Event event) {
                shell.close();
              }
            });
        systemControlsBar.pack();
        Point closeSize = systemControlsBar.getSize();
        titleSize.x += closeSize.x + titleWidgetSpacing;
        if (closeSize.y > titleSize.y) titleSize.y = closeSize.y;
      }

      titleSize.y += titleSpacing;
      if (titleSize.x > contentsSize.x) {
        contentsSize.x = titleSize.x;
        contents.setSize(contentsSize.x, contentsSize.y);
      }
      contentsSize.y += titleSize.y;
    }

    Rectangle screen = shell.getDisplay().getClientArea();

    int anchor = preferredAnchor;
    if (anchor != SWT.NONE && autoAnchor && locX != Integer.MIN_VALUE) {
      if ((anchor & SWT.LEFT) != 0) {
        if (locX + contentsSize.x + marginLeft + marginRight - 16 >= screen.x + screen.width)
          anchor = anchor - SWT.LEFT + SWT.RIGHT;
      } else // RIGHT
      {
        if (locX - contentsSize.x - marginLeft - marginRight + 16 < screen.x)
          anchor = anchor - SWT.RIGHT + SWT.LEFT;
      }
      if ((anchor & SWT.TOP) != 0) {
        if (locY + contentsSize.y + 20 + marginTop + marginBottom >= screen.y + screen.height)
          anchor = anchor - SWT.TOP + SWT.BOTTOM;
      } else // BOTTOM
      {
        if (locY - contentsSize.y - 20 - marginTop - marginBottom < screen.y)
          anchor = anchor - SWT.BOTTOM + SWT.TOP;
      }
    }

    final Point shellSize =
        (anchor == SWT.NONE)
            ? new Point(
                contentsSize.x + marginLeft + marginRight,
                contentsSize.y + marginTop + marginBottom)
            : new Point(
                contentsSize.x + marginLeft + marginRight,
                contentsSize.y + marginTop + marginBottom + 20);

    if (shellSize.x < 54 + marginLeft + marginRight) shellSize.x = 54 + marginLeft + marginRight;
    if (anchor == SWT.NONE) {
      if (shellSize.y < 10 + marginTop + marginBottom) shellSize.y = 10 + marginTop + marginBottom;
    } else {
      if (shellSize.y < 30 + marginTop + marginBottom) shellSize.y = 30 + marginTop + marginBottom;
    }

    shell.setSize(shellSize);
    int titleLocY = marginTop + (((anchor & SWT.TOP) != 0) ? 20 : 0);
    contents.setLocation(marginLeft, titleSize.y + titleLocY);
    if (showTitle) {
      int realTitleHeight = titleSize.y - titleSpacing;
      if (titleImageLabel != null) {
        titleImageLabel.setLocation(
            marginLeft, titleLocY + (realTitleHeight - titleImageLabel.getSize().y) / 2);
        titleLabel.setLocation(
            marginLeft + titleImageLabel.getSize().x + titleWidgetSpacing,
            titleLocY + (realTitleHeight - titleLabel.getSize().y) / 2);
      } else
        titleLabel.setLocation(
            marginLeft, titleLocY + (realTitleHeight - titleLabel.getSize().y) / 2);
      if (systemControlsBar != null)
        systemControlsBar.setLocation(
            shellSize.x - marginRight - systemControlsBar.getSize().x,
            titleLocY + (realTitleHeight - systemControlsBar.getSize().y) / 2);
    }

    final Region region = new Region();
    region.add(createOutline(shellSize, anchor, true));

    shell.setRegion(region);
    shell.addListener(
        SWT.Dispose,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            region.dispose();
          }
        });

    final int[] outline = createOutline(shellSize, anchor, false);
    shell.addListener(
        SWT.Paint,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            event.gc.drawPolygon(outline);
          }
        });

    if (locX != Integer.MIN_VALUE) {
      Point shellLoc = new Point(locX, locY);
      if ((anchor & SWT.BOTTOM) != 0) shellLoc.y = shellLoc.y - shellSize.y + 1;
      if ((anchor & SWT.LEFT) != 0) shellLoc.x -= 15;
      else if ((anchor & SWT.RIGHT) != 0) shellLoc.x = shellLoc.x - shellSize.x + 16;

      if (autoAnchor) {
        if (shellLoc.x < screen.x) shellLoc.x = screen.x;
        else if (shellLoc.x > screen.x + screen.width - shellSize.x)
          shellLoc.x = screen.x + screen.width - shellSize.x;

        if (anchor == SWT.NONE) {
          if (shellLoc.y < screen.y) shellLoc.y = screen.y;
          else if (shellLoc.y > screen.y + screen.height - shellSize.y)
            shellLoc.y = screen.y + screen.height - shellSize.y;
        }
      }

      shell.setLocation(shellLoc);
    }
  }
예제 #29
0
  /**
   * Create contents of the view part.
   *
   * @throws GkException
   */
  @PostConstruct
  public void createControls(Composite parent, MPart part) throws GkException {
    parent.setLayout(new FormLayout());

    Composite composite = new Composite(parent, SWT.NONE);

    FormData fd_composite = new FormData();
    fd_composite.top = new FormAttachment(0);
    fd_composite.left = new FormAttachment(0);
    composite.setLayoutData(fd_composite);

    GridLayout gl_composite = new GridLayout(3, false);
    gl_composite.verticalSpacing = 3;
    gl_composite.marginHeight = 3;
    gl_composite.marginWidth = 3;
    composite.setLayout(gl_composite);

    Group grpManualJog = new Group(composite, SWT.NONE);
    grpManualJog.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    grpManualJog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    grpManualJog.setText("Manual jog");

    GridLayout gl_grpManualJog = new GridLayout(1, false);
    gl_grpManualJog.verticalSpacing = 2;
    gl_grpManualJog.marginWidth = 4;
    gl_grpManualJog.marginHeight = 2;
    gl_grpManualJog.horizontalSpacing = 4;
    grpManualJog.setLayout(gl_grpManualJog);

    if (getDataModel().isStepModeChoiceEnabled()) {
      btnIncrementalJog = new Button(grpManualJog, SWT.CHECK);
      btnIncrementalJog.setEnabled(false);
      btnIncrementalJog.setText("Incremental jog");
    }
    Composite composite_5 = new Composite(grpManualJog, SWT.NONE);
    composite_5.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    composite_5.setLayout(new GridLayout(3, false));

    if (getDataModel().isIncrementalJog()) {
      lblJogStep = new Label(composite_5, SWT.NONE);
      lblJogStep.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblJogStep.setText("Step :");

      jogStepSpinner = new Spinner(composite_5, SWT.BORDER);
      jogStepSpinner.setMaximum(100000);
      jogStepSpinner.setMinimum(1);
      jogStepSpinner.setDigits(GokoPreference.getInstance().getDigitCount());
      GridData gd_jogSpinner = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
      gd_jogSpinner.widthHint = 40;
      jogStepSpinner.setLayoutData(gd_jogSpinner);

      lblUnit = new Label(composite_5, SWT.NONE);

      lblUnit.setText("mm");
    }

    Label lblJogSpeed = new Label(composite_5, SWT.NONE);
    lblJogSpeed.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblJogSpeed.setBounds(0, 0, 55, 15);

    lblJogSpeed.setText("Speed :");

    jogSpeedSpinner = new Spinner(composite_5, SWT.BORDER);
    jogSpeedSpinner.setMaximum(10000);
    GridData gd_jogSpeedSpinner = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_jogSpeedSpinner.widthHint = 40;
    jogSpeedSpinner.setLayoutData(gd_jogSpeedSpinner);

    new Label(composite_5, SWT.NONE);
    Composite composite_4 = new Composite(grpManualJog, SWT.NONE);

    GridLayout gl_composite_4 = new GridLayout(2, false);
    gl_composite_4.marginWidth = 0;
    gl_composite_4.marginHeight = 0;
    gl_composite_4.horizontalSpacing = 0;
    gl_composite_4.verticalSpacing = 0;
    composite_4.setLayout(gl_composite_4);

    Composite composite_2 = new Composite(composite_4, SWT.NONE);
    composite_2.setSize(45, 125);
    GridLayout gl_composite_2 = new GridLayout(1, false);
    gl_composite_2.marginWidth = 2;
    gl_composite_2.verticalSpacing = 2;
    gl_composite_2.horizontalSpacing = 2;
    gl_composite_2.marginHeight = 2;
    composite_2.setLayout(gl_composite_2);

    btnJogZPos = new Button(composite_2, SWT.NONE);
    btnJogZPos.setText("+Z");
    GridData gd_btnJogZPos = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnJogZPos.heightHint = 55;
    gd_btnJogZPos.widthHint = 35;
    btnJogZPos.setLayoutData(gd_btnJogZPos);

    btnJogZNeg = new Button(composite_2, SWT.NONE);
    btnJogZNeg.setText("-Z");
    GridData gd_btnJogZNeg = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnJogZNeg.widthHint = 35;
    gd_btnJogZNeg.heightHint = 55;
    btnJogZNeg.setLayoutData(gd_btnJogZNeg);

    Composite composite_1 = new Composite(composite_4, SWT.NONE);

    GridLayout gl_composite_1 = new GridLayout(3, false);
    gl_composite_1.verticalSpacing = 2;
    gl_composite_1.marginWidth = 2;
    gl_composite_1.horizontalSpacing = 0;
    gl_composite_1.marginHeight = 0;
    composite_1.setLayout(gl_composite_1);
    new Label(composite_1, SWT.NONE);

    btnJogYPos = new Button(composite_1, SWT.NONE);
    btnJogYPos.setText("+Y");
    GridData gd_btnJogYPos = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnJogYPos.heightHint = 35;
    gd_btnJogYPos.widthHint = 35;
    btnJogYPos.setLayoutData(gd_btnJogYPos);
    new Label(composite_1, SWT.NONE);

    btnJogXNeg = new Button(composite_1, SWT.NONE);
    btnJogXNeg.setText("-X");
    GridData gd_btnJogXNeg = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnJogXNeg.widthHint = 35;
    gd_btnJogXNeg.heightHint = 35;
    btnJogXNeg.setLayoutData(gd_btnJogXNeg);
    new Label(composite_1, SWT.NONE);

    btnJogXPos = new Button(composite_1, SWT.NONE);
    btnJogXPos.setText("+X");
    GridData gd_btnJogXPos = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnJogXPos.heightHint = 35;
    gd_btnJogXPos.widthHint = 35;
    btnJogXPos.setLayoutData(gd_btnJogXPos);
    new Label(composite_1, SWT.NONE);

    btnJogYNeg = new Button(composite_1, SWT.NONE);
    btnJogYNeg.setText("-Y");
    GridData gd_btnJogYNeg = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnJogYNeg.widthHint = 35;
    gd_btnJogYNeg.heightHint = 35;
    btnJogYNeg.setLayoutData(gd_btnJogYNeg);
    new Label(composite_1, SWT.NONE);
    new Label(composite_4, SWT.NONE);

    composite_7 = new Composite(composite_4, SWT.NONE);
    composite_7.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    GridLayout gl_composite_7 = new GridLayout(2, true);
    gl_composite_7.verticalSpacing = 2;
    gl_composite_7.marginWidth = 2;
    gl_composite_7.marginHeight = 2;
    gl_composite_7.horizontalSpacing = 2;
    composite_7.setLayout(gl_composite_7);

    btnJogANeg = new Button(composite_7, SWT.NONE);
    GridData gd_btnANeg = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_btnANeg.heightHint = 35;
    btnJogANeg.setLayoutData(gd_btnANeg);

    btnJogANeg.setText("A-");

    btnJogAPos = new Button(composite_7, SWT.NONE);
    GridData gd_btnAPos = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_btnAPos.heightHint = 35;
    btnJogAPos.setLayoutData(gd_btnAPos);

    btnJogAPos.setText("A+");

    Composite composite_9 = new Composite(composite, SWT.NONE);
    GridLayout gl_composite_9 = new GridLayout(1, false);
    gl_composite_9.horizontalSpacing = 4;
    gl_composite_9.verticalSpacing = 4;
    gl_composite_9.marginWidth = 0;
    gl_composite_9.marginHeight = 0;
    composite_9.setLayout(gl_composite_9);
    composite_9.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));

    Group grpCommands = new Group(composite_9, SWT.NONE);
    grpCommands.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    grpCommands.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    GridLayout gl_grpCommands = new GridLayout(1, false);
    gl_grpCommands.verticalSpacing = 2;
    gl_grpCommands.marginWidth = 2;
    gl_grpCommands.marginHeight = 2;
    gl_grpCommands.horizontalSpacing = 2;
    grpCommands.setLayout(gl_grpCommands);
    grpCommands.setText("Homing");

    btnHome = new Button(grpCommands, SWT.NONE);
    btnHome.setText("Home");
    GridData gd_btnNewButton_1 = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_btnNewButton_1.widthHint = 140;
    gd_btnNewButton_1.heightHint = 35;
    btnHome.setLayoutData(gd_btnNewButton_1);

    Label label = new Label(grpCommands, SWT.SEPARATOR | SWT.HORIZONTAL);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    btnResetZero = new Button(grpCommands, SWT.NONE);
    btnResetZero.setText("Zero all axis");
    GridData gd_btnNewButton_2 = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_btnNewButton_2.heightHint = 35;
    btnResetZero.setLayoutData(gd_btnNewButton_2);

    Composite composite_6 = new Composite(grpCommands, SWT.NONE);
    composite_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    GridLayout gl_composite_6 = new GridLayout(4, true);
    gl_composite_6.horizontalSpacing = 1;
    gl_composite_6.marginHeight = 0;
    gl_composite_6.verticalSpacing = 2;
    gl_composite_6.marginWidth = 0;
    composite_6.setLayout(gl_composite_6);

    btnResetX = new Button(composite_6, SWT.NONE);
    btnResetX.setText("X");
    btnResetX.setFont(SWTResourceManager.getFont("Segoe UI", 8, SWT.NORMAL));
    GridData gd_btnResetX = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_btnResetX.heightHint = 30;
    btnResetX.setLayoutData(gd_btnResetX);

    btnResetY = new Button(composite_6, SWT.NONE);
    btnResetY.setText("Y");
    btnResetY.setFont(SWTResourceManager.getFont("Segoe UI", 8, SWT.NORMAL));
    GridData gd_btnNewButton = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_btnNewButton.heightHint = 30;
    btnResetY.setLayoutData(gd_btnNewButton);

    btnResetZ = new Button(composite_6, SWT.NONE);
    btnResetZ.setText("Z");
    btnResetZ.setFont(SWTResourceManager.getFont("Segoe UI", 8, SWT.NORMAL));
    GridData gd_btnNewButton_21 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btnNewButton_21.heightHint = 30;
    btnResetZ.setLayoutData(gd_btnNewButton_21);

    btnResetA = new Button(composite_6, SWT.NONE);
    GridData gd_btnResetA = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btnResetA.heightHint = 30;
    btnResetA.setLayoutData(gd_btnResetA);

    btnResetA.setText("A");

    grpCoordinatesSystem = new Group(composite_9, SWT.NONE);
    grpCoordinatesSystem.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    GridLayout gl_grpCoordinatesSystem = new GridLayout(1, false);
    gl_grpCoordinatesSystem.verticalSpacing = 2;
    gl_grpCoordinatesSystem.marginWidth = 2;
    gl_grpCoordinatesSystem.marginHeight = 2;
    gl_grpCoordinatesSystem.horizontalSpacing = 2;
    grpCoordinatesSystem.setLayout(gl_grpCoordinatesSystem);
    grpCoordinatesSystem.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    grpCoordinatesSystem.setText("Coordinates system");

    Composite composite_11 = new Composite(grpCoordinatesSystem, SWT.NONE);
    composite_11.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));

    GridLayout gl_composite_11 = new GridLayout(3, true);
    gl_composite_11.verticalSpacing = 2;
    gl_composite_11.horizontalSpacing = 2;
    gl_composite_11.marginWidth = 0;
    gl_composite_11.marginHeight = 0;
    composite_11.setLayout(gl_composite_11);

    btnCSG54 = new Button(composite_11, SWT.NONE);
    btnCSG54.setText("G54");
    btnCSG54.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              getController().setCoordinateSystem(EnumCoordinateSystem.G54);
            } catch (GkException e1) {
              displayMessage(e1);
            }
          }
        });
    GridData gd_btnCSG54 = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_btnCSG54.heightHint = 30;
    btnCSG54.setLayoutData(gd_btnCSG54);

    btnCSG55 = new Button(composite_11, SWT.NONE);
    btnCSG55.setText("G55");
    btnCSG55.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              getController().setCoordinateSystem(EnumCoordinateSystem.G55);
            } catch (GkException e1) {
              displayMessage(e1);
            }
          }
        });
    GridData gd_btnCSG55 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btnCSG55.heightHint = 30;
    btnCSG55.setLayoutData(gd_btnCSG55);

    btnCSG56 = new Button(composite_11, SWT.NONE);
    btnCSG56.setText("G56");
    btnCSG56.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              getController().setCoordinateSystem(EnumCoordinateSystem.G56);
            } catch (GkException e1) {
              displayMessage(e1);
            }
          }
        });
    GridData gd_btnCSG56 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btnCSG56.heightHint = 30;
    btnCSG56.setLayoutData(gd_btnCSG56);

    btnCSG57 = new Button(composite_11, SWT.NONE);
    btnCSG57.setText("G57");
    btnCSG57.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              getController().setCoordinateSystem(EnumCoordinateSystem.G57);
            } catch (GkException e1) {
              displayMessage(e1);
            }
          }
        });
    GridData gd_btnCSG57 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btnCSG57.heightHint = 30;
    btnCSG57.setLayoutData(gd_btnCSG57);

    btnCSG58 = new Button(composite_11, SWT.NONE);
    btnCSG58.setText("G58");
    btnCSG58.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              getController().setCoordinateSystem(EnumCoordinateSystem.G58);
            } catch (GkException e1) {
              displayMessage(e1);
            }
          }
        });
    GridData gd_btnCSG58 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btnCSG58.heightHint = 30;
    btnCSG58.setLayoutData(gd_btnCSG58);

    btnCSG59 = new Button(composite_11, SWT.NONE);
    btnCSG59.setText("G59");
    btnCSG59.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              getController().setCoordinateSystem(EnumCoordinateSystem.G59);
            } catch (GkException e1) {
              displayMessage(e1);
            }
          }
        });
    GridData gd_btnCSG59 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btnCSG59.heightHint = 30;
    btnCSG59.setLayoutData(gd_btnCSG59);

    Composite composite_12 = new Composite(grpCoordinatesSystem, SWT.NONE);
    composite_12.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1));

    GridLayout gl_composite_12 = new GridLayout(1, false);
    gl_composite_12.verticalSpacing = 2;
    gl_composite_12.marginHeight = 2;
    gl_composite_12.marginWidth = 0;
    gl_composite_12.horizontalSpacing = 0;
    composite_12.setLayout(gl_composite_12);

    btnResetCsZero = new Button(composite_12, SWT.NONE);
    btnResetCsZero.setText("Set current zero");
    btnResetCsZero.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              getController().zeroCoordinateSystem();
            } catch (GkException e1) {
              displayMessage(e1);
            }
          }
        });
    GridData gd_btnResetCsZero = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1);
    gd_btnResetCsZero.heightHint = 35;
    gd_btnNewButton_1.heightHint = 35;
    btnResetCsZero.setLayoutData(gd_btnResetCsZero);
    btnResetCsZero.setBounds(0, 0, 75, 25);

    composite_10 = new Composite(composite, SWT.NONE);
    GridData gd_composite_10 = new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1);
    gd_composite_10.widthHint = 140;
    composite_10.setLayoutData(gd_composite_10);

    GridLayout gl_composite_10 = new GridLayout(1, false);
    gl_composite_10.verticalSpacing = 4;
    gl_composite_10.marginWidth = 2;
    gl_composite_10.marginHeight = 2;
    gl_composite_10.horizontalSpacing = 4;
    composite_10.setLayout(gl_composite_10);

    Group grpControls = new Group(composite_10, SWT.NONE);
    grpControls.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    grpControls.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    grpControls.setLayout(new GridLayout(1, false));
    grpControls.setText("Controls");

    Composite composite_8 = new Composite(grpControls, SWT.NONE);
    composite_8.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    GridLayout gl_composite_8 = new GridLayout(2, true);
    gl_composite_8.verticalSpacing = 2;
    gl_composite_8.horizontalSpacing = 2;
    gl_composite_8.marginWidth = 0;
    gl_composite_8.marginHeight = 0;
    composite_8.setLayout(gl_composite_8);

    btnStart = new Button(composite_8, SWT.NONE);
    GridData gd_btnStart = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btnStart.heightHint = 35;
    btnStart.setLayoutData(gd_btnStart);

    btnStart.setText("Resume");

    btnPause = new Button(composite_8, SWT.NONE);
    GridData gd_btnPause = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_btnPause.heightHint = 35;
    btnPause.setLayoutData(gd_btnPause);

    btnPause.setText("Pause");

    btnStop = new Button(grpControls, SWT.NONE);
    btnStop.setImage(
        ResourceManager.getPluginImage("org.goko.tools.commandpanel", "icons/stop.png"));
    btnStop.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
    GridData gd_btnStop = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_btnStop.heightHint = 35;
    btnStop.setLayoutData(gd_btnStop);

    btnStop.setText("Stop");

    btnKillAlarm = new Button(grpControls, SWT.NONE);
    btnKillAlarm.setImage(
        ResourceManager.getPluginImage("org.goko.tools.commandpanel", "icons/bell--minus.png"));
    GridData gd_btnKillAlarm = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btnKillAlarm.heightHint = 35;
    btnKillAlarm.setLayoutData(gd_btnKillAlarm);

    btnKillAlarm.setText("Kill alarm");

    Group grpSpindle = new Group(composite_10, SWT.NONE);
    grpSpindle.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    grpSpindle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    grpSpindle.setLayout(new FillLayout(SWT.HORIZONTAL));
    grpSpindle.setText("Spindle");

    Composite composite_3 = new Composite(grpSpindle, SWT.NONE);

    GridLayout gl_composite_3 = new GridLayout(2, true);
    gl_composite_3.marginWidth = 2;
    gl_composite_3.horizontalSpacing = 2;
    gl_composite_3.marginHeight = 2;
    composite_3.setLayout(gl_composite_3);

    btnSpindleOn = new Button(composite_3, SWT.NONE);
    btnSpindleOn.setText("On");
    GridData gd_btnSpindleOn = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_btnSpindleOn.heightHint = 35;
    btnSpindleOn.setLayoutData(gd_btnSpindleOn);

    btnSpindleOff = new Button(composite_3, SWT.NONE);
    btnSpindleOff.setText("Off");
    GridData gd_btnSpindleOff = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btnSpindleOff.heightHint = 35;
    btnSpindleOff.setLayoutData(gd_btnSpindleOff);

    getController().initilizeValues();
    if (getDataModel().getJogSpeed() != null) {
      jogSpeedSpinner.setSelection(
          (int)
              (getDataModel().getJogSpeed().doubleValue()
                  * Math.pow(10, jogSpeedSpinner.getDigits())));
    }
    initCustomBindings(part);
    enableAdaptiveSpinner();
  }
  @Override
  public void createPartControl(Composite parent) {
    Activator.getDefault()
        .getPreferenceStore()
        .addPropertyChangeListener(
            new IPropertyChangeListener() {

              @Override
              public void propertyChange(PropertyChangeEvent event) {
                if (event.getProperty() == "selectedfont") {
                  FontData[] fonts = (FontData[]) event.getNewValue();

                  Font font = new Font(Display.getDefault(), fonts[0]);

                  setFont(newPatientVisitComposite, font);
                }
              }
            });

    final Composite composite = new Composite(parent, SWT.NONE);
    GridLayout compositeGL = new GridLayout(1, true);
    composite.setLayout(compositeGL);
    GridData compositeGD = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
    composite.setLayoutData(compositeGD);
    composite.setSize(composite.computeSize(parent.getSize().x, SWT.DEFAULT));

    scrolledComposite = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
    scrolledComposite.setLayoutData(data);
    scrolledComposite.setSize(scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    newPatientVisitComposite = new Composite(scrolledComposite, SWT.NULL);
    GridLayout newPatientVisitCompositeGL = new GridLayout(1, false);
    newPatientVisitComposite.setLayout(newPatientVisitCompositeGL);
    GridData newPatientVisitCompositeGD = new GridData(GridData.FILL_BOTH);
    newPatientVisitComposite.setLayoutData(newPatientVisitCompositeGD);

    Group newPatientGroup = new Group(newPatientVisitComposite, SWT.NULL);
    newPatientGroup.setText("New / Search patient");
    GridLayout newPatientGroupGL = new GridLayout(4, true);
    newPatientGroup.setLayout(newPatientGroupGL);
    GridData newPatientGroupGD = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
    newPatientGroupGD.verticalIndent = 0;
    newPatientGroup.setLayoutData(newPatientGroupGD);

    // new patient / search components
    Button radioButtonNewPatient = new Button(newPatientGroup, SWT.RADIO);
    radioButtonNewPatient.setText("New Patient");
    GridData radioBtnNewPatientGD = new GridData();
    radioBtnNewPatientGD.horizontalSpan = 2;
    radioButtonNewPatient.setLayoutData(radioBtnNewPatientGD);

    Button radioButtonSearch = new Button(newPatientGroup, SWT.RADIO);
    radioButtonSearch.setText("Search");
    GridData radioBtnSearchGD = new GridData();
    radioBtnSearchGD.horizontalSpan = 2;
    radioButtonSearch.setLayoutData(radioBtnSearchGD);

    Label lblName = new Label(newPatientGroup, SWT.NONE);
    lblName.setText("Name");
    GridData lblNameGD = new GridData();
    lblNameGD.horizontalSpan = 3;
    lblNameGD.verticalIndent = 5;
    lblName.setLayoutData(lblNameGD);

    Label lblId = new Label(newPatientGroup, SWT.NONE);
    lblId.setText("ID");
    GridData lblIdGD = new GridData();
    lblIdGD.horizontalSpan = 1;
    lblIdGD.verticalIndent = 5;
    lblId.setLayoutData(lblIdGD);

    textName = new Text(newPatientGroup, SWT.BORDER);
    GridData txtNameGD = new GridData(GridData.FILL_HORIZONTAL);
    txtNameGD.horizontalSpan = 3;
    txtNameGD.grabExcessHorizontalSpace = true;
    textName.setLayoutData(txtNameGD);

    textID = new Text(newPatientGroup, SWT.BORDER);
    GridData txtIDGD = new GridData(GridData.FILL_HORIZONTAL);
    txtIDGD.grabExcessHorizontalSpace = true;
    textID.setLayoutData(txtIDGD);

    Label lblStudyType = new Label(newPatientGroup, SWT.NONE);
    lblStudyType.setText("Study Type:");
    GridData lblStudyTypeGD = new GridData();
    lblStudyTypeGD.verticalIndent = 5;
    lblStudyType.setLayoutData(lblStudyTypeGD);

    final Combo selectStudyTypeForSearchingCombo = new Combo(newPatientGroup, SWT.READ_ONLY);
    GridData selectStudyTypeForSearchingComboGD = new GridData(GridData.FILL_HORIZONTAL);
    selectStudyTypeForSearchingComboGD.horizontalSpan = 2;
    selectStudyTypeForSearchingComboGD.verticalIndent = 5;
    selectStudyTypeForSearchingComboGD.grabExcessHorizontalSpace = true;
    selectStudyTypeForSearchingCombo.setLayoutData(selectStudyTypeForSearchingComboGD);

    final Button buttonSaveSearch = new Button(newPatientGroup, SWT.NONE);
    GridData buttonSaveSearchGD = new GridData(GridData.FILL_HORIZONTAL);
    buttonSaveSearchGD.horizontalSpan = 1;
    buttonSaveSearchGD.verticalIndent = 5;
    buttonSaveSearchGD.grabExcessHorizontalSpace = true;
    buttonSaveSearch.setLayoutData(buttonSaveSearchGD);
    buttonSaveSearch.setText("Save");

    // search result components
    final TableViewer tableViewer =
        new TableViewer(newPatientGroup, SWT.BORDER | SWT.FULL_SELECTION);
    tableViewer.setColumnProperties(new String[] {"Name", "ID"});
    Table table = tableViewer.getTable();
    GridData tableGD = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    tableGD.grabExcessHorizontalSpace = true;
    tableGD.horizontalSpan = 4;
    tableGD.verticalIndent = 10;
    tableGD.heightHint = 125;
    table.setLayoutData(tableGD);

    // select study combo
    Label lblSelectStudy = new Label(newPatientGroup, SWT.NONE);
    lblSelectStudy.setText("Select Study");
    GridData lblSelectStudyGD = new GridData();
    lblSelectStudyGD.verticalIndent = 5;
    lblSelectStudy.setLayoutData(lblSelectStudyGD);

    final ComboViewer selectStudyFromSearchResultsComboViewer =
        new ComboViewer(newPatientGroup, SWT.READ_ONLY);
    GridData selectStudyFromSearchResultsComboViewerGD = new GridData(GridData.FILL_HORIZONTAL);
    selectStudyFromSearchResultsComboViewerGD.horizontalSpan = 3;
    selectStudyFromSearchResultsComboViewerGD.verticalIndent = 5;
    selectStudyFromSearchResultsComboViewerGD.grabExcessHorizontalSpace = true;
    selectStudyFromSearchResultsComboViewer
        .getControl()
        .setLayoutData(selectStudyFromSearchResultsComboViewerGD);

    // select series combo
    Label lblSelectSeries = new Label(newPatientGroup, SWT.NONE);
    lblSelectSeries.setText("Select Series");
    GridData lblSelectSeriesGD = new GridData();
    lblSelectSeriesGD.verticalIndent = 5;
    lblSelectSeries.setLayoutData(lblSelectSeriesGD);

    final ComboViewer selectSeriesComboViewer = new ComboViewer(newPatientGroup, SWT.READ_ONLY);
    GridData selectSeriesComboViewerGD = new GridData(GridData.FILL_HORIZONTAL);
    selectSeriesComboViewerGD.horizontalSpan = 3;
    selectSeriesComboViewerGD.verticalIndent = 5;
    selectSeriesComboViewerGD.grabExcessHorizontalSpace = true;
    selectSeriesComboViewer.getCombo().setLayoutData(selectSeriesComboViewerGD);

    // new study controls
    Group newStudyGroup = new Group(newPatientVisitComposite, SWT.NULL);
    newStudyGroup.setText("New Study");
    GridLayout newStudyGroupGL = new GridLayout(4, true);
    newStudyGroup.setLayout(newStudyGroupGL);
    GridData newStudyGroupGD = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
    newStudyGroupGD.verticalIndent = 10;
    newStudyGroup.setLayoutData(newStudyGroupGD);

    Label lblNewStudyName = new Label(newStudyGroup, SWT.NONE);
    lblNewStudyName.setText("Study Name");
    GridData lblNewStudyNameGD = new GridData();
    lblNewStudyNameGD.verticalIndent = 5;
    lblNewStudyName.setLayoutData(lblNewStudyNameGD);

    final Text newStudyNameText = new Text(newStudyGroup, SWT.BORDER);
    GridData newStudyNameTextGD = new GridData(GridData.FILL_HORIZONTAL);
    newStudyNameTextGD.horizontalSpan = 3;
    newStudyNameTextGD.verticalIndent = 5;
    newStudyNameTextGD.grabExcessHorizontalSpace = true;
    newStudyNameText.setLayoutData(newStudyNameTextGD);

    Label lblNewStudyType = new Label(newStudyGroup, SWT.NONE);
    lblNewStudyType.setText("Study Type:");
    GridData lblNewStudyTypeGD = new GridData();
    lblNewStudyTypeGD.verticalIndent = 5;
    lblNewStudyType.setLayoutData(lblNewStudyTypeGD);

    final Combo selectNewStudyTypeCombo = new Combo(newStudyGroup, SWT.READ_ONLY);
    GridData selectNewStudyTypeComboGD = new GridData(GridData.FILL_HORIZONTAL);
    selectNewStudyTypeComboGD.horizontalSpan = 2;
    selectNewStudyTypeComboGD.verticalIndent = 5;
    selectNewStudyTypeComboGD.grabExcessHorizontalSpace = true;
    selectNewStudyTypeCombo.setLayoutData(selectNewStudyTypeComboGD);

    final DateTime newStudyDateTimeDate =
        new DateTime(newStudyGroup, SWT.BORDER | SWT.DATE | SWT.DROP_DOWN);
    GridData dateTimeDateGD = new GridData(GridData.FILL_HORIZONTAL);
    dateTimeDateGD.grabExcessHorizontalSpace = true;
    dateTimeDateGD.verticalIndent = 5;
    newStudyDateTimeDate.setLayoutData(dateTimeDateGD);

    final Button btnSaveStudy = new Button(newStudyGroup, SWT.NONE);
    GridData btnSaveStudyGD = new GridData(GridData.FILL_HORIZONTAL);
    btnSaveStudyGD.horizontalSpan = 1;
    btnSaveStudyGD.verticalIndent = 5;
    btnSaveStudyGD.grabExcessHorizontalSpace = true;
    btnSaveStudy.setLayoutData(btnSaveStudyGD);
    btnSaveStudy.setText("Save Study");

    // new series controls
    Group newSeriesGroup = new Group(newPatientVisitComposite, SWT.NULL);
    newSeriesGroup.setText("New Series");
    GridLayout newSeriesGroupGL = new GridLayout(4, true);
    newSeriesGroup.setLayout(newSeriesGroupGL);
    GridData newSeriesGroupGD = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
    newSeriesGroupGD.verticalIndent = 10;
    newSeriesGroup.setLayoutData(newSeriesGroupGD);

    Label lblNewSeriesName = new Label(newSeriesGroup, SWT.NONE);
    lblNewSeriesName.setText("Series Name");
    GridData lblNewSeriesNameGD = new GridData();
    lblNewSeriesNameGD.verticalIndent = 5;
    lblNewSeriesName.setLayoutData(lblNewSeriesNameGD);

    final Text newSeriesNameText = new Text(newSeriesGroup, SWT.BORDER);
    GridData newSeriesNameTextGD = new GridData(GridData.FILL_HORIZONTAL);
    newSeriesNameTextGD.horizontalSpan = 3;
    newSeriesNameTextGD.verticalIndent = 5;
    newSeriesNameTextGD.grabExcessHorizontalSpace = true;
    newSeriesNameText.setLayoutData(newSeriesNameTextGD);

    Label lblNewSeriesTime = new Label(newSeriesGroup, SWT.NONE);
    lblNewSeriesTime.setText("Series Date Time");
    GridData lblNewSeriesTimeGD = new GridData();
    lblNewSeriesTimeGD.verticalIndent = 5;
    lblNewSeriesTime.setLayoutData(lblNewSeriesTimeGD);

    final DateTime newSeriesDateTimeDate =
        new DateTime(newSeriesGroup, SWT.BORDER | SWT.DATE | SWT.DROP_DOWN);
    GridData seriesDateGD = new GridData();
    seriesDateGD.horizontalSpan = 1;
    //		seriesDateGD.grabExcessHorizontalSpace = true;
    seriesDateGD.verticalIndent = 5;
    newSeriesDateTimeDate.setLayoutData(seriesDateGD);

    final DateTime newSeriesDateTimeTime =
        new DateTime(newSeriesGroup, SWT.BORDER | SWT.TIME | SWT.DROP_DOWN);
    GridData seriesTimeGD = new GridData();
    seriesTimeGD.horizontalSpan = 1;
    //		seriesTimeGD.grabExcessHorizontalSpace = true;
    seriesTimeGD.verticalIndent = 5;
    newSeriesDateTimeTime.setLayoutData(seriesTimeGD);

    Label placeHolder = new Label(newSeriesGroup, SWT.NONE);
    GridData placeHolderGD = new GridData(GridData.FILL_HORIZONTAL);
    placeHolderGD.horizontalSpan = 1;
    placeHolderGD.grabExcessHorizontalSpace = true;
    placeHolder.setLayoutData(placeHolderGD);

    Label lblNewSeriesDescription = new Label(newSeriesGroup, SWT.NONE);
    lblNewSeriesDescription.setText("Series Description");
    GridData lblNewSeriesDescriptionGD = new GridData();
    lblNewSeriesDescriptionGD.grabExcessVerticalSpace = true;
    lblNewSeriesDescriptionGD.verticalSpan = 15;
    lblNewSeriesDescriptionGD.verticalAlignment = SWT.BEGINNING;
    lblNewSeriesDescriptionGD.verticalIndent = 5;
    lblNewSeriesDescription.setLayoutData(lblNewSeriesDescriptionGD);

    final Text newSeriesNameDescription =
        new Text(newSeriesGroup, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    GridData newSeriesNameDescriptionGD =
        new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    newSeriesNameDescriptionGD.horizontalSpan = 3;
    newSeriesNameDescriptionGD.verticalIndent = 5;
    newSeriesNameDescriptionGD.verticalSpan = 15;
    newSeriesNameDescriptionGD.grabExcessHorizontalSpace = true;
    newSeriesNameDescription.setLayoutData(newSeriesNameDescriptionGD);

    Label lblPhotosLocation = new Label(newSeriesGroup, SWT.NONE);
    lblPhotosLocation.setText("Photos Location");
    GridData lblPhotosLocationGD = new GridData();
    lblPhotosLocationGD.horizontalSpan = 1;
    lblPhotosLocationGD.verticalIndent = 5;
    lblPhotosLocation.setLayoutData(lblPhotosLocationGD);

    final Text textPhotosLocation = new Text(newSeriesGroup, SWT.BORDER);
    GridData textPhotosLocationGD = new GridData(GridData.FILL_HORIZONTAL);
    textPhotosLocationGD.horizontalSpan = 1;
    textPhotosLocationGD.verticalIndent = 5;
    textPhotosLocationGD.grabExcessHorizontalSpace = true;
    textPhotosLocation.setLayoutData(textPhotosLocationGD);

    final Button buttonBrowse = new Button(newSeriesGroup, SWT.NONE);
    GridData btnBrowseGD = new GridData(GridData.FILL_HORIZONTAL);
    btnBrowseGD.horizontalSpan = 1;
    btnBrowseGD.verticalIndent = 5;
    btnBrowseGD.grabExcessHorizontalSpace = true;
    buttonBrowse.setLayoutData(btnBrowseGD);
    buttonBrowse.setText("Browse");

    final Button buttonLoad = new Button(newSeriesGroup, SWT.NONE);
    GridData btnLoadGD = new GridData(GridData.FILL_HORIZONTAL);
    btnLoadGD.horizontalSpan = 1;
    btnLoadGD.verticalIndent = 5;
    btnLoadGD.grabExcessHorizontalSpace = true;
    buttonLoad.setLayoutData(btnLoadGD);
    buttonLoad.setText("Load");

    final Button buttnoSaveSeries = new Button(newSeriesGroup, SWT.NONE);
    GridData btnSaveSeriesGD = new GridData(GridData.FILL_HORIZONTAL);
    btnSaveSeriesGD.horizontalSpan = 1;
    btnSaveSeriesGD.verticalIndent = 5;
    btnSaveSeriesGD.grabExcessHorizontalSpace = true;
    buttnoSaveSeries.setLayoutData(btnSaveSeriesGD);
    buttnoSaveSeries.setText("Save Series");

    // set defaults
    radioButtonNewPatient.setSelection(true);
    selectStudyTypeForSearchingCombo.setEnabled(false);
    tableViewer.getTable().setEnabled(false);
    selectStudyFromSearchResultsComboViewer.getControl().setEnabled(false);
    selectSeriesComboViewer.getControl().setEnabled(false);

    // set size
    Point size = newPatientVisitComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    scrolledComposite.setMinSize(size);
    scrolledComposite.setContent(newPatientVisitComposite);
    scrolledComposite.layout(true);

    scrolledComposite.addListener(
        SWT.Activate,
        new Listener() {
          public void handleEvent(Event e) {
            scrolledComposite.setFocus();
          }
        });

    final IPatientService pService =
        (IPatientService) PlatformUI.getWorkbench().getService(IPatientService.class);

    // browse button clicked
    buttonBrowse.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            final FileDialog dialog = new FileDialog(getSite().getShell(), SWT.OPEN | SWT.MULTI);
            final String lastSelectedFilePath = dialog.open();
            // create the structure for files
            Display.getDefault()
                .asyncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        String[] selectedFileNames = dialog.getFileNames();
                        if (selectedFileNames != null && selectedFileNames.length > 0) {
                          textPhotosLocation.setText(lastSelectedFilePath);
                          String dirName =
                              lastSelectedFilePath.substring(
                                  0, lastSelectedFilePath.lastIndexOf(File.separator) + 1);
                          if (loadedPhotosList != null) {
                            loadedPhotosList.clear();
                          } else {
                            loadedPhotosList = new ArrayList<String>();
                          }
                          for (String selectedFileName : selectedFileNames) {
                            loadedPhotosList.add(dirName.concat(selectedFileName));
                          }
                        }
                      }
                    });
          }
        });

    // load button clicked
    buttonLoad.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            loadPhotos();
          }
        });

    // save radio selected
    radioButtonNewPatient.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            selectStudyTypeForSearchingCombo.setEnabled(false);
            tableViewer.getTable().setEnabled(false);
            selectStudyFromSearchResultsComboViewer.getControl().setEnabled(false);
            selectSeriesComboViewer.getControl().setEnabled(false);
            buttonSaveSearch.setText("Save");
          }
        });

    // search radio selected
    radioButtonSearch.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            selectStudyTypeForSearchingCombo.setEnabled(true);
            tableViewer.getTable().setEnabled(true);
            selectStudyFromSearchResultsComboViewer.getControl().setEnabled(true);
            selectSeriesComboViewer.getControl().setEnabled(true);
            buttonSaveSearch.setText("Search");
          }
        });

    buttonSaveSearch.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (buttonSaveSearch.getText().equals("Save")) {
              String newPatientName = textName.getText();
              String ID = textID.getText();

              if (newPatientName == null || "".equals(newPatientName)) {
                Util.showMessage("Name can't be empty!");
                return;
              }

              if (ID == null || "".equals(ID)) {
                ID = String.valueOf(UUID.randomUUID().getMostSignificantBits());
              }

              IPatient newPatient = PatientFactory.getInstance().create(ID, newPatientName, null);

              //					IPatientService pservice = Activator.getDefault().getPatientService();
              if (pService != null) {
                IStatus status = null;
                try {
                  status = pService.saveNewPatient(newPatient);
                } catch (IOException e1) {
                  e1.printStackTrace();
                }

                if (status == Status.OK_STATUS) {
                  //							StatusLineContribution slc = (StatusLineContribution)
                  // Activator.getDefault().getStatusItem();
                  //							slc.setText("Active Patient : " + newPatient.getName());
                  //							slc.setVisible(true);
                  updateStatus("Active Patient : " + newPatient.getName());

                  activePatient = newPatient;

                  textName.setText("");
                  textID.setText("");

                } else {
                  // XXX log
                }
              } else {
                Util.showMessage("Patient service is null :-(");
              }
            } else {
              String searchName = textName.getText();
              String searchID = textID.getText();
              //					IPatientService pService = Activator.getDefault().getPatientService();

              try {
                List<IPatient> patientSearchResults = pService.searchPatients(searchName, searchID);

                if (patientSearchResults != null) {

                  tableViewer.setContentProvider(new ArrayContentProvider());
                  tableViewer.getTable().setLinesVisible(true);
                  tableViewer.getTable().setHeaderVisible(true);
                  // create columns
                  createPatientColumns(tableViewer);

                  // set input
                  tableViewer.setInput(patientSearchResults);

                  tableViewer.refresh();
                } else {
                  // XXX log and inform user null was returned
                }
              } catch (Exception e1) {
                //						StatusLineContribution slc = (StatusLineContribution)
                // Activator.getDefault().getStatusItem();
                //						slc.setText("Active Patient : " + e1.getMessage());
                //						slc.setVisible(true);
                updateStatus("Active Patient : " + e1.getMessage());
              }
            }
          }
        });

    btnSaveStudy.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IStudy newStudy = StudyFactory.getInstance().create(null);
            newStudy.setStudyName(newStudyNameText.getText());

            // get selected date for new study
            Calendar calendar = Calendar.getInstance();
            calendar.set(Calendar.DAY_OF_MONTH, newStudyDateTimeDate.getDay());
            calendar.set(Calendar.MONTH, newStudyDateTimeDate.getMonth());
            calendar.set(Calendar.YEAR, newStudyDateTimeDate.getYear());

            Date studyDate = calendar.getTime();

            newStudy.setStudyDate(studyDate);
            newStudy.setStudyType(selectNewStudyTypeCombo.getText());
            newStudy.setPatientID(activePatient.getId());
            newStudy.setNumberOfSeries((Integer) 0);
            newStudy.setStudyID(String.valueOf(UUID.randomUUID().getLeastSignificantBits()));

            //				IPatientService pService = Activator.getDefault().getPatientService();
            IStatus status = null;
            try {
              status = pService.saveNewStudy(newStudy);
            } catch (IOException e1) {
              e1.printStackTrace();
            }

            if (status == Status.OK_STATUS) {
              activeStudy = newStudy;

              String statusLineText =
                  "Active Patient : "
                      + activePatient.getName()
                      + " Active Study : "
                      + activeStudy.toString();

              updateStatus(statusLineText);

              //					StatusLineContribution slc = (StatusLineContribution)
              // Activator.getDefault().getStatusItem();
              //					slc.setText(statusLineText);
              //					slc.setVisible(true);

              newStudyNameText.setText("");
              selectNewStudyTypeCombo.clearSelection();
            } else {
              // XXX log
            }
          }
        });

    buttnoSaveSeries.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {

            ISeries newSeries = SeriesFactory.getInstance().create(null);
            newSeries.setSeriesName(newSeriesNameText.getText());
            newSeries.setNotes(newSeriesNameDescription.getText());
            newSeries.setParentStudyID("");
            newSeries.setPhotos(selectedPhotosFilesList);
            newSeries.setSeriesID(String.valueOf(UUID.randomUUID().getMostSignificantBits()));
            newSeries.setParentStudyID(activeStudy.getStudyID());

            // get selected date for new study
            Calendar calendar = Calendar.getInstance();
            //				calendar.set(Calendar.DAY_OF_MONTH, newSeriesDateTimeTime.getDay());
            //				calendar.set(Calendar.MONTH, newSeriesDateTimeTime.getMonth());
            //				calendar.set(Calendar.YEAR, newSeriesDateTimeTime.getYear());

            calendar.set(Calendar.DAY_OF_MONTH, newSeriesDateTimeDate.getDay());
            calendar.set(Calendar.MONTH, newSeriesDateTimeDate.getMonth());
            calendar.set(Calendar.YEAR, newSeriesDateTimeDate.getYear());

            calendar.set(Calendar.HOUR_OF_DAY, newSeriesDateTimeTime.getHours());
            calendar.set(Calendar.MINUTE, newSeriesDateTimeTime.getMinutes());
            calendar.set(Calendar.SECOND, newSeriesDateTimeTime.getSeconds());

            newSeries.setSeriesTime(calendar.getTime());

            //				IPatientService pService = Activator.getDefault().getPatientService();
            IStatus status = null;
            try {
              status = pService.saveNewSeries(newSeries);
            } catch (IOException e1) {
              e1.printStackTrace();
            }

            if (status == Status.OK_STATUS) {
              // clear UI fileds
              newSeriesNameText.setText("");
              newSeriesNameDescription.setText("");
              textPhotosLocation.setText("");

            } else {
              // XXX log
            }
          };
        });

    tableViewer
        .getTable()
        .addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
                if (selection.getFirstElement() instanceof IPatient) {
                  IPatient selectedPatient = (IPatient) selection.getFirstElement();

                  activePatient = selectedPatient;

                  //					StatusLineContribution slc = (StatusLineContribution)
                  // Activator.getDefault().getStatusItem();
                  //					slc.setText("Active Patient : " + activePatient.getName());
                  //					slc.setVisible(true);

                  updateStatus("Active Patient : " + activePatient.getName());

                  selectSeriesComboViewer.getCombo().clearSelection();
                  selectSeriesComboViewer.getCombo().removeAll();

                  // get all studies of this patient
                  //					IPatientService pService = Activator.getDefault().getPatientService();
                  try {
                    List<IStudy> studiesForSelectedpatient =
                        pService.getStudiesForPatient(selectedPatient);
                    selectStudyFromSearchResultsComboViewer.setContentProvider(
                        ArrayContentProvider.getInstance());
                    selectStudyFromSearchResultsComboViewer.setLabelProvider(
                        new LabelProvider() {
                          public String getText(Object element) {
                            return ((IStudy) element).toString();
                          };
                        });
                    selectStudyFromSearchResultsComboViewer.setInput(studiesForSelectedpatient);
                  } catch (Exception e1) {
                    updateStatus(e1.getMessage());
                    //						slc.setText(e1.getMessage());
                    //						slc.setVisible(true);
                  }
                }
              }
            });

    selectStudyFromSearchResultsComboViewer
        .getCombo()
        .addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                StructuredSelection selection =
                    (StructuredSelection) selectStudyFromSearchResultsComboViewer.getSelection();
                if (selection.getFirstElement() instanceof IStudy) {
                  IStudy selectedStudy = (IStudy) selection.getFirstElement();
                  activeStudy = selectedStudy;
                  //					StatusLineContribution slc = (StatusLineContribution)
                  // Activator.getDefault().getStatusItem();
                  //					slc.setText("Active Patient : " + activePatient.getName() +
                  //								  " Active Study : " + activeStudy.toString());
                  //					slc.setVisible(true);
                  updateStatus(
                      "Active Patient : "
                          + activePatient.getName()
                          + " Active Study : "
                          + activeStudy.toString());

                  // get all series for this study
                  //					IPatientService pService = Activator.getDefault().getPatientService();
                  try {
                    List<ISeries> seriesForSelectedStudy =
                        pService.getSeriesForStudy(selectedStudy);
                    selectSeriesComboViewer.setContentProvider(ArrayContentProvider.getInstance());
                    selectSeriesComboViewer.setLabelProvider(
                        new LabelProvider() {
                          public String getText(Object element) {
                            return ((ISeries) element).toString();
                          };
                        });
                    selectSeriesComboViewer.setInput(seriesForSelectedStudy);
                    selectSeriesComboViewer.refresh();
                  } catch (Exception e1) {
                    //						slc.setText(e1.getMessage());
                    updateStatus(e1.getMessage());
                  }
                }
              }
            });

    selectSeriesComboViewer
        .getCombo()
        .addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                StructuredSelection selection =
                    (StructuredSelection) selectSeriesComboViewer.getSelection();
                if (selection.getFirstElement() instanceof ISeries) {
                  ISeries selectedSeries = (ISeries) selection.getFirstElement();

                  if (loadedPhotosList != null) {
                    loadedPhotosList.clear();
                  } else {
                    loadedPhotosList = new ArrayList<String>();
                  }

                  // load photos for selected series
                  for (Object selectedFileName : selectedSeries.getPhotos()) {
                    loadedPhotosList.add(selectedFileName.toString());
                  }
                  loadPhotos();
                }
              }
            });
  }