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.DefaultsDialog.java
License:Open Source License
/*************************************************************************** * Create the button bar buttons./*from w ww . j a va2 s . co m*/ * * @param parent * The Button Bar. **************************************************************************/ protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); }
From source file:com.astra.ses.spell.gui.dialogs.DictionaryEditorDialog.java
License:Open Source License
/*************************************************************************** * //from ww w. ja v a2 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.dialogs.DictionaryEditorDialog.java
License:Open Source License
/*************************************************************************** * /*from w w w . j a v a 2 s. c o m*/ **************************************************************************/ public void update() { if (m_canMergeFiles) { m_mergeSelButton .setEnabled(!m_fileContainer.getVariables().isEmpty() && !m_fileTable.getSelection().isEmpty()); m_mergeAllButton.setEnabled(!m_fileContainer.getVariables().isEmpty()); m_chkOverwrite.setEnabled(!m_fileContainer.getVariables().isEmpty()); m_chkMergeNew.setEnabled(!m_fileContainer.getVariables().isEmpty()); } getButton(IDialogConstants.OK_ID).setEnabled(m_container.hasChanges()); getButton(IDialogConstants.BACK_ID).setEnabled(m_container.hasChanges()); }
From source file:com.astra.ses.spell.gui.dialogs.DictionaryEditorDialog.java
License:Open Source License
/*************************************************************************** * Create the button bar buttons./*from w ww . jav a 2 s. co m*/ * * @param parent * The Button Bar. **************************************************************************/ @Override protected void createButtonsForButtonBar(Composite parent) { if (!m_readOnly) { createButton(parent, IDialogConstants.BACK_ID, "Revert Changes", false); createButton(parent, IDialogConstants.OK_ID, "Apply and Close", false); getButton(IDialogConstants.OK_ID).setEnabled(false); getButton(IDialogConstants.BACK_ID).setEnabled(false); } createButton(parent, IDialogConstants.CANCEL_ID, "Close", true); }
From source file:com.astra.ses.spell.gui.dialogs.DictionaryEditorDialog.java
License:Open Source License
/*************************************************************************** * Called when one of the buttons of the button bar is pressed. * /*from ww w.ja v a 2 s . c o m*/ * @param buttonId * The button identifier. **************************************************************************/ @Override protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.OK_ID) { if (m_container.hasChanges()) { boolean mergeNew = false; // The button can be null for dialogs without file import if (m_chkMergeNew != null) { m_chkMergeNew.getSelection(); } UpdateDataContainerJob job = new UpdateDataContainerJob(m_procId, m_container, mergeNew); CommandHelper.executeInProgress(job, true, true); m_varTable.refresh(); if (job.result == CommandResult.FAILED) { MessageDialog.openError(getShell(), "Update Error", "Failed to update changes to dictionary:\n" + job.error); return; } } } else if (buttonId == IDialogConstants.BACK_ID) { doRevert(); return; } else if (buttonId == IDialogConstants.CANCEL_ID) { if (m_container.hasChanges()) { if (!MessageDialog.openConfirm(getShell(), "Changes made", "There are changes made to the data container variables.\n\n" + "If you close the dialog, these changes will be lost. ")) return; } if (!m_fileContainer.getVariables().isEmpty()) { if (!MessageDialog.openConfirm(getShell(), "File loaded", "There are NO changes made to the data container variables, but an input file was loaded.\n\n" + "If you close the dialog, no changes will be applied. Are you sure to close?")) return; } } close(); }
From source file:com.astra.ses.spell.gui.dialogs.DictionaryNameDialog.java
License:Open Source License
/*************************************************************************** * Create the dialog area contents.//from w ww .j a v a 2 s . c om * * @param parent * The base composite of the dialog * @return The resulting contents **************************************************************************/ protected Control createDialogArea(Composite parent) { Composite top = new Composite(parent, SWT.NONE); top.setLayout(new GridLayout(1, true)); top.setLayoutData(new GridData(GridData.FILL_BOTH)); Label label = new Label(top, SWT.NONE); label.setText("Type the name of the dictionary or data container to edit:"); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); m_selectedName = new Text(top, SWT.BORDER); m_selectedName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); m_selectedName.setText(""); m_selectedName.addVerifyListener(new VerifyListener() { @Override public void verifyText(VerifyEvent ev) { boolean ok = !m_selectedName.getText().trim().isEmpty(); getButton(IDialogConstants.OK_ID).setEnabled(ok); if (ok) { setErrorMessage(null); m_selectedNameStr = m_selectedName.getText(); } else { setErrorMessage("Must provide a dictionary or data container name"); m_selectedNameStr = null; } } }); setErrorMessage("Must provide a dictionary or data container name"); return parent; }
From source file:com.astra.ses.spell.gui.dialogs.DictionaryNameDialog.java
License:Open Source License
/*************************************************************************** * Create the button bar buttons./*from www .j a v a2s . c o m*/ * * @param parent * The Button Bar. **************************************************************************/ protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true); createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false); getButton(IDialogConstants.OK_ID).setEnabled(false); }
From source file:com.astra.ses.spell.gui.dialogs.DictionaryNameDialog.java
License:Open Source License
/*************************************************************************** * Called when one of the buttons of the button bar is pressed. * //from w ww . j a va 2s .c om * @param buttonId * The button identifier. **************************************************************************/ protected void buttonPressed(int buttonId) { setReturnCode(buttonId); switch (buttonId) { case IDialogConstants.OK_ID: m_selectedNameStr = m_selectedName.getText(); if (m_selectedNameStr.trim().isEmpty()) m_selectedNameStr = null; break; case IDialogConstants.CANCEL_ID: m_selectedNameStr = null; break; } close(); }
From source file:com.astra.ses.spell.gui.dialogs.GotoDialog.java
License:Open Source License
/*************************************************************************** * Called when one of the buttons of the button bar is pressed. * /*from w w w .j ava 2 s.c o m*/ * @param buttonId * The button identifier. **************************************************************************/ protected void buttonPressed(int buttonId) { switch (buttonId) { case IDialogConstants.OK_ID: m_target = m_input.getText(); if (m_typeLine.getSelection()) { try { Integer.parseInt(m_target); } catch (NumberFormatException ex) { MessageDialog.openError(getShell(), "Input error", "Shall provide a valid line number"); } } else { if (m_target.trim().isEmpty()) { MessageDialog.openError(getShell(), "Input error", "Shall provide a valid step label"); return; } } m_isLabel = m_typeLabel.getSelection(); close(); break; case IDialogConstants.CANCEL_ID: m_target = null; m_isLabel = false; close(); break; } }
From source file:com.astra.ses.spell.gui.dialogs.InputFileViewerDialog.java
License:Open Source License
/*************************************************************************** * Create the button bar buttons.// w ww. ja va 2 s . com * * @param parent * The Button Bar. **************************************************************************/ @Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, "Close", true); }