Пример #1
0
  public void createPartControl(final Composite parent) {
    parent.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE));
    parent.setBackgroundMode(SWT.INHERIT_FORCE);
    parent.setLayout(UIUtil.formLayout(0, 0));
    GridLayout layout = new GridLayout(1, true);
    layout.marginHeight = MARGIN;
    layout.marginWidth = MARGIN;
    scroll = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scroll.setLayoutData(UIUtil.formData(0, 0, 0, 0, 100, 0, 100, 0));
    canvas = new Canvas(scroll, SWT.DOUBLE_BUFFERED);
    canvas.setLayout(layout);
    canvas.addPaintListener(
        new PaintListener() {
          public void paintControl(PaintEvent e) {
            try {
              area = canvas.getClientArea();
              winYSize = parent.getSize().y;
              drawEQImage(e.gc);
            } catch (Throwable t) {
            }
          }
        });
    canvas.addMouseListener(
        new MouseAdapter() {
          public void mouseDoubleClick(MouseEvent e) {
            if (unitHeight == 0 || datas == null) {
              return;
            }
            if (e.y <= AXIS_PADDING) {
              return;
            }
            int index = (e.y - AXIS_PADDING) / unitHeight;
            if (datas.length < index + 1 || datas[index].isAlive == false) {
              return;
            }
            AgentObject agent = AgentModelThread.getInstance().getAgentObject(datas[index].objHash);
            new OpenCxtmenuActiveServiceListAction(
                    getSite().getWorkbenchWindow(),
                    MenuStr.ACTIVE_SERVICE_LIST,
                    datas[index].objHash,
                    agent.getObjType(),
                    agent.getServerId())
                .run();
          }
        });

    scroll.setContent(canvas);
    scroll.setExpandVertical(true);
    scroll.setExpandHorizontal(true);

    scroll.addListener(
        SWT.MouseWheel,
        new Listener() {
          public void handleEvent(Event event) {
            Point origin = scroll.getOrigin();
            origin.y += (event.count * -1) * 10;
            scroll.setOrigin(origin);
          }
        });

    // canvas.setToolTipText("Double click to list active services");
    thread = new RefreshThread(this, REFRESH_INTERVAL);
    thread.start();
  }
Пример #2
0
  public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    skin = skinObject.getSkin();

    SWTSkinProperties properties = skin.getSkinProperties();
    colorFileDragBorder = properties.getColor("color.buddy.filedrag.bg.border");
    colorFileDragBG = properties.getColor("color.buddy.filedrag.bg");

    soNoBuddies = skin.getSkinObject("buddies-viewer-nobuddies-panel");

    SWTSkinObject viewer = skin.getSkinObject(SkinConstants.VIEWID_BUDDIES_VIEWER);

    if (null != viewer) {

      parent = (Composite) skinObject.getControl();
      parent.setBackgroundMode(SWT.INHERIT_FORCE);
      scrollable = new ScrolledComposite(parent, SWT.V_SCROLL);
      scrollable.setExpandHorizontal(true);
      scrollable.setExpandVertical(true);
      scrollable.setBackgroundMode(SWT.INHERIT_FORCE);
      scrollable.getVerticalBar().setIncrement(10);
      scrollable.getVerticalBar().setPageIncrement(65);

      FormData fd = new FormData();
      fd.top = new FormAttachment(0, 0);
      fd.bottom = new FormAttachment(100, 0);
      fd.left = new FormAttachment(0, 0);
      fd.right = new FormAttachment(100, 0);
      scrollable.setLayoutData(fd);

      avatarsPanel = new Composite(scrollable, SWT.NONE);
      avatarsPanel.setBackgroundMode(SWT.INHERIT_FORCE);
      scrollable.setContent(avatarsPanel);

      scrollable.addListener(
          SWT.Resize,
          new Listener() {

            public void handleEvent(Event event) {
              Rectangle r = scrollable.getClientArea();
              scrollable.setMinHeight(avatarsPanel.computeSize(r.width, SWT.DEFAULT).y);
            }
          });

      /*
       * Specify avatar dimensions and attributes before creating the avatars
       */
      textColor = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
      selectedTextColor = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
      textLinkColor = properties.getColor("color.links.hover");
      imageBorderColor = properties.getColor("color.buddy.bg.border");
      selectedColor = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
      highlightedColor = parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);

      avatarHightLightBorder = 0;
      avatarImageBorder = 1;
      hSpacing = 1;
      avatarImageSize = new Point(40, 40);
      avatarNameSize = new Point(60, 30);
      avatarSize = new Point(0, 0);
      avatarSize.x =
          Math.max(avatarNameSize.x, avatarImageSize.x)
              + (2 * (avatarHightLightBorder + avatarImageBorder));
      avatarSize.y =
          avatarNameSize.y
              + avatarImageSize.y
              + (2 * (avatarHightLightBorder + avatarImageBorder) + 6);

      fillBuddies(avatarsPanel);

      /* UNCOMMENT THIS SECTION TO REVERT TO A ROW LAYOUT*/
      //			RowLayout rLayout = new RowLayout(SWT.HORIZONTAL);
      //			rLayout.wrap = true;
      //			rLayout.spacing = hSpacing;
      //			avatarsPanel.setLayout(rLayout);

      // COMMENT THIS SECTION TO REVERT TO A ROW LAYOUT
      SimpleReorderableListLayout rLayout = new SimpleReorderableListLayout();
      rLayout.margin = hSpacing;
      rLayout.wrap = true;
      rLayout.center = true;
      avatarsPanel.setLayout(rLayout);

      avatarsPanel.pack();

      avatarsPanel.addMouseListener(
          new MouseAdapter() {
            public void mouseDown(MouseEvent e) {
              select(null, false, false);
            }
          });

      avatarsPanel.addMouseListener(
          new MouseAdapter() {
            public void mouseDown(MouseEvent e) {
              select(null, false, false);
            }
          });

      parent.layout();

      hookFAQLink();

      hookImageAction();
    }

    return null;
  }
