1/*
2 * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25package com.sun.hotspot.igv.coordinator.actions;
26
27import org.openide.nodes.Node;
28import org.openide.util.HelpCtx;
29import org.openide.util.NbBundle;
30import org.openide.util.actions.CookieAction;
31
32/**
33 *
34 * @author Thomas Wuerthinger
35 */
36public final class DiffGraphAction extends CookieAction {
37
38    @Override
39    protected void performAction(Node[] activatedNodes) {
40        DiffGraphCookie c = activatedNodes[0].getCookie(DiffGraphCookie.class);
41        assert c != null;
42        c.openDiff();
43    }
44
45    @Override
46    protected int mode() {
47        return CookieAction.MODE_EXACTLY_ONE;
48    }
49
50    @Override
51    protected boolean enable(Node[] activatedNodes) {
52        boolean b = super.enable(activatedNodes);
53        if (b) {
54            assert activatedNodes.length == 1;
55            DiffGraphCookie c = activatedNodes[0].getCookie(DiffGraphCookie.class);
56            assert c != null;
57            return c.isPossible();
58        }
59
60        return false;
61    }
62
63    @Override
64    public String getName() {
65        return NbBundle.getMessage(DiffGraphAction.class, "CTL_DiffGraphAction");
66    }
67
68    @Override
69    protected Class<?>[] cookieClasses() {
70        return new Class<?>[]{
71            DiffGraphCookie.class
72        };
73    }
74
75    @Override
76    protected String iconResource() {
77        return "com/sun/hotspot/igv/coordinator/images/diff.png";
78    }
79
80    @Override
81    public HelpCtx getHelpCtx() {
82        return HelpCtx.DEFAULT_HELP;
83    }
84
85    @Override
86    protected boolean asynchronous() {
87        return false;
88    }
89}
90
91