List of usage examples for org.eclipse.jface.viewers StructuredSelection StructuredSelection
public StructuredSelection(List elements)
List
. From source file:com.aptana.deploy.ftp.ui.wizard.FTPDeployWizard.java
License:Open Source License
protected IRunnableWithProgress createFTPDeployRunnable(FTPDeployWizardPage page) { if (!page.completePage()) { return null; }/*w w w . ja v a2 s.c om*/ final IConnectionPoint destinationConnectionPoint = page.getConnectionPoint(); final boolean isAutoSyncSelected = page.isAutoSyncSelected(); final SyncDirection direction = page.getSyncDirection(); final IWorkbenchPart activePart = UIUtils.getActivePart(); IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { SubMonitor sub = SubMonitor.convert(monitor, 100); try { ISiteConnection site = null; ISiteConnection[] sites = SiteConnectionUtils.findSites(selectedContainer, destinationConnectionPoint); if (sites.length == 0) { // creates the site to link the project with the FTP connection IConnectionPoint sourceConnectionPoint = SyncUtils .findOrCreateConnectionPointFor(selectedContainer); CoreIOPlugin.getConnectionPointManager().addConnectionPoint(sourceConnectionPoint); site = SiteConnectionUtils.createSite( MessageFormat.format("{0} <-> {1}", selectedContainer.getName(), //$NON-NLS-1$ destinationConnectionPoint.getName()), sourceConnectionPoint, destinationConnectionPoint); SyncingPlugin.getSiteConnectionManager().addSiteConnection(site); } else if (sites.length == 1) { // the site to link the project with the FTP connection already exists site = sites[0]; } else { // multiple FTP connections are associated with the project; finds the last one // try for last remembered site first String lastConnection = DeployPreferenceUtil.getDeployEndpoint(selectedContainer); if (lastConnection != null) { site = SiteConnectionUtils.getSiteWithDestination(lastConnection, sites); } } if (isAutoSyncSelected) { BaseSyncAction action = null; switch (direction) { case UPLOAD: action = new UploadAction(); break; case DOWNLOAD: action = new DownloadAction(); break; case BOTH: action = new SynchronizeProjectAction(); } action.setActivePart(null, activePart); action.setSelection(new StructuredSelection(selectedContainer)); action.setSelectedSite(site); action.run(null); } } finally { sub.done(); } } }; return runnable; }
From source file:com.aptana.deploy.internal.ui.handlers.RunDeployWizardHandler.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { IStructuredSelection selection = StructuredSelection.EMPTY; IWorkbenchPart activePart = HandlerUtil.getActivePart(event); if (activePart instanceof IEditorPart) { IEditorInput editorInput = ((IEditorPart) activePart).getEditorInput(); if (editorInput instanceof IFileEditorInput) { selection = new StructuredSelection(((IFileEditorInput) editorInput).getFile()); }//w w w. j a v a 2s .c o m } else { selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); } // Instantiates and initializes the wizard DeployWizard wizard = new DeployWizard(); wizard.init(activePart.getSite().getWorkbenchWindow().getWorkbench(), selection); wizard.setWindowTitle(Messages.DeployHandler_Wizard_Title); IDialogSettings workbenchSettings = DeployUIPlugin.getDefault().getDialogSettings(); IDialogSettings wizardSettings = workbenchSettings.getSection(DEPLOY_WIZARD_SECTION); if (wizardSettings == null) { wizardSettings = workbenchSettings.addNewSection(DEPLOY_WIZARD_SECTION); } wizard.setDialogSettings(wizardSettings); wizard.setForcePreviousAndNextButtons(true); // Instantiates the wizard container with the wizard and opens it Shell shell = activePart.getSite().getShell(); if (shell == null) { shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); } // FIXME Don't use this special dialog! move ILoginValidator stuff to page change listener stuff when necessary! DeployWizardDialog dialog = new DeployWizardDialog(shell, wizard); dialog.setPageSize(350, 500); dialog.setHelpAvailable(false); dialog.create(); dialog.open(); return null; }
From source file:com.aptana.deploy.wizard.DeployWizardPage.java
License:Open Source License
/** * Selects the wizard category and wizard in this page that were selected last time this page was used. If a * category or wizard that was previously selected no longer exists then it is ignored. *//*w ww. j a va 2 s. co m*/ protected void selectPreviouslySelected(String setting, IWizardCategory wizardCategories, final TreeViewer viewer) { String selectedId = getDialogSettings().get(setting); if (selectedId == null) { return; } if (wizardCategories == null) { return; } Object selected = wizardCategories.findCategory(new Path(selectedId)); if (selected == null) { selected = wizardCategories.findWizard(selectedId); if (selected == null) { // if we cant find either a category or a wizard, abort. return; } } viewer.setSelection(new StructuredSelection(selected), true); }
From source file:com.aptana.editor.common.internal.scripting.TemplateSelectionPage.java
License:Open Source License
protected void selectInitialTemplate() { // Select the first one on the list as the initial one if (templates.length > 0) { templateSelectionViewer.setSelection(new StructuredSelection(templates[0]), true); setPreviewContent(templates[0]); }/*ww w.j a va 2 s. co m*/ }
From source file:com.aptana.editor.common.outline.CommonOutlinePage.java
License:Open Source License
public void select(Object element) { if (element != null && !isDisposed()) { getTreeViewer().setSelection(new StructuredSelection(element)); }/*from w w w . ja v a 2s . c o m*/ }
From source file:com.aptana.editor.common.properties.CommonEditorPropertySheetPage.java
License:Open Source License
@Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { removePostSelectionListener();//from ww w . j ava 2 s .c om if (selection instanceof ITextSelection && part instanceof AbstractTextEditor) { selection = new StructuredSelection( new AdaptableTextSelection(getViewer(), (ITextSelection) selection)); sourcePart = (AbstractTextEditor) part; ((IPostSelectionProvider) sourcePart.getSelectionProvider()) .addPostSelectionChangedListener(selectionChangedListener); sourcePart.getSite().getPage().addPartListener(partListener); } super.selectionChanged(part, selection); }
From source file:com.aptana.editor.common.properties.CommonEditorPropertySheetPage.java
License:Open Source License
private void textSelectionChanged(ITextSelection textSelection) { if (sourcePart != null) { ISelection selection = new StructuredSelection(new AdaptableTextSelection(getViewer(), textSelection)); super.selectionChanged(sourcePart, selection); }/*w ww . j a v a 2 s .c o m*/ }
From source file:com.aptana.editor.js.views.JSIndexViewActionProvider.java
License:Open Source License
/** * @param view/*from w w w . j a v a 2 s . c o m*/ * @param typeNames * @return */ protected IAction createAction(final IndexView view, final List<String> typeNames) { IAction action = new Action() { @Override public void run() { TreeViewer treeViewer = view.getTreeViewer(); if (treeViewer != null) { Object input = treeViewer.getInput(); if (input instanceof IProject) { IProject project = (IProject) input; Index index = getIndexManager().getIndex(project.getLocationURI()); JSIndexQueryHelper queryHelper = new JSIndexQueryHelper(); Collection<TypeElement> types = queryHelper.getTypes(index, typeNames.get(0), true); List<ClassElement> classes = JSTypeUtil.typesToClasses(types); if (!CollectionsUtil.isEmpty(classes)) { ClassElement c = classes.get(0); treeViewer.setSelection(new StructuredSelection(c), true); } } } } }; action.setText(Messages.JSIndexViewActionProvider_JumpToType); return action; }
From source file:com.aptana.editor.php.internal.ui.dialog.CustomFilteredItemsSelectionDialog.java
License:Open Source License
/** * Refreshes the dialog - has to be called in UI thread. *///www .j av a 2s. com public void refresh() { if (list != null && !list.getTable().isDisposed()) { List<?> lastRefreshSelection = ((StructuredSelection) list.getSelection()).toList(); list.setItemCount(contentProvider.getElements(null).length); list.refresh(); if (list.getTable().getItemCount() > 0) { // preserve previous selection if (refreshWithLastSelection && lastRefreshSelection != null && lastRefreshSelection.size() > 0) { list.setSelection(new StructuredSelection(lastRefreshSelection)); } else { refreshWithLastSelection = true; list.getTable().setSelection(0); list.getTable().notifyListeners(SWT.Selection, new Event()); } } else { list.setSelection(StructuredSelection.EMPTY); } } scheduleProgressMessageRefresh(); }
From source file:com.aptana.editor.php.internal.ui.dialog.CustomFilteredItemsSelectionDialog.java
License:Open Source License
/** * Returns the current selection./* w ww.java2 s . c o m*/ * * @return the current selection */ protected StructuredSelection getSelectedItems() { StructuredSelection selection = (StructuredSelection) list.getSelection(); List<?> selectedItems = selection.toList(); Object itemToRemove = null; for (Iterator<?> it = selection.iterator(); it.hasNext();) { Object item = it.next(); if (item instanceof ItemsListSeparator) { itemToRemove = item; break; } } if (itemToRemove == null) { return new StructuredSelection(selectedItems); } // Create a new selection without the collision @SuppressWarnings("rawtypes") List<?> newItems = new ArrayList(selectedItems); newItems.remove(itemToRemove); return new StructuredSelection(newItems); }