Skip to content

Commit 56aecb8

Browse files
Enhanced UCT run configuration
1 parent 8ab114d commit 56aecb8

11 files changed

+233
-50
lines changed

resources/META-INF/plugin.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</change-notes>
2525

2626
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
27-
<idea-version since-build="212.5080.71"/>
27+
<idea-version since-build="212.5080.55"/>
2828

2929
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
3030
on how to target different products -->

resources/icons/pluginIcon16x16.svg

+13
Loading

resources/icons/pluginIcon64x64.svg

+13
Loading

src/com/magento/idea/magento2plugin/MagentoIcons.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public class MagentoIcons {
1313

1414
public static final Icon WEB_API = IconLoader.getIcon("/icons/webapi.png", MagentoIcons.class);
1515
public static final Icon MODULE = IconLoader.getIcon("/icons/module.png", MagentoIcons.class);
16-
public static final Icon PLUGIN_ICON = IconLoader.getIcon(
17-
"/META-INF/pluginIcon.svg",
18-
MagentoIcons.class
19-
);
16+
public static final Icon PLUGIN_ICON_SMALL =
17+
IconLoader.getIcon("/icons/pluginIcon16x16.svg", MagentoIcons.class);
18+
public static final Icon PLUGIN_ICON_MEDIUM =
19+
IconLoader.getIcon("/icons/pluginIcon64x64.svg", MagentoIcons.class);
2020
}

src/com/magento/idea/magento2uct/execution/DownloadUctCommand.java

+32-2
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@
77

88
import com.intellij.execution.ExecutionException;
99
import com.intellij.execution.configurations.GeneralCommandLine;
10+
import com.intellij.execution.configurations.PtyCommandLine;
1011
import com.intellij.execution.filters.TextConsoleBuilderFactory;
1112
import com.intellij.execution.process.OSProcessHandler;
1213
import com.intellij.execution.process.ProcessHandlerFactory;
1314
import com.intellij.execution.process.ProcessTerminatedListener;
1415
import com.intellij.execution.ui.ConsoleView;
16+
import com.intellij.icons.AllIcons;
1517
import com.intellij.openapi.project.Project;
18+
import com.intellij.openapi.util.SystemInfo;
1619
import com.intellij.openapi.wm.RegisterToolWindowTask;
1720
import com.intellij.openapi.wm.ToolWindow;
1821
import com.intellij.openapi.wm.ToolWindowAnchor;
1922
import com.intellij.openapi.wm.ToolWindowId;
2023
import com.intellij.openapi.wm.ToolWindowManager;
2124
import com.intellij.ui.content.Content;
25+
import com.magento.idea.magento2plugin.MagentoIcons;
2226
import org.jetbrains.annotations.NotNull;
2327

