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.aptana.php.debug.ui.phpini.PHPIniEditor.java

License:Open Source License

/**
 * Removes entry./* w ww  . j  a  va 2  s  .c o  m*/
 */
private void removeEntry() {
    ISelection selection = viewer.getSelection();
    if (selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();

        if (element instanceof PHPIniEntry) {
            provider.removeEntry(((PHPIniEntry) element));
            viewer.refresh(true);
            viewer.getTree().getParent().layout(true, true);
        } else if (element instanceof INIFileSection) {
            INIFileSection section = (INIFileSection) element;
            if (section.equals(provider.getGlobalSection())) {
                MessageDialog.openInformation(viewer.getTree().getShell(), Messages.PHPIniEditor_11,
                        Messages.PHPIniEditor_12);
                return;
            }
            boolean result = MessageDialog.openQuestion(viewer.getTree().getShell(), Messages.PHPIniEditor_13,
                    Messages.PHPIniEditor_14 + section.getName() + Messages.PHPIniEditor_15);
            if (result) {
                provider.removeSection(section);
                viewer.refresh(true);
                viewer.getTree().getParent().layout(true, true);
            }
        }
    }
}

From source file:com.aptana.syncing.ui.wizards.ImportConnectionsWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    IPath location = mainPage.getLocation();
    int connectionCount = 0, siteCount = 0;
    int[] applyToAllAction = new int[] { -1 };
    if (mainPage.isWorkspaceSelected()) {
        // importing from workspace
        // imports connection points
        IPath connectionPath = location.append(STATE_LOCATION_ROOT).append("com.aptana.ide.core.io"); //$NON-NLS-1$
        File dir = connectionPath.toFile();
        if (dir.isDirectory()) {
            // this is a 2.0 workspace
            connectionCount = loadConnectionPoints(dir, applyToAllAction);
            if (connectionCount == -1) {
                return false;
            }/* w w  w .  j  a  va  2  s.  c  om*/
        } else {
            // checks if it is a 3.0 workspace
            connectionPath = location.append(STATE_LOCATION_ROOT).append(CoreIOPlugin.PLUGIN_ID);
            dir = connectionPath.toFile();
            if (dir.isDirectory()) {
                connectionCount = loadConnectionPoints(dir, applyToAllAction);
                if (connectionCount == -1) {
                    return false;
                }
            }
        }

        // imports site connections
        IPath sitePath = location.append(STATE_LOCATION_ROOT).append("com.aptana.ide.syncing.core"); //$NON-NLS-1$
        dir = sitePath.toFile();
        if (dir.isDirectory()) {
            // this is a 2.0 workspace
            siteCount = loadSiteConnections(dir, applyToAllAction);
        } else {
            // checks if it is a 3.0 workspace
            sitePath = location.append(STATE_LOCATION_ROOT).append(SyncingPlugin.PLUGIN_ID);
            dir = sitePath.toFile();
            if (dir.isDirectory()) {
                siteCount = loadSiteConnections(dir, applyToAllAction);
            }
        }
    } else {
        // importing from file
        List<IConnectionPoint> connections = validateConnectionsFrom(location, applyToAllAction);
        if (connections == null) {
            return false;
        }

        connectionCount = connections.size();
        List<ISiteConnection> sites = validateSitesFrom(location, applyToAllAction);
        siteCount = sites.size();
    }
    final int cCount = connectionCount;
    final int sCount = siteCount;
    UIUtils.getDisplay().asyncExec(new Runnable() {

        public void run() {
            MessageDialog.openInformation(getShell(), Messages.ImportConnectionsWizard_Info_Title,
                    MessageFormat.format(Messages.ImportConnectionsWizard_Info_Message, cCount, sCount));
        }
    });
    return true;
}

From source file:com.aptana.ui.ftp.internal.FTPConnectionPropertyComposite.java

License:Open Source License

