Java Code Examples for org.eclipse.swt.widgets.List#getSelection()
The following examples show how to use
org.eclipse.swt.widgets.List#getSelection() .
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: ShowUsesHandler.java From tlaplus with MIT License | 6 votes |
/** * Called when the user selects an item in the List. */ public void widgetSelected(SelectionEvent e) { List list = ((List) e.widget); Spec spec = ToolboxHandle.getCurrentSpec(); if (spec != null) { spec.setModuleToShow(list.getSelection()[0]); String moduleName = list.getSelection()[0]; spec.setModuleToShow(list.getSelection()[0]); int idx = selectString(moduleNames, moduleName); if (idx != -1) { setUseMarkers(showUses[idx], moduleName, spec); } } }
Example 2
Source File: ControlSpaceKeyAdapter.java From hop with Apache License 2.0 | 5 votes |
private static final void applyChanges( Shell shell, List list, Control control, int position, IInsertText insertTextInterface ) { String selection = list.getSelection()[ 0 ].contains( Const.getDeprecatedPrefix() ) ? list.getSelection()[ 0 ].replace( Const.getDeprecatedPrefix(), "" ) : list.getSelection()[ 0 ]; String extra = "${" + selection + "}"; if ( insertTextInterface != null ) { insertTextInterface.insertText( extra, position ); } else { if ( control.isDisposed() ) { return; } if ( list.getSelectionCount() <= 0 ) { return; } if ( control instanceof Text ) { ( (Text) control ).insert( extra ); } else if ( control instanceof CCombo ) { CCombo combo = (CCombo) control; combo.setText( extra ); // We can't know the location of the cursor yet. All we can do is overwrite. } else if ( control instanceof StyledTextComp ) { ( (StyledTextComp) control ).insert( extra ); } else if ( control instanceof StyledText ) { ( (StyledText) control ).insert( extra ); } } if ( !shell.isDisposed() ) { shell.dispose(); } if ( !control.isDisposed() ) { control.setData( Boolean.FALSE ); } }
Example 3
Source File: VarTypeDialog.java From Rel with Apache License 2.0 | 5 votes |
private static String obtainSelectedType(List listVarType) { String[] selected = listVarType.getSelection(); if (selected == null || selected.length == 0) return null; lastVariableType = getVarTypeCode(selected[0]); return lastVariableType; }
Example 4
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 5
Source File: ControlSpaceKeyAdapter.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private static final void applyChanges( Shell shell, List list, Control control, int position, InsertTextInterface insertTextInterface ) { String selection = list.getSelection()[0].contains( Const.getDeprecatedPrefix() ) ? list.getSelection()[0].replace( Const.getDeprecatedPrefix(), "" ) : list.getSelection()[0]; String extra = "${" + selection + "}"; if ( insertTextInterface != null ) { insertTextInterface.insertText( extra, position ); } else { if ( control.isDisposed() ) { return; } if ( list.getSelectionCount() <= 0 ) { return; } if ( control instanceof Text ) { ( (Text) control ).insert( extra ); } else if ( control instanceof CCombo ) { CCombo combo = (CCombo) control; combo.setText( extra ); // We can't know the location of the cursor yet. All we can do is overwrite. } else if ( control instanceof StyledTextComp ) { ( (StyledTextComp) control ).insert( extra ); } else if ( control instanceof StyledText ) { ( (StyledText) control ).insert( extra ); } } if ( !shell.isDisposed() ) { shell.dispose(); } if ( !control.isDisposed() ) { control.setData( Boolean.FALSE ); } }