/**
   * This method generates the dependency graph and sets an {@link EditorPart} to show the graph's
   * window.
   */
  @Override
  public void createPartControl(final Composite parent) {
    initGeneratorAndHandler(parent);
    editorComposite = new Composite(parent, SWT.NO_BACKGROUND | SWT.EMBEDDED);
    window = SWT_AWT.new_Frame(editorComposite);
    windowSize = new Dimension(parent.getSize().x, parent.getSize().y);

    parent.addListener(
        SWT.Resize,
        new Listener() {
          @Override
          public void handleEvent(org.eclipse.swt.widgets.Event event) {
            Point tmpSize = parent.getSize();
            windowSize = new Dimension(tmpSize.x, tmpSize.y);
            if (handler != null) {
              handler.changeWindowSize(windowSize);
            }
            if (window != null && drawArea != null) {
              drawArea.setPreferredSize(windowSize);
              window.setPreferredSize(windowSize);
              window.repaint();
            }
          }
        });

    project = ((IFileEditorInput) getEditorInput()).getFile().getProject();
    setPartName(getPartName() + " - " + project.getName());

    // get a reference to the satellite viewer
    satView =
        (SatelliteView)
            PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow()
                .getActivePage()
                .findView(SatelliteView.ID);
    if (satView != null) {
      satView.setEditor(this);
    } else {
      try {
        satView =
            (SatelliteView)
                PlatformUI.getWorkbench()
                    .getActiveWorkbenchWindow()
                    .getActivePage()
                    .showView(SatelliteView.ID);
        satView.setEditor(this);
      } catch (PartInitException e) {
        errorHandler.reportException("Error while opening the view", e);
      }
    }
    initWindow();
  }
 public Point getSize() {
   Point result = null;
   if (content != null) {
     result = content.getSize();
   }
   return result;
 }
  private void showStandaloneViewMenu(
      ExecutionEvent event, MPart model, MMenu menuModel, Composite partContainer) {
    Shell shell = partContainer.getShell();
    Menu menu = (Menu) menuModel.getWidget();
    if (menu == null) {
      IPresentationEngine engine =
          (IPresentationEngine) HandlerUtil.getVariable(event, IPresentationEngine.class.getName());
      menu = (Menu) engine.createGui(menuModel, shell, model.getContext());
      if (menu != null) {
        final Menu tmpMenu = menu;
        partContainer.addDisposeListener(
            new DisposeListener() {
              public void widgetDisposed(DisposeEvent e) {
                tmpMenu.dispose();
              }
            });
      }
    }

    Display display = menu.getDisplay();
    Point location = display.map(partContainer, null, partContainer.getLocation());
    Point size = partContainer.getSize();
    menu.setLocation(location.x + size.x, location.y);
    menu.setVisible(true);

    while (!menu.isDisposed() && menu.isVisible()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    if (!(menu.getData() instanceof MenuManager)) {
      menu.dispose();
    }
  }
  void resize() {
    Point size = comp.getSize();
    Image oldBackgroundImage = backgroundImage;
    backgroundImage = new Image(comp.getDisplay(), size.x, size.y);
    GC gc = new GC(backgroundImage);
    comp.getParent().drawBackground(gc, 0, 0, size.x, size.y, 0, 0);
    Color background = comp.getBackground();
    Color border = comp.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
    RGB backgroundRGB = background.getRGB();
    // TODO naive and hard coded, doesn't deal with high contrast, etc.
    Color gradientTop =
        new Color(
            comp.getDisplay(),
            backgroundRGB.red + 12,
            backgroundRGB.green + 10,
            backgroundRGB.blue + 10);
    int h = size.y;
    int curveStart = 0;
    int curve_width = 5;

    int[] curve =
        new int[] {
          0, h, 1, h, 2, h - 1, 3, h - 2, 3, 2, 4, 1, 5, 0,
        };
    int[] line1 = new int[curve.length + 4];
    int index = 0;
    int x = curveStart;
    line1[index++] = x + 1;
    line1[index++] = h;
    for (int i = 0; i < curve.length / 2; i++) {
      line1[index++] = x + curve[2 * i];
      line1[index++] = curve[2 * i + 1];
    }
    line1[index++] = x + curve_width;
    line1[index++] = 0;

    int[] line2 = new int[line1.length];
    index = 0;
    for (int i = 0; i < line1.length / 2; i++) {
      line2[index] = line1[index++] - 1;
      line2[index] = line1[index++];
    }

    // custom gradient
    gc.setForeground(gradientTop);
    gc.setBackground(background);
    gc.drawLine(4, 0, size.x, 0);
    gc.drawLine(3, 1, size.x, 1);
    gc.fillGradientRectangle(2, 2, size.x - 2, size.y - 3, true);
    gc.setForeground(background);
    gc.drawLine(2, size.y - 1, size.x, size.y - 1);
    gradientTop.dispose();

    gc.setForeground(border);
    gc.drawPolyline(line2);
    gc.dispose();
    comp.setBackgroundImage(backgroundImage);
    if (oldBackgroundImage != null) oldBackgroundImage.dispose();
  }
  private void handleOptionSelection() {
    // Get the selection from the tree list
    if (fTree == null) return;
    IStructuredSelection selection = (IStructuredSelection) fTree.getSelection();
    ToolListElement element = (ToolListElement) selection.getFirstElement();
    if (element != null) {
      displayPageForElement(element);
    }

    ScrollBar sb = containerSC.getHorizontalBar();
    if (sb != null && sb.isVisible()) {
      settingsPageContainer.pack(true);
      containerSC.setMinSize(settingsPageContainer.getSize());
      ((AbstractPage) page).resize();
    }
  }
    public void mouseDown(MouseEvent e) {
      Composite parent = fControl.getParent();

      Point s = parent.getSize();
      Point as = fAncestorLabel.getSize();
      Point ys = fLeftLabel.getSize();
      Point ms = fRightLabel.getSize();

      fWidth1 = ys.x;
      fWidth2 = ms.x;
      fHeight1 = fLeftLabel.getLocation().y - as.y;
      fHeight2 = s.y - (fLeftLabel.getLocation().y + ys.y);

      fX = e.x;
      fY = e.y;
      fIsDown = true;
    }
  void paint(PaintEvent e) {
    GC gc = e.gc;
    Point size = comp.getSize();
    if (curveColor == null) curveColor = e.display.getSystemColor(SWT.COLOR_BLACK);
    int h = size.y;
    int[] simpleCurve = new int[] {0, h - 1, 1, h - 1, 2, h - 2, 2, 1, 3, 0};
    // draw border
    gc.setForeground(curveColor);
    gc.setAdvanced(true);
    if (gc.getAdvanced()) {
      gc.setAntialias(SWT.ON);
    }
    gc.drawPolyline(simpleCurve);

    Rectangle bounds = ((Control) e.widget).getBounds();
    bounds.x = bounds.y = 0;
    Region r = new Region();
    r.add(bounds);
    int[] simpleCurveClose = new int[simpleCurve.length + 4];
    System.arraycopy(simpleCurve, 0, simpleCurveClose, 0, simpleCurve.length);
    int index = simpleCurve.length;
    simpleCurveClose[index++] = bounds.width;
    simpleCurveClose[index++] = 0;
    simpleCurveClose[index++] = bounds.width;
    simpleCurveClose[index++] = bounds.height;
    r.subtract(simpleCurveClose);
    Region clipping = new Region();
    gc.getClipping(clipping);
    r.intersect(clipping);
    gc.setClipping(r);
    Image b = toolParent.getBackgroundImage();
    if (b != null && !b.isDisposed()) gc.drawImage(b, 0, 0);

    r.dispose();
    clipping.dispose();
    // // gc.fillRectangle(bounds);
    // Rectangle mappedBounds = e.display.map(comp, comp.getParent(),
    // bounds);
    // ((Composite) toolParent).drawBackground(gc, bounds.x, bounds.y,
    // bounds.width,
    // bounds.height, mappedBounds.x, mappedBounds.y);

  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
   * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
   */
  @Override
  public int estimateRowSize(Composite subComposite, IElementParameter param) {
    if (!estimateInitialized) {
      DecoratedField dField =
          new DecoratedField(
              subComposite,
              SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP,
              new TextControlCreator());
      Text text = (Text) dField.getControl();
      FormData d = (FormData) text.getLayoutData();
      d.height = text.getLineHeight();
      text.getParent().setSize(subComposite.getSize().x, text.getLineHeight());
      Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
      rowSizeByLine = text.getLineHeight();
      dField.getLayoutControl().dispose();
      rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine);
      estimateInitialized = true;
    }

    return rowSizeFixed + (rowSizeByLine * param.getNbLines());
  }
 public Point getSize() {
   return footerCenter.getSize();
 }
Exemple #10
0
 // Private
 private void populateScreenComposite() {
   f =
       new ScaledWidgetFactory(
           this.getClass(), screenComposite.getSize(), REFERENCE_HEIGHT, REFERENCE_WIDTH);
   screenComposite.setBackgroundImage(
       f.getSizedImageForWidget(RADIO_PANEL_IMAGE, screenComposite));
   screenComposite.setBackgroundMode(SWT.INHERIT_FORCE);
   tuneDownButton =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           54,
           127,
           65,
           75,
           TUNE_DEC_UP_IMAGE,
           TUNE_DEC_DOWN_IMAGE,
           true,
           this);
   tuneUpButton =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           53,
           53,
           65,
           75,
           TUNE_INC_UP_IMAGE,
           TUNE_INC_DOWN_IMAGE,
           true,
           this);
   bandButton =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           121,
           168,
           182,
           33,
           BAND_UP_IMAGE,
           BAND_DOWN_IMAGE,
           false,
           this);
   seekDownButton =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           305,
           127,
           65,
           75,
           SEEK_DEC_UP_IMAGE,
           SEEK_DEC_DOWN_IMAGE,
           true,
           this);
   seekUpButton =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           305,
           52,
           65,
           75,
           SEEK_INC_UP_IMAGE,
           SEEK_INC_DOWN_IMAGE,
           true,
           this);
   Font font = crustShell.getFont(ICrustShell.FONT_H3);
   presetButtons[0] =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           44,
           256,
           88,
           60,
           B1_UP_IMAGE,
           B1_DOWN_IMAGE,
           true,
           this,
           font);
   presetButtons[1] =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           132,
           256,
           79,
           60,
           B2_UP_IMAGE,
           B2_DOWN_IMAGE,
           true,
           this,
           font);
   presetButtons[2] =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           211,
           256,
           79,
           60,
           B3_UP_IMAGE,
           B3_DOWN_IMAGE,
           true,
           this,
           font);
   presetButtons[3] =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           291,
           256,
           88,
           60,
           B4_UP_IMAGE,
           B4_DOWN_IMAGE,
           true,
           this,
           font);
   presetButtons[4] =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           44,
           317,
           88,
           60,
           B5_UP_IMAGE,
           B5_DOWN_IMAGE,
           true,
           this,
           font);
   presetButtons[5] =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           132,
           317,
           79,
           60,
           B6_UP_IMAGE,
           B6_DOWN_IMAGE,
           true,
           this,
           font);
   presetButtons[6] =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           211,
           317,
           79,
           60,
           B7_UP_IMAGE,
           B7_DOWN_IMAGE,
           true,
           this,
           font);
   presetButtons[7] =
       f.createImageButton(
           screenComposite,
           SWT.PUSH,
           291,
           317,
           88,
           60,
           B8_UP_IMAGE,
           B8_DOWN_IMAGE,
           true,
           this,
           font);
   frequencyLabel =
       f.createLabel(
           screenComposite, SWT.CENTER, 131, 87, 165, 45, crustShell.getFont(ICrustShell.FONT_H1));
   bandLabel = f.createLabel(screenComposite, SWT.RIGHT | SWT.BOTTOM, 261, 129, 30, 30, font);
   updateWidgetsFromModel();
 }
  @Override
  protected void layout(Composite composite, boolean flushCache) {

    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "in layout(" + flushCache + ") " + composite.getSize().x + " " + composite.getSize().y);
    }

    if (flushCache) {
      setLayoutData();
      adjustFontSizes();
    }

    long startTime = System.currentTimeMillis();

    board.getGameDescriptionLabel().setBounds(gameDescriptionLabelRect);
    board.getCurrentPremovesLabel().setBounds(currentPremovesLabelRect);
    board.getStatusLabel().setBounds(statusLabelRect);
    board.getOpeningDescriptionLabel().setBounds(openingDescriptionLabelRect);

    layoutChessBoard(boardTopLeft, squareSize);

    board
        .getWhiteNameRatingLabel()
        .setBounds(board.isWhiteOnTop() ? topNameLabelRect : bottomNameLabelRect);
    board.getWhiteLagLabel().setBounds(board.isWhiteOnTop() ? topLagRect : bottomLagRect);
    board.getWhiteClockLabel().setBounds(board.isWhiteOnTop() ? topClockRect : bottomClockRect);

    board
        .getBlackNameRatingLabel()
        .setBounds(board.isWhiteOnTop() ? bottomNameLabelRect : topNameLabelRect);
    board.getBlackLagLabel().setBounds(board.isWhiteOnTop() ? bottomLagRect : topLagRect);
    board.getBlackClockLabel().setBounds(board.isWhiteOnTop() ? bottomClockRect : topClockRect);

    if (board.isWhitePieceJailOnTop()) {
      board.getPieceJailSquares()[WP].setBounds(
          topPieceJailRow1Point.x,
          topPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[WN].setBounds(
          topPieceJailRow1Point.x + pieceJailSquareSize,
          topPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[WB].setBounds(
          topPieceJailRow1Point.x + 2 * pieceJailSquareSize,
          topPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[WQ].setBounds(
          topPieceJailRow2Point.x,
          topPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[WR].setBounds(
          topPieceJailRow2Point.x + pieceJailSquareSize,
          topPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[WK].setBounds(
          topPieceJailRow2Point.x + 2 * pieceJailSquareSize,
          topPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);

      board.getPieceJailSquares()[BP].setBounds(
          bottomPieceJailRow1Point.x,
          bottomPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[BN].setBounds(
          bottomPieceJailRow1Point.x + pieceJailSquareSize,
          bottomPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[BB].setBounds(
          bottomPieceJailRow1Point.x + 2 * pieceJailSquareSize,
          bottomPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[BQ].setBounds(
          bottomPieceJailRow2Point.x,
          bottomPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[BR].setBounds(
          bottomPieceJailRow2Point.x + pieceJailSquareSize,
          bottomPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[BK].setBounds(
          bottomPieceJailRow2Point.x + 2 * pieceJailSquareSize,
          bottomPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
    } else {
      board.getPieceJailSquares()[BP].setBounds(
          topPieceJailRow1Point.x,
          topPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[BN].setBounds(
          topPieceJailRow1Point.x + pieceJailSquareSize,
          topPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[BB].setBounds(
          topPieceJailRow1Point.x + 2 * pieceJailSquareSize,
          topPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[BQ].setBounds(
          topPieceJailRow2Point.x,
          topPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[BR].setBounds(
          topPieceJailRow2Point.x + pieceJailSquareSize,
          topPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[BK].setBounds(
          topPieceJailRow2Point.x + 2 * pieceJailSquareSize,
          topPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);

      board.getPieceJailSquares()[WP].setBounds(
          bottomPieceJailRow1Point.x,
          bottomPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[WN].setBounds(
          bottomPieceJailRow1Point.x + pieceJailSquareSize,
          bottomPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[WB].setBounds(
          bottomPieceJailRow1Point.x + 2 * pieceJailSquareSize,
          bottomPieceJailRow1Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[WQ].setBounds(
          bottomPieceJailRow2Point.x,
          bottomPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[WR].setBounds(
          bottomPieceJailRow2Point.x + pieceJailSquareSize,
          bottomPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
      board.getPieceJailSquares()[WK].setBounds(
          bottomPieceJailRow2Point.x + 2 * pieceJailSquareSize,
          bottomPieceJailRow2Point.y,
          pieceJailSquareSize,
          pieceJailSquareSize);
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug("Layout completed in " + (System.currentTimeMillis() - startTime));
    }
  }
  @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();
                }
              }
            });
  }
 public int getHeight() {
   return composite.getSize().y;
 }
 public int getWidth() {
   return composite.getSize().x;
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    int nbLines = param.getNbLines();

    DecoratedField dField =
        new DecoratedField(
            subComposite,
            SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP,
            new SelectAllTextControlCreator());
    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();
    Text text = (Text) dField.getControl();

    editionControlHelper.register(param.getName(), text);

    FormData d = (FormData) text.getLayoutData();
    if (getAdditionalHeightSize() != 0) {
      nbLines += this.getAdditionalHeightSize() / text.getLineHeight();
    }
    d.height = text.getLineHeight() * nbLines;
    FormData data;
    text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * nbLines);
    cLayout.setBackground(subComposite.getBackground());
    // for bug 7580
    if (!(text instanceof Text)) {
      text.setEnabled(!param.isReadOnly());
    } else {
      text.setEditable(!param.isReadOnly());
    }
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
    FontData fontData = new FontData(fontType);
    Font font = new Font(null, fontData);
    addResourceDisposeListener(text, font);
    text.setFont(font);
    if (elem instanceof Node) {
      text.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    addDragAndDropTarget(text);

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }

    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), text);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);

    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return null;
  }
Exemple #16
0
 /**
  * When this view is resized, the StyledText SWT widget is resized accordingly. This method should
  * be called only as a response to the ControlListener.
  */
 public void controlResized(ControlEvent e) {
   Point parentSize = parentCompo.getSize();
   rowData.width = parentSize.x - 36;
   rowData.height = parentSize.y - 11;
   shellTextArea.setLayoutData(rowData);
 }
  void doRename(boolean showPreview) {
    cancel();

    Image image = null;
    Label label = null;

    fShowPreview |= showPreview;
    try {
      ISourceViewer viewer = fEditor.getViewer();
      if (viewer instanceof SourceViewer) {
        SourceViewer sourceViewer = (SourceViewer) viewer;
        Control viewerControl = sourceViewer.getControl();
        if (viewerControl instanceof Composite) {
          Composite composite = (Composite) viewerControl;
          Display display = composite.getDisplay();

          // Flush pending redraw requests:
          while (!display.isDisposed() && display.readAndDispatch()) {}

          // Copy editor area:
          GC gc = new GC(composite);
          Point size;
          try {
            size = composite.getSize();
            image = new Image(gc.getDevice(), size.x, size.y);
            gc.copyArea(image, 0, 0);
          } finally {
            gc.dispose();
            gc = null;
          }

          // Persist editor area while executing refactoring:
          label = new Label(composite, SWT.NONE);
          label.setImage(image);
          label.setBounds(0, 0, size.x, size.y);
          label.moveAbove(null);
        }
      }

      String newName = fNamePosition.getContent();
      if (fOriginalName.equals(newName)) {
        return;
      }
      RenameSupport renameSupport = undoAndCreateRenameSupport(newName);
      if (renameSupport == null) {
        return;
      }

      Shell shell = fEditor.getSite().getShell();
      if (renameSupport.hasUnresolvedNameReferences()) {
        fShowPreview = true;
      }
      boolean executed;
      if (fShowPreview) { // could have been updated by undoAndCreateRenameSupport(..)
        executed = renameSupport.openDialog(shell, true);
      } else {
        renameSupport.perform(shell, fEditor.getSite().getWorkbenchWindow());
        executed = true;
      }
      if (executed) {
        restoreFullSelection();
      }
    } catch (CoreException ex) {
      DartToolsPlugin.log(ex);
    } catch (InterruptedException ex) {
      // canceling is OK -> redo text changes in that case?
    } catch (InvocationTargetException ex) {
      DartToolsPlugin.log(ex);
    } catch (BadLocationException e) {
      DartToolsPlugin.log(e);
    } finally {
      if (label != null) {
        label.dispose();
      }
      if (image != null) {
        image.dispose();
      }
    }
  }
  @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);
    }
  }