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

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

Introduction

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

Prototype

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

Source Link

Document

Convenience method to open a standard information dialog.

Usage

From source file:com.denimgroup.threadfix.plugin.eclipse.action.ClearAction.java

License:Mozilla Public License

/**
 * The action has been activated. The argument of the
 * method represents the 'real' action sitting
 * in the workbench UI./*from   ww  w . j av  a  2 s.  c o m*/
 * @see IWorkbenchWindowActionDelegate#run
 */
@Override
public void run(IAction action) {
    MessageDialog.openInformation(window.getShell(), "Clear",
            "Clearing all ThreadFix warnings in the workspace.");
    VulnerabilityMarkerUtils.clearAllMarkers();
}

From source file:com.denimgroup.threadfix.plugin.eclipse.action.ImportAction.java

License:Mozilla Public License

/**
 * The action has been activated. The argument of the
 * method represents the 'real' action sitting
 * in the workbench UI.//  w w w  . ja  v a2  s.com
 * @see IWorkbenchWindowActionDelegate#run
 */
@Override
public void run(IAction action) {
    boolean cancelled = false;
    ConfigDialog dialog = new ConfigDialog(window.getShell(), false);

    dialog.create();

    if (dialog.open() == Window.OK) {
        EclipsePropertiesManager.saveThreadFixInfo(dialog.getUrl(), dialog.getApiKey());
        ApplicationsMap threadFixApplicationMap = ThreadFixService.getApplications();

        while (threadFixApplicationMap.getTeams().isEmpty()) {
            dialog = new ConfigDialog(window.getShell(), true);

            dialog.create();
            if (dialog.open() == Window.OK) {
                EclipsePropertiesManager.saveThreadFixInfo(dialog.getUrl(), dialog.getApiKey());
                System.out.println("Saved ThreadFix information successfully.");
                threadFixApplicationMap = ThreadFixService.getApplications();
            } else {
                System.out.println("Cancel was pressed.");
                cancelled = true;
                break;
            }
        }

        if (!cancelled) {
            MessageDialog.openInformation(window.getShell(), "ThreadFix Vulnerability Import",
                    "Importing ThreadFix Vulnerabilities.");
            List<VulnerabilityMarker> vulnerabilityMarkers = VulnerabilityMarkerService.getMarkers();

            Map<String, Set<IFile>> files = WorkspaceUtils.getFileMap();

            VulnerabilityMarkerUtils.clearAllMarkers();

            VulnerabilityMarkerUtils.addMarkersToFiles(vulnerabilityMarkers, files);

            VulnerabilitiesView.showView();
        }
    }
}

From source file:com.density.ezsbt.views.SbtView.java

License:Apache License

protected void showMessage(String message) {
    MessageDialog.openInformation(viewer.getControl().getShell(), "Sbt View", message);
}

From source file:com.dforensic.plugin.manal.views.handlers.SuspectSearchHandler.java

License:Open Source License

/**
 * the command has been executed, so extract extract the needed information
 * from the application context.//w  w  w  . ja v a  2s .co m
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    this.shell = window.getShell();
    if (window != null) {
        try {
            IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection();
            Object firstElement = selection.getFirstElement();
            if (firstElement instanceof IAdaptable) {
                IProject project = (IProject) ((IAdaptable) firstElement).getAdapter(IProject.class);
                try {
                    ProjectProperties.setApkNameVal(project.getPersistentProperty(
                            new QualifiedName(ProjectProperties.QUALIFIER, ProjectProperties.getApkNameKey())));
                    //                  ProjectProperties.setPrjNameVal(
                    //                        project.getPersistentProperty(new QualifiedName(ProjectProperties.QUALIFIER,
                    //                              ProjectProperties.getPrjNameKey())));
                    ProjectProperties.setAndroidPathVal(project.getPersistentProperty(new QualifiedName(
                            ProjectProperties.QUALIFIER, ProjectProperties.getAndroidPathKey())));
                } catch (CoreException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            MessageDialog.openInformation(window.getShell(), "No selected project",
                    "Please, select a project to analyse.");
        }
    }

    ManalManager manager = new ManalManager();
    /*
    Display  display  =  PlatformUI.getWorkbench().getDisplay();
      Shell  shell  =  new  Shell(display);
      shell.setLayout(new  GridLayout());
      shell.setSize(150,60);
      ProgressBar  pb  =  new  ProgressBar(shell,  SWT.HORIZONTAL  |  SWT.SMOOTH);
      pb.setLayoutData(new  GridData(GridData.FILL_HORIZONTAL));
      pb.setMinimum(0);
      pb.setMaximum(30);
              
      new myProgressBar(display,pb).start();
      shell.open();
      while  (!shell.isDisposed())  {
    if  (!display.readAndDispatch())  {
            //display.sleep();
       manager.searchSuspiciousApi();
    }
      }*/

    manager.searchSuspiciousApi();

    /*
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
     IWorkbenchPage page = window.getActivePage();
     SuspectListVw view = (SuspectListVw) page.findView(SuspectListVw.ID);
    view.openJavaSourceEditor();
     MessageDialog.openInformation(
    window.getShell(),
    "Manal",
    "Hello, Eclipse world");
    */
    return null;
}

