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

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

Introduction

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

Prototype

public static boolean openQuestion(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a simple Yes/No question dialog.

Usage

From source file:com.microsoft.tfs.client.common.ui.teambuild.actions.OpenDropFolderAction.java

License:Open Source License

private void downloadDrop(final IBuildDetail build) {
    // Prompt the user for confirmation to download
    final String title = Messages.getString("BuildDropDownload.ConfirmTitle"); //$NON-NLS-1$
    final String prompt = Messages.getString("BuildDropDownload.ConfirmPrompt"); //$NON-NLS-1$

    if (!MessageDialog.openQuestion(getShell(), title, prompt)) {
        return;/*  w  w w  .  j a  va  2 s  .c  om*/
    }

    // Calculate the resource url
    final URL dropURL = TSWAHyperlinkBuilder.getFileContainerURL(build);

    if (dropURL == null) {
        return;
    }

    String dropFileName = Messages.getString("BuildDrop.DownloadFileName"); //$NON-NLS-1$
    final String[] dropLocationParts = build.getDropLocation().split("/"); //$NON-NLS-1$
    if (dropLocationParts != null && dropLocationParts.length == 3) {
        dropFileName = dropLocationParts[2] + Messages.getString("BuildDrop.DownloadFileExtension"); //$NON-NLS-1$
        ;
    }

    // Let the user pick download local path
    final File localTarget = promptForLocation(dropFileName);
    if (localTarget == null) {
        return;
    }

    // Download the drop
    final DownloadBuildDropCommand downloadCommand = new DownloadBuildDropCommand(dropURL, localTarget,
            build.getBuildServer().getConnection());

    UICommandExecutorFactory.newUICommandExecutor(getShell()).execute(downloadCommand);
}

From source file:com.microsoft.tfs.client.common.ui.teambuild.actions.ToggleProtectionAction.java

License:Open Source License

/**
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 *///from  ww  w  .  j ava 2  s .  c om
@Override
public void run(final IAction action) {
    // Set the keep forever status of the selection based on the opposite of
    // the current state of the first build detail in the selection.
    final boolean keepForever = !getSelectedBuildDetail().isKeepForever();

    if (!keepForever) {
        if (!MessageDialog.openQuestion(getShell(),
                Messages.getString("ToggleProtectionAction.ConfirmRemoveLockDialogTitle"), //$NON-NLS-1$
                Messages.getString("ToggleProtectionAction.ConfirmRemoveLockDialogText"))) //$NON-NLS-1$
        {
            action.setChecked(true);
            return;
        }
    }

    final Shell shell = getTargetPart().getSite().getShell();
    final IBuildDetail[] selectedBuildDetails = getSelectedBuildDetails();

    final ToggleProtectionCommand command = new ToggleProtectionCommand(getBuildServer(), selectedBuildDetails,
            keepForever);

    UICommandExecutorFactory.newUICommandExecutor(shell).execute(command);

    BuildHelpers.getBuildManager().fireBuildDetailsChangedEvent(getTargetPart(), selectedBuildDetails);
}

From source file:com.microsoft.tfs.client.common.ui.teambuild.teamexplorer.actions.DeleteBuildDefinitionAction.java

License:Open Source License

@Override
public void doRun(final IAction action) {
    Check.notNull(selectedDefinition, "selectedDefinition"); //$NON-NLS-1$

    final String title = Messages.getString("DeleteBuildDefinitionAction.DeleteBuildDefDialogTitle"); //$NON-NLS-1$
    final String messageFormat = Messages
            .getString("DeleteBuildDefinitionAction.DeleteBuildDefDialogTextFormat"); //$NON-NLS-1$
    final String message = MessageFormat.format(messageFormat, selectedDefinition.getName());

    if (!MessageDialog.openQuestion(getShell(), title, message)) {
        return;/*from w  w  w. j  a v a  2 s  .c o m*/
    }

    final DeleteBuildDefinitionCommand command = new DeleteBuildDefinitionCommand(
            selectedDefinition.getBuildServer(), selectedDefinition);

    final IStatus status = execute(command, false);
    if (status == Status.OK_STATUS) {
        // We should redraw build definitions at this point
        if (BuildExplorer.getInstance() != null && !BuildExplorer.getInstance().isDisposed()) {
            BuildExplorer.getInstance().reloadBuildDefinitions();
        }

        final BuildDefinitionEventArg arg = new BuildDefinitionEventArg(selectedDefinition);
        getContext().getEvents().notifyListener(TeamExplorerEvents.BUILD_DEFINITION_DELETED, arg);
    }
}

From source file:com.microsoft.tfs.client.common.ui.teamexplorer.helpers.PendingChangesHelpers.java

License:Open Source License

public static boolean confirmShelvesetCanBeWritten(final Shell shell, final TFSRepository repository,
        final String shelvesetName) {
    final QueryShelvesetsCommand queryCommand = new QueryShelvesetsCommand(repository.getVersionControlClient(),
            shelvesetName, VersionControlConstants.AUTHENTICATED_USER);

    final IStatus queryStatus = UICommandExecutorFactory.newUICommandExecutor(shell).execute(queryCommand);

    if (!queryStatus.isOK()) {
        return false;
    }//from ww  w . j a  v  a2  s.c o  m

    final Shelveset[] existingShelvesets = queryCommand.getShelvesets();

    if (existingShelvesets != null && existingShelvesets.length > 0) {
        final String title = Messages.getString("ShelveDialog.OverwriteDialogTitle"); //$NON-NLS-1$
        final String messageFormat = Messages.getString("ShelveDialog.OverwriteDialogTextFormat"); //$NON-NLS-1$
        final String message = MessageFormat.format(messageFormat, shelvesetName);

        if (!MessageDialog.openQuestion(shell, title, message)) {
            return false;
        }
    }

    return true;
}

From source file:com.microsoft.tfs.client.common.ui.vcexplorer.findinsce.actions.UndoAction.java

License:Open Source License

@Override
public void run() {
    if (editor == null || editor.getEditorInput() == null) {
        return;/*from  ww  w. j  a v a 2  s  .c  o  m*/
    }

    final FindInSourceControlEditorInput editorInput = editor.getEditorInput();

    final TFSRepository repository = editorInput.getRepository();
    final Map<PendingChange, PendingSet> pendingChangeMap = editor.getSelectedPendingChanges();

    if (pendingChangeMap == null || pendingChangeMap.size() == 0) {
        return;
    }

    /*
     * Build a composite undo command for each pending change. Stop
     * processing only on cancel. If we're undoing a pending change in the
     * local workspace, keep that command so we can query conflicts with it.
     */
    UndoCommand localWorkspaceCommand = null;
    final CommandList undoCommands = new CommandList(Messages.getString("UndoAction.UndoCommandName"), //$NON-NLS-1$
            Messages.getString("UndoAction.UndoCommandError"), //$NON-NLS-1$
            new int[] { IStatus.OK, IStatus.INFO, IStatus.WARNING, IStatus.ERROR });

    for (final Entry<PendingChange, PendingSet> entry : pendingChangeMap.entrySet()) {
        final PendingChange pendingChange = entry.getKey();
        final PendingSet pendingSet = entry.getValue();

        final ItemSpec[] itemSpecs = new ItemSpec[] { new ItemSpec(pendingChange.getServerItem(),
                pendingChange.getItemType() == ItemType.FILE ? RecursionType.NONE : RecursionType.FULL) };

        /*
         * This is the current workspace.
         */
        if (Workspace.matchOwner(pendingSet.getOwnerName(), repository.getWorkspace().getOwnerName())
                && Workspace.matchComputer(pendingSet.getComputer(), repository.getWorkspace().getComputer())
                && Workspace.matchName(pendingSet.getName(), repository.getWorkspace().getName())) {
            localWorkspaceCommand = new UndoCommand(repository, itemSpecs);
            undoCommands.addCommand(localWorkspaceCommand);

            continue;
        }

        /*
         * Load up the workspace cache so that we can use local (on this
         * computer) workspaces that are not the current workspace.
         */
        final Workstation workstation = Workstation
                .getCurrent(repository.getConnection().getPersistenceStoreProvider());

        try {
            final WorkspaceInfo info = workstation.getLocalWorkspaceInfo(repository.getVersionControlClient(),
                    pendingSet.getName(), pendingSet.getOwnerName());

            if (info == null) {
                /*
                 * Warn, fall through to non-local behavior which will not
                 * do a get.
                 */
                log.warn(MessageFormat.format(
                        "Could not find cached workspace with name {0}, will not update disk during undo", //$NON-NLS-1$
                        pendingSet.getName()));
            } else {
                final Workspace workspace = repository.getVersionControlClient().getWorkspace(info);
                undoCommands.addCommand(new UndoOtherPendingChangeCommand(workspace, itemSpecs));
                continue;
            }

        } catch (final MultipleWorkspacesFoundException e) {
            /*
             * Warn, fall through to non-local behavior which will not do a
             * get.
             */
            log.warn(MessageFormat.format(
                    "Multiple workspaces found in workspace cache with name {0}, will not update disk during undo", //$NON-NLS-1$
                    pendingSet.getName()));
        }

        /*
         * Non-local workspace, simply tell VersionControlClient to do the
         * undo, we don't need to worry about GetOperations coming back.
         */
        undoCommands.addCommand(new UndoOtherPendingChangeCommand(repository.getVersionControlClient(),
                pendingSet.getName(), pendingSet.getOwnerName(), itemSpecs));

    }

    /* Prompt for confirmation. */
    final String title, prompt;

    if (pendingChangeMap.entrySet().size() == 1) {
        title = Messages.getString("UndoAction.UndoSingleConfirmTitle"); //$NON-NLS-1$
        prompt = Messages.getString("UndoAction.UndoSingleConfirmPrompt"); //$NON-NLS-1$
    } else {
        title = Messages.getString("UndoAction.UndoMultipleConfirmTitle"); //$NON-NLS-1$
        prompt = Messages.getString("UndoAction.UndoMultipleConfirmPrompt"); //$NON-NLS-1$
    }

    if (!MessageDialog.openQuestion(editor.getSite().getShell(), title, prompt)) {
        return;
    }

    /*
     * Execute all the commands - if we had a pending change in the local
     * workspace and it has conflicts, prompt to resolve.
     */
    UICommandExecutorFactory.newUICommandExecutor(editor.getSite().getShell()).execute(undoCommands);

    if (localWorkspaceCommand != null && localWorkspaceCommand.hasConflicts()) {
        final ConflictDescription[] conflicts = localWorkspaceCommand.getConflictDescriptions();

        final ConflictDialog conflictDialog = new ConflictDialog(editor.getSite().getShell(), repository,
                conflicts);
        conflictDialog.open();
    }

    editor.run();
}

From source file:com.microsoft.tfs.client.common.ui.wit.results.QueryResultsControl.java

License:Open Source License

private void createActions() {
    openAction = new Action() {
        @Override//from  w  w w  . j a  v  a2s .  c  o  m
        public void run() {
            final WorkItem selectedWorkItem = getSelectedWorkItem();
            if (UIQueryUtils.verifyAccessToWorkItem(selectedWorkItem)) {
                WorkItemEditorHelper.openEditor(server, selectedWorkItem);
            }
        }
    };
    openAction.setText(Messages.getString("QueryResultsControl.OpenActionText")); //$NON-NLS-1$

    final List<WorkItemEditorInfo> editors = WorkItemEditorHelper.getWorkItemEditors();
    if (editors != null && editors.size() > 0) {
        int count = 0;
        openWithActions = new OpenWorkItemWithAction[editors.size()];

        for (final WorkItemEditorInfo editor : editors) {
            openWithActions[count++] = new OpenWorkItemWithAction(editor.getDisplayName(),
                    editor.getEditorID()) {
                @Override
                public void run() {
                    final WorkItem selectedWorkItem = getSelectedWorkItem();
                    if (UIQueryUtils.verifyAccessToWorkItem(selectedWorkItem)) {
                        WorkItemEditorHelper.openEditor(server, selectedWorkItem, getEditorID());
                    }
                }
            };
        }
    }

    associateWithPendingChangesAction = new Action() {
        @Override
        public void run() {
            final TFSCommonUIClientPlugin plugin = TFSCommonUIClientPlugin.getDefault();
            plugin.getPendingChangesViewModel().associateWorkItems(getSelectedWorkItems());
        }
    };
    associateWithPendingChangesAction
            .setText(Messages.getString("QueryResultsControl.AssocWithPendingChangeActionText")); //$NON-NLS-1$

    linkExistingWorkItemAction = new Action() {
        @Override
        public void run() {
            final WorkItem selectedWorkItem = getSelectedWorkItem();
            if (UIQueryUtils.verifyAccessToWorkItem(selectedWorkItem)) {
                try {
                    final LinkDialog dialog = new LinkDialog(getShell(), selectedWorkItem,
                            new LinkUIRegistry(server, selectedWorkItem, null), null);

                    if (dialog.open() == IDialogConstants.OK_ID) {
                        selectedWorkItem.open();
                        final Link[] links = dialog.getLinks();
                        for (int i = 0; i < links.length; i++) {
                            selectedWorkItem.getLinks().add(links[i]);
                        }

                        WorkItemEditorHelper.openEditor(server, selectedWorkItem);
                    }
                } catch (final WorkItemLinkValidationException e) {
                    MessageDialog.openError(getShell(),
                            Messages.getString("QueryResultsControl.ErrorDialogTitle"), //$NON-NLS-1$
                            e.getLocalizedMessage());
                }
            }
        }
    };
    linkExistingWorkItemAction.setText(Messages.getString("QueryResultsControl.LinkToExistingActionText")); //$NON-NLS-1$

    destroyAction = new Action() {
        @Override
        public void run() {
            final WorkItem selectedWorkItem = getSelectedWorkItem();
            if (UIQueryUtils.verifyAccessToWorkItem(selectedWorkItem)) {
                final int destroyId = selectedWorkItem.getFields().getID();

                final String messageFormat = Messages
                        .getString("QueryResultsControl.ConfirmDestroyDialogTextFormat"); //$NON-NLS-1$
                final String message = MessageFormat.format(messageFormat, Integer.toString(destroyId));

                if (MessageDialog.openQuestion(getShell(),
                        Messages.getString("QueryResultsControl.DestroyDialogTitle"), //$NON-NLS-1$
                        message)) {
                    final DestroyWorkItemCommand command = new DestroyWorkItemCommand(selectedWorkItem);
                    final ICommandExecutor executor = UICommandExecutorFactory.newUICommandExecutor(getShell());
                    executor.execute(command);
                }
            }
        }
    };
    destroyAction.setText(Messages.getString("QueryResultsControl.DestroyActionText")); //$NON-NLS-1$

    copyUrlAction = new Action() {
        @Override
        public void run() {
            final WorkItem workItem = getSelectedWorkItem();
            final String url = LinkingFacade.getExternalURL(workItem, workItem.getClient().getConnection());
            UIHelpers.copyToClipboard(url);
        }
    };
    copyUrlAction.setText(Messages.getString("QueryResultsControl.CopyUrlActionText")); //$NON-NLS-1$

    copyIdAction = new Action() {
        @Override
        public void run() {
            final WorkItem[] workItems = getSelectedWorkItems();
            final String gitCommitWorkItemsLink = WorkItemEditorHelper.createGitCommitWorkItemsLink(workItems);
            UIHelpers.copyToClipboard(gitCommitWorkItemsLink);
        }
    };
    copyIdAction.setText(Messages.getString("QueryResultsControl.CopyIdActionText")); //$NON-NLS-1$

    copySelectionAction = new Action() {
        @Override
        public void run() {
            QueryResultsControl.this.copySelectionToClipboard();
        }
    };
    copySelectionAction.setText(Messages.getString("QueryResultsControl.CopyResultsToClipActionText")); //$NON-NLS-1$
    copySelectionAction.setImageDescriptor(
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
    copySelectionAction.setActionDefinitionId(CommandIDs.COPY);

    copyAllAction = new Action() {
        @Override
        public void run() {
            QueryResultsControl.this.copyAllToClipboard();
        }
    };
    copyAllAction.setText(Messages.getString("QueryResultsControl.CopyAllToClipActionText")); //$NON-NLS-1$
}

From source file:com.microsoft.tfs.client.eclipse.ui.connectionconflict.EclipseUIConnectionConflictHandler.java

License:Open Source License

private boolean promptForDisconnect() {
    final Shell parentShell = ShellUtils.getWorkbenchShell();

    /* Synchronize for visibility */
    final Object retryLock = new Object();
    final boolean[] retry = new boolean[1];

    UIHelpers.runOnUIThread(false, new Runnable() {
        @Override//ww w  .j  ava 2s  .  c  o m
        public void run() {
            synchronized (retryLock) {
                retry[0] = MessageDialog.openQuestion(parentShell,
                        Messages.getString("EclipseUIConnectionConflictHandler.DisconnectProjectsPromptTitle"), //$NON-NLS-1$
                        Messages.getString(
                                "EclipseUIConnectionConflictHandler.DisconnectProjectsPromptMessage")); //$NON-NLS-1$
            }
        }
    });

    synchronized (retryLock) {
        return retry[0];
    }
}

From source file:com.microsoftopentechnologies.acsfilter.ui.classpath.ClasspathContainerPage.java

License:Open Source License

/**
 * Method creates Security (certificate and https check) component.
 * @param container// w ww . ja v a 2 s .  c o  m
 */
private void createCertComponent(Composite container) {
    Group certGrp = new Group(container, SWT.SHADOW_ETCHED_IN);
    GridLayout groupGridLayout = new GridLayout();
    groupGridLayout.numColumns = 3;
    groupGridLayout.verticalSpacing = 10;
    groupGridLayout.horizontalSpacing = 0;

    GridData groupGridData = new GridData();
    groupGridData.grabExcessHorizontalSpace = true;
    groupGridData.horizontalIndent = 10;
    groupGridData.verticalIndent = 10;
    groupGridData.horizontalAlignment = SWT.FILL;

    certGrp.setText(Messages.acsCertGrpTxt);
    certGrp.setLayout(groupGridLayout);
    certGrp.setLayoutData(groupGridData);

    certLbl = new Label(certGrp, SWT.LEFT);
    groupGridData = new GridData();
    groupGridData.grabExcessHorizontalSpace = true;
    groupGridData.horizontalSpan = 3;
    groupGridData.horizontalAlignment = SWT.FILL;
    certLbl.setText(Messages.acsCertLbl);
    certLbl.setLayoutData(groupGridData);

    certTxt = new Text(certGrp, SWT.LEFT | SWT.BORDER);
    groupGridData = new GridData();
    groupGridData.horizontalSpan = 1;
    groupGridData.horizontalAlignment = SWT.FILL;
    groupGridData.grabExcessHorizontalSpace = true;
    groupGridData.widthHint = 60;
    certTxt.setLayoutData(groupGridData);
    certTxt.addListener(SWT.FocusOut, new Listener() {
        public void handleEvent(Event arg0) {
            String certInfo = getCertInfo(certTxt.getText());
            if (certInfo != null)
                certInfoTxt.setText(certInfo);
            else
                certInfoTxt.setText("");
        }
    });

    browseBtn = new Button(certGrp, SWT.PUSH);
    groupGridData = new GridData();
    groupGridData.grabExcessHorizontalSpace = false;
    groupGridData.horizontalIndent = 5;
    groupGridData.horizontalAlignment = SWT.FILL;
    groupGridLayout.verticalSpacing = 10;
    groupGridData.widthHint = 65;
    browseBtn.setLayoutData(groupGridData);
    browseBtn.setText(Messages.acsBrwBtn);
    browseBtn.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            browseBtnListener();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });

    newCertBtn = new Button(certGrp, SWT.PUSH);
    groupGridData = new GridData();
    groupGridData.grabExcessHorizontalSpace = false;
    groupGridData.horizontalIndent = 5;
    groupGridData.horizontalAlignment = SWT.FILL;
    groupGridLayout.verticalSpacing = 10;
    groupGridData.widthHint = 65;
    newCertBtn.setLayoutData(groupGridData);
    newCertBtn.setText(Messages.acsnewCertBtn);
    newCertBtn.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            newCertBtnListener();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });

    //create non editable cert info text
    certInfoTxt = new Text(certGrp, SWT.LEFT | SWT.BORDER | SWT.MULTI);
    certInfoTxt.setEditable(false);
    groupGridData = new GridData();
    groupGridData.horizontalSpan = 3;
    groupGridData.horizontalAlignment = SWT.FILL;
    groupGridData.grabExcessHorizontalSpace = true;
    groupGridData.widthHint = 20;
    groupGridData.heightHint = 50;
    certInfoTxt.setLayoutData(groupGridData);
    certInfoTxt.setText(Messages.embedCertDefTxt);

    // Create Embed the certificate in the WAR file checkbox
    embedCertCheck = new Button(certGrp, SWT.LEFT | SWT.CHECK);
    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 3;
    gridData.horizontalAlignment = SWT.FILL;
    embedCertCheck.setText(Messages.embedCert);
    embedCertCheck.setLayoutData(gridData);
    embedCertCheck.setSelection(false);

    requiresHttpsCheck = new Button(certGrp, SWT.LEFT | SWT.CHECK);
    requiresHttpsCheck.setText(Messages.requiresHttpsChkBox);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 3;
    gridData.horizontalAlignment = SWT.FILL;
    requiresHttpsCheck.setLayoutData(gridData);
    requiresHttpsCheck.setSelection(true);
    requiresHttpsCheck.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent event) {
        }

        public void widgetSelected(SelectionEvent event) {
            if (event.getSource() instanceof Button) {
                Button checkBox = (Button) event.getSource();
                if (checkBox.getSelection()) {
                    //Do nothing
                } else {
                    boolean choice = MessageDialog.openQuestion(getShell(), Messages.requiresHttpsDlgTitle,
                            Messages.requiresHttpsDlgMsg);
                    if (!choice) {
                        checkBox.setSelection(true);
                    }
                }
            }
        }
    });
}

