Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
witmicko authored and vchepeli committed Feb 7, 2018
1 parent d282561 commit 89e5157
Show file tree
Hide file tree
Showing 22 changed files with 539 additions and 30 deletions.
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
.idea/*
*.iml
*.ipr
*.iws
target/*
*.zip
.gradle/*
.idea/*
.classPath
.project
.settings/*
bin/*
build/*
lib/*
out/*
*.zip
lib/*
target/*
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "disabled"
}
10 changes: 10 additions & 0 deletions CodeStyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<code_scheme name="Default" version="173">
<JavaCodeStyleSettings>
<option name="CLASS_NAMES_IN_JAVADOC" value="2" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
</JavaCodeStyleSettings>
</code_scheme>
21 changes: 12 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,18 @@ compileJava.dependsOn extractIdeaSdk
apply plugin: 'idea'

intellij {
updateSinceUntilBuild false
version '172.4343.14'
plugins = ['properties', 'Groovy', 'gradle', 'android']
// UnComment one of the following lines and set your path to Android Studio.
// Example for linux
// alternativeIdePath = '/home/$USER/Programs/android-studio'
// Example for Mac
// alternativeIdePath = '/Applications/Android Studio.app'
updateSinceUntilBuild false
version '172.4343.14'
plugins = ['properties', 'Groovy', 'gradle', 'android']

// Uncomment line matching path to the IDE you want to run the plugin with.

// Android studio linux
// alternativeIdePath = '/home/summers/Programs/android-studio'

// Android studio and Webstorm, Mac
// alternativeIdePath = '/Applications/Webstorm.app'
// alternativeIdePath = '/Applications/Android Studio.app'

}

Expand Down Expand Up @@ -124,7 +127,7 @@ idea {
}

task wrapper(type: Wrapper) {
gradleVersion = '3.0'
gradleVersion = '4.1'
}

// ========= Custom tasks ========= //
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Jan 12 14:51:45 GMT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-rc-2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
6 changes: 3 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand Down Expand Up @@ -155,7 +155,7 @@ if $cygwin ; then
fi

# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

public interface CLIRunner {
String executeSync(List<String> command)throws CLIException;
void executeAsync(List<String> command, Watcher w);
String executeSync(List<String> command) throws CLIException;

void executeAsync(List<String> command, Watcher w);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ public void createService(ServiceClass sc, List<String> params, Watcher w) {
}
cliRunner.executeAsync(cmd, w);
}
public MobileClient createClient(String name, String clientType, String bundleID)throws CLIException{
if("".equals(name) || "".equals(clientType) || "".equals(bundleID)){


public MobileClient createClient(String name, String clientType, String bundleID) throws CLIException {
if (name.isEmpty() || clientType.isEmpty() || bundleID.isEmpty()) {
throw new CLIException("expected a client name, a client type and a bundle id");
}
String res = cliRunner.executeSync(Arrays.asList("create","client",name,clientType,bundleID));
try{
String res = cliRunner.executeSync(Arrays.asList("create", "client", "--", name, clientType, bundleID, "-o=json"));

try {
Gson gson = new Gson();
MobileClient client = gson.fromJson(res,MobileClient.class);
MobileClient client = gson.fromJson(res, MobileClient.class);
return client;
}catch (JsonSyntaxException e) {
} catch (JsonSyntaxException e) {
throw new CLIException("unexpected response from CLI: " + res);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,14 @@ public void setAppIdentifier(String appIdentifier) {
result = 31 * result + (appIdentifier != null ? appIdentifier.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "{\n" +
" name: " + name + ",\n" +
" apiKey: " + apiKey +",\n" +
" clientType: " + clientType +",\n" +
" appIdentifier: " + appIdentifier +",\n" +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.aerogear.plugin.intellij.mobile.ui;

import com.intellij.openapi.util.IconLoader;

import javax.swing.*;

public class MobileIcons {
public static final Icon FEEDHENRY = IconLoader.getIcon("/icons/fh_icon.png");
public static final Icon AEROGEAR = IconLoader.getIcon("/icons/aerogear.png");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.aerogear.plugin.intellij.mobile.wizard;

class Constants {
public static final String[] CLIENT_TYPES = new String[]{
"android",
"cordova",
"iOS"
};

public static final String MODULE_ID = "MOBILE_MODULE";
public static final String MODULE_NAME = "Mobile Client App";
public static final String MODULE_DESCRIPTION = "Mobile Client App Representation";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.aerogear.plugin.intellij.mobile.wizard;

import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleBuilderListener;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;


public class CreateClientBuilder extends ModuleBuilder implements ModuleBuilderListener {
private String commandOutput;

@Override
public void setupRootModel(ModifiableRootModel modifiableRootModel) throws ConfigurationException {
}

@Override
public ModuleType getModuleType() {
return CreateClientType.getInstance();
}


@Nullable
@Override
public ModuleWizardStep getCustomOptionsStep(WizardContext context, Disposable parentDisposable) {
return new CreateClientFirstStep(this);
}


@Override
public void moduleCreated(@NotNull Module module) {
//TODO what do we do after the wizard has been created
}


@Override
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
return new ModuleWizardStep[]{new CreateClientSecondStep(this)};
}

/**
* returns output of the create client command that was set in first step
* @return output of create client command
*/
public String getCommandOutput() {
return commandOutput;
}

