List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public int open()
From source file:carisma.ui.eclipse.dialogs.parameters.ParameterDialogUtil.java
License:Open Source License
/** * Getter for a Boolean Parameter.//from www.jav a 2s . co m * @param parameter Boolean Parameter * @return the new value of the Boolean Parameter */ public final boolean queryBooleanParameter(final BooleanParameter parameter) { int result = 0; if (!parameter.getValue()) { // defaultValue used for MessageDialog's result = 1; } MessageDialog md = new MessageDialog(super.getShell(), this.checkDescriptor.getName(), null, DIALOG_TEXT + "\"" + parameter.getDescriptor().getName() + "\" (BOOLEAN)", 0, new String[] { "True", "False" }, result); result = md.open(); return result == 0; }
From source file:carisma.ui.eclipse.editors.AdfEditorMasterDetailsBlock.java
License:Open Source License
/** * Creates the run-button and the corresponding listener. * /* w w w .j ava2 s . co m*/ * @param toolkit * The FormToolKit where the button is created * @param composite * The corresponding composite */ private void createRunButton(final FormToolkit toolkit, final Composite composite) { this.run = toolkit.createButton(composite, "RUN", SWT.PUSH); this.run.setEnabled(this.controller.isModelFileValid()); //Bug #1518: Wie kann man die Position des Tooltips verndern? //http://stackoverflow.com/questions/11375250/set-tooltip-text-at-a-particular-location this.run.setToolTipText("Runs the analysis"); this.run.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { listSelectionChanged(); if (AdfEditorMasterDetailsBlock.this.controller.isEditorDirty()) { MessageDialog messageDialog = new MessageDialog(composite.getShell(), "Save and Launch", null, "Do you want to save the changes?", 0, new String[] { "OK", "Cancel" }, 0); messageDialog.open(); if (messageDialog.getReturnCode() == 0) { AdfEditorMasterDetailsBlock.this.controller.saveAnalysis(); } } if (AdfEditorMasterDetailsBlock.this.controller.hasAnalysisInvalidParameters() || !AdfEditorMasterDetailsBlock.this.controller.isModelFileValid() || !isOneCheckEnabled()) { updateRunButtonEnable(); showProblems(); } else { AdfEditorMasterDetailsBlock.this.controller.runAnalysis(); } } }); this.problemLink = new Link(composite, SWT.NONE); this.problemLink.setText("<a>Show problems</a>"); this.problemLink.setBackground(new Color(null, 255, 255, 255)); this.problemLink.setVisible(false); this.problemLink.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { showProblems(); } }); }
From source file:carisma.ui.eclipse.editors.AdfEditorMasterDetailsBlock.java
License:Open Source License
/** * Displays a message box which contains a list of problems. *///from ww w.j a va 2 s.c om void showProblems() { StringBuffer message = new StringBuffer(""); for (String line : this.controller.getProblems()) { message.append(line + System.getProperty("line.separator")); } MessageDialog messageDialog = new MessageDialog(this.sashForm.getShell(), "Analysis problems", null, message.toString(), MessageDialog.ERROR, new String[] { "OK" }, 0); messageDialog.open(); }
From source file:carisma.ui.eclipse.editors.AdfEditorMasterDetailsBlock.java
License:Open Source License
/** * This method activates or deactivates the editors combo box. * //from ww w . j av a 2 s. co m * @param active * True, if the combo box should be activated, false otherwise * @param message * the message, which will be shown */ private void updateSelectedEditorEnableState(final boolean active, final String message) { boolean validEditor = false; if (this.selectedEditorCombo.getEnabled() != active) { this.selectedEditorCombo.removeAll(); if (active) { this.selectedEditorCombo.setEnabled(true); // Get the editors final EditorRegistry editorRegistry = CarismaGUI.INSTANCE.getEditorRegistry(); List<EditorDescriptor> editorDescriptorList = editorRegistry.getRegisteredEditors(); this.selectedEditorCombo.add(DEFAULT_EDITOR); // Add all applicable editors to the combo box for (EditorDescriptor editorDesc : editorDescriptorList) { if (editorDesc.isAvailable() && editorDesc.isApplicable(this.controller.getModelIFile())) { this.selectedEditorCombo.add(editorDesc.getName()); } } // Select 'Default Eclipse Editor' by default or the editor, // which is saved in the adf file this.selectedEditorCombo.select(0); EditorDescriptor savedEditorDescriptor = editorRegistry .getEditorDescriptorById(this.controller.getSelectedEditorId()); if (savedEditorDescriptor != null) { int index = 0; for (String item : this.selectedEditorCombo.getItems()) { if (item.equals(savedEditorDescriptor.getName())) { this.selectedEditorCombo.select(index); validEditor = true; break; } index++; } } else { if ((this.controller.getSelectedEditorId().equals("")) || (this.controller.getSelectedEditorId().equals("Default Eclipse Editor"))) { validEditor = true; } } this.selectedEditorCombo.setToolTipText("Choose an editor to open the model."); this.selectedEditorDecoration.hide(); } else { if (EditorPriorityList.getPriorityList(this.controller.getModelType()) != null && EditorPriorityList.getPriorityList(this.controller.getModelType()).size() >= 1) { this.selectedEditorCombo .add(EditorPriorityList.getPriorityList(this.controller.getModelType()).get(0)); } else { this.selectedEditorCombo.add("Priority list is empty!"); } this.selectedEditorCombo.select(0); this.selectedEditorCombo.setEnabled(false); this.selectedEditorDecoration.setDescriptionText(message); this.selectedEditorCombo.setToolTipText(""); this.selectedEditorDecoration.show(); } if (!validEditor) { //MessageBox if the stored editor is invalid MessageDialog messageDialog = new MessageDialog(this.selectedEditorCombo.getShell(), "Invalid Model-Editor", null, "The chosen editor for the modeltype of the CARiSMA analysis is invalid." + "\nThe ID is \"" + this.controller.getSelectedEditorId() + "\"." + "\nThe default editor will be chosen." + "\nClick \"OK && remove ID\" to change the editor to the default editor in the analysis file.", MessageDialog.INFORMATION, new String[] { "OK", "OK && remove ID" }, 0); // && in strings results in & messageDialog.open(); if (messageDialog.getReturnCode() == 1) { //set the stored Editor to the default Editor and saves the analysis file setEditorToDefault(); } } } }
From source file:carisma.ui.eclipse.editors.EditorTranslator.java
License:Open Source License
/** * Opens the editor, which is selected in the adf editor dropdown menu, or the * editors from the editor priority list. * @param defaultEditor Is true, when the Eclipse default editor for this file should be opened * @return An indicator for the success of the method *///w w w.j av a 2 s . co m public final boolean openEditor(final boolean defaultEditor) { EditorRegistry editorRegistry = CarismaGUI.INSTANCE.getEditorRegistry(); String editorSelectionArt = CarismaGUI.INSTANCE.getPreferenceStore() .getString(Constants.EDITOR_SELECTION_ART); // Priority list if (editorSelectionArt.equals(Constants.AUTO)) { List<String> editorPriorityList = EditorPriorityList.getPriorityList(this.analysis.getModelType()); if (editorPriorityList == null || editorPriorityList.size() < 1) { MessageDialog mDialog = new MessageDialog(Display.getDefault().getActiveShell(), "Error", null, "The editor priority list is empty\n" + "Add editors to the list in the CARiSMA Preferences", MessageDialog.ERROR, new String[] { "OK" }, 0); mDialog.open(); return false; } for (String editorName : editorPriorityList) { EditorDescriptor editorDesc = editorRegistry.getEditorDescriptorByName(editorName); if (editorDesc.forceOpen(this.analysis.getIFile())) { return true; } } // Dropdown menu selection } else { EditorDescriptor editorDesc = null; if (defaultEditor) { // Find Eclipse default editor for this model type editorDesc = getDefaultEditor(); } else { // Find selected editor in the editor registry String selectedEditorId = this.analysis.getSelectedEditorId(); editorDesc = editorRegistry.getEditorDescriptorById(selectedEditorId); } if (editorDesc != null) { if (editorDesc.forceOpen(this.analysis.getIFile())) { return true; } MessageDialog mDialog = new MessageDialog(Display.getDefault().getActiveShell(), "Error", null, "The selected editor cannot be opened", MessageDialog.ERROR, new String[] { "OK" }, 0); mDialog.open(); return false; } MessageDialog mDialog = new MessageDialog(Display.getDefault().getActiveShell(), "Error", null, "The selected editor was not found", MessageDialog.ERROR, new String[] { "OK" }, 0); mDialog.open(); return false; } return false; }
From source file:carisma.ui.eclipse.popup.actions.RunAnalysisAction.java
License:Open Source License
/** * Show a message with name of checks, where the required parameters are not * filled, used to stop Run process if necessary. * @param checksWithUnsetRequiredParameters A list of checks, for those required parameter are not filled *//*from w w w. j a v a 2 s . c om*/ private static void showUnsetRequiredParameters(final List<CheckReference> checksWithUnsetRequiredParameters) { StringBuffer message = new StringBuffer("Required parameters not set in: \n"); if (checksWithUnsetRequiredParameters.size() > 0) { for (CheckReference check : checksWithUnsetRequiredParameters) { message.append("\""); message.append(check.getCheckID()); message.append("\"\n"); } Display display = Display.getDefault(); Shell shell = new Shell(display); MessageDialog mDialog = new MessageDialog(shell, "Unset required parameter error", null, message.toString(), MessageDialog.ERROR, new String[] { "OK" }, 0); mDialog.open(); } }
From source file:carisma.ui.eclipse.rcp.ForgetEditorHandler.java
License:Open Source License
@Override public final Object execute(final ExecutionEvent event) throws ExecutionException { this.analysis = AnalysisUtil.readAnalysis(this.selectedFile.getLocation().toOSString()); if (this.analysis == null) { return null; } else if (this.analysis.getSelectedEditorId() == null || this.analysis.getSelectedEditorId().equals("")) { Display display = Display.getDefault(); Shell shell = new Shell(display); MessageDialog mDialog = new MessageDialog(shell, "Editor not set", null, "No editor set for this analysis", MessageDialog.ERROR, new String[] { "OK" }, 0); mDialog.open(); return null; }//from www. ja v a 2s . c o m this.analysis.setSelectedEditorId(null); fireHandlerChanged(new HandlerEvent(getHandler(), true, false)); saveChanges(); IWorkbenchPage[] pages = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPages(); for (IWorkbenchPage page : pages) { for (IEditorReference editorRef : page.getEditorReferences()) { if (editorRef != null && this.selectedFile.getName().equals(editorRef.getName()) && editorRef.getEditor(false) instanceof AdfEditor) { IEditorInput editInput = ((AdfEditor) editorRef.getEditor(false)).getEditorInput(); if (editInput.getAdapter(IFile.class) != null) { IFile file = editInput.getAdapter(IFile.class); this.analysis = AnalysisUtil.readAnalysis(file.getLocation().toOSString()); } } } } return null; }
From source file:carisma.ui.eclipse.rcp.ForgetEditorHandler.java
License:Open Source License
/** * save changes to resource.//from ww w . j a va2 s. com */ private void saveChanges() { if (this.selectedFile == null) { // TODO return; } Display display = Display.getDefault(); Shell shell = new Shell(display); MessageDialog mDialog = new MessageDialog(shell, "Save and Launch", null, "Do you want to save the changes in" + this.selectedFile.getLocation().toOSString() + "?", 0, new String[] { "OK", "Cancel" }, 0); mDialog.open(); if (mDialog.getReturnCode() == 0) { // save analysis AnalysisUtil.storeAnalysis(this.analysis, this.selectedFile.getLocation().toOSString()); // refresh resource try { this.selectedFile.refreshLocal(IResource.DEPTH_ZERO, null); } catch (CoreException e) { Logger.log(LogLevel.INFO, "Could not refresh resource"); } } }
From source file:ch.elexis.agenda.data.Termin.java
License:Open Source License
public boolean delete(boolean askForConfirmation) { boolean confirmed = !askForConfirmation; if (checkLock()) { return false; }//from w ww .ja v a 2 s .c om String linkgroup = get(FLD_LINKGROUP); //$NON-NLS-1$ boolean isLinked = linkgroup != null && !linkgroup.isEmpty(); if (isLinked && askForConfirmation) { MessageDialog msd = new MessageDialog(UiDesk.getTopShell(), Messages.Termin_deleteSeries, null, Messages.Termin_thisAppIsPartOfSerie, MessageDialog.QUESTION, new String[] { Messages.Termin_yes, Messages.Termin_no }, 1); int retval = msd.open(); if (retval == SWT.DEFAULT) { return false; } confirmed = (retval == Dialog.OK); } if (isLinked) { List<Termin> linked = getLinked(this); if (confirmed) { // delete whole series for (Termin ae : (List<Termin>) linked) { ae.set(new String[] { FLD_LASTEDIT, FLD_DELETED }, new String[] { createTimeStamp(), StringConstants.ONE }); } } else { if (getId().equals(linkgroup)) { // move root information if (linked.size() > 1) { int index = 0; Termin moveto = linked.get(index); while (moveto.getId().equals(linkgroup)) { moveto = linked.get(++index); } moveto.set(Termin.FLD_PATIENT, get(Termin.FLD_PATIENT)); moveto.set(Termin.FLD_GRUND, get(Termin.FLD_GRUND)); moveto.set(Termin.FLD_CREATOR, get(Termin.FLD_CREATOR)); moveto.set(Termin.FLD_EXTENSION, get(Termin.FLD_EXTENSION)); for (Termin termin : linked) { termin.set(Termin.FLD_LINKGROUP, moveto.getId()); } } } // delete this set(new String[] { FLD_DELETED, FLD_LASTEDIT }, StringConstants.ONE, createTimeStamp()); } } else { // delete this set(new String[] { FLD_DELETED, FLD_LASTEDIT }, StringConstants.ONE, createTimeStamp()); } return true; }
From source file:ch.elexis.core.ui.Hub.java
License:Open Source License
/** * Programmende/*from w w w. java 2 s.co m*/ */ public static void postShutdown() { // shutdownjobs are executed after the workbench has been shut down. // So those jobs must not use any of the workbench's resources. if ((shutdownJobs != null) && (shutdownJobs.size() > 0)) { Shell shell = new Shell(Display.getDefault()); MessageDialog dlg = new MessageDialog(shell, Messages.Hub_title_configuration, Dialog.getDefaultImage(), Messages.Hub_message_configuration, SWT.ICON_INFORMATION, new String[] {}, 0); dlg.setBlockOnOpen(false); dlg.open(); for (ShutdownJob job : shutdownJobs) { try { job.doit(); } catch (Exception e) { log.error("Error starting job: " + e.getMessage()); } } dlg.close(); } }