Example usage for org.eclipse.jface.dialogs MessageDialog openWarning

List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openWarning.

Prototype

public static void openWarning(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard warning dialog.

Usage

From source file:com.mercatis.lighthouse3.ui.environment.editors.pages.AttachedDeploymentsEditorFormPage.java

License:Apache License

public void updateModel() {
    Set<Deployment> removedItems = chooser.getModified(false);
    boolean allDetached = true;
    for (Deployment deployment : removedItems) {
        if (!CommonBaseActivator.getPlugin().getDomainService().isDeploymentPartOfStatusTemplate(carrier,
                deployment)) {/*from   w  ww.j  a v  a 2 s . c  o  m*/
            carrier.detachDeployment(deployment);
        } else {
            allDetached = false;
        }
    }
    if (!allDetached) {
        Shell shell = Display.getCurrent().getActiveShell();
        MessageDialog.openWarning(shell, "Deployments not detached",
                "One or more deployments were not detached because they are part of a status.");
    }

    Set<Deployment> addedItems = chooser.getModified(true);
    for (Deployment deployment : addedItems) {
        carrier.attachDeployment(deployment);
    }

    getEditor().editorDirtyStateChanged();
}

From source file:com.mercatis.lighthouse3.ui.environment.editors.pages.EnvironmentChildEditorFormPage.java

License:Apache License

public void updateModel() {
    Set<Environment> removedItems = chooser.getModified(false);
    boolean allRemoved = true;
    for (Environment environment : removedItems) {
        Set<Deployment> deployments = environment.getDeployments();
        boolean remove = true;
        for (Deployment deployment : deployments) {
            if (CommonBaseActivator.getPlugin().getDomainService()
                    .isDeploymentPartOfStatusTemplate(this.environment, deployment)) {
                remove = false;// w w w.ja v  a 2 s  .  c o m
            }
        }
        if (remove) {
            this.environment.removeSubEntity(environment);
        } else {
            allRemoved = false;
        }
    }
    if (!allRemoved) {
        Shell shell = Display.getCurrent().getActiveShell();
        MessageDialog.openWarning(shell, "Environments not detached",
                "One or more environments were not detached because their deployments are part of a status.");
    }

    Set<Environment> addedItems = chooser.getModified(true);
    for (Environment environment : addedItems) {
        this.environment.addSubEntity(environment);
    }

    getEditor().editorDirtyStateChanged();
}

From source file:com.mercatis.lighthouse3.ui.environment.editors.pages.ProcessTaskChildEditorFormPage.java

License:Apache License

public void updateModel() {
    Set<ProcessTask> removedItems = chooser.getModified(false);
    boolean allRemoved = true;
    for (ProcessTask processTask : removedItems) {
        Set<Deployment> deployments = processTask.getDeployments();
        boolean remove = true;
        for (Deployment deployment : deployments) {
            if (CommonBaseActivator.getPlugin().getDomainService()
                    .isDeploymentPartOfStatusTemplate(this.processTask, deployment)) {
                remove = false;//  w ww.  ja  va  2 s  . com
            }
        }
        if (remove) {
            this.processTask.removeSubEntity(processTask);
        } else {
            allRemoved = false;
        }
    }
    if (!allRemoved) {
        Shell shell = Display.getCurrent().getActiveShell();
        MessageDialog.openWarning(shell, "ProcessTasks not detached",
                "One or more processtasks were not detached because their deployments are part of a status.");
    }

    Set<ProcessTask> addedItems = chooser.getModified(true);
    for (ProcessTask task : addedItems) {
        processTask.addSubEntity(task);
    }

    getEditor().editorDirtyStateChanged();
}

From source file:com.mercatis.lighthouse3.ui.environment.handlers.RemoveDeploymentHandler.java

License:Apache License

public Object execute(ExecutionEvent event) throws ExecutionException {
    preExecution(event);//from  w w w  . j av  a2s  . co m

    boolean selectedDeploymentPartOfStatus = false;
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof TreeSelection) {
        ITreeSelection treeSelection = (ITreeSelection) selection;
        List<TreePath> paths = new ArrayList<TreePath>(Arrays.asList(treeSelection.getPaths()));

        // remove all paths that do not end in a deployment..
        for (Iterator<TreePath> it = paths.iterator(); it.hasNext();) {
            if (!(it.next().getLastSegment() instanceof Deployment)) {
                it.remove();
            }
        }

        // remove all paths where the selected deployment is part of a status..
        for (Iterator<TreePath> it = paths.iterator(); it.hasNext();) {
            TreePath path = it.next();
            Deployment deployment = (Deployment) path.getLastSegment();
            path = path.getParentPath();
            while (path != null) {
                Object element = path.getLastSegment();
                if (element instanceof StatusCarrier) {
                    StatusCarrier carrier = (StatusCarrier) element;
                    StatusRegistry registry = RegistryFactoryServiceUtil.getRegistryFactoryService(
                            StatusRegistryFactoryService.class, deployment.getLighthouseDomain(), this);
                    List<Status> statuus = registry.getStatusForCarrier(carrier);
                    for (Status status : statuus) {
                        if (contextContainsDeployment(status.getOkTemplate(), deployment)) {
                            selectedDeploymentPartOfStatus = true;
                            it.remove();
                            break;
                        }

                        if (contextContainsDeployment(status.getErrorTemplate(), deployment)) {
                            selectedDeploymentPartOfStatus = true;
                            it.remove();
                            break;
                        }
                    }
                }
                path = path.getParentPath();
            }
        }

        // detach remaining deployments..
        for (Iterator<TreePath> it = paths.iterator(); it.hasNext();) {
            TreePath path = it.next();
            Deployment deployment = (Deployment) path.getLastSegment();
            DeploymentCarryingDomainModelEntity<?> carrier = (DeploymentCarryingDomainModelEntity<?>) path
                    .getParentPath().getLastSegment();
            carrier.detachDeployment(deployment);

            if (carrier instanceof Environment) {
                EnvironmentRegistry registry = RegistryFactoryServiceUtil.getRegistryFactoryService(
                        EnvironmentRegistryFactoryService.class, carrier.getLighthouseDomain(), this);
                registry.update((Environment) carrier);
            }
            if (carrier instanceof ProcessTask) {
                ProcessTaskRegistry registry = RegistryFactoryServiceUtil.getRegistryFactoryService(
                        ProcessTaskRegistryFactoryService.class, carrier.getLighthouseDomain(), this);
                registry.update((ProcessTask) carrier);
            }
            containers.add(domainService.getLighthouseDomainByEntity(carrier).getContainerFor(carrier));
        }

        // notify user on deployments that were not detached..
        if (selectedDeploymentPartOfStatus) {
            Shell shell = HandlerUtil.getActiveShell(event);
            MessageDialog.openWarning(shell, "Deployments not detached",
                    "One or more deployments were not detached because they are part of a status.");
        }
    }

    postExecution(event);
    return null;
}

