Skip to content

Commit

Permalink
auto load context.xml if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
zengkid committed May 1, 2020
1 parent dc01eaf commit 2086358
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 70 deletions.
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.4.14'
id 'org.jetbrains.intellij' version '0.4.18'
}

version '3.5.0'
version '3.6.1'

sourceCompatibility = 1.8

Expand All @@ -16,14 +16,16 @@ dependencies {
}

intellij {
version '2019.3'
version '2019.3.3'
pluginName = 'SmartTomcat'
plugins 'java'
updateSinceUntilBuild false
}
patchPluginXml {
changeNotes """
new feature: Additional context parameters in custom context.xml.
3.6.1: 1.auto load webapp/META-INF/context instead of manual choose context.xml
2.bug fixed
3.6.0: remove ajp port.
fixed: 2019.3 storage issue.
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ private void updateServerConf(String tomcatVersion, Module module, Path confPath

Element contextE = doc.createElement("Context");


String customContext = cfg.getCustomContext();
String customContext = cfg.getDocBase() + "/META-INF/context.xml";
if (StringUtil.isNotEmpty(customContext)) {
File customContextFile = new File(customContext);
if (customContextFile.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
public class TomcatRunConfiguration extends RunConfigurationBase implements RunProfileWithCompileBeforeLaunchOption {
private TomcatInfo tomcatInfo;
private String docBase;
private String customContext;
private String moduleName;
private String contextPath;
private String port;
Expand Down Expand Up @@ -90,14 +89,6 @@ public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}

public String getCustomContext() {
return customContext;
}

public void setCustomContext(String customContext) {
this.customContext = customContext;
}

public String getContextPath() {
return contextPath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ protected void resetEditorFrom(TomcatRunConfiguration tomcatRunConfiguration) {
runnerSetting.getDocBaseField().getTextField().setText(docBase);
}

String customContext = tomcatRunConfiguration.getCustomContext();
if (customContext != null && !"".equals(customContext.trim())) {

runnerSetting.getCustomContextField().setText(customContext);
runnerSetting.getCustomContextField().getTextField().setText(customContext);
}

String contextPath = tomcatRunConfiguration.getContextPath();
if (contextPath != null && !"".equals(contextPath.trim())) {
Expand Down Expand Up @@ -100,7 +94,6 @@ protected void applyEditorTo(TomcatRunConfiguration tomcatRunConfiguration) thro
tomcatRunConfiguration.setTomcatInfo(selectedItem);
}
tomcatRunConfiguration.setDocBase(runnerSetting.getDocBaseField().getText());
tomcatRunConfiguration.setCustomContext(runnerSetting.getCustomContextField().getText());
tomcatRunConfiguration.setContextPath(runnerSetting.getContextPathField().getText());
tomcatRunConfiguration.setPort(runnerSetting.getPortField().getText());
tomcatRunConfiguration.setAdminPort(runnerSetting.getAdminPort().getText());
Expand All @@ -117,7 +110,6 @@ protected JComponent createEditor() {

ComboboxWithBrowseButton tomcatField = runnerSetting.getTomcatField();
TextFieldWithBrowseButton docBaseField = runnerSetting.getDocBaseField();
TextFieldWithBrowseButton customContextField = runnerSetting.getCustomContextField();

JTextField contextPathField = runnerSetting.getContextPathField();
JFormattedTextField portField = runnerSetting.getPortField();
Expand All @@ -141,22 +133,12 @@ protected void textChanged(DocumentEvent documentEvent) {
Module module = ModuleUtilCore.findModuleForFile(fileByIoFile, project);
String contextPath = module == null ? "/" : "/" + module.getName();
contextPathField.setText(contextPath);

File contextFile = new File(text + "/META-INF/context.xml");
if (contextFile.exists()) {
customContextField.setText(contextFile.getPath());
customContextField.getTextField().setText(contextFile.getPath());

}

}
}

}
});

customContextField.addBrowseFolderListener("Context xml", "Choose custom context xml file", project, FileChooserDescriptorFactory.createSingleFileDescriptor().withRoots(baseDir));

portField.setValue(8080);
adminPort.setValue(8005);
DefaultFormatterFactory tf = new DefaultFormatterFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
<rowspec value="center:32px:noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
Expand Down Expand Up @@ -65,7 +63,7 @@
</component>
<component id="fc00f" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
Expand All @@ -74,7 +72,7 @@
</component>
<component id="cd59c" class="javax.swing.JTextField" binding="contextPathField">
<constraints>
<grid row="6" column="2" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="4" column="2" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
Expand All @@ -83,7 +81,7 @@
</component>
<component id="8df0e" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
Expand All @@ -92,7 +90,7 @@
</component>
<component id="ad43a" class="javax.swing.JFormattedTextField" binding="portField">
<constraints>
<grid row="8" column="2" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="6" column="2" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
Expand All @@ -112,7 +110,7 @@
</component>
<component id="7eb04" class="javax.swing.JLabel">
<constraints>
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
Expand All @@ -121,7 +119,7 @@
</component>
<component id="cbe38" class="com.intellij.ui.RawCommandLineEditor" binding="vmOptons">
<constraints>
<grid row="12" column="2" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<grid row="10" column="2" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
Expand All @@ -130,7 +128,7 @@
</component>
<component id="40838" class="javax.swing.JLabel">
<constraints>
<grid row="14" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
Expand All @@ -139,7 +137,7 @@
</component>
<component id="43f5c" class="com.intellij.execution.configuration.EnvironmentVariablesComponent" binding="envOptions">
<constraints>
<grid row="14" column="2" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<grid row="12" column="2" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
Expand All @@ -149,7 +147,7 @@
</component>
<component id="2be6c" class="javax.swing.JLabel">
<constraints>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
Expand All @@ -158,7 +156,7 @@
</component>
<component id="7dbeb" class="javax.swing.JFormattedTextField" binding="adminPort">
<constraints>
<grid row="10" column="2" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="8" column="2" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
Expand All @@ -167,22 +165,6 @@
<verifyInputWhenFocusTarget value="true"/>
</properties>
</component>
<component id="4839e" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Custom Context"/>
</properties>
</component>
<component id="73290" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="customContextField">
<constraints>
<grid row="4" column="2" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class RunnerSetting {
private RawCommandLineEditor vmOptons;
private EnvironmentVariablesComponent envOptions;
private JFormattedTextField adminPort;
private TextFieldWithBrowseButton customContextField;

private Project project;

Expand Down Expand Up @@ -78,10 +77,6 @@ public EnvironmentVariablesComponent getEnvOptions() {
return envOptions;
}

public TextFieldWithBrowseButton getCustomContextField() {
return customContextField;
}

private void createUIComponents() {
FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();

Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2">
<idea-plugin>
<id>com.poratu.idea.plugins.tomcat</id>
<name>Smart Tomcat</name>
<version>3.5.0</version>
<version>3.6.1</version>
<vendor email="[email protected]">zengkid</vendor>

<description><![CDATA[
Expand All @@ -19,14 +19,14 @@
]]></change-notes>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="193"/>
<idea-version since-build="191"/>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<!-- uncomment to enable plugin in all products
<depends>com.intellij.modules.lang</depends>
-->
<depends>com.intellij.java</depends>
<depends>com.intellij.modules.java</depends>

<extensions defaultExtensionNs="com.intellij">
<applicationConfigurable instance="com.poratu.idea.plugins.tomcat.setting.TomcatSettingConfigurable"/>
Expand Down

0 comments on commit 2086358

Please sign in to comment.