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

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

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog 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:org.csstudio.email.ui.EMailDialogDemo.java

License:Open Source License

@Test
public void testEMailDialogWithOutImage() {
    final Shell shell = new Shell();

    final Dialog dlg = new EMailSenderDialog(shell, host, from, to, "Test", "This is a test", null);
    dlg.open();
}

From source file:org.csstudio.sds.ui.internal.runmode.ChangeLayerVisibilityAction.java

License:Open Source License

/**
 * {@inheritDoc}/*  w  w  w .  jav  a 2s. c om*/
 */
@Override
public void run() {
    EditPart contents = _viewer.getRootEditPart().getContents();
    if (contents instanceof DisplayEditPart) {
        DisplayEditPart displayEditPart = (DisplayEditPart) contents;
        LayerSupport layerSupport = displayEditPart.getContainerModel().getLayerSupport();
        Dialog dialog = new LayerDialog(_viewer.getControl().getShell(), layerSupport);
        dialog.open();
    }
}

From source file:org.dawb.passerelle.common.remote.RemoteWorkbenchImpl.java

License:Open Source License

@Override
public Map<String, String> createUserInput(final UserInputBean bean) throws Exception {

    if (!PlatformUI.isWorkbenchRunning())
        return bean.getScalarValues();

    if (bean.isSilent())
        return bean.getScalarValues();

    final BlockingQueue<Map<String, String>> queue = new LinkedBlockingQueue<Map<String, String>>(1);

    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

        @Override/*from  w  ww  . j  a  v  a2 s.c  om*/
        public void run() {
            try {

                final IUserInputService service = (IUserInputService) ServiceManager
                        .getService(IUserInputService.class);
                final RemoveWorkbenchPart part = service.openUserInputPart(bean.getPartName(), bean.isDialog());

                if (bean.getPartName() != null)
                    part.setPartName(bean.getPartName());
                part.setQueue(queue);
                part.setConfiguration(bean.getConfigurationXML());
                part.setValues(bean.getScalarValues());

                if (part instanceof Dialog) {
                    Dialog dialog = (Dialog) part;
                    dialog.open();

                    if (dialog.getReturnCode() != Dialog.OK) {
                        queue.add(Collections.EMPTY_MAP);
                    }
                }

                return; // Queue will be notified when they have chosen

            } catch (PartInitException e) {
                // Ignored.
            } catch (Exception e) {
                logger.error("Cannot open editor ", e);
                queue.add(Collections.EMPTY_MAP);
                return;
            }

            // If we drop through to here do nothing
            // adding this to the queue makes the take()
            // call return straight away.
            if (bean.getScalarValues() != null) {
                queue.add(bean.getScalarValues());
            } else {
                queue.add(Collections.EMPTY_MAP);
            }
        }
    });

    final Map<String, String> newValues = queue.take(); // Blocks until user edits this!
    return newValues;
}

From source file:org.eclipse.babel.editor.actions.NewLocaleAction.java

License:Open Source License

public void run() {
    // created choose locale dialog
    Dialog localeDialog = new Dialog(editor.getSite().getShell()) {
        LocaleSelector selector;/*from w w w  . jav  a  2s  .  c  om*/

        @Override
        protected void configureShell(Shell newShell) {
            super.configureShell(newShell);
            newShell.setText("Add new local");
        }

        @Override
        protected Control createDialogArea(Composite parent) {
            Composite comp = (Composite) super.createDialogArea(parent);
            selector = new LocaleSelector(comp);
            return comp;
        }

        @Override
        protected void okPressed() {
            // add local to bundleGroup
            MessagesBundleGroup bundleGroup = editor.getBundleGroup();
            Locale newLocal = selector.getSelectedLocale();

            // exists local already?
            boolean existsLocal = false;
            Locale[] locales = bundleGroup.getLocales();
            for (Locale locale : locales) {
                if (locale == null) {
                    if (newLocal == null) {
                        existsLocal = true;
                        break;
                    }
                } else if (locale.equals(newLocal)) {
                    existsLocal = true;
                    break;
                }
            }

            if (!existsLocal)
                bundleGroup.addMessagesBundle(newLocal);

            super.okPressed();
        }
    };
    // open dialog
    localeDialog.open();
}

From source file:org.eclipse.babel.runtime.actions.LocalizeAction.java

License:Open Source License

/**
 * The action has been activated. The argument of the
 * method represents the 'real' action sitting
 * in the workbench UI./*from   ww  w. j  a v a2 s . co  m*/
 * @see IWorkbenchWindowActionDelegate#run
 */
