Example usage for org.eclipse.jface.window IShellProvider IShellProvider

List of usage examples for org.eclipse.jface.window IShellProvider IShellProvider

Introduction

In this page you can find the example usage for org.eclipse.jface.window IShellProvider IShellProvider.

Prototype

IShellProvider

Source Link

Usage

From source file:com.aptana.ide.syncing.ui.wizards.RemoteConnectionSelectionPage.java

License:Open Source License

public void widgetSelected(SelectionEvent e) {
    Object source = e.getSource();

    if (source == newSiteButton) {
        final Shell shell = getShell();
        Dialog dlg = new FTPPropertyDialogProvider().createPropertyDialog(new IShellProvider() {

            public Shell getShell() {
                return shell;
            }/*w  w w.  j a va 2  s .c o m*/
        });
        if (dlg instanceof IPropertyDialog) {
            ((IPropertyDialog) dlg).setPropertySource(
                    CoreIOPlugin.getConnectionPointManager().getType(IBaseFTPConnectionPoint.TYPE_FTP));
        }
        int ret = dlg.open();

        if (ret == Window.OK) {
            populateTable();

            if (dlg instanceof IPropertyDialog) {
                checkItem((IConnectionPoint) ((IPropertyDialog) dlg).getPropertySource());
            }
        }
    } else if (source == syncOnFinish) {
        setSynchronize(syncOnFinish.getSelection());
    }
}

From source file:com.aptana.ide.ui.ftp.navigator.actions.DoubleClickAction.java

License:Open Source License

public void run() {
    if (selectionHasChildren()) {
        super.run();
    } else {/*from   ww  w .  j a  v a 2 s  . c  o m*/
        // no connection point has been defined; opens the FTP dialog
        Dialog dialog = new FTPPropertyDialogProvider().createPropertyDialog(new IShellProvider() {

            public Shell getShell() {
                return fShell;
            }

        });
        if (dialog instanceof IPropertyDialog) {
            ((IPropertyDialog) dialog).setPropertySource(
                    CoreIOPlugin.getConnectionPointManager().getType(FTPConnectionPoint.TYPE));
        }
        dialog.open();
    }
}

From source file:com.aptana.ide.ui.io.navigator.actions.ResourceEditActionGroup.java

License:Open Source License

@Override
protected BaseSelectionListenerAction createDeleteAction(final Shell shell) {
    return new DeleteResourceAction(new IShellProvider() {

        public Shell getShell() {
            return shell;
        }//from  w  w  w  .j av a  2 s . com
    });
}

From source file:com.aptana.ui.properties.ProjectNaturesPage.java

License:Open Source License

/**
 * Ask to reset the project (e.g. Close and Open) to apply the changes.
 */// w  w  w.  jav  a  2  s  .co  m
protected void resetProject() {
    boolean reset = MessageDialog.openQuestion(getControl().getShell(),
            EplMessages.ProjectNaturesPage_ResetTitle, EplMessages.ProjectNaturesPage_ResetMessage);
    if (reset) {
        // close the project
        IRunnableWithProgress close = new IRunnableWithProgress() {

            public void run(final IProgressMonitor monitor) throws InvocationTargetException {
                // use the CloseResourceAction to provide a file saving
                // dialog in case the project has some unsaved
                // files
                UIJob job = new UIJob(EplMessages.ProjectNaturesPage_CloseProjectJob_Title + "...") //$NON-NLS-1$
                {
                    @Override
                    public IStatus runInUIThread(IProgressMonitor monitor) {
                        CloseResourceAction closeAction = new CloseResourceAction(new IShellProvider() {
                            public Shell getShell() {
                                return Display.getDefault().getActiveShell();
                            }
                        });
                        closeAction.selectionChanged(new StructuredSelection(new Object[] { fProject }));
                        closeAction.run();
                        monitor.done();
                        return Status.OK_STATUS;
                    }
                };
                job.schedule();
                try {
                    job.join();
                } catch (InterruptedException e) {
                    // ignore
                }
                monitor.done();
            }
        };
        try {
            new ProgressMonitorJobsDialog(getControl().getShell()).run(true, true, close);
        } catch (InterruptedException e) {
            // ignore
        } catch (InvocationTargetException e) {
            IdeLog.logError(UIEplPlugin.getDefault(), EplMessages.ProjectNaturesPage_ERR_CloseProject, e);
        }

        // re-open the project
        IRunnableWithProgress open = new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException {
                try {
                    fProject.open(monitor);
                } catch (CoreException e) {
                    throw new InvocationTargetException(e);
                }
            }
        };
        try {
            new ProgressMonitorJobsDialog(getControl().getShell()).run(true, true, open);
        } catch (InterruptedException e) {
            // ignore
        } catch (InvocationTargetException e) {
            IdeLog.logError(UIEplPlugin.getDefault(), EplMessages.ProjectNaturesPage_ERR_OpenProject, e);
        }
    }
}

From source file:com.aptana.ui.SudoUIManager.java

License:Open Source License

/**
 * This is responsible for prompting the dialog to the user and returns the password back to the caller. If the user
 * cancels the dialog, then empty password is passed back to the caller.
 * /*from  w ww.j  a  va  2  s . c o m*/
 * @param promptMessage
 * @return
 * @throws CoreException
 */
