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

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

Introduction

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

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:com.nokia.s60tools.memspy.ui.UiUtils.java

License:Open Source License

/**
 * Advises used to install MemSpy launcher component and provides necessary action alternatives.
 * @param errorMessage error message/*  w w w.  j  av  a 2  s.  c  o  m*/
 */
private static void adviceUserToInstallLauncherComponent(final String errorMessage) {

    MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(),
            IMemSpyTraceListener.ERROR_MEMSPY, null, errorMessage, MessageDialog.ERROR,
            new String[] { "Install RnD-signed MemSpy Launcher", "Open sis-file's directory in Explorer",
                    "Don't install" },
            1);
    dialog.open();

    String launcherFolder = MemSpyPlugin.getDefault().getMemspyLauncherBinDir();
    String launcherLocation = launcherFolder + File.separatorChar
            + MEM_SPY_LAUNCHER_S60_50_RN_D_SIGNED_SIS_FILE_NAME;

    // if user wants to install launcher:
    if (dialog.getReturnCode() == 0) {
        // find program for xls-filetype
        Program p = Program.findProgram(".sis");
        // if found, launch it.
        if (p != null) {
            // Check that found program was Nokia PC Suite.
            p.execute(launcherLocation);
        } else {
            Status status = new Status(IStatus.ERROR, MemSpyPlugin.PLUGIN_ID, 0,
                    "Unable to locate PC suite or other suitable software for installing .sis -file from computer. You can try installing MemSpy launcher manually from:\n"
                            + launcherLocation,
                    null);
            ErrorDialog.openError(Display.getCurrent().getActiveShell(), "MemSpy Error", null, status);
        }

    }

    // Open directory in explorer
    else if (dialog.getReturnCode() == 1) {
        try {
            String directory = Platform.getConfigurationLocation().getURL().getFile();
            directory = directory.substring(1);
            Runtime.getRuntime().exec("explorer " + launcherFolder);
        } catch (IOException e) {
            Status status = new Status(IStatus.ERROR, MemSpyPlugin.PLUGIN_ID, 0, "Unable to open Explorer",
                    null);
            ErrorDialog.openError(Display.getCurrent().getActiveShell(), IMemSpyTraceListener.ERROR_MEMSPY,
                    null, status);
            e.printStackTrace();
        }
    }

}

From source file:com.nokia.s60tools.stif.scripteditor.editors.ScriptEditor.java

License:Open Source License

/**
 * Reads editor mode from file persistant property
 * @return editor mode /* www.j  ava 2 s  . c om*/
 */
private EditorMode queryEditorMode() {
    EditorMode mode = null;
    String dialogTitle = "Choose the proper editor mode";
    String modeQuestion = "Choose the proper editor mode (it will be possible to change the mode later)";
    String scripterButtonText = "test scripter";
    String combinerButtonText = "test combiner";
    MessageDialog modeDialog = new MessageDialog(
            org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dialogTitle, null,
            modeQuestion, 0, new String[] { scripterButtonText, combinerButtonText }, 0);
    int numericChosenMode = modeDialog.open();
    if (numericChosenMode == 0) {
        mode = EditorMode.scripterMode;
    } else {
        mode = EditorMode.combinerMode;
    }

    return mode;
}

From source file:com.nokia.sdt.symbian.ui.appeditor.ApplicationEditor.java

License:Open Source License

/**
 * Because of the app editor's synchronize on save behavior we need to customize
 * the close->ask save changes flow. If the user says "yes" to the built-in "Save changes"
 * query, the editor is definitely going to close. But our "confirm application changes" dialog
 * has a cancel. If they cancel there the changes would be thrown away
 *///from   w w w  .java  2s .  c om
