コード例 #1
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.IPresentationPreview#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.ui.themes.ITheme)
   */
  public void createControl(Composite parent, ITheme currentTheme) {
    this.theme = currentTheme;
    folder = new CTabFolder(parent, SWT.BORDER);
    folder.setUnselectedCloseVisible(false);
    folder.setEnabled(false);
    folder.setMaximizeVisible(true);
    folder.setMinimizeVisible(true);

    viewForm = new ViewForm(folder, SWT.NONE);
    viewForm.marginHeight = 0;
    viewForm.marginWidth = 0;
    viewForm.verticalSpacing = 0;
    viewForm.setBorderVisible(false);
    toolBar = new ToolBar(viewForm, SWT.FLAT | SWT.WRAP);
    ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);

    Image hoverImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU);
    toolItem.setImage(hoverImage);

    viewForm.setTopRight(toolBar);

    viewMessage = new CLabel(viewForm, SWT.NONE);
    viewMessage.setText("Etu?"); // $NON-NLS-1$
    viewForm.setTopLeft(viewMessage);

    CTabItem item = new CTabItem(folder, SWT.CLOSE);
    item.setText("Lorem"); // $NON-NLS-1$
    Label text = new Label(viewForm, SWT.NONE);
    viewForm.setContent(text);
    text.setText("Lorem ipsum dolor sit amet"); // $NON-NLS-1$
    text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    item = new CTabItem(folder, SWT.CLOSE);
    item.setText("Ipsum"); // $NON-NLS-1$
    item.setControl(viewForm);
    item.setImage(WorkbenchImages.getImage(ISharedImages.IMG_TOOL_COPY));

    folder.setSelection(item);

    item = new CTabItem(folder, SWT.CLOSE);
    item.setText("Dolor"); // $NON-NLS-1$
    item = new CTabItem(folder, SWT.CLOSE);
    item.setText("Sit"); // $NON-NLS-1$

    currentTheme.addPropertyChangeListener(fontAndColorListener);
    setColorsAndFonts();
    setTabPosition();
    setTabStyle();
  }
コード例 #2
0
  /** Creates a new <code>PinPropertySheetAction</code>. */
  public PinPropertySheetAction() {
    super(PropertiesMessages.Pin_text, IAction.AS_CHECK_BOX);

    setId(
        PinPropertySheetAction.class.getName()
            + "#"
            + Long.toString(System.currentTimeMillis())); // $NON-NLS-1$
    setToolTipText(PropertiesMessages.Pin_toolTip);
    setImageDescriptor(
        WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR));
    setDisabledImageDescriptor(
        WorkbenchImages.getImageDescriptor(
            IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR_DISABLED));

    PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IPropertiesHelpContextIds.PIN_ACTION);
  }
コード例 #3
0
 private Image getOpenPerspectiveImage() {
   if (perspectiveImage == null || perspectiveImage.isDisposed()) {
     ImageDescriptor desc =
         WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_PAGE);
     perspectiveImage = desc.createImage();
   }
   return perspectiveImage;
 }
コード例 #4
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.ui.internal.progress.AnimationItem#createAnimationItem(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createAnimationItem(Composite parent) {

    if (okImage == null) {
      Display display = parent.getDisplay();
      noneImage =
          WorkbenchImages.getWorkbenchImageDescriptor("progress/progress_none.png")
              .createImage(display); // $NON-NLS-1$
      okImage =
          WorkbenchImages.getWorkbenchImageDescriptor("progress/progress_ok.png")
              .createImage(display); // $NON-NLS-1$
      errorImage =
          WorkbenchImages.getWorkbenchImageDescriptor("progress/progress_error.png")
              .createImage(display); // $NON-NLS-1$
    }

    top = new Composite(parent, SWT.NULL);
    top.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent e) {
            FinishedJobs.getInstance().removeListener(ProgressAnimationItem.this);
            noneImage.dispose();
            okImage.dispose();
            errorImage.dispose();
          }
        });

    boolean isCarbon = Util.isMac();

    GridLayout gl = new GridLayout();
    if (isHorizontal()) gl.numColumns = isCarbon ? 3 : 2;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    if (isHorizontal()) {
      gl.horizontalSpacing = 2;
    } else {
      gl.verticalSpacing = 2;
    }
    top.setLayout(gl);

    bar = new ProgressBar(top, flags | SWT.INDETERMINATE);
    bar.setVisible(false);
    bar.addMouseListener(mouseListener);

    GridData gd;
    int hh = 12;
    if (isHorizontal()) {
      gd = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
      gd.heightHint = hh;
    } else {
      gd = new GridData(SWT.CENTER, SWT.BEGINNING, false, true);
      gd.widthHint = hh;
    }

    bar.setLayoutData(gd);

    toolbar = new ToolBar(top, SWT.FLAT);
    toolbar.setVisible(false);

    toolButton = new ToolItem(toolbar, SWT.NONE);
    toolButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            doAction();
          }
        });

    if (isCarbon) {
      new Label(top, SWT.NONE).setLayoutData(new GridData(4, 4));
    }

    refresh();

    return top;
  }
