use of javafx.scene.control.IndexRange in project RichTextFX by FXMisc.
the class GenericStyledAreaBehavior method handleFirstPrimaryPress.
private void handleFirstPrimaryPress(MouseEvent e) {
// ensure focus
view.requestFocus();
CharacterHit hit = view.hit(e.getX(), e.getY());
view.clearTargetCaretOffset();
IndexRange selection = view.getSelection();
if (view.isEditable() && selection.getLength() != 0 && hit.getCharacterIndex().isPresent() && hit.getCharacterIndex().getAsInt() >= selection.getStart() && hit.getCharacterIndex().getAsInt() < selection.getEnd()) {
// press inside selection
dragSelection = DragState.POTENTIAL_DRAG;
dragNewSelection = DragState.NO_DRAG;
} else {
dragSelection = DragState.NO_DRAG;
dragNewSelection = DragState.NO_DRAG;
view.getOnOutsideSelectionMousePressed().handle(e);
}
}
use of javafx.scene.control.IndexRange in project RichTextFX by FXMisc.
the class SimpleEditableStyledDocumentTest method testGetStyleRangeAtPosition.
@Test
public void testGetStyleRangeAtPosition() {
SimpleEditableStyledDocument<String, String> document = new SimpleEditableStyledDocument<>("", "");
String first = "some";
String second = " text";
replaceText(document, 0, 0, first + second);
document.setStyle(0, first.length(), "abc");
IndexRange range = document.getStyleRangeAtPosition(0);
IndexRange expected = new IndexRange(0, first.length());
assertEquals(expected, range);
range = document.getStyleRangeAtPosition(first.length());
assertEquals(expected, range);
range = document.getStyleRangeAtPosition(first.length() + 1);
expected = new IndexRange(first.length(), (first + second).length());
assertEquals(expected, range);
}
use of javafx.scene.control.IndexRange in project JFoenix by jfoenixadmin.
the class JFXPasswordField method cut.
/**
*************************************************************************
* *
* Methods *
* *
*************************************************************************
*/
@Override
public void cut() {
if (isMaskedText()) {
// No-op
return;
}
copy();
IndexRange selection = getSelection();
deleteText(selection.getStart(), selection.getEnd());
}
use of javafx.scene.control.IndexRange in project Gargoyle by callakrsos.
the class ASTSqlCodeAreaHelper method createResourceView.
@Override
public ResourceView<Map<String, Object>> createResourceView() {
TableOpenResourceView tableOpenResourceView = new TableOpenResourceView(connectionSupplier) {
/* (non-Javadoc)
* @see com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView#close()
*/
@Override
public void close() {
super.close();
codeArea.getPopupWindow().hide();
ResultDialog<Map<String, Object>> result = getResult();
if (result.getStatus() == ResultDialog.SELECT) {
Map<String, Object> data = result.getData();
if (data == null)
return;
String tableName = getTableName(data);
if (tableName == null)
return;
// Object object = data.get("table_name");
// if (object == null)
// return;
String string = currentPragraph(codeArea);
int markTextColumnIndex = getIndexOfValideWhiteSpace(string);
if (markTextColumnIndex == -1) {
codeArea.getUndoManager().mark();
codeArea.appendText(tableName);
} else {
int anchor = codeArea.getAnchor();
int start = anchor - string.length() + markTextColumnIndex;
IndexRange normalize = IndexRange.normalize(start, anchor);
codeArea.getUndoManager().mark();
codeArea.replaceText(normalize, tableName);
}
}
}
};
return tableOpenResourceView.getView();
}
use of javafx.scene.control.IndexRange in project Gargoyle by callakrsos.
the class CodeAreaFindAndReplaceHelper method findReplaceEvent.
/**
* 찾기 바꾸기 이벤트
*
* @작성자 : KYJ
* @작성일 : 2016. 10. 13.
* @param e
*/
protected void findReplaceEvent(Event e) {
if (e.isConsumed())
return;
ObservableValue<String> textProperty = codeArea.textProperty();
TextSearchAndReplaceView textSearchView = new TextSearchAndReplaceView(codeArea, textProperty);
textSearchView.setOnSearchResultListener((vo) -> {
switch(vo.getSearchType()) {
case SEARCH_SIMPLE:
{
int startIndex = vo.getStartIndex();
int endIndex = vo.getEndIndex();
codeArea.selectRange(startIndex, endIndex);
LOGGER.debug(String.format("find text : %s startIdx :%d endIdx :%d", vo.getSearchText(), startIndex, endIndex));
break;
}
case SEARCH_ALL:
{
int startIndex = vo.getStartIndex();
String searchText = vo.getSearchText();
String replaceText = vo.getReplaceText();
// codeArea.getUndoManager().mark();
// codeArea.replaceText(startIndex, (startIndex +
// searchText.length()), replaceText);
setContent(startIndex, startIndex + searchText.length(), replaceText);
break;
}
}
});
textSearchView.setOnReplaceResultListener(vo -> {
switch(vo.getReaplceType()) {
case SIMPLE:
{
String reaplceResult = vo.getReaplceResult();
setContent(reaplceResult);
break;
}
case ALL:
{
String reaplceResult = vo.getReaplceResult();
setContent(reaplceResult);
break;
}
}
});
textSearchView.setOnSelectionMoveListener(vo -> {
codeArea.selectRange(vo.getStartIndex(), vo.getEndIndex());
});
textSearchView.isSelectScopePropertyProperty().addListener((oba, oldval, newval) -> {
if (newval)
LOGGER.debug("User Select Locale Scope..");
else
LOGGER.debug("User Select Gloval Scope..");
});
codeArea.setOnMouseClicked(event -> {
IndexRange selection = codeArea.getSelection();
int start = selection.getStart();
textSearchView.setSlidingStartIndexProperty(start);
});
textSearchView.show();
// codeArea.setOnMouseClicked(defaultSelectionHandler);
e.consume();
}
Aggregations