// Path: SVNToolBox/src/main/java/zielu/svntoolbox/SvnToolBoxBundle.java
// public class SvnToolBoxBundle {
//     private static Reference<ResourceBundle> ourBundle;
// 
//     @NonNls
//     private static final String BUNDLE = "zielu.svntoolbox.SvnToolBoxBundle";
// 
//     private SvnToolBoxBundle() {
//     }
// 
//     public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
//         return CommonBundle.message(getBundle(), key, params);
//     }
// 
//     public static String getString(@PropertyKey(resourceBundle = BUNDLE) String key) {
//         return getBundle().getString(key);
//     }
// 
//     private static ResourceBundle getBundle() {
//         ResourceBundle bundle = null;
//         if (ourBundle != null) {
//             bundle = ourBundle.get();
//         }
//         if (bundle == null) {
//             bundle = ResourceBundle.getBundle(BUNDLE);
//             ourBundle = new SoftReference<ResourceBundle>(bundle);
//         }
//         return bundle;
//     }
// }
// 
// Path: SVNToolBox/src/main/java/zielu/svntoolbox/config/SvnToolBoxProjectState.java
// @State(
//     name = "SvnToolBoxConfig",
//     storages = @Storage("SvnToolBox.xml")
// )
// public class SvnToolBoxProjectState implements PersistentStateComponent<SvnToolBoxProjectState> {
//     public boolean showProjectViewModuleDecoration = true;
//     public boolean showProjectViewSwitchedDecoration = true;
// 
//     public static SvnToolBoxProjectState getInstance(@NotNull Project project) {
//         return ServiceManager.getService(project, SvnToolBoxProjectState.class);
//     }
// 
//     public boolean showingAnyDecorations() {
//         return showProjectViewModuleDecoration || showProjectViewSwitchedDecoration;
//     }
// 
//     @Nullable
//     @Override
//     public SvnToolBoxProjectState getState() {
//         return this;
//     }
// 
//     @Override
//     public void loadState(SvnToolBoxProjectState state) {
//         XmlSerializerUtil.copyBean(state, this);
//     }
// }
// 
// Path: SVNToolBox/src/main/java/zielu/svntoolbox/projectView/DecorationToggleNotifier.java
// public interface DecorationToggleNotifier {
//     Topic<DecorationToggleNotifier> TOGGLE_TOPIC = Topic.create("Toggle decorations", DecorationToggleNotifier.class);
// 
//     void decorationChanged(Project project);
// }


import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.Project;
import zielu.svntoolbox.SvnToolBoxBundle;
import zielu.svntoolbox.config.SvnToolBoxProjectState;
import zielu.svntoolbox.projectView.DecorationToggleNotifier;
/* 
 * @(#) $Id:  $
 */
package zielu.svntoolbox.ui.actions;


/**
 * <p></p>
 * <br/>
 * <p>Created on 21.09.13</p>
 *
 * @author Lukasz Zielinski
 */
public class ToggleSvnModuleDecorationAction extends ToggleAction {

    public ToggleSvnModuleDecorationAction() {
        super(SvnToolBoxBundle.getString("action.show.module.decorations"));
    }

    @Override
    public boolean isSelected(AnActionEvent e) {
        Project project = e.getProject();
        if (project != null) {
            return SvnToolBoxProjectState.getInstance(project).showProjectViewModuleDecoration;
        }
        return false;
    }

    @Override
    public void setSelected(AnActionEvent e, boolean state) {
        Project project = e.getProject();
        if (project != null) {
            SvnToolBoxProjectState.getInstance(project).showProjectViewModuleDecoration = state;
            project.getMessageBus().
// Path: SVNToolBox/src/main/java/zielu/svntoolbox/SvnToolBoxBundle.java
// public class SvnToolBoxBundle {
//     private static Reference<ResourceBundle> ourBundle;
// 
//     @NonNls
//     private static final String BUNDLE = "zielu.svntoolbox.SvnToolBoxBundle";
// 
//     private SvnToolBoxBundle() {
//     }
// 
//     public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
//         return CommonBundle.message(getBundle(), key, params);
//     }
// 
//     public static String getString(@PropertyKey(resourceBundle = BUNDLE) String key) {
//         return getBundle().getString(key);
//     }
// 
//     private static ResourceBundle getBundle() {
//         ResourceBundle bundle = null;
//         if (ourBundle != null) {
//             bundle = ourBundle.get();
//         }
//         if (bundle == null) {
//             bundle = ResourceBundle.getBundle(BUNDLE);
//             ourBundle = new SoftReference<ResourceBundle>(bundle);
//         }
//         return bundle;
//     }
// }
// 
// Path: SVNToolBox/src/main/java/zielu/svntoolbox/config/SvnToolBoxProjectState.java
// @State(
//     name = "SvnToolBoxConfig",
//     storages = @Storage("SvnToolBox.xml")
// )
// public class SvnToolBoxProjectState implements PersistentStateComponent<SvnToolBoxProjectState> {
//     public boolean showProjectViewModuleDecoration = true;
//     public boolean showProjectViewSwitchedDecoration = true;
// 
//     public static SvnToolBoxProjectState getInstance(@NotNull Project project) {
//         return ServiceManager.getService(project, SvnToolBoxProjectState.class);
//     }
// 
//     public boolean showingAnyDecorations() {
//         return showProjectViewModuleDecoration || showProjectViewSwitchedDecoration;
//     }
// 
//     @Nullable
//     @Override
//     public SvnToolBoxProjectState getState() {
//         return this;
//     }
// 
//     @Override
//     public void loadState(SvnToolBoxProjectState state) {
//         XmlSerializerUtil.copyBean(state, this);
//     }
// }
// 
// Path: SVNToolBox/src/main/java/zielu/svntoolbox/projectView/DecorationToggleNotifier.java
// public interface DecorationToggleNotifier {
//     Topic<DecorationToggleNotifier> TOGGLE_TOPIC = Topic.create("Toggle decorations", DecorationToggleNotifier.class);
// 
//     void decorationChanged(Project project);
// }


// Path: SVNToolBox/src/main/java/zielu/svntoolbox/ui/actions/ToggleSvnModuleDecorationAction.java
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.Project;
import zielu.svntoolbox.SvnToolBoxBundle;
import zielu.svntoolbox.config.SvnToolBoxProjectState;
import zielu.svntoolbox.projectView.DecorationToggleNotifier;

/* 
 * @(#) $Id:  $
 */
package zielu.svntoolbox.ui.actions;


/**
 * <p></p>
 * <br/>
 * <p>Created on 21.09.13</p>
 *
 * @author Lukasz Zielinski
 */
public class ToggleSvnModuleDecorationAction extends ToggleAction {

    public ToggleSvnModuleDecorationAction() {
        super(SvnToolBoxBundle.getString("action.show.module.decorations"));
    }

    @Override
    public boolean isSelected(AnActionEvent e) {
        Project project = e.getProject();
        if (project != null) {
            return SvnToolBoxProjectState.getInstance(project).showProjectViewModuleDecoration;
        }
        return false;
    }

    @Override
    public void setSelected(AnActionEvent e, boolean state) {
        Project project = e.getProject();
        if (project != null) {
            SvnToolBoxProjectState.getInstance(project).showProjectViewModuleDecoration = state;
            project.getMessageBus().
                    syncPublisher(DecorationToggleNotifier.TOGGLE_TOPIC).decorationChanged(project);