public int promptToSaveOnClose() {
    if (!isDirty()) {
        return NO;
    }
    PreflightInfo pi = calcPreflightInfo(true);
    if (pi.changeFlags == 0 || pi.dialogMessage == null) {
        return DEFAULT;
    }

    String title = Messages.getString("ApplicationEditor.saveDialogTitle"); //$NON-NLS-1$
    String labels[];
    if (pi.preSaveOtherEditorsNeeded) {
        labels = new String[] { Messages.getString("ApplicationEditor.saveAllButton"), //$NON-NLS-1$
                Messages.getString("ApplicationEditor.dontSaveButton"), //$NON-NLS-1$
                Messages.getString("ApplicationEditor.cancelButton") }; //$NON-NLS-1$
    } else {
        labels = new String[] { Messages.getString("ApplicationEditor.saveButton"), //$NON-NLS-1$
                Messages.getString("ApplicationEditor.dontSaveButton"), //$NON-NLS-1$
                Messages.getString("ApplicationEditor.cancelButton") }; //$NON-NLS-1$
    }
    MessageDialog dialog = new MessageDialog(getEditorSite().getShell(), title, null, pi.dialogMessage,
            MessageDialog.QUESTION, labels, YES);
    int result = dialog.open();
    if (result == YES) {
        // set after user approves actions, so we don't requery from doSave
        closingEditorPreflightInfo = pi;
    }
    return result;
}

From source file:com.nokia.sdt.uidesigner.events.EventCommands.java

License:Open Source License

public static void navigateToHandlerCode(EventPage page, IEventBinding binding, boolean isNewBinding) {
    IEventDescriptor eventDescriptor = binding.getEventDescriptor();
    IStatus status = eventDescriptor.gotoHandlerCode(binding, isNewBinding);
    if (status != null) {
        if (!isNewBinding) {
            // Hmm, an error.  It could be the data model was not saved.
            // It may just be a problem in the component's sourcegen, hence
            // the fallthrough to the descriptive error later.
            MessageDialog dialog = new MessageDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    Messages.getString("EventCommands.Error"), null, //$NON-NLS-1$
                    Messages.getString("EventCommands.NoEventHandlerFound"), //$NON-NLS-1$
                    MessageDialog.QUESTION,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, //$NON-NLS-1$ //$NON-NLS-2$
                    0);//from  w  ww .  j  av  a2  s.c om
            int result = dialog.open();
            if (result == MessageDialog.OK) {
                if (page.saveDataModel()) {
                    status = eventDescriptor.gotoHandlerCode(binding, isNewBinding);
                }
            }
        }
        if (status != null) {
            Logging.log(UIDesignerPlugin.getDefault(), status);
        }
    }

}

From source file:com.nokia.tools.s60.editor.actions.CopyImageAction.java

License:Open Source License

