List of usage examples for org.eclipse.jface.viewers StructuredSelection iterator
@Override
public Iterator iterator()
From source file:org.eclipse.titan.designer.editors.configeditor.pages.modulepar.ModuleParameterSectionPage.java
License:Open Source License
private void internalRefresh() { StructuredSelection selection = (StructuredSelection) moduleParametersTableViewer.getSelection(); Iterator<?> iterator = selection.iterator(); if (iterator.hasNext()) { valueChanged = true;//from ww w . j av a 2 s . c o m } else { parameterValueText.setText(""); } add.setEnabled(moduleParametersHandler != null); remove.setEnabled(moduleParametersHandler != null); parameterValueText.setEnabled(moduleParametersHandler != null && selection.size() == 1); moduleParametersTableViewer.setInput(moduleParametersHandler); moduleParametersTable.setEnabled(moduleParametersHandler != null); if (moduleParametersHandler != null) { totalModuleParametersLabel.setText("Total: " + moduleParametersHandler.getModuleParameters().size()); } }
From source file:org.eclipse.titan.designer.editors.configeditor.pages.modulepar.ModuleParameterSectionPage.java
License:Open Source License
public void removeSelectedParameters() { if (moduleParametersTableViewer == null || moduleParametersHandler == null) { return;/*from w w w . jav a2 s . c o m*/ } StructuredSelection selection = (StructuredSelection) moduleParametersTableViewer.getSelection(); Iterator<?> iterator = selection.iterator(); // remove the selected elements for (; iterator.hasNext();) { ModuleParameter moduleParameter = (ModuleParameter) iterator.next(); if (moduleParameter != null) { ConfigTreeNodeUtilities.removeChild(moduleParametersHandler.getLastSectionRoot(), moduleParameter.getRoot()); moduleParametersHandler.getModuleParameters().remove(moduleParameter); } } moduleParametersTableViewer.setSelection(null); }
From source file:org.eclipse.titan.designer.editors.configeditor.pages.testportpar.TestportParametersSectionPage.java
License:Open Source License
private void createDetailsPart(final Composite parent, final ScrolledForm form, final FormToolkit toolkit) { Section section = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR); section.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground()); section.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR)); Composite client = toolkit.createComposite(section, SWT.WRAP); GridLayout layout = new GridLayout(); layout.numColumns = 1;//from w ww . j a v a 2 s . c o m client.setLayout(layout); parameterValueText = toolkit.createText(client, "", SWT.MULTI | SWT.BORDER); parameterValueText.setLayoutData(new GridData(GridData.FILL_BOTH)); parameterValueText.addModifyListener(new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { StructuredSelection selection = (StructuredSelection) testportParametersTableViewer.getSelection(); Iterator<?> iterator = selection.iterator(); if (!iterator.hasNext()) { return; } TestportParameter testportParameter = (TestportParameter) iterator.next(); ConfigTreeNodeUtilities.setText(testportParameter.getValue(), parameterValueText.getText()); if (valueChanged) { valueChanged = false; return; } editor.setDirty(); } }); parameterValueText.setEnabled(testportParametersHandler != null); section.setText("Testport parameter details"); section.setDescription("Specify the concrete value for the actually selected testport parameter."); section.setClient(client); section.setExpanded(true); section.addExpansionListener(new ExpansionAdapter() { @Override public void expansionStateChanged(final ExpansionEvent e) { form.reflow(false); } }); GridData gd = new GridData(GridData.FILL_BOTH); gd.grabExcessVerticalSpace = true; section.setLayoutData(gd); }
From source file:org.eclipse.titan.designer.editors.configeditor.pages.testportpar.TestportParametersSectionPage.java
License:Open Source License
private void internalRefresh() { StructuredSelection selection = (StructuredSelection) testportParametersTableViewer.getSelection(); Iterator<?> iterator = selection.iterator(); if (iterator.hasNext()) { valueChanged = true;//from w ww. j a v a 2 s .com } else { parameterValueText.setText(""); } add.setEnabled(testportParametersHandler != null); remove.setEnabled(testportParametersHandler != null); testportParametersTableViewer.setInput(testportParametersHandler); testportParametersTable.setEnabled(testportParametersHandler != null); parameterValueText.setEnabled(testportParametersHandler != null && selection.size() == 1); if (testportParametersHandler != null) { totalTestportParametersLabel .setText("Total: " + testportParametersHandler.getTestportParameters().size()); } }
From source file:org.eclipse.titan.designer.editors.configeditor.pages.testportpar.TestportParametersSectionPage.java
License:Open Source License
public void removeSelectedParameters() { if (testportParametersTableViewer == null || testportParametersHandler == null) { return;// ww w. j av a2 s . c o m } StructuredSelection selection = (StructuredSelection) testportParametersTableViewer.getSelection(); Iterator<?> iterator = selection.iterator(); // remove the selected elements for (; iterator.hasNext();) { TestportParameter testportParameter = (TestportParameter) iterator.next(); if (testportParameter != null) { ConfigTreeNodeUtilities.removeChild(testportParametersHandler.getLastSectionRoot(), testportParameter.getRoot()); testportParametersHandler.getTestportParameters().remove(testportParameter); } } testportParametersTableViewer.setSelection(null); }
From source file:org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers.AssignLoggerHandler.java
License:Open Source License
@Override public boolean isEnabled() { @NonNull/*w ww . j av a 2s.c o m*/ ArrayList<@NonNull BaseLoggerComponent> loggers = new ArrayList<>(); @NonNull TraceSessionComponent[] sessions = null; TraceDomainType domain = null; // Get workbench page for the Control View IWorkbenchPage page = getWorkbenchPage(); if (page == null) { return false; } // Check if one or more session are selected ISelection selection = page.getSelection(ControlView.ID); if (selection instanceof StructuredSelection) { StructuredSelection structered = ((StructuredSelection) selection); for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) { Object element = iterator.next(); if (element instanceof BaseLoggerComponent) { BaseLoggerComponent logger = (BaseLoggerComponent) element; // The loggers have to be the same domain (multiple selection) if (domain == null) { domain = logger.getDomain(); } else if (!domain.equals(logger.getDomain())) { loggers.clear(); break; } // Add BaseLoggerComponents loggers.add(logger); if (sessions == null) { TargetNodeComponent root = (TargetNodeComponent) logger.getParent().getParent().getParent(); sessions = root.getSessions(); } } } } boolean isEnabled = ((!loggers.isEmpty()) && (sessions != null) && (sessions.length > 0)); if (domain == null) { return false; } fLock.lock(); try { fParam = null; if (isEnabled) { fParam = new Parameter(NonNullUtils.checkNotNull(sessions), loggers, domain); } } finally { fLock.unlock(); } return isEnabled; }
From source file:org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers.ChangeLoggerStateHandler.java
License:Open Source License
@Override public boolean isEnabled() { // Get workbench page for the Control View IWorkbenchPage page = getWorkbenchPage(); if (page == null) { return false; }/* www.jav a 2s. c o m*/ // Check if one or more session are selected ISelection selection = page.getSelection(ControlView.ID); TraceDomainComponent domain = null; ITraceLogLevel logLevel = null; LogLevelType logLevelType = null; List<TraceLoggerComponent> loggers = new ArrayList<>(); if (selection instanceof StructuredSelection) { StructuredSelection structered = ((StructuredSelection) selection); String sessionName = null; String domainName = null; for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) { Object element = iterator.next(); if (element instanceof TraceLoggerComponent) { TraceLoggerComponent logger = (TraceLoggerComponent) element; // This is a work-around the a bug that destroys all the sessions, this bug was fixed in LTTng 2.8.1 // https://github.com/lttng/lttng-tools/pull/75/commits/aae621cf9d9a078f40415495a77e07079690fea1 if (logger.getName().equals("*") && !logger.getTargetNode().isVersionSupported("2.8.1")) { //$NON-NLS-1$ //$NON-NLS-2$ return false; } if (sessionName == null) { sessionName = String.valueOf(logger.getSessionName()); } if (domain == null) { domain = (TraceDomainComponent) logger.getParent(); } if (domainName == null) { domainName = logger.getDomain().name(); } if (logLevel == null) { logLevel = logger.getLogLevel(); } if (logLevelType == null) { logLevelType = logger.getLogLevelType(); } // Enable command only for loggers of same session and domain. // This is because when using the lttng enable-event command to re-enable disabled // loggers we need to pass all the options of the logger, this means that if two loggers are from // different session or domain they need to be enabled in two different lttng commands. At this moment, // it is simpler to disable the context menu. This issue will be addressed later as an enhancement. if ((!sessionName.equals(logger.getSessionName())) || (!domain.getName().equalsIgnoreCase(logger.getDomain().name()))) { loggers.clear(); break; } // Enable command only for loggers of same loglevel and loglevel type // Same reason as explained above. if ((!logLevel.equals(logger.getLogLevel())) || (!logLevelType.equals(logger.getLogLevelType()))) { loggers.clear(); break; } if ((logger.getState() != getNewState())) { loggers.add(logger); } } } } boolean isEnabled = !loggers.isEmpty(); fLock.lock(); try { fParam = null; if (isEnabled) { fParam = new Parameter(domain, loggers, logLevel, logLevelType); } } finally { fLock.unlock(); } return isEnabled; }
From source file:org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers.SaveHandler.java
License:Open Source License
@Override public boolean isEnabled() { // Get workbench page for the Control View IWorkbenchPage page = getWorkbenchPage(); if (page == null) { return false; }//www. j ava 2s. c o m List<TraceSessionComponent> sessions = new ArrayList<>(0); // Check if one or more session are selected ISelection selection = page.getSelection(ControlView.ID); if (selection instanceof StructuredSelection) { StructuredSelection structered = ((StructuredSelection) selection); for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) { Object element = iterator.next(); if (element instanceof TraceSessionComponent) { // Add only TraceSessionComponents that are inactive and not destroyed TraceSessionComponent session = (TraceSessionComponent) element; if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) { sessions.add(session); } } } } boolean isEnabled = !sessions.isEmpty(); fLock.lock(); try { fSessions = null; if (isEnabled) { fSessions = sessions; } } finally { fLock.unlock(); } return isEnabled; }
From source file:org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers.SnapshotHandler.java
License:Open Source License
@Override public boolean isEnabled() { // Get workbench page for the Control View IWorkbenchPage page = getWorkbenchPage(); if (page == null) { return false; }/*from w w w . ja va 2 s . c o m*/ List<TraceSessionComponent> sessions = new ArrayList<>(0); // Check if one session is selected ISelection selection = page.getSelection(ControlView.ID); if (selection instanceof StructuredSelection) { StructuredSelection structered = ((StructuredSelection) selection); for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) { Object element = iterator.next(); if (element instanceof TraceSessionComponent) { // Add only if corresponding TraceSessionComponent is an active snapshot session and not destroyed TraceSessionComponent session = (TraceSessionComponent) element; if (session.isSnapshotSession() && !session.isDestroyed()) { sessions.add(session); } } } } boolean isEnabled = !sessions.isEmpty(); fLock.lock(); try { fSessions.clear(); if (isEnabled) { fSessions.addAll(sessions); } } finally { fLock.unlock(); } return isEnabled; }
From source file:org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.java
License:Open Source License
/** * Returns the current selection./*from w ww . j a va2 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 List newItems = new ArrayList(selectedItems); newItems.remove(itemToRemove); return new StructuredSelection(newItems); }