2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com
.intellij
.execution
.junit2
.ui
.actions
;
19 import com
.intellij
.execution
.junit2
.TestProxy
;
20 import com
.intellij
.execution
.junit2
.states
.ComparisonFailureState
;
21 import com
.intellij
.execution
.junit2
.states
.TestState
;
22 import com
.intellij
.execution
.testframework
.AbstractTestProxy
;
23 import com
.intellij
.openapi
.actionSystem
.*;
24 import org
.jetbrains
.annotations
.NonNls
;
28 public class ViewAssertEqualsDiffAction
extends AnAction
{
29 @NonNls public static final String ACTION_ID
= "openAssertEqualsDiff";
30 public void actionPerformed(final AnActionEvent e
) {
31 final DataContext dataContext
= e
.getDataContext();
32 final AbstractTestProxy testProxy
= (AbstractTestProxy
)dataContext
.getData(AbstractTestProxy
.DATA_CONSTANT
);
33 final ComparisonFailureState state
= (ComparisonFailureState
)((TestProxy
)testProxy
).getState();
34 state
.openDiff(PlatformDataKeys
.PROJECT
.getData(dataContext
));
37 public void update(final AnActionEvent e
) {
38 final Presentation presentation
= e
.getPresentation();
39 final boolean enabled
;
40 final DataContext dataContext
= e
.getDataContext();
41 if (dataContext
.getData(DataConstants
.PROJECT
) == null) enabled
= false;
43 final AbstractTestProxy test
= (AbstractTestProxy
)dataContext
.getData(AbstractTestProxy
.DATA_CONSTANT
);
44 if (test
instanceof TestProxy
) {
45 final TestState state
= ((TestProxy
)test
).getState();
46 enabled
= state
instanceof ComparisonFailureState
;
51 presentation
.setEnabled(enabled
);
52 presentation
.setVisible(enabled
);
55 public static void registerShortcut(final JComponent component
) {
56 ActionManager
.getInstance().getAction(ACTION_ID
).registerCustomShortcutSet(CommonShortcuts
.ALT_ENTER
, component
);