List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_ID
int OK_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_ID.
Click Source Link
From source file:com.astra.ses.spell.gui.dialogs.StartWithParametersDialog.java
License:Open Source License
/*************************************************************************** * Called when one of the buttons of the button bar is pressed. * //from w w w . j av a 2 s.c o m * @param buttonId * The button identifier. **************************************************************************/ protected void buttonPressed(int buttonId) { switch (buttonId) { case IDialogConstants.OK_ID: try { if (parseArguments()) { close(); } } catch (Exception ex) { MessageDialog.openError(Display.getCurrent().getActiveShell(), "Argument definition error", ex.getLocalizedMessage()); } break; case IDialogConstants.CANCEL_ID: m_argExpression = null; close(); } }
From source file:com.astra.ses.spell.gui.dialogs.StringDialog.java
License:Open Source License
/*************************************************************************** * Called when one of the buttons of the button bar is pressed. * // w w w .j a v a 2 s . co m * @param buttonId * The button identifier. **************************************************************************/ protected void buttonPressed(int buttonId) { switch (buttonId) { case IDialogConstants.OK_ID: m_answer = m_text.getText(); if (m_answer.length() == 0) { return; } setReturnCode(TitleAreaDialog.OK); break; case IDialogConstants.CANCEL_ID: m_answer = null; setReturnCode(TitleAreaDialog.CANCEL); break; } close(); }
From source file:com.astra.ses.spell.gui.model.commands.ConfigureDefaults.java
License:Open Source License
/*************************************************************************** * The command has been executed, so extract extract the needed information * from the application context./* w w w . jav a2s . c o m*/ **************************************************************************/ public CommandResult execute(ExecutionEvent event) throws ExecutionException { // Variables declaration and initialization IRuntimeSettings runtime = null; String procId = null; IServerProxy sProxy = null; IContextProxy cProxy = null; Shell shell = null; DefaultsDialog dialog = null; int dialogResult = 0; IConfigurationManager conf; ExecutorDefaults dialogValues; /** Holds the Context Executor Defaults of the form */ ExecutorDefaults executorDefaults = new ExecutorDefaults(); /** Transfer the updated executor defaults */ Map<String, String> updatedDefaults = new TreeMap<String, String>(); // Get server Proxy sProxy = (IServerProxy) ServiceManager.get(IServerProxy.class); if (sProxy.isConnected() && sProxy.getCurrentServer().getRole() == ServerRole.COMMANDING) { //Get cProxy cProxy = (IContextProxy) ServiceManager.get(IContextProxy.class); if (cProxy.isConnected()) { //Get shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); try { //Get context defaults from the Context Server through the Context Proxy. cProxy.getExecutorDefaults(executorDefaults); //Prepare dialog dialog = new DefaultsDialog(shell, executorDefaults); dialogResult = dialog.open(); if (dialogResult == IDialogConstants.OK_ID) { //Get defaults values of the dialog dialogValues = dialog.getExecutorDefaults(); //Only send updated values. if (dialogValues.getRunInto() != executorDefaults.getRunInto()) updatedDefaults.put(ExecutorDefaultParams.RUN_INTO.getParam(), dialogValues.getRunInto() ? "True" : "False"); if (dialogValues.getByStep() != executorDefaults.getByStep()) updatedDefaults.put(ExecutorDefaultParams.BY_STEP.getParam(), dialogValues.getByStep() ? "True" : "False"); if (dialogValues.getBrowsableLib() != executorDefaults.getBrowsableLib()) updatedDefaults.put(ExecutorDefaultParams.BROWSABLE_LIB.getParam(), dialogValues.getBrowsableLib() ? "True" : "False"); if (dialogValues.getForceTcConfirm() != executorDefaults.getForceTcConfirm()) updatedDefaults.put(ExecutorDefaultParams.FORCE_TC_CONFIRM.getParam(), dialogValues.getForceTcConfirm() ? "True" : "False"); if (dialogValues.getExecDelay() != executorDefaults.getExecDelay()) updatedDefaults.put(ExecutorDefaultParams.EXEC_DELAY.getParam(), Integer.toString(dialogValues.getExecDelay())); if (dialogValues.getPromptWarningDelay() != executorDefaults.getPromptWarningDelay()) updatedDefaults.put(ExecutorDefaultParams.PROMPT_DELAY.getParam(), Integer.toString(dialogValues.getPromptWarningDelay())); if (dialogValues.getMaxVerbosity() != executorDefaults.getMaxVerbosity()) updatedDefaults.put(ExecutorDefaultParams.MAX_VERBOSITY.getParam(), Integer.toString(dialogValues.getMaxVerbosity())); if (dialogValues.getWatchVariables() != executorDefaults.getWatchVariables()) updatedDefaults.put(ExecutorDefaultParams.WATCH_VARIABLES.getParam(), dialogValues.getWatchVariables() ? "True" : "False"); if (dialogValues.getSaveStateMode() != executorDefaults.getSaveStateMode()) updatedDefaults.put(ExecutorDefaultParams.SAVE_STATE_MODE.getParam(), dialogValues.getSaveStateMode().getKey()); //Send updated default fields to server cProxy.setExecutorDefaults(updatedDefaults); } } catch (Exception ex) { MessageDialog.openError(shell, "Configure Defaults", "Failed to obtain exector defaults of the context."); return CommandResult.FAILED; } } //context connected } //Server proxy connected and Commanding return CommandResult.SUCCESS; }
From source file:com.astra.ses.spell.gui.model.commands.ConfigureExecution.java
License:Open Source License
/*************************************************************************** * The command has been executed, so extract extract the needed information * from the application context./*www . j av a 2s. com*/ **************************************************************************/ public CommandResult execute(ExecutionEvent event) throws ExecutionException { IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class); String procId = (String) runtime.getRuntimeProperty(RuntimeProperty.ID_PROCEDURE_SELECTION); IProcedureManager mgr = (IProcedureManager) ServiceManager.get(IProcedureManager.class); IProcedure proc = mgr.getProcedure(procId); Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); try { proc.getController().updateConfig(); } catch (Exception ex) { MessageDialog.openError(shell, "Configure Execution", "Failed to obtain current procedure configuration"); return CommandResult.FAILED; } ConfigDialog dialog = new ConfigDialog(shell, proc); int result = dialog.open(); if (result == IDialogConstants.OK_ID) { boolean runIntoOrig = proc.getController().getStepOverControl().getMode() .equals(StepOverMode.STEP_INTO_ALWAYS); boolean byStepOrig = proc.getRuntimeInformation().isStepByStep(); int delayOrig = proc.getRuntimeInformation().getExecutionDelay(); if (runIntoOrig != dialog.getRunInto()) { proc.getController().setRunInto(dialog.getRunInto()); } if (byStepOrig != dialog.getByStep()) { proc.getController().setStepByStep(dialog.getByStep()); } if (delayOrig != dialog.getExecutionDelay()) { proc.getController().setExecutionDelay(dialog.getExecutionDelay()); } } 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./*from ww w. j a v a 2 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.dialogs.VariableDetailDialog.java
License:Open Source License
/*************************************************************************** * Create the button bar buttons./*from ww w. java 2s .c om*/ * * @param parent * The Button Bar. **************************************************************************/ protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); }
From source file:com.astra.ses.spell.gui.replay.dialogs.ExecutionSelectionDialog.java
License:Open Source License
/*************************************************************************** * Create the button bar buttons./*ww w.ja v a 2s . c om*/ * * @param parent * The Button Bar. **************************************************************************/ @Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, "Replay", false); createButton(parent, SAVE_ID, "Save as...", false); getButton(IDialogConstants.OK_ID).setEnabled(false); getButton(SAVE_ID).setEnabled(false); createButton(parent, IDialogConstants.CANCEL_ID, "Close", true); }
From source file:com.astra.ses.spell.gui.replay.dialogs.ExecutionSelectionDialog.java
License:Open Source License
/*************************************************************************** * Called when one of the buttons of the button bar is pressed. * /* w w w .j a v a 2 s . com*/ * @param buttonId * The button identifier. **************************************************************************/ @Override protected void buttonPressed(int buttonId) { close(); if (buttonId == IDialogConstants.OK_ID) { if (m_selection != null) { HashMap<String, String> args = new HashMap<String, String>(); args.put(OpenProcedureReplay.ARG_ASRUN, m_selection.getASRUN()); CommandHelper.execute(OpenProcedureReplay.ID, args); } } else if (buttonId == SAVE_ID) { if (m_selection != null) { ExportAsRunFileJob job = new ExportAsRunFileJob(m_selection.getASRUN()); CommandHelper.executeInProgress(job, true, true); List<AsRunFile> toExport = new LinkedList<AsRunFile>(); if (job.result.equals(CommandResult.SUCCESS)) { toExport.add(job.asrunFile); if (!job.asrunFile.getChildren().isEmpty()) { boolean alsoChildren = MessageDialog.openQuestion(getParentShell(), "Save children ASRUN files", "This procedure has executed sub-procedures.\n\nDo you want to export these ASRUN files as well?"); if (alsoChildren) { gatherChildAsRunFiles(job.asrunFile, toExport); } } } DirectoryDialog dialog = new DirectoryDialog(getParentShell(), SWT.SAVE); dialog.setMessage("Select directory to export ASRUN file(s)"); dialog.setText("Save ASRUN"); String destination = dialog.open(); if (destination != null && !destination.isEmpty()) { SaveAsRunFileJob saveJob = new SaveAsRunFileJob(destination, toExport); CommandHelper.executeInProgress(saveJob, true, true); } } } }
From source file:com.astra.ses.spell.gui.replay.dialogs.ExecutionSelectionDialog.java
License:Open Source License
/*************************************************************************** * /*from w w w . jav a2 s . c o m*/ **************************************************************************/ @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) event.getSelection(); if (sel.isEmpty()) { getButton(IDialogConstants.OK_ID).setEnabled(false); getButton(SAVE_ID).setEnabled(false); } else { if (sel.getFirstElement() instanceof ExecutionSelectionLeafNode) { m_selection = (ExecutionSelectionLeafNode) sel.getFirstElement(); getButton(IDialogConstants.OK_ID).setEnabled(true); getButton(SAVE_ID).setEnabled(true); } else { m_selection = null; getButton(IDialogConstants.OK_ID).setEnabled(false); getButton(SAVE_ID).setEnabled(false); } } }
From source file:com.astra.ses.spell.gui.shared.views.controls.ScopeTab.java
License:Open Source License
/*************************************************************************** * //from w ww .j av a 2 s . c o m **************************************************************************/ public ScopeTab(TabFolder parent, ISharedScope table, SharedVariablesView view, boolean monitoringMode) { super(parent, SWT.NONE); Logger.debug("Created tab: " + table.getScopeName(), Level.GUI, this); m_table = table; m_view = view; m_monitoringMode = monitoringMode; Composite top = new Composite(parent, SWT.NONE); top.setLayout(new GridLayout(isGlobal() ? 4 : 5, true)); top.setLayoutData(new GridData(GridData.FILL_BOTH)); m_viewer = new SharedVariablesTableViewer(top, table, monitoringMode); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = isGlobal() ? 4 : 5; m_viewer.getControl().setLayoutData(gd); m_viewer.addSelectionChangedListener(this); if (isGlobal()) { setText("GLOBAL"); } else { setText(m_table.getScopeName()); } m_btnNew = new Button(top, SWT.PUSH); m_btnNew.setText("New variable"); m_btnNew.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); m_btnNew.setEnabled(false); m_btnNew.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent ev) { SharedVariableDialog dialog = new SharedVariableDialog(m_viewer.getControl().getShell(), true, "", ""); if (dialog.open() == IDialogConstants.OK_ID) { String key = dialog.getKey(); String value = dialog.getValue(); if (!key.trim().isEmpty() && !value.trim().isEmpty()) { m_table.set(dialog.getKey(), dialog.getValue()); refresh(); } } } }); m_btnDel = new Button(top, SWT.PUSH); m_btnDel.setText("Delete variable"); m_btnDel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); m_btnDel.setEnabled(false); m_btnDel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent ev) { IStructuredSelection sel = (IStructuredSelection) m_viewer.getSelection(); if (!sel.isEmpty()) { @SuppressWarnings("rawtypes") Iterator it = sel.iterator(); String toDeleteText = "Are you sure to delete the following shared variables?\n\n"; List<SharedVariable> toDelete = new LinkedList<SharedVariable>(); while (it.hasNext()) { SharedVariable var = (SharedVariable) it.next(); toDelete.add(var); toDeleteText += " - " + var.name + "\n"; } if (MessageDialog.openConfirm(m_viewer.getControl().getShell(), "Delete shared variables", toDeleteText)) { ClearSharedVariablesJob job = new ClearSharedVariablesJob(m_table, toDelete); CommandHelper.executeInProgress(job, true, true); refresh(); } } } }); m_btnClear = new Button(top, SWT.PUSH); m_btnClear.setText("Remove all variables"); m_btnClear.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); m_btnClear.setEnabled(false); m_btnClear.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent ev) { String text = "This action will remove all shared variables in the scope.\n\nDo you want to proceed?"; if (MessageDialog.openConfirm(m_viewer.getControl().getShell(), "Delete shared variables", text)) { ClearSharedVariablesJob job = new ClearSharedVariablesJob(m_table); CommandHelper.executeInProgress(job, true, true); refresh(); } } }); Button refreshScope = new Button(top, SWT.PUSH); refreshScope.setText("Refresh variables"); refreshScope.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); refreshScope.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent ev) { Logger.debug("Refreshing tab: " + m_table.getScopeName(), Level.GUI, this); RefreshSharedVariablesJob job = new RefreshSharedVariablesJob(m_table); CommandHelper.executeInProgress(job, true, true); refresh(); } }); if (!isGlobal()) { m_btnRemove = new Button(top, SWT.PUSH); m_btnRemove.setText("Remove scope"); m_btnRemove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); m_btnRemove.setEnabled(false); m_btnRemove.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent ev) { String text = "This action will completely remove the scope and its variables.\n\nDo you want to proceed?"; if (MessageDialog.openConfirm(m_viewer.getControl().getShell(), "Delete shared variables", text)) { ISharedDataService svc = (ISharedDataService) ServiceManager.get(ISharedDataService.class); svc.removeSharedScope(m_table.getScopeName()); m_view.removeScope(m_table.getScopeName()); } } }); } if (!monitoringMode) { m_btnNew.setEnabled(true); m_btnClear.setEnabled(true); if (!isGlobal()) m_btnRemove.setEnabled(true); } setControl(top); }