List of usage examples for org.eclipse.jface.viewers StructuredSelection size
@Override public int size()
From source file:org.switchyard.tools.ui.editor.diagram.shared.WSDLPortSelectionDialog.java
License:Open Source License
@Override protected void handleSelected(StructuredSelection selection) { // update portTypes list if (selection.isEmpty() || selection.size() != 1 || !(selection.getFirstElement() instanceof IResource)) { _portsList.setInput(null);/*from ww w . j av a 2s .c om*/ return; } Definition definition = _wsdlDefinitions.get(selection.getFirstElement()); if (definition == null) { // we need to load the definition final IResource wsdlFile = (IResource) selection.getFirstElement(); final Definition[] holder = new Definition[1]; BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { public void run() { try { ResourceSet resourceSet = new ResourceSetImpl(); WSDLResourceImpl resource = (WSDLResourceImpl) resourceSet.getResource( URI.createPlatformResourceURI(wsdlFile.getFullPath().toString(), true), true); holder[0] = resource.getDefinition(); } catch (Exception e) { e.printStackTrace(); } } }); definition = holder[0]; _wsdlDefinitions.put(wsdlFile, definition); } Collection<?> services = definition == null ? Collections.emptyList() : definition.getServices().values(); ArrayList<Port> ports = new ArrayList<Port>(); for (Object object : services) { Service service = (Service) object; if (!service.getPorts().values().isEmpty()) { Collection<?> servicePorts = service.getPorts().values(); for (Object svcPort : servicePorts) { ports.add((Port) svcPort); } } } _portsList.setInput(ports); if (ports.size() > 0) { selection = new StructuredSelection(ports.iterator().next()); } else { selection = StructuredSelection.EMPTY; } _portsList.setSelection(selection, true); }
From source file:org.talend.designer.core.ui.editor.TalendSelectionManager.java
License:Open Source License
@Override public void setSelection(ISelection arg0) { if (arg0 instanceof StructuredSelection) { StructuredSelection selection = filterSelection((StructuredSelection) arg0); if (selection.size() != 1) { // if there is more than one element, remove all the selections of labels if (selection.size() > 1) { this.selectionType = ETalendSelectionType.MULTIPLE; } else { this.selectionType = ETalendSelectionType.NONE; }/*from w w w .ja v a2s . c o m*/ super.setSelection(selection); } else { this.selectionType = ETalendSelectionType.SINGLE; super.setSelection(selection); } } else { this.selectionType = ETalendSelectionType.SINGLE; super.setSelection(arg0); } }
From source file:org.talend.designer.core.ui.editor.TalendTabbedPropertySheetPage.java
License:Open Source License
@Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { ISelection newSelection;/* w w w .j ava 2s .co m*/ if (part instanceof AbstractMultiPageTalendEditor) { AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part; newSelection = mpte.getTalendEditor().getViewer().getSelection(); if (selection instanceof StructuredSelection) { StructuredSelection structSel = (StructuredSelection) newSelection; if (structSel.size() != 1) { return; } if (structSel.getFirstElement() instanceof EditPart) { if (structSel.equals(oldSelection)) { // if (getCurrentTab() != null) { // getCurrentTab().setInput(part, selection); // } } else { super.selectionChanged(part, selection); } oldSelection = structSel; } } } else if (part instanceof ContentOutline) { ContentOutline outline = (ContentOutline) part; newSelection = outline.getSelection(); if (selection instanceof StructuredSelection) { StructuredSelection structSel = (StructuredSelection) newSelection; if (structSel.size() != 1) { return; } if (structSel.getFirstElement() instanceof NodeTreeEditPart) { if (structSel.equals(oldSelection)) { // this.getCurrentTab().setInput(part, selection); } else { super.selectionChanged(part, selection); } oldSelection = structSel; } } } }
From source file:org.thanlwinsoft.languagetest.eclipse.editors.TestItemEditor.java
License:Open Source License
@SuppressWarnings("unchecked") public TestItemType[] getSelectedItems() { TestItemType[] items = null;/*from w w w. ja v a 2s. c o m*/ ISelection s = tableViewer.getSelection(); if (s instanceof StructuredSelection) { StructuredSelection ss = (StructuredSelection) s; items = new TestItemType[ss.size()]; int row = 0; Iterator i = ss.iterator(); while (i.hasNext()) { Object o = i.next(); if (ss.getFirstElement() instanceof TestItemType) { items[row++] = (TestItemType) o; } } } return items; }
From source file:rocks.inspectit.ui.rcp.preferences.page.CmrRepositoryPreferencePage.java
/** * Updates the state of the remove and license info buttons depending on the current table * selection./* ww w .j a v a2 s . co m*/ */ private void updateButtonsState() { StructuredSelection structuredSelection = (StructuredSelection) tableViewer.getSelection(); if (structuredSelection.isEmpty()) { removeButton.setEnabled(false); manageLabelsButton.setEnabled(false); } else { removeButton.setEnabled(true); if ((structuredSelection.size() == 1) && (((CmrRepositoryDefinition) structuredSelection.getFirstElement()) .getOnlineStatus() == OnlineStatus.ONLINE)) { manageLabelsButton.setEnabled(true); } else { manageLabelsButton.setEnabled(false); } } }
From source file:sernet.gs.ui.rcp.main.bsi.dialogs.AccessControlEditDialog.java
License:Open Source License
private Composite createRolesComposite(final Composite composite) { GridData gridData;//w w w . j av a2 s .c om final Composite containerRoles = new Composite(composite, SWT.NONE); GridLayout layout = generateGridLayout(COLSPAN_DEFAULT, false, MARGIN_WIDTH_DEFAULT, MARGIN_HEIGHT_DEFAULT); containerRoles.setLayout(layout); GridData gd2 = generateGridData(GridData.GRAB_HORIZONTAL, Boolean.TRUE, Boolean.TRUE, GridData.FILL, GridData.FILL, null); containerRoles.setLayoutData(gd2); Label labelFilter = new Label(containerRoles, SWT.NONE); labelFilter.setText("Filter"); Label labelRole = new Label(containerRoles, SWT.NONE); labelRole.setText(Messages.AccessControlEditDialog_12); labelRole.setLayoutData(generateGridData(SWT.NONE, true, false, GridData.FILL, GridData.CENTER, 4)); filter = new Text(containerRoles, SWT.BORDER); filter.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { // do nothing } @Override public void keyReleased(KeyEvent e) { filterRoleCombo(); switchButtons(comboRole.getText() != null && !comboRole.getText().isEmpty()); } }); filter.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { String filterText = filter.getText(); if (filterText == null || filterText.isEmpty()) { StructuredSelection selection = ((StructuredSelection) viewer.getSelection()); String tableText = ""; if (selection != null && selection.size() > 0) { Object firstElement = selection.getFirstElement(); if (firstElement != null) { tableText = ((Permission) firstElement).getRole(); } } comboRole.setItems(getRoles()); if (!"".equals(tableText) && ArrayUtils.contains(getRoles(), tableText)) { syncCombo(tableText); } } String comboText = comboRole.getText(); switchButtons(comboText != null && !comboText.isEmpty()); } @Override public void focusGained(FocusEvent e) { // do nothing } }); comboRole = new Combo(containerRoles, SWT.DROP_DOWN | SWT.READ_ONLY); comboRole.setItems(getRoles()); comboRole.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String text = comboRole.getText(); syncTable(comboRole.getText()); switchButtons(text != null && !(text.trim().isEmpty())); } }); buttonRead = generateButton(containerRoles, Integer.valueOf(SWT.CHECK), Messages.AccessControlEditDialog_13, Boolean.FALSE, null); buttonWrite = generateButton(containerRoles, Integer.valueOf(SWT.CHECK), Messages.AccessControlEditDialog_14, Boolean.FALSE, null); buttonRead.setEnabled(false); buttonWrite.setEnabled(false); SelectionListener addListener = new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { addPermission(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }; buttonAdd = generateButton(containerRoles, Integer.valueOf(SWT.PUSH), Messages.AccessControlEditDialog_15, null, addListener); buttonAdd.setEnabled(false); gridData = generateGridData(null, Boolean.TRUE, null, Integer.valueOf(SWT.RIGHT), null, null); buttonAdd.setLayoutData(gridData); createViewer(containerRoles); Button buttonRemove = generateButton(containerRoles, Integer.valueOf(SWT.PUSH), Messages.AccessControlEditDialog_16, null, removeListener); gridData = generateGridData(null, null, null, SWT.RIGHT, null, Integer.valueOf(COLSPAN_DEFAULT)); buttonRemove.setLayoutData(gridData); return containerRoles; }
From source file:sernet.verinice.bpm.rcp.TaskView.java
License:Open Source License
protected List<TaskInformation> getSelectedTasks() { final StructuredSelection selection = (StructuredSelection) getViewer().getSelection(); List<TaskInformation> taskList = new ArrayList<TaskInformation>(selection.size()); for (Iterator<Object> iterator = selection.iterator(); iterator.hasNext();) { Object sel = iterator.next(); if (sel instanceof TaskInformation) { taskList.add((TaskInformation) sel); }/* w w w .j a v a 2s.c o m*/ } return taskList; }