/** * Create an instance of the AboutDialog for the given window. * * @param parentShell * The parent of the dialog. */ public CustomAboutDialog(Shell parentShell) { super(parentShell); this.parentShell = parentShell; setShellStyle(SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.WRAP); product = Platform.getProduct(); if (product != null) { productName = product.getName(); } if (productName == null) { productName = WorkbenchMessages.AboutDialog_defaultProductName; } // setDialogHelpAvailable(true); }
/** * Returns the initial location to use for the shell. The default implementation centers the shell horizontally (1/2 * of the difference to the left and 1/2 to the right) and vertically (1/3 above and 2/3 below) relative to the * active workbench windows shell, or display bounds if there is no parent shell. * * @param shell * the shell which initial location has to be calculated. * @param initialSize * the initial size of the shell, as returned by <code>getInitialSize</code>. * @return the initial location of the shell */ public static Point getInitialLocation(final Shell shell, final Point initialSize) { final Composite parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); Monitor monitor = shell.getDisplay().getPrimaryMonitor(); if (parent != null) { monitor = parent.getMonitor(); } final Rectangle monitorBounds = monitor.getClientArea(); Point centerPoint; if (parent != null) { centerPoint = Geometry.centerPoint(parent.getBounds()); } else { centerPoint = Geometry.centerPoint(monitorBounds); } return new Point(centerPoint.x - (initialSize.x / 2), Math.max( monitorBounds.y, Math.min(centerPoint.y - (initialSize.y * 2 / 3), monitorBounds.y + monitorBounds.height - initialSize.y))); }
public static void openShell(String format, int weight, int height, Function<Shell, Control> function) { Display display = new Display(); Shell shell = new Shell(display); shell.setSize(weight, height); shell.setLayout(new FillLayout()); function.apply(shell); shell.open(); while(!shell.isDisposed()) { if(!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
public static void doProgressTask(final Shell s, final ProgressTask t) { SWTAsync.slow(new SWTAsync("doProgressTask") { public void task() { ProgressDialog p = new ProgressDialog(s, t); t.setProgress(p); p.open(); p.getShell().setText(t.getName()); //$NON-NLS-1$ // pd.taskLabel.setText("taskLabel"); // pd.messageLabel.setText("messageLabel"); p.runTask(); } }); }
public SelectAnyEObjectDialog(Shell parent, ResourceSet resourceSet, ILabelProvider renderer) { super(parent, renderer); _searchedResourceSet = resourceSet; ArrayList<EObject> all = new ArrayList<EObject>(); EcoreUtil.resolveAll(resourceSet); for (Resource r : _searchedResourceSet.getResources()) { for (TreeIterator<EObject> iterator = r.getAllContents(); iterator.hasNext();) { EObject o = iterator.next(); if(select(o)) all.add(o); } } Object[] elements = all.toArray(); this.setElements(elements); }
/** * Create the dialog. * @param parentShell */ public ParameterGridDialog(Shell parentShell) { super(parentShell); setShellStyle(SWT.CLOSE | SWT.RESIZE | SWT.TITLE | SWT.WRAP | SWT.APPLICATION_MODAL); runGraph=false; lastRowLastColumnTraverseListener=new TraverseListener() { @Override public void keyTraversed(TraverseEvent e) { if(e.detail == SWT.TRAVERSE_TAB_NEXT) addRowToTextGrid(); } }; }
@Override public void run() { if (GenerationUtils.validate(containerName)) { Shell shell = Display.getDefault().getActiveShell(); boolean confirm = MessageDialog.openQuestion(shell, "Confirm Create", "Existing Files will be cleared. Do you wish to continue?"); if (confirm) { wsRoot = ResourcesPlugin.getWorkspace().getRoot(); names = StringUtils.split(containerName, "/"); wsRootRes = wsRoot.findMember(new Path("/" + names[0])); prj = wsRootRes.getProject(); steps = prj.getFolder("target/Steps"); File root = new File(steps.getLocation().toOSString()); if (root.exists()) { GenerationUtils.clearCreatedFolders(root); } for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { try { project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } catch (CoreException e) { } } } } }
@Override protected Shell createShell(Display display) throws Exception { this.model = new MultiStepModel(); Shell shell = new Shell(display); shell.setText("Multi-Step"); shell.setLayout(new GridLayout(1, false)); this.ui = new MultiStepComposite(shell, SWT.NONE); this.controller = BeanService.getInstance().createController(ui, model); controller.beanToUI(); controller.switchState(true); this.service = new MockScannableConnector(null); AnnotationManager manager = new AnnotationManager(Inject.class); manager.addDevices(ui); manager.invoke(Inject.class, service, model); shell.pack(); shell.setSize(500, 500); shell.open(); return shell; }
@Override protected Shell createShell(Display display) throws Exception { this.viewer = new ScannableViewer(); Shell shell = new Shell(display); shell.setText("Monitors"); shell.setLayout(new GridLayout(1, false)); viewer.createPartControl(shell); shell.pack(); shell.setSize(500, 500); shell.open(); return shell; }
/** * Find controls within a part, set it up to be used by iTrace, * and extract meta-data from it. * * @param partRef partRef that just became visible. */ private void setupControls(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(true); Control control = part.getAdapter(Control.class); //set up manager for control and managers for each child control if necessary if (control != null) { setupControls(part, control); } else { //Browser - always set up browser managers, no matter the partRef that //has become visible //not possible to get Browser control from a partRef Shell workbenchShell = partRef.getPage().getWorkbenchWindow().getShell(); for (Control ctrl: workbenchShell.getChildren()) { setupBrowsers(ctrl); } } }
/** * Build and show the Windows, dispose it after is is not longer needed. * @param parentShell The parent windows' Shell. * @param classLoader The system MugglClassLoader. */ public void show(Shell parentShell, MugglClassLoader classLoader) { try { this.display = Display.getDefault(); createShell(parentShell, classLoader); this.shell.open(); while (!this.shell.isDisposed()) { if (!this.display.readAndDispatch()) this.display.sleep(); } } catch (Throwable t) { t.printStackTrace(); StaticGuiSupport.processGuiError(t, "options", parentShell); } finally { doExit(); } }
private void renderTransparency(final Shell shell) { Group group = new Group(shell, SWT.NONE); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 6, 1)); group.setLayout(new GridLayout(1, false)); group.setText("Transparency"); final Scale transparencySlider = new Scale(group, SWT.HORIZONTAL); transparencySlider.setMinimum(20); transparencySlider.setMaximum(100); transparencySlider.setPageIncrement(90); transparencySlider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); transparencySlider.setSelection(100); transparencySlider.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { shell.setAlpha(255 * transparencySlider.getSelection() / 100); } }); }
/** * Notify error using message box (thread safe). * @param message The message to display * @param error The error that occurred */ public void notifyError ( final String message, final Throwable error ) { final Display display = getWorkbench ().getDisplay (); if ( !display.isDisposed () ) { display.asyncExec ( new Runnable () { @Override public void run () { final Shell shell = getWorkbench ().getActiveWorkbenchWindow ().getShell (); logger.debug ( "Shell disposed: {}", shell.isDisposed () ); if ( !shell.isDisposed () ) { final IStatus status = new OperationStatus ( IStatus.ERROR, PLUGIN_ID, 0, message + ":" + error.getMessage (), error ); ErrorDialog.openError ( shell, null, message, status ); } } } ); } }
private void attachButtonListner(Button selectKeysButton) { selectKeysButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String buttonText = Messages.UPDATE_KEYS_WINDOW_LABEL; FieldDialog fieldDialog = new FieldDialog(new Shell(), propertyDialogButtonBar); fieldDialog.setComponentName(buttonText); fieldDialog.setSourceFieldsFromPropagatedSchema(getPropagatedSchema()); if(StringUtils.isNotBlank(updateByKeysTextBox.getText())){ fieldDialog.setPropertyFromCommaSepratedString(updateByKeysTextBox.getText()); } fieldDialog.open(); String valueForNewTableTextBox = fieldDialog.getResultAsCommaSeprated(); if(valueForNewTableTextBox !=null){ updateByKeysTextBox.setText(valueForNewTableTextBox); } showHideErrorSymbol(widgets); } }); }
public EntryEditDialog ( final Shell shell, final Map.Entry<?, ?> entry ) { super ( shell ); this.entry = new ConfigurationEntry (); if ( entry == null ) { this.createMode = true; this.entry.setKey ( "" ); this.entry.setValue ( "" ); } else { this.entry.setKey ( "" + entry.getKey () ); this.entry.setValue ( "" + entry.getValue () ); this.createMode = false; } }
/** * Error message. * * @param message * the message */ public static void errorMessage(String message) { Shell shell = new Shell(); MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); messageBox.setText(ERROR); messageBox.setMessage(message); messageBox.open(); }
public void saveParameters() { //get map from file Map<String,String> currentParameterMap = getCurrentParameterMap(); if(currentParameterMap == null){ return; } List<String> letestParameterList = getLatestParameterList(); Map<String,String> newParameterMap = new LinkedHashMap<>(); for(int i=0;i<letestParameterList.size();i++){ newParameterMap.put(letestParameterList.get(i), ""); } for(String parameterName : currentParameterMap.keySet()){ newParameterMap.put(parameterName, currentParameterMap.get(parameterName)); } try { ParameterFileManager.getInstance().storeParameters(newParameterMap,null, getParameterFile()); } catch (IOException e) { logger.error("Unable to store parameters to the file", e); MessageBox messageBox = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK ); messageBox.setText("Error"); messageBox.setMessage("Unable to store parameters to the file - \n" + e.getMessage()); messageBox.open(); } refreshParameterFileInProjectExplorer(); }
/** * Create the dialog. * * @param parentShell * @wbp.parser.constructor */@Deprecated public JoinMapDialog(Shell parentShell) { super(parentShell); setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.WRAP | SWT.APPLICATION_MODAL | SWT.RESIZE); }
public static void pause(DownloadManager dm, Shell shell) { if (dm == null) { return; } int state = dm.getState(); if (state == DownloadManager.STATE_STOPPED || state == DownloadManager.STATE_STOPPING ){ return; } asyncPause(dm); }
public void run() { Display display = Display.getDefault(); Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT); Shell shell = getParentShell(); shell.setCursor(waitCursor); try { ProjectExplorerView explorerView = getProjectExplorerView(); if (explorerView != null) { TreeObject treeObject = explorerView.getFirstSelectedTreeObject(); if (treeObject instanceof MobileComponentTreeObject) { if (treeObject instanceof MobileApplicationComponentTreeObject) { MobileApplicationComponentTreeObject mpcto = (MobileApplicationComponentTreeObject) treeObject; ApplicationComponentEditor editor = mpcto.activeEditor(false); editor.launchBuilder(forceInstall, forceClean); } } } } catch (Throwable e) { ConvertigoPlugin.logException(e, "Unable to open the mobile builder!"); } finally { shell.setCursor(null); waitCursor.dispose(); } }
public ShellDocker(Control anchorControl, Shell dockedShell) { if (null == anchorControl || anchorControl.isDisposed()) { throw new NullPointerException("anchorControl cannot be null or disposed"); } if (null == dockedShell || dockedShell.isDisposed()) { throw new NullPointerException("dockedShell cannot be null or disposed"); } this.anchorControl = anchorControl; this.dockedShell = dockedShell; mainShell = anchorControl.getShell(); }
private void createMessageBox(){ Shell shell=container.getShell(); int style = SWT.APPLICATION_MODAL | SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION; messageBox = new MessageBox(shell,style); messageBox.setText("Confirm"); //$NON-NLS-1$ messageBox.setMessage(Messages.MessageBeforeClosingWindow); }
/** * Display a dialog box with the error icon and only the ok button. */ public static void showErrorDialog(Shell shell, String title, String message) { MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); messageBox.setText(title); messageBox.setMessage(message); messageBox.open(); }
public static DownloadBar open(DownloadManager download, Shell main) { DownloadBar result = (DownloadBar)manager.getMiniBarForObject(download); if (result == null) { result = new DownloadBar(download, main); } return result; }
public PluginDialog(Shell shell) { super(shell); this.display = Display.getDefault(); fontName = display.getSystemFont().getFontData()[0].getName(); backColor = new Color(display, 244, 244, 244); rowColorSelection = display.getSystemColor(SWT.COLOR_WHITE); titleFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL); topFont = new Font(display, fontName, getTopFontSize(), SWT.NORMAL); }
public void showWarning(String message) { EclipseUtil.safeAsyncExec(new Runnable() { @Override public void run() { Shell shell = getActiveWorkbenchShell(); MessageDialog.openWarning(shell, JENKINS_EDITOR, message); } }); }
/** * Create the Lookup mapping dialog. * * @param parentShell * @wbp.parser.constructor */@Deprecated public LookupMapDialog(Shell parentShell) { super(parentShell); setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.WRAP | SWT.APPLICATION_MODAL | SWT.RESIZE); }
private void resetWorkbench() { try { IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences(); for (IViewReference iViewReference : views) { if ( iViewReference.getTitle().equals( "Welcome" ) ) { iViewReference.getPage().hideView(iViewReference); break; } } IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); IWorkbenchPage page = workbenchWindow.getActivePage(); Shell activeShell = Display.getCurrent().getActiveShell(); if ( activeShell != null && activeShell != workbenchWindow.getShell() ) { activeShell.close(); } page.closeAllEditors( false ); page.resetPerspective(); String defaultPerspectiveId = workbench.getPerspectiveRegistry().getDefaultPerspective(); workbench.showPerspective( defaultPerspectiveId, workbenchWindow ); page.resetPerspective(); } catch ( WorkbenchException e ) { throw new RuntimeException( e ); } }
protected void openDialog ( final Display display, final Shell parentShell, final Callback[] callbacks, final String dialogTitle ) { try { for ( final Callback cb : callbacks ) { if ( cb instanceof ConfirmationCallback ) { final Boolean result = showDialog ( (ConfirmationCallback)cb, display, parentShell, dialogTitle ); if ( result == null ) { setError ( new CancellationException ( "Cancelled by user request" ) ); } else { ( (ConfirmationCallback)cb ).setValue ( result ); } } else { cb.cancel (); } } setResult ( callbacks ); } catch ( final Exception e ) { setError ( e ); } }
public void run() { Display display = Display.getDefault(); Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT); Shell shell = getParentShell(); shell.setCursor(waitCursor); MessageDialog.openInformation( shell, "Convertigo Plug-in", "The choosen operation is not yet implemented : '"+ action.getId() + "'."); shell.setCursor(null); waitCursor.dispose(); }
public static void main(final String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); Locale.setDefault(Locale.ENGLISH); final TipDayEx tipDayEx = new TipDayEx(); String yamlFile = String.format("%s/src/main/resources/%s", System.getProperty("user.dir"), "help.yaml"); help = YamlHelper.loadHelp(yamlFile); for (Entry<String, String> helpdata : help.entrySet()) { String title = helpdata.getKey(); String description = helpdata.getValue(); tipDayEx.addTip(String.format("<h4>%s</h4>%s", title, description)); } if (tipDayEx.getTips().size() == 0) { for (String tipMessage : new String[] { "This is the first tip", "This is the second tip", "This is the third tip", "This is the forth tip", "This is the fifth tip" }) { tipDayEx.addTip(String.format( "<h4>%s</h4>" + "<b>%s</b> " + "<u>%s</u> " + "<i>%s</i> " + "%s " + "%s<br/>" + "<p color=\"#A00000\">%s</p>", tipMessage, tipMessage, tipMessage, tipMessage, tipMessage, tipMessage, tipMessage)); } } tipDayEx.open(shell, display); display.dispose(); }
public void run() { Display display = Display.getDefault(); Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT); Shell shell = getParentShell(); shell.setCursor(waitCursor); try { ProjectExplorerView explorerView = getProjectExplorerView(); if (explorerView != null) { DatabaseObjectTreeObject treeObject = null; Statement statement = null; TreeObject[] treeObjects = explorerView.getSelectedTreeObjects(); for (int i = treeObjects.length-1 ; i>=0 ; i--) { treeObject = (DatabaseObjectTreeObject) treeObjects[i]; if (treeObject instanceof StatementTreeObject) { StatementTreeObject statementTreeObject = (StatementTreeObject)treeObject; statement = (Statement)statementTreeObject.getObject(); statement.setEnabled(false); statementTreeObject.setEnabled(false); statementTreeObject.hasBeenModified(true); } } explorerView.refreshSelectedTreeObjects(); } } catch (Throwable e) { ConvertigoPlugin.logException(e, "Unable to disable statement!"); } finally { shell.setCursor(null); waitCursor.dispose(); } }
public static void locateFiles( final DownloadManager[] dms, Shell shell ) { locateFiles( dms, null, shell ); }
@Override public void run() { Point location = MouseInfo.getPointerInfo().getLocation(); Rectangle bounds = new Rectangle(location.x, location.y, 250, 250); Shell shell = Display.getDefault().getActiveShell(); SchemaViewerPreferencesDialog dialog = new SchemaViewerPreferencesDialog(shell, bounds, serviceProvider); dialog.open(); }
public void run() { Display display = Display.getDefault(); Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT); Shell shell = getParentShell(); shell.setCursor(waitCursor); try { ProjectExplorerView explorerView = getProjectExplorerView(); if (explorerView != null) { String sXml; if (explorerView.isEditing()) { sXml = explorerView.getEditingText(); } else { // copy to clipboard manager sXml = copy(explorerView); } // copy to system clipboard if (sXml != null) { Clipboard clipboard = new Clipboard(display); TextTransfer textTransfer = TextTransfer.getInstance(); clipboard.setContents(new String[]{sXml}, new Transfer[]{textTransfer}); clipboard.dispose(); } } } catch (Throwable e) { ConvertigoPlugin.logException(e, "Unable to copy!"); } finally { shell.setCursor(null); waitCursor.dispose(); } }
/** * Create the dialog. * * @param parentShell */ public DevicePanel(Shell parentShell, String nodeid, String lab) { super(parentShell); this.nodeid = nodeid; setShellStyle(SWT.MAX | SWT.RESIZE); }
@Override public void mouseAction(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Event event, Widget... widgets) { Table table=(Table)event.widget; Shell tip=(Shell) table.getData("tip"); Label label=(Label) table.getData("label"); if(tip!=null) { tip.dispose(); tip = null; label = null; } }
private Shell getMainShell() { UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT(); if (null != uiFunctions) { return uiFunctions.getMainShell(); } throw new IllegalStateException( "No instance of UIFunctionsSWT found; the UIFunctionsManager might not have been initialized properly"); }
private void createCommentBoxShell(org.eclipse.swt.graphics.Rectangle commentBoxEditorBounds) { shell = new Shell(getParent(), SWT.NONE); shell.setBounds(commentBoxEditorBounds); GridLayout gl_shell = new GridLayout(1, false); gl_shell.verticalSpacing = 0; gl_shell.marginWidth = 0; gl_shell.marginHeight = 0; gl_shell.horizontalSpacing = 0; shell.setLayout(gl_shell); }
public void run() { Display display = Display.getDefault(); Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT); Shell shell = getParentShell(); shell.setCursor(waitCursor); try { ProjectExplorerView explorerView = getProjectExplorerView(); if (explorerView != null) { TreeObject treeObject = explorerView.getFirstSelectedTreeObject(); Object databaseObject = treeObject.getObject(); if ((databaseObject != null) && (databaseObject instanceof TestCase)) { TestCase testCase = (TestCase)databaseObject; testCase.importRequestableVariables((RequestableObject)testCase.getParent()); if (testCase.hasChanged) { explorerView.reloadTreeObject(treeObject); StructuredSelection structuredSelection = new StructuredSelection(treeObject); ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart)explorerView, structuredSelection); } } } } catch (Throwable e) { ConvertigoPlugin.logException(e, "Unable to add requestable variables to test case!"); } finally { shell.setCursor(null); waitCursor.dispose(); } }