Merge remote-tracking branch 'origin/master'

This commit is contained in:
anna
2013-07-05 16:00:25 +02:00
46 changed files with 2045 additions and 346 deletions
+2
View File
@@ -121,6 +121,8 @@
<module fileurl="file://$PROJECT_DIR$/platform/projectModel-api/projectModel-api.iml" filepath="$PROJECT_DIR$/platform/projectModel-api/projectModel-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/projectModel-impl/projectModel-impl.iml" filepath="$PROJECT_DIR$/platform/projectModel-impl/projectModel-impl.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/plugins/properties/properties.iml" filepath="$PROJECT_DIR$/plugins/properties/properties.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/platform/remote-servers/api/remote-servers-api.iml" filepath="$PROJECT_DIR$/platform/remote-servers/api/remote-servers-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/remote-servers/impl/remote-servers-impl.iml" filepath="$PROJECT_DIR$/platform/remote-servers/impl/remote-servers-impl.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/xml/relaxng/relaxng.iml" filepath="$PROJECT_DIR$/xml/relaxng/relaxng.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/resources/resources.iml" filepath="$PROJECT_DIR$/resources/resources.iml" />
<module fileurl="file://$PROJECT_DIR$/resources-en/resources-en.iml" filepath="$PROJECT_DIR$/resources-en/resources-en.iml" />
+2
View File
@@ -56,6 +56,7 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir
"testFramework-java",
"debugger-openapi",
"compiler-openapi",
"remote-servers-api",
"dom-openapi",
"execution-openapi",
"jsp-openapi",
@@ -64,6 +65,7 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir
//noinspection GroovyAssignabilityCheck
List<String> implementationModules = [platformImplementationModules,
"compiler-impl",
"remote-servers-impl",
"debugger-impl",
"dom-impl",
"execution-impl",
+1
View File
@@ -89,6 +89,7 @@
<orderEntry type="module" module-name="android" />
<orderEntry type="module" module-name="relaxng" />
<orderEntry type="module" module-name="gradle" />
<orderEntry type="module" module-name="remote-servers-impl" />
<orderEntry type="module" module-name="xml-tests" scope="TEST" />
<orderEntry type="module" module-name="dom-tests" />
<orderEntry type="module" module-name="devkit-jps-plugin" scope="TEST" />
@@ -15,9 +15,11 @@
*/
package com.intellij.psi.impl.source.codeStyle.javadoc;
import org.jetbrains.annotations.NonNls;
import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* Class comment
@@ -25,51 +27,45 @@ import java.util.ArrayList;
* @author Dmitry Skavish
*/
public class JDClassComment extends JDParamListOwnerComment {
public JDClassComment(CommentFormatter formatter) {
private List<String> myAuthorsList;
private String myVersion;
public JDClassComment(@NotNull CommentFormatter formatter) {
super(formatter);
}
private ArrayList authorsList;
private String version;
@Override
protected void generateSpecial(String prefix, @NonNls StringBuffer sb) {
protected void generateSpecial(@NotNull String prefix, @NotNull StringBuilder sb) {
super.generateSpecial(prefix, sb);
if (!isNull(authorsList)) {
for (Object aAuthorsList : authorsList) {
String s = (String)aAuthorsList;
if (!isNull(myAuthorsList)) {
JDTag tag = JDTag.AUTHOR;
for (String author : myAuthorsList) {
sb.append(prefix);
sb.append("@author ");
sb.append(myFormatter.getParser().splitIntoCLines(s, prefix + " ", false));
sb.append(tag.getWithEndWhitespace());
sb.append(myFormatter.getParser().formatJDTagDescription(author, tag.getDescriptionPrefix(prefix)));
}
}
if (!isNull(version)) {
if (!isNull(myVersion)) {
sb.append(prefix);
sb.append("@version ");
sb.append(myFormatter.getParser().splitIntoCLines(version, prefix + " ", false));
JDTag tag = JDTag.VERSION;
sb.append(tag.getWithEndWhitespace());
sb.append(myFormatter.getParser().formatJDTagDescription(myVersion, tag.getDescriptionPrefix(prefix)));
}
}
public void addAuthor(String author) {
if (authorsList == null) {
authorsList = new ArrayList();
public void addAuthor(@NotNull String author) {
if (myAuthorsList == null) {
myAuthorsList = ContainerUtilRt.newArrayList();
}
authorsList.add(author);
}
public ArrayList getAuthorsList() {
return authorsList;
}
public void setAuthorsList(ArrayList authorsList) {
this.authorsList = authorsList;
myAuthorsList.add(author);
}
@Nullable
public String getVersion() {
return version;
return myVersion;
}
public void setVersion(String version) {
this.version = version;
public void setVersion(@NotNull String version) {
this.myVersion = version;
}
}
@@ -15,9 +15,11 @@
*/
package com.intellij.psi.impl.source.codeStyle.javadoc;
import org.jetbrains.annotations.NonNls;
import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* @author max
@@ -27,43 +29,42 @@ import java.util.ArrayList;
* @author Dmitry Skavish
*/
public class JDComment {
protected CommentFormatter myFormatter;
protected final CommentFormatter myFormatter;
String description;
protected ArrayList unknownList;
protected ArrayList seeAlsoList;
protected String since;
String deprecated;
private String myDescription;
private List<String> myUnknownList;
private List<String> mySeeAlsoList;
private String mySince;
private String myDeprecated;
//protected LinkedHashMap xdocTagMap = new LinkedHashMap();
public JDComment(CommentFormatter formatter) {
public JDComment(@NotNull CommentFormatter formatter) {
myFormatter = formatter;
}
protected static boolean isNull(String s) {
protected static boolean isNull(@Nullable String s) {
return s == null || s.trim().length() == 0;
}
protected static boolean isNull(ArrayList l) {
protected static boolean isNull(@Nullable List<?> l) {
return l == null || l.size() == 0;
}
public String generate(String indent) {
@Nullable
public String generate(@NotNull String indent) {
final String prefix;
if (myFormatter.getSettings().JD_LEADING_ASTERISKS_ARE_ENABLED) {
prefix = indent + " * ";
} else {
prefix = indent;
}
@NonNls StringBuffer sb = new StringBuffer();
// sb.append("/**\n");
StringBuilder sb = new StringBuilder();
int start = sb.length();
if (!isNull(description)) {
sb.append(myFormatter.getParser().splitIntoCLines(description, prefix));
if (!isNull(myDescription)) {
sb.append(prefix);
sb.append(myFormatter.getParser().formatJDTagDescription(myDescription, prefix));
if (myFormatter.getSettings().JD_ADD_BLANK_AFTER_DESCRIPTION) {
sb.append(prefix);
@@ -73,48 +74,40 @@ public class JDComment {
generateSpecial(prefix, sb);
if (!isNull(unknownList) && myFormatter.getSettings().JD_KEEP_INVALID_TAGS) {
for (Object aUnknownList : unknownList) {
String s = (String)aUnknownList;
sb.append(myFormatter.getParser().splitIntoCLines(s, prefix));
}
}
/*
if( xdocTagMap.size() > 0 ) {
Iterator it = xdocTagMap.values().iterator();
while( it.hasNext() ) {
ArrayList list = (ArrayList) it.next();
for( int i = 0; i<list.size(); i++ ) {
XDTag tag = (XDTag) list.get(i);
tag.append(sb, prefix);
if( myFormatter.getSettings().add_blank_after_xdoclet_tag ) {
sb.append(prefix);
sb.append('\n');
}
}
}
}*/
if (!isNull(seeAlsoList)) {
for (Object aSeeAlsoList : seeAlsoList) {
String s = (String)aSeeAlsoList;
if (!isNull(myUnknownList) && myFormatter.getSettings().JD_KEEP_INVALID_TAGS) {
for (String aUnknownList : myUnknownList) {
sb.append(prefix);
sb.append("@see ");
sb.append(myFormatter.getParser().splitIntoCLines(s, prefix + " ", false));
sb.append(myFormatter.getParser().formatJDTagDescription(aUnknownList, prefix));
}
}
if (!isNull(since)) {
sb.append(prefix);
sb.append("@since ");
sb.append(myFormatter.getParser().splitIntoCLines(since, prefix + " ", false));
if (!isNull(mySeeAlsoList)) {
JDTag tag = JDTag.SEE;
for (String aSeeAlsoList : mySeeAlsoList) {
sb.append(prefix);
sb.append(tag.getWithEndWhitespace());
StringBuilder tagDescription = myFormatter.getParser()
.formatJDTagDescription(aSeeAlsoList, prefix, true, tag.getDescriptionPrefix(prefix).length());
sb.append(tagDescription);
}
}
if (deprecated != null) {
if (!isNull(mySince)) {
JDTag tag = JDTag.SINCE;
sb.append(prefix);
sb.append("@deprecated ");
sb.append(myFormatter.getParser().splitIntoCLines(deprecated, prefix + " ", false));
sb.append(tag.getWithEndWhitespace());
StringBuilder tagDescription = myFormatter.getParser()
.formatJDTagDescription(mySince, prefix, true, tag.getDescriptionPrefix(prefix).length());
sb.append(tagDescription);
}
if (myDeprecated != null) {
JDTag tag = JDTag.DEPRECATED;
sb.append(prefix);
sb.append(tag.getWithEndWhitespace());
StringBuilder tagDescription = myFormatter.getParser()
.formatJDTagDescription(myDeprecated, prefix, true, tag.getDescriptionPrefix(prefix).length());
sb.append(tagDescription);
}
if (sb.length() == start) return null;
@@ -139,77 +132,37 @@ public class JDComment {
return sb.toString();
}
protected void generateSpecial(String prefix, StringBuffer sb) {
protected void generateSpecial(@NotNull String prefix, @NotNull StringBuilder sb) {
}
public void addSeeAlso(String seeAlso) {
if (seeAlsoList == null) {
seeAlsoList = new ArrayList();
public void addSeeAlso(@NotNull String seeAlso) {
if (mySeeAlsoList == null) {
mySeeAlsoList = ContainerUtilRt.newArrayList();
}
seeAlsoList.add(seeAlso);
mySeeAlsoList.add(seeAlso);
}
public void addUnknownTag(String unknownTag) {
if (unknownList == null) {
unknownList = new ArrayList();
public void addUnknownTag(@NotNull String unknownTag) {
if (myUnknownList == null) {
myUnknownList = ContainerUtilRt.newArrayList();
}
unknownList.add(unknownTag);
}
/*
public void addXDocTag( XDTag tag ) {
getXdocTagList(tag.getNamespaceDesc()).add(tag);
}
public ArrayList getXdocTagList( String nsName ) {
ArrayList list = (ArrayList) xdocTagMap.get(nsName);
if( list == null ) {
list = new ArrayList();
xdocTagMap.put(nsName, list);
}
return list;
}
public ArrayList getXdocTagList( XDNamespaceDesc desc ) {
return getXdocTagList(desc.getName());
}
*/
public ArrayList getSeeAlsoList() {
return seeAlsoList;
myUnknownList.add(unknownTag);
}
public void setUnknownList(ArrayList unknownList) {
this.unknownList = unknownList;
public void setSince(@Nullable String since) {
this.mySince = since;
}
public void setSeeAlsoList(ArrayList seeAlsoList) {
this.seeAlsoList = seeAlsoList;
}
public ArrayList getUnknownList() {
return unknownList;
}
public String getSince() {
return since;
}
public void setSince(String since) {
this.since = since;
}
public String getDeprecated() {
return deprecated;
}
public void setDeprecated(String deprecated) {
this.deprecated = deprecated;
public void setDeprecated(@Nullable String deprecated) {
this.myDeprecated = deprecated;
}
@Nullable
public String getDescription() {
return description;
return myDescription;
}
public void setDescription(String description) {
this.description = description;
public void setDescription(@Nullable String description) {
this.myDescription = description;
}
}
@@ -15,9 +15,11 @@
*/
package com.intellij.psi.impl.source.codeStyle.javadoc;
import org.jetbrains.annotations.NonNls;
import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* Method comment
@@ -25,26 +27,23 @@ import java.util.ArrayList;
* @author Dmitry Skavish
*/
public class JDMethodComment extends JDParamListOwnerComment {
private String myReturnTag;
private List<NameDesc> myThrowsList;
private static final @NonNls String THROWS_TAG = "@throws ";
private static final @NonNls String EXCEPTION_TAG = "@exception ";
private String returnTag;
private ArrayList<NameDesc> throwsList;
public JDMethodComment(CommentFormatter formatter) {
public JDMethodComment(@NotNull CommentFormatter formatter) {
super(formatter);
}
@Override
protected void generateSpecial(String prefix, @NonNls StringBuffer sb) {
protected void generateSpecial(@NotNull String prefix, @NotNull StringBuilder sb) {
super.generateSpecial(prefix, sb);
if (returnTag != null) {
if (returnTag.trim().length() != 0 || myFormatter.getSettings().JD_KEEP_EMPTY_RETURN) {
if (myReturnTag != null) {
if (myFormatter.getSettings().JD_KEEP_EMPTY_RETURN || myReturnTag.trim().length() != 0) {
JDTag tag = JDTag.RETURN;
sb.append(prefix);
sb.append("@return ");
sb.append(myFormatter.getParser().splitIntoCLines(returnTag, prefix + " ", false));
sb.append(tag.getWithEndWhitespace());
sb.append(myFormatter.getParser().formatJDTagDescription(myReturnTag, prefix, true, tag.getDescriptionPrefix(prefix).length()));
if (myFormatter.getSettings().JD_ADD_BLANK_AFTER_RETURN) {
sb.append(prefix);
sb.append('\n');
@@ -52,9 +51,9 @@ public class JDMethodComment extends JDParamListOwnerComment {
}
}
if (throwsList != null) {
String tag = myFormatter.getSettings().JD_USE_THROWS_NOT_EXCEPTION ? THROWS_TAG : EXCEPTION_TAG;
generateList(prefix, sb, throwsList, tag,
if (myThrowsList != null) {
JDTag tag = myFormatter.getSettings().JD_USE_THROWS_NOT_EXCEPTION ? JDTag.THROWS : JDTag.EXCEPTION;
generateList(prefix, sb, myThrowsList, tag.getWithEndWhitespace(),
myFormatter.getSettings().JD_ALIGN_EXCEPTION_COMMENTS,
myFormatter.getSettings().JD_KEEP_EMPTY_EXCEPTION,
myFormatter.getSettings().JD_PARAM_DESCRIPTION_ON_NEW_LINE
@@ -62,19 +61,14 @@ public class JDMethodComment extends JDParamListOwnerComment {
}
}
public void setReturnTag(String returnTag) {
this.returnTag = returnTag;
public void setReturnTag(@NotNull String returnTag) {
this.myReturnTag = returnTag;
}
public ArrayList<NameDesc> getThrowsList() {
return throwsList;
}
public void addThrow(String className, String description) {
if (throwsList == null) {
throwsList = new ArrayList<NameDesc>();
public void addThrow(@NotNull String className, @Nullable String description) {
if (myThrowsList == null) {
myThrowsList = ContainerUtilRt.newArrayList();
}
throwsList.add(new NameDesc(className, description));
myThrowsList.add(new NameDesc(className, description));
}
}
@@ -25,23 +25,24 @@ import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import org.jetbrains.annotations.NonNls;
import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class JDParamListOwnerComment extends JDComment{
protected ArrayList<NameDesc> parmsList;
private static final @NonNls String PARAM_TAG = "@param ";
public class JDParamListOwnerComment extends JDComment {
protected List<NameDesc> myParamsList;
public JDParamListOwnerComment(CommentFormatter formatter) {
public JDParamListOwnerComment(@NotNull CommentFormatter formatter) {
super(formatter);
}
@Override
protected void generateSpecial(String prefix, StringBuffer sb) {
if (parmsList != null) {
protected void generateSpecial(@NotNull String prefix, @NotNull StringBuilder sb) {
if (myParamsList != null) {
int before = sb.length();
generateList(prefix, sb, parmsList, PARAM_TAG,
generateList(prefix, sb, myParamsList, JDTag.PARAM.getWithEndWhitespace(),
myFormatter.getSettings().JD_ALIGN_PARAM_COMMENTS,
myFormatter.getSettings().JD_KEEP_EMPTY_PARAMETER,
myFormatter.getSettings().JD_PARAM_DESCRIPTION_ON_NEW_LINE
@@ -55,22 +56,25 @@ public class JDParamListOwnerComment extends JDComment{
}
}
public NameDesc getParameter(String name) {
return getNameDesc(name, parmsList);
@Nullable
public NameDesc getParameter(@Nullable String name) {
return getNameDesc(name, myParamsList);
}
public void addParameter(String name, String description) {
if (parmsList == null) {
parmsList = new ArrayList<NameDesc>();
public void addParameter(@NotNull String name, @Nullable String description) {
if (myParamsList == null) {
myParamsList = ContainerUtilRt.newArrayList();
}
parmsList.add(new NameDesc(name, description));
myParamsList.add(new NameDesc(name, description));
}
static NameDesc getNameDesc(String name, ArrayList<NameDesc> list) {
@Nullable
private static NameDesc getNameDesc(@Nullable String name, @Nullable List<NameDesc> list) {
if (list == null) return null;
for (Object aList : list) {
NameDesc parameter = (NameDesc)aList;
if (parameter.name.equals(name)) return parameter;
for (NameDesc aList : list) {
if (aList.name.equals(name)) {
return aList;
}
}
return null;
}
@@ -79,10 +83,10 @@ public class JDParamListOwnerComment extends JDComment{
* Generates parameters or exceptions
*
*/
protected void generateList(String prefix,
StringBuffer sb,
ArrayList<NameDesc> list,
String tag,
protected void generateList(@NotNull String prefix,
@NotNull StringBuilder sb,
@NotNull List<NameDesc> list,
@NotNull String tag,
boolean align_comments,
boolean generate_empty_tags,
boolean wrapDescription)
@@ -104,7 +108,7 @@ public class JDParamListOwnerComment extends JDComment{
}
}
StringBuffer fill = new StringBuffer(prefix.length() + tag.length() + max + 1);
StringBuilder fill = new StringBuilder(prefix.length() + tag.length() + max + 1);
fill.append(prefix);
StringUtil.repeatSymbol(fill, ' ', max + 1 + tag.length());
@@ -113,7 +117,8 @@ public class JDParamListOwnerComment extends JDComment{
if (isNull(nd.desc) && !generate_empty_tags) continue;
if (wrapDescription && !isNull(nd.desc)) {
sb.append(prefix).append(tag).append(nd.name).append("\n");
sb.append(myFormatter.getParser().splitIntoCLines(nd.desc, wrapParametersPrefix));
sb.append(wrapParametersPrefix);
sb.append(myFormatter.getParser().formatJDTagDescription(nd.desc, wrapParametersPrefix));
}
else if (align_comments) {
sb.append(prefix);
@@ -121,11 +126,13 @@ public class JDParamListOwnerComment extends JDComment{
sb.append(nd.name);
int spacesNumber = max + 1 - nd.name.length();
StringUtil.repeatSymbol(sb, ' ', Math.max(0, spacesNumber));
sb.append(myFormatter.getParser().splitIntoCLines(nd.desc, fill, false));
sb.append(myFormatter.getParser().formatJDTagDescription(nd.desc, fill));
}
else {
sb.append(myFormatter.getParser().splitIntoCLines(tag + nd.name + " " + nd.desc, prefix, true));
sb.append(prefix);
String description = (nd.desc == null) ? "" : nd.desc;
sb.append(myFormatter.getParser().formatJDTagDescription(tag + nd.name + " " + description, prefix));
}
}
}
}
}
@@ -16,8 +16,9 @@
package com.intellij.psi.impl.source.codeStyle.javadoc;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -26,27 +27,31 @@ import java.util.StringTokenizer;
/**
* Javadoc parser
*
*
* @author Dmitry Skavish
*/
public class JDParser {
private static final String PRE_TAG_START = "<pre>";
private static final String PRE_TAG_END = "</pre>";
private static final String P_END_TAG = "</p>";
private static final String P_START_TAG = "<p>";
private static final String SELF_CLOSED_P_TAG = "<p/>";
private final CodeStyleSettings mySettings;
public JDParser(CodeStyleSettings settings) {
public JDParser(@NotNull CodeStyleSettings settings) {
mySettings = settings;
}
private static final char lineSeparator = '\n';
public JDComment parse(String text, JDComment c) {
@NotNull
public JDComment parse(@Nullable String text, @NotNull JDComment c) {
if (text == null) return c;
ArrayList<Boolean> markers = new ArrayList<Boolean>();
ArrayList<String> l = toArray(text, "\n", markers);
List<Boolean> markers = new ArrayList<Boolean>();
List<String> l = toArray(text, "\n", markers);
if (l == null) return c;
int size = l.size();
if (size == 0) return c;
@@ -73,7 +78,7 @@ public class JDParser {
l.set(i, line);
}
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
String tag = null;
for (int i = 0; i <= size; i++) {
String line = i == size ? null : l.get(i);
@@ -125,43 +130,23 @@ public class JDParser {
return c;
}
/**
* Breaks the specified string by lineseparator into array of strings
*
* @param s the specified string
* @return array of strings (lines)
*/
public ArrayList<String> toArrayByNL(String s) {
return toArray(s, "\n", null);
}
/**
* Breaks the specified string by comma into array of strings
*
* @param s the specified string
* @return list of strings
*/
public ArrayList<String> toArrayByComma(String s) {
return toArray(s, ",", null);
}
/**
* Breaks the specified string by the specified separators into array of strings
*
*
* @param s the specified string
* @param separators the specified separators
* @param markers if this parameter is not null then it will be filled with Boolean values:
* true if the correspoding line in returned list is inside &lt;pre&gt; tag,
* true if the corresponding line in returned list is inside &lt;pre&gt; tag,
* false if it is outside
* @return array of strings (lines)
*/
@SuppressWarnings({"HardCodedStringLiteral"})
private ArrayList<String> toArray(String s, String separators, ArrayList<Boolean> markers) {
@Nullable
private List<String> toArray(@Nullable String s, @NotNull String separators, @Nullable List<Boolean> markers) {
if (s == null) return null;
s = s.trim();
if (s.length() == 0) return null;
boolean p2nl = markers != null && mySettings.JD_P_AT_EMPTY_LINES;
ArrayList<String> list = new ArrayList<String>();
List<String> list = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(s, separators, true);
boolean first = true;
int preCount = 0;
@@ -170,7 +155,7 @@ public class JDParser {
String token = st.nextToken();
curPos += token.length();
if (separators.indexOf(token) >= 0) {
if (separators.contains(token)) {
if (!first) {
list.add("");
if (markers != null) markers.add(Boolean.valueOf(preCount > 0));
@@ -180,7 +165,7 @@ public class JDParser {
else {
first = true;
if (p2nl) {
if (isParaTag(token) && s.indexOf("</p>", curPos) < 0) {
if (isParaTag(token) && s.indexOf(P_END_TAG, curPos) < 0) {
list.add("");
markers.add(Boolean.valueOf(preCount > 0));
continue;
@@ -191,9 +176,9 @@ public class JDParser {
list.add(token);
if (markers != null) {
if (token.indexOf("<pre>") >= 0) preCount++;
if (token.contains(PRE_TAG_START)) preCount++;
markers.add(Boolean.valueOf(preCount > 0));
if (token.indexOf("</pre>") >= 0) preCount--;
if (token.contains(PRE_TAG_END)) preCount--;
}
}
@@ -201,56 +186,30 @@ public class JDParser {
return list;
}
@SuppressWarnings({"HardCodedStringLiteral"})
private boolean isParaTag(final String token) {
private static boolean isParaTag(@NotNull final String token) {
String withoutWS = removeWhiteSpacesFrom(token).toLowerCase();
return withoutWS.equals("<p/>") || withoutWS.equals("<p>");
return withoutWS.equals(SELF_CLOSED_P_TAG) || withoutWS.equals(P_START_TAG);
}
private String removeWhiteSpacesFrom(final String token) {
final StringBuffer result = new StringBuffer();
@NotNull
private static String removeWhiteSpacesFrom(@NotNull final String token) {
final StringBuilder result = new StringBuilder();
for (char c : token.toCharArray()) {
if (c != ' ') result.append(c);
}
return result.toString();
}
public static String toLines(ArrayList l) {
if (l == null || l.size() == 0) return null;
StringBuffer sb = new StringBuffer();
for (Object aL : l) {
String s = (String)aL;
if (sb.length() > 0) {
sb.append(lineSeparator);
}
sb.append(s);
}
return sb.toString();
}
public static String toCommaSeparated(ArrayList<String> l) {
if (l == null || l.size() == 0) return null;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < l.size(); i++) {
String s = l.get(i);
if (i != 0) {
sb.append(", ");
}
sb.append(s);
}
return sb.toString();
}
/**
* Processes all lines (char sequences separated by line feed symbol) from the given string slitting them if necessary
* ensuring that every returned line contains less symbols than the given width.
*
* Processes all lines (char sequences separated by line feed symbol) from the given string slitting them if necessary
* ensuring that every returned line contains less symbols than the given width.
*
* @param s the specified string
* @param width width of the wrapped text
* @return array of strings (lines)
*/
@Nullable
private List<String> toArrayWrapping(String s, int width) {
private List<String> toArrayWrapping(@Nullable String s, int width) {
List<String> list = new ArrayList<String>();
List<Pair<String, Boolean>> pairs = splitToParagraphs(s);
if (pairs == null) {
@@ -305,7 +264,7 @@ public class JDParser {
/**
* Processes given string and produces on its basis set of pairs like <code>'(string; flag)'</code> where <code>'string'</code>
* is interested line and <code>'flag'</code> indicates if it is wrapped to {@code <pre>} tag.
*
*
* @param s string to process
* @return processing result
*/
@@ -313,15 +272,16 @@ public class JDParser {
private List<Pair<String, Boolean>> splitToParagraphs(@Nullable String s) {
if (s == null) return null;
s = s.trim();
if (s == null /* just to make inspection happy*/ || s.isEmpty()) return null;
if (s.isEmpty()) return null;
List<Pair<String, Boolean>> result = new ArrayList<Pair<String, Boolean>>();
StringBuilder sb = new StringBuilder();
ArrayList<Boolean> markers = new ArrayList<Boolean>();
ArrayList<String> list = toArray(s, "\n", markers);
List<Boolean> markers = new ArrayList<Boolean>();
List<String> list = toArray(s, "\n", markers);
Boolean[] marks = markers.toArray(new Boolean[markers.size()]);
markers.clear();
assert list != null;
for (int i = 0; i < list.size(); i++) {
String s1 = list.get(i);
if (marks[i].booleanValue()) {
@@ -353,27 +313,17 @@ public class JDParser {
}
return result;
}
static abstract class TagParser {
abstract static class TagParser {
abstract boolean parse(String tag, String line, JDComment c);
}
private static final @NonNls String SEE_TAG = "see";
private static final @NonNls String SINCE_TAG = "since";
private static final @NonNls String VERSION_TAG = "version";
private static final @NonNls String DEPRECATED_TAG = "deprecated";
private static final @NonNls String RETURN_TAG = "return";
private static final @NonNls String PARAM_TAG = "param";
private static final @NonNls String THROWS_TAG = "throws";
private static final @NonNls String EXCEPTION_TAG = "exception";
private static final @NonNls String AUTHOR_TAG = "author";
private static final TagParser[] tagParsers = {
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
boolean isMyTag = SEE_TAG.equals(tag);
boolean isMyTag = JDTag.SEE.tagEqual(tag);
if (isMyTag) {
c.addSeeAlso(line);
}
@@ -383,7 +333,7 @@ public class JDParser {
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
boolean isMyTag = SINCE_TAG.equals(tag);
boolean isMyTag = JDTag.SINCE.tagEqual(tag);
if (isMyTag) {
c.setSince(line);
}
@@ -393,7 +343,7 @@ public class JDParser {
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
boolean isMyTag = c instanceof JDClassComment && VERSION_TAG.equals(tag);
boolean isMyTag = c instanceof JDClassComment && JDTag.VERSION.tagEqual(tag);
if (isMyTag) {
((JDClassComment)c).setVersion(line);
}
@@ -403,7 +353,7 @@ public class JDParser {
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
boolean isMyTag = DEPRECATED_TAG.equals(tag);
boolean isMyTag = JDTag.DEPRECATED.tagEqual(tag);
if (isMyTag) {
c.setDeprecated(line);
}
@@ -413,7 +363,7 @@ public class JDParser {
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
boolean isMyTag = c instanceof JDMethodComment && RETURN_TAG.equals(tag);
boolean isMyTag = c instanceof JDMethodComment && JDTag.RETURN.tagEqual(tag);
if (isMyTag) {
JDMethodComment mc = (JDMethodComment)c;
mc.setReturnTag(line);
@@ -424,7 +374,7 @@ public class JDParser {
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
boolean isMyTag = c instanceof JDParamListOwnerComment && PARAM_TAG.equals(tag);
boolean isMyTag = c instanceof JDParamListOwnerComment && JDTag.PARAM.tagEqual(tag);
if (isMyTag) {
JDParamListOwnerComment mc = (JDParamListOwnerComment)c;
int idx;
@@ -447,7 +397,7 @@ public class JDParser {
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
boolean isMyTag = c instanceof JDMethodComment && (THROWS_TAG.equals(tag) || EXCEPTION_TAG.equals(tag));
boolean isMyTag = c instanceof JDMethodComment && (JDTag.THROWS.tagEqual(tag) || JDTag.EXCEPTION.tagEqual(tag));
if (isMyTag) {
JDMethodComment mc = (JDMethodComment)c;
int idx;
@@ -470,7 +420,7 @@ public class JDParser {
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
boolean isMyTag = c instanceof JDClassComment && AUTHOR_TAG.equals(tag);
boolean isMyTag = c instanceof JDClassComment && JDTag.AUTHOR.tagEqual(tag);
if (isMyTag) {
JDClassComment cl = (JDClassComment)c;
cl.addAuthor(line.trim());
@@ -478,33 +428,72 @@ public class JDParser {
return isMyTag;
}
},
/* new TagParser() {
boolean parse( String tag, String line, JDComment c ) {
XDTag xdtag = XDTag.parse(tag, line);
if( xdtag != null ) {
c.addXDocTag(xdtag);
}
return xdtag != null;
}
},*/
};
protected StringBuffer splitIntoCLines(String s, String prefix) {
return splitIntoCLines(s, prefix, true);
/**
* @see JDParser#formatJDTagDescription(String, CharSequence, boolean, int)
*/
@NotNull
protected StringBuilder formatJDTagDescription(@Nullable String s, @NotNull CharSequence prefix) {
return formatJDTagDescription(s, prefix, false, 0);
}
protected StringBuffer splitIntoCLines(String s, String prefix, boolean add_prefix_to_first_line) {
return splitIntoCLines(s, new StringBuffer(prefix), add_prefix_to_first_line);
private static boolean lineHasUnclosedPreTag(@NotNull String line) {
return StringUtil.getOccurrenceCount(line, PRE_TAG_START) > StringUtil.getOccurrenceCount(line, PRE_TAG_END);
}
protected StringBuffer splitIntoCLines(String s, StringBuffer prefix, boolean add_prefix_to_first_line) {
@NonNls StringBuffer sb = new StringBuffer();
if (add_prefix_to_first_line) {
sb.append(prefix);
/**
* Returns formatted JavaDoc tag description, according to selected configuration
* @param str JavaDoc tag description
* @param prefix JavaDoc prefix(like " * ") which will be appended to every new line
* @param firstLineShorter flag if first line should be shorter (has another prefix length than other lines)
* @param firstLinePrefixLength first line prefix length
* @return formatted JavaDoc tag description
*/
@NotNull
protected StringBuilder formatJDTagDescription(@Nullable String str,
@NotNull CharSequence prefix,
boolean firstLineShorter,
int firstLinePrefixLength)
{
StringBuilder sb = new StringBuilder();
List<String> list;
//If wrap comments selected, comments should be wrapped by the right margin
if (mySettings.WRAP_COMMENTS) {
list = toArrayWrapping(str, mySettings.RIGHT_MARGIN - prefix.length());
if (firstLineShorter
&& list != null && !list.isEmpty()
&& list.get(0).length() > mySettings.RIGHT_MARGIN - firstLinePrefixLength)
{
list = new ArrayList<String>();
//want the first line to be shorter, according to it's prefix
String firstLine = toArrayWrapping(str, mySettings.RIGHT_MARGIN - firstLinePrefixLength).get(0);
//so now first line is exactly same width we need
list.add(firstLine);
str = str.substring(firstLine.length());
//actually there is one more problem - when first line has unclosed <pre> tag, substring should be processed if it's inside <pre>
boolean unclosedPreTag = lineHasUnclosedPreTag(firstLine);
if (unclosedPreTag) {
str = PRE_TAG_START + str.replaceAll("^\\s+", "");
}
//getting all another lines according to their prefix
List<String> subList = toArrayWrapping(str, mySettings.RIGHT_MARGIN - prefix.length());
//removing pre tag
if (unclosedPreTag) {
String firstLineTagRemoved = subList.get(0).substring(PRE_TAG_START.length());
subList.set(0, firstLineTagRemoved);
}
list.addAll(subList);
}
}
List<String> list = mySettings.WRAP_COMMENTS
? toArrayWrapping(s, mySettings.RIGHT_MARGIN - prefix.length())
: toArray(s, "\n", new ArrayList<Boolean>());
else {
list = toArray(str, "\n", new ArrayList<Boolean>());
}
if (list == null) {
sb.append('\n');
}
@@ -515,11 +504,11 @@ public class JDParser {
if (line.length() == 0 && !mySettings.JD_KEEP_EMPTY_LINES) continue;
if (i != 0) sb.append(prefix);
if (line.length() == 0 && mySettings.JD_P_AT_EMPTY_LINES && !insidePreTag) {
sb.append("<p/>");
sb.append(SELF_CLOSED_P_TAG);
}
else {
sb.append(line);
// We want to track if we're inside <pre>...</pre> in order to not generate <p/> there.
if (PRE_TAG_START.equals(line)) {
insidePreTag = true;
@@ -0,0 +1,58 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.psi.impl.source.codeStyle.javadoc;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* User: Lepenkin Y.
* Date: 7/1/13
* Time: 4:15 PM
*/
public enum JDTag {
SEE("see"),
AUTHOR("author"),
VERSION("version"),
THROWS("throws"),
EXCEPTION("exception"),
RETURN("return"),
PARAM("param"),
SINCE("since"),
DEPRECATED("deprecated");
@NotNull private final String myTag;
JDTag(@NotNull String tag) {
this.myTag = tag;
}
@NotNull
public String getDescriptionPrefix(@NotNull String prefix) {
return prefix + StringUtil.repeatSymbol(' ', getWithEndWhitespace().length());
}
@NotNull
public String getWithEndWhitespace() {
return "@" + myTag + " ";
}
public boolean tagEqual(@Nullable String tag) {
return myTag.equals(tag);
}
}
@@ -15,29 +15,25 @@
*/
package com.intellij.psi.impl.source.codeStyle.javadoc;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
*
* @author Dmitry Skavish
*/
public class NameDesc {
@NotNull public final String name;
@Nullable public final String desc;
public String name;
public String desc;
private String type;
public NameDesc(String name, String desc) {
public NameDesc(@NotNull String name, @Nullable String desc) {
this.name = name;
this.desc = desc;
}
public NameDesc(String name, String desc, String type) {
this.name = name;
this.desc = desc;
this.type = type;
}
@NotNull
@Override
public String toString() {
if (type == null) return name;
return name + ": " + type;
return name;
}
}
@@ -216,4 +216,140 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest {
doTextTest(before, after);
}
public void testReturnTagAlignment() throws Exception {
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
getSettings().getRootSettings().RIGHT_MARGIN = 80;
getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
getSettings().getRootSettings().WRAP_COMMENTS = true;
getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
String before = " /**\n" +
" * @return this is a return value documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters, which should be greater than any sane right margin.\n" +
" */\n" +
" public int method(int parameter) {\n" +
" return 0;\n" +
" }\n";
String after = "/**\n" +
" * @return this is a return value documentation with a very long description\n" +
" * that is longer than the right margin. It is more than 200 characters\n" +
" * long, not including the comment indent and the asterisk characters, which\n" +
" * should be greater than any sane right margin.\n" +
" */\n" +
"public int method(int parameter) {\n" +
" return 0;\n" +
"}\n";
doClassTest(before, after);
}
public void testReturnTagAlignmentWithPreTagOnFirstLine() throws Exception {
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
getSettings().getRootSettings().RIGHT_MARGIN = 80;
getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
getSettings().getRootSettings().WRAP_COMMENTS = true;
getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
String before = " /**\n" +
" * @return <pre>this is a return value documentation with a very long description\n" +
" * that is longer than the right margin.</pre>\n" +
" */\n" +
" public int method(int parameter) {\n" +
" return 0;\n" +
" }";
String after = "/**\n" +
" * @return <pre>this is a return value documentation with a very long\n" +
" * description\n" +
" * that is longer than the right margin.</pre>\n" +
" */\n" +
"public int method(int parameter) {\n" +
" return 0;\n" +
"}";
doClassTest(before, after);
}
public void testSeeTagAlignment() throws Exception {
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
getSettings().getRootSettings().RIGHT_MARGIN = 80;
getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
getSettings().getRootSettings().WRAP_COMMENTS = true;
getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
String before = " /**\n" +
" * @see this is an additional documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters which should be greater than any sane right margin\n" +
" */\n" +
" public int method(int parameter) {\n" +
" return 0;\n" +
" }";
String after = "/**\n" +
" * @see this is an additional documentation with a very long description\n" +
" * that is longer than the right margin. It is more than 200 characters\n" +
" * long, not including the comment indent and the asterisk characters which\n" +
" * should be greater than any sane right margin\n" +
" */\n" +
"public int method(int parameter) {\n" +
" return 0;\n" +
"}";
doClassTest(before, after);
}
public void testDummySinceTagAlignment() throws Exception {
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
getSettings().getRootSettings().RIGHT_MARGIN = 80;
getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
getSettings().getRootSettings().WRAP_COMMENTS = true;
getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
String before = " /**\n" +
" * @since this is an additional documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters which should be greater than any sane right margin\n" +
" */\n" +
" public int method(int parameter) {\n" +
" return 0;\n" +
" }";
String after = "/**\n" +
" * @since this is an additional documentation with a very long description\n" +
" * that is longer than the right margin. It is more than 200 characters\n" +
" * long, not including the comment indent and the asterisk characters which\n" +
" * should be greater than any sane right margin\n" +
" */\n" +
"public int method(int parameter) {\n" +
" return 0;\n" +
"}";
doClassTest(before, after);
}
public void testDummyDeprecatedTagAlignment() throws Exception {
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
getSettings().getRootSettings().RIGHT_MARGIN = 80;
getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
getSettings().getRootSettings().WRAP_COMMENTS = true;
getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
String before = " /**\n" +
" * @deprecated this is an additional documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters which should be greater than any sane right margin\n" +
" */\n" +
" public int method(int parameter) {\n" +
" return 0;\n" +
" }";
String after = "/**\n" +
" * @deprecated this is an additional documentation with a very long\n" +
" * description that is longer than the right margin. It is more than 200\n" +
" * characters long, not including the comment indent and the asterisk\n" +
" * characters which should be greater than any sane right margin\n" +
" */\n" +
"public int method(int parameter) {\n" +
" return 0;\n" +
"}";
doClassTest(before, after);
}
}
@@ -16,12 +16,10 @@
package com.intellij.execution.configurations;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author yole
@@ -44,10 +42,7 @@ public abstract class ConfigurationTypeBase implements ConfigurationType {
}
protected void addFactory(ConfigurationFactory factory) {
List<ConfigurationFactory> newFactories = new ArrayList<ConfigurationFactory>(myFactories.length + 1);
Collections.addAll(newFactories, myFactories);
newFactories.add(factory);
myFactories = newFactories.toArray(new ConfigurationFactory[newFactories.size()]);
myFactories = ArrayUtil.append(myFactories, factory);
}
@Override
@@ -88,6 +88,7 @@
</extensions>
<xi:include href="xdebugger.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="RemoteServers.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/ultimate.xml" xpointer="xpointer(/idea-plugin/*)">
<xi:fallback/>
</xi:include>
@@ -0,0 +1,19 @@
<idea-plugin>
<extensionPoints>
<extensionPoint name="remoteServer.type" interface="com.intellij.remoteServer.ServerType"/>
</extensionPoints>
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceInterface="com.intellij.remoteServer.configuration.RemoteServersManager"
serviceImplementation="com.intellij.remoteServer.configuration.impl.RemoteServersManagerImpl"/>
<applicationService serviceInterface="com.intellij.remoteServer.deployment.DeploymentSourceUtil"
serviceImplementation="com.intellij.remoteServer.deployment.impl.DeploymentSourceUtilImpl"/>
<applicationConfigurable instance="com.intellij.remoteServer.configuration.impl.RemoteServerListConfigurable"/>
<programRunner implementation="com.intellij.remoteServer.run.DeployToServerRunner"/>
</extensions>
<application-components>
<component>
<implementation-class>com.intellij.remoteServer.run.DeployToServerConfigurationTypesRegistrar</implementation-class>
</component>
</application-components>
</idea-plugin>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="core-api" />
<orderEntry type="module" module-name="platform-api" />
<orderEntry type="module" module-name="compiler-openapi" />
</component>
</module>
@@ -0,0 +1,41 @@
package com.intellij.remoteServer;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.options.UnnamedConfigurable;
import com.intellij.openapi.project.Project;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import com.intellij.remoteServer.deployment.Deployer;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author nik
*/
public abstract class ServerType<C extends ServerConfiguration> {
public static final ExtensionPointName<ServerType> EP_NAME = ExtensionPointName.create("com.intellij.remoteServer.type");
private final String myId;
protected ServerType(String id) {
myId = id;
}
public final String getId() {
return myId;
}
@NotNull
public abstract String getPresentableName();
@NotNull
public abstract Icon getIcon();
@NotNull
public abstract C createDefaultConfiguration();
@NotNull
public abstract UnnamedConfigurable createConfigurable(@NotNull C configuration);
@NotNull
public abstract Deployer<C> createDeployer(Project project);
}
@@ -0,0 +1,20 @@
package com.intellij.remoteServer.configuration;
import com.intellij.remoteServer.ServerType;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public interface RemoteServer<C extends ServerConfiguration> {
@NotNull
String getName();
@NotNull
ServerType<C> getType();
@NotNull
C getConfiguration();
void setName(String name);
}
@@ -0,0 +1,30 @@
package com.intellij.remoteServer.configuration;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.remoteServer.ServerType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author nik
*/
public abstract class RemoteServersManager {
public static RemoteServersManager getInstance() {
return ServiceManager.getService(RemoteServersManager.class);
}
public abstract List<RemoteServer<?>> getServers();
public abstract <C extends ServerConfiguration> List<RemoteServer<C>> getServers(@NotNull ServerType<C> type);
@Nullable
public abstract <C extends ServerConfiguration> RemoteServer<C> findByName(@NotNull String name, @NotNull ServerType<C> type);
public abstract <C extends ServerConfiguration> RemoteServer<C> createServer(@NotNull ServerType<C> type, @NotNull String name);
public abstract void addServer(RemoteServer<?> server);
public abstract void removeServer(RemoteServer<?> server);
}
@@ -0,0 +1,10 @@
package com.intellij.remoteServer.configuration;
import com.intellij.openapi.components.PersistentStateComponent;
/**
* @author nik
*/
public abstract class ServerConfiguration {
public abstract PersistentStateComponent<?> getSerializer();
}
@@ -0,0 +1,32 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.deployment;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ArtifactPointer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public interface ArtifactDeploymentSource extends DeploymentSource {
@NotNull
ArtifactPointer getArtifactPointer();
@Nullable
Artifact getArtifact();
}
@@ -0,0 +1,32 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.deployment;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author nik
*/
public abstract class Deployer<C extends ServerConfiguration> {
@NotNull
public abstract List<DeploymentSource> getAvailableDeploymentSources();
public abstract void startDeployment(@NotNull RemoteServer<C> server, @NotNull DeploymentSource source);
}
@@ -0,0 +1,41 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.deployment;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.io.File;
/**
* @author nik
*/
public interface DeploymentSource {
@Nullable
File getFile();
@Nullable
String getFilePath();
@NotNull
String getPresentableName();
@Nullable
Icon getIcon();
boolean isValid();
}
@@ -0,0 +1,38 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.deployment;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.packaging.artifacts.ArtifactPointer;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public abstract class DeploymentSourceUtil {
public static DeploymentSourceUtil getInstance() {
return ServiceManager.getService(DeploymentSourceUtil.class);
}
@NotNull
public abstract ArtifactDeploymentSource createArtifactDeploymentSource(@NotNull ArtifactPointer artifactPointer);
public abstract DeploymentSource loadDeploymentSource(@NotNull Element element, @NotNull Project project);
public abstract void saveDeploymentSource(@NotNull DeploymentSource source, @NotNull Element element, @NotNull Project project);
}
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="platform-api" />
<orderEntry type="module" module-name="remote-servers-api" />
<orderEntry type="module" module-name="core-impl" />
<orderEntry type="module" module-name="lang-api" />
<orderEntry type="module" module-name="compiler-openapi" />
<orderEntry type="module" module-name="lang-impl" />
</component>
</module>
@@ -0,0 +1,93 @@
package com.intellij.remoteServer.configuration.impl;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.UnnamedConfigurable;
import com.intellij.openapi.ui.NamedConfigurable;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
/**
* @author nik
*/
public class RemoteServerConfigurable extends NamedConfigurable<RemoteServer<?>> {
private final UnnamedConfigurable myConfigurable;
private final RemoteServer<?> myServer;
private String myServerName;
private boolean myNew;
public <C extends ServerConfiguration> RemoteServerConfigurable(RemoteServer<C> server, Runnable treeUpdater, boolean isNew) {
super(true, treeUpdater);
myServer = server;
myNew = isNew;
myServerName = myServer.getName();
C c = server.getConfiguration();
myConfigurable = server.getType().createConfigurable(c);
}
@Override
public RemoteServer<?> getEditableObject() {
return myServer;
}
@Override
public String getBannerSlogan() {
return myServer.getName();
}
@Override
public JComponent createOptionsPanel() {
JComponent component = myConfigurable.createComponent();
JPanel panel = new JPanel(new BorderLayout());
panel.add(component, BorderLayout.NORTH);
return panel;
}
@Nls
@Override
public String getDisplayName() {
return myServerName;
}
@Nullable
@Override
public String getHelpTopic() {
return null;
}
@Override
public void setDisplayName(String name) {
myServerName = name;
}
@Override
public boolean isModified() {
return myNew || myConfigurable.isModified() || !myServerName.equals(myServer.getName());
}
@Override
public void apply() throws ConfigurationException {
myConfigurable.apply();
myNew = false;
}
@Override
public void reset() {
myConfigurable.reset();
}
@Override
public void disposeUIResources() {
myConfigurable.disposeUIResources();
}
@Nullable
@Override
public Icon getIcon(boolean expanded) {
return myServer.getType().getIcon();
}
}
@@ -0,0 +1,44 @@
package com.intellij.remoteServer.configuration.impl;
import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public class RemoteServerImpl<C extends ServerConfiguration> implements RemoteServer<C> {
private String myName;
private ServerType<C> myType;
private C myConfiguration;
public RemoteServerImpl(String name, ServerType<C> type, C configuration) {
myName = name;
myType = type;
myConfiguration = configuration;
}
@NotNull
@Override
public String getName() {
return myName;
}
@NotNull
@Override
public ServerType<C> getType() {
return myType;
}
@NotNull
@Override
public C getConfiguration() {
return myConfiguration;
}
@Override
public void setName(String name) {
myName = name;
}
}
@@ -0,0 +1,171 @@
package com.intellij.remoteServer.configuration.impl;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonShortcuts;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.OptionalConfigurable;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.ui.MasterDetailsComponent;
import com.intellij.openapi.ui.NamedConfigurable;
import com.intellij.openapi.util.Condition;
import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.RemoteServersManager;
import com.intellij.util.IconUtil;
import com.intellij.util.text.UniqueNameGenerator;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author nik
*/
public class RemoteServerListConfigurable extends MasterDetailsComponent implements OptionalConfigurable {
private final RemoteServersManager myServersManager;
public RemoteServerListConfigurable(RemoteServersManager manager) {
myServersManager = manager;
initTree();
}
@Nls
@Override
public String getDisplayName() {
return "Clouds";
}
@Override
public void reset() {
myRoot.removeAllChildren();
for (RemoteServer<?> server : myServersManager.getServers()) {
addServerNode(server, false);
}
super.reset();
}
private MyNode addServerNode(RemoteServer<?> server, boolean isNew) {
MyNode node = new MyNode(new RemoteServerConfigurable(server, TREE_UPDATER, isNew));
addNode(node, myRoot);
return node;
}
@Override
protected void processRemovedItems() {
Set<RemoteServer<?>> servers = new HashSet<RemoteServer<?>>();
for (NamedConfigurable<RemoteServer<?>> configurable : getConfiguredServers()) {
servers.add(configurable.getEditableObject());
}
List<RemoteServer<?>> toDelete = new ArrayList<RemoteServer<?>>();
for (RemoteServer<?> server : myServersManager.getServers()) {
if (!servers.contains(server)) {
toDelete.add(server);
}
}
for (RemoteServer<?> server : toDelete) {
myServersManager.removeServer(server);
}
}
@Override
public void apply() throws ConfigurationException {
super.apply();
Set<RemoteServer<?>> servers = new HashSet<RemoteServer<?>>(myServersManager.getServers());
for (NamedConfigurable<RemoteServer<?>> configurable : getConfiguredServers()) {
RemoteServer<?> server = configurable.getEditableObject();
server.setName(configurable.getDisplayName());
if (!servers.contains(server)) {
myServersManager.addServer(server);
}
}
}
@Nullable
@Override
protected ArrayList<AnAction> createActions(boolean fromPopup) {
ArrayList<AnAction> actions = new ArrayList<AnAction>();
actions.add(new AddRemoteServerGroup());
actions.add(new MyDeleteAction());
return actions;
}
@Override
public boolean needDisplay() {
return ServerType.EP_NAME.getExtensions().length > 0;
}
@Override
protected boolean wasObjectStored(Object editableObject) {
return true;
}
private List<NamedConfigurable<RemoteServer<?>>> getConfiguredServers() {
List<NamedConfigurable<RemoteServer<?>>> configurables = new ArrayList<NamedConfigurable<RemoteServer<?>>>();
for (int i = 0; i < myRoot.getChildCount(); i++) {
MyNode node = (MyNode)myRoot.getChildAt(i);
configurables.add((NamedConfigurable<RemoteServer<?>>)node.getConfigurable());
}
return configurables;
}
private class AddRemoteServerGroup extends ActionGroup implements ActionGroupWithPreselection {
private AddRemoteServerGroup() {
super("Add", "", IconUtil.getAddIcon());
registerCustomShortcutSet(CommonShortcuts.INSERT, myTree);
}
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
ServerType[] serverTypes = ServerType.EP_NAME.getExtensions();
AnAction[] actions = new AnAction[serverTypes.length];
for (int i = 0; i < serverTypes.length; i++) {
actions[i] = new AddRemoteServerAction(serverTypes[i]);
}
return actions;
}
@Override
public ActionGroup getActionGroup() {
return this;
}
@Override
public int getDefaultIndex() {
return 0;
}
}
private class AddRemoteServerAction extends DumbAwareAction {
private final ServerType<?> myServerType;
private AddRemoteServerAction(ServerType<?> serverType) {
super(serverType.getPresentableName(), null, serverType.getIcon());
myServerType = serverType;
}
@Override
public void actionPerformed(AnActionEvent e) {
String name = UniqueNameGenerator.generateUniqueName(myServerType.getPresentableName(), new Condition<String>() {
@Override
public boolean value(String s) {
for (NamedConfigurable<RemoteServer<?>> configurable : getConfiguredServers()) {
if (configurable.getDisplayName().equals(s)) {
return false;
}
}
return true;
}
});
MyNode node = addServerNode(myServersManager.createServer(myServerType, name), true);
selectNodeInTree(node);
}
}
}
@@ -0,0 +1,18 @@
package com.intellij.remoteServer.configuration.impl;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Tag;
import org.jdom.Element;
/**
* @author nik
*/
@Tag("remote-server")
public class RemoteServerState {
@Attribute("name")
public String myName;
@Attribute("type")
public String myTypeId;
@Tag("configuration")
public Element myConfiguration;
}
@@ -0,0 +1,125 @@
package com.intellij.remoteServer.configuration.impl;
import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.RemoteServersManager;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
import com.intellij.util.xmlb.XmlSerializer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author nik
*/
@State(name = "RemoteServers", storages = {
@Storage(file = StoragePathMacros.APP_CONFIG + "/remote-servers.xml")
})
public class RemoteServersManagerImpl extends RemoteServersManager implements PersistentStateComponent<RemoteServersManagerState> {
public static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTERS = new SkipDefaultValuesSerializationFilters();
private List<RemoteServer<?>> myServers = new ArrayList<RemoteServer<?>>();
private List<RemoteServerState> myUnknownServers = new ArrayList<RemoteServerState>();
@Override
public List<RemoteServer<?>> getServers() {
return Collections.unmodifiableList(myServers);
}
@Override
public <C extends ServerConfiguration> List<RemoteServer<C>> getServers(@NotNull ServerType<C> type) {
List<RemoteServer<C>> servers = new ArrayList<RemoteServer<C>>();
for (RemoteServer<?> server : myServers) {
if (server.getType().equals(type)) {
servers.add((RemoteServer<C>)server);
}
}
return servers;
}
@Nullable
@Override
public <C extends ServerConfiguration> RemoteServer<C> findByName(@NotNull String name, @NotNull ServerType<C> type) {
for (RemoteServer<?> server : myServers) {
if (server.getType().equals(type) && server.getName().equals(name)) {
return (RemoteServer<C>)server;
}
}
return null;
}
@Override
public <C extends ServerConfiguration> RemoteServer<C> createServer(@NotNull ServerType<C> type, @NotNull String name) {
return new RemoteServerImpl<C>(name, type, type.createDefaultConfiguration());
}
@Override
public void addServer(RemoteServer<?> server) {
myServers.add(server);
}
@Override
public void removeServer(RemoteServer<?> server) {
myServers.remove(server);
}
@Nullable
@Override
public RemoteServersManagerState getState() {
RemoteServersManagerState state = new RemoteServersManagerState();
for (RemoteServer<?> server : myServers) {
RemoteServerState serverState = new RemoteServerState();
serverState.myName = server.getName();
serverState.myTypeId = server.getType().getId();
serverState.myConfiguration = XmlSerializer.serialize(server.getConfiguration().getSerializer().getState(), SERIALIZATION_FILTERS);
state.myServers.add(serverState);
}
state.myServers.addAll(myUnknownServers);
return state;
}
@Override
public void loadState(RemoteServersManagerState state) {
myUnknownServers.clear();
myServers.clear();
for (RemoteServerState server : state.myServers) {
ServerType<?> type = findServerType(server.myTypeId);
if (type == null) {
myUnknownServers.add(server);
}
else {
myServers.add(createConfiguration(type, server));
}
}
}
private static <C extends ServerConfiguration> RemoteServerImpl<C> createConfiguration(ServerType<C> type, RemoteServerState server) {
C configuration = type.createDefaultConfiguration();
PersistentStateComponent<?> serializer = configuration.getSerializer();
loadConfiguration(server, serializer);
return new RemoteServerImpl<C>(server.myName, type, configuration);
}
private static <S> void loadConfiguration(RemoteServerState server, PersistentStateComponent<S> serializer) {
S deserialize = (S)XmlSerializer.deserialize(server.myConfiguration, ComponentSerializationUtil.getStateClass(serializer.getClass()));
serializer.loadState(deserialize);
}
@Nullable
private static ServerType<?> findServerType(@NotNull String typeId) {
for (ServerType serverType : ServerType.EP_NAME.getExtensions()) {
if (serverType.getId().equals(typeId)) {
return serverType;
}
}
return null;
}
}
@@ -0,0 +1,16 @@
package com.intellij.remoteServer.configuration.impl;
import com.intellij.util.xmlb.annotations.AbstractCollection;
import com.intellij.util.xmlb.annotations.Property;
import java.util.ArrayList;
import java.util.List;
/**
* @author nik
*/
public class RemoteServersManagerState {
@Property(surroundWithTag = false)
@AbstractCollection(surroundWithTag = false)
public List<RemoteServerState> myServers = new ArrayList<RemoteServerState>();
}
@@ -0,0 +1,88 @@
package com.intellij.remoteServer.deployment.impl;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ArtifactPointer;
import com.intellij.packaging.elements.ArtifactRootElement;
import com.intellij.packaging.elements.CompositePackagingElement;
import com.intellij.remoteServer.deployment.ArtifactDeploymentSource;
import com.intellij.remoteServer.deployment.DeploymentSource;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.io.File;
/**
* @author nik
*/
public class ArtifactDeploymentSourceImpl implements ArtifactDeploymentSource, DeploymentSource {
private final ArtifactPointer myPointer;
public ArtifactDeploymentSourceImpl(@NotNull ArtifactPointer pointer) {
myPointer = pointer;
}
@NotNull
@Override
public ArtifactPointer getArtifactPointer() {
return myPointer;
}
@Override
public Artifact getArtifact() {
return myPointer.getArtifact();
}
@Override
public File getFile() {
final String path = getFilePath();
return path != null ? new File(path) : null;
}
@Override
public String getFilePath() {
final Artifact artifact = getArtifact();
if (artifact != null) {
String outputPath = artifact.getOutputPath();
if (outputPath != null) {
final CompositePackagingElement<?> rootElement = artifact.getRootElement();
if (!(rootElement instanceof ArtifactRootElement<?>)) {
outputPath += "/" + rootElement.getName();
}
return FileUtil.toSystemDependentName(outputPath);
}
}
return null;
}
@NotNull
@Override
public String getPresentableName() {
return myPointer.getArtifactName();
}
@Override
public Icon getIcon() {
final Artifact artifact = getArtifact();
return artifact != null ? artifact.getArtifactType().getIcon() : null;
}
@Override
public boolean isValid() {
return getArtifact() != null;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ArtifactDeploymentSourceImpl)) return false;
return myPointer.equals(((ArtifactDeploymentSourceImpl)o).myPointer);
}
@Override
public int hashCode() {
return myPointer.hashCode();
}
}
@@ -0,0 +1,51 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.deployment.impl;
import com.intellij.openapi.project.Project;
import com.intellij.packaging.artifacts.ArtifactPointer;
import com.intellij.packaging.artifacts.ArtifactPointerManager;
import com.intellij.remoteServer.deployment.ArtifactDeploymentSource;
import com.intellij.remoteServer.deployment.DeploymentSource;
import com.intellij.remoteServer.deployment.DeploymentSourceUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public class DeploymentSourceUtilImpl extends DeploymentSourceUtil {
@NotNull
@Override
public ArtifactDeploymentSource createArtifactDeploymentSource(@NotNull ArtifactPointer artifactPointer) {
return new ArtifactDeploymentSourceImpl(artifactPointer);
}
@Override
public DeploymentSource loadDeploymentSource(@NotNull Element element, @NotNull Project project) {
ArtifactPointerManager artifactPointerManager = ArtifactPointerManager.getInstance(project);
Element artifact = element.getChild("artifact");
return createArtifactDeploymentSource(artifactPointerManager.createPointer(artifact.getAttributeValue("name")));
}
@Override
public void saveDeploymentSource(@NotNull DeploymentSource source, @NotNull Element element, @NotNull Project project) {
if (source instanceof ArtifactDeploymentSource) {
String artifactName = ((ArtifactDeploymentSource)source).getArtifactPointer().getArtifactName();
element.addContent(new Element("artifact").setAttribute("name", artifactName));
}
}
}
@@ -0,0 +1,73 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.run;
import com.intellij.execution.configuration.ConfigurationFactoryEx;
import com.intellij.execution.configurations.ConfigurationTypeBase;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.project.Project;
import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.RemoteServersManager;
import com.intellij.remoteServer.deployment.DeploymentSource;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author nik
*/
public class DeployToServerConfigurationType extends ConfigurationTypeBase {
private ServerType<?> myServerType;
public DeployToServerConfigurationType(ServerType<?> serverType) {
super(serverType.getId() + "-deploy", serverType.getPresentableName() + " Deployment",
"Deploy to " + serverType.getPresentableName() + " run configuration", serverType.getIcon());
addFactory(new DeployToServerConfigurationFactory());
myServerType = serverType;
}
public class DeployToServerConfigurationFactory extends ConfigurationFactoryEx {
public DeployToServerConfigurationFactory() {
super(DeployToServerConfigurationType.this);
}
@Override
public void onNewConfigurationCreated(@NotNull RunConfiguration configuration) {
DeployToServerRunConfiguration deployConfiguration = (DeployToServerRunConfiguration)configuration;
if (deployConfiguration.getServerName() == null) {
RemoteServer<?> server = ContainerUtil.getFirstItem(RemoteServersManager.getInstance().getServers(myServerType));
if (server != null) {
deployConfiguration.setServerName(server.getName());
}
}
if (deployConfiguration.getDeploymentSource() == null) {
List<DeploymentSource> sources = deployConfiguration.getDeployer().getAvailableDeploymentSources();
DeploymentSource source = ContainerUtil.getFirstItem(sources);
if (source != null) {
deployConfiguration.setDeploymentSource(source);
}
}
}
@Override
public RunConfiguration createTemplateConfiguration(Project project) {
return new DeployToServerRunConfiguration(project, this, "", myServerType);
}
}
}
@@ -0,0 +1,47 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.run;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.extensions.ExtensionPoint;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.remoteServer.ServerType;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public class DeployToServerConfigurationTypesRegistrar implements ApplicationComponent {
@Override
public void initComponent() {
//todo[nik] improve this: configuration types should be loaded lazily
ExtensionPoint<ConfigurationType> point = Extensions.getRootArea().getExtensionPoint(ConfigurationType.CONFIGURATION_TYPE_EP);
for (ServerType serverType : ServerType.EP_NAME.getExtensions()) {
point.registerExtension(new DeployToServerConfigurationType(serverType));
}
}
@Override
public void disposeComponent() {
}
@NotNull
@Override
public String getComponentName() {
return "DeployToServerConfigurationTypesRegistrar";
}
}
@@ -0,0 +1,127 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.run;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.configurations.RuntimeConfigurationException;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.RemoteServersManager;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import com.intellij.remoteServer.deployment.Deployer;
import com.intellij.remoteServer.deployment.DeploymentSource;
import com.intellij.remoteServer.deployment.DeploymentSourceUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public class DeployToServerRunConfiguration<C extends ServerConfiguration> extends RunConfigurationBase {
public static final String SERVER_NAME_ATTRIBUTE = "server-name";
public static final String SOURCE_ELEMENT = "source";
private final ServerType<C> myServerType;
private final Deployer<C> myDeployer;
private String myServerName;
private DeploymentSource myDeploymentSource;
public DeployToServerRunConfiguration(Project project, ConfigurationFactory factory, String name, ServerType<C> serverType) {
super(project, factory, name);
myServerType = serverType;
myDeployer = myServerType.createDeployer(project);
}
public String getServerName() {
return myServerName;
}
@NotNull
public Deployer getDeployer() {
return myDeployer;
}
@Override
public SettingsEditor<DeployToServerRunConfiguration> getConfigurationEditor() {
return new DeployToServerSettingsEditor(myServerType, myDeployer, getProject());
}
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
String serverName = getServerName();
if (serverName == null) {
throw new ExecutionException("Server is not specified");
}
RemoteServer<C> server = RemoteServersManager.getInstance().findByName(serverName, myServerType);
if (server == null) {
throw new ExecutionException("Server '" + serverName + " not found");
}
if (myDeploymentSource == null) {
throw new ExecutionException("Deployment is not selected");
}
return new DeployToServerState(env, myDeployer, server, myDeploymentSource);
}
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
}
public void setServerName(String serverName) {
myServerName = serverName;
}
public DeploymentSource getDeploymentSource() {
return myDeploymentSource;
}
public void setDeploymentSource(DeploymentSource deploymentSource) {
myDeploymentSource = deploymentSource;
}
@Override
public void readExternal(Element element) throws InvalidDataException {
super.readExternal(element);
myServerName = element.getAttributeValue(SERVER_NAME_ATTRIBUTE);
Element sourceElement = element.getChild(SOURCE_ELEMENT);
myDeploymentSource = sourceElement != null ? DeploymentSourceUtil.getInstance().loadDeploymentSource(sourceElement, getProject()) : null;
}
@Override
public void writeExternal(Element element) throws WriteExternalException {
if (myServerName != null) {
element.setAttribute(SERVER_NAME_ATTRIBUTE, myServerName);
}
if (myDeploymentSource != null) {
Element source = new Element(SOURCE_ELEMENT);
DeploymentSourceUtil.getInstance().saveDeploymentSource(myDeploymentSource, source, getProject());
element.addContent(source);
}
super.writeExternal(element);
}
}
@@ -0,0 +1,22 @@
package com.intellij.remoteServer.run;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.runners.DefaultProgramRunner;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public class DeployToServerRunner extends DefaultProgramRunner {
@NotNull
@Override
public String getRunnerId() {
return "DeployToServer";
}
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
return executorId.equals(DefaultRunExecutor.EXECUTOR_ID) && profile instanceof DeployToServerRunConfiguration;
}
}
@@ -0,0 +1,111 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.run;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.RemoteServersManager;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import com.intellij.remoteServer.deployment.Deployer;
import com.intellij.remoteServer.deployment.DeploymentSource;
import com.intellij.ui.ColoredListCellRendererWrapper;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.SortedComboBoxModel;
import com.intellij.util.ui.FormBuilder;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.Comparator;
/**
* @author nik
*/
public class DeployToServerSettingsEditor extends SettingsEditor<DeployToServerRunConfiguration> {
private ComboBox myServerComboBox;
private ComboBox mySourceComboBox;
private final SortedComboBoxModel<String> myServerListModel;
private final SortedComboBoxModel<DeploymentSource> mySourceListModel;
public DeployToServerSettingsEditor(final ServerType<?> type, Deployer deployer, Project project) {
myServerListModel = new SortedComboBoxModel<String>(String.CASE_INSENSITIVE_ORDER);
for (RemoteServer<? extends ServerConfiguration> server : RemoteServersManager.getInstance().getServers(type)) {
myServerListModel.add(server.getName());
}
myServerComboBox = new ComboBox(myServerListModel);
myServerComboBox.setRenderer(new ColoredListCellRendererWrapper<String>() {
@Override
protected void doCustomize(JList list, String value, int index, boolean selected, boolean hasFocus) {
if (value == null) return;
SimpleTextAttributes attributes = RemoteServersManager.getInstance().findByName(value, type) == null
? SimpleTextAttributes.ERROR_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;
append(value, attributes);
}
});
mySourceListModel = new SortedComboBoxModel<DeploymentSource>(new Comparator<DeploymentSource>() {
@Override
public int compare(DeploymentSource o1, DeploymentSource o2) {
return o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName());
}
});
mySourceListModel.addAll(deployer.getAvailableDeploymentSources());
mySourceComboBox = new ComboBox(mySourceListModel);
mySourceComboBox.setRenderer(new ListCellRendererWrapper<DeploymentSource>() {
@Override
public void customize(JList list, DeploymentSource value, int index, boolean selected, boolean hasFocus) {
if (value == null) return;
setIcon(value.getIcon());
setText(value.getPresentableName());
}
});
}
@Override
protected void resetEditorFrom(DeployToServerRunConfiguration configuration) {
String serverName = configuration.getServerName();
if (serverName != null && !myServerListModel.getItems().contains(serverName)) {
myServerListModel.add(serverName);
}
myServerComboBox.setSelectedItem(serverName);
mySourceComboBox.setSelectedItem(configuration.getDeploymentSource());
}
@Override
protected void applyEditorTo(DeployToServerRunConfiguration configuration) throws ConfigurationException {
configuration.setServerName(myServerListModel.getSelectedItem());
configuration.setDeploymentSource(mySourceListModel.getSelectedItem());
}
@NotNull
@Override
protected JComponent createEditor() {
return FormBuilder.createFormBuilder()
.addLabeledComponent("Server:", myServerComboBox)
.addLabeledComponent("Deployment:", mySourceComboBox)
.getPanel();
}
@Override
protected void disposeEditor() {
}
}
@@ -0,0 +1,68 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.run;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.ExecutionResult;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.configurations.RunnerSettings;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import com.intellij.remoteServer.deployment.Deployer;
import com.intellij.remoteServer.deployment.DeploymentSource;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public class DeployToServerState<C extends ServerConfiguration> implements RunProfileState {
private final ExecutionEnvironment myExecutionEnvironment;
@NotNull private final Deployer<C> myDeployer;
@NotNull private final RemoteServer<C> myServer;
@NotNull private final DeploymentSource mySource;
public DeployToServerState(@NotNull ExecutionEnvironment executionEnvironment,
@NotNull Deployer<C> deployer,
@NotNull RemoteServer<C> server,
@NotNull DeploymentSource deploymentSource) {
myExecutionEnvironment = executionEnvironment;
myDeployer = deployer;
myServer = server;
mySource = deploymentSource;
}
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
myDeployer.startDeployment(myServer, mySource);
return null;
}
@Override
public RunnerSettings getRunnerSettings() {
return myExecutionEnvironment.getRunnerSettings();
}
@Override
public ConfigurationPerRunnerSettings getConfigurationSettings() {
return myExecutionEnvironment.getConfigurationSettings();
}
}
@@ -24,6 +24,7 @@
<orderEntry type="module" module-name="compiler-impl" />
<orderEntry type="module" module-name="dom-openapi" />
<orderEntry type="module" module-name="java-impl" />
<orderEntry type="module" module-name="remote-servers-api" />
</component>
</module>
@@ -22,6 +22,8 @@
<localInspection language="JAVA" shortName="AppEngineForbiddenCode" displayName="Forbidden code in App Engine applications"
groupName="Google App Engine" enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.appengine.inspections.AppEngineForbiddenCodeInspection"/>
<remoteServer.type implementation="com.intellij.appengine.cloud.AppEngineCloudType"/>
</extensions>
<actions>
@@ -16,6 +16,7 @@
package com.intellij.appengine.actions;
import com.intellij.CommonBundle;
import com.intellij.appengine.cloud.AppEngineServerConfiguration;
import com.intellij.appengine.descriptor.dom.AppEngineWebApp;
import com.intellij.appengine.facet.AppEngineAccountDialog;
import com.intellij.appengine.facet.AppEngineFacet;
@@ -105,7 +106,9 @@ public class AppEngineUploader {
}
@Nullable
public static AppEngineUploader createUploader(@NotNull Project project, @NotNull Artifact artifact) {
public static AppEngineUploader createUploader(@NotNull Project project,
@NotNull Artifact artifact,
@Nullable AppEngineServerConfiguration configuration) {
final String explodedPath = artifact.getOutputPath();
if (explodedPath == null) {
Messages.showErrorDialog(project, "Output path isn't specified for '" + artifact.getName() + "' artifact", CommonBundle.getErrorTitle());
@@ -150,7 +153,7 @@ public class AppEngineUploader {
String password = null;
String email = null;
try {
email = AppEngineAccountDialog.getStoredEmail(project);
email = AppEngineAccountDialog.getStoredEmail(configuration, project);
password = AppEngineAccountDialog.getStoredPassword(project, email);
}
catch (PasswordSafeException e) {
@@ -158,7 +161,7 @@ public class AppEngineUploader {
LOG.info(e);
}
if (StringUtil.isEmpty(email) || StringUtil.isEmpty(password)) {
final AppEngineAccountDialog dialog = new AppEngineAccountDialog(project);
final AppEngineAccountDialog dialog = new AppEngineAccountDialog(project, configuration);
dialog.show();
if (!dialog.isOK()) return null;
@@ -57,7 +57,7 @@ public class UploadApplicationAction extends AnAction {
return;
}
}
final AppEngineUploader uploader = AppEngineUploader.createUploader(project, artifact);
final AppEngineUploader uploader = AppEngineUploader.createUploader(project, artifact, null);
if (uploader != null) {
uploader.startUploading();
}
@@ -0,0 +1,147 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.appengine.cloud;
import com.intellij.appengine.actions.AppEngineUploader;
import com.intellij.appengine.util.AppEngineUtil;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.UnnamedConfigurable;
import com.intellij.openapi.project.Project;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ArtifactPointerManager;
import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.deployment.ArtifactDeploymentSource;
import com.intellij.remoteServer.deployment.Deployer;
import com.intellij.remoteServer.deployment.DeploymentSource;
import com.intellij.remoteServer.deployment.DeploymentSourceUtil;
import com.intellij.util.ui.FormBuilder;
import icons.GoogleAppEngineIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/**
* @author nik
*/
public class AppEngineCloudType extends ServerType<AppEngineServerConfiguration> {
public AppEngineCloudType() {
super("google-app-engine");
}
@NotNull
@Override
public String getPresentableName() {
return "Google App Engine";
}
@NotNull
@Override
public Icon getIcon() {
return GoogleAppEngineIcons.AppEngine;
}
@NotNull
@Override
public AppEngineServerConfiguration createDefaultConfiguration() {
return new AppEngineServerConfiguration();
}
@NotNull
@Override
public UnnamedConfigurable createConfigurable(@NotNull AppEngineServerConfiguration configuration) {
return new AppEngineCloudConfigurable(configuration);
}
@NotNull
@Override
public Deployer createDeployer(Project project) {
return new AppEngineDeployer(project);
}
private static class AppEngineCloudConfigurable implements UnnamedConfigurable {
private final JTextField myEmailField;
private final AppEngineServerConfiguration myConfiguration;
public AppEngineCloudConfigurable(AppEngineServerConfiguration configuration) {
myConfiguration = configuration;
myEmailField = new JTextField();
myEmailField.setPreferredSize(new Dimension(250, myEmailField.getPreferredSize().height));
}
@Nullable
@Override
public JComponent createComponent() {
return FormBuilder.createFormBuilder().addLabeledComponent("E-mail:", myEmailField).getPanel();
}
@Override
public boolean isModified() {
return !myEmailField.getText().equals(myConfiguration.getEmail());
}
@Override
public void apply() throws ConfigurationException {
myConfiguration.setEmail(myEmailField.getText());
}
@Override
public void reset() {
myEmailField.setText(myConfiguration.getEmail());
}
@Override
public void disposeUIResources() {
}
}
private static class AppEngineDeployer extends Deployer<AppEngineServerConfiguration> {
private final Project myProject;
public AppEngineDeployer(Project project) {
myProject = project;
}
@NotNull
@Override
public List<DeploymentSource> getAvailableDeploymentSources() {
List<Artifact> artifacts = AppEngineUtil.collectWebArtifacts(myProject, true);
List<DeploymentSource> sources = new ArrayList<DeploymentSource>();
ArtifactPointerManager pointerManager = ArtifactPointerManager.getInstance(myProject);
for (Artifact artifact : artifacts) {
sources.add(DeploymentSourceUtil.getInstance().createArtifactDeploymentSource(pointerManager.createPointer(artifact)));
}
return sources;
}
@Override
public void startDeployment(@NotNull RemoteServer<AppEngineServerConfiguration> server,
@NotNull DeploymentSource source) {
Artifact artifact = ((ArtifactDeploymentSource)source).getArtifact();
if (artifact == null) return;
AppEngineUploader uploader = AppEngineUploader.createUploader(myProject, artifact, server.getConfiguration());
if (uploader != null) {
uploader.startUploading();
}
}
}
}
@@ -0,0 +1,54 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.appengine.cloud;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import com.intellij.util.xmlb.XmlSerializerUtil;
import com.intellij.util.xmlb.annotations.Attribute;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public class AppEngineServerConfiguration extends ServerConfiguration implements PersistentStateComponent<AppEngineServerConfiguration> {
private String myEmail;
@Attribute("email")
public String getEmail() {
return myEmail;
}
public void setEmail(String email) {
myEmail = email;
}
@Nullable
@Override
public AppEngineServerConfiguration getState() {
return this;
}
@Override
public void loadState(AppEngineServerConfiguration state) {
XmlSerializerUtil.copyBean(state, this);
}
@Override
public PersistentStateComponent<?> getSerializer() {
return this;
}
}
@@ -16,6 +16,7 @@
package com.intellij.appengine.facet;
import com.intellij.CommonBundle;
import com.intellij.appengine.cloud.AppEngineServerConfiguration;
import com.intellij.ide.passwordSafe.PasswordSafe;
import com.intellij.ide.passwordSafe.PasswordSafeException;
import com.intellij.ide.util.PropertiesComponent;
@@ -39,12 +40,14 @@ public class AppEngineAccountDialog extends DialogWrapper {
private JPasswordField myPasswordField;
private JTextField myUserEmailField;
private final Project myProject;
@Nullable private final AppEngineServerConfiguration myConfiguration;
public AppEngineAccountDialog(@NotNull Project project) {
public AppEngineAccountDialog(@NotNull Project project, @Nullable AppEngineServerConfiguration configuration) {
super(project);
myProject = project;
myConfiguration = configuration;
setTitle("AppEngine Account");
myUserEmailField.setText(StringUtil.notNullize(getStoredEmail(project)));
myUserEmailField.setText(StringUtil.notNullize(getStoredEmail(myConfiguration, project)));
init();
}
@@ -67,14 +70,22 @@ public class AppEngineAccountDialog extends DialogWrapper {
}
@Nullable
public static String getStoredEmail(@NotNull Project project) {
return PropertiesComponent.getInstance(project).getValue(EMAIL_KEY);
public static String getStoredEmail(@Nullable AppEngineServerConfiguration configuration, @NotNull Project project) {
if (configuration != null) {
return configuration.getEmail();
}
return PropertiesComponent.getInstance(project).getValue(EMAIL_KEY);//todo[nik] remove this
}
@Override
protected void doOKAction() {
final String email = getEmail();
PropertiesComponent.getInstance(myProject).setValue(EMAIL_KEY, email);
if (myConfiguration != null) {
myConfiguration.setEmail(email);
}
else {
PropertiesComponent.getInstance(myProject).setValue(EMAIL_KEY, email);
}
if (myRememberPasswordCheckBox.isSelected()) {
try {
PasswordSafe.getInstance().storePassword(myProject, AppEngineAccountDialog.class, getPasswordKey(email), getPassword());
@@ -385,6 +385,7 @@
</extensions>
<xi:include href="/META-INF/xdebugger.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/RemoteServers.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/XmlPlugin.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/RegExpPlugin.xml" xpointer="xpointer(/idea-plugin/*)"/>