From source file:com.dgex.offspring.application.handlers.AboutHandler.java

License:Open Source License

@Execute
public void execute(Shell shell, INxtService nxt) {
    MessageDialog.openInformation(shell, Messages.AboutHandler_title,
            formatMessage(nxt) + "\n\n" + formatUptime());
}

From source file:com.dtsworkshop.flextools.actions.SampleAction.java

/**
 * The action has been activated. The argument of the
 * method represents the 'real' action sitting
 * in the workbench UI.//  w  w  w .  j  a va2  s.  c o m
 * @see IWorkbenchWindowActionDelegate#run
 */
public void run(IAction action) {
    MessageDialog.openInformation(window.getShell(), "The Flex Tools Project : Adding the bit Adobe forgot",
            "Hello, Eclipse world");
}

From source file:com.dubture.pdt.ui.actions.GenerateGettersHandler.java

License:Open Source License

protected Object exitMessage() {
    final Shell p = DLTKUIPlugin.getActiveWorkbenchShell();
    MessageDialog.openInformation(p, "Getter/Setter generation unavailable",
            "No fields to generate getters/setters found.");
    return null;//from  w  w  w  .  ja  v  a 2  s .c om
}

From source file:com.ebmwebsourcing.petals.components.drivers.ComponentConfigurationWizard.java

License:Open Source License

@Override
public boolean performFinish() {

    WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
        @Override/*from  ww  w.jav  a 2  s . com*/
        protected void execute(IProgressMonitor monitor)
                throws CoreException, InvocationTargetException, InterruptedException {

            try {
                doFinish(monitor);

            } catch (Exception e) {
                throw new InvocationTargetException(e);

            } finally {
                monitor.done();
            }
        }
    };

    try {
        getContainer().run(true, false, op);
        MessageDialog.openInformation(getShell(), "Success", "The configuration completed successfully.");

    } catch (InterruptedException e) {
        return false;

    } catch (InvocationTargetException e) {
        PetalsComponentsPlugin.log(e, IStatus.ERROR);
        Throwable realException = e.getTargetException();
        MessageDialog.openError(getShell(), "Error", realException.getMessage());
        return false;
    }

    return true;
}

From source file:com.ebmwebsourcing.petals.services.cdk.editor.WSDLHelperTooltip.java

License:Open Source License

/**
 * Populates the tool tip./*from  w  ww  .j  a v a2  s. c  o m*/
 */
