List of usage examples for org.eclipse.jface.viewers StructuredSelection StructuredSelection
public StructuredSelection(List elements)
List
. From source file:com.aptana.jira.ui.internal.SubmitTicketDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite main = new Composite(parent, SWT.NONE); main.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create()); main.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); Label separator = new Label(main, SWT.HORIZONTAL | SWT.SEPARATOR); separator.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); // adds control for login credentials userInfoProvider = new JiraPreferencePageProvider(); userInfoControl = userInfoProvider.createContents(main); userInfoControl.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); // issue type Label label = new Label(main, SWT.NONE); label.setText(StringUtil.makeFormLabel(Messages.SubmitTicketDialog_LBL_Type)); label.setLayoutData(GridDataFactory.swtDefaults().create()); typeCombo = new ComboViewer(main, SWT.DROP_DOWN | SWT.READ_ONLY); typeCombo.setContentProvider(ArrayContentProvider.getInstance()); typeCombo.setLabelProvider(new LabelProvider()); typeCombo.setInput(JiraIssueType.values()); typeCombo.getControl().setLayoutData(GridDataFactory.swtDefaults().create()); typeCombo.setSelection(new StructuredSelection(JiraIssueType.BUG)); ISelectionChangedListener listener = new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { validate();/*w w w . j ava2 s . c o m*/ } }; typeCombo.addSelectionChangedListener(listener); // FIXME Severity doesn't apply for Story in Studio tracker // severity label = new Label(main, SWT.NONE); label.setText(StringUtil.makeFormLabel(Messages.SubmitTicketDialog_LBL_Severity)); label.setLayoutData(GridDataFactory.swtDefaults().create()); severityCombo = new ComboViewer(main, SWT.DROP_DOWN | SWT.READ_ONLY); severityCombo.setContentProvider(ArrayContentProvider.getInstance()); severityCombo.setLabelProvider(new LabelProvider()); severityCombo.setInput(JiraIssueSeverity.values()); severityCombo.getControl().setLayoutData(GridDataFactory.swtDefaults().create()); severityCombo.setSelection(new StructuredSelection(JiraIssueSeverity.MINOR)); severityCombo.addSelectionChangedListener(listener); // summary label = new Label(main, SWT.NONE); label.setText(StringUtil.makeFormLabel(Messages.SubmitTicketDialog_LBL_Summary)); label.setLayoutData(GridDataFactory.swtDefaults().create()); summaryText = new Text(main, SWT.BORDER | SWT.SINGLE); summaryText.setLayoutData( GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create()); ModifyListener modifyListener = new ModifyListener() { public void modifyText(ModifyEvent e) { validate(); } }; summaryText.addModifyListener(modifyListener); // Steps to Reproduce label = new Label(main, SWT.NONE); label.setText(StringUtil.makeFormLabel(Messages.SubmitTicketDialog_LBL_StepsToReproduce)); label.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).create()); reproduceText = new Text(main, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); reproduceText .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 100).create()); reproduceText.addModifyListener(modifyListener); TraverseListener traverseListener = new TraverseListener() { public void keyTraversed(TraverseEvent e) { e.doit = true; } }; reproduceText.addTraverseListener(traverseListener); // Actual Result label = new Label(main, SWT.NONE); label.setText(StringUtil.makeFormLabel(Messages.SubmitTicketDialog_LBL_ActualResult)); label.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).create()); actualResultText = new Text(main, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); actualResultText .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 50).create()); actualResultText.addModifyListener(modifyListener); actualResultText.addTraverseListener(traverseListener); // Expected Result label = new Label(main, SWT.NONE); label.setText(StringUtil.makeFormLabel(Messages.SubmitTicketDialog_LBL_ExpectedResult)); label.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).create()); expectedResultText = new Text(main, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); expectedResultText .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 50).create()); expectedResultText.addModifyListener(modifyListener); expectedResultText.addTraverseListener(traverseListener); // logs to attach label = new Label(main, SWT.NONE); label.setText(StringUtil.makeFormLabel(Messages.SubmitTicketDialog_LBL_LogsToAttach)); label.setLayoutData(GridDataFactory.swtDefaults().create()); Composite composite = new Composite(main, SWT.NONE); composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create()); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); studioLogCheckbox = new Button(composite, SWT.CHECK); studioLogCheckbox.setText(Messages.SubmitTicketDialog_LBL_StudioLog); studioLogCheckbox.setSelection(true); diagnosticLogCheckbox = new Button(composite, SWT.CHECK); diagnosticLogCheckbox.setText(Messages.SubmitTicketDialog_LBL_DiagnosticLog); diagnosticLogCheckbox.setSelection(true); // screenshots label = new Label(main, SWT.NONE); label.setText(StringUtil.makeFormLabel(Messages.SubmitTicketDialog_LBL_Screenshots)); label.setLayoutData(GridDataFactory.swtDefaults().create()); composite = new Composite(main, SWT.NONE); composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create()); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); screenshotText = new Text(composite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); screenshotText.setLayoutData( GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create()); screenshotText.addMouseListener(new MouseListener() { public void mouseUp(MouseEvent e) { browse(); } public void mouseDown(MouseEvent e) { } public void mouseDoubleClick(MouseEvent e) { } }); browseButton = new Button(composite, SWT.PUSH); browseButton.setText(StringUtil.ellipsify(CoreStrings.BROWSE)); browseButton.setLayoutData(GridDataFactory.swtDefaults().create()); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { browse(); } }); // the list of selected screenshots label = new Label(main, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults().create()); screenshotsComposite = new Composite(main, SWT.NONE); screenshotsComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 0).create()); screenshotsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); // a progress bar for when validating the login progressMonitorPart = new ProgressMonitorPart(main, GridLayoutFactory.fillDefaults().create()); progressMonitorPart .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).exclude(true).span(2, 1).create()); userInfoProvider.setProgressMonitor(progressMonitorPart); userInfoProvider.addValidationListener(new IAccountPageProvider.IValidationListener() { public void preValidationStart() { setUILocked(true); progressMonitorPart.setVisible(true); ((GridData) progressMonitorPart.getLayoutData()).exclude = false; layoutShell(); } public void postValidationEnd() { setUILocked(false); if (!progressMonitorPart.isDisposed()) { progressMonitorPart.setVisible(false); ((GridData) progressMonitorPart.getLayoutData()).exclude = true; layoutShell(); } } }); setTitle(Messages.SubmitTicketDialog_Title); setTitleImage(SWTUtils.getImage(JiraUIPlugin.getDefault(), IMAGE_PATH)); setMessage(Messages.SubmitTicketDialog_DefaultMessage); return main; }
From source file:com.aptana.js.debug.ui.internal.actions.BreakpointPropertiesAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *//*w ww . j a v a 2 s . c o m*/ public void run(IAction action) { PropertyDialogAction propertyAction = new PropertyDialogAction( new SameShellProvider(UIUtils.getActiveShell()), new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { } public ISelection getSelection() { return new StructuredSelection(breakpoint); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { } public void setSelection(ISelection selection) { } }); propertyAction.run(); }
From source file:com.aptana.js.debug.ui.internal.dialogs.AddExceptionBreakpointDialog.java
License:Open Source License
private boolean createBreakpoint() { final Object[] selected = getSelectedElements(); if (selected.length != 1) { return false; }/* w ww. j a va2s . co m*/ new Job(Messages.AddExceptionBreakpointDialog_AddJavaScriptExceptionBreakpoint) { protected IStatus run(IProgressMonitor monitor) { try { IResource resource = null; if (resource == null) { resource = ResourcesPlugin.getWorkspace().getRoot(); } IJSExceptionBreakpoint breakpoint = JSDebugModel.createExceptionBreakpoint(resource, (String) selected[0]); final List<IBreakpoint> list = new ArrayList<IBreakpoint>(1); list.add(breakpoint); Runnable r = new Runnable() { public void run() { IViewPart part = UIUtils.getActivePage().findView(IDebugUIConstants.ID_BREAKPOINT_VIEW); if (part instanceof IDebugView) { Viewer viewer = ((IDebugView) part).getViewer(); if (viewer instanceof StructuredViewer) { StructuredViewer sv = (StructuredViewer) viewer; sv.setSelection(new StructuredSelection(list), true); } } } }; DebugUiPlugin.getStandardDisplay().asyncExec(r); return Status.OK_STATUS; } catch (CoreException e) { updateStatus(e.getStatus()); return Status.CANCEL_STATUS; } } }.schedule(); return true; }
From source file:com.aptana.js.debug.ui.internal.launchConfigurations.LaunchBrowserSettingsTab.java
License:Open Source License
/** * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) *///w ww . j ava 2s .c o m public void initializeFrom(ILaunchConfiguration configuration) { hookListeners(false); try { fBrowserExeText.setText(configuration.getAttribute( ILaunchConfigurationConstants.CONFIGURATION_BROWSER_EXECUTABLE, StringUtil.EMPTY)); fCommandArgsText.setText(configuration.getAttribute( ILaunchConfigurationConstants.CONFIGURATION_BROWSER_COMMAND_LINE, StringUtil.EMPTY)); int startActionType = configuration.getAttribute( ILaunchConfigurationConstants.CONFIGURATION_START_ACTION_TYPE, ILaunchConfigurationConstants.DEFAULT_START_ACTION_TYPE); rbCurrentPage.setSelection(startActionType == ILaunchConfigurationConstants.START_ACTION_CURRENT_PAGE); rbSpecificPage .setSelection(startActionType == ILaunchConfigurationConstants.START_ACTION_SPECIFIC_PAGE); fSpecificPageText.setText(configuration .getAttribute(ILaunchConfigurationConstants.CONFIGURATION_START_PAGE_PATH, StringUtil.EMPTY)); rbStartUrl.setSelection(startActionType == ILaunchConfigurationConstants.START_ACTION_START_URL); fStartUrlText.setText(configuration .getAttribute(ILaunchConfigurationConstants.CONFIGURATION_START_PAGE_URL, StringUtil.EMPTY)); fAddProjectName.setSelection(configuration .getAttribute(ILaunchConfigurationConstants.CONFIGURATION_APPEND_PROJECT_NAME, false)); int serverType = configuration.getAttribute(ILaunchConfigurationConstants.CONFIGURATION_SERVER_TYPE, ILaunchConfigurationConstants.DEFAULT_SERVER_TYPE); rbInternalServer.setSelection(serverType == ILaunchConfigurationConstants.SERVER_INTERNAL); rbCustomServer.setSelection(serverType == ILaunchConfigurationConstants.SERVER_EXTERNAL); fbaseUrlText.setText(configuration .getAttribute(ILaunchConfigurationConstants.CONFIGURATION_EXTERNAL_BASE_URL, StringUtil.EMPTY)); rbManagedServer.setSelection(serverType == ILaunchConfigurationConstants.SERVER_MANAGED); IServer server = WebServerCorePlugin.getDefault().getServerManager().findServerByName(configuration .getAttribute(ILaunchConfigurationConstants.CONFIGURATION_SERVER_NAME, StringUtil.EMPTY)); if (server != null) { managedServersView.setSelection(new StructuredSelection(server)); } } catch (CoreException e) { IdeLog.logError(JSDebugUIPlugin.getDefault(), "Reading launch configuration fails", e); //$NON-NLS-1$ } finally { hookListeners(true); updateEnablement(); } }
From source file:com.aptana.js.debug.ui.internal.preferences.JSDetailFormattersPreferencePage.java
License:Open Source License
@SuppressWarnings("unchecked") private void removeTypes() { Object[] list = formatters.toArray(); IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); Object first = selection.getFirstElement(); int index = -1; for (int i = 0; i < list.length; i++) { if (list[i].equals(first)) { index = i;/* w ww.j a v a 2 s. c o m*/ break; } } removeDetailFormatters( (DetailFormatter[]) selection.toList().toArray(new DetailFormatter[selection.size()])); list = formatters.toArray(); if (index > list.length - 1) { index = list.length - 1; } if (index >= 0) { listViewer.setSelection(new StructuredSelection(list[index])); } }
From source file:com.aptana.js.debug.ui.internal.preferences.JSDetailFormattersPreferencePage.java
License:Open Source License
private void addDetailFormatter(DetailFormatter detailFormatter) { formatters.add(detailFormatter);//from www .j av a 2 s.c o m listViewer.refresh(); updateViewerCheckboxes(); IStructuredSelection selection = new StructuredSelection(detailFormatter); listViewer.setSelection(selection); updatePage(selection); }
From source file:com.aptana.php.debug.ui.actions.breakpoints.PHPBreakpointPropertiesRulerAction.java
License:Open Source License
/** * @see Action#run()/* w ww . j a v a2 s . c o m*/ */ @Override public void run() { if (getBreakpoint() != null) { final PropertyDialogAction action = new PropertyDialogAction(getEditor().getEditorSite(), new ISelectionProvider() { public void addSelectionChangedListener(final ISelectionChangedListener listener) { } @SuppressWarnings("synthetic-access") public ISelection getSelection() { return new StructuredSelection(getBreakpoint()); } public void removeSelectionChangedListener(final ISelectionChangedListener listener) { } public void setSelection(final ISelection selection) { } }); action.run(); } }
From source file:com.aptana.php.debug.ui.launching.LaunchConfigurationsSelectionDialog.java
License:Open Source License
@SuppressWarnings({ "rawtypes", "unchecked" }) protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent);/*from w w w . j av a 2 s.c o m*/ Composite comp = (Composite) super.createDialogArea(parent); String label = getMessage(); if (!StringUtil.isEmpty(label)) { SWTFactory.createWrapLabel(comp, label, 1); } label = getViewerLabel(); if (!StringUtil.isEmpty(label)) { SWTFactory.createLabel(comp, label, 1); } fViewer = createViewer(comp); fViewer.setLabelProvider(getLabelProvider()); fViewer.setContentProvider(getContentProvider()); fViewer.setInput(getViewerInput()); List selectedElements = getInitialElementSelections(); if (!CollectionsUtil.isEmpty(selectedElements)) { fViewer.setSelection(new StructuredSelection(selectedElements)); } addViewerListeners(fViewer); addCustomFooterControls(comp); Dialog.applyDialogFont(comp); return comp; }
From source file:com.aptana.portal.ui.dispatch.actionControllers.LaunchActionController.java
License:Open Source License
/** * Returns the available launch type IDs for a given project and mode. * /*from www . j av a 2s . com*/ * @param attributes * Contains the project name and mode of launching. * @return A JSON Map representation for the launch types allowed (ID and Label pairs). */ @ControllerAction public Object getLaunchTypes(Object attributes) { if (!containsMap(attributes)) { return IBrowserNotificationConstants.JSON_ERROR; } Map<String, String> attrMap = (Map<String, String>) ((Object[]) attributes)[0]; // We expect a project name and a launch mode. IProject project = getProject(attrMap.get(ATTR_PROJECT)); if (project == null) { return IBrowserNotificationConstants.JSON_ERROR; } String mode = getMode(attrMap.get(ATTR_MODE)); if (mode == null) { return IBrowserNotificationConstants.JSON_ERROR; } // List<LaunchShortcutExtension> shortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager() // .getLaunchShortcuts(); // List availableShortcuts = new ArrayList(); LaunchingResourceManager lrm = DebugUIPlugin.getDefault().getLaunchingResourceManager(); List<LaunchShortcutExtension> shortcutsForSelection = lrm .getShortcutsForSelection(new StructuredSelection(project), mode); Map<String, String> result = new HashMap<String, String>(); if (CollectionsUtil.isEmpty(shortcutsForSelection)) { return JSON.toString(result); } // Prepare a Map representation for the result (ID to Label map) for (LaunchShortcutExtension shortcut : shortcutsForSelection) { result.put(shortcut.getId(), shortcut.getLabel()); } return JSON.toString(result); }
From source file:com.aptana.portal.ui.dispatch.actionControllers.LaunchActionController.java
License:Open Source License
/** * Launch a project in a given mode with the specified type. * /*from www. j av a 2 s .c om*/ * @param attributes * Contains the project name, mode of launching, and launcher ID retrieved from the * {@link #getLaunchTypes(Object)} call. */ @ControllerAction public Object launch(Object attributes) { if (!containsMap(attributes)) { return IBrowserNotificationConstants.JSON_ERROR; } Map<String, String> attrMap = (Map<String, String>) ((Object[]) attributes)[0]; // We expect a project name and a launch mode. IProject project = getProject(attrMap.get(ATTR_PROJECT)); if (project == null) { return IBrowserNotificationConstants.JSON_ERROR; } String mode = getMode(attrMap.get(ATTR_MODE)); if (mode == null) { return IBrowserNotificationConstants.JSON_ERROR; } String type = attrMap.get(ATTR_TYPE); if (StringUtil.isEmpty(type)) { IdeLog.logError(PortalUIPlugin.getDefault(), new Exception("LaunchActionController - missing type")); //$NON-NLS-1$ } LaunchingResourceManager lrm = DebugUIPlugin.getDefault().getLaunchingResourceManager(); IStructuredSelection projectSelection = new StructuredSelection(project); List<LaunchShortcutExtension> shortcutsForSelection = lrm.getShortcutsForSelection(projectSelection, mode); // Prepare a Map representation for the result (ID to Label map) for (LaunchShortcutExtension shortcut : shortcutsForSelection) { if (type.equals(shortcut.getId())) { innerLaunch(shortcut, projectSelection, mode); // done! return IBrowserNotificationConstants.JSON_OK; } } return IBrowserNotificationConstants.JSON_ERROR; }