public char[] getPassword() throws CoreException {
    // FIXME Handle when password is empty (meaning sudo doesn't require a password!)
    final IStatus[] status = new IStatus[] { Status.OK_STATUS };
    if (validPassword == null) {
        // If the system doesn't require a password, we don't need to pop the prompt at all!
        final SudoManager sudoMngr = new SudoManager();
        if (sudoMngr.authenticate(null)) {
            // sudo doesn't require password!
            return new char[0];
        }

        UIUtils.getDisplay().syncExec(new Runnable() {
            public void run() {
                try {
                    boolean retry;
                    int retryAttempts = 0;
                    String promptMessage = MessageFormat.format(Messages.SudoManager_MessagePrompt,
                            EclipseUtil.getStudioPrefix());
                    do {
                        retryAttempts++;
                        retry = false;
                        SudoPasswordPromptDialog sudoDialog = new SudoPasswordPromptDialog(
                                new IShellProvider() {

                                    public Shell getShell() {
                                        return UIUtils.getActiveShell();
                                    }
                                }, promptMessage);
                        int open = sudoDialog.open();
                        if (open == Dialog.OK) {
                            if (sudoMngr.authenticate(sudoDialog.getPassword())) {
                                validPassword = sudoDialog.getPassword();
                            } else {
                                // Re-run the authentication dialog as long as user attempts to provide password.
                                retry = true;
                            }
                        } else if (open == Dialog.CANCEL) {
                            throw new CoreException(new Status(Status.CANCEL, UIPlugin.PLUGIN_ID,
                                    Messages.SudoUIManager_OperationCancelledError));
                        }
                        promptMessage = Messages.Sudo_Invalid_Password_Prompt;
                    } while (retry && retryAttempts < MAX_ATTEMPTS);
                    if (validPassword == null && retryAttempts >= MAX_ATTEMPTS) {
                        // User has exceeded the max attempts to provide the password.
                        throw new CoreException(new Status(Status.CANCEL, UIPlugin.PLUGIN_ID,
                                Messages.SudoUIManager_LoginErrorMessage));
                    }
                } catch (CoreException e) {
                    status[0] = e.getStatus();
                }
            }
        });

    }
    if (status[0] != Status.OK_STATUS) {
        throw new CoreException(status[0]);
    }
    return validPassword;
}

From source file:com.ebmwebsourcing.petals.common.internal.commands.PetalsDeleteHandler.java

License:Open Source License

/**
 * Constructor./*from   w  w w . java 2  s . co m*/
 */
public PetalsDeleteHandler() {

    final Shell shell = new Shell(Display.getDefault());
    this.deleteAction = new DeleteResourceAction(new IShellProvider() {
        @Override
        public Shell getShell() {
            return shell;
        }
    });
}

From source file:com.ebmwebsourcing.petals.common.internal.commands.PetalsMoveHandler.java

License:Open Source License

/**
 * Constructor.// w w w . j  av  a2  s.c om
 */
public PetalsMoveHandler() {

    final Shell shell = new Shell(Display.getDefault());
    this.moveAction = new MoveResourceAction(new IShellProvider() {
        @Override
        public Shell getShell() {
            return shell;
        }
    });
}

From source file:com.ebmwebsourcing.petals.common.internal.commands.PetalsRenameHandler.java

License:Open Source License

/**
 * Constructor./* w w w .j av a  2  s .  co  m*/
 */
public PetalsRenameHandler() {

    final Shell shell = new Shell(Display.getDefault());
    this.renameAction = new RenameResourceAction(new IShellProvider() {
        @Override
        public Shell getShell() {
            return shell;
        }
    });
}

From source file:com.gigaspaces.azure.propertypage.SubscriptionPropertyPage.java

License:Open Source License

protected int openPropertyDialog(PublishData pd) {
    int retVal = Window.CANCEL;
    try {/*from   w w  w  . j a  va  2 s . c o m*/
        // Create the nodes
        IPreferenceNode subscriptionGeneral = new PreferenceNode(Messages.credentialsPageId,
                Messages.credentialsNodeText, null, CredentialsPropertyPage.class.toString());

        CredentialsPropertyPage.setPublishData(null);

        if (pd != null) {
            CredentialsPropertyPage.setPublishData(pd);
        }

        SelectionProvider selProvider = new SelectionProvider();

        PropertyDialogAction action = new PropertyDialogAction(new IShellProvider() {

            @Override
            public Shell getShell() {
                return new Shell();
            }
        }, selProvider);

        StructuredSelection selection = new StructuredSelection(subscriptionGeneral);

        selProvider.setSelection(selection);

        PreferenceDialog dlg = action.createDialog();

        String dlgTitle = String.format(Messages.credentialsDlgTitle);

        dlg.getShell().setText(dlgTitle);

        retVal = dlg.open();

    } catch (Exception ex) {
    }
    return retVal;
}

From source file:com.google.cloud.tools.eclipse.appengine.login.GoogleLoginService.java

License:Apache License

/**
 * Called by OSGi Declarative Services Runtime when the {@link GoogleLoginService} is activated
 * as an OSGi service./*  w  w  w  .  j  a  v a 2s  . co  m*/
 */
protected void activate() {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    LoginServiceLogger logger = new LoginServiceLogger();
    IShellProvider shellProvider = new IShellProvider() {
        @Override
        public Shell getShell() {
            return workbench.getDisplay().getActiveShell();
        }
    };

    loginServiceUi = new LoginServiceUi(workbench, shellProvider, workbench.getDisplay());
    loginState = new GoogleLoginState(Constants.getOAuthClientId(), Constants.getOAuthClientSecret(),
            OAUTH_SCOPES, new JavaPreferenceOAuthDataStore(PREFERENCE_PATH_OAUTH_DATA_STORE, logger),
            loginServiceUi, logger);
    accounts = loginState.listAccounts();
}