Пример #3
0
  private Control createScrollingPreview(Composite parent) {
    scroll = new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scroll.setExpandHorizontal(true);
    scroll.setExpandVertical(true);

    preview = new PrintPreview(scroll, SWT.NONE);
    scroll.setContent(preview);

    scroll.addListener(
        SWT.Resize,
        new Listener() {
          public void handleEvent(Event event) {
            Rectangle bounds = scroll.getClientArea();

            scroll.getHorizontalBar().setPageIncrement(bounds.width * 2 / 3);
            scroll.getVerticalBar().setPageIncrement(bounds.height * 2 / 3);

            if (preview.isFitHorizontal() ^ preview.isFitVertical()) {
              rememberScrollingPosition();
              updatePreviewSize();
              restoreScrollingPosition();
            }
          }
        });

    preview.setFitVertical(true);
    preview.setFitHorizontal(true);

    Listener dragListener =
        new Listener() {
          private final Point dpi = display.getDPI();
          private boolean scrollable = false;

          private boolean dragging = false;
          private Point dragStartScrollOrigin = null;
          private Point dragStartMouseAnchor = null;

          public void handleEvent(Event event) {
            switch (event.type) {
              case SWT.Resize:
                forgetScrollingPosition();
                Rectangle bounds = scroll.getClientArea();
                Point size = preview.getSize();
                scrollable = size.x > bounds.width || size.y > bounds.height;
                if (!scrollable && dragging) endDragging();
                break;
              case SWT.MouseDown:
                forgetScrollingPosition();
                if (scrollable && event.button == 1) beginDragging(event);
                break;
              case SWT.MouseMove:
                if (dragging) {
                  forgetScrollingPosition();
                  Point point = preview.toDisplay(event.x, event.y);
                  scroll.setOrigin(
                      dragStartScrollOrigin.x + dragStartMouseAnchor.x - point.x,
                      dragStartScrollOrigin.y + dragStartMouseAnchor.y - point.y);
                }
                break;
              case SWT.MouseUp:
                forgetScrollingPosition();
                if (dragging) endDragging();
                break;
              case SWT.MouseEnter:
                display.addFilter(SWT.MouseWheel, this);
                break;
              case SWT.MouseWheel:
                if (event.count != 0) {
                  if (scrollable
                      && !dragging
                      && (event.stateMask == SWT.NONE || event.stateMask == SWT.SHIFT)) {
                    forgetScrollingPosition();
                    bounds = scroll.getClientArea();
                    size = preview.getSize();
                    Point origin = scroll.getOrigin();
                    int direction = event.count > 0 ? -1 : 1;
                    // Prefer vertical scrolling unless user is
                    // pressing Shift
                    if (size.y > bounds.height && event.stateMask == SWT.NONE)
                      origin.y += direction * Math.min(dpi.y, bounds.height / 4);
                    else if (size.x > bounds.width)
                      origin.x += direction * Math.min(dpi.x, bounds.width / 4);
                    scroll.setOrigin(origin);
                    event.doit = false;
                  } else if (event.stateMask == SWT.CTRL) { // Ctrl+MouseWheel
                    // ->
                    // zoom
                    float scale = preview.getAbsoluteScale();
                    setPreviewScale(event.count > 0 ? scale / 1.1f : scale * 1.1f);
                  }
                }
                break;
              case SWT.MouseExit:
                display.removeFilter(SWT.MouseWheel, this);
                break;
            }
          }

          private void beginDragging(Event event) {
            dragStartScrollOrigin = scroll.getOrigin();
            dragStartMouseAnchor = preview.toDisplay(event.x, event.y);
            dragging = true;
          }

          private void endDragging() {
            dragging = false;
            dragStartMouseAnchor = null;
            dragStartScrollOrigin = null;
          }
        };

    scroll.addListener(SWT.Resize, dragListener);
    preview.addListener(SWT.MouseDown, dragListener);
    preview.addListener(SWT.MouseMove, dragListener);
    preview.addListener(SWT.MouseUp, dragListener);

    // These are for mouse wheel handling
    preview.addListener(SWT.MouseEnter, dragListener);
    preview.addListener(SWT.MouseExit, dragListener);

    return scroll;
  }
  @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();
                }
              }
            });
  }