From source file:com.mercatis.lighthouse3.ui.environment.wizards.pages.WizardNewProjectLighthouseConnectionPage.java

License:Apache License

private void createLighthouseLocationGroup(Composite parent) {

    // common layout data
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;

    // lighthouse service group
    Group locationGroup = new Group(parent, SWT.NONE);
    locationGroup.setText("Server settings");
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;/*ww w  .  ja  va 2s.co m*/
    locationGroup.setLayout(layout);
    locationGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // new env registry label
    Label environmentRegistryLabel = new Label(locationGroup, SWT.NONE);
    environmentRegistryLabel.setText("Lighthouse URL");
    environmentRegistryLabel.setFont(parent.getFont());

    // new env registry text field
    lighthouseUrl = new Text(locationGroup, SWT.BORDER);
    lighthouseUrl.setLayoutData(data);
    lighthouseUrl.setFont(parent.getFont());
    lighthouseUrl.addListener(SWT.Modify, modifyListener);
    lighthouseUrl.setFocus();
    lighthouseUrl.setText("http://localhost:8081");

    Button testB = new Button(parent, SWT.PUSH);
    testB.setText("Test Connection");
    testB.setLayoutData(new GridData(SWT.END, SWT.TOP, true, false));
    testB.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            BufferedReader in = null;
            try {
                String txt = lighthouseUrl.getText();
                StringBuilder sb = new StringBuilder(txt);
                if (!txt.endsWith("/"))
                    sb.append('/');
                sb.append("Version");
                URL url = new URL(sb.toString());
                URLConnection conn = url.openConnection();
                in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                String inputLine = in.readLine();
                Pattern p = Pattern.compile("^\\d.\\d.\\d(?:-SNAPSHOT)?$");
                Matcher m = p.matcher(inputLine);
                if (m.matches())
                    MessageDialog.openInformation(getShell(), "Connection Test",
                            "Connection test successful!\n\nLighthouse Server v" + inputLine + " was found.");
                else
                    MessageDialog.openWarning(getShell(), "Connection Test",
                            "Connection test failed!\n\nThere was a reply but it could not be validated.");
            } catch (Exception e1) {
                MessageDialog.openError(getShell(), "Connection Test",
                        "Connection test failed!\n\n" + e1.getMessage());
            } finally {
                if (in != null)
                    try {
                        in.close();
                    } catch (IOException e1) {
                        /* ignore */ }
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            /* ignore */ }
    });
}

