use of org.fxmisc.richtext.CodeArea in project aic-praise by aic-sri-international.
the class HOGMCodeArea method initialize.
//
// PRIVATE
//
private void initialize(boolean showLineNumbers) {
codeArea = new CodeArea();
if (showLineNumbers) {
codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea, digits -> "%" + (digits < 2 ? 2 : digits) + "d"));
}
codeArea.textProperty().addListener((obs, oldText, newText) -> {
codeArea.setStyleSpans(0, computeHighlighting(newText));
});
FXUtil.anchor(codeArea);
getChildren().add(codeArea);
}
use of org.fxmisc.richtext.CodeArea in project Gargoyle by callakrsos.
the class PagedCodeAreaFindAndReplaceHelper method setContent.
public void setContent(String content) {
SimpleTextView currentPageView = this.view.getCurrentPageView();
if (currentPageView != null) {
CodeArea codeArea = currentPageView.getCodeArea();
codeArea.getUndoManager().mark();
codeArea.clear();
codeArea.replaceText(0, 0, content);
codeArea.getUndoManager().mark();
}
}
use of org.fxmisc.richtext.CodeArea in project Gargoyle by callakrsos.
the class TextPopupExam method start.
/* (non-Javadoc)
* @see javafx.application.Application#start(javafx.stage.Stage)
*/
// @Override
// public void start(Stage primaryStage) throws Exception {
// CustomTextArea textArea = new CustomTextArea("Hello world.,!");
//
// textArea.addEventHandler(KeyEvent.KEY_PRESSED, ev -> {
// if (ev.isControlDown() && ev.getCode() == KeyCode.SPACE) {
//
// Bounds blankBounds = textArea.getBlankBounds();
// Bounds localToScreen = textArea.localToScreen(blankBounds);
//
// double minX = localToScreen.getMinX();
// double minY = localToScreen.getMinY();
// PopOver popOver = new PopOver(new Label("asdasdasd"));
// popOver.show(textArea, minX, minY);
// }
// });
// primaryStage.setScene(new Scene(textArea));
// primaryStage.show();
// }
@Override
public void start(Stage primaryStage) throws Exception {
CodeArea textArea = new CodeArea("select * from ");
new ASTSqlCodeAreaHelper(textArea, () -> {
try {
return DbUtil.getConnection();
} catch (Exception e) {
e.printStackTrace();
}
return null;
});
// // UnaryOperator<Point2D> unaryOperator = textArea.popupAnchorAdjustmentProperty().get();
// // unaryOperator.
// TableOpenResourceView tableOpenResourceView = new TableOpenResourceView(() -> {
// try {
// return DbUtil.getConnection();
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }) {
//
// /* (non-Javadoc)
// * @see com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView#close()
// */
// @Override
// public void close() {
//
// ResultDialog<Map<String, Object>> result = getResult();
//
// Map<String, Object> data = result.getData();
// if (data == null)
// return;
// Object object = data.get("table_name");
// if (object == null)
// return;
//
// String string = currentPragraph(textArea);
// int markTextColumnIndex = getIndexOfValideWhiteSpace(string);
//
// Paragraph<Collection<String>> currentParagraphRange = currentParagraphRange(textArea);
// IndexRange styleRangeAtPosition = currentParagraphRange.getStyleRangeAtPosition(markTextColumnIndex);
// IndexRange normalize = IndexRange.normalize(markTextColumnIndex, styleRangeAtPosition.getEnd());
// textArea.replaceText(normalize, object.toString());
//
// super.close();
// textArea.getPopupWindow().hide();
//
// }
//
// };
//
// textArea.setPopupWindow(new PopOver(tableOpenResourceView.getView()));
// textArea.setPopupAlignment(PopupAlignment.SELECTION_TOP_CENTER);
// textArea.addEventHandler(KeyEvent.KEY_PRESSED, ev -> {
//
// if (ev.isControlDown() && ev.getCode() == KeyCode.SPACE) {
//
// String string = markText(textArea);
// tableOpenResourceView.getView().getTxtFilter().setText(string);
//
// textArea.getPopupWindow().show(primaryStage);
// textArea.getPopupWindow().requestFocus();
//
// tableOpenResourceView.getView().getTxtFilter().requestFocus();
// tableOpenResourceView.getView().getTxtFilter().selectEnd();
// }
// });
primaryStage.setScene(new Scene(textArea));
primaryStage.show();
}
use of org.fxmisc.richtext.CodeArea in project Gargoyle by callakrsos.
the class PagedCodeAreaFindAndReplaceHelper method findReplaceEvent.
/**
* 찾기 바꾸기 이벤트
*
* @작성자 : KYJ
* @작성일 : 2016. 10. 13.
* @param e
*/
protected void findReplaceEvent(Event e) {
if (e.isConsumed())
return;
SimpleTextView currentPageView = view.getCurrentPageView();
CodeArea codeArea = currentPageView.getCodeArea();
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();
}
use of org.fxmisc.richtext.CodeArea in project Gargoyle by callakrsos.
the class PagedCodeAreaFindAndReplaceHelper method setContent.
public void setContent(int start, int end, String text) {
SimpleTextView currentPageView = this.view.getCurrentPageView();
if (currentPageView != null) {
CodeArea codeArea = currentPageView.getCodeArea();
codeArea.getUndoManager().mark();
codeArea.replaceText(start, end, text);
codeArea.getUndoManager().mark();
}
}
Aggregations