public FTPConnectionPropertyComposite(Composite parent, int style, IBaseRemoteConnectionPoint connectionPoint,
        IListener listener) {/*  w w  w.j  ava 2  s .co m*/
    super(parent, style);
    setConnectionPoint(connectionPoint);
    this.listener = listener;

    PixelConverter converter = new PixelConverter(this);
    setLayout(GridLayoutFactory.swtDefaults()
            .margins(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN),
                    converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN))
            .spacing(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING),
                    converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING))
            .numColumns(2).create());

    /* row 1 */
    createSiteSection(this);

    Group group = new Group(this, SWT.NONE);
    group.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create());
    group.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());
    group.setText(Messages.FTPConnectionPointPropertyDialog_LBL_GroupInfo);

    /* row 2 */
    Label label = new Label(group, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH),
                    SWT.DEFAULT)
            .create());
    label.setText(StringUtil.makeFormLabel(Messages.FTPConnectionPointPropertyDialog_LBL_Server));

    hostText = new Text(group, SWT.SINGLE | SWT.BORDER);
    hostText.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(hostText)
                    .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT)
            .span(2, 1).create());

    /* row 3 */
    new Label(group, SWT.NONE).setLayoutData(GridDataFactory.swtDefaults().create());

    label = new Label(group, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());
    smallFont = JFaceResources.getTextFontDescriptor().increaseHeight(-2).createFont(getDisplay());
    label.setFont(smallFont);
    label.setText(Messages.FTPConnectionPointPropertyDialog_LBL_Example);

    /* row 4 */
    label = new Label(group, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH),
                    SWT.DEFAULT)
            .create());
    label.setText(StringUtil.makeFormLabel(Messages.FTPConnectionPointPropertyDialog_LBL_Username));

    loginCombo = new Combo(group, SWT.DROP_DOWN | SWT.BORDER);
    loginCombo.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(loginCombo)
                    .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT)
            .grab(true, false).create());
    loginCombo.add(IFTPConstants.LOGIN_ANONYMOUS);

    testButton = new Button(group, SWT.PUSH);
    testButton.setText(Messages.FTPConnectionPointPropertyDialog_LBL_Test);
    testButton.setLayoutData(GridDataFactory.fillDefaults()
            .hint(Math.max(
                    new PixelConverter(testButton).convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH),
                    testButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x), SWT.DEFAULT)
            .create());

    /* row 5 */
    createPasswordSection(group);

    /* row 6 */
    label = new Label(group, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH),
                    SWT.DEFAULT)
            .create());
    label.setText(StringUtil.makeFormLabel(Messages.FTPConnectionPointPropertyDialog_LBL_RemotePath));

    remotePathText = new Text(group, SWT.SINGLE | SWT.BORDER);
    remotePathText.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(remotePathText)
                    .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT)
            .grab(true, false).create());

    browseButton = new Button(group, SWT.PUSH);
    browseButton.setText('&' + StringUtil.ellipsify(CoreStrings.BROWSE));
    browseButton.setLayoutData(GridDataFactory.fillDefaults()
            .hint(Math.max(
                    new PixelConverter(browseButton)
                            .convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH),
                    browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x), SWT.DEFAULT)
            .create());

    /* row 7 */
    optionsExpandable = new ExpandableComposite(this, SWT.NONE,
            ExpandableComposite.TWISTIE | ExpandableComposite.FOCUS_TITLE);
    optionsExpandable.setText(Messages.FTPConnectionPointPropertyDialog_LBL_Options);
    optionsExpandable.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, true)
            .minSize(SWT.DEFAULT, SWT.DEFAULT).create());
    Group optionsGroup = new Group(optionsExpandable, SWT.NONE);
    optionsGroup.setLayout(GridLayoutFactory.fillDefaults().create());

    createAdvancedOptions(optionsGroup);

    optionsExpandable.setClient(optionsGroup);
    optionsExpandable.addExpansionListener(new ExpansionAdapter() {

        public void expansionStateChanged(ExpansionEvent e) {
            FTPConnectionPropertyComposite.this.listener.layoutShell();
        }
    });

    /* row 8 */
    progressMonitorPart = new ProgressMonitorPart(this, GridLayoutFactory.fillDefaults().create());
    progressMonitorPart
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).exclude(true).span(2, 1).create());

    /* -- */
    addListeners();

    passwordText.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            e.doit = false;
            testConnection();
        }
    });

    testButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (testConnection()) {
                MessageDialog.openInformation(getShell(),
                        Messages.FTPConnectionPointPropertyDialog_Succeed_Title, MessageFormat.format(
                                Messages.FTPConnectionPointPropertyDialog_Succeed_Message, hostText.getText()));
            }
        }
    });

    browseButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            browseConnection();
        }
    });

    if (ftpConnectionPoint == null) {
        isNew = true;
        ftpConnectionPoint = getOrCreateConnectionPoint(getConnectionPointType());
        ftpConnectionPoint.setName(DEFAULT_NAME);
    } else {
        originalFtpConnectionPoint = ftpConnectionPoint;
    }
    loadPropertiesFrom(ftpConnectionPoint);
    connectionTested = !isNew;
}