private void populateTooltip() {

    // Deal with the SHELL content
    GridLayoutFactory.swtDefaults().applyTo(this.shell);
    this.shell.setLayoutData(new GridData(GridData.FILL_BOTH));
    this.shell.setBackground(this.shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));

    Form res = this.toolkit.createForm(this.shell);
    res.setText(Messages.wsdlTools);
    res.getBody().setLayout(new GridLayout());

    // Helper: import the WSDL in the project
    this.importLink = this.toolkit.createHyperlink(res.getBody(), "Import this WSDL in the project", SWT.NONE);
    final IFolder resFolder = WSDLHelperTooltip.this.ise.getEditedFile().getProject()
            .getFolder(PetalsConstants.LOC_RES_FOLDER);

    this.importLink.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        public void linkActivated(HyperlinkEvent e) {

            hide();
            try {
                URI wsdlUri = WSDLHelperTooltip.this.wsdlParsingJob.getWsdlUri();
                Map<String, File> map = new WsdlImportHelper()
                        .importWsdlOrXsdAndDependencies(resFolder.getLocation().toFile(), wsdlUri.toString());
                File importedFile = map.get(wsdlUri.toString());
                String value = IoUtils.getRelativeLocationToFile(resFolder.getLocation().toFile(),
                        importedFile);
                SetCommand cmd = new SetCommand(WSDLHelperTooltip.this.ise.getEditingDomain(),
                        WSDLHelperTooltip.this.service, Cdk5Package.Literals.CDK5_PROVIDES__WSDL, value);

                WSDLHelperTooltip.this.ise.getEditingDomain().getCommandStack().execute(cmd);

            } catch (Exception e1) {
                CdkPlugin.log(e1, IStatus.ERROR);
            }
        }
    });

    // Helper: select a service in the WSDL
    this.selectServiceLink = this.toolkit.createHyperlink(res.getBody(),
            "Select a service in the WSDL to fill-in the properties below", SWT.NONE);
    this.selectServiceLink.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        public void linkActivated(HyperlinkEvent e) {

            hide();
            EMFPCStyledLabelProvider lp = new EMFPCStyledLabelProvider(WSDLHelperTooltip.this.shell);
            StyledElementListSelectionDialog dlg = new StyledElementListSelectionDialog(
                    WSDLHelperTooltip.this.shell, lp);

            dlg.setFilter("*");
            dlg.setSize(120, 20);
            dlg.setMultipleSelection(false);
            dlg.setTitle("Service Selection");
            dlg.setMessage("Select the service to expose inside Petals.");

            dlg.setElements(WSDLHelperTooltip.this.wsdlParsingJob.getBeans().toArray());
            if (dlg.open() == Window.OK) {
                CompoundCommand cc = new CompoundCommand();
                JbiBasicBean bean = (JbiBasicBean) dlg.getResult()[0];
                cc.append(new SetCommand(WSDLHelperTooltip.this.ise.getEditingDomain(),
                        WSDLHelperTooltip.this.service, JbiPackage.Literals.ABSTRACT_ENDPOINT__SERVICE_NAME,
                        bean.getServiceName()));

                cc.append(new SetCommand(WSDLHelperTooltip.this.ise.getEditingDomain(),
                        WSDLHelperTooltip.this.service, JbiPackage.Literals.ABSTRACT_ENDPOINT__INTERFACE_NAME,
                        bean.getInterfaceName()));

                cc.append(new SetCommand(WSDLHelperTooltip.this.ise.getEditingDomain(),
                        WSDLHelperTooltip.this.service, JbiPackage.Literals.ABSTRACT_ENDPOINT__ENDPOINT_NAME,
                        bean.getEndpointName()));

                WSDLHelperTooltip.this.ise.getEditingDomain().getCommandStack().execute(cc);
            }

            lp.dispose();
        }
    });

    // Helper: open in the WSDL editor
    this.openLink = this.toolkit.createHyperlink(res.getBody(), "Open in the WSDL editor", SWT.NONE);
    this.openLink.setToolTipText("Open this WSDL in the default WSDL editor");
    this.openLink.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        public void linkActivated(HyperlinkEvent e) {
            hide();

            URI wsdlUri = WSDLHelperTooltip.this.wsdlParsingJob.getWsdlUri();
            File wsdlFile = IoUtils.convertToFile(wsdlUri);
            IFile f = ResourceUtils.getIFile(wsdlFile);
            if (f == null)
                return;

            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            try {
                IDE.openEditor(page, f, true);

            } catch (PartInitException exception) {
                CdkPlugin.log(exception, IStatus.ERROR);
            }
        }
    });

    // Helper: update the end-point name in the WSDL
    this.updateLink = this.toolkit.createHyperlink(res.getBody(), "Update the service end-point in the WSDL",
            SWT.NONE);
    this.updateLink.setToolTipText(
            "Update the WSDL so that it declared end-point for this service is the one defined below");
    this.updateLink.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        public void linkActivated(HyperlinkEvent e) {
            hide();
            QName serviceName = WSDLHelperTooltip.this.service.getServiceName();
            String edptName = WSDLHelperTooltip.this.service.getEndpointName();
            URI wsdlUri = WSDLHelperTooltip.this.wsdlParsingJob.getWsdlUri();

            // Perform an update if, and only if, there is no ambiguity in the WSDL.
            // It is too complicated (and there are too many error cases) to keep the old end-point name value.
            // So, the user may have to modify the WSDL by hand in some situations.
            try {
                List<JbiBasicBean> beans = WsdlUtils.INSTANCE.parse(wsdlUri);
                int candidates = 0;
                for (JbiBasicBean bean : beans) {
                    if (serviceName.equals(bean.getServiceName()))
                        candidates++;
                }

                if (candidates > 1) {
                    MessageDialog.openInformation(WSDLHelperTooltip.this.shell, "Ambiguous Situation",
                            "The right WSDL port to update could not be determined. Please, update the WSDL manually.");
                } else {
                    File wsdlFile = IoUtils.convertToFile(wsdlUri);
                    if (!WsdlUtils.INSTANCE.updateEndpointNameInWsdl(wsdlFile, serviceName, null, edptName)) {
                        MessageDialog.openError(WSDLHelperTooltip.this.shell, "End-point Update Failure",
                                "The end-point could not be updated in the WSDL.");
                    } else {
                        // Force the validation of the file
                        WSDLHelperTooltip.this.ise.getEditedFile().touch(null);
                    }
                }

            } catch (InvocationTargetException e1) {
                MessageDialog.openError(WSDLHelperTooltip.this.shell, "Invalid WSDL",
                        "The WSDL file could not be parsed. Make sure the URL and the file are both valid.");

            } catch (CoreException e1) {
                CdkPlugin.log(e1, IStatus.WARNING);
            }
        }
    });

    res.getBody().addListener(SWT.MouseDown, new Listener() {
        @Override
        public void handleEvent(Event e) {
            hide();
        }
    });
}

