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.sap.dirigible.ide.jgit.command.PullCommandHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final ISelection selection = HandlerUtil.getActiveMenuSelection(event);
    if (selection.isEmpty()) {
        logger.warn(NO_PROJECT_IS_SELECTED_FOR_PULL);
        StatusLineManagerUtil.setWarningMessage(NO_PROJECT_IS_SELECTED_FOR_PULL);
        MessageDialog.openWarning(null, NO_PROJECT_IS_SELECTED_FOR_PULL, PLEASE_SELECT_ONE);
        return null;
    }//from w  w  w.j a va 2 s  .  co m
    final IProject[] projects = CommandHandlerUtils.getProjects(selection, logger);
    if (projects.length == 0) {
        logger.warn(NO_PROJECT_IS_SELECTED_FOR_PULL);
        StatusLineManagerUtil.setWarningMessage(NO_PROJECT_IS_SELECTED_FOR_PULL);
        MessageDialog.openWarning(null, NO_PROJECT_IS_SELECTED_FOR_PULL, PLEASE_SELECT_ONE);
        return null;
    } else if (projects.length > 1) {
        logger.warn(ONLY_ONE_PROJECT_CAN_BE_PULLEDT_AT_A_TIME);
        StatusLineManagerUtil.setWarningMessage(ONLY_ONE_PROJECT_CAN_BE_PULLEDT_AT_A_TIME);
        MessageDialog.openWarning(null, ONLY_ONE_PROJECT_CAN_BE_PULLEDT_AT_A_TIME, PLEASE_SELECT_ONE);
        return null;
    }

    final IProject selectedProject = projects[0];

    DefaultProgressMonitor monitor = new DefaultProgressMonitor();
    monitor.beginTask(TASK_PULLING_FROM_REMOTE_REPOSITORY, IProgressMonitor.UNKNOWN);

    pullProjectFromGitRepository(selectedProject);

    monitor.done();
    return null;
}

From source file:com.sap.dirigible.ide.jgit.command.PushCommandHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final ISelection selection = HandlerUtil.getActiveMenuSelection(event);
    if (selection.isEmpty()) {
        logger.warn(NO_PROJECT_IS_SELECTED_FOR_PUSH);
        StatusLineManagerUtil.setWarningMessage(NO_PROJECT_IS_SELECTED_FOR_PUSH);
        MessageDialog.openWarning(null, NO_PROJECT_IS_SELECTED_FOR_PUSH, PLEASE_SELECT_ONE);
        return null;
    }//from ww w  .  j a  va2s. co  m
    final IProject[] projects = CommandHandlerUtils.getProjects(selection, logger);
    if (projects.length == 0) {
        logger.warn(NO_PROJECT_IS_SELECTED_FOR_PUSH);
        StatusLineManagerUtil.setWarningMessage(NO_PROJECT_IS_SELECTED_FOR_PUSH);
        MessageDialog.openWarning(null, NO_PROJECT_IS_SELECTED_FOR_PUSH, PLEASE_SELECT_ONE);
        return null;
    } else if (projects.length > 1) {
        logger.warn(ONLY_ONE_PROJECT_CAN_BE_PUSHED_AT_A_TIME);
        StatusLineManagerUtil.setWarningMessage(ONLY_ONE_PROJECT_CAN_BE_PUSHED_AT_A_TIME);
        MessageDialog.openWarning(null, ONLY_ONE_PROJECT_CAN_BE_PUSHED_AT_A_TIME, PLEASE_SELECT_ONE);
        return null;
    }

    final IProject selectedProject = projects[0];

    DefaultProgressMonitor monitor = new DefaultProgressMonitor();
    monitor.beginTask(TASK_PUSHING_TO_REMOTE_REPOSITORY, IProgressMonitor.UNKNOWN);

    final Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    PushCommandDialog pushCommandDialog = new PushCommandDialog(parent);
    switch (pushCommandDialog.open()) {
    case Window.OK:
        final String commitMessage = pushCommandDialog.getCommitMessage();
        final String username = pushCommandDialog.getUsername();
        final String password = pushCommandDialog.getPassword();
        final String email = pushCommandDialog.getEmail();
        pushProjectToGitRepository(selectedProject, commitMessage, username, email, password);
        break;
    }

    monitor.done();
    return null;
}

