Search in sources :

Example 1 with TableOpenResourceView

use of com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView in project Gargoyle by callakrsos.

the class SqlPane method showTableResourceView.

/**
	 * 테이블을 찾는 리소스 뷰를 오픈
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 10. 20.
	 */
protected void showTableResourceView() {
    try {
        TableOpenResourceView tableOpenResourceView = new TableOpenResourceView(connectionSupplier);
        ResultDialog<Map<String, Object>> show = tableOpenResourceView.show(this);
        Map<String, Object> data = show.getData();
        if (ValueUtil.isNotEmpty(data)) {
            String schema = tableOpenResourceView.getSchema(data);
            String databaseName = tableOpenResourceView.getDatabaseName(data);
            String tableName = tableOpenResourceView.getTableName(data);
            TreeItem<K> search = search(schema, databaseName, tableName);
            if (search != null) {
                TreeView<K> schemaTree = getSchemaTree();
                schemaTree.getSelectionModel().select(search);
                schemaTree.getFocusModel().focus(schemaTree.getSelectionModel().getSelectedIndex());
                schemaTree.scrollTo(schemaTree.getSelectionModel().getSelectedIndex());
                LOGGER.debug(search.toString());
                LOGGER.debug(data.toString());
            } else {
                LOGGER.debug("search result empty.");
            }
        }
    } catch (Exception e1) {
        LOGGER.error(ValueUtil.toString(e1));
    }
}
Also used : TableOpenResourceView(com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView) Map(java.util.Map) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap)

Example 2 with TableOpenResourceView

use of com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView 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();
}
Also used : IndexRange(javafx.scene.control.IndexRange) TableOpenResourceView(com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView) Map(java.util.Map)

Aggregations

TableOpenResourceView (com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView)2 Map (java.util.Map)2 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 IndexRange (javafx.scene.control.IndexRange)1