@Override
public void doRun(Object sel) {

    if (clip == null)
        clip = Toolkit.getDefaultToolkit().getSystemClipboard();

    IContentData data = getContentData(sel);
    ISkinnableEntityAdapter skAdapter = (ISkinnableEntityAdapter) data
            .getAdapter(ISkinnableEntityAdapter.class);

    if (sel instanceof IAnimationFrame) {
        if (isMaskNode()) {
            IAnimationFrame frame = (IAnimationFrame) sel;
            if (frame.getMaskFile() != null) {
                ClipboardHelper.copyImageToClipboard(clip, frame.getMaskFile());
            } else {
                ClipboardHelper.copyImageToClipboard(clip, frame.getMask());
            }//  ww  w  .  j  a v a 2  s  .com
        } else if (isImageNode()) {
            IAnimationFrame frame = (IAnimationFrame) sel;
            if (frame.getImageFile() != null) {
                ClipboardHelper.copyImageToClipboard(clip, frame.getImageFile());
            } else {
                ClipboardHelper.copyImageToClipboard(clip, frame.getRAWImage(false));
            }
        } else {
            ((IAnimationFrame) sel).copyImageToClipboard(clip);
        }
        return;
    }

    // when layer is selected in tree
    if (sel instanceof ILayer) {

        try {
            ILayer l = (ILayer) sel;
            if (isLayerNode() || isNodeOfType(AbstractAction.TYPE_PART)) {

                if (skAdapter instanceof S60SkinnableEntityAdapter) {
                    // copy image + mask
                    l.copyImageToClipboard(clip);
                }
            } else if (isImageNode()) {
                // copy image only
                Object param = l.getFileName(false) == null ? l.getRAWImage() : l.getFileName(true);
                ClipboardHelper.copyImageToClipboard(clip, param);
            } else if (isMaskNode()) {
                // copy mask only
                if (l.getMaskFileName(true) != null) {
                    ClipboardHelper.copyImageToClipboard(clip, l.getMaskFileName(true));
                } else {
                    ClipboardHelper.copyImageToClipboard(clip, l.getMaskImage());
                }
            } else {
                l.copyImageToClipboard(clip);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return;
    }

    IImageHolder holder = getImageHolder(sel);
    if (holder != null) {
        holder.copyImageToClipboard(clip);
        return;
    }

    // IContentData data = getContentData(sel);

    if (data != null) {

        ISkinnableContentDataAdapter skinableAdapter = (ISkinnableContentDataAdapter) data
                .getAdapter(ISkinnableContentDataAdapter.class);
        if (skinableAdapter != null) {
            skinableAdapter.copyToClipboard(null);
            return;
        }

        /*
         * ISkinnableEntityAdapter skAdapter = (ISkinnableEntityAdapter)
         * data .getAdapter(ISkinnableEntityAdapter.class);
         */
        if (skAdapter != null) {

            if (skAdapter.hasMask()) {

            }

            if (skAdapter instanceof S60SkinnableEntityAdapter)
                skAdapter.copyImageToClipboard(clip);

            else {
                copyIdAndFileToClipboard(data, skAdapter);
            }
            // if (skAdapter.isNinePiece()) {
            if (skAdapter.isMultiPiece()) {
                // copy from 9-piece was performed, show info dialog
                IPreferenceStore store = S60WorkspacePlugin.getDefault().getPreferenceStore();
                Boolean showState = store.getBoolean(skAdapter.getCopyPieceInfo());
                // .getBoolean(IMediaConstants.NINE_PIECE_COPY_INFO);
                if (showState || silent)
                    return;

                IBrandingManager branding = BrandingExtensionManager.getBrandingManager();
                Image image = null;
                if (branding != null) {
                    image = branding.getIconImageDescriptor().createImage();
                }
                MessageDialog messageDialog = new MessageDialogWithCheckBox(
                        PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                        Messages.CopyAction_9piece_title, image, MultiPieceManager.getCopyMessageText(),
                        // MultipieceHelper.getCopyMessageText(),
                        Messages.CopyAction_9piece_checkbox, false, null, null, null, 2,
                        new String[] { IDialogConstants.OK_LABEL }, 0);
                messageDialog.open();
                if (image != null) {
                    image.dispose();
                }

                // store.setValue(IMediaConstants.NINE_PIECE_COPY_INFO,
                store.setValue(skAdapter.getCopyPieceInfo(),
                        ((MessageDialogWithCheckBox) messageDialog).getCheckBoxValue());
            }
        }
        return;
    }

    ILayer layer = getLayer(true, sel);
    if (layer != null) {
        layer.copyImageToClipboard(clip);
    }
}

From source file:com.nokia.tools.s60.editor.ui.dialogs.WarningMessageDialogs.java

License:Open Source License

public static void noPreviewAvailableMessageBox() {
    IPreferenceStore store = S60WorkspacePlugin.getDefault().getPreferenceStore();
    Boolean showState = store.getBoolean(IS60IDEConstants.PREF_NO_PREVIEW_HIDE_MESSAGEBOX);
    if (showState)
        return;//from w ww.  j a va  2s.  c  o  m

    IBrandingManager branding = BrandingExtensionManager.getBrandingManager();
    Image image = null;
    if (branding != null) {
        image = branding.getIconImageDescriptor().createImage();
    }
    MessageDialog messageDialog = new MessageDialogWithCheckBox(
            PlatformUI.getWorkbench().getDisplay().getActiveShell(), ViewMessages.IconView_Preview_MsgBox_Title,
            image, ViewMessages.IconView_Preview_MsgBox_Message, ViewMessages.IconView_Preview_MsgBox_ShowAgain,
            false, null, null, null, 2, new String[] { IDialogConstants.OK_LABEL }, 0);

    messageDialog.open();

    if (image != null) {
        image.dispose();
    }

    store.setValue(IS60IDEConstants.PREF_NO_PREVIEW_HIDE_MESSAGEBOX,
            ((MessageDialogWithCheckBox) messageDialog).getCheckBoxValue());

}

From source file:com.nokia.tools.s60.views.ColorsViewPage.java

License:Open Source License

public void fillTable() {
    for (ColorQuadruple input : inputs) {
        if (!table.isDisposed()) {
            final Composite labelComp = new Composite(table, SWT.NONE);
            GridLayout gl = new GridLayout();
            gl.marginWidth = gl.marginHeight = gl.horizontalSpacing = gl.verticalSpacing = 0;
            labelComp.setLayout(gl);/*from  w ww  .ja v  a2 s . com*/
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.grabExcessHorizontalSpace = true;
            gd.horizontalSpan = 3;
            gd.verticalIndent = 5;
            labelComp.setLayoutData(gd);
            labelComp.setBackground(labelComp.getParent().getBackground());

            final Text label = new Text(labelComp, SWT.NONE);
            label.setEditable(false);
            label.setData(input);
            gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.grabExcessHorizontalSpace = true;
            gd.grabExcessVerticalSpace = true;
            label.setLayoutData(gd);
            label.setFont(ItalicFont);

            label.setText(input.getQuadrupleName());

            label.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseDown(MouseEvent e) {
                    if (e.button == 1) {
                        label.setFont(null);
                        label.setEditable(true);
                        labelComp.setBackground(ColorConstants.white);
                    }
                }
            });

            label.addMouseTrackListener(new MouseTrackListener() {
                public void mouseEnter(MouseEvent e) {

                }

                public void mouseExit(MouseEvent e) {
                    label.setFont(ItalicFont);
                    label.setEditable(false);
                    // this will call the focus lost event
                    label.setEnabled(false);
                    if (!label.isDisposed()) {
                        label.setEnabled(true);
                        labelComp.setBackground(labelComp.getParent().getBackground());
                    }
                }

                public void mouseHover(MouseEvent e) {

                }
            });

            label.addTraverseListener(new TraverseListener() {
                public void keyTraversed(TraverseEvent e) {
                    if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
                        ColorQuadruple quad = (ColorQuadruple) label.getData();

                        if (e.detail == SWT.TRAVERSE_ESCAPE) {
                            label.setText(quad.getQuadrupleName());
                        } else if (e.detail == SWT.TRAVERSE_RETURN) {
                            //the focus lost will happen
                            // after this
                            // if (!updateName(quad, label.getText())) {
                            // label.setText(quad.getQuadrupleName());
                            // }
                        }

                        label.setFont(ItalicFont);
                        label.setEditable(false);
                        // this will call the focus lost event
                        label.setEnabled(false);
                        if (!label.isDisposed()) {
                            label.setEnabled(true);
                            labelComp.setBackground(labelComp.getParent().getBackground());
                        }
                    }
                }
            });

            label.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(FocusEvent e) {
                    label.setFont(ItalicFont);
                    label.setEditable(false);
                    label.setEnabled(false);
                    label.setEnabled(true);
                    labelComp.setBackground(labelComp.getParent().getBackground());
                    ColorQuadruple quad = (ColorQuadruple) label.getData();
                    if (!updateName(quad, label.getText())) {
                        label.setText(quad.getQuadrupleName());
                    }
                }

                @Override
                public void focusGained(FocusEvent e) {
                    label.setFont(null);
                    label.setEditable(true);
                    labelComp.setBackground(ColorConstants.white);
                }
            });

            final Canvas quadrupleComposite = new Canvas(table, SWT.BORDER);
            quadrupleComposite.addPaintListener(new PaintListener() {
                public void paintControl(PaintEvent e) {
                    GC gc = e.gc;
                    gc.setBackground(ColorConstants.white);
                    // gc.setBackgroundPattern(BG_PATTERN);
                    gc.fillRectangle(0, 0, quadrupleComposite.getSize().x, quadrupleComposite.getSize().y);
                }
            });
            gl = new GridLayout(4, false);
            gl.marginWidth = 2;
            gl.marginHeight = gl.horizontalSpacing = gl.verticalSpacing = 0;
            quadrupleComposite.setLayout(gl);
            gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.heightHint = rowHeight;
            gd.verticalAlignment = SWT.CENTER;
            quadrupleComposite.setLayoutData(gd);

            Canvas q1 = new Canvas(quadrupleComposite, SWT.NONE);
            q1.setData(input);
            gd = new GridData();
            gd.grabExcessVerticalSpace = true;
            gd.widthHint = QuadrupleColumnWidth;
            gd.heightHint = rowHeight;
            gd.verticalAlignment = SWT.CENTER;
            q1.setLayoutData(gd);
            q1.setBackground(q1.getParent().getBackground());
            addPaintListener(0, q1);
            addDragSource(0, q1);
            addQuadrupleMouseListener(0, q1);
            createTooltip(0, q1);

            Canvas q2 = new Canvas(quadrupleComposite, SWT.NONE);
            q2.setData(input);
            gd = new GridData();
            gd.grabExcessVerticalSpace = true;
            gd.widthHint = QuadrupleColumnWidth;
            gd.heightHint = rowHeight;
            gd.verticalAlignment = SWT.CENTER;
            gd.horizontalIndent = 6;
            q2.setLayoutData(gd);
            q2.setBackground(q2.getParent().getBackground());
            addPaintListener(1, q2);
            addDragSource(1, q2);
            addQuadrupleMouseListener(1, q2);
            createTooltip(1, q2);

            Canvas q3 = new Canvas(quadrupleComposite, SWT.NONE);
            q3.setData(input);
            gd = new GridData();
            gd.grabExcessVerticalSpace = true;
            gd.widthHint = QuadrupleColumnWidth;
            gd.heightHint = rowHeight;
            gd.verticalAlignment = SWT.CENTER;
            q3.setLayoutData(gd);
            q3.setBackground(q3.getParent().getBackground());
            addPaintListener(2, q3);
            addDragSource(2, q3);
            addQuadrupleMouseListener(2, q3);
            createTooltip(2, q3);

            Canvas q4 = new Canvas(quadrupleComposite, SWT.NONE);
            q4.setData(input);
            gd = new GridData();
            gd.grabExcessVerticalSpace = true;
            gd.widthHint = QuadrupleColumnWidth;
            gd.heightHint = rowHeight;
            gd.verticalAlignment = SWT.CENTER;
            q4.setLayoutData(gd);
            q4.setBackground(q4.getParent().getBackground());
            addPaintListener(3, q4);
            addDragSource(3, q4);
            addQuadrupleMouseListener(3, q4);
            createTooltip(3, q4);

            final Button b1 = new Button(table, SWT.FLAT);
            b1.setData(input);
            gd = new GridData();
            gd.grabExcessHorizontalSpace = false;
            gd.heightHint = 20;
            gd.widthHint = 20;
            gd.verticalAlignment = SWT.CENTER;
            b1.setLayoutData(gd);
            b1.setBackground(b1.getParent().getBackground());
            b1.setImage(CopyGroupImage);
            b1.setToolTipText("Copy Color Group as a new Group");

            b1.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    CommandStack stck = (CommandStack) sourceEditor.getAdapter(CommandStack.class);

                    Command cmd = new Command() {
                        @Override
                        public boolean canExecute() {
                            return true;
                        }

                        @Override
                        public boolean canUndo() {
                            return false;
                        }

                        @Override
                        public void execute() {
                            ColorQuadruple quad = (ColorQuadruple) b1.getData();
                            ColorQuadruple newQuad = new ColorQuadruple("copy of " + quad.getQuadrupleName());
                            ColorGroups grps = getColorGroups();

                            int idx = 1;
                            while (grps.getGroupByName(newQuad.getQuadrupleName()) != null) {
                                idx++;
                                newQuad = new ColorQuadruple(
                                        "copy (" + idx + ") of " + quad.getQuadrupleName());
                            }

                            for (int i = 0; i < quad.getRgbList().size(); i++) {
                                RGB rgb = quad.getRgbList().get(i);
                                // (add group notifies this observer about
                                // adding
                                // group)
                                if (i == 0) {
                                    if (grps.addGroup(newQuad.getQuadrupleName(), rgb) == true) {
                                        // newQuad.addRGB(rgb, false);
                                        // inputs.add(newQuad);
                                    }
                                } else {
                                    String newName = newQuad.getQuadrupleName() + " tone" + i;
                                    if (grps.addGroup(newName, rgb) == true) {
                                        // newQuad.addRGB(rgb, false);
                                        ColorGroup added = grps.getGroupByName(newName);
                                        added.setParentGroupName(newQuad.getQuadrupleName());
                                    }
                                }
                            }
                        }
                    };

                    if (stck != null) {
                        stck.execute(cmd);
                    } else {
                        cmd.execute();
                    }
                }
            });

            final Button b2 = new Button(table, SWT.FLAT);
            b2.setData(input);
            gd = new GridData();
            gd.grabExcessHorizontalSpace = false;
            gd.heightHint = 20;
            gd.widthHint = 20;
            gd.verticalAlignment = SWT.CENTER;
            b2.setLayoutData(gd);
            b2.setBackground(b2.getParent().getBackground());
            b2.setImage(DeleteGroupImage);
            b2.setToolTipText("Delete Color Group");

            b2.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    CommandStack stck = (CommandStack) sourceEditor.getAdapter(CommandStack.class);

                    Command cmd = new Command() {
                        @Override
                        public boolean canExecute() {
                            return true;
                        }

                        @Override
                        public boolean canUndo() {
                            return false;
                        }

                        @Override
                        public void execute() {
                            ColorQuadruple quad = (ColorQuadruple) b2.getData();
                            IBrandingManager branding = BrandingExtensionManager.getBrandingManager();
                            Image image = null;
                            if (branding != null) {
                                image = branding.getIconImageDescriptor().createImage();
                            }
                            MessageDialog dialog = new MessageDialog(
                                    PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                                    ViewMessages.RefColors_Delete_MsgBox_Title, image,
                                    MessageFormat.format(ViewMessages.RefColors_Delete_MsgBox_Message,
                                            new Object[] { quad.getQuadrupleName() }),
                                    3, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL },
                                    1);
                            dialog.create();
                            image.dispose();
                            if (dialog.open() == 0) {
                                inputs.remove(quad);
                                ColorGroups grps = getColorGroups();
                                grps.removeGroup(quad.getQuadrupleName());
                                for (int i = 1; i <= 3; i++) {
                                    // (remove group notifies this observer
                                    // about group
                                    // removal
                                    grps.removeGroup(quad.getQuadrupleName() + " tone" + i);
                                }

                            }
                        }
                    };

                    if (stck != null) {
                        stck.execute(cmd);
                    } else {
                        cmd.execute();
                    }
                }
            });
        }
    }
}

