mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
(no message)
This commit is contained in:
@@ -35,13 +35,6 @@
|
||||
<interface-class>com.intellij.j2ee.make.ModuleBuildDescriptor</interface-class>
|
||||
<implementation-class>org.jetbrains.idea.devkit.build.PluginModuleBuildDescriptor</implementation-class>
|
||||
<option name="type" value="PLUGIN_MODULE"/>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>org.jetbrains.idea.devkit.module.PluginModuleProperties</implementation-class>
|
||||
<option name="type" value="PLUGIN_MODULE"/>
|
||||
</component>
|
||||
<!-- <component>
|
||||
<implementation-class>org.jetbrains.idea.devkit.projectRoots.IdeaProjectJdkPatch</implementation-class>
|
||||
</component>-->
|
||||
</component>
|
||||
</module-components>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -9,16 +9,25 @@ import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.j2ee.make.ModuleBuildProperties;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ide.util.BrowseFilesListener;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -38,16 +47,18 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor {
|
||||
private JRadioButton myClasses = new JRadioButton("Classes"); //todo: best Labels
|
||||
private JRadioButton myJar = new JRadioButton("Jar");
|
||||
private JLabel myDesctination = new JLabel();
|
||||
|
||||
private JLabel myPluginXMLLabel = new JLabel("Choose path to META-INF" + File.separator + "plugin.xml:");
|
||||
private TextFieldWithBrowseButton myPluginXML = new TextFieldWithBrowseButton();
|
||||
private boolean myModified = false;
|
||||
|
||||
private PluginModuleBuildProperties myBuildProperties;
|
||||
private ModuleConfigurationState myState;
|
||||
|
||||
private HashSet<String> mySetDependencyOnPluginModule = new HashSet<String>();
|
||||
|
||||
public PluginModuleBuildConfEditor(PluginModuleBuildProperties buildProperties, ModuleConfigurationState state) {
|
||||
myBuildProperties = buildProperties;
|
||||
private Module myModule;
|
||||
public PluginModuleBuildConfEditor(ModuleConfigurationState state) {
|
||||
myModule = state.getRootModel().getModule();
|
||||
myBuildProperties = (PluginModuleBuildProperties)ModuleBuildProperties.getInstance(myModule);
|
||||
myState = state;
|
||||
}
|
||||
|
||||
@@ -67,15 +78,26 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor {
|
||||
deploymentMethodChanged();
|
||||
}
|
||||
});
|
||||
myWholePanel.add(new JLabel("Choose the plugin deployment method:"), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
|
||||
myWholePanel.add(myJar, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.NONE, new Insets(2, 10, 5, 5), 0, 0));
|
||||
myPluginXML.addActionListener(new BrowseFilesListener(myPluginXML.getTextField(), "Select META-INF Directory Location", "The META-INF"+ File.separator + "plugin.xml will be saved in selected directory", BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR));
|
||||
myPluginXML.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
myModified = !myPluginXML.getText().equals(myBuildProperties.getPluginXMLPath());
|
||||
}
|
||||
});
|
||||
JPanel pluginXmlPanel = new JPanel(new BorderLayout());
|
||||
pluginXmlPanel.add(myPluginXMLLabel, BorderLayout.NORTH);
|
||||
pluginXmlPanel.add(myPluginXML, BorderLayout.CENTER);
|
||||
myWholePanel.add(pluginXmlPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.HORIZONTAL, new Insets(10, 5, 15, 5), 0, 0));
|
||||
myWholePanel.add(new JLabel("Choose plugin deployment method:"), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.HORIZONTAL, new Insets(15, 5, 0, 5), 0, 0));
|
||||
myWholePanel.add(myClasses, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.NONE, new Insets(0, 10, 5, 5), 0, 0));
|
||||
|
||||
GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
|
||||
myWholePanel.add(myJar, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
|
||||
myWholePanel.add(myDesctination, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.SOUTHWEST,
|
||||
GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
|
||||
|
||||
return myWholePanel;
|
||||
}
|
||||
|
||||
@@ -97,12 +119,12 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor {
|
||||
}
|
||||
final String toDelete = !myJar.isSelected() ? myBuildProperties.getJarPath() != null ? myBuildProperties.getJarPath().replace('/', File.separatorChar) : null :
|
||||
myBuildProperties.getExplodedPath() != null ? myBuildProperties.getExplodedPath().replace('/', File.separatorChar) : null;
|
||||
if (myModified && toDelete != null && new File(toDelete).exists()) {
|
||||
if (Messages.showYesNoDialog(myBuildProperties.getModule().getProject(),
|
||||
if (toDelete != null && new File(toDelete).exists()) {
|
||||
if (Messages.showYesNoDialog(myModule.getProject(),
|
||||
(!myJar.isSelected() ? "Delete " : "Clear ") + toDelete + "?",
|
||||
"Clean up plugin directory", null) == DialogWrapper.OK_EXIT_CODE) {
|
||||
|
||||
CommandProcessor.getInstance().executeCommand(myBuildProperties.getModule().getProject(),
|
||||
CommandProcessor.getInstance().executeCommand(myModule.getProject(),
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
FileUtil.delete(new File(toDelete));
|
||||
@@ -113,12 +135,30 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor {
|
||||
}
|
||||
}
|
||||
myBuildProperties.setJarPlugin(myJar.isSelected());
|
||||
final File plugin = new File(myBuildProperties.getPluginXMLPath());
|
||||
if (plugin.exists() &&
|
||||
!plugin.getPath().equals(myPluginXML.getText()) &&
|
||||
Messages.showYesNoDialog(myModule.getProject(),
|
||||
"Delete " + plugin.getPath() + File.separator + "META-INF" + " ?",
|
||||
"Clean up META-INF directory", null) == DialogWrapper.OK_EXIT_CODE) {
|
||||
|
||||
CommandProcessor.getInstance().executeCommand(myModule.getProject(),
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
FileUtil.delete(new File(plugin, "META-INF"));
|
||||
}
|
||||
},
|
||||
"Remove old plugin.xml directory",
|
||||
null);
|
||||
}
|
||||
myBuildProperties.setPluginXMLPath(myPluginXML.getText());
|
||||
myModified = false;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
myJar.setSelected(myBuildProperties.isJarPlugin());
|
||||
myClasses.setSelected(!myBuildProperties.isJarPlugin());
|
||||
myPluginXML.setText(myBuildProperties.getPluginXMLPath());
|
||||
deploymentMethodChanged();
|
||||
myModified = false;
|
||||
}
|
||||
@@ -140,25 +180,6 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor {
|
||||
}
|
||||
|
||||
public void moduleStateChanged() {
|
||||
/*
|
||||
if (model.getModule().equals(myState.getRootModel().getModule())) {
|
||||
return;
|
||||
}
|
||||
final String moduleName = myState.getRootModel().getModule().getName();
|
||||
final String changedModuleName = model.getModule().getName();
|
||||
if (ArrayUtil.find(model.getDependencyModuleNames(),
|
||||
moduleName) >
|
||||
-1) {
|
||||
mySetDependencyOnPluginModule.add(changedModuleName);
|
||||
myModified = true;
|
||||
} else {
|
||||
mySetDependencyOnPluginModule.remove(changedModuleName);
|
||||
if (mySetDependencyOnPluginModule.isEmpty()){
|
||||
myModified = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
package org.jetbrains.idea.devkit.build;
|
||||
|
||||
import com.intellij.j2ee.make.ModuleBuildProperties;
|
||||
import com.intellij.j2ee.j2eeDom.J2EEDeploymentItem;
|
||||
import com.intellij.j2ee.j2eeDom.DeploymentDescriptorFactory;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleComponent;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
@@ -14,16 +16,31 @@ import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import org.jetbrains.idea.devkit.projectRoots.IdeaJdk;
|
||||
import org.jetbrains.idea.devkit.projectRoots.Sandbox;
|
||||
import org.jetbrains.idea.devkit.module.PluginDescriptorMetaData;
|
||||
import org.jdom.Element;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class PluginModuleBuildProperties extends ModuleBuildProperties implements ModuleComponent, JDOMExternalizable {
|
||||
private Module myModule;
|
||||
private J2EEDeploymentItem myPluginXML;
|
||||
public boolean myJarPlugin = false;
|
||||
|
||||
public String myPluginXMLPath;
|
||||
public PluginModuleBuildProperties(Module module) {
|
||||
myModule = module;
|
||||
myPluginXMLPath = new File(myModule.getModuleFilePath()).getParent();
|
||||
myPluginXML = DeploymentDescriptorFactory.getInstance().createDeploymentItem(myModule, new PluginDescriptorMetaData());
|
||||
myPluginXML.setUrl(createPluginXMLURL(myPluginXMLPath));
|
||||
myPluginXML.createIfNotExists();
|
||||
}
|
||||
|
||||
public static PluginModuleBuildProperties getInstance(Module module) {
|
||||
return (PluginModuleBuildProperties)module.getComponent(ModuleBuildProperties.class);
|
||||
}
|
||||
|
||||
public String getArchiveExtension() {
|
||||
@@ -88,4 +105,23 @@ public class PluginModuleBuildProperties extends ModuleBuildProperties implement
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
DefaultJDOMExternalizer.writeExternal(this, element);
|
||||
}
|
||||
|
||||
public J2EEDeploymentItem getPluginXML() {
|
||||
return myPluginXML;
|
||||
}
|
||||
|
||||
public String getPluginXMLPath() {
|
||||
return myPluginXMLPath;
|
||||
}
|
||||
|
||||
public void setPluginXMLPath(String pluginXMLPath) {
|
||||
myPluginXMLPath = pluginXMLPath;
|
||||
myPluginXML = DeploymentDescriptorFactory.getInstance().createDeploymentItem(myModule, new PluginDescriptorMetaData());
|
||||
myPluginXML.setUrl(createPluginXMLURL(myPluginXMLPath));
|
||||
myPluginXML.createIfNotExists();
|
||||
}
|
||||
|
||||
private String createPluginXMLURL(String path){
|
||||
return VirtualFileManager.constructUrl("file", StringUtil.replace(path + "/META-INF/plugin.xml", File.separator, "/"));
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class PluginModuleEditorsProvider implements ModuleComponent, ModuleConfi
|
||||
editorFactory.createDependenciesEditor(state),
|
||||
editorFactory.createOrderEntriesEditor(state),
|
||||
editorFactory.createJavadocEditor(state),
|
||||
new PluginModuleBuildConfEditor((PluginModuleBuildProperties)ModuleBuildProperties.getInstance(module), state)
|
||||
new PluginModuleBuildConfEditor(state)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user