use of org.eclipse.jface.dialogs.MessageDialog in project jbosstools-openshift by jbosstools.
the class AdvancedConnectionEditor method discoverRegistryPressed.
private void discoverRegistryPressed(Shell shell) {
IConnection tmp = pageModel.createConnection();
IStatus ret = RegistryProviderModel.getDefault().getRegistryURL(tmp);
String oldVal = (String) registryURLObservable.getValue();
String newVal = ret.getMessage();
if (ret != null && ret.isOK()) {
// If they're equal, do nothing
if (!eq(oldVal, newVal)) {
// Verify with user
String title = "Overwrite registry URL?";
String msg = "Are you sure you want to change the registry URL from " + oldVal + " to " + newVal + "?";
MessageDialog dialog = new MessageDialog(shell, title, null, msg, MessageDialog.CONFIRM, new String[] { "OK", "Cancel" }, 0);
String old = registryURLObservable.getValue().toString().trim();
if (old.isEmpty() || dialog.open() == IDialogConstants.OK_ID) {
registryURLObservable.setValue(ret.getMessage());
}
}
} else {
String title = "Registry URL not found";
String msg = "No registry provider found for the given connection. If your Openshift connection is backed by a CDK or minishift installation, please ensure the CDK is running.";
ErrorDialog ed = new ErrorDialog(shell, title, msg, ret, IStatus.ERROR | IStatus.WARNING | IStatus.INFO | IStatus.CANCEL);
ed.open();
}
}
use of org.eclipse.jface.dialogs.MessageDialog in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method run.
public void run(Object element) {
if (element instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) element;
IEditorPart editorPart = findOpenEditor(processVersion);
if (editorPart != null && editorPart.isDirty()) {
if (MessageDialog.openQuestion(getShell(), "Process Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
editorPart.doSave(new NullProgressMonitor());
}
if (MdwPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREFS_WEB_BASED_PROCESS_LAUNCH)) {
// web-based process launch
try {
IViewPart viewPart = getPage().showView("mdw.views.designer.process.launch");
if (viewPart != null) {
ProcessLaunchView launchView = (ProcessLaunchView) viewPart;
launchView.setProcess(processVersion);
}
} catch (PartInitException ex) {
PluginMessages.log(ex);
}
} else {
if (editorPart == null) {
// process must be open
open((WorkflowElement) element);
}
ProcessLaunchShortcut launchShortcut = new ProcessLaunchShortcut();
launchShortcut.launch(new StructuredSelection(processVersion), ILaunchManager.RUN_MODE);
}
} else if (element instanceof Activity) {
Activity activity = (Activity) element;
WorkflowProcess processVersion = activity.getProcess();
IEditorPart editorPart = findOpenEditor(processVersion);
if (editorPart != null && editorPart.isDirty()) {
if (MessageDialog.openQuestion(getShell(), "Activity Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
editorPart.doSave(new NullProgressMonitor());
}
ActivityLaunchShortcut launchShortcut = new ActivityLaunchShortcut();
launchShortcut.launch(new StructuredSelection(activity), ILaunchManager.RUN_MODE);
} else if (element instanceof ExternalEvent) {
ExternalEvent externalEvent = (ExternalEvent) element;
ExternalEventLaunchShortcut launchShortcut = new ExternalEventLaunchShortcut();
launchShortcut.launch(new StructuredSelection(externalEvent), ILaunchManager.RUN_MODE);
} else if (element instanceof Template) {
Template template = (Template) element;
IEditorPart editorPart = template.getFileEditor();
if (editorPart != null && editorPart.isDirty()) {
if (MessageDialog.openQuestion(getShell(), "Run Template", "Save template '" + template.getName() + "' before running?"))
editorPart.doSave(new NullProgressMonitor());
}
template.openFile(new NullProgressMonitor());
new TemplateRunDialog(getShell(), template).open();
} else if (element instanceof Page) {
Page page = (Page) element;
IEditorPart editorPart = page.getFileEditor();
if (editorPart != null) {
if (editorPart.isDirty()) {
if (MessageDialog.openQuestion(getShell(), "Run Page", "Save page '" + page.getName() + "' before running?"))
editorPart.doSave(new NullProgressMonitor());
}
}
page.run();
} else if (element instanceof WorkflowProject || element instanceof ServerSettings) {
ServerSettings serverSettings;
if (element instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) element;
if (workflowProject.isRemote())
throw new IllegalArgumentException("Cannot run server for remote projects.");
serverSettings = workflowProject.getServerSettings();
} else {
serverSettings = (ServerSettings) element;
}
if (ServerRunner.isServerRunning()) {
String question = "A server may be running already. Shut down the currently-running server?";
MessageDialog dlg = new MessageDialog(getShell(), "Server Running", null, question, MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Shutdown", "Ignore", "Cancel" }, 0);
int res = dlg.open();
if (res == 0)
new ServerRunner(serverSettings, getShell().getDisplay()).stop();
else if (res == 2)
return;
}
if (serverSettings.getHome() == null && element instanceof WorkflowProject) {
final IProject project = serverSettings.getProject().isCloudProject() ? serverSettings.getProject().getSourceProject() : serverSettings.getProject().getEarProject();
@SuppressWarnings("restriction") org.eclipse.ui.internal.dialogs.PropertyDialog dialog = org.eclipse.ui.internal.dialogs.PropertyDialog.createDialogOn(getShell(), "mdw.workflow.mdwServerConnectionsPropertyPage", project);
if (dialog != null)
dialog.open();
} else {
IPreferenceStore prefStore = MdwPlugin.getDefault().getPreferenceStore();
if (element instanceof WorkflowProject)
prefStore.setValue(PreferenceConstants.PREFS_SERVER_WF_PROJECT, ((WorkflowProject) element).getName());
else
prefStore.setValue(PreferenceConstants.PREFS_RUNNING_SERVER, serverSettings.getServerName());
ServerRunner runner = new ServerRunner(serverSettings, getShell().getDisplay());
if (serverSettings.getProject() != null)
runner.setJavaProject(serverSettings.getProject().getJavaProject());
runner.start();
}
}
}
use of org.eclipse.jface.dialogs.MessageDialog in project tdq-studio-se by Talend.
the class ReloadDatabaseAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
returnCode = new ReturnCode(true);
if (!isSupport()) {
// $NON-NLS-1$
returnCode.setReturnCode(Messages.getString("ReloadDatabaseAction.NotSupportMessage"), false);
return;
}
// MOD TDQ-7528 20130627 yyin: if needCompare=false,no need to popup select compare dialog
if (this.needCompare) {
// popup a dialog to warn the user better do the compare before the reload, and provide two buttons:
// if the user click the compare button, the compare will be executed.
// if the user click the reload button, the reload will continue.
// $NON-NLS-1$
String[] dialogButtonLabels = { Messages.getString("ReloadDatabaseAction.ReloadLabel") };
MessageDialog dialog = new MessageDialog(CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("ReloadDatabaseAction.ReloadLabel"), null, Messages.getString("ReloadDatabaseAction.IsContinue"), 3, dialogButtonLabels, // $NON-NLS-1$ //$NON-NLS-2$
SWT.NONE);
int open = dialog.open();
// when click close, do nothing.
if (open == -1) {
return;
}
// when click compare
// if (open == 0) {
// // go to compare instead of reloading now
// new PopComparisonUIAction(selectedObject, Messages.getString("ReloadDatabaseAction.CompareLabel")).run();//$NON-NLS-1$
// returnCode.setReturnCode(Messages.getString("ReloadDatabaseAction.IsContinue"), false);//$NON-NLS-1$
// return;
// }// ~
}
Connection conn = getConnection();
List<ModelElement> dependencyClients = EObjectHelper.getDependencyClients(conn);
if (!(dependencyClients == null || dependencyClients.isEmpty())) {
int isOk = DeleteModelElementConfirmDialog.showElementImpactConfirmDialog(null, new ModelElement[] { conn }, // $NON-NLS-1$
DefaultMessagesImpl.getString("TOPRepositoryService.dependcyTile"), // $NON-NLS-1$
DefaultMessagesImpl.getString("TOPRepositoryService.dependcyMessage", conn.getLabel()));
if (isOk != Dialog.OK) {
// $NON-NLS-1$
returnCode.setReturnCode("The user canceled the operation!", false);
return;
}
}
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException {
final IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(selectedObject);
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
try {
Connection oldDataProvider = creatComparisonLevel.reloadCurrentLevelElement();
// MOD mzhao 2009-07-13 bug 7454 Impact existing analysis.
// MOD qiongli 2011-9-8,move method 'impactExistingAnalyses(...)' to class WorkbenchUtils
// update the sql explore.
Property property = PropertyHelper.getProperty(oldDataProvider);
if (property != null) {
Item newItem = property.getItem();
if (newItem != null) {
CWMPlugin.getDefault().updateConnetionAliasByName(oldDataProvider, oldDataProvider.getLabel());
}
}
// update the related analyses.
WorkbenchUtils.impactExistingAnalyses(oldDataProvider);
// Update software system.
updateSoftwareSystem(oldDataProvider);
} catch (ReloadCompareException e) {
// $NON-NLS-1$
MessageUI.openError(Messages.getString("ReloadDatabaseAction.Error", e.getMessage()));
log.error(e, e);
returnCode.setReturnCode(e.getMessage(), false);
} catch (PartInitException e) {
log.error(e, e);
returnCode.setReturnCode(e.getMessage(), false);
}
}
});
}
};
try {
ProgressUI.popProgressDialog(op);
CorePlugin.getDefault().refreshDQView(selectedObject);
} catch (InvocationTargetException e) {
// $NON-NLS-1$
MessageUI.openError(Messages.getString("ReloadDatabaseAction.checkConnectionFailured", e.getCause().getMessage()));
log.error(e, e);
} catch (InterruptedException e) {
log.error(e, e);
}
}
use of org.eclipse.jface.dialogs.MessageDialog in project tdq-studio-se by Talend.
the class PatternTestView method savePattern.
/**
* If the pattern is not null, will save it and update the corresponding pattern editor content.
*/
private void savePattern() {
// If the pattern is not null, will update the pattern editor content.
if (pattern != null) {
String expressionLanguage = this.regularExpression.getExpression().getLanguage();
DbmsLanguage dbmsLanguage = this.getDbmsLanguage();
// MOD gdbu 2011-6-13 bug : 21695
if (null != dbmsLanguage) {
dbmsLanguage.setRegularExpressionFunction(getFunctionName());
}
// ~21695
// ~19119
// MOD qiongli 2011-1-7 featrue 16799.
boolean isLanguageMatched = false;
if (isJavaEngine && expressionLanguage.equals(ExecutionLanguage.JAVA.getLiteral()) || dbmsLanguage != null && (dbmsLanguage.getDbmsName().equalsIgnoreCase(expressionLanguage))) {
isLanguageMatched = true;
}
if (!isLanguageMatched) {
String messageInfo = DefaultMessagesImpl.getString("PatternTestView.modifiedTheRegularExpression", expressionLanguage, dbmsLanguage.getDbmsName(), expressionLanguage, expressionLanguage, // $NON-NLS-1$
dbmsLanguage.getDbmsName());
MessageDialog messageDialog = new MessageDialog(new Shell(), // $NON-NLS-1$
DefaultMessagesImpl.getString("PatternTestView.warning"), // $NON-NLS-1$
null, // $NON-NLS-1$
messageInfo, // $NON-NLS-1$
MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
int result = messageDialog.open();
if (result == MessageDialog.OK) {
regularExpression.getExpression().setBody(regularText.getText());
} else {
EList<PatternComponent> components = this.pattern.getComponents();
boolean isContainLanguage = false;
for (int i = 0; i < components.size(); i++) {
RegularExpressionImpl regularExpress = (RegularExpressionImpl) components.get(i);
// expression
if (dbmsLanguage.getDbmsName().equalsIgnoreCase(regularExpress.getExpression().getLanguage())) {
regularExpress.getExpression().setBody(regularText.getText());
isContainLanguage = true;
break;
}
}
// expression.
if (!isContainLanguage) {
RegularExpression newRegularExpress = BooleanExpressionHelper.createRegularExpression(dbmsLanguage.getDbmsName(), regularText.getText());
this.pattern.getComponents().add(newRegularExpress);
}
}
} else {
regularExpression.getExpression().setBody(regularText.getText());
}
EMFUtil.saveSingleResource(pattern.eResource());
editorPage.updatePatternDefinitonSection();
// MessageDialog.openInformation(new Shell(), "Success",
// "Success to save the pattern '" +
// pattern.getName()
// + "'");
saveButton.setEnabled(false);
}
}
use of org.eclipse.jface.dialogs.MessageDialog in project tdq-studio-se by Talend.
the class ConnectionJob method promptForPassword.
/**
* Prompts the user for a new username/password to attempt login with; if the dialog is
* cancelled then this.user is set to null.
* @param message
*/
private void promptForPassword(final String message) {
final Shell shell = SQLExplorerPlugin.getDefault().getSite().getShell();
// Switch to the UI thread to run the password dialog, but run it synchronously so we
// wait for it to complete
shell.getDisplay().syncExec(new Runnable() {
public void run() {
if (message != null) {
String title = Messages.getString("Progress.Connection.Title") + ' ' + alias.getName();
if (user != null && !alias.hasNoUserName())
title += '/' + user.getUserName();
if (alias.hasNoUserName()) {
MessageDialog dlg = new MessageDialog(shell, title, null, Messages.getString("Progress.Connection.ErrorMessage_Part1") + "\n\n" + message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
dlg.open();
cancelled = true;
return;
} else {
MessageDialog dlg = new MessageDialog(shell, title, null, Messages.getString("Progress.Connection.ErrorMessage_Part1") + "\n\n" + message + "\n\n" + Messages.getString("Progress.Connection.ErrorMessage_Part2"), MessageDialog.ERROR, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
boolean retry = dlg.open() == 0;
if (!retry) {
cancelled = true;
return;
}
}
}
Shell shell = Display.getCurrent().getActiveShell();
PasswordConnDlg dlg = new PasswordConnDlg(shell, user.getAlias(), user);
if (dlg.open() != Window.OK) {
cancelled = true;
return;
}
// Create a new user and add it to the alias
User userTmp = new User(dlg.getUserName(), dlg.getPassword());
userTmp.setAutoCommit(dlg.getAutoCommit());
userTmp.setCommitOnClose(dlg.getCommitOnClose());
user = alias.addUser(userTmp);
}
});
}
Aggregations