From source file:com.sap.dirigible.ide.jgit.command.PushCommandHandler.java

License:Open Source License

private void pushProjectToGitRepository(final IProject selectedProject, final String commitMessage,
        final String username, final String email, final String password) {

    final String errorMessage = String.format(WHILE_PUSHING_PROJECT_ERROR_OCCURED, selectedProject.getName());
    GitProjectProperties gitProperties = null;
    try {/*from  www.j  a  va2 s.  c  om*/
        gitProperties = GitFileUtils.getGitPropertiesForProject(selectedProject,
                RemoteResourcesPlugin.getUserName());
    } catch (IOException e) {
        MessageDialog.openError(null, THIS_IS_NOT_A_GIT_PROJECT, errorMessage);
        return;
    }
    File tempGitDirectory = null;
    try {
        String gitRepositoryURI = gitProperties.getURL();
        String repositoryName = gitRepositoryURI.substring(gitRepositoryURI.lastIndexOf(SLASH) + 1,
                gitRepositoryURI.lastIndexOf(DOT_GIT));
        tempGitDirectory = GitFileUtils
                .createTempDirectory(JGitConnector.TEMP_DIRECTORY_PREFIX + repositoryName);
        JGitConnector.cloneRepository(tempGitDirectory, gitRepositoryURI, username, password);

        Repository repository = JGitConnector.getRepository(tempGitDirectory.toString());
        JGitConnector jgit = new JGitConnector(repository);
        String lastSHA = gitProperties.getSHA();

        final String changesBranch = CHANGES_BRANCH + RemoteResourcesPlugin.getUserName();
        jgit.checkout(lastSHA);
        jgit.createBranch(changesBranch, lastSHA);
        jgit.checkout(changesBranch);

        GitFileUtils.deleteProjectFolderFromDirectory(tempGitDirectory, selectedProject.getName());
        GitFileUtils.copyProjectToDirectory(selectedProject, tempGitDirectory);

        jgit.add(selectedProject.getName());
        jgit.commit(commitMessage, username, email, true);
        jgit.pull();
        int numberOfConflictingFiles = jgit.status().getConflicting().size();
        if (numberOfConflictingFiles == 0) {
            jgit.checkout(MASTER);
            jgit.rebase(changesBranch);
            jgit.push(username, password);

            String dirigibleUser = RemoteResourcesPlugin.getUserName();

            GitFileUtils.deleteDGBRepositoryProject(selectedProject, dirigibleUser);

            Workspace workspace = (Workspace) RemoteResourcesPlugin.getWorkspace();
            IRepository dirigibleRepository = workspace.getRepository();

            String workspacePath = String.format(GitProjectProperties.DB_DIRIGIBLE_USERS_S_WORKSPACE,
                    dirigibleUser);

            String newLastSHA = jgit.getLastSHAForBranch(MASTER);
            gitProperties.setSHA(newLastSHA);

            GitFileUtils.importProject(tempGitDirectory, dirigibleRepository, workspacePath, dirigibleUser,
                    gitProperties);

            refreshWorkspace();
            StatusLineManagerUtil.setInfoMessage(
                    String.format(PROJECT_HAS_BEEN_PUSHED_TO_REMOTE_REPOSITORY, selectedProject.getName()));
        } else {
            jgit.hardReset();
            jgit.push(username, password);
            String statusLineMessage = String.format(PROJECT_HAS_D_CONFILCTING_FILES, numberOfConflictingFiles);
            StatusLineManagerUtil.setWarningMessage(statusLineMessage);
            String message = String.format(
                    PROJECT_HAS_D_CONFILCTING_FILES + PUSHED_TO_REMOTE_BRANCH_S
                            + PLEASE_MERGE_TO_MASTER_AND_THEN_CONTINUE_WORKING_ON_PROJECT,
                    numberOfConflictingFiles, changesBranch);
            MessageDialog.openWarning(null, CONFLICTING_FILES, message);
        }
    } catch (IOException e) {
        logger.error(errorMessage, e);
        MessageDialog.openError(null, ERROR_DURING_PUSH, errorMessage);
    } catch (CoreException e) {
        logger.error(errorMessage, e);
        MessageDialog.openError(null, ERROR_DURING_PUSH, errorMessage);
    } catch (InvalidRemoteException e) {
        logger.error(errorMessage, e);
        MessageDialog.openError(null, ERROR_DURING_PUSH, errorMessage + "\n" + e.getMessage()); //$NON-NLS-1$
    } catch (TransportException e) {
        logger.error(errorMessage, e);
        Throwable rootCause = e.getCause();
        if (rootCause != null) {
            rootCause = rootCause.getCause();
            if (rootCause instanceof UnknownHostException) {
                MessageDialog.openError(null, errorMessage, PLEASE_CHECK_IF_PROXY_SETTINGS_ARE_SET_PROPERLY);
            } else {
                MessageDialog.openError(null, errorMessage,
                        e.getCause().getMessage() + INCORRECT_USERNAME_AND_OR_PASSWORD_OR_GIT_REPOSITORY_URI);
            }
        }
    } catch (GitAPIException e) {
        logger.error(errorMessage, e);
        MessageDialog.openError(null, ERROR_DURING_PUSH, errorMessage);
    } finally {
        GitFileUtils.deleteDirectory(tempGitDirectory);
    }
}

