Пример #1
0
  /**
   * Returns whether the given <code>AvatarWidget</code> is fully visible in the view port of the
   * viewer
   */
  public boolean isFullyVisible(AvatarWidget avatarWidget) {
    if (null != avatarWidget
        && null != avatarWidget.getControl()
        && false == avatarWidget.getControl().isDisposed()) {

      Rectangle controlBounds = avatarWidget.getControl().getBounds();
      if (controlBounds.x + controlBounds.width
          < avatarsPanel.getBounds().width - avatarsPanel.getBounds().x) {
        return true;
      }
    }
    return false;
  }
Пример #2
0
  @Override
  public void createControl(Composite parent) {

    composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    Text pageText = new Text(composite, SWT.CENTER);
    pageText.setBounds(composite.getBounds());
    pageText.setText("Toolchain F Wizard Page");
    pageText.setVisible(true);
  }
Пример #3
0
  protected void slideRightTo(final int index) {
    if (isMoving == true) return;
    isMoving = true;
    performPreSlideActions(index);
    notifyListeners(SlideEventType.PRE_SLIDE, myCurrentSlideIndex, index);
    final Composite currentSlide = getCurrentSlide();
    final Composite leftComp = getSlide(index);
    final int oldIndex = myCurrentSlideIndex;
    // leftComp.setLayoutData( FormDataMaker.makeFormData(0, 0, 100, 0, 0,
    // -SlideDeck.this.getBounds().width, currentSlide, 0 ) );
    leftComp.setLayoutData(makeSlideRightFormData(currentSlide));
    ((FormData) leftComp.getLayoutData()).width = this.getBounds().width;

    leftComp.setVisible(true);
    final int width = currentSlide.getBounds().width;

    Runnable slideRightAction =
        new Runnable() {
          private int numFrames = 0;

          @Override
          public void run() {
            Display.getDefault()
                .syncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        FormData fd = (FormData) currentSlide.getLayoutData();
                        fd.right.offset = fd.right.offset + width / 5;
                        fd.left.offset = fd.left.offset + width / 5;
                        if (numFrames == 4) {
                          myFuture.cancel(true);
                          fd.right.offset =
                              currentSlide.getBounds().width + currentSlide.getBounds().width;
                          fd.left.offset = currentSlide.getBounds().width;
                          leftComp.setLayoutData(makeFullFormData());
                          currentSlide.setVisible(false);
                          SlideDeck.this.layout();
                          myCurrentSlideIndex = index;
                          isMoving = false;
                          performPostSlideActions(oldIndex);
                          notifyListeners(SlideEventType.POST_SLIDE, myCurrentSlideIndex, index);
                          return;
                        } else SlideDeck.this.layout();
                        numFrames++;
                      }
                    });
          }
        };
    myFuture =
        myAnimationExecutor.scheduleAtFixedRate(
            slideRightAction, 0, DEFAULT_FRAME_DISPLAY_TIME, TimeUnit.MILLISECONDS);
  }
Пример #4
0
  protected Point getInitialLocation(Point initialSize) {
    Composite parent = getParent();

    Rectangle parentBounds = parent.getClientArea();
    Point centerPoint = Geometry.centerPoint(parent.getBounds());

    return new Point(
        centerPoint.x - (initialSize.x / 2),
        Math.max(
            parentBounds.y,
            Math.min(
                centerPoint.y - (initialSize.y * 2 / 3),
                parentBounds.y + parentBounds.height - initialSize.y)));
  }
Пример #5
0
 /**
  * Calculates the proper trim. Includes scrollbars' sizes only if they're visible.
  *
  * @param canvas The canvas.
  * @since 3.6
  */
 public static Rectangle calculateEditorTrim(Composite canvas) {
   /*
    * Workaround for Bug# 87712 Calculating the trim using the clientArea.
    */
   Rectangle bounds = canvas.getBounds();
   Rectangle clientArea = canvas.getClientArea();
   Rectangle result =
       new Rectangle(0, 0, bounds.width - clientArea.width, bounds.height - clientArea.height);
   if (result.width != 0 || result.height != 0) {
     Rectangle trim = canvas.computeTrim(0, 0, 0, 0);
     result.x = result.height == 0 ? 0 : trim.x;
     result.y = result.width == 0 ? 0 : trim.y;
   }
   return result;
 }
