Skip to content

Commit

Permalink
Add doc on how to develop the plugin and a little bit of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
olafleur committed Jun 9, 2014
1 parent f514bcb commit f9a3a2f
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -25,6 +25,14 @@ Create the presenter and view classes quickly with this.
##Download
* <a href="http://plugins.jetbrains.com/plugin/7318?pr=idea_ce" target="_blank">GWTP IDEA Plugin</a>

##Develop the plugin (inspired by http://bjorn.tipling.com/how-to-make-an-intellij-idea-plugin-in-30-minutes)
* Download and install the Community Edition of IntelliJ IDEA (it will be the SDK)
* Download the source code of IntelliJ (to be able to debug)
* Clone this repository and set the SDK of the project with the version you downloaded of IntelliJ
* Add the source code of IntelliJ to your sourcepath
* Add the maven.jar located in plugins/maven directory of the SDK to your classpath
* Install the UI Designer (as prompted by your editor)

##Thanks to
[![Arcbees.com](http://arcbees-ads.appspot.com/ad.png)](http://arcbees.com)

Expand Down
5 changes: 2 additions & 3 deletions src/com/arcbees/plugin/idea/dialogs/ContentSlotDialog.java
Expand Up @@ -31,7 +31,6 @@
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -118,7 +117,7 @@ public boolean process(PsiMember psiMember) {
private String getSlot(PsiMember psiMember) {
PsiClass container = psiMember.getContainingClass();
String classname = container.getName();
String slot = classname + "." + psiMember.getName();
return slot;

return classname + "." + psiMember.getName();
}
}
32 changes: 16 additions & 16 deletions src/com/arcbees/plugin/idea/domain/Archetype.java
Expand Up @@ -82,16 +82,16 @@ public String getCategoriesAsString() {
return "";
}

StringBuffer sb = new StringBuffer();
if (categories != null) {
for (int i = 0; i < categories.size(); i++) {
Category c = categories.get(i);
sb.append(c.getName());
if (i < categories.size() - 1) {
sb.append(", ");
}
StringBuilder sb = new StringBuilder();

for (int i = 0; i < categories.size(); i++) {
Category c = categories.get(i);
sb.append(c.getName());
if (i < categories.size() - 1) {
sb.append(", ");
}
}

return sb.toString();
}

Expand All @@ -104,16 +104,16 @@ public String getTagsAsString() {
if (tags == null) {
return "";
}
StringBuffer sb = new StringBuffer();
if (tags != null) {
for (int i = 0; i < tags.size(); i++) {
Tag t = tags.get(i);
sb.append(t.getName());
if (i < tags.size() - 1) {
sb.append(", ");
}
StringBuilder sb = new StringBuilder();

for (int i = 0; i < tags.size(); i++) {
Tag t = tags.get(i);
sb.append(t.getName());
if (i < tags.size() - 1) {
sb.append(", ");
}
}

return sb.toString();
}

Expand Down
4 changes: 2 additions & 2 deletions src/com/arcbees/plugin/idea/domain/ProjectConfigModel.java
Expand Up @@ -65,12 +65,12 @@ public void setArchetypeSelected(Archetype archetypeSelected) {

// TODO future
public String getVersion() {
return "1.0-SNAPSHOT";
return "1.1.0";
}

// TODO future
public String getDescription() {
return "This project was genereted by ArcBees Eclipse plugin.";
return "This project was generated by ArcBees IntelliJ IDEA plugin.";
}

@Override
Expand Down
Expand Up @@ -18,7 +18,6 @@

import com.arcbees.plugin.idea.icons.PluginIcons;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleTypeManager;

import javax.swing.*;

Expand Down
20 changes: 8 additions & 12 deletions src/com/arcbees/plugin/idea/utils/PackageHierarchy.java
Expand Up @@ -50,7 +50,7 @@
public class PackageHierarchy {
private static final Logger logger = Logger.getLogger(PackageHierarchy.class.getName());

private PresenterConfigModel presenterConfigModel;
private final PresenterConfigModel presenterConfigModel;
private Map<String, PackageHierarchyElement> packagesIndex;

public PackageHierarchy(PresenterConfigModel presenterConfigModel) {
Expand Down Expand Up @@ -200,7 +200,7 @@ public void run() {

for (PsiClass unit : units) {
boolean found = findInterfaceUseInUnit(unit, findTypeName);
if (found == true) {
if (found) {
psiClassModel.set(unit);
}
}
Expand All @@ -216,11 +216,9 @@ private boolean findInterfaceUseInUnit(PsiClass unit, String findTypeName) {
for (PsiClassType types : unit.getSuperTypes()) {
PsiType[] superTypes = types.getSuperTypes();

if (superTypes != null) {
for (PsiType superType : superTypes) {
if (superType.getCanonicalText().contains(findTypeName)) {
return true;
}
for (PsiType superType : superTypes) {
if (superType.getCanonicalText().contains(findTypeName)) {
return true;
}
}
}
Expand All @@ -247,8 +245,8 @@ private void indexPackage(VirtualFile root, PsiPackage packageFragment) {
GlobalSearchScope scope = GlobalSearchScope.projectScope(presenterConfigModel.getProject());
PsiPackage[] children = packageFragment.getSubPackages(scope);

for (int i = 0; i < children.length; i++) {
indexPackage(root, children[i]);
for (PsiPackage aChildren : children) {
indexPackage(root, aChildren);
}
}

Expand All @@ -269,9 +267,7 @@ public void run() {
}
}, ModalityState.NON_MODAL);

List<PsiClass> found = new ArrayList<PsiClass>(Arrays.asList(psiClassesModel.get()));

return found;
return new ArrayList<PsiClass>(Arrays.asList(psiClassesModel.get()));
}

private List<PackageRoot> getTopLevelPackages() {
Expand Down
Expand Up @@ -18,7 +18,6 @@

import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiPackage;

import java.util.HashMap;
Expand Down
4 changes: 2 additions & 2 deletions src/com/arcbees/plugin/idea/utils/PackageRoot.java
Expand Up @@ -20,8 +20,8 @@
import com.intellij.psi.PsiPackage;

public class PackageRoot {
private VirtualFile root;
private PsiPackage psiPackage;
private final VirtualFile root;
private final PsiPackage psiPackage;

public PackageRoot(VirtualFile root, PsiPackage psiPackage) {
this.root = root;
Expand Down
3 changes: 1 addition & 2 deletions src/com/arcbees/plugin/idea/utils/PackageUtilExt.java
Expand Up @@ -240,8 +240,7 @@ public static PsiDirectory findOrCreateDirectoryForPackage(@NotNull Module modul
try {
foundExistingDirectory = ActionRunner.runInsideWriteAction(new ActionRunner.InterruptibleRunnableWithResult<PsiDirectory>() {
public PsiDirectory run() throws Exception {
PsiDirectory foundExistingDirectory = passDir.findSubdirectory(name);
return foundExistingDirectory;
return passDir.findSubdirectory(name);
}
});
} catch (Exception e) {
Expand Down
Expand Up @@ -307,12 +307,9 @@ public void run() {

private PsiMethod findMethod(PsiClass unit, String methodName) {
PsiMethod[] methods = unit.getMethods();
if (methods == null) {
return null;
}

for (PsiMethod method : methods) {
if (method.getName().toString().contains(methodName)) {
if (method.getName().contains(methodName)) {
return method;
}
}
Expand Down Expand Up @@ -565,7 +562,6 @@ private void addMethodsToNameTokens(final PsiClass nameTokensPsiClass) {
List<String> fields = createdNameTokenTemplates.getFields();
List<String> methods = createdNameTokenTemplates.getMethods();
final String fieldSource = fields.get(0).replaceAll("\n", "");
;
final String methodSource = methods.get(0);

final PsiFieldModel psiFieldModel = new PsiFieldModel();
Expand Down Expand Up @@ -682,9 +678,8 @@ private void fetchTemplatesNameTokens() throws Exception {
NameTokenOptions nameTokenOptions = new NameTokenOptions();
nameTokenOptions.setPackageName(createdNameTokensPackage.getQualifiedName());
nameTokenOptions.setNameTokens(nameTokens);
boolean processFileOnly = false;

createdNameTokenTemplates = CreateNameTokens.run(nameTokenOptions, true, processFileOnly);
createdNameTokenTemplates = CreateNameTokens.run(nameTokenOptions, true, false);
}

private void createPackageHierachyIndex() {
Expand Down Expand Up @@ -746,17 +741,15 @@ private void createNametokensClass() throws Exception {
}

private PsiClass createNewNameTokensClass() throws Exception {
boolean processFileOnly = true;
NameTokenOptions nameTokenOptions = new NameTokenOptions();
nameTokenOptions.setPackageName(createdNameTokensPackage.getQualifiedName());
CreatedNameTokens createdNameToken;

createdNameToken = CreateNameTokens.run(nameTokenOptions, true, processFileOnly);
createdNameToken = CreateNameTokens.run(nameTokenOptions, true, true);

RenderedTemplate renderedTemplate = createdNameToken.getNameTokensFile();
PsiClass createdPsiClass = createPsiClass(createdNameTokensPackage, renderedTemplate);

return createdPsiClass;
return createPsiClass(createdNameTokensPackage, renderedTemplate);
}

private PsiDirectory getBaseDir() {
Expand Down
Expand Up @@ -6,7 +6,6 @@
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.ValidationInfo;
Expand Down
Expand Up @@ -21,7 +21,6 @@

import javax.swing.table.DefaultTableModel;
import java.util.List;
import java.util.Vector;

public class ArchetypesTableModel extends DefaultTableModel {
private static final String[] COLUMN_TITLES = {"Name", "Categories", "Tags"};
Expand Down
Expand Up @@ -48,8 +48,7 @@ public class FetchArchetypes {
public ArchetypeCollection fetchArchetypes() {
initRestAssured();

ArchetypeCollection archetypeCollection = RestAssured.get(DIRECTORY_URL).as(ArchetypeCollection.class);
return archetypeCollection;
return RestAssured.get(DIRECTORY_URL).as(ArchetypeCollection.class);
}

private void initRestAssured() {
Expand Down

0 comments on commit f9a3a2f

Please sign in to comment.