From source file:com.mercatis.lighthouse3.ui.operations.ui.wizards.pages.WizardNewLighthouseDomainOperationPage.java

License:Apache License

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    initializeDialogUnits(parent);//from w w w. j  ava2  s  . c  o m

    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;

    Group urlGroup = new Group(composite, SWT.NONE);
    urlGroup.setText("Operations URL");
    GridLayout urlLayout = new GridLayout();
    urlLayout.numColumns = 2;
    urlGroup.setLayout(urlLayout);
    urlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label urlLabel = new Label(urlGroup, SWT.NONE);
    urlLabel.setText("URL:");
    urlLabel.setFont(parent.getFont());

    urlText = new Text(urlGroup, SWT.BORDER);
    urlText.setLayoutData(data);
    urlText.setFont(parent.getFont());
    urlText.setText(urlTextValue != null ? urlTextValue : "http://localhost:8085");
    urlText.addListener(SWT.Modify, modifyListener);
    urlText.setFocus();

    Button testB = new Button(composite, SWT.PUSH);
    testB.setText("Test Connection");
    testB.setLayoutData(new GridData(SWT.END, SWT.TOP, true, false));
    testB.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            BufferedReader in = null;
            try {
                String txt = urlText.getText();
                StringBuilder sb = new StringBuilder(txt);
                if (!txt.endsWith("/"))
                    sb.append('/');
                sb.append("Operation");
                URL url = new URL(sb.toString());
                URLConnection conn = url.openConnection();
                in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                String inputLine = in.readLine();

                Pattern p = Pattern.compile(
                        "^<\\?xml version=\"[\\d\\.]+\"(?: \\w+=\"[\\w\\-]+\")*\\?>(?:<list>(?:<code>\\w+</code>)*</list>)?");
                Matcher m = p.matcher(inputLine);
                if (m.matches())
                    MessageDialog.openInformation(getShell(), "Connection Test", "Connection test successful!");
                else
                    MessageDialog.openWarning(getShell(), "Connection Test",
                            "Connection test failed!\n\nThere was a reply but it could not be validated.");
            } catch (Exception e1) {
                MessageDialog.openError(getShell(), "Connection Test",
                        "Connection test failed!\n\n" + e1.getMessage());
            } finally {
                if (in != null)
                    try {
                        in.close();
                    } catch (IOException e1) {
                        /* ignore */ }
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            /* ignore */ }
    });

    setPageComplete(validatePage());
    // Show description on opening
    setErrorMessage(null);
    setMessage(null);
    setControl(composite);
    Dialog.applyDialogFont(composite);
}

From source file:com.microsoft.azuretools.docker.ui.wizards.publish.AzureSelectDockerWizard.java

License:Open Source License

