Search in sources :

Example 1 with ASTSqlCodeAreaHelper

use of com.kyj.fx.voeditor.visual.component.text.ASTSqlCodeAreaHelper 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();
}
Also used : ASTSqlCodeAreaHelper(com.kyj.fx.voeditor.visual.component.text.ASTSqlCodeAreaHelper) Scene(javafx.scene.Scene) CodeArea(org.fxmisc.richtext.CodeArea)

Example 2 with ASTSqlCodeAreaHelper

use of com.kyj.fx.voeditor.visual.component.text.ASTSqlCodeAreaHelper in project Gargoyle by callakrsos.

the class SqlPane method createTabItem.

/**
	 * 탭추가.
	 *
	 * 2016-12-09 CodeAssistHelper 기능 추가.
	 *
	 * 2016-10-27 키 이벤트를 setAccelerator를 사용하지않고 이벤트 방식으로 변경 이유 : 도킹기능을 적용하하면
	 * setAccelerator에 등록된 이벤트가 호출안됨
	 *
	 * @return
	 */
SqlTab createTabItem() {
    SqlTab sqlTab = new SqlTab(this::txtSqlOnKeyEvent);
    SqlKeywords sqlNode = sqlTab.getSqlNode();
    //코드 AreaHelper 설치.
    new ASTSqlCodeAreaHelper(sqlNode.getCodeArea(), connectionSupplier);
    ContextMenu contextMenu = sqlTab.getTxtSqlPaneContextMenu();
    Menu menuFunc = new Menu("Functions");
    MenuItem menuQueryMacro = new MenuItem("Query-Macro");
    menuQueryMacro.setOnAction(this::menuQueryMacroOnAction);
    MenuItem menuFormatter = new MenuItem("SQL Formatter [F + CTRL + SHIFT] ");
    // 2016-10-27 주석
    // menuFormatter.setAccelerator(new KeyCodeCombination(KeyCode.F,
    // KeyCombination.SHIFT_DOWN, KeyCombination.CONTROL_DOWN));
    menuFormatter.setOnAction(this::menuFormatterOnAction);
    MenuItem menuShowApplicationCode = new MenuItem("Show Application Code");
    menuShowApplicationCode.setOnAction(this::menuShowApplicationCodeOnAction);
    menuFunc.getItems().addAll(menuQueryMacro, menuFormatter, menuShowApplicationCode);
    contextMenu.getItems().add(menuFunc);
    return sqlTab;
}
Also used : SqlKeywords(com.kyj.fx.voeditor.visual.component.text.SqlKeywords) ASTSqlCodeAreaHelper(com.kyj.fx.voeditor.visual.component.text.ASTSqlCodeAreaHelper) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SqlTab(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTab) Menu(javafx.scene.control.Menu) ContextMenu(javafx.scene.control.ContextMenu)

Aggregations

ASTSqlCodeAreaHelper (com.kyj.fx.voeditor.visual.component.text.ASTSqlCodeAreaHelper)2 SqlTab (com.kyj.fx.voeditor.visual.component.sql.tab.SqlTab)1 SqlKeywords (com.kyj.fx.voeditor.visual.component.text.SqlKeywords)1 Scene (javafx.scene.Scene)1 ContextMenu (javafx.scene.control.ContextMenu)1 Menu (javafx.scene.control.Menu)1 MenuItem (javafx.scene.control.MenuItem)1 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)1 CodeArea (org.fxmisc.richtext.CodeArea)1