Package com.urswolfer.intellij.plugin.gerrit.ui.action

Source Code of com.urswolfer.intellij.plugin.gerrit.ui.action.StarAction$Proxy

package com.urswolfer.intellij.plugin.gerrit.ui.action;

import com.google.common.base.Optional;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.inject.Inject;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.urswolfer.intellij.plugin.gerrit.GerritModule;
import com.urswolfer.intellij.plugin.gerrit.git.GerritGitUtil;
import icons.Git4ideaIcons;

/**
* @author Urs Wolfer
*/
@SuppressWarnings("ComponentNotRegistered") // proxy class below is registered
public class StarAction extends AbstractLoggedInChangeAction {
    @Inject
    private GerritGitUtil gerritGitUtil;

    public StarAction() {
        super("Star", "Switch star status of change", Git4ideaIcons.Star);
    }

    @Override
    public void actionPerformed(AnActionEvent anActionEvent) {
        Optional<ChangeInfo> selectedChange = getSelectedChange(anActionEvent);
        if (!selectedChange.isPresent()) {
            return;
        }
        Project project = anActionEvent.getData(PlatformDataKeys.PROJECT);
        ChangeInfo changeInfo = selectedChange.get();
        gerritUtil.changeStarredStatus(changeInfo.id, !(changeInfo.starred != null && changeInfo.starred), project);
    }

    public static class Proxy extends StarAction {
        private final StarAction delegate;

        public Proxy() {
            delegate = GerritModule.getInstance(StarAction.class);
        }

        @Override
        public void update(AnActionEvent e) {
            delegate.update(e);
        }

        @Override
        public void actionPerformed(AnActionEvent e) {
            delegate.actionPerformed(e);
        }
    }
}
TOP

Related Classes of com.urswolfer.intellij.plugin.gerrit.ui.action.StarAction$Proxy

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.