From source file:com.sap.dirigible.ide.jgit.command.ResetCommandHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final ISelection selection = HandlerUtil.getActiveMenuSelection(event);
    final IProject[] projects = CommandHandlerUtils.getProjects(selection, logger);

    if (projects.length == 0) {
        logger.warn(NO_PROJECT_IS_SELECTED_FOR_HARD_RESET);
        StatusLineManagerUtil.setWarningMessage(NO_PROJECT_IS_SELECTED_FOR_HARD_RESET);
        MessageDialog.openWarning(null, NO_PROJECT_IS_SELECTED_FOR_HARD_RESET, PLEASE_SELECT_ONE);
        return null;
    } else if (projects.length > 1) {
        logger.warn(ONLY_ONE_PROJECT_CAN_BE_HARD_RESETED_AT_A_TIME);
        StatusLineManagerUtil.setWarningMessage(ONLY_ONE_PROJECT_CAN_BE_HARD_RESETED_AT_A_TIME);
        MessageDialog.openWarning(null, ONLY_ONE_PROJECT_CAN_BE_HARD_RESETED_AT_A_TIME, PLEASE_SELECT_ONE);
        return null;
    }/*from  ww w .jav  a 2 s  .co  m*/

    IProject project = projects[0];
    final Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    String message = String.format(DO_YOU_REALLY_WANT_TO_HARD_RESET_PROJECT_S, project.getName());

    DefaultProgressMonitor monitor = new DefaultProgressMonitor();
    monitor.beginTask(TASK_RESETING_PROJECT, IProgressMonitor.UNKNOWN);

    boolean confirmed = MessageDialog.openConfirm(parent, HARD_RESET, message);
    if (confirmed) {
        hardReset(project);
    }

    monitor.done();
    return null;
}

