-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,72 @@ | ||
package com.bryansharpe.slackstorm; | ||
|
||
import com.intellij.openapi.actionSystem.ActionGroup; | ||
import com.intellij.openapi.actionSystem.AnAction; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.actionSystem.CommonDataKeys; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.ui.Messages; | ||
import com.intellij.openapi.util.IconLoader; | ||
import org.jdesktop.swingx.action.ActionManager; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.HashSet; | ||
|
||
/** | ||
* Created by bsharpe on 11/2/2015. | ||
*/ | ||
public class SlackSettings extends AnAction { | ||
public void actionPerformed(AnActionEvent e) { | ||
final Project project = e.getData(CommonDataKeys.PROJECT); | ||
public class SlackSettings extends ActionGroup { | ||
@NotNull | ||
@Override | ||
public AnAction[] getChildren(AnActionEvent anActionEvent) { | ||
final AnAction[] children=new AnAction[2]; | ||
|
||
String description = Messages.showInputDialog(project, "Enter a Description", "Slack Settings", IconLoader.getIcon("/icons/slack.png")); | ||
if (description != null) { | ||
String token = Messages.showInputDialog(project, "Enter your slack webhook integration path (i.e. <xxx>/<yyy>/<zzz>.", "Slack Settings", IconLoader.getIcon("/icons/slack.png")); | ||
children[0] = new addChannel(); | ||
children[1] = new removeChannels(); | ||
|
||
if (token != null) { | ||
SlackStorage slackStorage = SlackStorage.getInstance(); | ||
slackStorage.settings.clear(); | ||
slackStorage.settings.put(description, token); | ||
return children; | ||
} | ||
|
||
public class addChannel extends AnAction { | ||
public addChannel() { | ||
super("Add Slack Channel"); | ||
} | ||
public void actionPerformed(AnActionEvent e) { | ||
final Project project = e.getData(CommonDataKeys.PROJECT); | ||
|
||
String description = Messages.showInputDialog(project, "Enter a Description", "Slack Settings", IconLoader.getIcon("/icons/slack.png")); | ||
if (description != null) { | ||
String token = Messages.showInputDialog(project, "Enter your slack webhook integration path (i.e. <xxx>/<yyy>/<zzz>.", "Slack Settings", IconLoader.getIcon("/icons/slack.png")); | ||
|
||
if (token != "" && token != null) { | ||
SlackStorage slackStorage = SlackStorage.getInstance(); | ||
slackStorage.settings.put(description, token); | ||
|
||
// Debug | ||
for (String key : slackStorage.settings.keySet()) { | ||
System.out.println(key); | ||
} | ||
|
||
for ( String key : slackStorage.settings.keySet() ) { | ||
System.out.println( key ); | ||
Messages.showMessageDialog(project, "Settings Saved.", "Information", Messages.getInformationIcon()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public class removeChannels extends AnAction { | ||
public removeChannels() { | ||
super("Reset Slack Channels"); | ||
} | ||
public void actionPerformed(AnActionEvent e) { | ||
final Project project = e.getData(CommonDataKeys.PROJECT); | ||
|
||
Messages.showMessageDialog(project, "Settings Saved.", "Information", Messages.getInformationIcon()); | ||
int confirm = Messages.showYesNoDialog(project, "This will clear all of your channel settings", "Slack Settings", IconLoader.getIcon("/icons/slack.png")); | ||
if (confirm == 0) { | ||
SlackStorage slackStorage = SlackStorage.getInstance(); | ||
slackStorage.settings.clear(); | ||
Messages.showMessageDialog(project, "Settings Cleared.", "Information", Messages.getInformationIcon()); | ||
} | ||
} | ||
} | ||
|
||
} |