List of usage examples for org.eclipse.jface.wizard WizardDialog getShell
public Shell getShell();
From source file:org.eclipse.tcf.te.tcf.ui.handler.ConnectLocatorNodeCommandHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); if (window == null) window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); Assert.isNotNull(window);// w ww .j a v a 2s .c o m // Get the selection from the event ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection && !selection.isEmpty()) { // The selection contains only one element as multi element selections are not supported by this handler Object element = ((IStructuredSelection) selection).getFirstElement(); // The element must be of type IPeer if (element instanceof ILocatorNode) { System.setProperty("NewWizard_" + IPeerProperties.PROP_AUTO_CONNECT, Boolean.TRUE.toString()); //$NON-NLS-1$ // Get the list of enabled new wizards IWorkbenchPart part = HandlerUtil.getActivePart(event); if (part instanceof CommonNavigator) { CommonWizardDescriptor[] wizards = CommonWizardDescriptorManager.getInstance() .getEnabledCommonWizardDescriptors(element, WizardActionGroup.TYPE_NEW, ((CommonNavigator) part).getNavigatorContentService()); // If there are more than one wizard, the user must select which wizard // to use to create the connection -> open the new connection wizard if (wizards.length > 1) { NewWizard wizard = new NewWizard( "org.eclipse.tcf.te.tcf.ui.newWizards.category.configurations"); //$NON-NLS-1$ wizard.setWindowTitle(Messages.NewTargetWizardPage_title); wizard.init(window.getWorkbench(), (IStructuredSelection) selection); WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard); dialog.create(); dialog.getShell().setSize(Math.max(400, dialog.getShell().getSize().x), 500); window.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IContextHelpIds.NEW_TARGET_WIZARD); dialog.open(); } else if (wizards.length == 1) { IWizardDescriptor wizardDesc = NewWizardRegistry.getInstance() .findWizard(wizards[0].getWizardId()); new NewWizardShortcutAction(window, wizardDesc).run(); } } System.clearProperty("NewWizard_" + IPeerProperties.PROP_AUTO_CONNECT); //$NON-NLS-1$ } } return null; }
From source file:org.eclipse.tcf.te.ui.wizards.AbstractWizardCommandHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // In Eclipse 4.x, the HandlerUtil.getActiveWorkbenchWindow(event) may return null IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); if (window == null) window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { // Create the wizard IWizard wizard = createWizard(); Assert.isNotNull(wizard);/* ww w . jav a 2 s . c o m*/ // If the wizard is a workbench wizard, initialize the wizard // with the current workbench instance and the current selection if (wizard instanceof IWorkbenchWizard) { ((IWorkbenchWizard) wizard).init(window.getWorkbench(), getCurrentSelection(event)); } // Create and configure the wizard dialog WizardDialog dialog = createWizardDialog(window.getShell(), wizard); dialog.create(); dialog.getShell().setSize(Math.max(getDefaultWidth(), dialog.getShell().getSize().x), getDefaultHeight()); // Configure the wizard dialog help id if (getHelpId() != null) { window.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), getHelpId()); } // Open the dialog dialog.open(); } return null; }
From source file:org.eclipse.team.svn.ui.action.remote.CheckoutAsAction.java
License:Open Source License
public void runImpl(IAction action) { IRepositoryResource[] selectedResources = this.getSelectedRepositoryResources(); IRepositoryLocation[] locations = this.getSelectedRepositoryLocations(); if (selectedResources.length == 0) { selectedResources = new IRepositoryResource[locations.length]; for (int i = 0; i < locations.length; i++) { selectedResources[i] = locations[i].getRoot(); }//from w w w .j av a2s . c om } CheckoutAsWizard checkoutWizard = new CheckoutAsWizard(selectedResources); WizardDialog dialog = new WizardDialog(this.getShell(), checkoutWizard); dialog.create(); dialog.getShell().setSize(Math.max(CheckoutAsWizard.SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), CheckoutAsWizard.SIZING_WIZARD_HEIGHT); dialog.open(); }
From source file:org.eclipse.team.svn.ui.wizard.CheckoutAsWizard.java
License:Open Source License
protected AbstractActionOperation getCheckoutProjectOperation(final IRepositoryResource[] resources, final ObtainProjectNameOperation obtainOperation, final SVNDepth depth, final SVNRevision revisionToCheckoutFrom) { return new AbstractActionOperation("Operation_CheckoutProjects", SVNUIMessages.class) { //$NON-NLS-1$ protected void runImpl(IProgressMonitor monitor) throws Exception { UIMonitorUtility.getDisplay().syncExec(new Runnable() { public void run() { HashMap name2resources = obtainOperation.getNames2Resources(); if (name2resources.isEmpty()) { new MessageDialog(UIMonitorUtility.getShell(), getOperationResource("Title"), null, //$NON-NLS-1$ getOperationResource("Message"), MessageDialog.INFORMATION, //$NON-NLS-1$ new String[] { IDialogConstants.OK_LABEL }, 0).open(); return; }//from www.java 2 s . c o m CheckoutProjectsWizard wizard = new CheckoutProjectsWizard(resources, name2resources); WizardDialog dialog = new WizardDialog(UIMonitorUtility.getShell(), wizard); dialog.create(); wizard.postInit(); dialog.getShell().setSize(Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), SIZING_WIZARD_HEIGHT); if (dialog.open() == 0) {//finish button pressed List selection = wizard.getResultSelections(); IActionOperation op; final Set projectNames; if (wizard.isCheckoutAsFoldersSelected()) { projectNames = null; Map resources2Names = new HashMap(); if (CheckoutAsWizard.this.names2resources != null) { for (Iterator it = CheckoutAsWizard.this.names2resources.entrySet() .iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); resources2Names.put(entry.getValue(), entry.getKey()); } } Map mappings = CheckoutAsWizard.this.getExternalsFolderNames(resources, resources2Names); op = CheckoutAsWizard.this .getCheckoutAsFolderOperation(wizard.getTargetFolder(), (IRepositoryResource[]) selection .toArray(new IRepositoryResource[selection.size()]), mappings); } else { HashMap selectedMap = new HashMap(); List projects = new ArrayList(); projectNames = name2resources.keySet(); for (Iterator iter = projectNames.iterator(); iter.hasNext();) { String projName = (String) iter.next(); if (wizard.getResultSelections().contains(name2resources.get(projName))) { selectedMap.put(projName, name2resources.get(projName)); projects.add(name2resources.get(projName)); } } boolean ignoreExternals = SVNTeamPreferences.getBehaviourBoolean( SVNTeamUIPlugin.instance().getPreferenceStore(), SVNTeamPreferences.BEHAVIOUR_IGNORE_EXTERNALS_NAME); op = ExtensionsManager.getInstance().getCurrentCheckoutFactory() .getCheckoutOperation(CheckoutAsWizard.this.getShell(), (IRepositoryResource[]) projects .toArray(new IRepositoryResource[projects.size()]), selectedMap, wizard.isRespectHierarchy(), wizard.getLocation(), depth, ignoreExternals); } if (op != null) { String wsName = wizard.getWorkingSetName(); if (CheckoutAsWizard.this.priorOp != null || wsName != null) { CompositeOperation tmp = new CompositeOperation(op.getId(), op.getMessagesClass()); if (CheckoutAsWizard.this.priorOp != null) { tmp.add(CheckoutAsWizard.this.priorOp); tmp.add(op, new IActionOperation[] { CheckoutAsWizard.this.priorOp }); } else { tmp.add(op); } if (wsName != null) { tmp.add(new MoveProjectsToWorkingSetOperation(new IResourceProvider() { public IResource[] getResources() { List projects = new ArrayList(); for (Iterator it = projectNames.iterator(); it.hasNext();) { String name = (String) it.next(); IProject prj = ResourcesPlugin.getWorkspace().getRoot() .getProject(name); if (prj != null) { projects.add(prj); } } return (IProject[]) projects.toArray(new IProject[projects.size()]); } }, wsName)); } op = tmp; } UIMonitorUtility.doTaskScheduledActive(op); } } } }); } }; }
From source file:org.eclipse.team.svn.ui.wizard.ImportFromSVNWizard.java
License:Open Source License
public boolean performFinish() { IRepositoryResource resource = this.selectResource.getSelectedResource(); CheckoutAsWizard checkoutWizard = new CheckoutAsWizard(new IRepositoryResource[] { resource }, this.addLocation.getOperationToPeform()); WizardDialog dialog = new WizardDialog(this.getShell(), checkoutWizard); dialog.create();/*from w w w. j a va 2s. co m*/ dialog.getShell().setSize(Math.max(CheckoutAsWizard.SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), CheckoutAsWizard.SIZING_WIZARD_HEIGHT); return dialog.open() == 0 ? true : false; }
From source file:org.eclipse.tm.te.ui.wizards.AbstractWizardCommandHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); if (window != null) { // Create the wizard IWizard wizard = createWizard(); Assert.isNotNull(wizard);//ww w. j a va2 s. c o m // If the wizard is a workbench wizard, initialize the wizard // with the current workbench instance and the current selection if (wizard instanceof IWorkbenchWizard) { ((IWorkbenchWizard) wizard).init(window.getWorkbench(), getCurrentSelection(event)); } // Create and configure the wizard dialog WizardDialog dialog = createWizardDialog(window.getShell(), wizard); dialog.create(); dialog.getShell().setSize(Math.max(getDefaultWidth(), dialog.getShell().getSize().x), getDefaultHeight()); // Configure the wizard dialog help id if (getHelpId() != null) { window.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), getHelpId()); } // Open the dialog dialog.open(); } return null; }
From source file:org.eclipse.ui.actions.CreateFileAction.java
License:Open Source License
/** * The <code>CreateFileAction</code> implementation of this * <code>IAction</code> method opens a <code>BasicNewFileResourceWizard</code> * in a wizard dialog under the shell passed to the constructor. *///from w w w . jav a 2 s.c om public void run() { BasicNewFileResourceWizard wizard = new BasicNewFileResourceWizard(); wizard.init(PlatformUI.getWorkbench(), getStructuredSelection()); wizard.setNeedsProgressMonitor(true); WizardDialog dialog = new WizardDialog(shellProvider.getShell(), wizard); dialog.create(); dialog.getShell().setText(IDEWorkbenchMessages.CreateFileAction_title); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IIDEHelpContextIds.NEW_FILE_WIZARD); dialog.open(); }
From source file:org.eclipse.ui.actions.CreateFolderAction.java
License:Open Source License
/** * The <code>CreateFolderAction</code> implementation of this * <code>IAction</code> method opens a <code>BasicNewFolderResourceWizard</code> * in a wizard dialog under the shell passed to the constructor. *///from ww w .j a v a2 s. c o m public void run() { BasicNewFolderResourceWizard wizard = new BasicNewFolderResourceWizard(); wizard.init(PlatformUI.getWorkbench(), getStructuredSelection()); wizard.setNeedsProgressMonitor(true); WizardDialog dialog = new WizardDialog(shellProvider.getShell(), wizard); dialog.create(); dialog.getShell().setText(IDEWorkbenchMessages.CreateFolderAction_title); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IIDEHelpContextIds.NEW_FOLDER_WIZARD); dialog.open(); }
From source file:org.eclipse.ui.actions.NewExampleAction.java
License:Open Source License
public void run() { // Create wizard selection wizard. IWorkbench workbench = PlatformUI.getWorkbench(); NewWizard wizard = new NewWizard(); wizard.setCategoryId(WizardsRegistryReader.FULL_EXAMPLES_WIZARD_CATEGORY); ISelection selection = window.getSelectionService().getSelection(); IStructuredSelection selectionToPass = StructuredSelection.EMPTY; if (selection instanceof IStructuredSelection) { selectionToPass = (IStructuredSelection) selection; }/*from ww w.jav a 2 s . co m*/ wizard.init(workbench, selectionToPass); IDialogSettings workbenchSettings = IDEWorkbenchPlugin.getDefault().getDialogSettings(); IDialogSettings wizardSettings = workbenchSettings.getSection("NewWizardAction"); //$NON-NLS-1$ if (wizardSettings == null) { wizardSettings = workbenchSettings.addNewSection("NewWizardAction"); //$NON-NLS-1$ } wizard.setDialogSettings(wizardSettings); wizard.setForcePreviousAndNextButtons(true); // Create wizard dialog. Shell parent = window.getShell(); WizardDialog dialog = new WizardDialog(parent, wizard); dialog.create(); wizard.setWindowTitle(IDEWorkbenchMessages.NewExample_title); dialog.getShell().setSize(Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), SIZING_WIZARD_HEIGHT); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IIDEHelpContextIds.NEW_PROJECT_WIZARD); // Open wizard. dialog.open(); }
From source file:org.eclipse.ui.actions.NewProjectAction.java
License:Open Source License
public void run() { // Create wizard selection wizard. IWorkbench workbench = PlatformUI.getWorkbench(); NewWizard wizard = new NewWizard(); wizard.setProjectsOnly(true);/*from ww w.j a v a 2s . c o m*/ ISelection selection = window.getSelectionService().getSelection(); IStructuredSelection selectionToPass = StructuredSelection.EMPTY; if (selection instanceof IStructuredSelection) { selectionToPass = (IStructuredSelection) selection; } wizard.init(workbench, selectionToPass); IDialogSettings workbenchSettings = IDEWorkbenchPlugin.getDefault().getDialogSettings(); IDialogSettings wizardSettings = workbenchSettings.getSection("NewWizardAction");//$NON-NLS-1$ if (wizardSettings == null) { wizardSettings = workbenchSettings.addNewSection("NewWizardAction");//$NON-NLS-1$ } wizard.setDialogSettings(wizardSettings); wizard.setForcePreviousAndNextButtons(true); // Create wizard dialog. WizardDialog dialog = new WizardDialog(null, wizard); dialog.create(); dialog.getShell().setSize(Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), SIZING_WIZARD_HEIGHT); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IIDEHelpContextIds.NEW_PROJECT_WIZARD); // Open wizard. dialog.open(); }