public void run(IAction action) {
    IWorkbenchPart activePart = window.getActivePage().getActivePart();

    ITranslatableText tabTitle;
    if (activePart instanceof IEditorPart) {
        tabTitle = TranslatableNLS.bind(Messages.LocalizeDialog_TabTitle_EditorPart, activePart.getTitle()); //$NON-NLS-1$
    } else if (activePart instanceof IViewPart) {
        tabTitle = TranslatableNLS.bind(Messages.LocalizeDialog_TabTitle_ViewPart, activePart.getTitle()); //$NON-NLS-1$
    } else {
        tabTitle = TranslatableNLS.bind(Messages.LocalizeDialog_TabTitle_OtherPart, activePart.getTitle()); //$NON-NLS-1$
    }

    ITranslatableSet languageSet = (ITranslatableSet) activePart.getAdapter(ITranslatableSet.class);

    Dialog dialog = new LocalizeDialog(window.getShell(), tabTitle, languageSet,
            Activator.getDefault().getMenuTextSet());
    dialog.open();
}

From source file:org.eclipse.babel.runtime.dialogs.LocalizableTrayDialog.java

License:Open Source License

protected void localizationPressed() {
    Dialog dialog = new LocalizeDialog(getShell(),
            TranslatableNLS.bind(Messages.LocalizeDialog_Title_DialogPart, getShell().getText()), languageSet,
            Activator.getDefault().getMenuTextSet());
    dialog.open();
}

From source file:org.eclipse.babel.runtime.handlers.LocalizeHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    IWorkbenchPart activePart = window.getActivePage().getActivePart();

    ITranslatableText tabTitle;/*from ww  w .ja v a  2  s .c  om*/
    ITranslatableSet languageSet;
    if (activePart != null) {
        if (activePart instanceof IEditorPart) {
            tabTitle = TranslatableNLS.bind(Messages.LocalizeDialog_TabTitle_EditorPart, activePart.getTitle()); //$NON-NLS-1$
        } else if (activePart instanceof IViewPart) {
            tabTitle = TranslatableNLS.bind(Messages.LocalizeDialog_TabTitle_ViewPart, activePart.getTitle()); //$NON-NLS-1$
        } else {
            // When can this happen?
            tabTitle = TranslatableNLS.bind(Messages.LocalizeDialog_TabTitle_OtherPart, activePart.getTitle()); //$NON-NLS-1$
        }
        languageSet = (ITranslatableSet) activePart.getAdapter(ITranslatableSet.class);
    } else {
        // No view or editor is active
        tabTitle = null;
        languageSet = null;
    }

    Dialog dialog = new LocalizeDialog(window.getShell(), tabTitle, languageSet,
            Activator.getDefault().getMenuTextSet());
    dialog.open();

    return null;
}

From source file:org.eclipse.birt.report.designer.internal.ui.command.ImportCSSHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    super.execute(event);

    Dialog dialog = new BaseWizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
            new SelectCssStyleWizard(getSelection()));
    dialog.open();

    return Boolean.TRUE;
}

From source file:org.eclipse.birt.report.designer.internal.ui.command.ImpotCSSStyleHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    boolean retBoolean = true;
    super.execute(event);

    Dialog dialog = new BaseWizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
            new SelectCssStyleWizard(getSelection()));
    dialog.open();

    return Boolean.valueOf(retBoolean);
}

From source file:org.eclipse.birt.report.designer.internal.ui.views.actions.ImportCSSStyleAction.java

License:Open Source License

public void run() {
    Dialog dialog = new BaseWizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
            new SelectCssStyleWizard(getSelection()));
    dialog.open();

    // FileDialog fd = new FileDialog( PlatformUI.getWorkbench( )
    // .getDisplay( )
    // .getActiveShell( ), SWT.OPEN );
    // fd.setFilterExtensions( new String[]{
    // "*.css"} );//$NON-NLS-1$
    // fd.setFilterNames( new String[]{
    // "CSS Style file" + " (css)" //$NON-NLS-1$ //$NON-NLS-2$
    // } );// ww w .j av a 2 s .  com
    //
    // String file = fd.open( );
    // if ( file != null )
    // {
    // Dialog dialog = new ImportCSSStyleDialog( "Import CSS Style", file );
    // //$NON-NLS-1$
    // dialog.open( );
    // }
    //
}