Search in sources :

Example 1 with PopupDialog

use of org.eclipse.jface.dialogs.PopupDialog in project liferay-ide by liferay.

the class InitConfigureProjectPage method createSpecialDescriptor.

@Override
public void createSpecialDescriptor(Composite parent, int style) {
    Composite fillLayoutComposite = SWTUtil.createComposite(parent, 2, 2, GridData.FILL_HORIZONTAL);
    final StringBuilder descriptorBuilder = new StringBuilder("The initial step will be to upgrade to Liferay Workspace or Liferay Plugins SDK 7.0. ");
    descriptorBuilder.append("For more details, please see <a>dev.liferay.com</a>.");
    String url = "https://dev.liferay.com/develop/tutorials";
    SWTUtil.createHyperLink(fillLayoutComposite, SWT.WRAP, descriptorBuilder.toString(), 1, url);
    final StringBuilder extensionDecBuilder = new StringBuilder("The first step will help you convert a Liferay Plugins SDK 6.2 to Liferay Plugins SDK 7.0 or to Liferay Workspace.\n");
    extensionDecBuilder.append("Click the \"Import Projects\" button to import your project into the Eclipse workspace ");
    extensionDecBuilder.append("(this process maybe need 5-10 minutes for bundle initialization).\n");
    extensionDecBuilder.append("Note:\n");
    extensionDecBuilder.append("       To save time, downloading the 7.0 ivy cache locally could be a good choice when upgrading to Liferay Plugins SDK 7. \n");
    extensionDecBuilder.append("       Theme and Ext projects will be ignored since this tool does not support them currently. \n");
    Label image = new Label(fillLayoutComposite, SWT.WRAP);
    image.setImage(loadImage("question.png"));
    PopupDialog popupDialog = new PopupDialog(fillLayoutComposite.getShell(), PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, true, false, false, false, false, null, null) {

        private static final int _cursorSize = 15;

        @Override
        protected Point getInitialLocation(Point initialSize) {
            Display display = getShell().getDisplay();
            Point location = display.getCursorLocation();
            location.x += _cursorSize;
            location.y += _cursorSize;
            return location;
        }

        @Override
        protected Control createDialogArea(Composite parent) {
            Label label = new Label(parent, SWT.WRAP);
            label.setText(extensionDecBuilder.toString());
            label.setFont(new Font(null, "Times New Roman", 11, SWT.NORMAL));
            GridData gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
            gd.horizontalIndent = PopupDialog.POPUP_HORIZONTALSPACING;
            gd.verticalIndent = PopupDialog.POPUP_VERTICALSPACING;
            label.setLayoutData(gd);
            return label;
        }
    };
    image.addListener(SWT.MouseHover, new org.eclipse.swt.widgets.Listener() {

        @Override
        public void handleEvent(org.eclipse.swt.widgets.Event event) {
            popupDialog.open();
        }
    });
    image.addListener(SWT.MouseExit, new org.eclipse.swt.widgets.Listener() {

        @Override
        public void handleEvent(org.eclipse.swt.widgets.Event event) {
            popupDialog.close();
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) PopupDialog(org.eclipse.jface.dialogs.PopupDialog) GridData(org.eclipse.swt.layout.GridData) Display(org.eclipse.swt.widgets.Display)

Example 2 with PopupDialog

use of org.eclipse.jface.dialogs.PopupDialog in project bndtools by bndtools.

the class OSGiRunLaunchDelegate method launch.

@Override
public void launch(final ILaunchConfiguration configuration, String mode, final ILaunch launch, IProgressMonitor monitor) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, 2);
    try {
        boolean dynamic = configuration.getAttribute(LaunchConstants.ATTR_DYNAMIC_BUNDLES, LaunchConstants.DEFAULT_DYNAMIC_BUNDLES);
        if (dynamic)
            registerLaunchPropertiesRegenerator(run, launch);
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error obtaining OSGi project launcher.", e));
    }
    display = Workbench.getInstance().getDisplay();
    display.syncExec(new Runnable() {

        @Override
        public void run() {
            dialog = new PopupDialog(new Shell(display), PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, false, true, true, true, false, "Errors in running OSGi Framework", "") {

                @Override
                protected Control createDialogArea(Composite parent) {
                    textArea = new Text(parent, SWT.LEAD | SWT.READ_ONLY | SWT.WRAP);
                    return textArea;
                }

                @Override
                protected void fillDialogMenu(IMenuManager dialogMenu) {
                    super.fillDialogMenu(dialogMenu);
                    Action dismissAction = new Action("Close") {

                        @Override
                        public void run() {
                            close();
                        }
                    };
                    dialogMenu.add(dismissAction);
                }

                @Override
                protected Control createInfoTextArea(Composite parent) {
                    Link link = new Link(parent, SWT.NONE);
                    link.setText("<a>Dismiss\u2026</a> ");
                    link.addSelectionListener(new SelectionAdapter() {

                        @Override
                        public void widgetSelected(SelectionEvent e) {
                            close();
                        }
                    });
                    GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.FILL).applyTo(link);
                    return link;
                }

                @Override
                protected Point getDefaultSize() {
                    Point p = getShell().getSize();
                    p.x = Math.max(400, p.x / 2);
                    p.y = Math.max(200, p.y / 2);
                    return p;
                }

                @Override
                protected Point getInitialLocation(Point initialSize) {
                    Rectangle r = getShell().getBounds();
                    return new Point(r.x + r.width - initialSize.x, r.y + r.height - initialSize.y);
                }

                @Override
                public boolean close() {
                    if (textArea != null) {
                        textArea.setText("");
                    }
                    return super.close();
                }
            };
        }
    });
    super.launch(configuration, mode, launch, progress.newChild(1, SubMonitor.SUPPRESS_NONE));
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Action(org.eclipse.jface.action.Action) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SubMonitor(org.eclipse.core.runtime.SubMonitor) Rectangle(org.eclipse.swt.graphics.Rectangle) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) Shell(org.eclipse.swt.widgets.Shell) CoreException(org.eclipse.core.runtime.CoreException) PopupDialog(org.eclipse.jface.dialogs.PopupDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IMenuManager(org.eclipse.jface.action.IMenuManager) Link(org.eclipse.swt.widgets.Link)

Aggregations

PopupDialog (org.eclipse.jface.dialogs.PopupDialog)2 Point (org.eclipse.swt.graphics.Point)2 Composite (org.eclipse.swt.widgets.Composite)2 IOException (java.io.IOException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 Action (org.eclipse.jface.action.Action)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Font (org.eclipse.swt.graphics.Font)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 GridData (org.eclipse.swt.layout.GridData)1 Display (org.eclipse.swt.widgets.Display)1 Label (org.eclipse.swt.widgets.Label)1 Link (org.eclipse.swt.widgets.Link)1 Shell (org.eclipse.swt.widgets.Shell)1