use of org.eclipse.jface.dialogs.Dialog in project tdi-studio-se by Talend.
the class ParallelExecutionAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
boolean hasFlowConnection = false;
for (IConnection connection : node.getOutgoingConnections()) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
hasFlowConnection = true;
break;
}
}
if (hasFlowConnection) {
MessageDialog.openError(getWorkbenchPart().getSite().getShell(), Messages.getString(//$NON-NLS-1$
"ParallelExecutionAction.gotLink"), //$NON-NLS-1$
Messages.getString("ParallelExecutionAction.noOutputLink"));
return;
}
IElementParameter enableParallelizeParameter = node.getElementParameter(EParameterName.PARALLELIZE.getName());
if (enableParallelizeParameter != null) {
parallelEnable = (Boolean) enableParallelizeParameter.getValue();
}
IElementParameter numberParallelizeParameter = node.getElementParameter(EParameterName.PARALLELIZE_NUMBER.getName());
if (numberParallelizeParameter != null) {
numberParallel = (String) numberParallelizeParameter.getValue();
}
Dialog dialog = new ParallelDialog(getWorkbenchPart().getSite().getShell());
if (dialog.open() == Dialog.OK) {
Command command = new PropertyChangeCommand(node, EParameterName.PARALLELIZE.getName(), parallelEnable);
execute(command);
}
}
use of org.eclipse.jface.dialogs.Dialog in project tdi-studio-se by Talend.
the class SqlMemoController method refreshConnectionCommand.
private Command refreshConnectionCommand() {
// open sql builder in repository mode, just use query object, no need for connection information
ConnectionParameters connParameters = new ConnectionParameters();
String queryId = (String) elem.getPropertyValue(EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName());
Query query = MetadataToolHelper.getQueryFromRepository(queryId);
DatabaseConnectionItem item = findRepositoryItem(queryId);
if (item != null) {
connParameters.setRepositoryName(item.getProperty().getLabel());
connParameters.setRepositoryId(item.getProperty().getId());
}
connParameters.setQueryObject(query);
connParameters.setQuery(query.getValue());
TextUtil.setDialogTitle(TextUtil.SQL_BUILDER_TITLE_REP);
String processName = null;
if (elem instanceof IProcess) {
processName = ((IProcess) elem).getName();
} else if (elem instanceof INode) {
processName = ((INode) elem).getProcess().getName();
} else if (elem instanceof IConnection) {
processName = ((IConnection) elem).getSource().getProcess().getName();
}
connParameters.setNodeReadOnly(false);
connParameters.setFromRepository(true);
ISQLBuilderService sqlBuilderService = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
Dialog sqlBuilder = sqlBuilderService.openSQLBuilderDialog(composite.getShell(), processName, connParameters);
String sql = null;
if (Window.OK == sqlBuilder.open()) {
sql = connParameters.getQuery();
}
if (sql != null && !queryText.isDisposed()) {
queryText.setText(sql);
String propertyName = (String) openSQLEditorButton.getData(PARAMETER_NAME);
return new PropertyChangeCommand(elem, propertyName, sql);
}
return null;
}
use of org.eclipse.jface.dialogs.Dialog in project pentaho-kettle by pentaho.
the class Spoon method openFile.
public void openFile(String filename, boolean importfile) {
// Open the XML and see what's in there.
// We expect a single <transformation> or <job> root at this time...
// does the file exist? If not, show an error dialog
boolean fileExists = false;
try {
final FileObject file = KettleVFS.getFileObject(filename);
fileExists = file.exists();
} catch (final KettleFileException | FileSystemException e) {
// nothing to do, null fileObject will be handled below
}
if (StringUtils.isBlank(filename) || !fileExists) {
final Dialog dlg = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Message", getFileType(filename).toLowerCase()), MessageDialog.ERROR, BaseMessages.getString(PKG, "System.Button.Close"), MISSING_RECENT_DLG_WIDTH, SimpleMessageDialog.BUTTON_WIDTH);
dlg.open();
return;
}
boolean loaded = false;
FileListener listener = null;
Node root = null;
// match by extension first
int idx = filename.lastIndexOf('.');
if (idx != -1) {
for (FileListener li : fileListeners) {
if (li.accepts(filename)) {
listener = li;
break;
}
}
}
// types.
try {
Document document = XMLHandler.loadXMLFile(filename);
root = document.getDocumentElement();
} catch (KettleXMLException e) {
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "Spoon.File.Xml.Parse.Error"));
}
}
// as XML
if (listener == null && root != null) {
for (FileListener li : fileListeners) {
if (li.acceptsXml(root.getNodeName())) {
listener = li;
break;
}
}
}
//
if (!Utils.isEmpty(filename)) {
if (listener != null) {
try {
loaded = listener.open(root, filename, importfile);
} catch (KettleMissingPluginsException e) {
log.logError(e.getMessage(), e);
}
}
if (!loaded) {
// Give error back
hideSplash();
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.UnknownFileType.Message", filename));
mb.setText(BaseMessages.getString(PKG, "Spoon.UnknownFileType.Title"));
mb.open();
} else {
// set variables in the newly loaded
applyVariables();
// transformation(s) and job(s).
}
}
}
use of org.eclipse.jface.dialogs.Dialog in project pentaho-kettle by pentaho.
the class JobEntryTransDialog method ok.
protected void ok() {
if (Utils.isEmpty(wName.getText())) {
final Dialog dialog = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "System.StepJobEntryNameMissing.Title"), BaseMessages.getString(PKG, "System.JobEntryNameMissing.Msg"), MessageDialog.ERROR);
dialog.open();
return;
}
jobEntry.setName(wName.getText());
try {
getInfo(jobEntry);
} catch (KettleException e) {
// suppress exceptions at this time - we will let the runtime report on any errors
}
jobEntry.setChanged();
dispose();
}
use of org.eclipse.jface.dialogs.Dialog in project eclipse.platform.text by eclipse.
the class ChangeEncodingAction method run.
@Override
public void run() {
final IResource resource = getResource();
final Shell parentShell = getTextEditor().getSite().getShell();
final IEncodingSupport encodingSupport = getEncodingSupport();
if (resource == null && encodingSupport == null) {
MessageDialog.openInformation(parentShell, fDialogTitle, TextEditorMessages.ChangeEncodingAction_message_noEncodingSupport);
return;
}
Dialog dialog = new Dialog(parentShell) {
private AbstractEncodingFieldEditor fEncodingEditor;
private IPreferenceStore store = null;
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(fDialogTitle);
}
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
composite = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
composite.setLayoutData(data);
composite.setFont(parent.getFont());
DialogPage page = new MessageDialogPage(composite) {
@Override
public void setErrorMessage(String newMessage) {
super.setErrorMessage(newMessage);
setButtonEnabledState(IDialogConstants.OK_ID, newMessage == null);
setButtonEnabledState(APPLY_ID, newMessage == null);
}
private void setButtonEnabledState(int id, boolean state) {
Button button = getButton(id);
if (button != null)
button.setEnabled(state);
}
};
if (resource != null) {
// $NON-NLS-1$
fEncodingEditor = new ResourceEncodingFieldEditor("", composite, resource, null);
fEncodingEditor.setPage(page);
fEncodingEditor.load();
} else {
// $NON-NLS-1$
fEncodingEditor = new EncodingFieldEditor(ENCODING_PREF_KEY, "", null, composite);
store = new PreferenceStore();
String defaultEncoding = encodingSupport.getDefaultEncoding();
store.setDefault(ENCODING_PREF_KEY, defaultEncoding);
String encoding = encodingSupport.getEncoding();
if (encoding != null)
store.setValue(ENCODING_PREF_KEY, encoding);
fEncodingEditor.setPreferenceStore(store);
fEncodingEditor.setPage(page);
fEncodingEditor.load();
if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0)
fEncodingEditor.loadDefault();
}
return composite;
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, APPLY_ID, TextEditorMessages.ChangeEncodingAction_button_apply_label, false);
super.createButtonsForButtonBar(parent);
}
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == APPLY_ID)
apply();
else
super.buttonPressed(buttonId);
}
@Override
protected void okPressed() {
apply();
super.okPressed();
}
private void apply() {
fEncodingEditor.store();
if (resource == null) {
String encoding = fEncodingEditor.getPreferenceStore().getString(fEncodingEditor.getPreferenceName());
encodingSupport.setEncoding(encoding);
}
}
};
dialog.open();
}
Aggregations