use of com.kyj.fx.voeditor.visual.component.FileWrapper in project Gargoyle by callakrsos.
the class SystemLayoutViewController method createNewTreeViewMenuItems.
/**
* 트리뷰의 메뉴컨텍스트를 새로 생성ㅎ한다.
*
* @Date 2015. 10. 17.
* @User KYJ
*/
private void createNewTreeViewMenuItems() {
fileTreeContextMenu = new ContextMenu();
MenuItem openFileMenuItem = new MenuItem("Open");
Menu menuOpenWidth = new Menu("Open With ");
/***********************************************************************************/
// 조건에 따라 보여주는 아이템. [start]
/***********************************************************************************/
// FXML선택한경우에만 보여주는 조건처리.
final MenuItem menuItemOpenWithSceneBuilder = new MenuItem("SceneBuilder");
final MenuItem menuItemSCMGraphs = new MenuItem("SCM Graphs");
menuItemSCMGraphs.setDisable(true);
menuItemSCMGraphs.setOnAction(this::menuItemSCMGraphsOnAction);
menuItemOpenWithSceneBuilder.setOnAction(this::menuItemOpenWithSceneBuilderOnAction);
menuOpenWidth.setOnShowing(event -> {
String sceneBuilderLocation = ResourceLoader.getInstance().get(ResourceLoader.SCENEBUILDER_LOCATION);
TreeItem<FileWrapper> selectedTreeItem = this.treeProjectFile.getSelectionModel().getSelectedItem();
boolean isRemoveOpenWidthSceneBuilderMenuItem = true;
if (selectedTreeItem != null) {
FileWrapper fileWrapper = selectedTreeItem.getValue();
File selectedTree = fileWrapper.getFile();
if (FileUtil.isFXML(selectedTree)) {
if (!menuOpenWidth.getItems().contains(menuItemOpenWithSceneBuilder)) {
menuOpenWidth.getItems().add(menuItemOpenWithSceneBuilder);
}
isRemoveOpenWidthSceneBuilderMenuItem = false;
File file = new File(sceneBuilderLocation);
if (file.exists()) {
menuItemOpenWithSceneBuilder.setDisable(false);
} else {
menuItemOpenWithSceneBuilder.setDisable(true);
}
}
}
if (isRemoveOpenWidthSceneBuilderMenuItem)
menuOpenWidth.getItems().remove(menuItemOpenWithSceneBuilder);
});
Menu menuRunAs = new Menu("Run As");
Menu menuPMD = new Menu("PMD");
fileTreeContextMenu.setOnShowing(ev -> {
TreeItem<FileWrapper> selectedTreeItem = this.treeProjectFile.getSelectionModel().getSelectedItem();
boolean isDisableSCMGraphsMenuItem = true;
if (selectedTreeItem != null) {
menuRunAs.getItems().clear();
menuPMD.getItems().clear();
FileWrapper fileWrapper = selectedTreeItem.getValue();
File file = fileWrapper.getFile();
if (fileWrapper.isSVNConnected())
isDisableSCMGraphsMenuItem = false;
if (fileWrapper.isJavaProjectFile()) {
LOGGER.debug("isJavaProjectFile true");
menuRunAs.getItems().add(new MenuItem("Java Application"));
}
if (selectedTreeItem instanceof JavaProjectMemberFileTreeItem) {
LOGGER.debug("projectFile Member true");
if (FileUtil.isJavaFile(file)) {
MenuItem runJavaApp = new MenuItem("Java Application");
runJavaApp.setOnAction(this::miRunJavaAppOnAction);
menuRunAs.getItems().add(runJavaApp);
}
}
if (PMDUtil.isSupportedLanguageVersions(file)) {
MenuItem menuRunPmd = new MenuItem("Run PMD");
menuRunPmd.setUserData(file);
menuRunPmd.setOnAction(this::menuRunPmdOnAction);
menuPMD.getItems().add(menuRunPmd);
}
if (file.isDirectory()) {
MenuItem menuRunAllPmd = new MenuItem("Run All PMD");
menuRunAllPmd.setUserData(file);
menuRunAllPmd.setOnAction(this::menuRunPmdOnAction);
menuPMD.getItems().add(menuRunAllPmd);
}
menuRunAs.getItems().add(new SeparatorMenuItem());
menuRunAs.getItems().add(new MenuItem("Run Configurations"));
}
menuItemSCMGraphs.setDisable(isDisableSCMGraphsMenuItem);
});
/***********************************************************************************/
// 조건에 따라 보여주는 아이템. [end]
/***********************************************************************************/
{
MenuItem openSystemExplorerMenuItem = new MenuItem("Open Sys. Explorer");
openSystemExplorerMenuItem.setOnAction(this::openSystemExplorerMenuItemOnAction);
menuOpenWidth.getItems().add(openSystemExplorerMenuItem);
}
Menu newFileMenuItem = new Menu("New");
MenuItem newDir = new MenuItem("Dir");
newDir.setOnAction(this::newDirOnAction);
newFileMenuItem.getItems().add(newDir);
MenuItem deleteFileMenuItem = new MenuItem("Delete");
KeyCodeCombination value = new KeyCodeCombination(KeyCode.DELETE);
deleteFileMenuItem.setAccelerator(value);
deleteFileMenuItem.setOnAction(this::deleteFileMenuItemOnAction);
// 선택한 파일아이템을 VoEditor에서 조회시 사용
// MenuItem voEditorMenuItem = new MenuItem("Show VO Editor");
// //선택한 파일아이템을 DaoWizard에서 조회시 사용
// MenuItem daoWizardMenuItem = new MenuItem("Show DAO Wizard");
// 선택한 파일경로를 Vo Editor Location에 바인딩함.
// MenuItem setVoEditorMenuItem = new MenuItem("SET Vo Editor
// Directory");
// 선택한 파일경로를 Vo Editor Location에 바인딩함.
MenuItem voEditorMenuItem = new MenuItem("Vo Editor");
// 선택한 파일경로를 DaoWizard Location에 바인딩함.
MenuItem setDaoWizardMenuItem = new MenuItem("SET DAO Wizard Directory");
// 경로 리프레쉬
MenuItem refleshMenuItem = new MenuItem("Reflesh");
// 코드분석
MenuItem chodeAnalysisMenuItem = new MenuItem("자바 코드 분석");
// 사양서 생성
MenuItem makeProgramSpecMenuItem = new MenuItem("Gen. Program Spec.");
// 파일 속성 조회
MenuItem menuProperties = new MenuItem("Properties");
menuProperties.setOnAction(this::menuPropertiesOnAction);
chodeAnalysisMenuItem.setOnAction(this::menuItemCodeAnalysisMenuItemOnAction);
fileTreeContextMenu.getItems().addAll(openFileMenuItem, menuOpenWidth, newFileMenuItem, deleteFileMenuItem, /* voEditorMenuItem, daoWizardMenuItem, */
voEditorMenuItem, /* setVoEditorMenuItem, */
setDaoWizardMenuItem, chodeAnalysisMenuItem, makeProgramSpecMenuItem, menuItemSCMGraphs, new SeparatorMenuItem(), refleshMenuItem, new SeparatorMenuItem(), menuPMD, new SeparatorMenuItem(), menuRunAs, new SeparatorMenuItem(), menuProperties);
// daoWizardMenuItem.addEventHandler(ActionEvent.ACTION,
// this::daoWizardMenuItemOnActionEvent);
// Vo Editor
// setVoEditorMenuItem.addEventHandler(ActionEvent.ACTION, event -> {
// Node lookup = borderPaneMain.lookup("#txtLocation");
// if (lookup != null && tmpSelectFileWrapper != null) {
// TextField txtLocation = (TextField) lookup;
// File file = tmpSelectFileWrapper.getFile();
// if (file.isDirectory()) {
// String absolutePath = file.getAbsolutePath();
// ResourceLoader.getInstance().put(ResourceLoader.USER_SELECT_LOCATION_PATH,
// absolutePath);
// txtLocation.setText(absolutePath);
// } else {
// DialogUtil.showMessageDialog("Only Directory.");
// }
// }
// tmpSelectFileWrapper = null;
// });
voEditorMenuItem.addEventHandler(ActionEvent.ACTION, this::voEditorMenuItemOnAction);
// Dao Wizard
setDaoWizardMenuItem.addEventHandler(ActionEvent.ACTION, event -> {
Node lookup = borderPaneMain.lookup("#txtDaoLocation");
if (lookup != null && tmpSelectFileWrapper != null) {
TextField txtLocation = (TextField) lookup;
File file = tmpSelectFileWrapper.getFile();
if (file.exists() && file.isDirectory()) {
ResourceLoader.getInstance().put(ResourceLoader.USER_SELECT_LOCATION_PATH, file.getAbsolutePath());
Path relativize = FileUtil.toRelativizeForGagoyle(file);
txtLocation.setText(File.separator + relativize.toString());
} else {
DialogUtil.showMessageDialog("Only Directory.");
}
}
tmpSelectFileWrapper = null;
});
refleshMenuItem.setOnAction(event -> {
TreeItem<FileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
refleshWorkspaceTreeItem(selectedItem);
});
//함수위치로 이동
// deleteFileMenuItem.setOnAction(event -> {
// TreeItem<FileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
// if (selectedItem != null) {
// File file = selectedItem.getValue().getFile();
// if (file != null && file.exists()) {
// Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("파일삭제.",
// file.getName() + " 정말 삭제하시겠습니까? \n[휴지통에 보관되지않음.]");
// showYesOrNoDialog.ifPresent(pair -> {
// if ("Y".equals(pair.getValue())) {
// TreeItem<FileWrapper> root = treeProjectFile.getRoot();
// root.getChildren().remove(selectedItem);
// file.delete();
// }
// });
// }
// }
// });
makeProgramSpecMenuItem.setOnAction(event -> {
TreeItem<FileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
File sourceFile = selectedItem.getValue().getFile();
if (sourceFile != null && sourceFile.exists()) {
try {
if (FileUtil.isJavaFile(sourceFile)) {
File targetFile = DialogUtil.showFileSaveCheckDialog(SharedMemory.getPrimaryStage(), chooser -> {
chooser.setInitialFileName(DateUtil.getCurrentDateString(DateUtil.SYSTEM_DATEFORMAT_YYYYMMDDHHMMSS));
chooser.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.DOCX_NAME, GargoyleExtensionFilters.DOCX));
chooser.setTitle("Save Program Spec. Doc");
chooser.setInitialDirectory(new File(SystemUtils.USER_HOME));
});
if (targetFile != null) {
boolean createDefault = ProgramSpecUtil.createDefault(sourceFile, targetFile);
if (createDefault)
FileUtil.openFile(targetFile);
}
} else {
DialogUtil.showMessageDialog("사양서 작성 가능한 유형이 아닙니다.");
}
} catch (Exception e) {
DialogUtil.showExceptionDailog(e);
}
}
}
});
}
use of com.kyj.fx.voeditor.visual.component.FileWrapper in project Gargoyle by callakrsos.
the class SystemLayoutViewController method treeProjectFileOnMouseClick.
/********************************
* 작성일 : 2016. 6. 11. 작성자 : KYJ
*
* 프로젝트 트리 마우스 클릭 이벤트
*
* @param event
********************************/
public void treeProjectFileOnMouseClick(MouseEvent event) {
fileTreeContextMenu.hide();
/* 탭 추가 기능. */
if (event.getClickCount() == 2) {
TreeItem<FileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
if (selectedItem == null)
return;
FileWrapper value = selectedItem.getValue();
if (value != null) {
File file = value.getFile();
LOGGER.debug(String.format(" file : %s ", file.toPath()));
if (file.exists() && file.isFile()) {
try {
boolean javaFile = FileUtil.isJavaFile(file);
LOGGER.debug("is javafile ? " + javaFile);
openFile(file);
} catch (Exception e) {
LOGGER.error(ValueUtil.toString(e));
}
}
}
}
}
use of com.kyj.fx.voeditor.visual.component.FileWrapper in project Gargoyle by callakrsos.
the class SystemLayoutViewController method daoWizardMenuItemOnActionEvent.
/********************************
* 작성일 : 2016. 4. 26. 작성자 : KYJ
*
* TODO 파일로부터 DAO WIZARD 로드 처리
*
* @param e
********************************/
private void daoWizardMenuItemOnActionEvent(ActionEvent e) {
TreeItem<FileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
if (selectedItem == null)
return;
FileWrapper value = selectedItem.getValue();
File file = value.getFile();
if (file.isFile()) {
String fileName = file.getName();
String absoluteFile = file.getAbsolutePath();
String uLocationPath = ResourceLoader.getInstance().get(ResourceLoader.USER_SELECT_LOCATION_PATH);
if (uLocationPath.indexOf(absoluteFile) > 0) {
}
}
}
use of com.kyj.fx.voeditor.visual.component.FileWrapper in project Gargoyle by callakrsos.
the class SystemLayoutViewController method search.
public TreeItem<FileWrapper> search(File f) {
TreeItem<FileWrapper> root = treeProjectFile.getRoot();
Path p = FileUtil.toRelativizeForGagoyle(f);
String[] split = StringUtils.split(p.toString(), File.separator);
boolean isFound = false;
ObservableList<TreeItem<FileWrapper>> children = root.getChildren();
int sliding = 0;
TreeItem<FileWrapper> treeItem = null;
for (int i = 0; i < split.length; i++) {
isFound = false;
for (TreeItem<FileWrapper> w : children) {
treeItem = w;
String name = treeItem.getValue().getFile().getName();
if (split[sliding].equals(name)) {
isFound = true;
break;
}
}
if (isFound) {
children = treeItem.getChildren();
sliding++;
} else {
// 아예못찾은경우는 종료.
break;
}
}
return treeItem;
}
use of com.kyj.fx.voeditor.visual.component.FileWrapper in project Gargoyle by callakrsos.
the class SystemLayoutViewController method openSystemExplorerMenuItemOnAction.
/********************************
* 작성일 : 2016. 5. 29. 작성자 : KYJ
*
* OS 시스템에 의존되는 형식으로 파일을 오픈함.
*
* @param e
********************************/
public void openSystemExplorerMenuItemOnAction(ActionEvent e) {
TreeItem<FileWrapper> selectedItem = this.treeProjectFile.getSelectionModel().getSelectedItem();
NullExpresion.ifNotNullDo(selectedItem, item -> {
FileWrapper fw = item.getValue();
File file = fw.getFile();
if (file != null && file.exists()) {
FileUtil.openFile(file);
}
});
//
}
Aggregations