Skip to content

Commit

Permalink
feat: add menu item to open project directory
Browse files Browse the repository at this point in the history
  • Loading branch information
shannah committed Jan 2, 2025
1 parent ba7f57d commit 17a46f6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
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);
}
}

0 comments on commit 17a46f6

Please sign in to comment.