Пример #6
0
  /** Moves the target control on top of the dummy control. */
  public void layout() {
    if (getTargetControl() == null) {
      return;
    }

    // Compute the unclipped bounds of the target in display coordinates
    Rectangle displayBounds = Geometry.toDisplay(control.getParent(), control.getBounds());

    // Clip the bounds of the target so that it doesn't go outside the dummy control's parent
    Rectangle clippingRegion = DragUtil.getDisplayBounds(control.getParent());
    displayBounds = displayBounds.intersection(clippingRegion);

    // Compute the bounds of the target, in the local coordinate system of its parent
    Rectangle targetBounds = Geometry.toControl(getTargetControl().getParent(), displayBounds);

    // Move the target
    getTargetControl().setBounds(targetBounds);
  }
  @Override
  public void dragEnter(MUIElement dragElement, DnDInfo info) {
    super.dragEnter(dragElement, info);

    clientBounds = dropCTF.getClientArea();
    clientBounds = Display.getCurrent().map(dropCTF, null, clientBounds);
    ctfBounds = dropCTF.getBounds();
    ctfBounds = Display.getCurrent().map(dropCTF.getParent(), null, ctfBounds);

    // Find the root of the dropStack's sash structure
    outerRelTo = dropStack.getParent();
    if (outerRelTo instanceof MPartSashContainer) {
      while (outerRelTo != null && !(outerRelTo.getWidget() instanceof Composite))
        outerRelTo = outerRelTo.getParent();
    }

    // If the stack is in an MArea or a Perspective then allow 'outer' docking
    if (outerRelTo instanceof MArea) {
      // If the relTo is in the MArea then use its 'curSharedRef'
      outerRelTo = outerRelTo.getCurSharedRef();
    } else if (outerRelTo instanceof MPartSashContainer) {
      MUIElement relToParent = outerRelTo.getParent();
      if (relToParent instanceof MArea) {
        outerRelTo = relToParent.getCurSharedRef();
      } else if (relToParent instanceof MPerspective) {
        outerRelTo = relToParent.getParent(); // PerspectiveStack
      } else {
        outerRelTo = null;
      }
    } else {
      outerRelTo = null;
    }

    if (outerRelTo != null) {
      Composite outerComposite = (Composite) outerRelTo.getWidget();
      ocBounds = outerComposite.getBounds();
      ocBounds = Display.getCurrent().map(outerComposite.getParent(), null, ocBounds);
    } else {
      ocBounds = null;
    }

    getDockLocation(info);
    showFeedback(curDockLocation);
  }
Пример #8
0
  /** Performs layouting. */
  private void layout() {

    // Disable redrawing
    toolbar.setRedraw(false);

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

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

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

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

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

    // Redraw
    toolbar.setRedraw(true);
  }
Пример #9
0
  /** Run the test */
  protected void runTest() throws CoreException, WorkbenchException {

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

    // This test is different now duw to trim API changes so 'gray' it...
    setDegradationComment(
        "<a href=https://bugs.eclipse.org/bugs/show_bug.cgi?id=129001>See Bug 129001</a> ");

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

      processEvents();

      startMeasuring();

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

        newBounds.width = xSize;
        newBounds.height = ySize;

        widget.setBounds(newBounds);
        widget.layout(flushState);
      }

      stopMeasuring();
    }

    commitMeasurements();
    assertPerformance();

    widget.setBounds(initialBounds);
    widgetFactory.done();
  }
  /** Run the test */
  @Override
  protected void runTest() throws CoreException, WorkbenchException {

    tagIfNecessary(tagString, Dimension.ELAPSED_PROCESS);

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

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

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

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

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

            widget.setSize(xSize, ySize);

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

    widget.setBounds(initialBounds);
    widgetFactory.done();
  }
