Java Code Examples for org.eclipse.jface.viewers.StructuredSelection#getFirstElement()
The following examples show how to use
org.eclipse.jface.viewers.StructuredSelection#getFirstElement() .
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: 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 2
Source File: CustomerLoaderDialog.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
@Override protected void buttonPressed(int buttonId) { if (buttonId == 0) { StructuredSelection ss = (StructuredSelection) this.list .getSelection(); IProject project = (IProject) ss.getFirstElement(); path =project.getLocation().toString(); File fileToRead = new File(path + File.separator + "config.xml"); try { Config config = Config.loadXml(new FileInputStream(fileToRead)); id = config.getId(); } catch (FileNotFoundException e) { e.printStackTrace(); } initInfo(); compileLoader(id); close(); } else if (buttonId == 1) { close(); } }
Example 3
Source File: GoNavigatorActionProvider.java From goclipse with Eclipse Public License 1.0 | 6 votes |
@Override public boolean isEnabled() { ISelection selection = selectionProvider.getSelection(); if(selection.isEmpty() || !(selection instanceof StructuredSelection)) { return false; } StructuredSelection ss = (StructuredSelection) selection; if(ss.size() == 1 && ss.getFirstElement() instanceof IFileStore) { IFileStore fileStore = (IFileStore) ss.getFirstElement(); if(!fileStore.fetchInfo().isDirectory()) { this.fileStore = fileStore; return true; } return false; } return false; }
Example 4
Source File: GamlActionProvider.java From gama with GNU General Public License v3.0 | 6 votes |
@Override public void updateActionBars() { final StructuredSelection s = (StructuredSelection) getContext().getSelection(); if (s.isEmpty()) { selection = null; return; } final Object o = s.getFirstElement(); if (!(o instanceof WrappedSyntacticContent)) { selection = null; return; } selection = (WrappedSyntacticContent) o; runAction.selectionChanged(s); revealAction.selectionChanged(s); }
Example 5
Source File: TableCellKeyDelegate.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Finds the appropriate Table Cell siblings when SHIFT is pressed. * * @param siblings * @param pStart * @param direction * @param exclude * @return */ protected List findTableCellSiblings( List siblings, Point pStart, int direction, EditPart exclude ) { AbstractCellEditPart start = (AbstractCellEditPart) exclude; AbstractTableEditPart parent = (AbstractTableEditPart) start.getParent( ); StructuredSelection selection = (StructuredSelection) getViewer( ).getSelection( ); Object obj = selection.getFirstElement( ); if ( obj instanceof AbstractCellEditPart ) { AbstractCellEditPart first = (AbstractCellEditPart) obj; Rectangle constraint = TableCellSelectionHelper.getSelectionRectangle( first, selection.toList( ) ); boolean refined = TableCellSelectionHelper.increaseSelectionRectangle( constraint, parent ); while ( refined ) { refined = TableCellSelectionHelper.increaseSelectionRectangle( constraint, parent ); } translateRectangle( parent, constraint, direction ); alterRectangle( constraint, direction, parent ); return TableCellSelectionHelper.getRectangleSelection( constraint, parent ); } return NULL_LIST; }
Example 6
Source File: CustomerUserInformationDefinitionNameValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public CustomerUserInformationDefinitionNameValidator(final Organization organization, final ColumnViewer viewer) { final StructuredSelection structuredSelection = (StructuredSelection) viewer.getSelection(); final CustomUserInfoDefinition selectedCustomUserDef = (CustomUserInfoDefinition) structuredSelection.getFirstElement(); final String selectedDefinitionName = selectedCustomUserDef.getName(); if (organization != null && organization.getCustomUserInfoDefinitions() != null && organization.getCustomUserInfoDefinitions().getCustomUserInfoDefinition() != null) { for (final CustomUserInfoDefinition def : organization.getCustomUserInfoDefinitions().getCustomUserInfoDefinition()) { if (!def.getName().equalsIgnoreCase(selectedDefinitionName)) { exisingNames.add(def.getName().toLowerCase()); } } } }
Example 7
Source File: TempleteFarmeWizardPage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected boolean validatePage() { canFinish=false; StructuredSelection ss = (StructuredSelection)list.getSelection(); IProject p = (IProject)ss.getFirstElement(); if(project == null) { setPageComplete(false); setErrorMessage("\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A\u9879\u76EE!"); return false; } if ("".equals(pageName.getText())) { setPageComplete(false); setErrorMessage(Messages.PAGENAMEISNOTNULL); return false; } String fileName = pageName.getText() + "_window.html"; IResource resource = p.findMember(new Path("/html/" + fileName)); if(resource != null) { setPageComplete(false); setErrorMessage("doub"); return false; } setErrorMessage(null); setMessage(null); canFinish=true; return true; }
Example 8
Source File: RunMobileDialog.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected void buttonPressed(int buttonId) { if (buttonId == 0) { StructuredSelection ss = (StructuredSelection)this.list.getSelection(); IProject project = (IProject)ss.getFirstElement(); Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); if(validate(getID(project),project)){ final SyncApplicationDialog sad = new SyncApplicationDialog(shell, aMobiles,iMobiles, project); final CountDownLatch threadSignal = new CountDownLatch(aMobiles.size()+iMobiles.size()); sad.open(); sad.run(threadSignal); Job job = new WorkspaceJob("") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { try { threadSignal.await(); } catch (InterruptedException e) { e.printStackTrace(); } sad.finish(); return Status.OK_STATUS; } }; job.schedule(); close(); }else if (buttonId == 1) { close(); }else{ close(); } } else{ close(); } }
Example 9
Source File: BlockSelector.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public void selectionChanged(SelectionChangedEvent event){ TreeViewer tv = (TreeViewer) event.getSource(); StructuredSelection ss = (StructuredSelection) tv.getSelection(); Object selected = null; Object firstElement = ss.isEmpty() ? null : ss.getFirstElement(); if (firstElement instanceof BlockTreeViewerItem) { selected = ((BlockTreeViewerItem) firstElement).getBlock(); } tvfa.updateSelection((Identifiable) selected); if (selected != null) { ContextServiceHolder.get().getRootContext().setTyped(selected); } }
Example 10
Source File: SelectModulaSourceFileDialog.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
@Override protected void updateButtonsEnableState(IStatus status) { Button okButton = getOkButton(); StructuredSelection ss = getSelectedItems(); if (ss.size() == 0 || (ss.getFirstElement() instanceof ListItem && ((ListItem)ss.getFirstElement()).isDelimiter())) { if (okButton != null && !okButton.isDisposed()) { okButton.setEnabled(false); } } else { super.updateButtonsEnableState(status); } }
Example 11
Source File: InvoiceListHeaderComposite.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
String getSelectedInvoiceType(){ StructuredSelection ss = (StructuredSelection) comboViewerType.getSelection(); if (!ss.isEmpty()) { Object firstElement = ss.getFirstElement(); if (firstElement != ALL_ELEMENTS_LABEL) { return (String) firstElement; } } return null; }
Example 12
Source File: ControlFlowView.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.0 */ @Override protected void fillTimeGraphEntryContextMenu(@NonNull IMenuManager menuManager) { ISelection selection = getSite().getSelectionProvider().getSelection(); if (selection instanceof StructuredSelection) { StructuredSelection sSel = (StructuredSelection) selection; if (sSel.getFirstElement() instanceof TimeGraphEntry) { TimeGraphEntry entry = (TimeGraphEntry) sSel.getFirstElement(); ITmfTreeDataModel entryModel = entry.getEntryModel(); if (entryModel instanceof ThreadEntryModel) { menuManager.add(new FollowThreadAction(ControlFlowView.this, entry.getName(), ((ThreadEntryModel) entryModel).getThreadId(), getTrace(entry))); } } } }
Example 13
Source File: TreeUtil.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Find new selected item * * @param selection * the selected element * @param rootEntry * the element to search through recursively * @return the new selected element */ public static ISelection getNewSelection(ISelection selection, @NonNull ITmfTreeViewerEntry rootEntry) { if (selection instanceof StructuredSelection && !selection.isEmpty()) { StructuredSelection structuredSelection = (StructuredSelection) selection; Object element = structuredSelection.getFirstElement(); if (element instanceof ITmfTreeViewerEntry) { ITmfTreeViewerEntry newSelection = findEquivalent(rootEntry, (ITmfTreeViewerEntry) element); return newSelection != null ? new StructuredSelection(newSelection) : StructuredSelection.EMPTY; } } return selection; }
Example 14
Source File: TmfUml2SDSyncLoader.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { ISelection sel = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); if ((sel != null) && (sel instanceof StructuredSelection)) { StructuredSelection stSel = (StructuredSelection) sel; if (stSel.getFirstElement() instanceof TmfSyncMessage) { TmfSyncMessage syncMsg = ((TmfSyncMessage) stSel.getFirstElement()); ITmfTimestamp startTime = syncMsg.getStartTime(); if (startTime == null) { startTime = TmfTimestamp.BIG_BANG; } broadcast(new TmfSelectionRangeUpdatedSignal(this, startTime, startTime, fTrace)); } } }
Example 15
Source File: InvoiceCorrectionView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public LeistungDTO getSelection(){ if (tableViewer != null) { StructuredSelection structuredSelection = (StructuredSelection) tableViewer.getSelection(); if (!structuredSelection.isEmpty()) { return (LeistungDTO) structuredSelection.getFirstElement(); } } return null; }
Example 16
Source File: LabeledInputField.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * get the String/the selected item/text for TEXT, MONEY, LINK, EXECLINK, LIST, COMBO, DATE. For * BOOL, BOOLTRISTATE it returns the label of the control. * * @return */ public String getText(){ if (viewer != null) { StructuredSelection ss = (StructuredSelection) viewer.getSelection(); Object firstElement = ss.getFirstElement(); if (firstElement == null) { return StringConstants.EMPTY; } if (firstElement instanceof INumericEnum) { return Integer.toString(((INumericEnum) firstElement).numericValue()); } return ss.getFirstElement().toString(); } if (ctl instanceof Text) { // for TEXT, MONEY, LINK, EXECLINK return ((Text) ctl).getText(); } else if (ctl instanceof List) { List list = (List) ctl; String[] sel = list.getSelection(); if (sel.length == 0) { return ""; } else { return StringTool.join(sel, StringConstants.COMMA); } } else if (ctl instanceof Combo) { return ((Combo) ctl).getText(); } else if (ctl instanceof Button) { return ((Button) ctl).getText(); } return ""; }
Example 17
Source File: LogContent.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
private void updateDetailsPane(SelectionChangedEvent event) { StructuredSelection structuredSelection = (StructuredSelection) event.getSelection(); if (structuredSelection == null || structuredSelection.isEmpty()) { scrolledFormDetailsText.setText(""); return; } LogEntry<?> logEntry = (LogEntry<?>) (structuredSelection.getFirstElement()); Color foregroundColor = logLabelProvider.getForeground(logEntry); scrolledFormDetailsText.setForeground(foregroundColor); LogEntry.Data data = logEntry.getLogData(); StringBuffer buf = new StringBuffer(); buf.append("<p>"); Date logEntryDate = new Date(data.getTimestamp()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss.SSS"); buf.append(simpleDateFormat.format(logEntryDate)); // Add the log level // FIXME: Need coloring here, for error entries. buf.append(" ["); buf.append(logEntry.getLogData().getLogLevel()); buf.append("]"); // Add the module name buf.append(" ["); buf.append(logEntry.getModuleHandle().getName()); buf.append("] "); buf.append(buildLabelHtml(logEntry)); buf.append("<br/>"); // Add the detailed information, if available String details = buildDetailsHtml(logEntry.getLogData().getDetails()); if (details.length() > 0) { buf.append("<br/>"); buf.append(details); buf.append("<br/>"); } /* * Add help information, if available. */ String helpInfoURL = logEntry.getLogData().getHelpInfoURL(); if (helpInfoURL.length() > 0) { String escapedHelpInfoURL = convertToHtmlContent(helpInfoURL); buf.append("<br/>"); buf.append("See the following URL for additional information:<br/>"); buf.append("<br/>"); buf.append("<a href='"); buf.append(escapedHelpInfoURL); buf.append("'>"); buf.append(escapedHelpInfoURL); buf.append("</a>"); buf.append("<br/>"); } else { /* * TODO: We always defer to the Help Info URL, as the Help Info text is in * HTML, and we're not rendering HTML in this region as yet. */ } buf.append("</p>"); String text = buf.toString(); scrolledFormDetailsTextContents = collapseHtmlFormatting(text); scrolledFormDetailsText.setText(text); }
Example 18
Source File: GwtSuperDevModeCodeServerSettingsTab.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
public String getLogLevel() { StructuredSelection logLevelSelection = (StructuredSelection) logLevelComboViewer.getSelection(); return logLevelSelection.getFirstElement() != null ? logLevelSelection.getFirstElement().toString() : LogLevelArgumentProcessor.DEFAULT_LOG_LEVEL; }
Example 19
Source File: LaborVerordnungDialog.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
@Override protected void okPressed(){ List<ILabOrder> existing = LabOrder.getLabOrdersByOrderId(orderId.getText()); if (existing != null) { String newOrderId = LabOrder.getNextOrderId(); setErrorMessage(String.format(Messages.LaborVerordnungDialog_errorOrderNumber, orderId.getText(), newOrderId)); orderId.setText(newOrderId); return; } final List<LabOrder> orders = createLabOrders(selectionComposite.getSelectedItems()); ElexisEventDispatcher.reload(LabOrder.class); if (getSelectedUser() != null) { createReminder(getSelectedUser(), orders); } saveLastSelectedUser(); StructuredSelection externSelection = (StructuredSelection) externViewer.getSelection(); if (!externSelection.isEmpty()) { IExternLaborOrder extern = (IExternLaborOrder) externSelection.getFirstElement(); extern.order(patient, orders); } // save print settings boolean doPrint = btnPrint.getSelection(); CoreHub.userCfg.set(PREV_PRINT_SETTING, doPrint); if (doPrint) { UiDesk.getDisplay().asyncExec(new Runnable() { @Override public void run(){ Patient pat = ElexisEventDispatcher.getSelectedPatient(); try { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); LabOrderView labOrderView = (LabOrderView) page.showView(LabOrderView.ID); labOrderView.createLabOrderPrint(pat, orders); } catch (PartInitException e) { e.printStackTrace(); } } }); } super.okPressed(); }
Example 20
Source File: CompilerBlock.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
public String getLogLevel() { StructuredSelection logLevelSelection = (StructuredSelection) logLevelComboViewer.getSelection(); return logLevelSelection.getFirstElement() != null ? logLevelSelection.getFirstElement().toString() : LogLevelArgumentProcessor.DEFAULT_LOG_LEVEL; }