/**
* sets commandOutput, used in first step to save the state between two steps.
* @param commandOutput
*/
public void setCommandOutput(String commandOutput) {
this.commandOutput = commandOutput;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.aerogear.plugin.intellij.mobile.wizard;

import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import org.aerogear.plugin.intellij.mobile.api.CLIException;
import org.aerogear.plugin.intellij.mobile.api.CLIRunnerImpl;
import org.aerogear.plugin.intellij.mobile.api.MobileAPI;
import org.aerogear.plugin.intellij.mobile.models.MobileClient;

import javax.swing.JComponent;


class CreateClientFirstStep extends ModuleWizardStep {
private CreateClientForm clientForm;
private CreateClientFormInputs clientFormInputs;
private MobileAPI mobileAPI;
private CreateClientBuilder createClientBuilder;


CreateClientFirstStep(CreateClientBuilder createClientBuilder) {
this.createClientBuilder = createClientBuilder;
clientForm = new CreateClientForm();
mobileAPI = new MobileAPI(new CLIRunnerImpl());
}

@Override
public JComponent getComponent() {
return clientForm;
}

@Override
public void updateDataModel() {
String output;
try {
MobileClient mobileClient = mobileAPI.createClient(
clientFormInputs.getName(),
clientFormInputs.getClientType(),
clientFormInputs.getAppIdentifier()
);
output = mobileClient.getSpec().toString();

} catch (CLIException e) {
output = e.getMessage();
}
createClientBuilder.setCommandOutput(output);
System.out.println(output);
}

@Override
public boolean validate() {
clientFormInputs = clientForm.getInputs();
clientForm.resetValidationNotifications();
boolean validName = true;
boolean validId = true;

if (clientFormInputs.isInvalidName()) {
clientForm.invalidNameNotify();
validName = false;
}

if (clientFormInputs.isInvalidAppIdentifier()) {
clientForm.invalidAppIdNotify();
validId = false;
}

return validName && validId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.aerogear.plugin.intellij.mobile.wizard.CreateClientForm">
<grid id="27dc6" binding="clientPanel" layout-manager="GridLayoutManager" row-count="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="397" height="179"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="50367" class="javax.swing.JLabel" binding="clientNameLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="674d1"/>
<text value="Client name"/>
</properties>
</component>
<component id="674d1" class="javax.swing.JTextField" binding="clientNameTxtField">
<constraints>
<grid row="0" column="1" row-span="3" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="300" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="f995c" class="javax.swing.JLabel" binding="clientTypeLabel">
<constraints>
<grid row="2" column="0" row-span="3" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="8328c"/>
<text value="Client Type"/>
</properties>
</component>
<component id="8328c" class="javax.swing.JComboBox" binding="clientTypeComboBox" custom-create="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="a0234" class="javax.swing.JLabel" binding="errorLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
<component id="ef699" class="javax.swing.JLabel" binding="errorMessage">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
<component id="54d91" class="javax.swing.JLabel" binding="appIdLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="496a7"/>
<text value="App Identifier"/>
</properties>
</component>
<component id="496a7" class="javax.swing.JTextField" binding="clientAppIdTxtField">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>
Loading

0 comments on commit 89e5157

Please sign in to comment.