From source file:com.aptana.ui.s3.internal.S3ConnectionPropertyComposite.java

License:Open Source License

public S3ConnectionPropertyComposite(Composite parent, int style, IBaseRemoteConnectionPoint connectionPoint,
        Listener listener) {/*  w w  w  .  java2  s . co m*/
    super(parent, style);
    setConnectionPoint(connectionPoint);
    this.listener = listener;

    PixelConverter converter = new PixelConverter(this);
    setLayout(GridLayoutFactory.swtDefaults()
            .margins(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN),
                    converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN))
            .spacing(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING),
                    converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING))
            .numColumns(2).create());

    /* row 1 */
    createSiteSection(this);

    Group group = new Group(this, SWT.NONE);
    group.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create());
    group.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());
    group.setText(Messages.S3ConnectionPointPropertyDialog_LBL_GroupInfo);

    /* row 2 */
    Label label = new Label(group, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create());
    label.setText(StringUtil.makeFormLabel(Messages.S3ConnectionPointPropertyDialog_LBL_Server));

    hostText = new Text(group, SWT.SINGLE | SWT.BORDER);
    hostText.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(hostText)
                    .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT)
            .span(2, 1).create());
    hostText.setText(S3ConnectionPoint.DEFAULT_HOST);

    /* row 3 */
    new Label(group, SWT.NONE).setLayoutData(GridDataFactory.swtDefaults().create());

    label = new Label(group, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());
    smallFont = JFaceResources.getTextFontDescriptor().increaseHeight(-2).createFont(getDisplay());
    label.setFont(smallFont);
    label.setText(Messages.S3ConnectionPointPropertyDialog_LBL_Example);

    /* row 4 */
    label = new Label(group, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create());
    label.setText(StringUtil.makeFormLabel(Messages.S3ConnectionPointPropertyDialog_LBL_AccessKeyID));

    accessKeyText = new Text(group, SWT.SINGLE | SWT.BORDER);
    accessKeyText.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(accessKeyText)
                    .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT)
            .grab(true, false).create());

    testButton = new Button(group, SWT.PUSH);
    testButton.setText(Messages.S3ConnectionPointPropertyDialog_LBL_Test);
    testButton.setLayoutData(GridDataFactory.fillDefaults()
            .hint(Math.max(
                    new PixelConverter(testButton).convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH),
                    testButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x), SWT.DEFAULT)
            .create());

    /* row 5 */
    createPasswordSection(group);

    /* row 6 */
    label = new Label(group, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create());
    label.setText(StringUtil.makeFormLabel(Messages.S3ConnectionPointPropertyDialog_LBL_RemotePath));

    remotePathText = new Text(group, SWT.SINGLE | SWT.BORDER);
    remotePathText.setLayoutData(GridDataFactory.swtDefaults()
            .hint(new PixelConverter(remotePathText)
                    .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT)
            .grab(true, false).create());

    browseButton = new Button(group, SWT.PUSH);
    browseButton.setText('&' + StringUtil.ellipsify(CoreStrings.BROWSE));
    browseButton.setLayoutData(GridDataFactory.fillDefaults()
            .hint(Math.max(
                    new PixelConverter(browseButton)
                            .convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH),
                    browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x), SWT.DEFAULT)
            .create());

    /* row 7 */
    progressMonitorPart = new ProgressMonitorPart(this, GridLayoutFactory.fillDefaults().create());
    progressMonitorPart
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).exclude(true).span(2, 1).create());

    /* -- */
    addListeners();

    passwordText.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            e.doit = false;
            testConnection();
        }
    });

    testButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (testConnection()) {
                MessageDialog.openInformation(getShell(),
                        Messages.S3ConnectionPointPropertyDialog_Succeed_Title, MessageFormat.format(
                                Messages.S3ConnectionPointPropertyDialog_Succeed_Message, hostText.getText()));
            }
        }
    });

    browseButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            browseConnection();
        }
    });

    if (s3ConnectionPoint == null) {
        isNew = true;
        s3ConnectionPoint = getOrCreateConnectionPoint(getConnectionPointType());
        s3ConnectionPoint.setName(DEFAULT_NAME);
    } else {
        originalS3ConnectionPoint = s3ConnectionPoint;
    }
    loadPropertiesFrom(s3ConnectionPoint);
    connectionTested = !isNew;
}