From source file:com.nokia.tools.screen.ui.actions.NewPackageAction.java

License:Open Source License

public void run() {
    final IEditorPart currentEditor = EclipseUtils.getActiveSafeEditor();

    if (currentEditor == null)
        return;/*w w  w.  j  a v  a 2  s .c o m*/

    if (currentEditor.isDirty()) {
        boolean saveWithoutConfirm = false;
        IPreferenceStore store = UiPlugin.getDefault().getPreferenceStore();
        saveWithoutConfirm = store.getBoolean(IScreenConstants.PREF_SAVE_BEFORE_PACKAGING_ASK);
        if (!saveWithoutConfirm) {
            IBrandingManager branding = BrandingExtensionManager.getBrandingManager();
            Image image = null;
            if (branding != null) {
                image = branding.getIconImageDescriptor().createImage();
            }
            MessageDialog messageDialog = new MessageDialogWithCheckBox(
                    PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                    Messages.NewPackageAction_Save_MsgBox_Title, image,
                    Messages.NewPackageAction_Save_MsgBox_Message,
                    Messages.NewPackageAction_Save_MsgBox_Confirmation_text, saveWithoutConfirm, null, null,
                    null, 3, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
            messageDialog.open();
            if (image != null) {
                image.dispose();
            }
            store.setValue(IScreenConstants.PREF_SAVE_BEFORE_PACKAGING_ASK,
                    ((MessageDialogWithCheckBox) messageDialog).getCheckBoxValue());

            if (messageDialog.getReturnCode() != 0)
                return;
        }
        try {
            new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell()).run(false, false,
                    new IRunnableWithProgress() {

                        /*
                         * (non-Javadoc)
                         * 
                         * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
                         */
                        public void run(IProgressMonitor monitor)
                                throws InvocationTargetException, InterruptedException {
                            currentEditor.doSave(monitor);
                        }
                    });
        } catch (Exception e) {
            UiPlugin.error(e);
        }
        performPackaging();

    } else
        performPackaging();
}

