Skip to content

Commit e1c2f60

Browse files
authored
Merge pull request #636 from bohdan-harniuk/uct-project-dev
Enhanced analysis execution, added settings
2 parents f73b27d + dbbf399 commit e1c2f60

30 files changed

+1090
-97
lines changed

resources/META-INF/plugin.xml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,14 @@
118118
</group>
119119
<group id="UctRunMenu">
120120
<separator/>
121+
<action id="com.magento.idea.magento2uct.actions.ConfigureUctAction"
122+
class="com.magento.idea.magento2uct.actions.ConfigureUctAction"
123+
text="Configure The Upgrade Compatibility Tool"/>
121124
<action id="com.magento.idea.magento2uct.actions.RunUpgradeCompatibilityToolAction"
122125
class="com.magento.idea.magento2uct.actions.RunUpgradeCompatibilityToolAction"
123126
text="Run The Upgrade Compatibility Tool Action"/>
124-
<add-to-group group-id="RunMenu" anchor="last"/>
127+
<separator/>
128+
<add-to-group group-id="ToolsMenu" anchor="last"/>
125129
</group>
126130
</actions>
127131

@@ -256,84 +260,84 @@
256260
shortName="ExtendingDeprecatedClass"
257261
bundle="uct.bundle.inspection" key="inspection.displayName.ExtendingDeprecatedClass"
258262
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
259-
enabledByDefault="true"
263+
enabledByDefault="false"
260264
level="WARNING"
261265
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.ExtendingDeprecatedClass"/>
262266
<localInspection language="PHP" groupPath="UCT"
263267
shortName="ImportingDeprecatedClass"
264268
bundle="uct.bundle.inspection" key="inspection.displayName.ImportingDeprecatedClass"
265269
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
266-
enabledByDefault="true"
270+
enabledByDefault="false"
267271
level="WARNING"
268272
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.ImportingDeprecatedClass"/>
269273
<localInspection language="PHP" groupPath="UCT"
270274
shortName="ImportingDeprecatedInterface"
271275
bundle="uct.bundle.inspection" key="inspection.displayName.ImportingDeprecatedInterface"
272276
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
273-
enabledByDefault="true"
277+
enabledByDefault="false"
274278
level="WARNING"
275279
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.ImportingDeprecatedInterface"/>
276280
<localInspection language="PHP" groupPath="UCT"
277281
shortName="UsingDeprecatedClass"
278282
bundle="uct.bundle.inspection" key="inspection.displayName.UsingDeprecatedClass"
279283
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
280-
enabledByDefault="true"
284+
enabledByDefault="false"
281285
level="WARNING"
282286
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.UsingDeprecatedClass"/>
283287
<localInspection language="PHP" groupPath="UCT"
284288
shortName="UsingDeprecatedInterface"
285289
bundle="uct.bundle.inspection" key="inspection.displayName.UsingDeprecatedInterface"
286290
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
287-
enabledByDefault="true"
291+
enabledByDefault="false"
288292
level="WARNING"
289293
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.UsingDeprecatedInterface"/>
290294
<localInspection language="PHP" groupPath="UCT"
291295
shortName="UsingDeprecatedConstant"
292296
bundle="uct.bundle.inspection" key="inspection.displayName.UsingDeprecatedConstant"
293297
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
294-
enabledByDefault="true"
298+
enabledByDefault="false"
295299
level="WARNING"
296300
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.UsingDeprecatedConstant"/>
297301
<localInspection language="PHP" groupPath="UCT"
298302
shortName="OverridingDeprecatedConstant"
299303
bundle="uct.bundle.inspection" key="inspection.displayName.OverridingDeprecatedConstant"
300304
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
301-
enabledByDefault="true"
305+
enabledByDefault="false"
302306
level="WARNING"
303307
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.OverridingDeprecatedConstant"/>
304308
<localInspection language="PHP" groupPath="UCT"
305309
shortName="OverridingDeprecatedProperty"
306310
bundle="uct.bundle.inspection" key="inspection.displayName.OverridingDeprecatedProperty"
307311
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
308-
enabledByDefault="true"
312+
enabledByDefault="false"
309313
level="WARNING"
310314
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.OverridingDeprecatedProperty"/>
311315
<localInspection language="PHP" groupPath="UCT"
312316
shortName="InheritedDeprecatedInterface"
313317
bundle="uct.bundle.inspection" key="inspection.displayName.InheritedDeprecatedInterface"
314318
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
315-
enabledByDefault="true"
319+
enabledByDefault="false"
316320
level="WARNING"
317321
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.InheritedDeprecatedInterface"/>
318322
<localInspection language="PHP" groupPath="UCT"
319323
shortName="ImplementedDeprecatedInterface"
320324
bundle="uct.bundle.inspection" key="inspection.displayName.ImplementedDeprecatedInterface"
321325
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
322-
enabledByDefault="true"
326+
enabledByDefault="false"
323327
level="WARNING"
324328
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.ImplementedDeprecatedInterface"/>
325329
<localInspection language="PHP" groupPath="UCT"
326330
shortName="CallingDeprecatedMethod"
327331
bundle="uct.bundle.inspection" key="inspection.displayName.CallingDeprecatedMethod"
328332
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
329-
enabledByDefault="true"
333+
enabledByDefault="false"
330334
level="WARNING"
331335
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.CallingDeprecatedMethod"/>
332336
<localInspection language="PHP" groupPath="UCT"
333337
shortName="UsingDeprecatedProperty"
334338
bundle="uct.bundle.inspection" key="inspection.displayName.UsingDeprecatedProperty"
335339
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
336-
enabledByDefault="true"
340+
enabledByDefault="false"
337341
level="WARNING"
338342
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.UsingDeprecatedProperty"/>
339343
<!-- \UCT inspection -->
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2uct.actions;
7+
8+
import com.intellij.icons.AllIcons;
9+
import com.intellij.openapi.actionSystem.AnAction;
10+
import com.intellij.openapi.actionSystem.AnActionEvent;
11+
import com.intellij.openapi.project.Project;
12+
import com.magento.idea.magento2plugin.project.Settings;
13+
import com.magento.idea.magento2uct.ui.ConfigurationDialog;
14+
import org.jetbrains.annotations.NotNull;
15+
16+
public class ConfigureUctAction extends AnAction {
17+
18+
public static final String ACTION_NAME = "Configure The Upgrade Compatibility Tool";
19+
public static final String ACTION_DESCRIPTION = "Magento 2 Upgrade Compatibility Tool Settings";
20+
21+
/**
22+
* An action constructor.
23+
*/
24+
public ConfigureUctAction() {
25+
super(ACTION_NAME, ACTION_DESCRIPTION, AllIcons.Actions.InlayGear);
26+
}
27+
28+
@Override
29+
public void update(final @NotNull AnActionEvent event) {
30+
setIsAvailableForEvent(event, false);
31+
final Project project = event.getProject();
32+
33+
if (project == null || !Settings.isEnabled(project)) {
34+
return;
35+
}
36+
setIsAvailableForEvent(event, true);
37+
}
38+
39+
@Override
40+
public void actionPerformed(final @NotNull AnActionEvent event) {
41+
final Project project = event.getProject();
42+
43+
if (project == null) {
44+
return;
45+
}
46+
ConfigurationDialog.open(project);
47+
}
48+
49+
/**
50+
* Set is action available for event.
51+
*
52+
* @param event AnActionEvent
53+
* @param isAvailable boolean
54+
*/
55+
private void setIsAvailableForEvent(
56+
final @NotNull AnActionEvent event,
57+
final boolean isAvailable
58+
) {
59+
event.getPresentation().setVisible(isAvailable);
60+
event.getPresentation().setEnabled(isAvailable);
61+
}
62+
}

