List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning
public static void openWarning(Shell parent, String title, String message)
From source file:com.archimatetool.help.cheatsheets.CreateMapViewCheatSheetAction.java
License:Open Source License
public void run(String[] params, ICheatSheetManager manager) { IViewPart viewPart = ViewManager.showViewPart(ITreeModelView.ID, true); if (viewPart == null) { MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.CreateMapViewCheatSheetAction_0, Messages.CreateMapViewCheatSheetAction_1); return;//ww w . j av a 2 s . c o m } IArchimateModel model = (IArchimateModel) viewPart.getAdapter(IArchimateModel.class); if (model == null) { MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.CreateMapViewCheatSheetAction_2, Messages.CreateMapViewCheatSheetAction_3); return; } EList<IDiagramModel> diagramModels = model.getDiagramModels(); if (diagramModels.size() < 2) { MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.CreateMapViewCheatSheetAction_4, Messages.CreateMapViewCheatSheetAction_5); return; } CommandStack stack = (CommandStack) model.getAdapter(CommandStack.class); if (stack != null) { IArchimateDiagramModel diagramModel = IArchimateFactory.eINSTANCE.createArchimateDiagramModel(); diagramModel.setName(Messages.CreateMapViewCheatSheetAction_6); int y = 20; for (IDiagramModel dm : diagramModels) { IDiagramModelReference ref = IArchimateFactory.eINSTANCE.createDiagramModelReference(); ref.setReferencedModel(dm); ref.setBounds(20, y, 400, 100); diagramModel.getChildren().add(ref); y += 120; } IFolder folder = model.getDefaultFolderForElement(diagramModel); stack.execute(new NewViewCommand(folder, diagramModel)); } }
From source file:com.astra.ses.spell.dev.scheck.ui.handlers.GenerateReportCommand.java
License:Open Source License
/** * the command has been executed, so extract extract the needed information * from the application context.// www . j ava 2 s. c om */ @SuppressWarnings("unchecked") public Object execute(ExecutionEvent event) throws ExecutionException { // Gather all markers // Get the list of known issues List<IMarker> markers = null; IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); ISelectionService sservice = window.getSelectionService(); ISelection selection = sservice.getSelection(); // If nothing selected, generate all issues known if ((selection == null) || (selection.isEmpty())) { markers = MarkerManager.getAllMarkers(); } else { List<IResource> selectedItems = null; // The selection may be a structured selection or text selected in an editor part if (selection instanceof IStructuredSelection) { IStructuredSelection sselection = (IStructuredSelection) selection; selectedItems = (List<IResource>) sselection.toList(); } else if ((selection instanceof ITextSelection)) { IEditorPart editor = window.getActivePage().getActiveEditor(); // If an editor is selected if (editor != null) { SpellEditorInfo info = (SpellEditorInfo) editor.getAdapter(SpellEditorInfo.class); // If the editor could adapt if (info != null) { selectedItems = new ArrayList<IResource>(); selectedItems.add(info.getFile()); } } } // Gather only the resources selected for processing if (selectedItems != null) { markers = new ArrayList<IMarker>(); for (IResource res : selectedItems) { markers.addAll(MarkerManager.getAllMarkers(res)); } } } // If no issues known, dont continue if (markers.size() == 0) { MessageDialog.openWarning(window.getShell(), "Report generation", "No semantic issues to report"); return null; } String output = ""; DirectoryDialog dialog = new DirectoryDialog(Display.getCurrent().getActiveShell(), SWT.SAVE); dialog.setText("Select directory for generated report files"); dialog.setFilterPath(System.getProperty("user.home")); output = dialog.open(); if ((output != null) && (!output.isEmpty())) { File dir = new File(output); if (!dir.exists()) { MessageDialog.openError(window.getShell(), "Cannot generate reports", "Given directory does not exist"); return null; } if (!dir.canWrite()) { MessageDialog.openError(window.getShell(), "Cannot generate reports", "Cannot write to given directory"); return null; } GenerateReportFilesJob job = new GenerateReportFilesJob(output, markers); JobHelper.executeJob(job, true, true); if (job.numGenerated > 0) { MessageDialog.openInformation(window.getShell(), "Reports generated", "Generated " + job.numGenerated + " files in '" + output + "'"); } } return null; }
From source file:com.astra.ses.spell.gui.advisor.ApplicationWorkbenchWindowAdvisor.java
License:Open Source License
/*************************************************************************** * Called just before the workbench window is to be closed. * Returning false prevents the window to be closed **************************************************************************/ public boolean preWindowShellClose() { Logger.debug("Closing workbench", Level.INIT, this); IWorkbenchWindow window = getWindowConfigurer().getWindow(); ProcedureManager mgr = (ProcedureManager) ServiceManager.get(ProcedureManager.ID); ServerProxy sproxy = (ServerProxy) ServiceManager.get(ServerProxy.ID); ContextProxy cproxy = (ContextProxy) ServiceManager.get(ContextProxy.ID); if (cproxy.isConnected() && mgr.getOpenLocalProcedures().size() > 0) { MessageDialog.openWarning(window.getShell(), "Shutdown", "Cannot shutdown client.\n\n" + "There are open procedures"); return false; }/*w w w . j a va2 s . c o m*/ // Obtain a handle to the server proxy CommandResult cresult = CommandResult.SUCCESS; if (sproxy.isConnected() && cproxy.isConnected()) { cresult = CommandHelper.execute(DetachContext.ID); } return (cresult == CommandResult.SUCCESS); }
From source file:com.astra.ses.spell.gui.dialogs.DictionaryEditorDialog.java
License:Open Source License
/*************************************************************************** * //from ww w. j a v a 2 s. c o m **************************************************************************/ private void mergeVariables(List<TypedVariable> fileVars) { if (m_chkOverwrite.getSelection()) { String overwrite = ""; for (TypedVariable fileVar : fileVars) { if (m_container.hasVariable(fileVar.getName())) { TypedVariable var = m_container.getVariable(fileVar.getName()); String origValue = var.getValue(); String newValue = fileVar.getValue(); if (!origValue.equals(newValue)) { if (!overwrite.isEmpty()) overwrite += "\n"; overwrite += " - " + fileVar.getName(); } } } if (!overwrite.isEmpty()) { LongTextDialog dialog = new LongTextDialog(getShell(), "Value overwrite", "The value of the following variables will be changed.\n\nDo you want to continue?", overwrite, false); dialog.open(); if (dialog.choice != IDialogConstants.OK_ID) { return; } } } String errors = ""; int numMerged = 0; boolean mergeNew = m_chkMergeNew.getSelection(); for (TypedVariable fileVar : fileVars) { boolean varExists = m_container.hasVariable(fileVar.getName()); if (!mergeNew && !varExists) continue; if (varExists) { TypedVariable var = m_container.getVariable(fileVar.getName()); String newValue = fileVar.getValue(); try { var.setValue(newValue); numMerged++; } catch (Exception ex) { if (!errors.isEmpty()) errors += "\n"; errors += " - '" + fileVar.getName() + "': " + ex.getLocalizedMessage(); } } else { TypedVariable copy = fileVar.copy(); copy.markNew(); m_container.addVariable(fileVar.getName(), copy); numMerged++; } } if (!errors.isEmpty()) { LongTextDialog dialog = new LongTextDialog(getShell(), "Failed to change value", "The value of the following variables could not be changed:", errors, true); dialog.open(); } if (numMerged == 0) { MessageDialog.openWarning(getShell(), "No changes made", "No value has been changed in the data container"); return; } m_varTable.refresh(); m_varTable.setSelection(null); m_fileTable.setSelection(null); update(); }
From source file:com.astra.ses.spell.gui.model.commands.AttachContext.java
License:Open Source License
/*************************************************************************** * The command has been executed, so extract extract the needed information * from the application context.// www. j a va2 s .com **************************************************************************/ public CommandResult execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ServerProxy proxy = (ServerProxy) ServiceManager.get(ServerProxy.ID); ContextProxy cproxy = (ContextProxy) ServiceManager.get(ContextProxy.ID); ConfigurationManager cfg = (ConfigurationManager) ServiceManager.get(ConfigurationManager.ID); ContextInfo info = (ContextInfo) cfg.getSelection(IConfig.ID_CONTEXT_SELECTION); if (info == null) { MessageDialog.openWarning(window.getShell(), "Attach context", "Cannot attach: no context selected"); return CommandResult.NO_EFFECT; } if (!proxy.isConnected()) { MessageDialog.openWarning(window.getShell(), "Attach context", "Cannot attach: not connected to server"); return CommandResult.FAILED; } if (cproxy.isConnected()) { MessageDialog.openWarning(window.getShell(), "Attach context", "Cannot attach: already attached to a context"); return CommandResult.FAILED; } if (!info.isRunning()) { MessageDialog.openWarning(window.getShell(), "Attach context", "Context is not running"); return CommandResult.NO_EFFECT; } try { proxy.attachContext(info.getName()); } catch (ServerError ex) { MessageDialog.openError(window.getShell(), "Attach context", "Cannot stop context:\n\n" + ex.getLocalizedMessage()); return CommandResult.FAILED; } return CommandResult.SUCCESS; }
From source file:com.astra.ses.spell.gui.model.commands.DestroyContext.java
License:Open Source License
/*************************************************************************** * The command has been executed, so extract extract the needed information * from the application context./*from ww w. j ava 2 s. com*/ **************************************************************************/ public CommandResult execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ServerProxy proxy = (ServerProxy) ServiceManager.get(ServerProxy.ID); if (!proxy.isConnected()) { MessageDialog.openWarning(window.getShell(), "Destroy context", "Cannot destroy: not connected to server"); return CommandResult.FAILED; } try { try { proxy.detachContext(); } catch (Exception ex) { ; } ; ConfigurationManager cfg = (ConfigurationManager) ServiceManager.get(ConfigurationManager.ID); ContextInfo info = (ContextInfo) cfg.getSelection(IConfig.ID_CONTEXT_SELECTION); proxy.destroyContext(info.getName()); } catch (ServerError ex) { MessageDialog.openError(window.getShell(), "Destroy context", "Cannot destroy context:\n\n" + ex.getLocalizedMessage()); return CommandResult.FAILED; } return CommandResult.SUCCESS; }
From source file:com.astra.ses.spell.gui.model.commands.DetachContext.java
License:Open Source License
/*************************************************************************** * The command has been executed, so extract extract the needed information * from the application context./*from w ww. ja va2s .co m*/ **************************************************************************/ public CommandResult execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ServerProxy proxy = (ServerProxy) ServiceManager.get(ServerProxy.ID); ContextProxy cproxy = (ContextProxy) ServiceManager.get(ContextProxy.ID); ProcedureManager pmgr = (ProcedureManager) ServiceManager.get(ProcedureManager.ID); if (!cproxy.isConnected()) { MessageDialog.openWarning(window.getShell(), "Detach context", "Cannot detach: not attached to a context"); return CommandResult.FAILED; } if (!proxy.isConnected()) { MessageDialog.openWarning(window.getShell(), "Detach context", "Cannot detach: not connected to server"); return CommandResult.FAILED; } try { // Check if there are open procedures. Set<String> openProcs = pmgr.getOpenLocalProcedures(); if (openProcs.size() > 0) { CloseAllDialog dialog = new CloseAllDialog(window.getShell()); int result = dialog.open(); if (result == CloseAllDialog.CLOSE) { CommandHelper.executeInProgress(new CloseAllJob(), true, true); } else if (result == CloseAllDialog.KILL) { CommandHelper.executeInProgress(new KillAllJob(), true, true); } else if (result == CloseAllDialog.DETACH) { CommandHelper.executeInProgress(new ReleaseAllJob(), true, true); } else { return CommandResult.NO_EFFECT; } } proxy.detachContext(); } catch (ServerError ex) { MessageDialog.openError(window.getShell(), "Detach context", "Cannot stop context:\n\n" + ex.getLocalizedMessage()); return CommandResult.FAILED; } return CommandResult.SUCCESS; }
From source file:com.astra.ses.spell.gui.model.commands.DisconnectServer.java
License:Open Source License
/*************************************************************************** * The command has been executed, so extract extract the needed information * from the application context./*from w ww .ja v a 2 s . c om*/ **************************************************************************/ public CommandResult execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ServerProxy proxy = (ServerProxy) ServiceManager.get(ServerProxy.ID); if (!proxy.isConnected()) { MessageDialog.openWarning(window.getShell(), "Disconnect from server", "Already disconnected from server"); return CommandResult.NO_EFFECT; } else { try { proxy.disconnect(); } catch (ServerError ex) { MessageDialog.openError(window.getShell(), "Disconnect from server", "Cannot disconnect from server:\n\n" + ex.getLocalizedMessage()); return CommandResult.FAILED; } } return CommandResult.SUCCESS; }
From source file:com.astra.ses.spell.gui.model.commands.EditDictionary.java
License:Open Source License
/*************************************************************************** * The command has been executed, so extract extract the needed information * from the application context.// w ww . j a v a2 s . c o m **************************************************************************/ public CommandResult execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IRuntimeSettings svc = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class); String procId = (String) svc.getRuntimeProperty(RuntimeProperty.ID_PROCEDURE_SELECTION); String dictname = event.getParameter(ARG_DICTNAME); String canMergeStr = event.getParameter(ARG_CANMERGE); boolean canMerge = false; if (canMergeStr != null) { canMerge = canMergeStr.equals("true"); } if (dictname == null) { DictionaryNameDialog dialog = new DictionaryNameDialog(window.getShell()); if (dialog.open() == IDialogConstants.OK_ID) { dictname = dialog.getSelectedDictionary(); } } if (dictname != null) { IProcedureManager pmgr = (IProcedureManager) ServiceManager.get(IProcedureManager.class); IProcedure proc = pmgr.getProcedure(procId); try { DictionaryEditorDialog dialog = new DictionaryEditorDialog(window.getShell(), proc, dictname, canMerge); dialog.open(); } catch (ContextError ex) { MessageDialog.openWarning(window.getShell(), "Error retrieving dictionary", ex.getMessage()); return CommandResult.FAILED; } } else { return CommandResult.CANCELLED; } return CommandResult.SUCCESS; }
From source file:com.astra.ses.spell.gui.model.commands.RefreshProcedures.java
License:Open Source License
/*************************************************************************** * The command has been executed, so extract extract the needed information * from the application context.// w w w.j a v a 2s . c o m **************************************************************************/ public CommandResult execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ContextProxy cproxy = (ContextProxy) ServiceManager.get(ContextProxy.ID); ViewManager viewMgr = (ViewManager) ServiceManager.get(ViewManager.ID); NavigationView navView = (NavigationView) viewMgr.getView(NavigationView.ID); if (!cproxy.isConnected()) { MessageDialog.openWarning(window.getShell(), "Refresh procedures", "Cannot refresh: not attached to a context"); return CommandResult.FAILED; } try { Logger.debug("Triggering procedure list refresh", Level.PROC, this); navView.getModel().update(false); } catch (ServerError ex) { MessageDialog.openError(window.getShell(), "Refresh procedures", "Cannot refresh procedures:\n\n" + ex.getLocalizedMessage()); return CommandResult.FAILED; } return CommandResult.SUCCESS; }