From source file:com.ebmwebsourcing.petals.services.explorer.ServiceExplorerActionProvider.java

License:Open Source License

@Override
public void init(final ICommonActionExtensionSite aSite) {

    ICommonViewerSite site = aSite.getViewSite();
    if (!(site instanceof ICommonViewerWorkbenchSite))
        return;/*  ww w.  j ava 2  s .  co  m*/

    final ISelectionProvider provider = ((ICommonViewerWorkbenchSite) site).getSelectionProvider();

    //
    // Workspace Folder Source
    this.addWorkspaceFolderSourceAction = new Action() {
        @Override
        public void run() {

            DirectoryDialog dlg = new DirectoryDialog(aSite.getViewSite().getShell());
            dlg.setText("External workspace");
            dlg.setMessage("Find Petals services in an external workspace.");
            String result = dlg.open();

            if (result != null) {
                EndpointSource source = new ExternalWorkspaceSource(new File(result));
                SourceManager.getInstance().addSource(source);
            }
        }
    };

    this.addWorkspaceFolderSourceAction.setText("Workspace Folder");
    this.addWorkspaceFolderSourceAction.setToolTipText("New workspace folder source");
    this.addWorkspaceFolderSourceAction
            .setDescription("Find the Petals services in contained in another workspace folder.");
    ImageDescriptor desc = PetalsServicesPlugin.getImageDescriptor("icons/obj16/EndpointProjectClosed.gif");
    this.addWorkspaceFolderSourceAction.setImageDescriptor(desc);

    //
    // SA Folder Source
    this.addSaFolderAction = new Action() {
        @Override
        public void run() {
            DirectoryDialog dlg = new DirectoryDialog(aSite.getViewSite().getShell());
            dlg.setText("Service Assembly folder");
            dlg.setMessage("Find Petals services in a directory of service assemblies.");
            String result = dlg.open();

            if (result != null) {
                EndpointSource source = new SaDirectorySource(new File(result), false, false);
                SourceManager.getInstance().addSource(source);
            }
        }
    };

    this.addSaFolderAction.setText("SA Folder");
    this.addSaFolderAction.setToolTipText("New SA folder source");
    this.addSaFolderAction
            .setDescription("Find the Petals services in contained in a folder of service assemblies.");
    desc = PetalsServicesPlugin.getImageDescriptor("icons/obj16/EndpointFolderClosed.gif");
    this.addSaFolderAction.setImageDescriptor(desc);

    //    //
    //   // Workspace Folder Source
    //   this.addServerSourceAction = new Action() {
    //      @Override
    //      public void run() {
    //         // TODO
    //      }
    //   };
    //
    //   this.addServerSourceAction.setText( "Petals Server" );
    //   this.addServerSourceAction.setToolTipText( "New server source" );
    //   this.addServerSourceAction.setDescription( "Browse the end-points contained in a Petals server." );
    //   desc = PetalsServicesPlugin.getImageDescriptor( "icons/obj16/EndpointServer.gif" );
    //   this.addServerSourceAction.setImageDescriptor( desc );

    //
    // Refresh action
    this.refreshAction = new Action() {
        @Override
        public void run() {
            final EndpointSource source = getEndpointSource(provider);
            if (source != null)
                SourceManager.getInstance().updateSource(source);
        }

        @Override
        public boolean isEnabled() {
            return getEndpointSource(provider) != null;
        }
    };

    this.refreshAction.setText("Refresh");
    this.refreshAction.setAccelerator(SWT.F5);
    this.refreshAction.setToolTipText("Refresh the list of Petals services");
    this.refreshAction.setDescription("Refresh the list of Petals services.");
    desc = PetalsServicesPlugin.getImageDescriptor("icons/obj16/refresh.gif");
    this.refreshAction.setImageDescriptor(desc);

    //
    // Remove action
    this.deleteAction = new Action() {
        @Override
        public void run() {
            EndpointSource source = getEndpointSource(provider);
            if (source != null)
                SourceManager.getInstance().removeSource(source);
        }

        @Override
        public boolean isEnabled() {
            EndpointSource edptSource = getEndpointSource(provider);
            return edptSource != null && !(edptSource instanceof CurrentWorkspaceSource);
        }
    };

    this.deleteAction.setText("Delete");
    this.deleteAction.setToolTipText("Delete this source of Petals services");
    this.deleteAction.setDescription("Delete this source of Petals services.");
    desc = PetalsServicesPlugin.getImageDescriptor("icons/obj16/delete.gif");
    this.deleteAction.setImageDescriptor(desc);

    //
    // Properties action
    this.propertiesAction = new Action() {
        @Override
        public boolean isEnabled() {
            return getEndpointSource(provider) != null || getEndpointBean(provider) != null;
        }

        @Override
        public void run() {
            Object object = getEndpointSource(provider);
            if (object == null)
                object = getEndpointBean(provider);

            try {
                // Show properties view
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                page.showView("org.eclipse.ui.views.PropertySheet"); //$NON-NLS-1$

                // Show the Petals service explorer
                page.showView("com.ebmwebsourcing.petals.services.explorer"); //$NON-NLS-1$

                // Select the previous selection in the outline.
                provider.setSelection(new StructuredSelection(object));
            } catch (Exception e) {
                PetalsServicesPlugin.log(e, IStatus.ERROR);
            }
        }
    };

    this.propertiesAction.setText("Properties");
    this.propertiesAction.setToolTipText("Show properties");
    this.propertiesAction.setDescription("Show the properties of the selected element.");
    desc = PetalsServicesPlugin.getImageDescriptor("icons/obj16/properties.gif");
    this.propertiesAction.setImageDescriptor(desc);

    //
    // Open WSDL action
    this.openWsdlAction = new Action() {

        @Override
        public boolean isEnabled() {
            EndpointBean edptBean = getEndpointBean(provider);

            if (edptBean != null) {
                if (edptBean.getServiceUnit().isWsdlContainerLocationComputed()) {
                    URI uri = edptBean.getWsdlUri();
                    return uri != null && new File(uri).exists();
                }

                return edptBean.getWsdlLocation() != null;
            }

            return false;
        }

        @Override
        public boolean isHandled() {
            EndpointBean edptBean = getEndpointBean(provider);
            return edptBean != null;
        }

        @Override
        public void run() {
            final EndpointBean edptBean = getEndpointBean(provider);
            try {
                URI wsdlUri = edptBean.getWsdlUri();

                // WSDL not null: open it
                File f = null;
                if (wsdlUri != null && (f = new File(wsdlUri)).exists()) {
                    IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(f.getAbsolutePath()));
                    if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
                        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                                .getActivePage();
                        IDE.openEditorOnFileStore(page, fileStore);
                    }
                }

                // WSDL URI is null or points to a nonexistent file
                /*
                 * Can only happen when this URI is computed for the first time.
                 * Then, isEnabled() prevents this from happening.
                 * 
                 * Refreshing the source of the end-point will have for consequence
                 * a new computation of the WSDL URI.
                 */
                else if (f != null) {
                    MessageDialog.openInformation(aSite.getViewSite().getShell(), "Nonexistent WSDL",
                            "The WSDL file " + f.getAbsolutePath() + " does not exist.");
                } else {
                    MessageDialog.openInformation(aSite.getViewSite().getShell(), "No WSDL to open",
                            "No WSDL could be found for this service.");
                }

            } catch (Exception e) {
                MessageDialog.openError(aSite.getViewSite().getShell(), "Failure in opening the WSDL",
                        "The service WSDL could not be opened. See the log for more details.");
                PetalsServicesPlugin.log(e, IStatus.ERROR);
            }
        }
    };

    this.openWsdlAction.setText("Open WSDL");
    this.openWsdlAction.setToolTipText("Show the service interface in the WSDL editor");
    this.openWsdlAction.setDescription("Show the service interface in the WSDL editor.");
}