Пример #11
0
  /**
   * 建立Page外觀View
   *
   * @param composite
   */
  private void buildPage(Composite composite) {
    selectComposite = new Composite(composite, SWT.NONE);

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

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

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

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

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

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

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

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

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

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

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

    // 自動調整設定主頁面Container的大小
    selectComposite.pack();
    selectComposite.setSize(
        getLowerRightCoordinate(smellTypeGroup).x + 15, selectComposite.getBounds().height);
  }
Пример #12
0
 private void layoutFacade(final Composite facade) {
   Rectangle bounds = composite.getBounds();
   facade.setBounds(0, 0, bounds.width, bounds.height);
   facade.moveAbove(null);
 }
Пример #13
0
  /** Create widgets for monkey options */
  private void createUI() {

    Composite mainComposite = this;
    Layout mainLayout = new GridLayout();
    mainComposite.setLayout(mainLayout);

    // list of monkey options groups
    List<MonkeyOptionsGroup> monkeyOptionsGroupsList =
        MonkeyOptionsMgt.getMonkeyOptionsGroupsList();

    // list of monkey options in each group
    List<MonkeyOption> monkeyOptions = null;

    // Create Tab Folder
    final TabFolder tabFolder = new TabFolder(mainComposite, SWT.NULL);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.heightHint = TABFOLDER_HEIGHT_HINT;
    tabFolder.setLayoutData(data);

    /*
     * Iterate through Monkey Groups
     */
    for (MonkeyOptionsGroup monkeyOptionGroup : monkeyOptionsGroupsList) {

      // Create Tab Item
      TabItem tabItem = new TabItem(tabFolder, SWT.NULL);
      tabItem.setText(monkeyOptionGroup.getTitle());
      Composite group = new Composite(tabFolder, SWT.NULL);
      group.setLayout(new GridLayout(3, false));
      group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
      tabItem.setControl(group);

      // get monkey options in this group
      monkeyOptions = monkeyOptionGroup.getMonkeyOptions();

      /*
       * Iterate through Monkey Options in this group
       */
      for (final MonkeyOption monkeyOption : monkeyOptions) {

        // create a checkbox for each monkey option
        Button checkbox = new Button(group, SWT.CHECK);
        checkbox.setSelection(monkeyOption.isChecked());
        checkbox.setText(monkeyOption.getUserFriendlyName());
        checkbox.setToolTipText(monkeyOption.getName() + ": " + monkeyOption.getDescription());

        monkeyOption.setCheckedWidget(checkbox);
        checkbox.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                boolean checkedStatus = ((Button) e.widget).getSelection();
                monkeyOption.setChecked(checkedStatus);
                notifyCompositeChangeListeners();
              }
            });
        GridData checkboxData = new GridData(SWT.NULL, SWT.FILL, false, false);
        checkbox.setLayoutData(checkboxData);

        // Create input fields depending on the monkey option type
        switch (monkeyOption.getType()) {
          case TYPE_NONE:
            // extend checkbox area along the line
            checkboxData.widthHint = SWT.DEFAULT;
            checkboxData.horizontalSpan = 3;
            checkbox.setLayoutData(checkboxData);
            break;

          case TYPE_TEXT:
          case TYPE_NUMBER:
            createWidgetsForTextOrNumberType(group, monkeyOption);
            break;

          case TYPE_PATH:
            createWidgetsForPathType(group, monkeyOption);
            break;

          default:
            // none

        }
      }
    }

    /*
     * Command Line area
     */
    Composite commandLineArea = new Composite(mainComposite, SWT.NONE); // composite
    commandLineArea.setLayout(new GridLayout(2, false));
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    commandLineArea.setLayoutData(data);

    Label commandLineLabel = new Label(commandLineArea, SWT.NONE); // label
    commandLineLabel.setText(AndroidNLS.UI_MonkeyOptions_CommandLine);
    data = new GridData(SWT.FILL, SWT.FILL, false, true);
    commandLineLabel.setLayoutData(data);

    commandLine =
        new Text(commandLineArea, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); // text
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    commandLineArea.pack();
    data.widthHint = commandLineArea.getBounds().width - commandLineLabel.getBounds().width;
    data.heightHint = commandLineArea.getBounds().height;
    commandLine.setLayoutData(data);
    commandLine.setText(MonkeyOptionsMgt.getParamList());
    commandLine.setEditable(false);
  }
  private void loadPhotos() {
    if (selectedPhotosFilesList == null) {
      selectedPhotosFilesList = new ArrayList<String>();
    } else {
      selectedPhotosFilesList.clear();
    }

    if (thumbnailWidgetList == null) {
      thumbnailWidgetList = new ArrayList<ThumbnailWidget>();
    } else {
      thumbnailWidgetList.clear();
    }

    ImagesGridView imagesGridView =
        (ImagesGridView)
            Activator.getView(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow(), ImagesGridView.ID);
    Composite thumbnailGridComposite = imagesGridView.getThumbnailGridComposite();
    for (Control control : thumbnailGridComposite.getChildren()) {
      control.dispose();
    }
    int gridWidth = thumbnailGridComposite.getBounds().width;
    int numberOfColumns = gridWidth / 200 - 1;

    GridLayout thumbnailGridCompositeGL = new GridLayout(numberOfColumns, true);
    thumbnailGridComposite.setLayout(thumbnailGridCompositeGL);
    GridData thumbnailGridCompositeGD = new GridData(GridData.FILL_BOTH);
    thumbnailGridCompositeGD.horizontalSpan = 2;
    thumbnailGridComposite.setLayoutData(thumbnailGridCompositeGD);
    if (loadedPhotosList != null && loadedPhotosList.size() > 0) {
      // begin add photo composite, check and text fields
      for (ListIterator<String> selectedPhotosIterator = loadedPhotosList.listIterator();
          selectedPhotosIterator.hasNext(); ) {
        String selectedPhotoFilePath = selectedPhotosIterator.next();
        // check if the file has a valid imagesList
        final Image thumbnail;
        try {
          thumbnail = new Image(Display.getDefault(), selectedPhotoFilePath);
        } catch (SWTException ex) {
          selectedPhotosIterator.remove();
          continue;
        }
        Composite imageParentComposite = new Composite(thumbnailGridComposite, SWT.BORDER);
        GridLayout imageParentCompositeGridLayout = new GridLayout(2, false);
        imageParentComposite.setLayout(imageParentCompositeGridLayout);
        GridData imageParentCompositeGridData = new GridData();
        imageParentCompositeGridData.grabExcessHorizontalSpace = true;
        imageParentComposite.setLayoutData(imageParentCompositeGridData);

        final Composite imageComposite = new Composite(imageParentComposite, SWT.BORDER);
        GridData imageCompositeGridData = new GridData(175, 200);
        imageCompositeGridData.horizontalSpan = 2;
        imageComposite.setLayoutData(imageCompositeGridData);

        imageComposite.addMouseListener(
            new MouseListener() {
              @Override
              public void mouseUp(MouseEvent e) {}

              @Override
              public void mouseDown(MouseEvent e) {}

              @Override
              public void mouseDoubleClick(MouseEvent e) {
                String selectedPhotosFile =
                    ((ThumbnailWidget) imageComposite.getData()).getSelectedPhotoFilePath();
                Dialog dialog =
                    new OriginalSizeImageDialog(
                        Display.getDefault().getActiveShell(),
                        new Image[] {new Image(Display.getDefault(), selectedPhotosFile)});
                dialog.open();
              }
            });

        ResizeImageListener comp1Listener =
            new ResizeImageListener(thumbnail, imageComposite, true);
        imageComposite.addListener(SWT.Dispose, comp1Listener);
        imageComposite.addListener(SWT.Paint, comp1Listener);

        final Button checkBox = new Button(imageParentComposite, SWT.CHECK);
        Text imageDescriptionText = new Text(imageParentComposite, SWT.BORDER);
        GridData imageDescriptionTextGridData = new GridData(GridData.FILL_HORIZONTAL);
        imageDescriptionTextGridData.grabExcessHorizontalSpace = true;
        imageDescriptionText.setLayoutData(imageDescriptionTextGridData);

        ThumbnailWidget thumbnailWidget = new ThumbnailWidget();
        thumbnailWidget.setImageParentComposite(imageParentComposite);
        thumbnailWidget.setImageComposite(imageComposite);
        thumbnailWidget.setImageDescriptionText(imageDescriptionText);
        thumbnailWidget.setImage(thumbnail);
        thumbnailWidget.setCheckBox(checkBox);
        thumbnailWidget.setSelectedPhotoFilePath(selectedPhotoFilePath);

        checkBox.setData(thumbnailWidget);
        imageDescriptionText.setData(thumbnailWidget);
        imageComposite.setData(thumbnailWidget);

        thumbnailWidgetList.add(thumbnailWidget);

        checkBox.addSelectionListener(
            new SelectionListener() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                String selectedPhotosFile =
                    ((ThumbnailWidget) checkBox.getData()).getSelectedPhotoFilePath();
                if (checkBox.getSelection()) {
                  selectedPhotosFilesList.add(selectedPhotosFile);
                } else {
                  selectedPhotosFilesList.remove(selectedPhotosFile);
                }
              }

              @Override
              public void widgetDefaultSelected(SelectionEvent e) {}
            });
      }
      // end add photo composite, check and text fields
      ScrolledComposite thumbnailGridScrolledComposite =
          imagesGridView.getViewerScrolledComposite();

      Point size = thumbnailGridComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
      thumbnailGridScrolledComposite.setMinSize(size);

      thumbnailGridScrolledComposite.setContent(thumbnailGridComposite);
      thumbnailGridScrolledComposite.layout(true);
    }
    // show image grid view
    try {
      PlatformUI.getWorkbench()
          .getActiveWorkbenchWindow()
          .getActivePage()
          .showView(ImagesGridView.ID);
    } catch (PartInitException e1) {
      e1.printStackTrace();
    }
  }
