use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.
the class FooterComposite method createComponents.
/**
* amaumont Comment method "createComponents".
*/
private void createComponents() {
GridData footerCompositeGridData = new GridData(GridData.FILL_HORIZONTAL);
this.setLayoutData(footerCompositeGridData);
FormLayout formLayout = new FormLayout();
this.setLayout(formLayout);
Button okButton = new Button(this, SWT.NONE);
//$NON-NLS-1$
okButton.setText(Messages.getString("FooterComposite.0"));
FormData okFormData = new FormData();
Point minSize = okButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
okFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x);
okButton.setLayoutData(okFormData);
okButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
if (foxManager.getUiManager().validateRootElement()) {
foxManager.getUiManager().closeFOX(SWT.OK);
} else {
MessageDialog warningMessageDialog = new MessageDialog(composite.getShell(), Messages.getString(//$NON-NLS-1$
"FooterComposite.RootElementError.Title"), //$NON-NLS-1$
null, //$NON-NLS-1$
Messages.getString("FooterComposite.RootElementError.Message"), //$NON-NLS-1$
MessageDialog.ERROR, new String[] { Messages.getString("FooterComposite.0") }, //$NON-NLS-1$
0);
warningMessageDialog.open();
}
}
});
Button cancelButton = new Button(this, SWT.NONE);
//$NON-NLS-1$
cancelButton.setText(Messages.getString("FooterComposite.1"));
cancelButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
foxManager.getUiManager().closeFOX(SWT.CANCEL);
}
});
FormData cancelFormData = new FormData();
minSize = cancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
cancelFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x);
cancelButton.setLayoutData(cancelFormData);
Button autoMapButton = new Button(this, SWT.NONE);
// see bug 7087
if (foxManager != null) {
boolean canModify = foxManager.getFoxComponent().getProcess().isReadOnly();
if (foxManager.getFoxComponent().getOriginalNode().getJobletNode() != null) {
canModify = foxManager.getFoxComponent().isReadOnly();
}
if (canModify) {
autoMapButton.setEnabled(false);
}
}
//$NON-NLS-1$
autoMapButton.setToolTipText(Messages.getString("FooterComposite.AutoMapTip"));
//$NON-NLS-1$
autoMapButton.setText(Messages.getString("FooterComposite.AutoMap"));
autoMapButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
foxManager.getUiManager().autoMap();
}
});
FormData autoMapFormData = new FormData();
minSize = autoMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
autoMapFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x);
autoMapButton.setLayoutData(autoMapFormData);
cancelFormData.right = new FormAttachment(100, -5);
okFormData.right = new FormAttachment(cancelButton, -5);
autoMapFormData.left = new FormAttachment(0, 5);
// tree operation buttons
FormData treeNodeData = new FormData();
moveDown = new MoveDownTreeNodeButton(this, foxManager);
treeNodeData.right = new FormAttachment(okButton, -5);
moveDown.getButton().setLayoutData(treeNodeData);
moveUpBtn = new MoveUpTreeNodeButton(this, foxManager);
treeNodeData = new FormData();
treeNodeData.right = new FormAttachment(moveDown.getButton(), -5);
moveUpBtn.getButton().setLayoutData(treeNodeData);
removeNodeBtn = new RemoveTreeNodeButton(this, foxManager);
treeNodeData = new FormData();
treeNodeData.right = new FormAttachment(moveUpBtn.getButton(), -5);
removeNodeBtn.getButton().setLayoutData(treeNodeData);
addNodeBtn = new AddTreeNodeButton(this, foxManager);
treeNodeData = new FormData();
treeNodeData.right = new FormAttachment(removeNodeBtn.getButton(), -5);
addNodeBtn.getButton().setLayoutData(treeNodeData);
}
use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.
the class ExportJobScriptAction method doRun.
@Override
protected void doRun() {
JobScriptsExportWizard processWizard = new JobScriptsExportWizard();
IWorkbench workbench = getWorkbench();
processWizard.setWindowTitle(EXPORTJOBSCRIPTS);
processWizard.init(workbench, (IStructuredSelection) this.getSelection());
Shell activeShell = Display.getCurrent().getActiveShell();
WizardDialog dialog = new WizardDialog(activeShell, processWizard);
if (checkDirtyPart(workbench)) {
MessageDialog messageDialog = new //$NON-NLS-1$
MessageDialog(//$NON-NLS-1$
new Shell(), //$NON-NLS-1$
"", //$NON-NLS-1$
null, //$NON-NLS-1$
Messages.getString("ExportJobScriptAction.confirmMessage"), MessageDialog.CONFIRM, new String[] { Messages.getString("ExportJobScriptAction.confirmContiune"), IDialogConstants.CANCEL_LABEL }, //$NON-NLS-1$
0);
if (messageDialog.open() != 0) {
// don't do anything
return;
}
}
dialog.setPageSize(830, 580);
dialog.open();
// collector
IPreferenceStore preferenceStore = RepositoryPlugin.getDefault().getPreferenceStore();
int num = preferenceStore.getInt(ExportJobTokenCollector.TOS_COUNT_JOB_EXPORTS.getPrefKey());
preferenceStore.setValue(ExportJobTokenCollector.TOS_COUNT_JOB_EXPORTS.getPrefKey(), num + 1);
}
use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.
the class ComponentsPreferencePage method propertyChangeForComponents.
public void propertyChangeForComponents(PropertyChangeEvent event) {
MessageDialog warningMessageDialog = new MessageDialog(getFieldEditorParent().getShell(), //$NON-NLS-1$
Messages.getString("ComponentsPreferencePage.WarningTitle"), //$NON-NLS-1$
null, //$NON-NLS-1$
Messages.getString("ComponentsPreferencePage.WarningMsg"), //$NON-NLS-1$
MessageDialog.WARNING, new String[] { Messages.getString("ComponentsPreferencePage.ButtonLabel0") }, //$NON-NLS-1$
0);
warningMessageDialog.open();
}
use of org.eclipse.jface.dialogs.MessageDialog in project sling by apache.
the class ServersActionModeFiddlerActionDelegate method initToolbarContributedActions.
private void initToolbarContributedActions() {
cleanAction = new Action("Clean Publish...", IAction.AS_PUSH_BUTTON) {
public void run() {
if (server == null) {
MessageDialog.openInformation(view.getSite().getShell(), "No server selected", "A server must be selected");
return;
}
int selection = 2;
if (!doNotAskAgain) {
MessageDialog dialog = new MessageDialog(view.getSite().getShell(), Messages.defaultDialogTitle, null, Messages.dialogPublishClean, MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Cancel", "OK (do not ask again)", "OK" }, 1) {
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
setShellStyle(getShellStyle() | SWT.SHEET);
}
};
selection = dialog.open();
}
if (selection != 0) {
if (selection == 1) {
doNotAskAgain = true;
}
IAdaptable info = new IAdaptable() {
public Object getAdapter(Class adapter) {
if (Shell.class.equals(adapter))
return view.getSite().getShell();
if (String.class.equals(adapter))
return "user";
return null;
}
};
server.publish(IServer.PUBLISH_CLEAN, modules, info, null);
}
}
};
cleanAction.setText("Clean Publish...");
cleanAction.setToolTipText("Clean and Publish...");
ImageDescriptor cleanAndPublishImageDesc = new DecorationOverlayIcon(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_PUBLISH).createImage(), ImageDescriptor.createFromFile(SharedImages.class, "refresh.gif"), IDecoration.BOTTOM_RIGHT);
cleanAction.setImageDescriptor(cleanAndPublishImageDesc);
cleanAction.setId("org.apache.sling.ide.eclipse.ui.actions.CleanPublishAction");
publishAction = new Action("Publish", IAction.AS_PUSH_BUTTON) {
public void run() {
if (server == null) {
MessageDialog.openInformation(view.getSite().getShell(), "No server selected", "A server must be selected");
return;
}
IAdaptable info = new IAdaptable() {
public Object getAdapter(Class adapter) {
if (Shell.class.equals(adapter))
return view.getSite().getShell();
if (String.class.equals(adapter))
return "user";
return null;
}
};
server.publish(IServer.PUBLISH_INCREMENTAL, modules, info, null);
}
};
publishAction.setText("Publish");
publishAction.setToolTipText("Publish");
publishAction.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_PUBLISH));
publishAction.setId("org.apache.sling.ide.eclipse.ui.actions.PublishAction");
cleanAction.setEnabled(false);
publishAction.setEnabled(false);
cleanActionContributionItem = new ActionContributionItem(cleanAction);
publishActionContributionItem = new ActionContributionItem(publishAction);
appendedToolbarActionContributionItems.add(publishActionContributionItem);
appendedToolbarActionContributionItems.add(cleanActionContributionItem);
}
use of org.eclipse.jface.dialogs.MessageDialog in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method performSaveAs.
/**
* This implementation asks the user for the workspace path of a file resource and saves the document there.
*
* @param progressMonitor the progress monitor to be used
* @since 3.2
*/
@Override
protected void performSaveAs(IProgressMonitor progressMonitor) {
Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
final IEditorInput input = getEditorInput();
IDocumentProvider provider = getDocumentProvider();
final IEditorInput newInput;
if (input instanceof IURIEditorInput && !(input instanceof IFileEditorInput)) {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
IPath oldPath = URIUtil.toPath(((IURIEditorInput) input).getURI());
if (oldPath != null && !oldPath.isEmpty()) {
dialog.setFileName(oldPath.lastSegment());
dialog.setFilterPath(oldPath.removeLastSegments(1).toOSString());
}
String path = dialog.open();
if (path == null) {
if (progressMonitor != null)
progressMonitor.setCanceled(true);
return;
}
// Check whether file exists and if so, confirm overwrite
final File localFile = new File(path);
if (localFile.exists()) {
MessageDialog overwriteDialog = new MessageDialog(shell, TextEditorMessages.AbstractDecoratedTextEditor_saveAs_overwrite_title, null, NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_saveAs_overwrite_message, path), MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, // 'No' is the default
1);
if (overwriteDialog.open() != Window.OK) {
if (progressMonitor != null) {
progressMonitor.setCanceled(true);
return;
}
}
}
IFileStore fileStore;
try {
fileStore = EFS.getStore(localFile.toURI());
} catch (CoreException ex) {
EditorsPlugin.log(ex.getStatus());
String title = TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_title;
String msg = NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_message, ex.getMessage());
MessageDialog.openError(shell, title, msg);
return;
}
IFile file = getWorkspaceFile(fileStore);
if (file != null)
newInput = new FileEditorInput(file);
else
newInput = new FileStoreEditorInput(fileStore);
} else {
SaveAsDialog dialog = new SaveAsDialog(shell);
IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null;
if (original != null)
dialog.setOriginalFile(original);
else
dialog.setOriginalName(input.getName());
dialog.create();
if (provider.isDeleted(input) && original != null) {
String message = NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_warning_saveAs_deleted, original.getName());
dialog.setErrorMessage(null);
dialog.setMessage(message, IMessageProvider.WARNING);
}
if (dialog.open() == Window.CANCEL) {
if (progressMonitor != null)
progressMonitor.setCanceled(true);
return;
}
IPath filePath = dialog.getResult();
if (filePath == null) {
if (progressMonitor != null)
progressMonitor.setCanceled(true);
return;
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFile file = workspace.getRoot().getFile(filePath);
newInput = new FileEditorInput(file);
}
if (provider == null) {
// editor has programmatically been closed while the dialog was open
return;
}
boolean success = false;
try {
provider.aboutToChange(newInput);
provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true);
success = true;
} catch (CoreException x) {
final IStatus status = x.getStatus();
if (status == null || status.getSeverity() != IStatus.CANCEL) {
String title = TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_title;
String msg = NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_error_saveAs_message, x.getMessage());
MessageDialog.openError(shell, title, msg);
}
} finally {
provider.changed(newInput);
if (success)
setInput(newInput);
}
if (progressMonitor != null)
progressMonitor.setCanceled(!success);
}
Aggregations