/* (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(); }
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; }