From source file:com.arc.embeddedcdt.gui.CMainTab.java

License:Open Source License

/**
 * Show a dialog that lists all main types
 *///from ww w. j a va2  s  .c  o  m
protected void handleSearchButtonSelected() {

    if (getCProject() == null) {
        MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$
                LaunchMessages.getString("CMainTab.Enter_project_before_searching_for_program")); //$NON-NLS-1$
        return;
    }

    ILabelProvider programLabelProvider = new CElementLabelProvider() {

        public String getText(Object element) {
            if (element instanceof IBinary) {
                IBinary bin = (IBinary) element;
                StringBuffer name = new StringBuffer();
                name.append(bin.getPath().lastSegment());
                return name.toString();
            }
            return super.getText(element);
        }

        public Image getImage(Object element) {
            if (!(element instanceof ICElement)) {
                return super.getImage(element);
            }
            ICElement celement = (ICElement) element;

            if (celement.getElementType() == ICElement.C_BINARY) {
                IBinary belement = (IBinary) celement;
                if (belement.isExecutable()) {
                    return DebugUITools.getImage(IDebugUIConstants.IMG_ACT_RUN);
                }
            }

            return super.getImage(element);
        }
    };

    ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {

        public String getText(Object element) {
            if (element instanceof IBinary) {
                IBinary bin = (IBinary) element;
                StringBuffer name = new StringBuffer();
                name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$
                name.append(" - "); //$NON-NLS-1$
                name.append(bin.getPath().toString());
                return name.toString();
            }
            return super.getText(element);
        }
    };

    TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider,
            qualifierLabelProvider);
    dialog.setElements(getBinaryFiles(getCProject()));
    dialog.setMessage(LaunchMessages.getString("CMainTab.Choose_program_to_run")); //$NON-NLS-1$
    dialog.setTitle(LaunchMessages.getString("CMainTab.Program_Selection")); //$NON-NLS-1$
    dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$
    dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$
    dialog.setMultipleSelection(false);
    // dialog.set
    if (dialog.open() == Window.OK) {
        IBinary binary = (IBinary) dialog.getFirstResult();
        fProgText.setText(binary.getResource().getProjectRelativePath().toString());
    }

}

From source file:com.archimatetool.editor.actions.CheckForNewVersionAction.java

License:Open Source License

@Override
public void run() {
    try {/*from  w  ww. j  a  v  a 2s.com*/
        URL url = new URL(versionFile);
        String newVersion = getOnlineVersion(url);

        // Get this app's main version number
        String thisVersion = System.getProperty(Application.APPLICATION_VERSIONID);

        if (StringUtils.compareVersionNumbers(newVersion, thisVersion) > 0) {
            boolean reply = MessageDialog.openQuestion(null, Messages.CheckForNewVersionAction_1,
                    Messages.CheckForNewVersionAction_2 + " (" + newVersion + "). " + //$NON-NLS-1$ //$NON-NLS-2$
                            Messages.CheckForNewVersionAction_3);

            if (reply) {
                IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
                IWebBrowser browser = support.getExternalBrowser();
                if (browser != null) {
                    URL url2 = new URL(downloadPage);
                    browser.openURL(url2);
                }
            }
        } else {
            MessageDialog.openInformation(null, Messages.CheckForNewVersionAction_1,
                    Messages.CheckForNewVersionAction_4);
        }
    } catch (MalformedURLException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
        showErrorMessage(Messages.CheckForNewVersionAction_5);
        return;
    } catch (PartInitException ex) {
        ex.printStackTrace();
    }

}

From source file:com.archimatetool.editor.actions.OpenModelAction.java

License:Open Source License

@Override
public void run() {
    FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
    dialog.setFilterExtensions(new String[] { IEditorModelManager.ARCHIMATE_FILE_WILDCARD, "*.xml", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
    String path = dialog.open();//from ww  w.j av  a 2 s  .c o m
    if (path != null) {
        final File file = new File(path);

        // Check it's not already open
        IArchimateModel model = getModel(file);
        if (model != null) {
            MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.OpenModelAction_2,
                    NLS.bind(Messages.OpenModelAction_3, file.getName(), model.getName()));
            return;
        }

        BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
            public void run() {
                IEditorModelManager.INSTANCE.openModel(file);
            }
        });
    }
}

From source file:com.archimatetool.editor.diagram.actions.CreateDerivedRelationAction.java