2428
public final class DownloadUctCommand {
@@ -55,7 +59,7 @@ public void execute() {
5559
* @return OSProcessHandler
5660
*/
5761
private OSProcessHandler createProcessHandler() throws ExecutionException {
58-
final GeneralCommandLine commandLine = new GeneralCommandLine();
62+
final GeneralCommandLine commandLine = createGeneralCommandLine(true);
5963
commandLine.setWorkDirectory(project.getBasePath());
6064
commandLine.setExePath("composer");
6165
commandLine.addParameters(
@@ -76,6 +80,30 @@ private OSProcessHandler createProcessHandler() throws ExecutionException {
7680
return processHandler;
7781
}
7882

83+
/**
84+
* Create general command line.
85+
*
86+
* @param withPty boolean
87+
*
88+
* @return GeneralCommandLine
89+
*/
90+
private GeneralCommandLine createGeneralCommandLine(boolean withPty) {
91+
GeneralCommandLine commandLine;
92+
93+
if (withPty) {
94+
if (!SystemInfo.isWindows) {
95+
commandLine = new PtyCommandLine().withInitialColumns(2500);
96+
} else {
97+
commandLine = new GeneralCommandLine();
98+
commandLine.getEnvironment().putIfAbsent("TERM", "xterm");
99+
}
100+
} else {
101+
commandLine = new GeneralCommandLine();
102+
}
103+
104+
return commandLine;
105+
}
106+
79107
/**
80108
* Create console view.
81109
*
@@ -97,7 +125,7 @@ private ConsoleView createConsole() {
97125
true,
98126
true,
99127
null,
100-
null,
128+
AllIcons.Actions.Execute,
101129
null
102130
)
103131
);
@@ -109,6 +137,8 @@ private ConsoleView createConsole() {
109137
.getContentManager()
110138
.getFactory()
111139
.createContent(consoleView.getComponent(), TAB_TITLE, true);
140+
content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
141+
content.setIcon(MagentoIcons.PLUGIN_ICON_SMALL);
112142
toolWindow.getContentManager().addContent(content);
113143
toolWindow.show();
114144

src/com/magento/idea/magento2uct/execution/configurations/UctRunConfiguration.java

+27
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.magento.idea.magento2uct.execution.filters.UctResultFileFilter;
3232
import com.magento.idea.magento2uct.settings.UctSettingsService;
3333
import com.magento.idea.magento2uct.util.module.UctExecutableValidatorUtil;
34+
import com.magento.idea.magento2uct.util.module.UctModulePathValidatorUtil;
3435
import com.magento.idea.magento2uct.versioning.IssueSeverityLevel;
3536
import org.jetbrains.annotations.NotNull;
3637
import org.jetbrains.annotations.Nullable;
@@ -93,6 +94,24 @@ public String getProjectRoot() {
9394
return getOptions().getProjectRoot();
9495
}
9596

97+
/**
98+
* Set path to analyse setting.
99+
*
100+
* @param modulePath String
101+
*/
102+
public void setModulePath(final String modulePath) {
103+
getOptions().setModulePath(modulePath);
104+
}
105+
106+
/**
107+
* Get path to analyse.
108+
*
109+
* @return String
110+
*/
111+
public String getModulePath() {
112+
return getOptions().getModulePath();
113+
}
114+
96115
/**
97116
* Set coming version setting.
98117
*
@@ -246,6 +265,14 @@ public void checkConfiguration() throws RuntimeConfigurationException {
246265
final IssueSeverityLevel defaultSeverityLevel =
247266
IssueSeverityLevel.getDefaultIssueSeverityLevel();
248267

268+
if (!getModulePath().isEmpty()) {
269+
if (UctModulePathValidatorUtil.validate(getModulePath())) {
270+
commandLine.addParameter("--module-path=".concat(getModulePath()));
271+
} else {
272+
throw new ExecutionException("The path to analyse is not valid");
273+
}
274+
}
275+
249276
if (!severityLevel.equals(defaultSeverityLevel)) {
250277
commandLine
251278
.addParameter("--min-issue-level=".concat(severityLevel.getLabel()));

src/com/magento/idea/magento2uct/execution/configurations/UctRunConfigurationOptions.java

+20
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class UctRunConfigurationOptions extends LocatableRunConfigurationOptions
1414
.provideDelegate(this, "scriptName");
1515
private final StoredProperty<String> projectRoot = string("")
1616
.provideDelegate(this, "projectRoot");
17+
private final StoredProperty<String> modulePath = string("")
18+
.provideDelegate(this, "modulePath");
1719
private final StoredProperty<String> comingVersion = string("")
1820
.provideDelegate(this, "comingVersion");
1921
private final StoredProperty<Integer> minIssueLevel = property(3)
@@ -59,6 +61,24 @@ public String getProjectRoot() {
5961
return projectRoot.getValue(this) != null ? projectRoot.getValue(this) : "";
6062
}
6163

64+
/**
65+
* Set path to analyse setting.
66+
*
67+
* @param modulePath String
68+
*/
69+
public void setModulePath(final String modulePath) {
70+
this.modulePath.setValue(this, modulePath);
71+
}
72+
73+
/**
74+
* Get path to analyse.
75+
*
76+
* @return String
77+
*/
78+
public String getModulePath() {
79+
return modulePath.getValue(this) != null ? modulePath.getValue(this) : "";
80+
}
81+
6282
/**
6383
* Set coming version setting.
6484
*

src/com/magento/idea/magento2uct/execution/configurations/UctRunConfigurationType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public String getConfigurationTypeDescription() {
3030

3131
@Override
3232
public Icon getIcon() {
33-
return MagentoIcons.PLUGIN_ICON;
33+
return MagentoIcons.PLUGIN_ICON_SMALL;
3434
}
3535

3636
@Override

0 commit comments

Comments
 (0)