forked from magento/magento2-phpstorm-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfigureUctAction.java
62 lines (52 loc) · 1.81 KB
/
ConfigureUctAction.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
package com.magento.idea.magento2uct.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2uct.ui.ConfigurationDialog;
import org.jetbrains.annotations.NotNull;
public class ConfigureUctAction extends AnAction {
public static final String ACTION_NAME = "Configure The Upgrade Compatibility Tool";
public static final String ACTION_DESCRIPTION = "Magento 2 Upgrade Compatibility Tool Settings";
/**
* An action constructor.
*/
public ConfigureUctAction() {
super(ACTION_NAME, ACTION_DESCRIPTION, AllIcons.Actions.InlayGear);
}
@Override
public void update(final @NotNull AnActionEvent event) {
setIsAvailableForEvent(event, false);
final Project project = event.getProject();
if (project == null || !Settings.isEnabled(project)) {
return;
}
setIsAvailableForEvent(event, true);
}
@Override
public void actionPerformed(final @NotNull AnActionEvent event) {
final Project project = event.getProject();
if (project == null) {
return;
}
ConfigurationDialog.open(project);
}
/**
* Set is action available for event.
*
* @param event AnActionEvent
* @param isAvailable boolean
*/
private void setIsAvailableForEvent(
final @NotNull AnActionEvent event,
final boolean isAvailable
) {
event.getPresentation().setVisible(isAvailable);
event.getPresentation().setEnabled(isAvailable);
}
}