org.eclipse.jface.viewers.StructuredSelection Java Examples
The following examples show how to use
org.eclipse.jface.viewers.StructuredSelection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FindbugsPlugin.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
public static void showMarker(IMarker marker, String viewId, IWorkbenchPart source) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart view = page.findView(viewId); if (!page.isPartVisible(view)) { try { view = page.showView(viewId); } catch (PartInitException e) { FindbugsPlugin.getDefault().logException(e, "Could not open view: " + viewId); return; } } if (view instanceof IMarkerSelectionHandler) { IMarkerSelectionHandler handler = (IMarkerSelectionHandler) view; handler.markerSelected(source, marker); } else if (DETAILS_VIEW_ID.equals(viewId) && view instanceof ISelectionListener) { ISelectionListener listener = (ISelectionListener) view; listener.selectionChanged(source, new StructuredSelection(marker)); } }
Example #2
Source File: TabbedPropertySynchronizerListener.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private ITabbedPropertySelectionProvider findDefaultProvider(final IWorkbenchPart editorPart, final IGraphicalEditPart editPart) { final String selectedViewId = activePropertyView(activePage); String selectedTabId = null; ITabbedPropertySelectionProvider defaultProvider = null; if (selectedViewId != null) { selectedTabId = activePropertyTabId(activePage, selectedViewId); final TabbedPropertySheetPage propertySheetPage = activePropertyTab(activePage, selectedViewId); if (propertySheetPage != null && propertySheetPage.getSelectedTab() != null) { final List<ISectionDescriptor> sectionDescriptors = propertySheetPage.getSelectedTab().getSectionDescriptors(); for (final ISectionDescriptor descriptor : sectionDescriptors) { if (descriptor.appliesTo(editorPart, new StructuredSelection(editPart))) { defaultProvider = DefaultTabbedPropertyProvider.defaultProvider(selectedViewId, selectedTabId); break; } } } } return defaultProvider; }
Example #3
Source File: OsgiEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * This sets the selection into whichever viewer is active. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setSelectionToViewer ( Collection<?> collection ) { final Collection<?> theSelection = collection; // Make sure it's okay. // if ( theSelection != null && !theSelection.isEmpty () ) { Runnable runnable = new Runnable () { public void run () { // Try to select the items in the current content viewer of the editor. // if ( currentViewer != null ) { currentViewer.setSelection ( new StructuredSelection ( theSelection.toArray () ), true ); } } }; getSite ().getShell ().getDisplay ().asyncExec ( runnable ); } }
Example #4
Source File: SelectionHandler.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Returns a <code>List</code> containing the currently selected objects. * * @return A List containing the currently selected objects. */ protected IStructuredSelection getSelection( ) { IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( ); Object selectVariable = UIUtil.getVariableFromContext( context, ISources.ACTIVE_CURRENT_SELECTION_NAME ); if ( selectVariable != null ) { if ( selectVariable instanceof IStructuredSelection ) { return (IStructuredSelection) selectVariable; } else { return new StructuredSelection( selectVariable ); } } return null; }
Example #5
Source File: AddMessageEventWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Refresh target combo content */ private void refreshTargetEventContent() { if (processExpressionViewer.getSelection() != null && !processExpressionViewer.getSelection().isEmpty()) { final Expression procName = (Expression) ((StructuredSelection) processExpressionViewer .getSelection()).getFirstElement(); if (procName.getType().equals(ExpressionConstants.CONSTANT_TYPE)) { final AbstractProcess proc = getProcessOnDiagram( ModelHelper.getMainProcess(element), procName.getContent()); final DiagramRepositoryStore store = RepositoryManager .getInstance().getRepositoryStore( DiagramRepositoryStore.class); final List<AbstractProcess> processes = store .findProcesses(procName.getContent()); if (proc != null) { processes.add(proc); } catchEventNatureProvider.setFoundProcesses(processes); } else { catchEventNatureProvider.setFoundProcesses(null); } elementExpressionViewer.updateAutocompletionProposals(); } }
Example #6
Source File: N4JSNavigatorActionProvider.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override public void setContext(final ActionContext context) { super.setContext(context); projectGroup.setContext(context); // context is null if disposal of the provider is triggered if (null != context) { StructuredSelection selection = (StructuredSelection) context.getSelection(); List<Object> selectedElements = Arrays.asList(selection.toArray()); selectionContainsWorkingSet = selectedElements.stream() .anyMatch(element -> element instanceof WorkingSet); // try to minimize number of context updates for working set action provider if (selectionContainsWorkingSet) { workingSetActionProvider.setContext(context); } assignWorkingSetsAction.selectionChanged(selection); } }
Example #7
Source File: BindingGroupDescriptor.java From birt with Eclipse Public License 1.0 | 6 votes |
private void saveBinding( ) { BindingInfo info = new BindingInfo( ); if ( datasetRadio.getSelection( ) ) { info = (BindingInfo) ( (StructuredSelection) datasetCombo.getSelection( ) ).getFirstElement( ); } else { info.setBindingType( ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF ); info.setBindingValue( reportItemCombo.getText( ) ); } try { this.oldInfo = info; save( info ); } catch ( SemanticException e ) { ExceptionHandler.handle( e ); } }
Example #8
Source File: DragAndDropSupport.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void dragSetData(DragSourceEvent event){ // we know that we use the RowSelectionModel with single selection StructuredSelection selection = (StructuredSelection) tableWrapper.getSelection(); if (!selection.isEmpty()) { this.draggedObjects = new ArrayList<>(selection.toList()); StringBuilder builder = new StringBuilder(); for (Object object : draggedObjects) { if(builder.length() > 0) { builder.append(DATA_SEPARATOR); } builder.append(getStringForObject(object)); } event.data = builder.toString(); } }
Example #9
Source File: ConditionalRoutePropertiesEditionPartImpl.java From eip-designer with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * @see com.github.lbroudoux.dsl.eip.parts.ConditionalRoutePropertiesEditionPart#setChannel(EObject newValue) * */ public void setChannel(EObject newValue) { if (newValue != null) { channel.setSelection(new StructuredSelection(newValue)); } else { channel.setSelection(new StructuredSelection()); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.ConditionalRoute.Properties.channel); if (eefElementEditorReadOnlyState && channel.isEnabled()) { channel.setEnabled(false); channel.setToolTipText(EipMessages.ConditionalRoute_ReadOnly); } else if (!eefElementEditorReadOnlyState && !channel.isEnabled()) { channel.setEnabled(true); } }
Example #10
Source File: MainEntryPoint.java From neoscada with Eclipse Public License 1.0 | 6 votes |
protected void handleSelectionChanged ( final SelectionChangedEvent event ) { if ( this.handlingEvent ) { return; } final TreeNode node = (TreeNode) ( (IStructuredSelection)event.getSelection () ).getFirstElement (); final TreeNode nodeShown = this.manager.showPage ( node ); try { this.handlingEvent = true; // select the node, could also be the old one this.viewer.setSelection ( new StructuredSelection ( nodeShown ), true ); } finally { this.handlingEvent = false; } }
Example #11
Source File: ReportPropertySheetPage.java From birt with Eclipse Public License 1.0 | 6 votes |
public void performRequest( IMediatorRequest request ) { if ( ReportRequest.SELECTION.equals( request.getType( ) ) ) { // Remove null from the list. That fix the bug 139422 ArrayList<Object> selections = new ArrayList<Object>( ); selections.add( null ); selections.addAll( ( (ReportRequest) request ).getSelectionModelList( ) ); ArrayList<Object> nullList = new ArrayList<Object>( ); nullList.add( null ); selections.removeAll( nullList ); // end handleSelectionChanged( new StructuredSelection( selections ) ); } }
Example #12
Source File: BugExplorerView.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void markerSelected(IWorkbenchPart part, IMarker marker) { if (selectionInProgress) { return; } BugContentProvider provider = BugContentProvider.getProvider(getNavigatorContentService()); CommonViewer commonViewer = getCommonViewer(); if (marker == null) { commonViewer.setSelection(new StructuredSelection(), false); } else if (provider.isFiltered(marker)) { Object parent = provider.getParent(marker); if (parent != null) { commonViewer.setSelection(new StructuredSelection(parent), true); } } else { commonViewer.setSelection(new StructuredSelection(marker), true); } }
Example #13
Source File: WorldEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * This sets the selection into whichever viewer is active. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setSelectionToViewer ( Collection<?> collection ) { final Collection<?> theSelection = collection; // Make sure it's okay. // if ( theSelection != null && !theSelection.isEmpty () ) { Runnable runnable = new Runnable () { public void run () { // Try to select the items in the current content viewer of the editor. // if ( currentViewer != null ) { currentViewer.setSelection ( new StructuredSelection ( theSelection.toArray () ), true ); } } }; getSite ().getShell ().getDisplay ().asyncExec ( runnable ); } }
Example #14
Source File: SuperInterfaceSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addSelectedInterfaces() { StructuredSelection selection= getSelectedItems(); if (selection == null) return; for (Iterator<?> iter= selection.iterator(); iter.hasNext();) { Object obj= iter.next(); if (obj instanceof TypeNameMatch) { accessedHistoryItem(obj); TypeNameMatch type= (TypeNameMatch) obj; String qualifiedName= getNameWithTypeParameters(type.getType()); String message; if (fTypeWizardPage.addSuperInterface(qualifiedName)) { message= Messages.format(NewWizardMessages.SuperInterfaceSelectionDialog_interfaceadded_info, BasicElementLabels.getJavaElementName(qualifiedName)); } else { message= Messages.format(NewWizardMessages.SuperInterfaceSelectionDialog_interfacealreadyadded_info, BasicElementLabels.getJavaElementName(qualifiedName)); } updateStatus(new StatusInfo(IStatus.INFO, message)); } } }
Example #15
Source File: InsertInLayoutUtil.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Converts edit part selection into model selection. * * @param selection * edit part * @return model, return Collections.EMPTY_LIST if selection is null or * empty. */ public static IStructuredSelection editPart2Model( ISelection selection ) { if ( selection == null || !( selection instanceof IStructuredSelection ) ) return new StructuredSelection( Collections.EMPTY_LIST ); List list = ( (IStructuredSelection) selection ).toList( ); List resultList = new ArrayList( ); for ( int i = 0; i < list.size( ); i++ ) { Object obj = list.get( i ); if ( obj instanceof ReportElementEditPart ) { Object model = ( (ReportElementEditPart) obj ).getModel( ); if ( model instanceof ListBandProxy ) { model = ( (ListBandProxy) model ).getSlotHandle( ); } resultList.add( model ); } } return new StructuredSelection( resultList ); }
Example #16
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 6 votes |
/** * Hook that allows to add actions to the context menu. * <p> * Subclasses may extend in order to add other actions.</p> * * @param menuManager the context menu manager * @since 3.5 */ protected void fillContextMenu(IMenuManager menuManager) { List selectedElements= ((StructuredSelection)list.getSelection()).toList(); Object item= null; for (Iterator it= selectedElements.iterator(); it.hasNext();) { item= it.next(); if (item instanceof ItemsListSeparator || !isHistoryElement(item)) { return; } } if (selectedElements.size() > 0) { removeHistoryItemAction.setText(WorkbenchMessages.FilteredItemsSelectionDialog_removeItemsFromHistoryAction); menuManager.add(removeHistoryActionContributionItem); } }
Example #17
Source File: JointDataSetPage.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * populate columns for the selection changed of comboViewer * * @param columsItems */ private void populateColumns( DataSetViewData[] columsItems ) { if ( leftSelected ) { this.leftColumnList.setInput( columsItems ); if ( columsItems != null && leftColumnList.getElementAt( 0 ) != null ) { this.leftColumnList.setSelection( new StructuredSelection( leftColumnList.getElementAt( 0 ) ) ); this.leftColumnSelection = ( (DataSetViewData) leftColumnList.getElementAt( 0 ) ).getName( ); } } else { this.rightColumnList.setInput( columsItems ); if ( columsItems != null && rightColumnList.getElementAt( 0 ) != null ) { this.rightColumnList.setSelection( new StructuredSelection( rightColumnList.getElementAt( 0 ) ) ); this.rightColumnSelection = ( (DataSetViewData) rightColumnList.getElementAt( 0 ) ).getName( ); } } }
Example #18
Source File: SectionList.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void createComponentViewer(Composite composite) { UI.formLabel(composite, toolkit, M.Component); componentViewer = new ComboViewer(composite); UI.gridData(componentViewer.getControl(), false, false).widthHint = 250; componentViewer.setContentProvider(ArrayContentProvider .getInstance()); componentViewer.setLabelProvider(new ComponentLabel()); componentViewer.setInput(ReportComponent.values()); componentViewer.addSelectionChangedListener((evt) -> { ReportComponent c = Viewers.getFirst(evt.getSelection()); if (c == null || c == ReportComponent.NONE) model.componentId = null; else model.componentId = c.getId(); editor.setDirty(true); }); if (model.componentId != null) componentViewer.setSelection(new StructuredSelection( ReportComponent.getForId(model.componentId))); }
Example #19
Source File: PropertiesView.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
@Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (part == null || selection == null) { return; } if (!(part instanceof TmxEditorViewer)) { return; } if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) { return; } // tgtLangcodeInTmxEditor = TmxEditorViewer.getInstance().getTmxEditor().getTgtLang(); StructuredSelection struct = (StructuredSelection) selection; Object obj = struct.getFirstElement(); if (obj instanceof TmxEditorSelection) { currentSelected = (TmxEditorSelection) obj; tableViewerManager.get(TU_ATTRS).setInput(new TableViewerInput(TU_ATTRS, currentSelected)); tableViewerManager.get(TUV_ATTRS).setInput(new TableViewerInput(TUV_ATTRS, currentSelected)); tableViewerManager.get(TU_NODE_NOTE).setInput(null); tableViewerManager.get(TU_NODE_NOTE).setInput(new TableViewerInput(TU_NODE_NOTE, currentSelected)); tableViewerManager.get(TU_NODE_PROPS).setInput(new TableViewerInput(TU_NODE_PROPS, currentSelected)); compostie.layout(); scrolledComposite.setMinSize(compostie.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } }
Example #20
Source File: PropertiesFileEditorPreferencePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void initialize() { initializeFields(); for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++) fHighlightingColorList.add(new HighlightingColorListItem (fSyntaxColorListModel[i][0], fSyntaxColorListModel[i][1], fSyntaxColorListModel[i][1] + BOLD, fSyntaxColorListModel[i][1] + ITALIC, fSyntaxColorListModel[i][1] + STRIKETHROUGH, fSyntaxColorListModel[i][1] + UNDERLINE, null)); fHighlightingColorListViewer.setInput(fHighlightingColorList); fHighlightingColorListViewer.setSelection(new StructuredSelection(fHighlightingColorListViewer.getElementAt(0))); // Make sure we propagate the colors to the shared color manager IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); PropertiesFileSourceViewerConfiguration sharedPropertiesFileSourceViewerConfiguration= new PropertiesFileSourceViewerConfiguration(textTools.getColorManager(), store, null, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING); new SourcePreviewerUpdater(fPreviewViewer, sharedPropertiesFileSourceViewerConfiguration, store); }
Example #21
Source File: RowSelectionProvider.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public ISelection getSelection() { int[] rowPositions = selectionLayer.getFullySelectedRowPositions(); if (rowPositions.length > 0) { Arrays.sort(rowPositions); int rowPosition = rowPositions[rowPositions.length - 1]; int rowIndex = selectionLayer.getRowIndexByPosition(rowPosition); return new StructuredSelection(rowIndex); } return new StructuredSelection(); }
Example #22
Source File: ExpressionSyntaxColoringPage.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void performDefaults( ) { super.performDefaults( ); getOverlayStore( ).loadDefaults( ); applyStyles( ); fStylesViewer.setSelection( StructuredSelection.EMPTY ); activate( null ); fText.redraw( ); }
Example #23
Source File: CustomRubberbandDragTracker.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected void performMarqueeSelect() { super.performMarqueeSelect() ; EditPartViewer viewer = getCurrentViewer(); if(viewer.getSelection().isEmpty() || ((StructuredSelection) viewer.getSelection()).getFirstElement() instanceof DiagramEditPart){ viewer.setSelection(new StructuredSelection(viewer.findObjectAt(getStartLocation()).getParent())) ; } }
Example #24
Source File: CleanUpRefactoringWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void openPropertyDialog(ListDialogField<IJavaProject> field) { IJavaProject project= field.getSelectedElements().get(0); PreferencesUtil.createPropertyDialogOn(fShell, project, CleanUpPreferencePage.PROP_ID, null, null).open(); List<?> selectedElements= field.getSelectedElements(); fProvider.reset(); field.refresh(); field.selectElements(new StructuredSelection(selectedElements)); }
Example #25
Source File: ContractPropertySectionTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_bindRemoveButtonEnablement_convert_boolean_value() throws Exception { section.init(new WritableValue(aContract().build(), Contract.class)); final Button removeButton = new Button(parent, SWT.PUSH); final TableViewer inputsTableViewer = new TableViewer(parent); inputsTableViewer.setLabelProvider(new LabelProvider()); inputsTableViewer.setContentProvider(ArrayContentProvider.getInstance()); inputsTableViewer.setInput(Arrays.asList("item")); section.bindRemoveButtonEnablement(removeButton, inputsTableViewer); assertThat(removeButton.isEnabled()).isFalse(); assertThat(inputsTableViewer.getSelection().isEmpty()).isTrue(); inputsTableViewer.setSelection(new StructuredSelection("item")); assertThat(removeButton.isEnabled()).isTrue(); assertThat(inputsTableViewer.getSelection().isEmpty()).isFalse(); }
Example #26
Source File: JsFileFormProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
public boolean isUpEnable( Object selectedObject ) { if ( selectedObject instanceof StructuredSelection && !( (StructuredSelection) selectedObject ).isEmpty( ) ) { IncludeScriptHandle includeScriptHandle = (IncludeScriptHandle) ( (StructuredSelection) selectedObject ).getFirstElement( ); if ( includeScriptHandle.getElementHandle( ) != inputElement ) { return false; } else { List handles = Arrays.asList( getElements( inputElement ) ); int index = -1; for ( int i = 0; i < handles.size( ); i++ ) { IncludeScriptHandle handle = (IncludeScriptHandle) handles.get( i ); if ( handle.getFileName( ) .equals( includeScriptHandle.getFileName( ) ) ) { index = i; break; } } if ( index > 0 ) { IncludeScriptHandle nextHandle = (IncludeScriptHandle) handles.get( index - 1 ); if ( nextHandle.getElementHandle( ) != inputElement ) { return false; } } } } return true; }
Example #27
Source File: BibtexEntryView.java From slr-toolkit with Eclipse Public License 1.0 | 5 votes |
/** * create a listener for listening the comboviewer. * * @return the listener */ private ISelectionChangedListener createProjectListener() { ISelectionChangedListener result = new ISelectionChangedListener() { private IProject lastProject = null; @Override public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() == null || event.getSelection().isEmpty()) { deleteResources(); return; } if (event.getSelection() instanceof StructuredSelection) { Object element = ((StructuredSelection) event.getSelection()).getFirstElement(); if (element.equals(lastProject)) { return; } if (element instanceof IProject) { IProject project = (IProject) element; deleteResources(); registerResources(project); viewer.refresh(); closeEditors(); lastProject = project; try { ResourcesPlugin.getWorkspace().getRoot() .setPersistentProperty(new QualifiedName(ID, "project"), lastProject.getName()); } catch (CoreException e) { e.printStackTrace(); } } } } }; return result; }
Example #28
Source File: CallHierarchyViewPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the current selection. * @return selection */ protected ISelection getSelection() { StructuredViewer viewerInFocus= fSelectionProviderMediator.getViewerInFocus(); if (viewerInFocus != null) { return viewerInFocus.getSelection(); } return StructuredSelection.EMPTY; }
Example #29
Source File: JarFileFormProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
public boolean isDownEnable( Object selectedObject ) { if ( selectedObject instanceof StructuredSelection && !( (StructuredSelection) selectedObject ).isEmpty( ) ) { ScriptLibHandle ScriptLibHandle = (ScriptLibHandle) ( (StructuredSelection) selectedObject ).getFirstElement( ); if ( ScriptLibHandle.getElementHandle( ) != inputElement ) { return false; } else { List handles = Arrays.asList( getElements( inputElement ) ); int index = -1; for ( int i = 0; i < handles.size( ); i++ ) { ScriptLibHandle handle = (ScriptLibHandle) handles.get( i ); if ( handle.getName( ).equals( ScriptLibHandle.getName( ) ) ) { index = i; break; } } if ( handles.size( ) > index + 1 ) { ScriptLibHandle nextHandle = (ScriptLibHandle) handles.get( index + 1 ); if ( nextHandle.getElementHandle( ) != inputElement ) { return false; } } } } return true; }
Example #30
Source File: ProjectActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void performSelectionChanged(IStructuredSelection structuredSelection) { Object[] array= structuredSelection.toArray(); ArrayList<IProject> openProjects= new ArrayList<IProject>(); int selectionStatus= evaluateSelection(array, openProjects); StructuredSelection sel= new StructuredSelection(openProjects); fOpenAction.setEnabled(hasClosedProjectsInWorkspace()); fEnableOpenInContextMenu= (selectionStatus & CLOSED_PROJECTS_SELECTED) != 0 || (selectionStatus == 0 && array.length == 0 && hasClosedProjectsInWorkspace()); fCloseAction.selectionChanged(sel); fCloseUnrelatedAction.selectionChanged(sel); }