Search in sources :

Example 91 with MessageDialog

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();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 92 with MessageDialog

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();
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IViewPart(org.eclipse.ui.IViewPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExternalEventLaunchShortcut(com.centurylink.mdw.plugin.launch.ExternalEventLaunchShortcut) AdapterActivity(com.centurylink.mdw.plugin.designer.model.Activity.AdapterActivity) EvaluatorActivity(com.centurylink.mdw.plugin.designer.model.Activity.EvaluatorActivity) StartActivity(com.centurylink.mdw.plugin.designer.model.Activity.StartActivity) Activity(com.centurylink.mdw.plugin.designer.model.Activity) ActivityLaunchShortcut(com.centurylink.mdw.plugin.launch.ActivityLaunchShortcut) TemplateRunDialog(com.centurylink.mdw.plugin.designer.dialogs.TemplateRunDialog) SearchResultsPage(com.centurylink.mdw.plugin.search.SearchResultsPage) Page(com.centurylink.mdw.plugin.designer.model.Page) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Template(com.centurylink.mdw.plugin.designer.model.Template) TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) ProcessLaunchShortcut(com.centurylink.mdw.plugin.launch.ProcessLaunchShortcut) ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) PartInitException(org.eclipse.ui.PartInitException) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) IProject(org.eclipse.core.resources.IProject) ServerRunner(com.centurylink.mdw.plugin.server.ServerRunner) ProcessLaunchView(com.centurylink.mdw.plugin.designer.views.ProcessLaunchView) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 93 with MessageDialog

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);
    }
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Example 94 with MessageDialog

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);
    }
}
Also used : DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Shell(org.eclipse.swt.widgets.Shell) RegularExpressionImpl(org.talend.dataquality.domain.pattern.impl.RegularExpressionImpl) PatternComponent(org.talend.dataquality.domain.pattern.PatternComponent) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 95 with MessageDialog

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);
        }
    });
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) PasswordConnDlg(net.sourceforge.sqlexplorer.dialogs.PasswordConnDlg)

Aggregations

MessageDialog (org.eclipse.jface.dialogs.MessageDialog)129 Shell (org.eclipse.swt.widgets.Shell)27 CoreException (org.eclipse.core.runtime.CoreException)16 IPath (org.eclipse.core.runtime.IPath)14 File (java.io.File)10 ArrayList (java.util.ArrayList)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 Composite (org.eclipse.swt.widgets.Composite)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Point (org.eclipse.swt.graphics.Point)7 IOException (java.io.IOException)6 IFile (org.eclipse.core.resources.IFile)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 List (java.util.List)5 IStatus (org.eclipse.core.runtime.IStatus)5 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)5 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)5 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)4 Path (org.eclipse.core.runtime.Path)4