List of usage examples for org.eclipse.jface.dialogs MessageDialog MessageDialog
public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, int defaultIndex, String... dialogButtonLabels)
From source file:eu.geclipse.ui.internal.transfer.GridElementTransferOperation.java
License:Open Source License
private void askOverwrite(final TransferParams data, final IFileInfo targetInfo) { class Runner implements Runnable { int exitCode; private final Display display; Runner(final Display display) { this.display = display; }// ww w.jav a 2 s .c o m public void run() { Shell shell = null; String[] labels = { Messages.getString("GridElementTransferOperation.buttonYes"), //$NON-NLS-1$ Messages.getString("GridElementTransferOperation.buttonYesAll"), //$NON-NLS-1$ Messages.getString("GridElementTransferOperation.buttonNo"), //$NON-NLS-1$ Messages.getString("GridElementTransferOperation.buttonNoAll"), //$NON-NLS-1$ Messages.getString("GridElementTransferOperation.buttonCancel") }; //$NON-NLS-1$ if (this.display != null) { shell = this.display.getActiveShell(); } String message = String.format(Messages.getString("GridElementTransferOperation.overwriteMsg"), //$NON-NLS-1$ data.targetFile.getName(), formatURI(data.targetFile.toURI()), formatDate(targetInfo.getLastModified()), formatURI(data.sourceFile.toURI()), "" //$NON-NLS-1$ ); MessageDialog dialog = new MessageDialog(shell, Messages.getString("GridElementTransferOperation.overwriteTitle"), //$NON-NLS-1$ null, message, MessageDialog.QUESTION, labels, 0); this.exitCode = dialog.open(); } } Display display = PlatformUI.getWorkbench().getDisplay(); Runner runner = new Runner(display); display.syncExec(runner); switch (runner.exitCode) { case 0: deleteTarget(data); break; case 1: this.overwriteMode = OverwriteMode.OVERWRITE_ALL; deleteTarget(data); break; case 2: ignoreTransfer(data); break; case 3: this.overwriteMode = OverwriteMode.IGNORE_ALL; ignoreTransfer(data); break; case 4: data.status = Status.CANCEL_STATUS; data.monitor.setCanceled(true); break; } }
From source file:eu.geclipse.workflow.ui.edit.policies.WorkflowJobDragDropEditPolicy.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from ww w. jav a 2s . c o m*/ public Command getDropObjectsCommand(DropObjectsRequest dropRequest) { List objects = dropRequest.getObjects(); CompoundCommand cmd = new CompoundCommand(); JSDLJobDescription jsdl = null; for (Object o : objects) { if (o instanceof JSDLJobDescription) { jsdl = (JSDLJobDescription) o; this.selectedElement = (WorkflowJobEditPart) getHost(); IWorkflowJob selectedJob = (IWorkflowJob) this.selectedElement.resolveSemanticElement(); CopyJobDescToWorkflowCommand copyCmd = new CopyJobDescToWorkflowCommand( this.selectedElement.resolveSemanticElement(), jsdl); UpdateJobPortsCommand updatePortsCmd = new UpdateJobPortsCommand(this.selectedElement, jsdl); if (!(selectedJob.getName() == null && selectedJob.getJobDescription() == null)) { MessageDialog confirmDialog = new MessageDialog(null, Messages.getString("WorkflowJobDragDropEditPolicy_confirmationTitle"), //$NON-NLS-1$ null, Messages.getString("WorkflowJobDragDropEditPolicy_userPrompt"), //$NON-NLS-1$ true ? MessageDialog.QUESTION : MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); int result = confirmDialog.open(); if (result == 0) { cmd.add(new ICommandProxy(copyCmd)); cmd.add(new ICommandProxy(updatePortsCmd)); } } else { cmd.add(new ICommandProxy(copyCmd)); cmd.add(new ICommandProxy(updatePortsCmd)); } } return cmd; } return super.getDropObjectsCommand(dropRequest); }
From source file:eu.geclipse.workflow.ui.internal.actions.GetJobDescriptionFromFileAction.java
License:Open Source License
/** * Fires up a GridFileDialog and fetches the contents of a user-chosen JSDL * file./*w w w . j a v a2 s . c om*/ */ public void run(final IAction action) { FileDialog dialog = new FileDialog(this.myShell, SWT.OPEN); String[] exts = { "*.jsdl" }; //$NON-NLS-1$ dialog.setFilterExtensions(exts); // this bit find the root directory of the workflow TransactionalEditingDomain domain = this.mySelectedElement.getEditingDomain(); ResourceSet resourceSet = domain.getResourceSet(); Resource res = resourceSet.getResources().get(0); URI wfRootUri = res.getURI(); String wfRootPath = wfRootUri.path(); this.dirs = wfRootPath.split("/"); //$NON-NLS-1$ String projectName = this.dirs[2]; this.wfRootFileStore = GridModel.getRoot().getFileStore().getChild(projectName); dialog.setFilterPath(this.wfRootFileStore.toString()); if (dialog.open() != null) { String result = dialog.getFileName(); if ((result != null) && (result.length() > 0)) { String filePath = dialog.getFilterPath() + "/" + result; //$NON-NLS-1$ // filePath = filePath.replace(' ', '+'); java.net.URI filePathUri = null; filePathUri = URIUtil.toURI(filePath); IFile jsdlFile = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePathUri)[0]; IWorkflowJob selectedJob = (IWorkflowJob) this.mySelectedElement.resolveSemanticElement(); if (!(selectedJob.getName() == null && selectedJob.getJobDescription() == null)) { MessageDialog confirmDialog = new MessageDialog(null, Messages.getString("WorkflowJobDragDropEditPolicy_confirmationTitle"), //$NON-NLS-1$ null, Messages.getString("WorkflowJobDragDropEditPolicy_userPrompt"), //$NON-NLS-1$ true ? MessageDialog.QUESTION : MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); int confirmResult = confirmDialog.open(); if (confirmResult == 0) { JSDLJobDescription jsdl = new JSDLJobDescription(jsdlFile); AbstractTransactionalCommand copyCommand = new CopyJobDescToWorkflowCommand( this.mySelectedElement.resolveSemanticElement(), jsdl); AbstractTransactionalCommand updatePortsCommand = new UpdateJobPortsCommand( GetJobDescriptionFromFileAction.this.mySelectedElement, jsdl); try { OperationHistoryFactory.getOperationHistory().execute(copyCommand, new NullProgressMonitor(), null); OperationHistoryFactory.getOperationHistory().execute(updatePortsCommand, new NullProgressMonitor(), null); } catch (ExecutionException eE) { eE.printStackTrace(); } } } } } }
From source file:eu.hydrologis.jgrass.console.editor.actions.ConsoleEditorActionCompile.java
License:Open Source License
public void run() { Display.getDefault().asyncExec(new Runnable() { public void run() { JGrass console = ConsolePlugin.console(); if (null == console) { MessageDialog dialog = new MessageDialog(null, "Info", null, "Missing JGrass ConsoleEngine.", MessageDialog.INFORMATION, new String[] { "Ok" }, 0); dialog.setBlockOnOpen(true); dialog.open();/*from w w w. j a va 2 s. co m*/ } else { // JavaEditor editor = (JavaEditor) getTextEditor(); // ProjectOptions projectOptions = editor.projectOptions(); // PreferencesInitializer.initialize(projectOptions); // projectOptions // .setOption(ProjectOptions.CONSOLE_COMPILE_ONLY, new Boolean(true)); // IDocument doc = editor.getDocumentProvider().getDocument( // editor.getEditorInput()); // editor.getTextConsole().clearConsole(); // console.dispatch(projectOptions, doc.get()); // String text = null; JavaEditor editor = (JavaEditor) getTextEditor(); ISelection selection = editor.getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection = (ITextSelection) selection; if (!textSelection.isEmpty()) { text = textSelection.getText(); } } ProjectOptions projectOptions = editor.projectOptions(); PreferencesInitializer.initialize(projectOptions); // FIXME check how GRASS preferences are saved in the preferencespage // Object option = projectOptions.getOption(ProjectOptions.COMMON_GRASS_MAPSET); projectOptions.setOption(ProjectOptions.CONSOLE_COMPILE_ONLY, new Boolean(true)); IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput()); editor.getTextConsole().clearConsole(); if (text == null || 0 >= text.length()) { text = doc.get(); } console.dispatch(projectOptions, text); } } }); }
From source file:eu.hydrologis.jgrass.console.editor.actions.ConsoleEditorActionRun.java
License:Open Source License
public void run() { Display.getDefault().asyncExec(new Runnable() { public void run() { JGrass console = ConsolePlugin.console(); if (null == console) { MessageDialog dialog = new MessageDialog(null, "Info", null, "Missing JGrass ConsoleEngine.", MessageDialog.INFORMATION, new String[] { "Ok" }, 0); dialog.setBlockOnOpen(true); dialog.open();/*from w w w.java 2 s . c o m*/ } else { JavaEditor editor = (JavaEditor) getTextEditor(); IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput()); editor.getTextConsole().clearConsole(); ProjectOptions projectOptions = editor.projectOptions(); PreferencesInitializer.initialize(projectOptions); projectOptions.setOption(ProjectOptions.CONSOLE_COMPILE_ONLY, new Boolean(false)); String text = null; ISelection selection = editor.getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection = (ITextSelection) selection; if (!textSelection.isEmpty()) { text = textSelection.getText(); } } if (text == null || 0 >= text.length()) { text = doc.get(); } if (text != null) { List<String> commandsOnly = new ArrayList<String>(); List<String> settingsOnly = new ArrayList<String>(); // extract only the commands String[] scriptSplit = text.split("\n"); //$NON-NLS-1$ for (String string : scriptSplit) { if (string.trim().startsWith("#")) { continue; } commandsOnly.add(string); } // from the whole document extract the settings, even id not selected String allText = doc.get(); String[] allSplit = allText.split("\n"); //$NON-NLS-1$ for (String string : allSplit) { if (string.trim().startsWith("#")) { settingsOnly.add(string); } } StringBuffer sB = new StringBuffer(); for (String string : settingsOnly) { sB.append(string).append("\n"); } sB.append("\n\n"); for (String string : commandsOnly) { sB.append(string).append("\n"); } text = sB.toString(); } console.dispatch(projectOptions, text); } } }); }
From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java
License:Open Source License
/** * @param errorMessage/* ww w .j av a2 s.co m*/ * @param shell */ private static void error(final String errorMessage, Shell shell) { Shell sh = shell != null ? shell : PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog dialog = new MessageDialog(sh, Messages.getString("ProblemDialogs.error"), null, errorMessage, //$NON-NLS-1$ MessageDialog.ERROR, new String[] { Messages.getString("ProblemDialogs.ok") }, 0); //$NON-NLS-1$ dialog.setBlockOnOpen(true); dialog.open(); }
From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java
License:Open Source License
/** * @param warningMessage//from ww w . ja v a 2 s . c om * @param shell */ private static void warning(final String warningMessage, Shell shell) { Shell sh = shell != null ? shell : PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog dialog = new MessageDialog(sh, Messages.getString("ProblemDialogs.warning"), null, //$NON-NLS-1$ warningMessage, MessageDialog.WARNING, new String[] { Messages.getString("ProblemDialogs.ok") }, 0); //$NON-NLS-1$ dialog.setBlockOnOpen(true); dialog.open(); }
From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java
License:Open Source License
/** * @param infoMessage/* w w w .j a va2 s.c o m*/ * @param shell */ private static void info(final String infoMessage, final Shell shell) { Shell sh = shell != null ? shell : PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog dialog = new MessageDialog(sh, Messages.getString("ProblemDialogs.Info"), null, infoMessage, //$NON-NLS-1$ MessageDialog.INFORMATION, new String[] { Messages.getString("ProblemDialogs.ok") }, 0); //$NON-NLS-1$ dialog.setBlockOnOpen(true); dialog.open(); }
From source file:eu.modelwriter.configuration.alloy.AlloyParser.java
License:Open Source License
private MarkerTypeElement convertToMarkerType(final Sig rootSig) { if (rootSig instanceof PrimSig) { final PrimSig primSig = (PrimSig) rootSig; MarkerTypeElement rootType;/*from www.j a va2 s . c o m*/ if (primSig.isAbstract != null) { rootType = new MarkerTypeElement( primSig.toString().substring(primSig.toString().indexOf("/") + 1) + " {abs}"); } else { rootType = new MarkerTypeElement(primSig.toString().substring(primSig.toString().indexOf("/") + 1)); } try { if (primSig.children().isEmpty()) { return rootType; } else { for (int i = 0; i < primSig.children().size(); i++) { rootType.getChildren().add(this.convertToMarkerType(primSig.children().get(i))); } return rootType; } } catch (final Err e) { final MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Alloy Error Information", null, e.getMessage(), MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); } } else if (rootSig instanceof SubsetSig) { final SubsetSig subsetSig = (SubsetSig) rootSig; String parentName = subsetSig.type().toString(); parentName = parentName.substring(parentName.indexOf("/") + 1, parentName.length() - 1); final MarkerTypeElement parentMarkerType = this.getMarkTypeElementByName(parentName, this.types); parentMarkerType.getChildren().add( new MarkerTypeElement(subsetSig.toString().substring(subsetSig.toString().indexOf("/") + 1))); } return null; }
From source file:eu.modelwriter.configuration.alloy.AlloyParser.java
License:Open Source License
private void parse(final String filename) { // AlloyUtilities.createXMLFromAlloy(filename); try {/*from ww w.ja va 2 s . c o m*/ // Parse+typecheck the model // System.out.println("=========== Parsing+Typechecking " + filename + " ============="); Module world; final DocumentRoot documentRoot = this.createBaseXmlFile(); final EList<SigType> xmlSigList = documentRoot.getAlloy().getInstance().getSig(); final EList<FieldType> xmlFieldList = documentRoot.getAlloy().getInstance().getField(); int idIndex = 4; final Map<String, String> map = new LinkedHashMap<String, String>(); world = CompUtil.parseEverything_fromFile(new A4Reporter(), map, filename); for (final Module modules : world.getAllReachableModules()) { final SafeList<Sig> list = modules.getAllSigs(); for (final Sig sig : list) { if (sig instanceof PrimSig) { final PrimSig primSig = (PrimSig) sig; xmlSigList.add(this.getSigType(primSig, idIndex, xmlSigList)); idIndex++; if (primSig.children().size() == 0 && primSig.toString() .substring(primSig.toString().indexOf("/") + 1).equals("Univ")) { break; } if (primSig.isTopLevel()) { this.types.add(this.convertToMarkerType(primSig)); } } else if (sig instanceof SubsetSig) { final SubsetSig subsetSig = (SubsetSig) sig; this.convertToMarkerType(subsetSig); xmlSigList.add(this.getSigType(subsetSig, idIndex, xmlSigList)); idIndex++; // this.types.add(this.convertToMarkerType(subsetSig)); } } } this.setParentIdForSigTypes(xmlSigList); for (final Module modules : world.getAllReachableModules()) { final SafeList<Sig> list = modules.getAllSigs(); for (final Sig sig : list) { final SafeList<Field> fields = sig.getFields(); for (final Field field : fields) { xmlFieldList.add(this.getFieldType(field, idIndex, xmlFieldList, xmlSigList)); idIndex++; String product = ""; if (field.decl().expr.type().size() > 1) { final Iterator<ProductType> iter = field.decl().expr.type().iterator(); while (iter.hasNext()) { final Type.ProductType productType = iter.next(); if (iter.hasNext()) { product += productType.toString() .substring(productType.toString().indexOf("/") + 1) + ","; } else { product += productType.toString() .substring(productType.toString().indexOf("/") + 1); } } } else { product = field.decl().expr.type().toExpr().toString() .substring(field.decl().expr.type().toExpr().toString().indexOf("/") + 1); } final String str2 = field.label + " : " + field.sig.toString().substring(field.sig.toString().indexOf("/") + 1) + " -> " + field.decl().expr.mult() + " " + product; this.rels.add(str2); } } } final Iterator<Entry<String, String>> mapIter = map.entrySet().iterator(); while (mapIter.hasNext()) { final Entry<String, String> entry = mapIter.next(); final SourceType sourceType = persistenceFactory.eINSTANCE.createSourceType(); sourceType.setFilename(entry.getKey()); sourceType.setContent(entry.getValue()); documentRoot.getAlloy().getSource().add(sourceType); } AlloyUtilities.writeDocumentRoot(documentRoot); // AlloyUtilities.saveResource(AlloyUtilities.getResource(), documentRoot); final MessageDialog messageDialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Information", null, "Alloy file has been parsed succesfully", MessageDialog.INFORMATION, new String[] { "OK" }, 0); messageDialog.open(); } catch (final Err e) { final MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Alloy Error Information", null, e.getMessage(), MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); } }