generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for registering keyboard actions to bld commands.
Cleanups.
- Loading branch information
Showing
10 changed files
with
204 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/rife/bld/idea/project/BldProjectActionAssignShortcut.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2024 Geert Bevin (gbevin[remove] at uwyn dot com) | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
*/ | ||
package rife.bld.idea.project; | ||
|
||
import com.intellij.openapi.actionSystem.ActionManager; | ||
import com.intellij.openapi.actionSystem.ActionUpdateThread; | ||
import com.intellij.openapi.actionSystem.AnAction; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.keymap.impl.ui.EditKeymapsDialog; | ||
import com.intellij.openapi.project.Project; | ||
import org.jetbrains.annotations.NotNull; | ||
import rife.bld.idea.utils.BldBundle; | ||
|
||
final class BldProjectActionAssignShortcut extends AnAction { | ||
private final Project project_; | ||
private final String actionId_; | ||
|
||
BldProjectActionAssignShortcut(Project project, String actionId) { | ||
super(BldBundle.message("bld.project.assign.shortcut.action.name")); | ||
project_ = project; | ||
actionId_ = actionId; | ||
} | ||
|
||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent e) { | ||
new EditKeymapsDialog(project_, actionId_).show(); | ||
} | ||
|
||
@Override | ||
public void update(@NotNull AnActionEvent e) { | ||
e.getPresentation().setEnabled(actionId_ != null && ActionManager.getInstance().getAction(actionId_) != null); | ||
} | ||
|
||
@Override | ||
public @NotNull ActionUpdateThread getActionUpdateThread() { | ||
return ActionUpdateThread.BGT; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/rife/bld/idea/project/BldProjectActionExecuteCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2024 Geert Bevin (gbevin[remove] at uwyn dot com) | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
*/ | ||
package rife.bld.idea.project; | ||
|
||
import com.intellij.execution.ui.ConsoleViewContentType; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.progress.ProgressIndicator; | ||
import com.intellij.openapi.progress.Task; | ||
import com.intellij.openapi.project.DumbAwareAction; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.util.NlsActions; | ||
import org.jetbrains.annotations.NonNls; | ||
import org.jetbrains.annotations.NotNull; | ||
import rife.bld.idea.console.BldConsoleManager; | ||
import rife.bld.idea.execution.BldExecution; | ||
import rife.bld.idea.execution.BldExecutionFlags; | ||
import rife.bld.idea.utils.BldBundle; | ||
|
||
import java.util.List; | ||
|
||
public final class BldProjectActionExecuteCommand extends DumbAwareAction { | ||
private final Project project_; | ||
private final String command_; | ||
private final String debugString_; | ||
|
||
public BldProjectActionExecuteCommand(final @NotNull Project project, | ||
final String command, | ||
final @NlsActions.ActionDescription String description) { | ||
project_ = project; | ||
|
||
var template_presentation = getTemplatePresentation(); | ||
template_presentation.setText("Bld Command: " + command, false); | ||
template_presentation.setDescription(description); | ||
command_ = command; | ||
debugString_ = "Command action: " + command + | ||
"; Project: " + project.getPresentableUrl(); | ||
} | ||
|
||
public @NonNls String toString() { | ||
return debugString_; | ||
} | ||
|
||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent e) { | ||
Project project = e.getProject(); | ||
if (project == null) return; | ||
|
||
new Task.Backgroundable(project_, BldBundle.message("bld.project.progress.commands", command_), true) { | ||
@Override | ||
public void run(@NotNull ProgressIndicator indicator) { | ||
BldConsoleManager.showTaskMessage(BldBundle.message("bld.project.console.commands", command_), ConsoleViewContentType.USER_INPUT, project_); | ||
BldExecution.instance(project_).executeCommands(new BldExecutionFlags(), List.of(command_)); | ||
} | ||
}.queue(); | ||
} | ||
} |
Oops, something went wrong.