-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue-tracker-idea-plugin-12 Action > Add action to Open the IssueUrl…
… in browser - Added the action to open the browser. The action will honor Enable/Disable.
- Loading branch information
1 parent
7a61143
commit f19e792
Showing
6 changed files
with
101 additions
and
5 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
53 changes: 53 additions & 0 deletions
53
Plugin/src/com/madrapps/issuetracker/actions/OpenIssueInBrowserAction.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,53 @@ | ||
package com.madrapps.issuetracker.actions; | ||
|
||
import com.intellij.openapi.actionSystem.AnAction; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.actionSystem.Presentation; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.tasks.Task; | ||
import com.madrapps.issuetracker.listissues.IListIssuesContract; | ||
import com.madrapps.issuetracker.listissues.ListIssuesPresenter; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* This will open the IssueUrl of the issue on the Browser | ||
* <p> | ||
* Created by Henry on 10/22/2016. | ||
*/ | ||
public class OpenIssueInBrowserAction extends AnAction { | ||
|
||
public static final String ACTION_ID = "IssueTracker.OpenIssueInBrowser"; | ||
|
||
@Override | ||
public void update(AnActionEvent e) { | ||
final Presentation presentation = e.getPresentation(); | ||
final Task selectedIssue = getSelectedIssue(e); | ||
presentation.setEnabled(selectedIssue != null); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(AnActionEvent e) { | ||
final Task selectedIssue = getSelectedIssue(e); | ||
if (selectedIssue != null) { | ||
ListIssuesPresenter.getInstance().openUrl(selectedIssue); | ||
} | ||
} | ||
|
||
/** | ||
* Get the issue currently selected, or null if nothing is selected | ||
* | ||
* @param e the actionEvent to get the Project | ||
* @return selected issue or null | ||
*/ | ||
@Nullable | ||
private Task getSelectedIssue(AnActionEvent e) { | ||
final Project project = e.getProject(); | ||
if (project != null) { | ||
final IListIssuesContract.IView view = ListIssuesPresenter.getInstance().setView(project); | ||
return view.getSelectedIssue(); | ||
} | ||
return null; | ||
} | ||
} | ||
|
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