コード例 #5
0
 @Override
 public ImageDescriptor getImageDescriptor() {
   return WorkbenchImages.getImageDescriptor(ISharedImages.IMG_ETOOL_DEF_PERSPECTIVE);
 }
コード例 #6
0
  private Composite createActions(
      final ChangeDetail changeDetail,
      final PatchSetDetail patchSetDetail,
      final PatchSetPublishDetail publishDetail,
      Composite composite) {
    Composite buttonComposite = new Composite(composite, SWT.NONE);
    RowLayout layout = new RowLayout();
    layout.center = true;
    layout.spacing = 10;
    buttonComposite.setLayout(layout);

    boolean canPublish =
        getTaskData()
            .getAttributeMapper()
            .getBooleanValue(
                getTaskData()
                    .getRoot()
                    .getAttribute(GerritTaskSchema.getDefault().CAN_PUBLISH.getKey()));
    boolean canSubmit = false;
    boolean canRebase = false;
    if (changeDetail.getCurrentActions() != null) {
      canSubmit = changeDetail.getCurrentActions().contains(ApprovalCategory.SUBMIT);
    } else if (changeDetail instanceof ChangeDetailX) {
      // Gerrit 2.2 and later
      canSubmit = ((ChangeDetailX) changeDetail).canSubmit();
      canRebase = ((ChangeDetailX) changeDetail).canRebase();
    }

    if (canPublish) {
      Button publishButton = toolkit.createButton(buttonComposite, "Publish Comments...", SWT.PUSH);
      publishButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              doPublish(publishDetail);
            }
          });
    }

    Button fetchButton = toolkit.createButton(buttonComposite, "Fetch...", SWT.PUSH);
    fetchButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            doFetch(changeDetail, patchSetDetail);
          }
        });

    final Composite compareComposite = toolkit.createComposite(buttonComposite);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(compareComposite);

    Button compareButton = toolkit.createButton(compareComposite, "Compare With Base", SWT.PUSH);
    compareButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            doCompareWith(changeDetail, null, patchSetDetail.getPatchSet());
          }
        });

    if (changeDetail.getPatchSets().size() > 1) {
      Button compareWithButton = toolkit.createButton(compareComposite, "", SWT.PUSH);
      GridDataFactory.fillDefaults().grab(false, true).applyTo(compareWithButton);
      compareWithButton.setImage(
          WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_BUTTON_MENU));
      compareWithButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              showCompareMenu(compareComposite, changeDetail, patchSetDetail);
            }

            private void showCompareMenu(
                Composite compareComposite,
                ChangeDetail changeDetail,
                PatchSetDetail patchSetDetail) {
              Menu menu = new Menu(compareComposite);
              Point p = compareComposite.getLocation();
              p.y = p.y + compareComposite.getSize().y;
              p = compareComposite.getParent().toDisplay(p);
              fillCompareWithMenu(changeDetail, patchSetDetail, menu);
              menu.setLocation(p);
              menu.setVisible(true);
            }
          });
    }

    if (canRebase) {
      Button rebaseButton = toolkit.createButton(buttonComposite, "Rebase", SWT.PUSH);
      rebaseButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              doRebase(patchSetDetail.getPatchSet());
            }
          });
    }

    if (canSubmit) {
      Button submitButton = toolkit.createButton(buttonComposite, "Submit", SWT.PUSH);
      submitButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              doSubmit(patchSetDetail.getPatchSet());
            }
          });
    }

    if (changeDetail != null && changeDetail.isCurrentPatchSet(patchSetDetail)) {
      if (changeDetail.canAbandon()) {
        Button abondonButton = toolkit.createButton(buttonComposite, "Abandon...", SWT.PUSH);
        abondonButton.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                doAbandon(patchSetDetail.getPatchSet());
              }
            });
      } else if (changeDetail.canRestore()) {
        Button restoreButton = toolkit.createButton(buttonComposite, "Restore...", SWT.PUSH);
        restoreButton.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                doRestore(patchSetDetail.getPatchSet());
              }
            });
      }
    }
    return buttonComposite;
  }