src/com/magento/idea/magento2uct/actions/RunUpgradeCompatibilityToolAction.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
import com.intellij.openapi.actionSystem.AnActionEvent;
1111
import com.intellij.openapi.project.Project;
1212
import com.magento.idea.magento2plugin.project.Settings;
13-
import com.magento.idea.magento2uct.execution.RunAnalysisExecutor;
13+
import com.magento.idea.magento2uct.execution.DefaultExecutor;
1414
import com.magento.idea.magento2uct.execution.process.DefaultAnalysisHandler;
15+
import com.magento.idea.magento2uct.settings.UctSettingsService;
1516
import org.jetbrains.annotations.NotNull;
1617

1718
public class RunUpgradeCompatibilityToolAction extends AnAction {
@@ -34,7 +35,12 @@ public void update(final @NotNull AnActionEvent event) {
3435
if (project == null || !Settings.isEnabled(project)) {
3536
return;
3637
}
38+
final UctSettingsService uctSettingsService = UctSettingsService.getInstance(project);
3739
setIsAvailableForEvent(event, true);
40+
41+
if (!uctSettingsService.isEnabled()) {
42+
event.getPresentation().setEnabled(false);
43+
}
3844
}
3945

4046
@Override
@@ -44,7 +50,7 @@ public void actionPerformed(final @NotNull AnActionEvent event) {
4450
if (project == null) {
4551
return;
4652
}
47-
final RunAnalysisExecutor executor = new RunAnalysisExecutor(
53+
final DefaultExecutor executor = new DefaultExecutor(
4854
project,
4955
new DefaultAnalysisHandler(project)
5056
);

src/com/magento/idea/magento2uct/execution/RunAnalysisExecutor.java renamed to src/com/magento/idea/magento2uct/execution/DefaultExecutor.java

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package com.magento.idea.magento2uct.execution;
77

8+
import com.intellij.execution.ExecutionBundle;
89
import com.intellij.execution.Executor;
910
import com.intellij.execution.executors.DefaultRunExecutor;
1011
import com.intellij.execution.filters.TextConsoleBuilder;
@@ -13,16 +14,25 @@
1314
import com.intellij.execution.ui.ConsoleView;
1415
import com.intellij.execution.ui.RunContentDescriptor;
1516
import com.intellij.execution.ui.RunContentManager;
17+
import com.intellij.icons.AllIcons;
1618
import com.intellij.openapi.Disposable;
19+
import com.intellij.openapi.actionSystem.ActionManager;
20+
import com.intellij.openapi.actionSystem.ActionToolbar;
21+
import com.intellij.openapi.actionSystem.AnAction;
22+
import com.intellij.openapi.actionSystem.AnActionEvent;
23+
import com.intellij.openapi.actionSystem.DefaultActionGroup;
1724
import com.intellij.openapi.fileEditor.FileDocumentManager;
25+
import com.intellij.openapi.project.DumbAware;
1826
import com.intellij.openapi.project.Project;
1927
import com.intellij.openapi.util.Disposer;
28+
import com.magento.idea.magento2uct.execution.filters.UctPhpFileFilter;
29+
import com.magento.idea.magento2uct.execution.filters.UctResultFileFilter;
2030
import java.awt.BorderLayout;
2131
import javax.swing.JComponent;
2232
import javax.swing.JPanel;
2333
import org.jetbrains.annotations.NotNull;
2434

25-
public class RunAnalysisExecutor implements Disposable {
35+
public class DefaultExecutor implements Disposable {
2636

2737
private static final String RUN_CONTENT_TITLE = "UCT analysis";
2838

@@ -35,7 +45,7 @@ public class RunAnalysisExecutor implements Disposable {
3545
* @param project Project
3646
* @param process ProcessHandler
3747
*/
38-
public RunAnalysisExecutor(
48+
public DefaultExecutor(
3949
final @NotNull Project project,
4050
final @NotNull ProcessHandler process
4151
) {
@@ -64,9 +74,14 @@ private ConsoleView createConsole() {
6474
final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory
6575
.getInstance()
6676
.createBuilder(myProject);
67-
// TODO: Add filters.
77+
consoleBuilder.addFilter(new UctPhpFileFilter(myProject));
78+
consoleBuilder.addFilter(new UctResultFileFilter(myProject));
79+
6880
final ConsoleView console = consoleBuilder.getConsole();
69-
final JComponent consolePanel = createConsolePanel(console);
81+
82+
final DefaultActionGroup actions = new DefaultActionGroup();
83+
84+
final JComponent consolePanel = createConsolePanel(console, actions);
7085
final RunContentDescriptor descriptor = new RunContentDescriptor(
7186
console,
7287
myProcess,
@@ -80,6 +95,7 @@ private ConsoleView createConsole() {
8095

8196
Disposer.register(descriptor, this);
8297
Disposer.register(descriptor, console);
98+
actions.add(new StopAction());
8399

84100
RunContentManager
85101
.getInstance(myProject)
@@ -95,18 +111,53 @@ private ConsoleView createConsole() {
95111
* Create console panel.
96112
*
97113
* @param view ConsoleView
114+
* @param actionGroup DefaultActionGroup
98115
*
99116
* @return JComponent
100117
*/
101-
private static JComponent createConsolePanel(final ConsoleView view) {
118+
private static JComponent createConsolePanel(
119+
final ConsoleView view,
120+
final DefaultActionGroup actionGroup
121+
) {
102122
JPanel panel = new JPanel();
123+
final ActionToolbar actionToolbar = ActionManager
124+
.getInstance()
125+
.createActionToolbar(
126+
"RunContentExecutor",
127+
actionGroup,
128+
false
129+
);
130+
actionToolbar.setTargetComponent(panel);
103131
panel.setLayout(new BorderLayout());
104132
panel.add(view.getComponent(), BorderLayout.CENTER);
133+
panel.add(actionToolbar.getComponent(), BorderLayout.WEST);
105134

106135
return panel;
107136
}
108137

109138
@Override
110139
public void dispose() {
111140
}
141+
142+
private class StopAction extends AnAction implements DumbAware {
143+
144+
public StopAction() {
145+
super(
146+
ExecutionBundle.messagePointer("action.AnAction.text.stop"),
147+
ExecutionBundle.messagePointer("action.AnAction.description.stop"),
148+
AllIcons.Actions.Suspend
149+
);
150+
}
151+
152+
@Override
153+
public void actionPerformed(final @NotNull AnActionEvent event) {
154+
myProcess.destroyProcess();
155+
}
156+
157+
@Override
158+
public void update(final @NotNull AnActionEvent event) {
159+
event.getPresentation().setVisible(true);
160+
event.getPresentation().setEnabled(!myProcess.isProcessTerminated());
161+
}
162+
}
112163
}

0 commit comments

Comments
 (0)