Search in sources :

Example 1 with AddReferenceWizard

use of net.servicestack.eclipse.wizard.AddReferenceWizard in project ServiceStack.Java by ServiceStack.

the class AddReferenceAction method run.

/**
 * @see IActionDelegate#run(IAction)
 */
public void run(IAction action) {
    if (_selection != null) {
        IStructuredSelection packageSelection = (IStructuredSelection) selectionService.getSelection("org.eclipse.jdt.ui.PackageExplorer");
        if (packageSelection == null) {
            ISelectionService selectionService = Workbench.getInstance().getActiveWorkbenchWindow().getSelectionService();
            packageSelection = (IStructuredSelection) selectionService.getSelection();
        }
        AddReferenceWizard generationWizard = new AddReferenceWizard(_selection, packageSelection);
        WizardDialog dialog = new WizardDialog(shell, generationWizard);
        dialog.setBlockOnOpen(false);
        Display display = shell.getDisplay();
        Monitor primaryMonitor = display.getPrimaryMonitor();
        Rectangle bounds = primaryMonitor.getBounds();
        dialog.open();
        Rectangle rect = dialog.getShell().getBounds();
        int x = bounds.x + (bounds.width - rect.width) / 2;
        int y = bounds.y + (bounds.height - rect.height) / 2;
        dialog.getShell().setLocation(x, y);
    }
}
Also used : Monitor(org.eclipse.swt.widgets.Monitor) Rectangle(org.eclipse.swt.graphics.Rectangle) ISelectionService(org.eclipse.ui.ISelectionService) AddReferenceWizard(net.servicestack.eclipse.wizard.AddReferenceWizard) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Display(org.eclipse.swt.widgets.Display)

Aggregations

AddReferenceWizard (net.servicestack.eclipse.wizard.AddReferenceWizard)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Display (org.eclipse.swt.widgets.Display)1 Monitor (org.eclipse.swt.widgets.Monitor)1 ISelectionService (org.eclipse.ui.ISelectionService)1