/** * Create contents of the application window. * * @param parent the parent * @return the control */ @Override protected Control createContents(Composite parent) { getShell().setText("Execution tracking console - " + consoleName); getShell().setBounds(50, 250, 450, 500); Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(1, false)); { styledText = new StyledText(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); styledText.setEditable(false); } statusLineManager.setMessage("Waiting for tracking status from server. Please wait!"); return container; }
/** * Recursive function for setting up children controls for a control if it is * a composite and setting up the main control's manager. * @param part * @param control */ private void setupControls(IWorkbenchPart part, Control control) { //If composite, setup children controls. if (control instanceof Composite) { Composite composite = (Composite) control; Control[] children = composite.getChildren(); if (children.length > 0 && children[0] != null) { for (Control curControl : children) setupControls(part, curControl); } } if (control instanceof StyledText) { //set up styled text manager if there is one setupStyledText((IEditorPart) part, (StyledText) control); } else if (control instanceof Browser) { //set up browser manager if there is one setupBrowser((Browser) control); } //TODO: no control set up for a ProjectExplorer, since there isn't an need for //a Manager right now, might be needed in the future }
private void buildContextMenu(MouseEvent e) { Point point = new Point(e.x, e.y); TreeItem treeItem = getTree().getItem(point); Menu menu = new Menu((Control)e.getSource()); Iterator<MenuMaker> i = menuMakers.iterator(); int cpt = 0; while(i.hasNext()) { i.next().makeMenu(this, treeItem, e, menu); if (i.hasNext() && menu.getItemCount() != cpt) { new MenuItem(menu, SWT.SEPARATOR); cpt = menu.getItemCount(); } } if (menu.getItemCount() > 0) { menu.setVisible(true); } else { menu.dispose(); } }
@Override protected Control createDialogArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); Label labelDescription = new Label(composite, SWT.WRAP); labelDescription.setText("Limit chars logs"); final Spinner spinnerBox = new Spinner(composite, SWT.WRAP); spinnerBox.setMaximum(MAX_LOG_CHARS); spinnerBox.setMinimum(MIN_LOG_CHARS); spinnerBox.setSelection(limitLogsChars); spinnerBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); spinnerBox.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { limitLogsChars = Integer.parseInt(spinnerBox.getText()); } }); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); composite.setLayout(new GridLayout(2, false)); return composite; }
/** * Bind a control. If it is a composite, also bind all of its children. * @param control Highest level control. * @param unbind If true, unbind instead of bind. */ private static void bindControl(IWorkbenchPartReference partRef, Control control, boolean unbind) { //If composite, bind children. if (control instanceof Composite) { Composite composite = (Composite) control; Control[] children = composite.getChildren(); if (children.length > 0 && children[0] != null) { for (Control curControl : children) bindControl(partRef, curControl, unbind); } } //control should not have any data set //upon reaching this part of the method IGazeHandler handler = GazeHandlerFactory. createHandler(control, partRef); if (handler != null && !unbind) control.setData(KEY_HANDLER, handler); else control.setData(KEY_HANDLER, null); }
@Override protected Control createButtonBar(Composite parent) { final Composite buttonBar = (Composite) super.createButtonBar(parent); logout = new Button(buttonBar, SWT.CENTER); final GridData layoutData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); layoutData.widthHint = 100; logout.setLayoutData(layoutData); logout.setText("Log Out"); logout.setVisible(credentials.isKeepLogged()); logout.addListener(SWT.Selection, e -> { credentials.setApplication(null); credentials.setUserKey(false, null); close(); }); logout.moveAbove(super.buttonControl); return buttonBar; }
protected Control createContents(Composite parent) { GridLayout gridLayout = new GridLayout(1, false); gridLayout.numColumns = 1; parent.setLayout(gridLayout); String[] values = PreferenceManager.getAuthorizedFolderForGraphDefinition(); String[] propertyNames = new String[] { PreferenceManager.AUTHORIZED_FOLDERS_FOR_GRAPH_DEFINITION }; authorizedFolders = new CustomListWithButtons(parent, SWT.NONE, true, new StringCustomListModel(MessageUtil.getString("authorizedfolderforgraphmodel"), values)); authorizedFolders.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); authorizedFolders.setPropertyNames(propertyNames); values = PreferenceManager.getGraphWalkerJavaLibName(); propertyNames = new String[] { PreferenceManager.GRAPHWALKER_JAVALIBRARIES }; gw4eLibraries = new CustomListWithButtons(parent, SWT.NONE, true, new StringCustomListModel(MessageUtil.getString("graphwalkerlibraries"), values)); gw4eLibraries.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); gw4eLibraries.setPropertyNames(propertyNames); return new Canvas(parent, 0); }
/** * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); composite.setLayout(layout); GridData data = new GridData(GridData.FILL); data.grabExcessHorizontalSpace = true; composite.setLayoutData(data); Preferences prefs = builderPreferences(); addFirstSection(composite); addSeparator(composite); addSecondSection(composite, prefs); addSpecificSection(composite, prefs); return composite; }
@Override public void createControl(Composite parent) { initializeDialogUnits(parent); final Composite composite= new Composite(parent, SWT.NULL); composite.setFont(parent.getFont()); composite.setLayout(initGridLayout(new GridLayout(1, false), true)); composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // create UI elements Control nameControl= createNameControl(composite); nameControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Control locationControl= createLocationControl(composite); locationControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Control infoControl= createInfoControl(composite); infoControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); setControl(composite); }
public BufferedLabel( Composite composite, int attrs ) { super((attrs&SWT.DOUBLE_BUFFERED)==0?new Label( composite, attrs ):new DoubleBufferedLabel( composite, attrs )); label = (Control)getWidget(); ClipboardCopy.addCopyToClipMenu( label, new ClipboardCopy.copyToClipProvider() { @Override public String getText() { return( BufferedLabel.this.getText()); } }); }
/** * Sets or clears the error message. * If not <code>null</code>, the OK button is disabled. * * @param errorMessage * the error message, or <code>null</code> to clear * @since 3.0 */ public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; if (errorMessageText != null && !errorMessageText.isDisposed()) { errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$ // Disable the error message text control if there is no error, or // no error text (empty or whitespace only). Hide it also to avoid // color change. // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281 boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0; errorMessageText.setEnabled(hasError); errorMessageText.setVisible(hasError); errorMessageText.getParent().update(); // Access the ok button by id, in case clients have overridden button creation. // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643 Control button = getButton(IDialogConstants.OK_ID); if (button != null) { button.setEnabled(errorMessage == null); } } }
@Override protected Control createContents(Composite parent) { Label trackerListLabel = new Label(parent, SWT.NONE); trackerListLabel.setText("Eye Tracker Interface"); //Get currently selected eye tracker type as index into list. TrackerType[] trackerKeys = EyeTrackerFactory.getAvailableEyeTrackers() .keySet().toArray(new TrackerType[0]); int trackerSelectionIndex = Arrays.asList(trackerKeys).indexOf( TrackerType.valueOf(getPreferenceStore() .getString(EYE_TRACKER_TYPE))); //Create tracker list. trackerList = new List(parent, SWT.BORDER); String[] items = EyeTrackerFactory.getAvailableEyeTrackers().values() .toArray(new String[0]); trackerList.setItems(items); trackerList.setSelection(trackerSelectionIndex); return parent; }
@Override protected Control createDialogArea(Composite parent) { Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = gridLayout.marginHeight = 0; container.setLayout(gridLayout); GridData gd = new GridData(GridData.FILL_BOTH); gd.minimumHeight = 600; gd.minimumWidth = 1024; container.setLayoutData(gd); diffPane = new DiffPaneViewer(container, SWT.NONE); diffPane.setDbSources(dbProject, dbRemote); diffPane.setInput(input, availableElements); return area; }
/** * @param control * @return */ public Control addBasicAuthKeyComposite(Composite control, FTPAuthOperationDetails authOperationDetails){ Composite basicAuthKeyComposite = new Composite(control, SWT.BORDER); basicAuthKeyComposite.setLayout(new GridLayout(3, false)); basicAuthKeyComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); FTPWidgetUtility ftpWidgetUtility = new FTPWidgetUtility(); ftpWidgetUtility.createLabel(basicAuthKeyComposite, "User ID"); ftpWidgetUtility.createText(basicAuthKeyComposite, "", SWT.BORDER); new Button(basicAuthKeyComposite, SWT.NONE).setVisible(false); ftpWidgetUtility.createLabel(basicAuthKeyComposite, "Password"); ftpWidgetUtility.createText(basicAuthKeyComposite, "", SWT.PASSWORD|SWT.BORDER); new Button(basicAuthKeyComposite, SWT.NONE).setVisible(false); ftpWidgetUtility.createLabel(basicAuthKeyComposite, "Public/Private Key"); Text privateKeyTxt = (Text) ftpWidgetUtility.createText(basicAuthKeyComposite, "", SWT.BORDER); Button keyFileBrwsBtn = new Button(basicAuthKeyComposite, SWT.NONE); keyFileBrwsBtn.setText("..."); selectionListener(keyFileBrwsBtn, privateKeyTxt); return basicAuthKeyComposite; }
/** * Adds a {@link DisposeListener} to the created {@link Control}. Listeners can be added either before or after the * Control is created. * * @param disposeListener The {@link DisposeListener} to add. * * @see Control#addControlDisposeListener(DisposeListener) */ public void addControlDisposeListener(DisposeListener disposeListener) { Control control = getControl(); if (control != null) { if (control.isDisposed()) { return; } control.addDisposeListener(disposeListener); } else { if (_DisposeListeners == null) { _DisposeListeners = new LinkedHashSet<DisposeListener>(); } _DisposeListeners.add(disposeListener); } }
private void obfuscatedImage(Composite c, Image image) { if (c == null || c.isDisposed() || !c.isVisible()) { return; } Control[] children = c.getChildren(); for (Control childControl : children) { if (!childControl.isVisible()) { continue; } ObfuscateImage oi = (ObfuscateImage) childControl.getData("ObfuscateImage"); if (oi != null) { oi.obfuscatedImage(image); continue; } if (childControl instanceof Composite) { obfuscatedImage((Composite) childControl, image); } } }
@Override protected Control createContents(Composite parent) { Composite panel = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; panel.setLayout(layout); btnForceUnixNewlines = new Button(panel, SWT.CHECK); btnForceUnixNewlines.setText(Messages.ProjectProperties_force_unix_newlines); btnForceUnixNewlines.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1)); btnForceUnixNewlines.setSelection(prefs.getBoolean(PROJ_PREF.FORCE_UNIX_NEWLINES, true)); Label label = new Label(panel, SWT.NONE); label.setText(Messages.projectProperties_timezone_for_all_db_connections); cmbTimezone = new Combo(panel, SWT.BORDER | SWT.DROP_DOWN); cmbTimezone.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); cmbTimezone.setItems(UIConsts.TIME_ZONES.toArray(new String[UIConsts.TIME_ZONES.size()])); String tz = prefs.get(PROJ_PREF.TIMEZONE, ApgdiffConsts.UTC); cmbTimezone.setText(tz); cmbTimezone.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { checkSwitchWarnLbl(); } }); lblWarn = new CLabel(panel, SWT.NONE); lblWarn.setImage(Activator.getEclipseImage(ISharedImages.IMG_OBJS_WARN_TSK)); lblWarn.setText(Messages.ProjectProperties_change_projprefs_warn); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, false, false, 2, 1); gd.exclude = true; lblWarn.setLayoutData(gd); lblWarn.setVisible(false); return panel; }
@Override protected AbstractKeyListener getMouseListener(Control control, Observer<? super KeyEvent> observer) { return new AbstractKeyListener(control) { @Override public void keyPressed(KeyEvent e) { if (!isDisposed()) { observer.onNext(e); } } }; }
protected void toggleAdvanced ( final boolean selection ) { if ( selection ) { openTray ( new DialogTray () { @Override protected Control createContents ( final Composite parent ) { return createAdvancedContent ( parent ); } } ); } else { closeTray (); } }
/** * Finds the control under the specified screen coordinates and calls its * gaze handler on the localized point. Returns the gaze response or null if * the gaze is not handled. */ private IGazeResponse handleGaze(int screenX, int screenY, Gaze gaze){ Queue<Control[]> childrenQueue = new LinkedList<Control[]>(); childrenQueue.add(rootShell.getChildren()); Rectangle monitorBounds = rootShell.getMonitor().getBounds(); while (!childrenQueue.isEmpty()) { for (Control child : childrenQueue.remove()) { Rectangle childScreenBounds = child.getBounds(); Point screenPos = child.toDisplay(0, 0); childScreenBounds.x = screenPos.x - monitorBounds.x; childScreenBounds.y = screenPos.y - monitorBounds.y; if (childScreenBounds.contains(screenX, screenY)) { if (child instanceof Composite) { Control[] nextChildren = ((Composite) child).getChildren(); if (nextChildren.length > 0 && nextChildren[0] != null) { childrenQueue.add(nextChildren); } } IGazeHandler handler = (IGazeHandler) child .getData(HandlerBindManager.KEY_HANDLER); if (child.isVisible() && handler != null) { return handler.handleGaze(screenX, screenY, screenX - childScreenBounds.x, screenY - childScreenBounds.y, gaze); } } } } return null; }
/** * @param control * @return */ public Control addLocalRemoteRemoveFiles(Composite control){ Composite composite = new Composite(control, SWT.BORDER); composite.setLayout(new GridLayout(3, false)); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); FTPWidgetUtility ftpWidgetUtility = new FTPWidgetUtility(); ftpWidgetUtility.createLabel(composite, "Local Path"); Text localPathTxt = (Text) ftpWidgetUtility.createText(composite, "", SWT.BORDER); Button localPathBrwsBtn = new Button(composite, SWT.NONE); localPathBrwsBtn.setText("..."); selectionListener(localPathBrwsBtn, localPathTxt); ftpWidgetUtility.createLabel(composite, "File Name"); ftpWidgetUtility.createText(composite, "", SWT.BORDER); return composite; }
/** Horizontal line separator */ public static Control insertHorizontalSeparator(Composite parent) { Label label = new Label(parent, SWT.SEPARATOR | SWT.WRAP | SWT.HORIZONTAL | SWT.SHADOW_NONE); GridData separatorLayoutData = new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1); separatorLayoutData.heightHint = 25; label.setLayoutData(separatorLayoutData); return label; }
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); try { GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_BOTH); objectsExplorerComposite = new ObjectsExplorerComposite(composite, SWT.NONE, parentObject, ExtractionRule.class); objectsExplorerComposite.setLayoutData(gridData); } catch(Exception e) {;} return composite; }
private void registerContextMenu() { final MenuManager contextMenu = new MenuManager(); contextMenu.setRemoveAllWhenShown(true); this.getSite().registerContextMenu(contextMenu, ContextualView.treeViewer); // Add in the entries for all markers views if this has a different if if (!this.getSite().getId().equals(ContextualView.MARKERS_ID)) { this.getSite().registerContextMenu(ContextualView.MARKERS_ID, contextMenu, ContextualView.treeViewer); } final Control control = ContextualView.treeViewer.getControl(); final Menu menu = contextMenu.createContextMenu(control); control.setMenu(menu); }
@Override public void attachToPropertySubGroup(AbstractELTContainerWidget subGroup) { ELTDefaultSubgroupComposite eltSuDefaultSubgroupComposite = new ELTDefaultSubgroupComposite(subGroup.getContainerControl()); eltSuDefaultSubgroupComposite.createContainerWidget(); AbstractELTWidget eltDefaultLable = new ELTDefaultLable("ID"); eltSuDefaultSubgroupComposite.attachWidget(eltDefaultLable); setPropertyHelpWidget((Control) eltDefaultLable.getSWTWidgetControl()); eltDefaultTextBox = new ELTDefaultTextBox().grabExcessHorizontalSpace(true).textBoxWidth(100); eltSuDefaultSubgroupComposite.attachWidget(eltDefaultTextBox); eltDefaultTextBox.setEnabled(false); populateWidget(); }
@Override protected Control createDialogArea ( final Composite parent ) { setMessage ( Messages.LockMessageDialog_DialogMessage ); setTitle ( Messages.LockMessageDialog_DialogTitle ); getShell ().setText ( Messages.LockMessageDialog_DialogTitle ); final Composite wrapper = (Composite)super.createDialogArea ( parent ); this.text = new Text ( wrapper, SWT.BORDER | SWT.MULTI ); this.text.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) ); if ( this.textString != null ) { this.text.setText ( this.textString ); this.text.setSelection ( 0, this.text.getText ().length () ); } return wrapper; }
private static void open(final int width, final int height) { SWTTestUtil.openShell(String.format("FX Canvas Frame Rater (%dx%d)", width, height), width, height, new Function<Shell, Control>() { @Override public Control apply(Shell shell) { FXCanvasComposite fxCanvas = new FXCanvasComposite(shell, SWT.NONE); ModifySizeThread modifySizeThread = new ModifySizeThread(shell); modifySizeThread.addTask(600, 400); modifySizeThread.addTask(300, 200); modifySizeThread.addTask(0, 0); modifySizeThread.start(); return fxCanvas; } }); Recorder.close(); }
/** * Create contents of the dialog. * @param parent */ @Override protected Control createDialogArea(Composite parent) { createPropertyDialogContainer(parent); propertyDialogButtonBar = new PropertyDialogButtonBar(container); propertyDialogBuilder = new PropertyDialogBuilder(container,propertyTree,componentProperties,propertyDialogButtonBar,component,this); propertyDialogBuilder.buildPropertyWindow(); return container; }
@Override protected Control createDialogArea(Composite parent) { Composite composite=super.createDialogArea(parent).getParent(); ELTDefaultSubgroupComposite eltSuDefaultSubgroupComposite = new ELTDefaultSubgroupComposite(composite); eltSuDefaultSubgroupComposite.createContainerWidget(); eltSuDefaultSubgroupComposite.numberOfBasicWidgets(2); AbstractELTWidget eltDefaultLable = new ELTDefaultLable(" "+ Messages.FILE_NAME +" :"); eltSuDefaultSubgroupComposite.attachWidget(eltDefaultLable); eltDefaultText= new ELTDefaultTextBox().grabExcessHorizontalSpace(true).textBoxWidth(280); eltSuDefaultSubgroupComposite.attachWidget(eltDefaultText); return composite; }
private void updateStoreState(final Binary binary, final Object newValue) { if (newValue instanceof String && !Strings.isNullOrEmpty((String) newValue)) { final File file = new File(String.valueOf(newValue)); store.setPath(binary, file.toURI()); } else { store.setPath(binary, null); } store.save(); final IStatus status = binary.validate(); UIUtils.getDisplay().asyncExec(new Runnable() { @Override public void run() { final Control control = getControl(); if (null != control && !control.isDisposed()) { if (!status.isOK()) { setErrorMessage(status.getMessage()); } else { setErrorMessage(null); } } } }); }
private void clearPanel() { if ( panel.isDisposed()){ return; } Control[] controls = panel.getChildren(); for (int i = 0; i < controls.length; i++) { if (controls[i] != null && !controls[i].isDisposed()) controls[i].dispose(); } setTitle(""); setCurrentInfo(""); }
@Override protected Control createContents(final Composite parent) { final Control control = super.createContents(parent); setInitialSelection(); updateButtonAvailability(); return control; }
/** * Create contents of the dialog. * * @param parent */ @Override protected Control createDialogArea(Composite parent) { isAnyUpdatePerformed = false; getShell().setText(Constants.PARTITION_KEYS_WINDOW_TITLE); container = (Composite) super.createDialogArea(parent); container.setLayout(new GridLayout(1, false)); SashForm outterSashForm = new SashForm(container, SWT.BORDER); outterSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); PartKeyComposite = new Composite(outterSashForm, SWT.NONE); addButtonPanel(PartKeyComposite); SashForm srcTgtTableSashForm = new SashForm(PartKeyComposite, SWT.NONE); srcTgtTableSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); createSourceTable(srcTgtTableSashForm); createTargetTable(srcTgtTableSashForm); partkeyValueComposite = new Composite(outterSashForm, SWT.NONE); createKeyValueComposite(partkeyValueComposite); outterSashForm.setWeights(new int[] {451, 176}); checkTargetFieldsSequence(); getShell().setMinimumSize(400,500); return container; }
private void buildTBoxComposite(){ // remove all of the old children from the composite. Control[] cList = tboxComp.getChildren(); for(int i=0; i<cList.length; i++){ Control c = cList[i]; if(c instanceof ParamComp){ ((ParamComp)c).removeParamListener(); } c.dispose(); } // setup the composite for rowLayout. GridLayout gl = new GridLayout(); gl.numColumns = 1; gl.marginWidth = 2; gl.marginHeight = 2; gl.verticalSpacing = 1; gl.horizontalSpacing = 0; tboxComp.setLayout(gl); // // TODO: sort all tools alphabetically LinkedList<MenuetElement> mElements = AvoGlobal.menuet.menuetElements[AvoGlobal.menuet.currentToolMode]; for(int i=0; i<mElements.size(); i++){ MenuetElement me = mElements.get(i); if(me.isStoredInToolbox){ MTToolComposite cnew = new MTToolComposite(tboxComp, SWT.BORDER, me); GridData gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.widthHint = 300; cnew.setLayoutData(gd); } } tboxComp.pack(); spComp.setMinSize(tboxComp.computeSize(spComp.getClientArea().width-10, SWT.DEFAULT)); }
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); final GridLayout gridLayout = new GridLayout(); composite.setLayout(gridLayout); try { dlgComposite = new ProjectChooseTestCasesDialogComposite(composite, SWT.FILL, project); listTCSequence = dlgComposite.getListTCSequence(); listTCTransaction = dlgComposite.getListTCTransaction(); } catch (Exception e) {}; return composite; }
private static void saveEditorContentsAsImage(IEditorPart editorPart, GraphicalViewer viewer, String saveFilePath, int format) { ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer.getEditPartRegistry().get(LayerManager.ID); IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);// rootEditPart.getFigure(); Rectangle rootFigureBounds = rootFigure.getBounds(); Control figureCanvas = viewer.getControl(); GC figureCanvasGC = new GC(figureCanvas); Image img = new Image(null, rootFigureBounds.width, rootFigureBounds.height); GC imageGC = new GC(img); imageGC.setBackground(figureCanvasGC.getBackground()); imageGC.setForeground(figureCanvasGC.getForeground()); imageGC.setFont(figureCanvasGC.getFont()); imageGC.setLineStyle(figureCanvasGC.getLineStyle()); imageGC.setLineWidth(figureCanvasGC.getLineWidth()); imageGC.setXORMode(figureCanvasGC.getXORMode()); Graphics imgGraphics = new SWTGraphics(imageGC); rootFigure.paint(imgGraphics); ImageData[] imgData = new ImageData[1]; imgData[0] = img.getImageData(); ImageLoader imgLoader = new ImageLoader(); imgLoader.data = imgData; imgLoader.save(saveFilePath, format); figureCanvasGC.dispose(); imageGC.dispose(); img.dispose(); }
@Override protected Control createButtonBar(Composite parent) { Control buttonBar = super.createButtonBar(parent); getButton(IDialogConstants.OK_ID).setText("Import"); getButton(IDialogConstants.OK_ID).setEnabled(false); return buttonBar; }
public void update(String currentPageId) { if (composite == null || composite.isDisposed()) return; GC metricsGC = new GC(composite); FontMetrics metrics = metricsGC.getFontMetrics(); metricsGC.dispose(); List buttons = (List) buttonMap.get(currentPageId); Control[] children = composite.getChildren(); int visibleChildren = 0; Button closeButton = getButton(IDialogConstants.CLOSE_ID); for (int i = 0; i < children.length; i++) { Control control = children[i]; if (closeButton == control) closeButton.dispose(); else { control.setVisible(false); setButtonLayoutData(metrics, control, false); } } if (buttons != null) { for (int i = 0; i < buttons.size(); i++) { Button button = (Button) buttons.get(i); button.setVisible(true); setButtonLayoutData(metrics, button, true); GridData data = (GridData) button.getLayoutData(); data.exclude = false; visibleChildren++; } } GridLayout compositeLayout = (GridLayout) composite.getLayout(); compositeLayout.numColumns = visibleChildren; composite.layout(true); }
@Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button button = new Button(container, SWT.PUSH); button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); button.setText("Press me"); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { System.out.println("Pressed"); } }); return container; }
protected void createDependency(Button master, Control slave) { Assert.isNotNull(slave); indent(slave); MasterButtonSlaveSelectionListener listener = new MasterButtonSlaveSelectionListener(master, slave); master.addSelectionListener(listener); this.masterSlaveListeners.add(listener); }