From source file:com.microsoftopentechnologies.acsfilter.ui.classpath.ClasspathContainerPage.java

License:Open Source License

/**
 * Method adds ACS filter and filter mapping tags in web.xml
 * and saves input values given on ACS library page.
 * In case of edit, populates previously set values.
 *///w w w  . j a v a 2  s.c  om
private void configureDeployment() {
    //edit library
    if (isEdit()) {
        IJavaProject proj1 = JavaCore.create(ACSFilterUtil.getSelectedProject());
        IClasspathEntry[] entries;
        try {
            entries = proj1.getRawClasspath();
            IClasspathEntry[] newentries = new IClasspathEntry[entries.length];

            for (int i = 0; i < entries.length; i++) {
                if (entries[i].toString().contains(Messages.sdkContainer)) {
                    if (depCheck.getSelection()) {
                        IClasspathAttribute[] attr = new IClasspathAttribute[1];
                        attr[0] = JavaCore.newClasspathAttribute(Messages.jstDep, "/WEB-INF/lib");
                        newentries[i] = JavaCore.newContainerEntry(entry, null, attr, true);
                    } else {
                        newentries[i] = JavaCore.newContainerEntry(entry);
                    }
                } else {
                    newentries[i] = entries[i];
                }
            }
            proj1.setRawClasspath(newentries, null);
        } catch (Exception e) {
            Activator.getDefault().log(e.getMessage(), e);
        }
    }

    ACSFilterHandler handler = null;
    try {
        IProject proj = ACSFilterUtil.getSelectedProject();
        if (proj.getFile(xmlPath).exists()) {
            handler = new ACSFilterHandler(proj.getFile(xmlPath).getLocation().toOSString());
            handler.setAcsFilterParams(Messages.acsAttr, acsTxt.getText());
            handler.setAcsFilterParams(Messages.relAttr, relTxt.getText());
            if (!embedCertCheck.getSelection()) {
                handler.setAcsFilterParams(Messages.certAttr, certTxt.getText());
                if (getEmbeddedCertInfo() != null)
                    removeEmbedCert(ACSFilterUtil.getSelectedProject());
            } else {
                handler.removeParamsIfExists(Messages.certAttr);
                if (!certTxt.getText().isEmpty()) {
                    String srcLoc = ACSFilterUtil.getSelectedProject().getFolder(certificateLocation)
                            .getLocation().toOSString();
                    String certLoc = String.format("%s%s%s", srcLoc, File.separator, Messages.acsCertLoc);
                    File destination = new File(certLoc);
                    if (!destination.getParentFile().exists())
                        destination.getParentFile().mkdir();
                    copy(new File(CerPfxUtil.getCertificatePath(certTxt.getText())), destination);
                }
            }
            handler.setAcsFilterParams(Messages.secretKeyAttr, generateKey());
            handler.setAcsFilterParams(Messages.allowHTTPAttr,
                    requiresHttpsCheck.getSelection() ? "false" : "true");
        } else {
            boolean choice = MessageDialog.openQuestion(this.getShell(), Messages.depDescTtl,
                    Messages.depDescMsg);
            if (choice) {
                String path = createWebXml(depDirLoc);
                //copy cert into WEB-INF/cert/_acs_signing.cer location if embed cert is selected 
                if (embedCertCheck.getSelection()) {
                    String srcLoc = ACSFilterUtil.getSelectedProject().getFolder(certificateLocation)
                            .getLocation().toOSString();
                    String certLoc = String.format("%s%s%s", srcLoc, File.separator, Messages.acsCertLoc);
                    File destination = new File(certLoc);
                    if (!destination.getParentFile().exists())
                        destination.getParentFile().mkdir();
                    copy(new File(CerPfxUtil.getCertificatePath(certTxt.getText())), destination);
                }
                handler = new ACSFilterHandler(path);
                handler.setAcsFilterParams(Messages.acsAttr, acsTxt.getText());
                handler.setAcsFilterParams(Messages.relAttr, relTxt.getText());
                if (!embedCertCheck.getSelection()) { //Donot make entry if embed cert is selected
                    handler.setAcsFilterParams(Messages.certAttr, certTxt.getText());
                    if (getEmbeddedCertInfo() != null)
                        removeEmbedCert(ACSFilterUtil.getSelectedProject());
                }
                handler.setAcsFilterParams(Messages.secretKeyAttr, generateKey());
                handler.setAcsFilterParams(Messages.allowHTTPAttr,
                        requiresHttpsCheck.getSelection() ? "false" : "true");
            } else {
                finishVal = true;
                return;
            }
        }
    } catch (Exception e) {
        MessageDialog.openError(this.getShell(), Messages.acsErrTtl, Messages.acsErrMsg);
        finishVal = false;
        Activator.getDefault().log(e.getMessage(), e);
    }
    try {
        handler.save();
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IWorkspaceRoot root = workspace.getRoot();
        root.refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (Exception e) {
        Activator.getDefault().log(e.getMessage(), e);
        MessageDialog.openError(this.getShell(), Messages.acsErrTtl, Messages.saveErrMsg);
        finishVal = false;
    }
}

From source file:com.minres.scviewer.e4.application.parts.WaveformViewer.java

License:Open Source License

@Override
public void fileChanged(List<File> file) {
    final Display display = myParent.getDisplay();
    display.asyncExec(new Runnable() {
        @Override//from  w w  w .  ja  v  a 2 s.c om
        public void run() {
            if (MessageDialog.openQuestion(display.getActiveShell(), "Database re-load",
                    "Would you like to reload the database?")) {
                Map<String, String> state = new HashMap<>();
                saveWaveformViewerState(state);
                waveformPane.getStreamList().clear();
                database.clear();
                if (filesToLoad.size() > 0)
                    loadDatabase(state);
            }
        }
    });
    fileMonitor.removeFileChangeListener(this);
}