use of com.kyj.fx.voeditor.visual.component.text.SimpleTextView in project Gargoyle by callakrsos.
the class SqlPane method menuExportJsonOnAction.
/**
* Export JSON Script.
*
* @작성자 : KYJ
* @작성일 : 2016. 6. 13.
* @param e
*/
public void menuExportJsonOnAction(ActionEvent e) {
ObservableList<Map<String, Object>> items = tbResult.getItems();
if (items.isEmpty())
return;
Map<String, Object> map = items.get(0);
if (map == null)
return;
// 클립보드 복사
StringBuilder clip = new StringBuilder();
List<String> valueList = items.stream().map(v -> {
return ValueUtil.toJSONString(v);
}).collect(Collectors.toList());
valueList.forEach(str -> {
clip.append(str).append(System.lineSeparator());
});
try {
SimpleTextView parent = new SimpleTextView(clip.toString());
parent.setWrapText(false);
FxUtil.createStageAndShow(parent, stage -> {
});
} catch (Exception e1) {
LOGGER.error(ValueUtil.toString(e1));
}
}
use of com.kyj.fx.voeditor.visual.component.text.SimpleTextView in project Gargoyle by callakrsos.
the class MysqlPane method menuExportInsertScriptOnAction.
@Override
public void menuExportInsertScriptOnAction(ActionEvent e) {
Optional<Pair<String, String[]>> showTableInputDialog = showTableInputDialog(f -> f.getName());
// DialogUtil.showInputDialog("table Name", "테이블명을 입력하세요.");
if (showTableInputDialog == null)
return;
showTableInputDialog.ifPresent(op -> {
if (op == null || op.getValue() == null)
return;
String schemaName = op.getValue()[0];
String _tableName = op.getValue()[1];
String tableName = "";
if (ValueUtil.isNotEmpty(schemaName)) {
tableName = String.format("`%s`.%s", schemaName, _tableName);
}
ObservableList<Map<String, Object>> items = getTbResult().getItems();
Map<String, Object> map = items.get(0);
final Set<String> keySet = map.keySet();
StringBuilder clip = new StringBuilder();
String insertPreffix = "insert into " + tableName;
String collect = keySet.stream().collect(Collectors.joining(",", "(", ")"));
String insertMiddle = " values ";
List<String> valueList = items.stream().map(v -> {
return ValueUtil.toJSONObject(v);
}).map(v -> {
Iterator<String> iterator = keySet.iterator();
List<Object> values = new ArrayList<>();
while (iterator.hasNext()) {
String columnName = iterator.next();
Object value = v.get(columnName);
values.add(value);
}
return values;
}).map(list -> {
return list.stream().map(str -> {
if (str == null)
return null;
else {
String convert = str.toString();
convert = convert.substring(1, convert.length() - 1);
if (convert.indexOf("'") >= 0) {
try {
convert = StringUtils.replace(convert, "'", "''");
} catch (Exception e1) {
e1.printStackTrace();
}
}
return "'".concat(convert).concat("'");
}
}).collect(Collectors.joining(",", "(", ")"));
}).map(str -> {
return new StringBuilder().append(insertPreffix).append(collect).append(insertMiddle).append(str).append(";\n").toString();
}).collect(Collectors.toList());
valueList.forEach(str -> {
clip.append(str);
});
SimpleTextView parent = new SimpleTextView(clip.toString());
parent.setWrapText(false);
FxUtil.createStageAndShow(String.format("[InsertScript] Table : %s", tableName), parent, stage -> {
});
});
}
use of com.kyj.fx.voeditor.visual.component.text.SimpleTextView in project Gargoyle by callakrsos.
the class BigTextView method initialize.
@FXML
public void initialize() {
// javaTextArea = new TextArea();
// javaTextArea.setPrefSize(TextArea.USE_COMPUTED_SIZE, Double.MAX_VALUE);
hboxButtons.setVisible(showButtons);
pagination = new Pagination(TOTAL_PAGE);
pagination.setCache(true);
pagination.setPageFactory(new Callback<Integer, Node>() {
@Override
public Node call(Integer param) {
if (isUsePageCache && pageCache.containsValue(param)) {
return pageCache.get(param);
}
String readContent = readPage(param);
//new PagedSimpleTextView(BigTextView.this, readContent, false);
SimpleTextView simpleTextView = new SimpleTextView(readContent, false);
simpleTextView.setPrefSize(TextArea.USE_COMPUTED_SIZE, Double.MAX_VALUE);
if (isUsePageCache)
pageCache.put(param, simpleTextView);
return simpleTextView;
}
});
pagination.setPrefSize(Pagination.USE_COMPUTED_SIZE, Pagination.USE_COMPUTED_SIZE);
this.setCenter(pagination);
}
use of com.kyj.fx.voeditor.visual.component.text.SimpleTextView in project Gargoyle by callakrsos.
the class CommonsSqllPan method menuExportInsertScriptOnAction.
@Override
public void menuExportInsertScriptOnAction(ActionEvent e) {
Optional<Pair<String, String[]>> showTableInputDialog = showTableInputDialog(f -> f.getName());
// Optional<Pair<String, String>> showInputDialog = DialogUtil.showInputDialog("table Name", "테이블명을 입력하세요.");
if (showTableInputDialog == null)
return;
showTableInputDialog.ifPresent(op -> {
if (op == null || op.getValue() == null)
return;
String schemaName = op.getValue()[0];
String _tableName = op.getValue()[1];
String tableName = "";
if (ValueUtil.isNotEmpty(schemaName)) {
tableName = String.format("%s.%s", schemaName, _tableName);
} else {
tableName = _tableName;
}
List<Map<String, Object>> items = getSelectedTabResultItems();
Map<String, Object> map = items.get(0);
final Set<String> keySet = map.keySet();
StringBuilder clip = new StringBuilder();
String insertPreffix = "insert into " + tableName;
String collect = keySet.stream().collect(Collectors.joining(",", "(", ")"));
String insertMiddle = " values ";
List<String> valueList = items.stream().map(v -> {
return ValueUtil.toJSONObject(v);
}).map(v -> {
Iterator<String> iterator = keySet.iterator();
List<Object> values = new ArrayList<>();
while (iterator.hasNext()) {
String columnName = iterator.next();
Object value = v.get(columnName);
values.add(value);
}
return values;
}).map(list -> {
return list.stream().map(str -> {
if (str == null)
return null;
else {
String convert = str.toString();
convert = convert.substring(1, convert.length() - 1);
if (convert.indexOf("'") >= 0) {
try {
convert = StringUtils.replace(convert, "'", "''");
} catch (Exception e1) {
e1.printStackTrace();
}
}
return "'".concat(convert).concat("'");
}
}).collect(Collectors.joining(",", "(", ")"));
}).map(str -> {
return new StringBuilder().append(insertPreffix).append(collect).append(insertMiddle).append(str).append(";\n").toString();
}).collect(Collectors.toList());
valueList.forEach(str -> {
clip.append(str);
});
SimpleTextView parent = new SimpleTextView(clip.toString());
parent.setWrapText(false);
FxUtil.createStageAndShow(String.format("[InsertScript] Table : %s", tableName), parent, stage -> {
});
});
}
use of com.kyj.fx.voeditor.visual.component.text.SimpleTextView in project Gargoyle by callakrsos.
the class SystemLayoutViewController method openText.
/**
* 텍스트기반 파일 형식을 연다.
*
* 무거운 텍스트를 열때... 멈추는 현상이 있음..
*
* 무거운 텍스트를 열경우 openBigText(File) 함수를 호출하도록 한다.
*
* @작성자 : KYJ
* @작성일 : 2016. 2. 22.
* @param file
* @param tabs
*/
@SuppressWarnings("unused")
@Deprecated
private void openText(File file) {
try {
String content2 = FileUtils.readFileToString(file);
SimpleTextView simpleTextView = new SimpleTextView(content2, false);
simpleTextView.setEditable(false);
loadNewSystemTab(file.getName(), simpleTextView);
} catch (IOException e2) {
LOGGER.debug(ValueUtil.toString(e2));
DialogUtil.showExceptionDailog(e2);
}
}
Aggregations