本文整理汇总了Java中org.netbeans.editor.Utilities.isSelectionShowing方法的典型用法代码示例。如果您正苦于以下问题:Java Utilities.isSelectionShowing方法的具体用法?Java Utilities.isSelectionShowing怎么用?Java Utilities.isSelectionShowing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.editor.Utilities
的用法示例。
在下文中一共展示了Utilities.isSelectionShowing方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseReleased
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
public @Override void mouseReleased(MouseEvent evt) {
lastMouseEvent = evt;
setToolTipVisible(false);
// Check that if a selection becomes visible by dragging a mouse
// the tooltip evaluation should be posted.
EditorUI ui = extEditorUI;
if (ui != null) {
JTextComponent component = ui.getComponent();
if (enabled && component != null && Utilities.isSelectionShowing(component)) {
enterTimer.restart();
}
}
}
示例2: actionPerformed
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
Caret caret = target.getCaret();
if (Utilities.isSelectionShowing(caret)) {
EditorFindSupport findSupport = EditorFindSupport.getInstance();
HashMap<String, Object> props = new HashMap<>(findSupport.createDefaultFindProperties());
String searchWord = target.getSelectedText();
int n = searchWord.indexOf('\n');
if (n >= 0) {
searchWord = searchWord.substring(0, n);
}
props.put(EditorFindSupport.FIND_WHAT, searchWord);
props.put(EditorFindSupport.ADD_MULTICARET, Boolean.TRUE);
EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(target);
if (eui.getComponent().getClientProperty("AsTextField") == null) { //NOI18N
findSupport.setFocusedTextComponent(eui.getComponent());
}
findSupport.putFindProperties(props);
findSupport.find(null, false);
props.put(EditorFindSupport.ADD_MULTICARET, Boolean.FALSE);
findSupport.putFindProperties(props);
} else {
try {
int[] identifierBlock = Utilities.getIdentifierBlock((BaseDocument) target.getDocument(), caret.getDot());
if (identifierBlock != null) {
caret.setDot(identifierBlock[0]);
caret.moveDot(identifierBlock[1]);
}
} catch (BadLocationException e) {
LOGGER.log(Level.WARNING, null, e);
}
}
}
}
示例3: actionPerformed
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
EditorFindSupport findSupport = EditorFindSupport.getInstance();
Caret caret = target.getCaret();
int dotPos = caret.getDot();
HashMap<String, Object> props = new HashMap<>(findSupport.createDefaultFindProperties());
String searchWord = null;
boolean revert = false;
Boolean originalValue = null;
Map<String, Object> revertMap = (Map<String, Object>) props.get(EditorFindSupport.REVERT_MAP);
Boolean revertValue = revertMap != null ? (Boolean) revertMap.get(EditorFindSupport.FIND_WHOLE_WORDS) : null;
if (Utilities.isSelectionShowing(caret)) {
// valid selection
searchWord = target.getSelectedText();
originalValue = (Boolean) props.put(EditorFindSupport.FIND_WHOLE_WORDS, Boolean.FALSE);
if (Boolean.FALSE.equals(revertValue)) {
revertMap.remove(EditorFindSupport.FIND_WHOLE_WORDS);
} else {
revert = !Boolean.FALSE.equals(originalValue);
}
} else {
// no selection, get current word
try {
searchWord = Utilities.getIdentifier((BaseDocument) target.getDocument(), dotPos);
originalValue = (Boolean) props.put(EditorFindSupport.FIND_WHOLE_WORDS, Boolean.TRUE);
if (Boolean.TRUE.equals(revertValue)) {
revertMap.remove(EditorFindSupport.FIND_WHOLE_WORDS);
} else {
revert = !Boolean.TRUE.equals(originalValue);
}
} catch (BadLocationException e) {
LOGGER.log(Level.WARNING, null, e);
}
}
if (searchWord != null) {
int n = searchWord.indexOf('\n');
if (n >= 0) {
searchWord = searchWord.substring(0, n);
}
props.put(EditorFindSupport.FIND_WHAT, searchWord);
if (revert) {
revertMap = new HashMap<>();
revertMap.put(EditorFindSupport.FIND_WHOLE_WORDS, originalValue != null ? originalValue : Boolean.FALSE);
props.put(EditorFindSupport.REVERT_MAP, revertMap);
}
props.put(EditorFindSupport.FIND_BLOCK_SEARCH, Boolean.FALSE);
props.put(EditorFindSupport.FIND_BLOCK_SEARCH_START, null);
props.put(EditorFindSupport.FIND_BLOCK_SEARCH_END, null);
EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(target);
if (eui.getComponent().getClientProperty("AsTextField") == null) {
//NOI18N
findSupport.setFocusedTextComponent(eui.getComponent());
}
findSupport.putFindProperties(props);
if (findSupport.find(null, false)) {
findSupport.addToHistory(new EditorFindSupport.SPW((String) props.get(EditorFindSupport.FIND_WHAT), (Boolean) props.get(EditorFindSupport.FIND_WHOLE_WORDS), (Boolean) props.get(EditorFindSupport.FIND_MATCH_CASE), (Boolean) props.get(EditorFindSupport.FIND_REG_EXP)));
}
}
}
}
示例4: actionPerformed
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
Caret caret = target.getCaret();
if (!Utilities.isSelectionShowing(caret)) {
try {
int[] identifierBlock = Utilities.getIdentifierBlock((BaseDocument) target.getDocument(), caret.getDot());
if (identifierBlock != null) {
caret.setDot(identifierBlock[0]);
caret.moveDot(identifierBlock[1]);
}
} catch (BadLocationException e) {
LOGGER.log(Level.WARNING, null, e);
}
}
EditorFindSupport findSupport = EditorFindSupport.getInstance();
HashMap<String, Object> props = new HashMap<>(findSupport.createDefaultFindProperties());
String searchWord = target.getSelectedText();
if (searchWord != null) {
int n = searchWord.indexOf('\n');
if (n >= 0) {
searchWord = searchWord.substring(0, n);
}
props.put(EditorFindSupport.FIND_WHAT, searchWord);
Document doc = target.getDocument();
EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(target);
if (eui.getComponent().getClientProperty("AsTextField") == null) { //NOI18N
findSupport.setFocusedTextComponent(eui.getComponent());
}
findSupport.putFindProperties(props);
findSupport.find(null, false);
if (caret instanceof EditorCaret) {
EditorCaret editorCaret = (EditorCaret) caret;
try {
int[] blocks = findSupport.getBlocks(new int[]{-1, -1}, doc, 0, doc.getLength());
if (blocks[0] >= 0 && blocks.length % 2 == 0) {
List<Position> newCarets = new ArrayList<>();
for (int i = 0; i < blocks.length; i += 2) {
int start = blocks[i];
int end = blocks[i + 1];
if (start == -1 || end == -1) {
break;
}
Position startPos = doc.createPosition(start);
Position endPos = doc.createPosition(end);
newCarets.add(endPos);
newCarets.add(startPos);
}
editorCaret.replaceCarets(newCarets, null); // TODO handle biases
}
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
}
}
}