Java Code Examples for org.eclipse.swt.widgets.Text#setSelection()
The following examples show how to use
org.eclipse.swt.widgets.Text#setSelection() .
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: CopyExperimentDialog.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private void createNewExperimentNameGroup(Composite parent) { Font font = parent.getFont(); Composite folderGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; folderGroup.setLayout(layout); folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); String name = fExperiment.getName(); // New experiment name label Label newExperimentLabel = new Label(folderGroup, SWT.NONE); newExperimentLabel.setFont(font); newExperimentLabel.setText(Messages.CopyExperimentDialog_ExperimentNewName); // New experiment name entry field fNewExperimentName = new Text(folderGroup, SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; fNewExperimentName.setLayoutData(data); fNewExperimentName.setFont(font); fNewExperimentName.setFocus(); fNewExperimentName.setText(name); fNewExperimentName.setSelection(0, name.length()); fNewExperimentName.addListener(SWT.Modify, event -> validateNewExperimentName()); }
Example 2
Source File: CopyTraceDialog.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private void createNewTraceNameGroup(Composite parent) { Font font = parent.getFont(); Composite folderGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; folderGroup.setLayout(layout); folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); String name = fTrace.getName(); // New trace name label Label newTraceLabel = new Label(folderGroup, SWT.NONE); newTraceLabel.setFont(font); newTraceLabel.setText(Messages.CopyTraceDialog_TraceNewName); // New trace name entry field fNewTraceName = new Text(folderGroup, SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; fNewTraceName.setLayoutData(data); fNewTraceName.setFont(font); fNewTraceName.setFocus(); fNewTraceName.setText(name); fNewTraceName.setSelection(0, name.length()); fNewTraceName.addListener(SWT.Modify, event -> validateNewTraceName()); }
Example 3
Source File: RenameFolderDialog.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private void createNewTraceNameGroup(Composite parent) { Font font = parent.getFont(); Composite folderGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; folderGroup.setLayout(layout); folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); String name = fFolder.getName(); // New trace name label Label newTaceLabel = new Label(folderGroup, SWT.NONE); newTaceLabel.setFont(font); newTaceLabel.setText(Messages.RenameFolderDialog_FolderNewName); // New trace name entry field fNewFolderNameText = new Text(folderGroup, SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; fNewFolderNameText.setLayoutData(data); fNewFolderNameText.setFont(font); fNewFolderNameText.setFocus(); fNewFolderNameText.setText(name); fNewFolderNameText.setSelection(0, name.length()); fNewFolderNameText.addListener(SWT.Modify, event -> validateNewFolderName()); }
Example 4
Source File: RenameTraceDialog.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private void createNewTraceNameGroup(Composite parent) { Font font = parent.getFont(); Composite folderGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; folderGroup.setLayout(layout); folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); String name = fTrace.getName(); // New trace name label Label newTaceLabel = new Label(folderGroup, SWT.NONE); newTaceLabel.setFont(font); newTaceLabel.setText(Messages.RenameTraceDialog_TraceNewName); // New trace name entry field fNewTraceNameText = new Text(folderGroup, SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; fNewTraceNameText.setLayoutData(data); fNewTraceNameText.setFont(font); fNewTraceNameText.setFocus(); fNewTraceNameText.setText(name); fNewTraceNameText.setSelection(0, name.length()); fNewTraceNameText.addListener(SWT.Modify, event -> validateNewTraceName()); }
Example 5
Source File: AbstractPythonWizardPage.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * @param topLevel */ protected void createNameSelect(Composite topLevel, boolean setFocus) { createNameLabel(topLevel); textName = new Text(topLevel, SWT.BORDER); textName.addKeyListener(this); setLayout(null, textName, null); if (initialTextName != null) { textName.setText(initialTextName); } if (setFocus) { setFocusOn(textName, "name"); textName.setSelection(textName.getText().length()); } //just create an empty to complete the line (that needs 3 items in the layout) Label label = new Label(topLevel, SWT.NONE); label.setText(""); }
Example 6
Source File: FieldWidget_Tests.java From goclipse with Eclipse Public License 1.0 | 6 votes |
@Override protected void doRunTest(Shell shell) { TextFieldWidget textFieldWidget = new TextFieldWidget("blah"); textFieldWidget.createComponent(shell); textFieldWidget.set("1234"); Text textControl = textFieldWidget.getFieldControl(); assertTrue(textControl.getCaretPosition() == 0); checkSelection(textControl, 0, 0); textControl.setSelection(1, 3); checkSelection(textControl, 1, 3); textFieldWidget.doUpdateWidgetFromInput(); checkSelection(textControl, 1, 3); textFieldWidget.set("123"); checkSelection(textControl, 0, 0); }
Example 7
Source File: InputQueryDialog.java From texlipse with Eclipse Public License 1.0 | 5 votes |
/** * Creates and returns the contents of an area of the dialog which appears * below the message and above the button bar. * <p> * The default implementation of this framework method returns * <code>null</code>. Subclasses may override. * </p> * * @param parent * parent composite to contain the custom area * @return the custom area control, or <code>null</code> */ protected Control createCustomArea(Composite parent) { // create the top level composite for the dialog area Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 1; composite.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); composite.setLayoutData(data); field = new Text(composite, SWT.SINGLE | SWT.BORDER); if (initialText != null) { field.setText(initialText); field.setSelection(0, initialText.length()); } field.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); field.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (validator != null) { input = field.getText(); if (input != null) { input = input.trim(); } String error = validator.isValid(input); Button ok = getButton(IDialogConstants.OK_ID); ok.setEnabled(error == null); } else { input = field.getText(); } }}); return composite; }
Example 8
Source File: RenameExperimentDialog.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private void createNewExperimentNameGroup(Composite parent) { Font font = parent.getFont(); Composite folderGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; folderGroup.setLayout(layout); folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); String name = fExperiment.getName(); // New experiment name label Label newExperimentLabel = new Label(folderGroup, SWT.NONE); newExperimentLabel.setFont(font); newExperimentLabel.setText(Messages.RenameExperimentDialog_ExperimentNewName); // New experiment name entry field fNewExperimentName = new Text(folderGroup, SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; fNewExperimentName.setLayoutData(data); fNewExperimentName.setFont(font); fNewExperimentName.setFocus(); fNewExperimentName.setText(name); fNewExperimentName.setSelection(0, name.length()); fNewExperimentName.addListener(SWT.Modify, event -> validateNewExperimentName()); }
Example 9
Source File: TrimTraceDialog.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private void createNewTraceNameGroup(Composite parent) { setStatusLineAboveButtons(true); Font font = parent.getFont(); Composite folderGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; folderGroup.setLayout(layout); folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); String name = fElement.getName(); // New trace name label Label newTaceLabel = new Label(folderGroup, SWT.NONE); newTaceLabel.setFont(font); newTaceLabel.setText(Messages.RenameTraceDialog_TraceNewName); // New trace name entry field GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; Text newElementName = new Text(folderGroup, SWT.BORDER); newElementName.setLayoutData(data); newElementName.setFont(font); newElementName.setFocus(); newElementName.setText(name); newElementName.setSelection(0, name.length()); newElementName.addListener(SWT.Modify, event -> validateNewTraceName()); fNewElementName = newElementName; validateNewTraceName(); }
Example 10
Source File: FindBarDecorator.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void updateTextAfterHistorySelection(String text, String preferenceName) { Text textBox = FindBarEntriesHelper.PREFERENCE_NAME_REPLACE.equals(preferenceName) ? textReplace : textFind; textBox.setForeground(null); textBox.setText(text); textBox.setSelection(0, text.length()); }
Example 11
Source File: FindBarDecorator.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
void inputNewline(Text text) { StringBuilder sb = new StringBuilder(text.getText()); Point selection = text.getSelection(); String delimiter = Text.DELIMITER; sb.replace(selection.x, selection.y, delimiter); text.setText(sb.toString()); text.setSelection(selection.x + delimiter.length()); }
Example 12
Source File: RenameInputWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void setVisible(boolean visible) { if (visible) { INameUpdating nameUpdating= (INameUpdating)getRefactoring().getAdapter(INameUpdating.class); if (nameUpdating != null) { String newName= getNewName(nameUpdating); if (newName != null && newName.length() > 0 && !newName.equals(getInitialValue())) { Text textField= getTextField(); textField.setText(newName); textField.setSelection(0, newName.length()); } } } super.setVisible(visible); }
Example 13
Source File: PyUnitPrefsPage2.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public void widgetSelected(SelectionEvent e) { String comboValue = comboField.getComboValue(); int val = 0; try { val = Integer.parseInt(comboValue); } catch (NumberFormatException e1) { Log.log(e1); } int testRunner = val; String tag; boolean addEquals = true; boolean addSpace = false; if (testRunner == TEST_RUNNER_PYDEV) { tag = "--" + fTag; } else if (testRunner == TEST_RUNNER_PY_TEST) { if ("n".equals(fTag)) { tag = "-" + fTag; addEquals = false; addSpace = true; } else if ("showlocals".equals(fTag) || "runxfail".equals(fTag)) { tag = "--" + fTag; addEquals = false; } else { //durations, maxfail, tb tag = "--" + fTag; } } else { tag = fTag; } Text textControl = parametersField.getTextControl(); String currentText = textControl.getText(); StringTokenizer stringTokenizer = new StringTokenizer(currentText); FastStringBuffer buf = new FastStringBuffer(currentText.length() * 2); boolean found = false; while (stringTokenizer.hasMoreTokens()) { String tok = stringTokenizer.nextToken(); if (tok.startsWith(tag)) { found = true; } buf.append(tok); buf.append('\n'); } if (!found) { buf.append(tag); if (addEquals) { buf.append('='); } if (addSpace) { buf.append(' '); } } else { buf.deleteLast(); //remove the last '\n' } textControl.setText(buf.toString()); textControl.setSelection(textControl.getSize()); textControl.setFocus(); }
Example 14
Source File: JobHistoryDelegate.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void showLogEntry() { JobHistoryLogTab model = models[tabFolder.getSelectionIndex()]; Text text = model.logDisplayText; if ( text == null || text.isDisposed() ) { return; } List<Object[]> list = model.rows; if ( list == null || list.size() == 0 ) { String message; if ( model.logTable.isDefined() ) { message = BaseMessages.getString( PKG, "JobHistory.PleaseRefresh.Message" ); } else { message = BaseMessages.getString( PKG, "JobHistory.HistoryConfiguration.Message" ); } text.setText( message ); return; } // grab the selected line in the table: int nr = model.logDisplayTableView.table.getSelectionIndex(); if ( nr >= 0 && nr < list.size() ) { // OK, grab this one from the buffer... Object[] row = list.get( nr ); // What is the name of the log field? // LogTableField logField = model.logTable.getLogField(); if ( logField != null ) { int index = model.logTableFields.indexOf( logField ); if ( index >= 0 ) { String logText = row[index].toString(); text.setText( Const.NVL( logText, "" ) ); text.setSelection( text.getText().length() ); text.showSelection(); } else { text.setText( BaseMessages.getString( PKG, "JobHistory.HistoryConfiguration.NoLoggingFieldDefined" ) ); } } } }
Example 15
Source File: TransHistoryDelegate.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void showLogEntry() { TransHistoryLogTab model = models[tabFolder.getSelectionIndex()]; Text text = model.logDisplayText; if ( text == null || text.isDisposed() ) { return; } List<Object[]> list = model.rows; if ( list == null || list.size() == 0 ) { String message; if ( model.logTable.isDefined() ) { message = BaseMessages.getString( PKG, "TransHistory.PleaseRefresh.Message" ); } else { message = BaseMessages.getString( PKG, "TransHistory.HistoryConfiguration.Message" ); } text.setText( message ); return; } // grab the selected line in the table: int nr = model.logDisplayTableView.table.getSelectionIndex(); if ( nr >= 0 && nr < list.size() ) { // OK, grab this one from the buffer... Object[] row = list.get( nr ); // What is the name of the log field? // LogTableField logField = model.logTable.getLogField(); if ( logField != null ) { int index = model.logTableFields.indexOf( logField ); if ( index >= 0 ) { String logText = row[index].toString(); text.setText( Const.NVL( logText, "" ) ); text.setSelection( text.getText().length() ); text.showSelection(); } else { text.setText( BaseMessages.getString( PKG, "TransHistory.HistoryConfiguration.NoLoggingFieldDefined" ) ); } } } }