Example usage for org.eclipse.jface.dialogs Dialog DLG_IMG_ERROR

List of usage examples for org.eclipse.jface.dialogs Dialog DLG_IMG_ERROR

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog DLG_IMG_ERROR.

Prototype

String DLG_IMG_ERROR

To view the source code for org.eclipse.jface.dialogs Dialog DLG_IMG_ERROR.

Click Source Link

Document

Image registry key for error image (value "dialog_error_image").

Usage

From source file:org.eclipse.team.internal.ccvs.ui.repo.RemoveRootAction.java

License:Open Source License

public void run() {
    final ICVSRepositoryLocation[] roots = getSelectedRemoteRoots();
    if (roots.length == 0)
        return;/*from  www  .ja  va2s  .c o m*/
    final boolean[] proceed = new boolean[1];
    shell.getDisplay().syncExec(new Runnable() {
        public void run() {
            String message;
            if (roots.length == 1) {
                message = NLS.bind(CVSUIMessages.RemoveRootAction_RepositoryRemovalDialogMessageSingle,
                        roots[0].getLocation(true));
            } else {
                message = NLS.bind(CVSUIMessages.RemoveRootAction_RepositoryRemovalDialogMessageMultiple,
                        new Integer(roots.length));
            }
            proceed[0] = MessageDialog.openQuestion(shell,
                    CVSUIMessages.RemoveRootAction_RepositoryRemovalDialogTitle, message);
        }
    });
    if (!proceed[0]) {
        return;
    }
    for (int i = 0; i < roots.length; i++) {
        final ICVSRepositoryLocation root = roots[i];
        try {
            // Check if any projects are shared with the repository
            IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
            final ArrayList shared = new ArrayList();
            for (int j = 0; j < projects.length; j++) {
                RepositoryProvider teamProvider = RepositoryProvider.getProvider(projects[j],
                        CVSProviderPlugin.getTypeId());
                if (teamProvider != null) {
                    CVSTeamProvider cvsProvider = (CVSTeamProvider) teamProvider;
                    if (cvsProvider.getCVSWorkspaceRoot().getRemoteLocation().equals(roots[i])) {
                        shared.add(projects[j]);
                    }
                }
            }

            // This will notify the RepositoryManager of the removal
            if (!shared.isEmpty()) {
                final String location = roots[i].getLocation(true);
                shell.getDisplay().syncExec(new Runnable() {
                    public void run() {
                        DetailsDialogWithProjects dialog = new DetailsDialogWithProjects(shell,
                                CVSUIMessages.RemoteRootAction_Unable_to_Discard_Location_1,
                                NLS.bind(
                                        CVSUIMessages.RemoteRootAction_Projects_in_the_local_workspace_are_shared_with__2,
                                        new String[] { location }),
                                CVSUIMessages.RemoteRootAction_The_projects_that_are_shared_with_the_above_repository_are__4,
                                (IProject[]) shared.toArray(new IProject[shared.size()]), false,
                                Dialog.DLG_IMG_ERROR);
                        dialog.open();
                    }
                });
            } else {
                IProgressService manager = PlatformUI.getWorkbench().getProgressService();
                try {
                    manager.busyCursorWhile(new IRunnableWithProgress() {
                        public void run(IProgressMonitor monitor)
                                throws InvocationTargetException, InterruptedException {
                            final ISchedulingRule rule = new RepositoryLocationSchedulingRule(root);
                            try {
                                Job.getJobManager().beginRule(rule, monitor);
                                view.getContentProvider().cancelJobs(root);
                                KnownRepositories.getInstance().disposeRepository(root);
                            } finally {
                                Job.getJobManager().endRule(rule);
                            }

                        }
                    });
                } catch (InvocationTargetException e) {
                    throw CVSException.wrapException(e);
                } catch (InterruptedException e) {
                    // Canceled
                    return;
                }
            }
        } catch (CVSException e) {
            CVSUIPlugin.openError(view.getShell(), null, null, e, CVSUIPlugin.PERFORM_SYNC_EXEC
                    | CVSUIPlugin.LOG_TEAM_EXCEPTIONS | CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS);
        }
    }
}

From source file:raptor.swt.RaptorImageRegistry.java

License:BSD License

/**
 * Returns the image associated with the given key in this registry, or
 * <code>null</code> if none.
 * //from  w  w  w .  j a  v  a 2 s  .c om
 * @param key
 *            the key
 * @return the image, or <code>null</code> if none
 */
@SuppressWarnings({ "deprecation" })
public Image get(String key) {

    // can be null
    if (key == null) {
        return null;
    }

    if (display != null) {
        /**
         * NOTE, for backwards compatibility the following images are
         * supported here, they should never be disposed, hence we
         * explicitly return them rather then registering images that SWT
         * will dispose.
         * 
         * Applications should go direclty to SWT for these icons.
         * 
         * @see Display.getSystemIcon(int ID)
         */
        int swtKey = -1;
        if (key.equals(Dialog.DLG_IMG_INFO)) {
            swtKey = SWT.ICON_INFORMATION;
        }
        if (key.equals(Dialog.DLG_IMG_QUESTION)) {
            swtKey = SWT.ICON_QUESTION;
        }
        if (key.equals(Dialog.DLG_IMG_WARNING)) {
            swtKey = SWT.ICON_WARNING;
        }
        if (key.equals(Dialog.DLG_IMG_ERROR)) {
            swtKey = SWT.ICON_ERROR;
        }
        // if we actually just want to return an SWT image do so without
        // looking in the registry
        if (swtKey != -1) {
            final Image[] image = new Image[1];
            final int id = swtKey;
            display.syncExec(new RaptorRunnable() {
                @Override
                public void execute() {
                    image[0] = display.getSystemImage(id);
                }
            });
            return image[0];
        }
    }

    Entry entry = getEntry(key);
    if (entry == null) {
        return null;
    }

    if (entry.image == null) {
        entry.image = manager.createImageWithDefault(entry.descriptor);
    }

    return entry.image;
}