Пример #15
0
 /**
  * Returns the bounds of this item.
  *
  * @return the bounds of this item
  */
 public Rectangle getBounds() {
   return fContainer.getBounds();
 }
Пример #16
0
  /**
   * show one popup menu over the main window
   *
   * @param menu_entry actual entry which should be shown or disposed
   * @param move TRUE if the curser be moved over one entry, otherwise by clicking false
   */
  private void show(String menu_entry, boolean move) {
    Point abs;
    Group popup;
    Rectangle rect, popup_rect = new Rectangle(0, 0, 120, 100);
    TreeNodes node;
    RowLayout l;
    ArrayList<TreeNodes> nodes;
    ArrayList<Composite> comps;

    if (move && m_sMenu.equals("")) {
      return;
    }
    if (!m_sMenu.equals(menu_entry)) {
      if (m_popupShell != null) m_popupShell.dispose();
      popup = m_mRootEntrys.get(menu_entry);
      rect = popup.getBounds();
      m_popupShell = new Shell(m_oTopLevelShell, SWT.NO_TRIM);
      // popup_rect= m_popupShell.getClientArea();
      abs = LayoutLoader.getAbsoluteUseFieldPoint();
      popup_rect.x = m_oMenu.getBounds().x + abs.x + rect.x;
      popup_rect.y = abs.y + rect.y + rect.height;
      l = new RowLayout();
      l.type = SWT.VERTICAL;
      l.pack = false;
      l.marginBottom = 0;
      l.marginHeight = 0;
      l.marginLeft = 0;
      l.marginRight = 0;
      l.marginTop = 0;
      l.marginWidth = 0;
      l.spacing = 0;
      m_popupShell.setLayout(l);
      node = m_mRootNodes.get(menu_entry);
      nodes = node.getChilds();
      m_sMenu = menu_entry;
      if (nodes.size() == 0) {
        m_sMenu = "";
        return;
      }
      comps = new ArrayList<Composite>();
      for (TreeNodes subnode : nodes) {
        RowLayout layout = new RowLayout();
        Composite comp = new Group(m_popupShell, SWT.NONE);
        Label text = new Label(comp, SWT.NONE);
        HashMap<String, String> metablock = subnode.getMetaData();
        String popupspace = metablock.get("popupspace");
        final String entry;
        int space = 20;
        FontObject font = new FontObject();
        int popupsize = 0;
        boolean bold = false;
        boolean italic = false;
        String looks, ssize;
        MouseListener listener1, listener2;

        entry = m_sMenu + "/" + subnode.getName();
        ssize = metablock.get("popupfontsize");
        if (ssize != null) popupsize = Integer.parseInt(ssize);
        looks = metablock.get("popupstyle");
        if (looks != null) {
          String[] split;

          split = looks.split(",");
          for (int i = 0; i < split.length; ++i) {
            split[i] = split[i].trim().toLowerCase();
            if (split[i].equals("bold")) bold = true;
            else if (split[i].equals("italic")) italic = true;
          }
        }
        font.defineColor(popup, metablock.get("popupcolor"), colors.WIDGET, entry + " popup");
        font.defineColor(popup, metablock.get("popupfontcolor"), colors.TEXT, entry + " popup");
        font.defineFont(
            popup, metablock.get("popupfont"), popupsize, bold, italic, /*underline*/ false);
        text.setText(subnode.getTitle().trim());
        if (popupspace != null) space = Integer.parseInt(popupspace);
        layout.type = SWT.VERTICAL;
        layout.marginTop = space;
        layout.marginRight = space;
        layout.marginBottom = space;
        layout.marginLeft = space;
        comp.setLayout(layout);
        font.setDevice(comp);
        font.setDevice(text);
        font.dispose();
        comps.add(comp);
        text.addMouseListener(
            listener1 =
                new MouseAdapter() {
                  public void mouseDown(MouseEvent event) {
                    LayoutLoader loader;
                    Thread t = null;

                    if (HtmTags.lockDebug) {
                      t = Thread.currentThread();
                      System.out.println(t.getName() + " want to setActiveSideVisible of " + entry);
                    }
                    loader = LayoutLoader.instance();
                    loader.m_sAktFolder = entry;
                    synchronized (TreeNodes.m_DISPLAYLOCK) {
                      loader.setCurrentSideVisible(/*inform server by no body*/ true);
                    }
                    m_nPopup = m_popupShell.getBounds();
                    destroyPopupShell();
                    m_sMenu = "";
                  }
                });
        m_aPopupListeners.put(text, listener1);
        comp.addMouseListener(
            listener2 =
                new MouseAdapter() {
                  public void mouseDown(MouseEvent event) {
                    LayoutLoader loader;
                    Thread t = null;

                    if (HtmTags.lockDebug) {
                      t = Thread.currentThread();
                      System.out.println(t.getName() + " want to setActiveSideVisible of " + entry);
                    }
                    loader = LayoutLoader.instance();
                    loader.m_sAktFolder = entry;
                    synchronized (TreeNodes.m_DISPLAYLOCK) {
                      loader.setCurrentSideVisible(/*inform server by no body*/ true);
                    }
                    m_nPopup = m_popupShell.getBounds();
                    destroyPopupShell();
                    m_sMenu = "";
                  }
                });
        m_aPopupListeners.put(comp, listener2);
      }

      if (m_nPopup != null) popup_rect = m_nPopup;
      m_popupShell.setBounds(popup_rect);
      m_popupShell.setEnabled(false);
      m_popupShell.setVisible(false);
      m_popupShell.open();
      m_popupShell.pack();
      m_popupShell.setEnabled(true);
      m_popupShell.setVisible(true);

    } else if (!m_sMenu.equals("") && !move) { // actual popup is the same
      m_popupShell.dispose();
      m_sMenu = "";
    }
  }