use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.
the class FxSVNHistoryDataSupplier method createHistoryListView.
public ListView<GargoyleSVNLogEntryPath> createHistoryListView(ObservableList<GargoyleSVNLogEntryPath> list) {
ListView<GargoyleSVNLogEntryPath> listView = new ListView<GargoyleSVNLogEntryPath>(list);
listView.setCellFactory(new Callback<ListView<GargoyleSVNLogEntryPath>, ListCell<GargoyleSVNLogEntryPath>>() {
@Override
public ListCell<GargoyleSVNLogEntryPath> call(ListView<GargoyleSVNLogEntryPath> param) {
ListCell<GargoyleSVNLogEntryPath> listCell = new ListCell<GargoyleSVNLogEntryPath>() {
/* (non-Javadoc)
* @see javafx.scene.control.Cell#updateItem(java.lang.Object, boolean)
*/
@Override
protected void updateItem(GargoyleSVNLogEntryPath item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
} else {
String type = "Modify";
switch(item.getType()) {
case GargoyleSVNLogEntryPath.TYPE_ADDED:
type = "Add";
break;
case GargoyleSVNLogEntryPath.TYPE_MODIFIED:
type = "Modify";
break;
case GargoyleSVNLogEntryPath.TYPE_REPLACED:
type = "Replace";
break;
case GargoyleSVNLogEntryPath.TYPE_DELETED:
type = "Delete";
break;
}
String path = item.getPath();
setText(String.format("Resivion :%d File : %s Date : %s Type : %s ", item.getCopyRevision(), path.substring(path.lastIndexOf("/")), YYYY_MM_DD_HH_MM_SS_PATTERN.format(item.getDate()), type));
}
}
};
return listCell;
}
});
listView.setPrefSize(600, ListView.USE_COMPUTED_SIZE);
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
listView.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
ContextMenu contextMenu = null;
ObservableList<GargoyleSVNLogEntryPath> selectedItems = listView.getSelectionModel().getSelectedItems();
GargoyleSVNLogEntryPath selectedItem = null;
if (selectedItems != null && !selectedItems.isEmpty()) {
selectedItem = selectedItems.get(0);
}
if (ev.getClickCount() == 2 && ev.getButton() == MouseButton.PRIMARY) {
if (selectedItem != null) {
String path = selectedItem.getPath();
long copyRevision = selectedItem.getCopyRevision();
String rootUrl = getRootUrl();
LOGGER.debug("{}", rootUrl);
LOGGER.debug("Cat Command, Path : {} Revision {}", path, copyRevision);
String content = "";
VBox vBox = new VBox(5);
if (isExists(path)) {
content = cat(path, String.valueOf(copyRevision));
List<SVNLogEntry> log = log(path, String.valueOf(copyRevision), ex -> {
LOGGER.error(ValueUtil.toString(ex));
});
if (ValueUtil.isNotEmpty(log)) {
SVNLogEntry svnLogEntry = log.get(0);
String apply = getManager().fromPrettySVNLogConverter().apply(svnLogEntry);
Label e = new Label(apply);
e.setStyle("-fx-text-fill:black");
vBox.getChildren().add(e);
}
vBox.getChildren().add(createJavaTextArea(content));
} else {
content = "Does not exists. Repository. [Removed]";
Label e = new Label(content);
e.setStyle("-fx-text-fill:black");
vBox.getChildren().add(e);
}
FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), vBox);
}
ev.consume();
} else if (ev.getClickCount() == 1 && ev.getButton() == MouseButton.SECONDARY) {
ObservableList<MenuItem> menus = FXCollections.observableArrayList();
MenuItem miHist = new MenuItem("History");
miHist.setUserData(selectedItem);
MenuItem miAllHist = new MenuItem("All History");
MenuItem miDiff = new MenuItem("Diff");
miDiff.setDisable(true);
menus.add(miHist);
menus.add(miAllHist);
menus.add(new SeparatorMenuItem());
menus.add(miDiff);
if (selectedItems.size() == 2) {
miDiff.setUserData(selectedItems);
miDiff.setDisable(false);
}
miHist.setOnAction(event -> {
GargoyleSVNLogEntryPath userData = (GargoyleSVNLogEntryPath) miHist.getUserData();
if (userData == null)
return;
FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), createHistoryListView(userData.getPath()));
});
miAllHist.setOnAction(event -> {
GargoyleSVNLogEntryPath userData = (GargoyleSVNLogEntryPath) miHist.getUserData();
if (userData == null)
return;
String path = userData.getPath();
try {
Collection<SVNLogEntry> allLogs = getManager().getAllLogs(path);
ObservableList<GargoyleSVNLogEntryPath> collect = createStream(allLogs).filter(v -> {
return path.equals(v.getPath());
}).collect(FxCollectors.toObservableList());
FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), createHistoryListView(collect));
} catch (Exception e) {
LOGGER.error(ValueUtil.toString(e));
}
});
miDiff.setOnAction(event -> {
List<GargoyleSVNLogEntryPath> userData = (List<GargoyleSVNLogEntryPath>) miDiff.getUserData();
if (userData == null && userData.size() != 2)
return;
GargoyleSVNLogEntryPath gargoyleSVNLogEntryPath1 = userData.get(0);
GargoyleSVNLogEntryPath gargoyleSVNLogEntryPath2 = userData.get(1);
try {
String diff = diff(gargoyleSVNLogEntryPath1.getPath(), gargoyleSVNLogEntryPath1.getCopyRevision(), gargoyleSVNLogEntryPath2.getCopyRevision());
TextArea showingNode = new TextArea(diff);
showingNode.setPrefSize(600d, 800d);
FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), showingNode);
} catch (Exception e) {
e.printStackTrace();
}
});
contextMenu = new ContextMenu(menus.stream().toArray(MenuItem[]::new));
contextMenu.show(ev.getPickResult().getIntersectedNode(), ev.getScreenX(), ev.getScreenY());
}
});
return listView;
}
use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.
the class ScmCommitComposite method init.
/* (non-Javadoc)
* @see com.kyj.fx.voeditor.visual.component.MasterSlaveChartComposite#init()
*/
@Override
public void init() {
MenuItem miReflesh = new MenuItem("Reflesh");
miReflesh.setOnAction(ex -> {
getLineChartDayOfWeek().getData().clear();
getLineChartDayOfWeekCategory().getCategories().clear();
getBarChartDayOfMonth().getData().clear();
getBarChartDayOfMonthCategory().getCategories().clear();
load();
});
ContextMenu contextMenu = new ContextMenu(miReflesh);
this.addEventFilter(MouseEvent.MOUSE_CLICKED, ev -> {
contextMenu.hide();
if (ev.getButton() == MouseButton.SECONDARY) {
contextMenu.show(FxUtil.getWindow(this), ev.getScreenX(), ev.getScreenY());
}
});
}
use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.
the class SqlMultiplePane method createTreeContextMenu.
/**
* 컨텍스트 메뉴 생성 및 기능 적용
*
* @param schemaTree2
*/
private void createTreeContextMenu(TreeView<K> schemaTree) {
MenuItem menuSelectScript = new MenuItem("Select Script");
menuSelectScript.setOnAction(this::applySelectScript);
MenuItem menuUpdateScript = new MenuItem("Update Script");
menuUpdateScript.setOnAction(this::applyUpdateScript);
MenuItem menuDeleteScript = new MenuItem("Delete Script");
menuDeleteScript.setOnAction(this::applyDeleteSelectScript);
MenuItem menuInsertScript = new MenuItem("Insert Script");
menuInsertScript.setOnAction(this::applyInsertScript);
Menu menu = new Menu("Script", null, menuSelectScript, menuUpdateScript, menuDeleteScript, menuInsertScript);
// MenuItem menuPrimaryKeys = new MenuItem("Primary Keys");
MenuItem menuShowData = new MenuItem("Show 100 rows");
menuShowData.setOnAction(this::show100RowAction);
MenuItem menuProperties = new MenuItem("Properties");
menuProperties.setOnAction(this::showProperties);
MenuItem menuReflesh = new MenuItem("Reflesh");
menuReflesh.setOnAction(this::menuRefleshOnAction);
menuReflesh.setAccelerator(new KeyCodeCombination(KeyCode.F5));
ContextMenu contextMenu = new ContextMenu(menu, menuShowData, menuProperties, new SeparatorMenuItem(), menuReflesh);
schemaTree.setContextMenu(contextMenu);
}
use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.
the class SqlMultiplePane method createResultTableContextMenu.
private void createResultTableContextMenu(TableView<Map<String, Object>> tbResult) {
MenuItem menuExportExcel = new MenuItem("Export Excel File");
menuExportExcel.setOnAction(e -> menuExportExcelOnAction(tbResult));
MenuItem menuExportSpreadSheet = new MenuItem("Export SpreadSheet");
menuExportSpreadSheet.setOnAction(this::menuExportSpreadSheetOnAction);
Menu menuExportExcelFile = new Menu("Export", null, menuExportExcel, menuExportSpreadSheet);
ContextMenu contextMenu = new ContextMenu(menuExportExcelFile);
tbResult.setContextMenu(contextMenu);
}
use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.
the class SqlPane method createResultTableContextMenu.
private void createResultTableContextMenu(TableView<?> tableView) {
MenuItem menuExportExcel = new MenuItem("Export Excel File");
menuExportExcel.setOnAction(this::menuExportExcelOnAction);
MenuItem menuExportSpreadSheet = new MenuItem("Export SpreadSheet");
menuExportSpreadSheet.setOnAction(this::menuExportSpreadSheetOnAction);
MenuItem menuExportInsertScript = new MenuItem("Export Insert Script");
menuExportInsertScript.setOnAction(this::menuExportInsertScriptOnAction);
MenuItem menuExportMergeScript = new MenuItem("Export Merge Script");
menuExportMergeScript.setOnAction(this::menuExportMergeScriptOnAction);
MenuItem menuExportJson = new MenuItem("Export Json");
menuExportJson.setOnAction(this::menuExportJsonOnAction);
Menu menuExportExcelFile = new Menu("Export", null, menuExportExcel, menuExportSpreadSheet, menuExportInsertScript, menuExportMergeScript, menuExportJson);
ContextMenu contextMenu = new ContextMenu(menuExportExcelFile);
tableView.setContextMenu(contextMenu);
}
Aggregations