Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add menu item to open project directory #160

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cli/src/main/java/ca/weblite/jdeploy/gui/JDeployProjectEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1525,8 +1525,23 @@ private void initMenu() {
openInTextEditor.setToolTipText("Open the package.json file for editing in your system text editor");

openInTextEditor.addActionListener(evt-> handleOpenInTextEditor());

JMenuItem openProjectDirectory = new JMenuItem("Open Project Directory");
openProjectDirectory.setToolTipText("Open the project directory in your system file manager");
openProjectDirectory.addActionListener(evt->{
if (context.getDesktopInterop().isDesktopSupported()) {
try {
context.getDesktopInterop().openDirectory(packageJSONFile.getParentFile());
} catch (Exception ex) {
showError("Failed to open project directory in file manager", ex);
}
} else {
showError("That feature isn't supported on this platform.", null);
}
});
file.addSeparator();
file.add(openInTextEditor);
file.add(openProjectDirectory);

generateGithubWorkflowMenuItem = new JMenuItem("Create Github Workflow");
generateGithubWorkflowMenuItem.setToolTipText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public void browse(URI url) throws Exception {
Desktop.getDesktop().browse(url);
}

public void openDirectory(File file) throws Exception {
Desktop.getDesktop().open(file);
}

public boolean isDesktopSupported() {
return Desktop.isDesktopSupported();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ public GithubTokenService(GithubConfig config) {
public String getToken() {
return config.getToken();
}

public void setToken(String token) {
config.setToken(token);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ public GithubConfig(Config config) {
public String getToken() {
return config.getProperties().getProperty("github.token");
}

public String setToken(String token) {
return (String) config.getProperties().setProperty("github.token", token);
}
}
Loading