Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package Name input #1

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.freshplanet.ane.${PROJECT_NAME}"
package="${PACKAGE_NAME}.${PROJECT_NAME}"
android:versionCode="1"
android:versionName="1.0" >

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2012 Freshplanet (http://freshplanet.com | [email protected])
//
// 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.freshplanet.ane.${PROJECT_NAME};
package ${PACKAGE_NAME}.${PROJECT_NAME};

import android.util.Log;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2012 Freshplanet (http://freshplanet.com | [email protected])
//
// 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.freshplanet.ane.${PROJECT_NAME};
package ${PACKAGE_NAME}.${PROJECT_NAME};

import java.util.HashMap;
import java.util.Map;
Expand All @@ -26,7 +7,7 @@ import android.util.Log;

import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.freshplanet.ane.${PROJECT_NAME}.functions.IsSupportedFunction;
import ${PACKAGE_NAME}.${PROJECT_NAME}.functions.IsSupportedFunction;

public class ${PROJECT_NAME}ExtensionContext extends FREContext
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2012 Freshplanet (http://freshplanet.com | [email protected])
//
// 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.freshplanet.ane.${PROJECT_NAME}.functions;
package ${PACKAGE_NAME}.${PROJECT_NAME}.functions;

import android.util.Log;

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;

import pl.mateuszmackowiak.ane.wizard.android.WizardNewProjectPackageAndLocationPage;


public class NewANEProjectWizard extends Wizard implements INewWizard
{
private WizardNewProjectCreationPage wizardPage;
private WizardNewProjectPackageAndLocationPage wizardPage;
private IConfigurationElement config;
private IWorkbench workbench;
private IStructuredSelection selection;
Expand All @@ -43,9 +45,10 @@ public NewANEProjectWizard()
*/
public void addPages()
{
wizardPage = new WizardNewProjectCreationPage("NewANEProject");
wizardPage = new WizardNewProjectPackageAndLocationPage("NewANEProject");
wizardPage.setDescription("Create a new ANE Project");
wizardPage.setTitle("New ANE Project");
wizardPage.setInitialPackageName("com.youcompany");
addPage(wizardPage);
}

Expand All @@ -60,6 +63,7 @@ public boolean performFinish()
if (project != null) return true;

final IProject projectHandle = wizardPage.getProjectHandle();
final String packageName = wizardPage.getPackageName();
URI projectURI = (!wizardPage.useDefaults()) ? wizardPage.getLocationURI() : null;
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProjectDescription desc = workspace.newProjectDescription(projectHandle.getName());
Expand All @@ -68,7 +72,7 @@ public boolean performFinish()
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor) throws CoreException
{
createProject(desc, projectHandle, monitor);
createProject(desc, projectHandle, monitor,packageName);
}
};

Expand Down Expand Up @@ -106,7 +110,7 @@ protected void execute(IProgressMonitor monitor) throws CoreException
* @throws CoreException
* @throws OperationCanceledException
*/
void createProject(IProjectDescription description, IProject proj, IProgressMonitor monitor) throws CoreException, OperationCanceledException
void createProject(IProjectDescription description, IProject proj, IProgressMonitor monitor, String packageName) throws CoreException, OperationCanceledException
{
try
{
Expand All @@ -130,21 +134,46 @@ void createProject(IProjectDescription description, IProject proj, IProgressMoni
createFolder("gen", container, monitor);
createFolder("res", container, monitor);
createFolder("src", container, monitor);
createFolder("src/com", container, monitor);

String fullPackageString = "src";

//Create folders if package not empty
if(packageName!=null && !packageName.isEmpty()){
String[] packages = packageName.split("\\.");

for (String packageElement : packages) {
fullPackageString+="/"+packageElement;
createFolder(fullPackageString, container, monitor);
}
}
createFolder(fullPackageString +"/"+ projectName, container, monitor);
createFolder(fullPackageString +"/"+ projectName + "/functions", container, monitor);



/*createFolder("src/com", container, monitor);
createFolder("src/com/freshplanet", container, monitor);
createFolder("src/com/freshplanet/ane", container, monitor);
createFolder("src/com/freshplanet/ane/" + projectName, container, monitor);
createFolder("src/com/freshplanet/ane/" + projectName + "/functions", container, monitor);

createFolder("src/com/freshplanet/ane/" + projectName + "/functions", container, monitor);*/
// Copy files
copyFile(".project", ".project", projectName, container, monitor);
copyFile("project.properties", "project.properties", projectName, container, monitor);
copyFile("proguard-project.txt", "proguard-project.txt", projectName, container, monitor);
copyFile(".classpath", ".classpath", projectName, container, monitor);
copyFile("AndroidManifest.xml", "AndroidManifest.xml", projectName, container, monitor);
copyFile(".project", ".project", projectName,packageName, container, monitor);
copyFile("project.properties", "project.properties", projectName,packageName, container, monitor);
copyFile("proguard-project.txt", "proguard-project.txt", projectName,packageName, container, monitor);
copyFile(".classpath", ".classpath", projectName,packageName, container, monitor);
copyFile("AndroidManifest.xml", "AndroidManifest.xml", projectName,packageName, container, monitor);


/*
copyFile("Extension.java.resource", "src/com/freshplanet/ane/" + projectName + "/" + projectName + "Extension.java", projectName, container, monitor);
copyFile("ExtensionContext.java.resource", "src/com/freshplanet/ane/" + projectName + "/" + projectName + "ExtensionContext.java", projectName, container, monitor);
copyFile("Function.java.resource", "src/com/freshplanet/ane/" + projectName + "/functions/IsSupportedFunction.java", projectName, container, monitor);
*/
fullPackageString+="/";
copyFile("Extension.java.resource", fullPackageString + projectName + "/" + projectName + "Extension.java", projectName,packageName, container, monitor);
copyFile("ExtensionContext.java.resource", fullPackageString + projectName + "/" + projectName + "ExtensionContext.java", projectName,packageName, container, monitor);
copyFile("Function.java.resource", fullPackageString + projectName + "/functions/IsSupportedFunction.java", projectName,packageName, container, monitor);
}
catch (IOException ioe)
{
Expand All @@ -163,9 +192,9 @@ private void createFolder(String path, IContainer container, IProgressMonitor mo
folder.create(true, true, monitor);
}

private void copyFile(String resourceName, String finalPath, String projectName, IContainer container, IProgressMonitor monitor) throws IOException, CoreException
private void copyFile(String resourceName, String finalPath, String projectName, String packageName, IContainer container, IProgressMonitor monitor) throws IOException, CoreException
{
InputStream resourceStream = openFilteredResource(resourceName, projectName);
InputStream resourceStream = openFilteredResource(resourceName, projectName,packageName);
addFileToProject(container, new Path(finalPath), resourceStream, monitor);
resourceStream.close();
}
Expand Down Expand Up @@ -194,7 +223,7 @@ private void addFileToProject(IContainer container, Path path, InputStream conte

}

private InputStream openFilteredResource(String resourceName, String projectName) throws CoreException
private InputStream openFilteredResource(String resourceName, String projectName,String packageName) throws CoreException
{
final String newline = "\n";
String line;
Expand All @@ -206,6 +235,11 @@ private InputStream openFilteredResource(String resourceName, String projectName
try {

while ((line = reader.readLine()) != null) {
if(packageName!=null && !packageName.isEmpty())
line = line.replaceAll("\\$\\{PACKAGE_NAME\\}", packageName);
else{
line = line.replaceAll("\\$\\{PACKAGE_NAME\\}", "");
}
line = line.replaceAll("\\$\\{PROJECT_NAME\\}", projectName);
sb.append(line);
sb.append(newline);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.freshplanet.ane.${PROJECT_NAME}"
package="${PACKAGE_NAME}.${PROJECT_NAME}"
android:versionCode="1"
android:versionName="1.0" >

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2012 Freshplanet (http://freshplanet.com | [email protected])
//
// 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.freshplanet.ane.${PROJECT_NAME};
package ${PACKAGE_NAME}.${PROJECT_NAME};

import android.util.Log;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2012 Freshplanet (http://freshplanet.com | [email protected])
//
// 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.freshplanet.ane.${PROJECT_NAME};
package ${PACKAGE_NAME}.${PROJECT_NAME};

import java.util.HashMap;
import java.util.Map;
Expand All @@ -26,7 +7,7 @@ import android.util.Log;

import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.freshplanet.ane.${PROJECT_NAME}.functions.IsSupportedFunction;
import ${PACKAGE_NAME}.${PROJECT_NAME}.functions.IsSupportedFunction;

public class ${PROJECT_NAME}ExtensionContext extends FREContext
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2012 Freshplanet (http://freshplanet.com | [email protected])
//
// 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.freshplanet.ane.${PROJECT_NAME}.functions;
package ${PACKAGE_NAME}.${PROJECT_NAME}.functions;

import android.util.Log;

Expand Down
Loading