From source file:com.nokia.tools.screen.ui.dialogs.MessageDialogWithCheckBox.java

License:Open Source License

/**
 * Convenience method to open a customized messagebox with normal message
 * and optionally any compinations of message with a link to preferences,
 * checkbox with text and access to help system via Help -button.
 * /*from  w  ww . j a  va 2 s  .  co  m*/
 * @param parent the parent shell of the dialog, or <code>null</code> if
 *        none
 * @param title the dialog's title, or <code>null</code> if none
 * @param message the message
 * @param chkButtonMessage the message for the checkbox, or
 *        <code>null</code> if none
 * @param chkButtonState the initial state for the checkbox
 * @param helpID help ID, or <code>null</code> if none
 * @param linkMessage the message including a link, or <code>null</code>
 *        if none
 * @param linkAddress the preference address for the link, or
 *        <code>null</code> if none
 * @return <code>true</code> if the user presses the OK button,
 *         <code>false</code> otherwise
 */
public static boolean openQuestion(Shell parent, String title, String message, String chkButtonMessage,
        boolean chkButtonState, String helpID, String linkMessage, String linkAddress) {
    MessageDialog dialog = new MessageDialogWithCheckBox(parent, title, null, message, chkButtonMessage,
            chkButtonState, helpID, linkMessage, linkAddress, QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    return dialog.open() == 0;
}

From source file:com.nokia.tools.screen.ui.utils.FileChangeWatchThread.java

License:Open Source License

public static void displayThirdPartyEditorMisssingErrorMessageBox() {
    IBrandingManager branding = BrandingExtensionManager.getBrandingManager();
    Image image = null;//from w w w  .ja  va 2s  . c  om
    if (branding != null) {
        image = branding.getIconImageDescriptor().createImage();
    }
    MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
            Messages.FileChangeWatchThread_editorSettingsError, image,
            Messages.FileChangeWatchThread_editorError, 1,
            new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
    dialog.open();
    if (image != null) {
        image.dispose();
    }
}