private boolean findSource() { // Guess, user selects an entry in the list on the right. // Find a comparable entry in the source list... boolean found = false; int targetIndex = wTarget.getSelectionIndex(); // Skip everything after the bracket... String targetString = wTarget.getItem( targetIndex ).toUpperCase(); int length = targetString.length(); boolean first = true; while ( !found && ( length >= 2 || first ) ) { first = false; for ( int i = 0; i < wSource.getItemCount() && !found; i++ ) { if ( wSource.getItem( i ).toUpperCase().indexOf( targetString.substring( 0, length ) ) >= 0 ) { wSource.setSelection( i ); found = true; } } length--; } return found; }
/** * Return the current selection */ public String getSelection() { String selectString = ""; //$NON-NLS-1$ for (int i = 0; i < this.mPropsList.getItems().length; i++) { String testitem = this.mPropsList.getItem(i).trim(); selectString = selectString + testitem; if (i < this.mPropsList.getItems().length - 1) { selectString = selectString + this.mDelimiter; //$NON-NLS-1$ } } return selectString; }
@Override public void widgetSelected( SelectionEvent event ) { int selectionIndex = lstFontFamily.getSelectionIndex(); if( selectionIndex != -1 ) { txtFontFamily.setText( lstFontFamily.getItem( selectionIndex ) ); } } } );
@Override protected String getItemDescription(int index) { return LanguageList.getDisplayName(list.getItem(index)); }
public void modifyText( ModifyEvent event ) { // See if there is a selected Validation // if ( wValidationsList != null && wValidationsList.getItemCount() > 0 && wValidationsList.getSelection().length == 1 ) { int index = wValidationsList.getSelectionIndex(); String description = wValidationsList.getItem( index ); Validation validation = Validation.findValidation( selectionList, description ); String newDescription = wDescription.getText(); validation.setName( newDescription ); wValidationsList.setItem( index, newDescription ); wValidationsList.select( index ); } } } );
@Override protected String getItemDescription(int index) { return Tokens.getTokenDescription(list.getItem(index)); }
private String prepareCopyString() { if (list == null || list.isDisposed()) { return ""; //$NON-NLS-1$ } StringBuilder sb = new StringBuilder(); String newLine = System.getProperty("line.separator"); //$NON-NLS-1$ for (int i = 0; i < list.getItemCount(); i++) { sb.append(list.getItem(i)); sb.append(newLine); } return sb.toString(); }
@Override String doGetStringValue(Object source) { List list = (List) source; int index = list.getSelectionIndex(); if (index >= 0) return list.getItem(index); return null; }
protected void buttonPressed(int buttonId) { if (buttonId == Window.OK) { StringBuffer sb = new StringBuffer(); int length = memberTypesList.getItemCount(); for (int i=0 ; i < length; i++) { sb.append(memberTypesList.getItem(i)); if (i < length - 1) { sb.append(" "); //$NON-NLS-1$ } } result = sb.toString(); } super.buttonPressed(buttonId); }
@Override public void dragSetData(DragSourceEvent event) { String listEntry = sourceList.getItem(sourceList.getSelectionIndex()); String token; Pattern patt = Pattern.compile(REPLACEMENT_OPTIONS_LIST_ENTRY_REGEX); Matcher tokenMatcher = patt.matcher(listEntry); if (tokenMatcher.matches()) { token = tokenMatcher.group(1); event.data = token; } }
/** * Move the current selection in the build list down. */ private void moveSelectionDown() { //Only do this operation on a single selection if (this.buildList.getSelectionCount() == 1) { int currentIndex = this.buildList.getSelectionIndex(); if (currentIndex < this.buildList.getItemCount() - 1) { String elementToMove = this.buildList.getItem(currentIndex); this.buildList.remove(currentIndex); this.buildList.add(elementToMove, currentIndex + 1); this.buildList.select(currentIndex + 1); } } }
public void widgetSelected(SelectionEvent e) { if (EditDriverDialog.this.list.getSelectionCount() > 0) { String selectedItem = EditDriverDialog.this.list .getItem(EditDriverDialog.this.list .getSelectionIndex()); handleLocationEditButtonPressed(selectedItem); updateJarList(); } } });
@Override public void widgetSelected(SelectionEvent e) { int i = categoryList.getSelectionIndex(); if (i > -1) { String name = categoryList.getItem(i); namesList.setItems(namesArray(name)); bAddFile.setEnabled(true); } else { namesList.setItems(new String[0]); bAddFile.setEnabled(false); } } }
void sendTreeDefaultSelection() { //Note, similar DefaultSelectionHandling in SWT List/Table/Tree Event event = new Event (); event.index = this.getFocusIndex (); if (event.index >= 0) event.text = this.getItem (event.index); sendSelectionEvent (SWT.DefaultSelection, event, false); }
void sendTreeDefaultSelection() { //Note, similar DefaultSelectionHandling in SWT List/Table/Tree Event event = new Event (); event.index = this.getFocusIndex (); if (event.index >= 0) event.text = this.getItem (event.index); sendSelectionEvent (SWT.DefaultSelection, event, false); }
void sendTreeDefaultSelection() { //Note, similar DefaultSelectionHandling in SWT List/Table/Tree Event event = new Event (); event.index = this.getFocusIndex (); if (event.index >= 0) event.text = this.getItem (event.index); sendSelectionEvent (SWT.DefaultSelection, event, false); }
public void addFileName(String value) { int i = categoryList.getSelectionIndex(); if (i > -1) { String categoryName = categoryList.getItem(i); LinkedHashSet<String> fileNames = categoryFiles.get(categoryName); fileNames.add(value); namesList.add(value); Object o = tabFolder.getItem(i + 1).getData(); if (o instanceof BoxSettingsTab) ((BoxSettingsTab) o).getSettings().setFileNames(fileNames); } }
/** * Move the current selection in the build list up. */ private void moveSelectionUp() { int currentIndex = this.buildList.getSelectionIndex(); //Only do this operation on a single selection if (currentIndex > 0 && this.buildList.getSelectionCount() == 1) { String elementToMove = this.buildList.getItem(currentIndex); this.buildList.remove(currentIndex); this.buildList.add(elementToMove, currentIndex - 1); this.buildList.select(currentIndex - 1); } }
private void removeRules () { int n = lbLangRules.getSelectionIndex(); if ( n == -1 ) return; String ruleName = lbLangRules.getItem(n); // Ask confirmation MessageBox dlg = new MessageBox(shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL); dlg.setText(shell.getText()); dlg.setMessage(String.format(Res.getString("options.confirmRemoveRules"), ruleName)); //$NON-NLS-1$ switch ( dlg.open() ) { case SWT.CANCEL: case SWT.NO: return; } // Remove srxDoc.getAllLanguageRules().remove(ruleName); srxDoc.setModified(true); updateLanguageRules(null); }