Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 214300 | Differences between
and this patch

Collapse All | Expand All

(-)a/hudson/src/org/netbeans/modules/hudson/api/UI.java (-2 / +3 lines)
 Lines 59-64    Link Here 
59
import org.openide.util.ImageUtilities;
59
import org.openide.util.ImageUtilities;
60
import org.openide.util.Mutex;
60
import org.openide.util.Mutex;
61
import org.openide.util.RequestProcessor;
61
import org.openide.util.RequestProcessor;
62
import org.openide.util.actions.SystemAction;
62
import org.openide.windows.TopComponent;
63
import org.openide.windows.TopComponent;
63
import org.openide.windows.WindowManager;
64
import org.openide.windows.WindowManager;
64
65
 Lines 147-160    Link Here 
147
     * Action to show test failures of a build.
148
     * Action to show test failures of a build.
148
     */
149
     */
149
    public static Action showFailuresAction(HudsonJobBuild build) {
150
    public static Action showFailuresAction(HudsonJobBuild build) {
150
        return new ShowFailures(build);
151
        return SystemAction.get(ShowFailures.class);
151
    }
152
    }
152
153
153
    /**
154
    /**
154
     * Action to show test failures of a Maven module build.
155
     * Action to show test failures of a Maven module build.
155
     */
156
     */
156
    public static Action showFailuresAction(HudsonMavenModuleBuild build) {
157
    public static Action showFailuresAction(HudsonMavenModuleBuild build) {
157
        return new ShowFailures(build);
158
        return SystemAction.get(ShowFailures.class);
158
    }
159
    }
159
160
160
    /**
161
    /**
(-)a/hudson/src/org/netbeans/modules/hudson/ui/actions/ShowFailures.java (-24 / +53 lines)
 Lines 41-87    Link Here 
41
 */
41
 */
42
package org.netbeans.modules.hudson.ui.actions;
42
package org.netbeans.modules.hudson.ui.actions;
43
43
44
import java.awt.event.ActionEvent;
45
import java.util.logging.Logger;
44
import java.util.logging.Logger;
46
import javax.swing.AbstractAction;
47
import org.netbeans.modules.hudson.api.HudsonInstance;
45
import org.netbeans.modules.hudson.api.HudsonInstance;
48
import org.netbeans.modules.hudson.api.HudsonJobBuild;
46
import org.netbeans.modules.hudson.api.HudsonJobBuild;
49
import org.netbeans.modules.hudson.api.HudsonMavenModuleBuild;
47
import org.netbeans.modules.hudson.api.HudsonMavenModuleBuild;
50
import org.netbeans.modules.hudson.impl.HudsonInstanceImpl;
48
import org.netbeans.modules.hudson.impl.HudsonInstanceImpl;
51
import org.netbeans.modules.hudson.spi.BuilderConnector;
49
import org.netbeans.modules.hudson.spi.BuilderConnector;
52
import static org.netbeans.modules.hudson.ui.actions.Bundle.*;
50
import org.openide.nodes.Node;
51
import org.openide.util.HelpCtx;
53
import org.openide.util.NbBundle.Messages;
52
import org.openide.util.NbBundle.Messages;
54
import org.openide.util.RequestProcessor;
53
import org.openide.util.RequestProcessor;
54
import org.openide.util.actions.NodeAction;
55
55
56
/**
56
/**
57
 * Action to display test failures.
57
 * Action to display test failures.
58
 */
58
 */
59
public class ShowFailures extends AbstractAction {
59
public class ShowFailures extends NodeAction {
60
60
61
    private static final Logger LOG = Logger.getLogger(ShowFailures.class.getName());
61
    private static final Logger LOG = Logger.getLogger(ShowFailures.class.getName());
62
    private static final RequestProcessor RP = new RequestProcessor(ShowFailures.class);
62
    private static final RequestProcessor RP = new RequestProcessor(ShowFailures.class);
63
    private final HudsonJobBuild build;
64
    private final HudsonMavenModuleBuild moduleBuild;
65
63
66
    public ShowFailures(HudsonJobBuild build) {
67
        this(build, null);
68
    }
69
64
70
    public ShowFailures(HudsonMavenModuleBuild module) {
65
    private void performAction(HudsonJobBuild build,
71
        this(module.getBuild(), module);
72
    }
73
74
    @Messages("ShowFailures.label=Show Test Failures")
75
    private ShowFailures(HudsonJobBuild build,
76
            HudsonMavenModuleBuild moduleBuild) {
66
            HudsonMavenModuleBuild moduleBuild) {
77
67
78
        this.build = build;
79
        this.moduleBuild = moduleBuild;
80
        putValue(NAME, ShowFailures_label());
81
    }
82
83
    @Override
84
    public void actionPerformed(ActionEvent e) {
85
        HudsonInstance hudsonInstance = build.getJob().getInstance();
68
        HudsonInstance hudsonInstance = build.getJob().getInstance();
86
        if (hudsonInstance instanceof HudsonInstanceImpl) {
69
        if (hudsonInstance instanceof HudsonInstanceImpl) {
87
            HudsonInstanceImpl hudsonInstanceImpl =
70
            HudsonInstanceImpl hudsonInstanceImpl =
 Lines 95-102    Link Here 
95
        }
78
        }
96
    }
79
    }
97
80
98
    @Override
81
    private boolean isEnabled(HudsonJobBuild build) {
99
    public boolean isEnabled() {
100
        HudsonInstance instance = build.getJob().getInstance();
82
        HudsonInstance instance = build.getJob().getInstance();
101
        if (instance instanceof HudsonInstanceImpl) {
83
        if (instance instanceof HudsonInstanceImpl) {
102
            BuilderConnector builderClient =
84
            BuilderConnector builderClient =
 Lines 105-108    Link Here 
105
        }
87
        }
106
        return false;
88
        return false;
107
    }
89
    }
90
91
    @Override
92
    protected void performAction(Node[] activatedNodes) {
93
        for (Node n : activatedNodes) {
94
            HudsonJobBuild build;
95
            build = n.getLookup().lookup(HudsonJobBuild.class);
96
            if (build == null) {
97
                HudsonMavenModuleBuild module =
98
                        n.getLookup().lookup(HudsonMavenModuleBuild.class);
99
                if (module != null) {
100
                    performAction(module.getBuild(), module);
101
                }
102
            } else {
103
                performAction(build, null);
104
            }
105
        }
106
    }
107
108
    @Override
109
    protected boolean enable(Node[] activatedNodes) {
110
        for (Node n : activatedNodes) {
111
            HudsonJobBuild build;
112
            build = n.getLookup().lookup(HudsonJobBuild.class);
113
            if (build == null) {
114
                HudsonMavenModuleBuild module =
115
                        n.getLookup().lookup(HudsonMavenModuleBuild.class);
116
                if (module != null) {
117
                    build = module.getBuild();
118
                }
119
            }
120
            if (build == null || !isEnabled(build)) {
121
                return false;
122
            }
123
        }
124
        return activatedNodes.length > 0;
125
    }
126
127
    @Messages("ShowFailures.label=Show Test Failures")
128
    @Override
129
    public String getName() {
130
        return Bundle.ShowFailures_label();
131
    }
132
133
    @Override
134
    public HelpCtx getHelpCtx() {
135
        return null;
136
    }
108
}
137
}

Return to bug 214300
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo