List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:com.bdaum.zoom.flickrrest.internal.RestFlickrApi.java
License:LGPL
/** *//from w w w. j a v a2s .c om */ private static boolean showUnfinishedUploadErrorMessage() { StringBuffer errorMessage = new StringBuffer(); errorMessage.append(Messages.getString("juploadr.flickerrest.error.after.upload")); //$NON-NLS-1$ Iterator<Class<? extends PostUploadAction>> failureClasses = unfinishedActions.keySet().iterator(); while (failureClasses.hasNext()) { List<PostUploadAction> actions = getFailedActions(failureClasses.next()); if (actions != null) { Iterator<PostUploadAction> actionIter = actions.iterator(); while (actionIter.hasNext()) { PostUploadAction method = actionIter.next(); errorMessage.append(Messages.getString("juploadr.flickerrest.failed.to")); //$NON-NLS-1$ errorMessage.append(method.getErrorText()); errorMessage.append("\n"); //$NON-NLS-1$ } } } errorMessage.append(Messages.getString("juploadr.flickerrest.option.retry")); //$NON-NLS-1$ return MessageDialog.openQuestion(null, errorMessage.toString(), Messages.getString("RestFlickrApi.actions_failed")); //$NON-NLS-1$ }
From source file:com.bdaum.zoom.ui.internal.preferences.PerspectivesPreferencePage.java
License:Open Source License
/** * Deletes the perspectives selected by the user if there is no opened instance * of that perspective./* w w w. j a v a 2 s . c o m*/ * * @return boolean <code>true</code> if all of the perspectives could be * deleted. */ private boolean findOpenInstance(IPerspectiveDescriptor desc) { IWorkbenchWindow windows[] = workbench.getWorkbenchWindows(); for (int i = 0; i < windows.length; i++) { IWorkbenchPage pages[] = windows[i].getPages(); for (int j = 0; j < pages.length; j++) { IPerspectiveDescriptor perspective = pages[j].getPerspective(); if (desc.equals(perspective)) if (!MessageDialog.openQuestion(getShell(), Messages.getString("PerspectivesPreferencePage.delete_perspective"), //$NON-NLS-1$ NLS.bind(Messages.getString("PerspectivesPreferencePage.are_you_sure"), //$NON-NLS-1$ desc.getLabel()))) { return true; } } } return false; }
From source file:com.bdaum.zoom.ui.internal.widgets.FileEditor.java
License:Open Source License
/** * Constructor//from ww w.j ava 2 s .co m * * @param parent * - parent container * @param style * - style bits, neither SWT.OPEN nor SWT.SAVE set: FolderDialog * @param lab * - label * @param hasLabel * - true if the input field has a label * @param filterExtensions * - filter extensions (not used for folders) * @param filterNames * - filter names (not used for folders) * @param path * - path * @param filenameProposal * - file name (not used for folders) * @param overwrite * - check for overwrite (not used for folders) * @param clear * - has clear button * @param settings * - dialogSettings for storing and retrieving the history */ public FileEditor(Composite parent, final int style, final String lab, boolean hasLabel, final String[] filterExtensions, final String[] filterNames, final String path, final String filenameProposal, final boolean overwrite, final boolean clear, IDialogSettings settings) { super(parent, style); this.path = path; this.fileName = filenameProposal; this.settings = settings; int hashCode = Arrays.hashCode(filterExtensions); historyKey = FILEHISTORY + hashCode; lastfileKey = LASTFILENAME + hashCode; setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); int cols = 2; if (hasLabel) ++cols; if (clear) ++cols; GridLayout layout = new GridLayout(cols, false); layout.marginHeight = 0; layout.marginWidth = 0; setLayout(layout); if (hasLabel) new Label(this, SWT.NONE).setText(lab); fileNameField = new Combo(this, SWT.BORDER | (style & SWT.READ_ONLY)); final GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false); data.widthHint = 200; fileNameField.setLayoutData(data); String[] items = settings == null ? null : settings.getArray(historyKey); if (items == null) items = new String[0]; fileNameField.setVisibleItemCount(8); String lastFile = settings == null ? null : settings.get(lastfileKey); if (lastFile != null) this.path = new File(this.fileName = lastFile).getParent(); if (this.fileName != null) { fileNameField.setItems(UiUtilities.addToHistoryList(items, this.fileName)); fileNameField.setText(this.fileName); } if (overwrite && lastFile != null && !lastFile.isEmpty() && new File(lastFile).exists()) { fileNameField.setItems(UiUtilities.addToHistoryList(fileNameField.getItems(), filenameProposal)); fileNameField.setText(this.fileName = filenameProposal); this.path = path; } fileNameField.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { int selectionIndex = fileNameField.getSelectionIndex(); if (!overwrite || !new File(fileNameField.getItem(selectionIndex)).exists() || MessageDialog .openQuestion(getShell(), Messages.FileEditor_file_exists, Messages.FileEditor_overwrite)) lastSelectionIndex = selectionIndex; else fileNameField.select(lastSelectionIndex); fireEvent(event); } }); if ((style & SWT.READ_ONLY) == 0) fileNameField.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event event) { fireEvent(event); } }); Button button = new Button(this, SWT.PUSH); button.setText(Messages.FileEditor_browse); button.setToolTipText(Messages.FileEditor_browse_tooltip); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { openBrowseDialog(style, lab, filterExtensions, filterNames, FileEditor.this.path, FileEditor.this.fileName, overwrite); } }); if (clear) { clearButton = new Button(this, SWT.PUSH); clearButton.setImage(Icons.delete.getImage()); clearButton.setToolTipText(Messages.FileEditor_clear_tooltip); clearButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { String text = getText(); setText(""); //$NON-NLS-1$ if (!text.isEmpty()) fireEvent(event); } }); addListener(new Listener() { public void handleEvent(Event e) { clearButton.setEnabled(!getText().isEmpty()); } }); } }
From source file:com.bibisco.rcp.ApplicationWorkbenchAdvisor.java
License:GNU General Public License
public boolean preShutdown() { Shell lShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String lStrDialogBoxTitle = ResourceBundleManager.getString("com.bibisco.rcp.preShutdown.confirm.title"); String lStrQuestion = ResourceBundleManager.getString("com.bibisco.rcp.preShutdown.confirm.question"); return MessageDialog.openQuestion(lShell, lStrDialogBoxTitle, lStrQuestion); }
From source file:com.buglabs.dragonfly.ui.wizards.bug.NewBugConnectionWizard.java
License:Open Source License
public boolean performFinish() { try {/*w ww . ja v a2 s. c o m*/ BugConnection bug = new StaticBugConnection(mainpage.getProjectName(), mainpage.getBugURL()); BugConnectionManager.getInstance().addBugConnection(bug); } catch (MalformedURLException e) { e.printStackTrace(); return false; } try { IPerspectiveDescriptor persp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getPerspective(); if (!persp.getId().equals(PerspectiveFactory.PERSPECTIVE_ID)) { boolean canSwitch = MessageDialog.openQuestion( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("NewProjectWizard.3"), Messages.getString("NewProjectWizard.4")); //$NON-NLS-1$ //$NON-NLS-2$ if (canSwitch) { PlatformUI.getWorkbench().showPerspective(PerspectiveFactory.PERSPECTIVE_ID, PlatformUI.getWorkbench().getActiveWorkbenchWindow()); } } } catch (WorkbenchException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; }
From source file:com.byterefinery.rmbench.dialogs.ModelPropertiesDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { Composite mainComposite = (Composite) super.createDialogArea(parent); final Composite localComposite = new Composite(mainComposite, SWT.NONE); localComposite.setLayout(new GridLayout(2, false)); Label label;//from w w w . j a v a 2 s. c o m GridData gd; if (storageKey != null) { Composite storageComposite = new Composite(localComposite, SWT.NONE); gd = new GridData(SWT.FILL, SWT.NONE, true, false); gd.horizontalSpan = 2; storageComposite.setLayoutData(gd); GridLayout layout = new GridLayout(); layout.marginWidth = 0; storageComposite.setLayout(layout); label = new Label(storageComposite, SWT.NONE); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.BOTTOM, false, false)); label.setText(Messages.ModelPropertiesDialog_Location + " " + storageKey); label = new Label(storageComposite, SWT.SEPARATOR | SWT.HORIZONTAL); gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false); gd.horizontalSpan = 2; label.setLayoutData(gd); } label = new Label(localComposite, SWT.NONE); label.setText(Messages.ModelPropertiesDialog_Name); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); final Text nameText = new Text(localComposite, SWT.BORDER | SWT.SINGLE); gd = new GridData(SWT.LEFT, SWT.FILL, false, true); gd.widthHint = convertWidthInCharsToPixels(MODEL_NAME_CHARS); nameText.setLayoutData(gd); nameText.setTextLimit(MODEL_NAME_CHARS); nameText.setText(modelName); nameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validateName(nameText.getText()); updateOKButton(); } }); label = new Label(localComposite, SWT.NONE); label.setText(Messages.ModelPropertiesDialog_Database); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); final ComboViewer dbCombo = new ComboViewer(localComposite, SWT.READ_ONLY | SWT.DROP_DOWN); dbCombo.getCombo().setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); dbCombo.setContentProvider(new ArrayContentProvider()); dbCombo.setLabelProvider(new LabelProvider() { public String getText(Object element) { DatabaseExtension dbExt = (DatabaseExtension) element; return dbExt.getName(); } }); dbCombo.setInput(RMBenchPlugin.getExtensionManager().getDatabaseExtensions()); dbCombo.setSelection(new StructuredSelection(databaseExtension)); dbCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); DatabaseExtension dbext = (DatabaseExtension) selection.getFirstElement(); if (dbext != databaseExtension) { boolean proceed = model.isEmpty() || MessageDialog.openQuestion(getShell(), Messages.ModelPropertiesDialog_ChangeModel_Title, Messages.ModelPropertiesDialog_ChangeModel_Message); if (proceed) { databaseExtension = dbext; updateOKButton(); } else { dbCombo.setSelection(new StructuredSelection(databaseExtension), true); } } } }); label = new Label(localComposite, SWT.NONE); label.setText(Messages.ModelPropertiesDialog_NameGenerator); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); final ComboViewer generatorCombo = new ComboViewer(localComposite, SWT.READ_ONLY | SWT.DROP_DOWN); generatorCombo.getCombo().setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); generatorCombo.setContentProvider(new ArrayContentProvider()); generatorCombo.setLabelProvider(new LabelProvider() { public String getText(Object element) { NameGeneratorExtension genext = (NameGeneratorExtension) element; return genext.getName(); } }); generatorCombo.setInput(RMBenchPlugin.getExtensionManager().getNameGeneratorExtensions()); generatorCombo.setSelection(new StructuredSelection(generatorExtension)); generatorCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); generatorExtension = (NameGeneratorExtension) selection.getFirstElement(); updateOKButton(); } }); return mainComposite; }
From source file:com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler.java
License:Apache License
public void run(Object element) { if (element instanceof WorkflowProcess) { WorkflowProcess processVersion = (WorkflowProcess) element; IEditorPart editorPart = findOpenEditor(processVersion); if (editorPart != null && editorPart.isDirty()) { if (MessageDialog.openQuestion(getShell(), "Process Launch", "Save process '" + processVersion.getLabel() + "' before launching?")) editorPart.doSave(new NullProgressMonitor()); }/*from ww w . j av a 2 s . com*/ if (MdwPlugin.getDefault().getPreferenceStore() .getBoolean(PreferenceConstants.PREFS_WEB_BASED_PROCESS_LAUNCH)) { // web-based process launch try { IViewPart viewPart = getPage().showView("mdw.views.designer.process.launch"); if (viewPart != null) { ProcessLaunchView launchView = (ProcessLaunchView) viewPart; launchView.setProcess(processVersion); } } catch (PartInitException ex) { PluginMessages.log(ex); } } else { if (editorPart == null) { // process must be open open((WorkflowElement) element); } ProcessLaunchShortcut launchShortcut = new ProcessLaunchShortcut(); launchShortcut.launch(new StructuredSelection(processVersion), ILaunchManager.RUN_MODE); } } else if (element instanceof Activity) { Activity activity = (Activity) element; WorkflowProcess processVersion = activity.getProcess(); IEditorPart editorPart = findOpenEditor(processVersion); if (editorPart != null && editorPart.isDirty()) { if (MessageDialog.openQuestion(getShell(), "Activity Launch", "Save process '" + processVersion.getLabel() + "' before launching?")) editorPart.doSave(new NullProgressMonitor()); } ActivityLaunchShortcut launchShortcut = new ActivityLaunchShortcut(); launchShortcut.launch(new StructuredSelection(activity), ILaunchManager.RUN_MODE); } else if (element instanceof ExternalEvent) { ExternalEvent externalEvent = (ExternalEvent) element; ExternalEventLaunchShortcut launchShortcut = new ExternalEventLaunchShortcut(); launchShortcut.launch(new StructuredSelection(externalEvent), ILaunchManager.RUN_MODE); } else if (element instanceof Template) { Template template = (Template) element; IEditorPart editorPart = template.getFileEditor(); if (editorPart != null && editorPart.isDirty()) { if (MessageDialog.openQuestion(getShell(), "Run Template", "Save template '" + template.getName() + "' before running?")) editorPart.doSave(new NullProgressMonitor()); } template.openFile(new NullProgressMonitor()); new TemplateRunDialog(getShell(), template).open(); } else if (element instanceof Page) { Page page = (Page) element; IEditorPart editorPart = page.getFileEditor(); if (editorPart != null) { if (editorPart.isDirty()) { if (MessageDialog.openQuestion(getShell(), "Run Page", "Save page '" + page.getName() + "' before running?")) editorPart.doSave(new NullProgressMonitor()); } } page.run(); } else if (element instanceof WorkflowProject || element instanceof ServerSettings) { ServerSettings serverSettings; if (element instanceof WorkflowProject) { WorkflowProject workflowProject = (WorkflowProject) element; if (workflowProject.isRemote()) throw new IllegalArgumentException("Cannot run server for remote projects."); serverSettings = workflowProject.getServerSettings(); } else { serverSettings = (ServerSettings) element; } if (ServerRunner.isServerRunning()) { String question = "A server may be running already. Shut down the currently-running server?"; MessageDialog dlg = new MessageDialog(getShell(), "Server Running", null, question, MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Shutdown", "Ignore", "Cancel" }, 0); int res = dlg.open(); if (res == 0) new ServerRunner(serverSettings, getShell().getDisplay()).stop(); else if (res == 2) return; } if (serverSettings.getHome() == null && element instanceof WorkflowProject) { final IProject project = serverSettings.getProject().isCloudProject() ? serverSettings.getProject().getSourceProject() : serverSettings.getProject().getEarProject(); @SuppressWarnings("restriction") org.eclipse.ui.internal.dialogs.PropertyDialog dialog = org.eclipse.ui.internal.dialogs.PropertyDialog .createDialogOn(getShell(), "mdw.workflow.mdwServerConnectionsPropertyPage", project); if (dialog != null) dialog.open(); } else { IPreferenceStore prefStore = MdwPlugin.getDefault().getPreferenceStore(); if (element instanceof WorkflowProject) prefStore.setValue(PreferenceConstants.PREFS_SERVER_WF_PROJECT, ((WorkflowProject) element).getName()); else prefStore.setValue(PreferenceConstants.PREFS_RUNNING_SERVER, serverSettings.getServerName()); ServerRunner runner = new ServerRunner(serverSettings, getShell().getDisplay()); if (serverSettings.getProject() != null) runner.setJavaProject(serverSettings.getProject().getJavaProject()); runner.start(); } } }
From source file:com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler.java
License:Apache License
public void runFromPage(WorkflowElement element) { if (element instanceof WorkflowProcess) { WorkflowProcess processVersion = (WorkflowProcess) element; IEditorPart editorPart = findOpenEditor(processVersion); if (editorPart != null && editorPart.isDirty()) { if (MessageDialog.openQuestion(getShell(), "Process Launch", "Save process '" + processVersion.getLabel() + "' before launching?")) editorPart.doSave(new NullProgressMonitor()); }// w w w . j av a 2 s . co m WebApp webapp = WebApp.TaskManager; if (element.getProject().checkRequiredVersion(5, 5) && !processVersion.isCompatibilityRendering()) webapp = WebApp.MdwHub; WebLaunchAction launchAction = WebLaunchActions.getLaunchAction(element.getProject(), webapp); String urlPath = "/start.jsf?process=" + processVersion.getName(); if (webapp.equals(WebApp.MdwHub)) { urlPath = urlPath + "&processVersion=" + processVersion.getVersion(); } launchAction.launch(element.getProject(), urlPath); } }
From source file:com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler.java
License:Apache License
public void debug(Object element) { if (element instanceof WorkflowProcess) { WorkflowProcess processVersion = (WorkflowProcess) element; IEditorPart editorPart = findOpenEditor(processVersion); if (editorPart != null && editorPart.isDirty()) { if (MessageDialog.openQuestion(getShell(), "Process Launch", "Save process '" + processVersion.getLabel() + "' before launching?")) editorPart.doSave(new NullProgressMonitor()); }/*w w w . ja v a 2 s .c o m*/ if (editorPart == null) { // process must be open open(processVersion); } ProcessLaunchShortcut launchShortcut = new ProcessLaunchShortcut(); launchShortcut.launch(new StructuredSelection(processVersion), ILaunchManager.DEBUG_MODE); } else if (element instanceof Activity) { Activity activity = (Activity) element; WorkflowProcess processVersion = activity.getProcess(); IEditorPart editorPart = findOpenEditor(processVersion); if (editorPart != null && editorPart.isDirty()) { if (MessageDialog.openQuestion(getShell(), "Activity Launch", "Save process '" + processVersion.getLabel() + "' before launching?")) editorPart.doSave(new NullProgressMonitor()); } ActivityLaunchShortcut launchShortcut = new ActivityLaunchShortcut(); launchShortcut.launch(new StructuredSelection(activity), ILaunchManager.DEBUG_MODE); } else if (element instanceof ExternalEvent) { ExternalEvent externalEvent = (ExternalEvent) element; ExternalEventLaunchShortcut launchShortcut = new ExternalEventLaunchShortcut(); launchShortcut.launch(new StructuredSelection(externalEvent), ILaunchManager.DEBUG_MODE); } else if (element instanceof WorkflowProject || element instanceof ServerSettings) { ServerSettings serverSettings; if (element instanceof WorkflowProject) { WorkflowProject workflowProject = (WorkflowProject) element; serverSettings = workflowProject.getServerSettings(); } else { serverSettings = (ServerSettings) element; } serverSettings.setDebug(true); if (serverSettings.getDebugPort() == 0) serverSettings.setDebugPort(8500); run(serverSettings); } }
From source file:com.centurylink.mdw.plugin.codegen.Generator.java
License:Apache License
/** * creates a file in the eclipse project and opens it in the editor window * /*from w w w.j a v a2 s . c om*/ * @param jet * @param monitor * @throws CoreException */ public void createFileAndOpen(Shell shell, JetAccess jet, IProgressMonitor monitor) throws CoreException { IContainer container = jet.findOrCreateContainer(monitor, jet.getConfig().getTargetFolder(), jet.getConfig().getPackageName()); IFile targetFile = container.getFile(new Path(jet.getConfig().getTargetFile())); targetFile.refreshLocal(IResource.DEPTH_ZERO, monitor); if (targetFile.exists()) { if (!(MessageDialog.openQuestion(shell, "Confirm Overwrite", "Target file :'" + targetFile.getLocation() + "' exists. Overwrite?"))) return; } IFile file = createFile(jet, monitor); openFile(file); }