use of org.eclipse.jface.text.TextViewer in project cubrid-manager by CUBRID.
the class TextEditorFindReplaceMediator method findNext.
/**
*
* Find next searched string
*
* @return boolean
*/
public static boolean findNext() {
TextViewer st = getCurrentTextEditor();
if (st == null) {
return false;
}
String searchedStr = st.getTextWidget().getSelectionText();
if (searchedStr == null || searchedStr.trim().length() == 0) {
return false;
}
FindReplaceOption findReplaceOption = new FindReplaceOption();
findReplaceOption.setSearchedStr(searchedStr);
return findAndSelect(st.getTextWidget().getCaretOffset(), true, findReplaceOption) >= 0;
}
use of org.eclipse.jface.text.TextViewer in project cubrid-manager by CUBRID.
the class FindReplaceDialog method replaceSelected.
/**
* Replace current selected text with input.
*/
protected void replaceSelected() {
TextViewer st = TextEditorFindReplaceMediator.getCurrentTextEditor();
if (st == null) {
return;
}
IFindReplaceTarget target = TextEditorFindReplaceMediator.getFindAndReplaceInterface();
if (target == null) {
return;
}
if (isTextSelected()) {
try {
target.replaceSelection(replaceText.getText());
} catch (Exception ignored) {
}
updateTextCombo(replaceText);
}
}
use of org.eclipse.jface.text.TextViewer in project cubrid-manager by CUBRID.
the class FindReplaceDialog method setSelectedText.
/**
*
* Set the selected text from focus text editor
*
*/
public void setSelectedText() {
TextViewer textViewer = TextEditorFindReplaceMediator.getCurrentTextEditor();
if (textViewer == null || textViewer.getTextWidget() == null || textViewer.getTextWidget().isDisposed()) {
return;
}
if (findText == null || findText.isDisposed()) {
return;
}
String selectedText = textViewer.getTextWidget().getSelectionText();
if (selectedText == null || selectedText.trim().length() == 0) {
return;
}
if (findText.getItems() != null && Arrays.asList(findText.getItems()).contains(selectedText)) {
findText.setText(selectedText);
} else {
findText.add(selectedText);
findText.setText(selectedText);
}
writeConfiguration();
}
use of org.eclipse.jface.text.TextViewer in project eclipse.platform.text by eclipse.
the class TextViewerTest method testSetRedraw_Bug441827.
@Test
public void testSetRedraw_Bug441827() throws Exception {
Shell shell = new Shell();
try {
TextViewer textViewer = new TextViewer(shell, SWT.NONE);
Document document = new Document("abc");
textViewer.setDocument(document);
int len = document.getLength();
// Select the whole document with the caret at the beginning.
textViewer.setSelectedRange(len, -len);
assertEquals(0, textViewer.getSelectedRange().x);
assertEquals(len, textViewer.getSelectedRange().y);
assertEquals(0, textViewer.getTextWidget().getCaretOffset());
textViewer.setRedraw(false);
textViewer.setRedraw(true);
// Check that the selection and the caret position are preserved.
assertEquals(0, textViewer.getSelectedRange().x);
assertEquals(len, textViewer.getSelectedRange().y);
assertEquals(0, textViewer.getTextWidget().getCaretOffset());
} finally {
shell.dispose();
}
}
use of org.eclipse.jface.text.TextViewer in project linuxtools by eclipse.
the class OcountView method createPartControl.
@Override
public void createPartControl(Composite parent) {
viewer = new TextViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL);
viewer.setEditable(false);
viewer.getTextWidget().setFont(JFaceResources.getFont(IDebugUIConstants.PREF_DETAIL_PANE_FONT));
Control control = viewer.getControl();
GridData gd = new GridData(GridData.FILL_BOTH);
control.setLayoutData(gd);
Document d = new Document(text);
viewer.setDocument(d);
viewer.refresh();
OprofileUiPlugin.getDefault().setOcountView(this);
this.parent = parent;
}
Aggregations