Skip to content

Commit

Permalink
Added icon to edit the bld project file
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Jul 17, 2024
1 parent 8844ce4 commit f9f29eb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = bld.idea
pluginName = bld
pluginRepositoryUrl = https://github.com/rife2/bld-idea
# SemVer format -> https://semver.org
pluginVersion = 0.1.0
pluginVersion = 0.1.1

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 232
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/rife/bld/idea/execution/BldExecution.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public void terminateBldProcess() {
}
}

public String getBldMainClass() {
return bldMainClass_;
}

public void setupProject() {
projectDir_ = ProjectUtil.guessProjectDir(project_);
if (projectDir_ == null) {
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/rife/bld/idea/project/BldProjectWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.DumbAware;
Expand All @@ -18,6 +19,9 @@
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.search.FilenameIndex;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.SimpleTextAttributes;
Expand Down Expand Up @@ -135,6 +139,8 @@ private JPanel createToolbarPanel() {
final var group = new DefaultActionGroup();
group.add(new RefreshAction());
group.add(new RunAction());
group.addSeparator();
group.add(new EditAction());

final var action_toolbar = ActionManager.getInstance().createActionToolbar(BldConstants.BLD_EXPLORER_TOOLBAR, group, true);
action_toolbar.setTargetComponent(this);
Expand Down Expand Up @@ -269,4 +275,32 @@ public void update(@NotNull AnActionEvent event) {
}
}

private final class EditAction extends AnAction implements DumbAware {
public EditAction() {
super(BldBundle.messagePointer("edit.bld.command.action.name"),
BldBundle.messagePointer("edit.bld.command.action.description"), AllIcons.Actions.EditSource);
}

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
var main_class = BldExecution.getInstance(project_).getBldMainClass();
var psi_class =JavaPsiFacade.getInstance(project_).findClass(main_class, GlobalSearchScope.allScope(project_));
if (psi_class != null) {
FileEditorManager.getInstance(project_).openFile(psi_class.getContainingFile().getVirtualFile());
}
}

@Override
public void update(@NotNull AnActionEvent event) {
final var presentation = event.getPresentation();
presentation.setText(BldBundle.messagePointer("edit.bld.command.action.name"));
presentation.setEnabled(true);
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.EDT;
}
}

}
2 changes: 2 additions & 0 deletions src/main/resources/messages/BldBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ refresh.bld.command.action.name=Refresh
refresh.bld.command.action.description=Refresh the bld commands
run.bld.command.action.name=Run
run.bld.command.action.description=Run the selected command(s) with bld
edit.bld.command.action.name=Edit
edit.bld.command.action.description=Edit the bld main class
progress.text.loading.bld.config=Loading bld configuration...
bld.empty.text=No bld commands found.
bld.project.commands=Commands
Expand Down

0 comments on commit f9f29eb

Please sign in to comment.