License:Open Source License

@Override
public void run() {
    List<?> selection = getSelectedObjects();

    EditPart editPart = (EditPart) selection.get(0);
    IDiagramModelArchimateObject diagramModelObject1 = (IDiagramModelArchimateObject) editPart.getModel();
    editPart = (EditPart) selection.get(1);
    IDiagramModelArchimateObject diagramModelObject2 = (IDiagramModelArchimateObject) editPart.getModel();

    ChainList chainList1 = new ChainList(diagramModelObject1, diagramModelObject2);
    ChainList chainList2 = new ChainList(diagramModelObject2, diagramModelObject1);

    // Already has a direct relationship in both directions
    if (chainList1.hasExistingDirectRelationship() && chainList2.hasExistingDirectRelationship()) {
        MessageDialog.openInformation(getWorkbenchPart().getSite().getShell(),
                Messages.CreateDerivedRelationAction_1, Messages.CreateDerivedRelationAction_2);
        return;//from  ww w. j  a  v  a 2s.  com
    }

    // Both chains are too complicated
    if (chainList1.isTooComplicated && chainList2.isTooComplicated) {
        MessageDialog.openInformation(getWorkbenchPart().getSite().getShell(),
                Messages.CreateDerivedRelationAction_1, Messages.CreateDerivedRelationAction_3);
        return;
    }

    // No chains found, although perhaps one was too complicated...
    if (chainList1.getChains() == null && chainList2.getChains() == null) {
        if (chainList1.isTooComplicated || chainList2.isTooComplicated) {
            MessageDialog.openInformation(getWorkbenchPart().getSite().getShell(),
                    Messages.CreateDerivedRelationAction_1, Messages.CreateDerivedRelationAction_4);
        } else {
            MessageDialog.openInformation(getWorkbenchPart().getSite().getShell(),
                    Messages.CreateDerivedRelationAction_1, Messages.CreateDerivedRelationAction_5);
        }
        return;
    }

    CreateDerivedConnectionDialog dialog = new CreateDerivedConnectionDialog(
            getWorkbenchPart().getSite().getShell(), chainList1, chainList2);

    if (dialog.open() == IDialogConstants.OK_ID) {
        List<IRelationship> chain = dialog.getSelectedChain();
        if (chain != null) {
            ChainList chainList = dialog.getSelectedChainList();
            EClass relationshipClass = DerivedRelationsUtils.getWeakestType(chain);
            IRelationship relation = (IRelationship) IArchimateFactory.eINSTANCE.create(relationshipClass);
            CommandStack stack = (CommandStack) getWorkbenchPart().getAdapter(CommandStack.class);
            stack.execute(new CreateDerivedConnectionCommand(chainList.srcDiagramObject,
                    chainList.tgtDiagramObject, relation));
        }
    }
}

From source file:com.archimatetool.editor.diagram.actions.ExportAsImageToClipboardAction.java

License:Open Source License

@Override
public void run() {
    BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
        @Override/*from  w  w  w  .j a  v  a  2s.  c  o  m*/
        public void run() {
            Image image = null;
            Clipboard cb = null;

            try {
                image = DiagramUtils.createImage(fDiagramViewer, 1, 10);
                ImageData imageData = image.getImageData();

                cb = new Clipboard(Display.getDefault());
                cb.setContents(new Object[] { imageData }, new Transfer[] { ImageTransfer.getInstance() });

                MessageDialog.openInformation(Display.getDefault().getActiveShell(),
                        Messages.ExportAsImageToClipboardAction_1, Messages.ExportAsImageToClipboardAction_2);

            } catch (Throwable ex) { // Catch Throwable for SWT errors
                ex.printStackTrace();

                MessageDialog.openError(Display.getCurrent().getActiveShell(),
                        Messages.ExportAsImageToClipboardAction_1,
                        Messages.ExportAsImageToClipboardAction_3 + " " + ex.getMessage()); //$NON-NLS-1$
            } finally {
                if (image != null && !image.isDisposed()) {
                    image.dispose();
                }

                if (cb != null) {
                    cb.dispose(); // If memory is low this will crash the JVM
                }
            }
        }
    });
}

From source file:com.archimatetool.editor.Logger.java

License:Open Source License

/**
 * Convenience method to open a standard information dialog
 * //from  ww w  . java  2s  . c  om
 * @param message
 *            the message
 */
public static void showInformationDialog(String message) {
    MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Information", message); //$NON-NLS-1$
}