From source file:com.sap.dirigible.ide.jgit.command.ShareCommandHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    final ISelection selection = HandlerUtil.getActiveMenuSelection(event);
    final IProject[] projects = CommandHandlerUtils.getProjects(selection, logger);

    if (projects.length == 0) {
        logger.warn(NO_PROJECT_IS_SELECTED_FOR_SHARE);
        StatusLineManagerUtil.setWarningMessage(NO_PROJECT_IS_SELECTED_FOR_SHARE);
        MessageDialog.openWarning(null, NO_PROJECT_IS_SELECTED_FOR_SHARE, PLEASE_SELECT_ONE);
        return null;
    } else if (projects.length > 1) {
        logger.warn(ONLY_ONE_PROJECT_CAN_BE_SHARED_AT_A_TIME);
        StatusLineManagerUtil.setWarningMessage(ONLY_ONE_PROJECT_CAN_BE_SHARED_AT_A_TIME);
        MessageDialog.openWarning(null, ONLY_ONE_PROJECT_CAN_BE_SHARED_AT_A_TIME, PLEASE_SELECT_ONE);
        return null;
    }/*  w ww . ja  v a  2  s .c  o  m*/

    DefaultProgressMonitor monitor = new DefaultProgressMonitor();
    monitor.beginTask(TASK_SHARING_PROJECT, IProgressMonitor.UNKNOWN);

    ShareCommandDialog shareCommandDialog = new ShareCommandDialog(parent);
    switch (shareCommandDialog.open()) {
    case Window.OK:
        String commitMessage = shareCommandDialog.getCommitMessage();
        String repositoryURI = shareCommandDialog.getRepositoryURI();
        String username = shareCommandDialog.getUsername();
        String email = shareCommandDialog.getEmail();
        String password = shareCommandDialog.getPassword();

        shareToGitRepository(projects[0], commitMessage, username, email, password, repositoryURI);
        break;
    }
    monitor.done();

    return null;
}

From source file:com.sap.dirigible.ide.repository.ui.command.DeleteHandler.java

License:Open Source License

private void execute(SortedSet<IEntity> resources) {
    if (resources.size() == 0) {
        return;/*from w  ww  . ja  va  2  s  .  c  om*/
    }
    if (!confirmDelete(resources.size())) {
        return;
    }
    Throwable throwable = null;
    for (IEntity resource : resources) {
        try {
            resource.delete();
        } catch (IOException ex) {
            if (throwable == null) {
                throwable = ex;
            }
        }
    }
    if (throwable != null) {
        MessageDialog.openWarning(null, DELETE_ERROR, SOME_OR_ALL_OF_THE_FILES_COULD_NOT_BE_DELETED);
    }
}

From source file:com.sap.dirigible.ide.repository.ui.command.PasteHandler.java

License:Open Source License

protected void execute(ExecutionEvent event, SortedSet<IEntity> resources) {
    if (resources.size() == 0) {
        return;//from   ww  w.  ja va  2 s  . com
    }

    IRepository repository = RepositoryFacade.getInstance().getRepository();

    String targetReposiotryPath = resources.first().getPath().toString();

    Clipboard clipboard = Clipboard.getInstance();

    String command = clipboard.getCommand();

    Throwable throwable = null;
    if (CUT.equals(command) || COPY.equals(command)) {

        for (Iterator<?> iterator = clipboard.iterator(); iterator.hasNext();) {
            IEntity resource = (IEntity) iterator.next();
            String sourceRepositoryPath = resource.getPath().toString();
            try {
                byte[] data = repository.exportZip(sourceRepositoryPath, true);
                repository.importZip(data, targetReposiotryPath);
            } catch (IOException e) {
                if (throwable == null) {
                    throwable = e;
                }
            }
            if (CUT.equals(command)) {
                try {
                    resource.delete();
                } catch (IOException e) {
                    if (throwable == null) {
                        throwable = e;
                    }
                }
            }
        }
    }

    if (throwable != null) {
        MessageDialog.openWarning(null, PASTE_ERROR, SOME_OR_ALL_OF_THE_FILES_COULD_NOT_BE_PASTED);
    }

    RefreshHandler.refreshActivePart(event);

}

From source file:com.sap.dirigible.ide.workspace.ui.commands.DeleteHandler.java

License:Open Source License