private static void displayWarningOnCreateDockerContainerDeployTask(Object parent,
        IProgressMonitor progressMonitor, String deploymentName) {
    DefaultLoader.getIdeHelper().invokeAndWait(new Runnable() {
        @Override/*from   w  w w  .j  av a2s .c o m*/
        public void run() {
            Shell shell = PluginUtil.getParentShell();

            if (shell != null) {
                MessageDialog.openWarning(shell, "Stop Publishing to Docker Container",
                        "Canceling the task at this time can leave the Docker virtual machine host in a broken state and it can resut in publishing to fail the next time!");
                AzureDeploymentProgressNotification.notifyProgress(parent, deploymentName, "Error", -1,
                        "Stopped by the user");
                progressMonitor.done();
            }
        }
    });
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.SetWorkingFolderDialog.java

License:Open Source License

@Override
protected void okPressed() {
    localFolder = localFolderField.getText().trim();
    repositoryFolder = repositoryFolderField.getText().trim();

    // Verify we don't already have a mapping for this local path.
    if (localFolderAlreadyMapped()) {
        final WorkspaceSpec spec = new WorkspaceSpec(workspace.getName(), workspace.getOwnerDisplayName());

        final String title = Messages.getString("SetWorkingFolderDialog.ErrorDialogTitle"); //$NON-NLS-1$
        final String messageFormat = Messages.getString("SetWorkingFolderDialog.ErrorDialogTextFormat"); //$NON-NLS-1$
        final String message = MessageFormat.format(messageFormat, spec.toString(), localFolder);
        MessageDialog.openWarning(getShell(), title, message);

        // Don't exit the dialog.
        return;//from  w  w  w.  ja  v a 2s. co  m
    }

    super.okPressed();
}

From source file:com.microsoft.tfs.client.common.ui.framework.helper.MessageBoxHelpers.java

License:Open Source License

public static void warningMessageBox(Shell parent, String dialogTitle, final String message) {
    parent = ShellUtils.getBestParent(parent);
    dialogTitle = sanitizeTitle(dialogTitle);

    MessageDialog.openWarning(parent, dialogTitle, message);
}

From source file:com.microsoft.tfs.client.common.ui.tasks.vc.CheckinTask.java

License:Open Source License

@Override
public IStatus run() {
    // Show the dialog if the caller did not already supply pending changes
    // to check-in.
    if (pendingCheckin == null) {
        final CheckinDialog checkinDialog = new CheckinDialog(getShell(), repository, pendingChanges, comment);

        if (checkinDialog.open() != IDialogConstants.OK_ID) {
            return Status.OK_STATUS;
        }/*from w w w.  j ava 2  s. c  o  m*/

        /*
         * Get the checkin information from the dialog.
         */
        pendingCheckin = checkinDialog.getPendingCheckin();

        /*
         * The dialog did the validation before it allowed OK to close the
         * dialog.
         */
        final ValidationResult validationResult = checkinDialog.getValidationResult();
        Check.notNull(validationResult, "validationResult"); //$NON-NLS-1$
        Check.isTrue(validationResult.getSucceeded(), "validationResult.getSucceeded()"); //$NON-NLS-1$

        /*
         * Build the override information from the validation result.
         */
        if (validationResult.getPolicyOverrideReason() != null
                && validationResult.getPolicyOverrideReason().length() > 0) {
            policyOverrideInfo = new PolicyOverrideInfo(validationResult.getPolicyOverrideReason(),
                    validationResult.getPolicyFailures());
        }
    }

    final CheckinCommand checkinCommand = new CheckinCommand(repository, pendingCheckin, policyOverrideInfo);
    checkinCommand.setAutoResolveConflicts(TFSCommonUIClientPlugin.getDefault().getPreferenceStore()
            .getBoolean(UIPreferenceConstants.AUTO_RESOLVE_CONFLICTS));
    checkinCommand.setQueryConflicts(true);

    /*
     * Make sure to use a command executor that does not raise error dialogs
     * - we need to handle conflicts (IStatus.WARNING) specially.
     *
     * Wrap these standard callbacks with a custom command finished callback
     * to gracefully handle some standard checkin exceptions.
     */
    final ICommandExecutor commandExecutor = getCommandExecutor();
    commandExecutor.setCommandFinishedCallback(new CheckinCommandFinishedCallback());

    boolean retryWithOverride;
    IStatus checkinStatus;

    do {
        retryWithOverride = false;
        checkinStatus = commandExecutor.execute(new ResourceChangingCommand(checkinCommand));

        if (checkinStatus.isOK()) {
            changesetID = checkinCommand.getChangeset();

            if (changesetID == 0) {
                MessageDialog.openWarning(getShell(),
                        Messages.getString("PendingChangesView.NoChangesDialogTitle"), //$NON-NLS-1$
                        Messages.getString("PendingChangesView.ChangeChangesDialogText")); //$NON-NLS-1$
            }

            pendingChangesCleared = true;
            return checkinStatus;
        }

        if (checkinStatus.getException() instanceof GatedCheckinException) {
            // The server rejected the check-in attempt because some of the
            // pending changes affect build definition(s) which have gated
            // check-ins.
            final GatedCheckinException e = (GatedCheckinException) checkinStatus.getException();

            // Strip the owner from the shelveset name
            String shelvesetName;
            try {
                final WorkspaceSpec spec = WorkspaceSpec.parse(e.getShelvesetName(), null);
                shelvesetName = spec.getName();
            } catch (final WorkspaceSpecParseException ex) {
                shelvesetName = e.getShelvesetName();
                log.warn("The shelveset name '" + shelvesetName + "' could not be parsed", e); //$NON-NLS-1$ //$NON-NLS-2$
            }

            // Determine if any changes had a lock.
            boolean allowKeepCheckedOut = true;

            for (final PendingChange pc : pendingCheckin.getPendingChanges().getCheckedPendingChanges()) {
                if (pc.isLock()) {
                    allowKeepCheckedOut = false;
                    break;
                }
            }

            // Display the gated check-in dialog to the user.
            final GatedCheckinDialog dialog = new GatedCheckinDialog(getShell(), shelvesetName,
                    e.getAffectedBuildDefinitionNames(), e.getAffectedBuildDefinitionURIs(),
                    e.getOverridePermission(), allowKeepCheckedOut);

            if (dialog.open() != IDialogConstants.OK_ID) {
                deleteGatedCheckinShelveset(e.getShelvesetName());
                return Status.OK_STATUS;
            }

            if (dialog.getBypassBuild()) {
                // The user chose to override the gated check-in. Attempt to
                // resubmit the check-in with the override property set.
                checkinCommand.setOverrideGatedCheckinOption();
                retryWithOverride = true;
                deleteGatedCheckinShelveset(e.getShelvesetName());
                continue; // retry the checkin
            } else {
                // The user chose to build the changes for the gated
                // check-in. Queue a build for the shelved changes against
                // the selected build definition.
                final IQueueGatedCheckinBuild queueGatedCheckinBuild = getQueueGatedCheckinBuildContributor();

                if (queueGatedCheckinBuild != null) {
                    final String buildDefinitionUri = dialog.getSelectedBuildDefinitionURI();
                    final TFSTeamProjectCollection c = repository.getVersionControlClient().getConnection();
                    final IBuildDefinition buildDefinition = c.getBuildServer()
                            .getBuildDefinition(buildDefinitionUri);

                    if (queueGatedCheckinBuild.queueBuild(getShell(), buildDefinition, buildDefinitionUri,
                            e.getShelvesetName(), e.getCheckinTicket())) {
                        queuedGatedBuild = queueGatedCheckinBuild.getQueuedBuild();

                        if (!dialog.getPreserveLocalChanges()) {
                            // The user chose to undo the local pending
                            // changes after queuing the build.
                            final PendingChange[] checkedPendingChanges = pendingCheckin.getPendingChanges()
                                    .getCheckedPendingChanges();

                            // Create item specs from the pending changes.
                            final ItemSpec[] itemSpecs = new ItemSpec[checkedPendingChanges.length];
                            for (int i = 0; i < checkedPendingChanges.length; i++) {
                                final PendingChange pendingChange = checkedPendingChanges[i];
                                itemSpecs[i] = new ItemSpec(pendingChange.getServerItem(), RecursionType.NONE);
                            }

                            // Undo the local pending changes. The undo task
                            // does not prompt the user for confirmation
                            // when supplying item specs, which is the
                            // desired behavior here.
                            final UndoPendingChangesTask undoTask = new UndoPendingChangesTask(getShell(),
                                    repository, itemSpecs);

                            undoTask.run();
                            pendingChangesCleared = true;
                        }

                        CodeMarkerDispatch.dispatch(CODEMARKER_GATED_CHECKIN_QUEUED);
                    }
                }
                return Status.OK_STATUS;
            }
        } else if (checkinStatus.getException() != null) {
            break;
        }

        if (checkinCommand.allConflictsResolved()) {
            MessageDialog.openInformation(getShell(), Messages.getString("CheckinTask.AllResolvedDialogTitle"), //$NON-NLS-1$
                    Messages.getString("CheckinTask.AllResolvedDialogMessage")); //$NON-NLS-1$
            return Status.OK_STATUS;
        }

        else if (!checkinCommand.hasResolvableConflicts()) {
            ErrorDialog.openError(getShell(), Messages.getString("CheckinTask.ErrorDialogTitle"), //$NON-NLS-1$
                    null, checkinStatus);
            return checkinStatus;
        }

        final ConflictDescription[] conflicts = checkinCommand.getCheckinConflicts();

        final ConflictResolutionTask conflictTask = new ConflictResolutionTask(getShell(), repository,
                conflicts);
        final IStatus conflictStatus = conflictTask.run();

        if (conflictStatus.isOK()) {
            return Status.OK_STATUS;
        }
    } while (retryWithOverride);

    return checkinStatus;
}