private void execute(SortedSet<IResource> resources) {
    if (resources.size() == 0) {
        return;/* www  .  j a  va 2  s  .  c  o  m*/
    }
    if (!confirmDelete(resources.size())) {
        return;
    }
    Throwable throwable = null;
    for (IResource resource : resources) {
        try {
            resource.delete(false, null);
            closeFileInEditor(resource.getName());
        } catch (CoreException ex) {
            if (throwable == null) {
                throwable = ex;
            }
        }
    }
    if (throwable != null) {
        MessageDialog.openWarning(null, DELETE_ERROR, SOME_OR_ALL_OF_THE_FILES_COULD_NOT_BE_DELETED);
    }
}

From source file:com.sap.dirigible.ide.workspace.ui.commands.PasteHandler.java

License:Open Source License

protected void execute(ExecutionEvent event, SortedSet<IResource> resources) {
    if (resources.size() == 0) {
        return;/*from ww w.  j  a va2  s .c  o  m*/
    }

    IRepository repository = RepositoryFacade.getInstance().getRepository();

    IResource targetContainer = resources.first();
    if (targetContainer instanceof IContainer) {
        String targetReposiotryPath = resources.first().getRawLocation().toString();

        Clipboard clipboard = Clipboard.getInstance();

        String command = clipboard.getCommand();

        Throwable throwable = null;
        if (CUT.equals(command) || COPY.equals(command)) {

            for (Iterator<?> iterator = clipboard.iterator(); iterator.hasNext();) {
                IResource resource = (IResource) iterator.next();
                String sourceRepositoryPath = resource.getRawLocation().toString();
                try {
                    String resourceName = resource.getName();
                    ICollection collection = repository.getCollection(targetReposiotryPath);
                    if (collection.exists()) {

                        if (resource instanceof IContainer) {

                            String localCollectionName = resourceName;
                            int i = 1;
                            while (collection.getCollectionsNames().contains(localCollectionName)) {
                                localCollectionName = resourceName + i++;
                            }
                            byte[] data = repository.exportZip(sourceRepositoryPath, false);
                            repository.importZip(data, targetReposiotryPath + "/" + localCollectionName); //$NON-NLS-1$
                        } else if (resource instanceof IFile) {
                            String localResourceName = resourceName;
                            if (collection.getResourcesNames().contains(resourceName)) {
                                int i = 1;
                                while (collection.getResourcesNames().contains(localResourceName)) {
                                    localResourceName = resourceName + i++;
                                }
                            }
                            com.sap.dirigible.repository.api.IResource sourceResource = repository
                                    .getResource(sourceRepositoryPath);
                            repository.createResource(targetReposiotryPath + "/" + localResourceName, //$NON-NLS-1$
                                    sourceResource.getContent(), sourceResource.isBinary(),
                                    sourceResource.getContentType());
                        }
                    }
                } catch (IOException e) {
                    if (throwable == null) {
                        throwable = e;
                    }
                }
                if (CUT.equals(command)) {
                    try {
                        resource.delete(false, null);
                    } catch (CoreException e) {
                        if (throwable == null) {
                            throwable = e;
                        }
                    }
                }
            }
        }

        if (throwable != null) {
            MessageDialog.openWarning(null, PASTE_ERROR, SOME_OR_ALL_OF_THE_FILES_COULD_NOT_BE_PASTED);
        }

        RefreshHandler.refreshActivePart(event);
    } else {
        MessageDialog.openWarning(null, PASTE_ERROR, SELECT_TARGET_FOLDER);
    }
}

From source file:com.siteview.mde.internal.ui.editor.actions.OpenSchemaAction.java

License:Open Source License

/**
 * @param fullPointID/*from  w w  w.  ja v a2  s . co  m*/
 */
private void displayErrorDialog() {
    String title = MDEUIMessages.OpenSchemaAction_titleExtensionPointSchema;
    String message = NLS.bind(MDEUIMessages.OpenSchemaAction_errorMsgSchemaNotFound, fFullPointID);
    MessageDialog.openWarning(MDEPlugin.getActiveWorkbenchShell(), title, message);
}