+/*
+ * IDE
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Shingil Kang <shingil.kang@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ *
+ * 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ */
package org.tizen.ncli.ide.shell;
import java.io.File;
import java.io.IOException;
import org.kohsuke.args4j.Option;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-//import org.tizen.ncli.ide.subcommands.CreateNativeProjectCommand;
+import org.tizen.ncli.core.TizenSubCommand;
import org.tizen.ncli.ide.messages.TizenCLIMessages;
import org.tizen.ncli.ide.subcommands.CreateNativeProjectCommand;
import org.tizen.ncli.ide.subcommands.CreateNativeProjectCommandData;
+@TizenSubCommand(name="native-project" , usage="Create the tizen native project")
public class CreateNativeProjectCLI extends AbstractCLI
{
@Option(name = "-t", aliases = { "--type" }, usage = "Specify template name")
CreateNativeProjectCommandData data = nativeCommand.runCommand();
- progressLog.info("Project Location : {}",data.getOutputName());
- progressLog.info("Creating native project succeeded!");
+ progressLog.info("Project Location: {}",data.getOutputName());
}
}
import java.io.File;
import java.io.IOException;
+import java.io.PrintWriter;
import java.net.URL;
import java.text.MessageFormat;
import java.util.HashMap;
import org.eclipse.cdt.core.templateengine.process.processes.Messages;
import org.tizen.common.util.FileUtil;
+import org.tizen.core.ide.TextProgressMonitor;
import org.tizen.nativeappcommon.wizards.TizenProjectWizard;
import org.tizen.nativecommon.Activator;
import org.tizen.nativecommon.exception.TizenProcessFailureException;
{
private CreateNativeProjectCommandData data = new CreateNativeProjectCommandData();
+ private static final String CREATE_NATIVE_PROJECT_TASK = "Create Native Project";
+
public void setTemplateName(String projectName)
{
this.data.setTemplateName(projectName);
/*
* create native project from template.
*
- * 1. get template list
+ * 1. get template list
* 2. copy native project template
*/
@Override
protected CreateNativeProjectCommandData call()
{
- progressLog.info("-----------------------------------------------------");
- progressLog.info("Starting Tizen project creation:");
- progressLog.info("-----------------------------------------------------");
-
+ progressMonitor = new TextProgressMonitor(new PrintWriter(System.out));
+ progressMonitor.beginTask(CREATE_NATIVE_PROJECT_TASK, 10);
+
// get template list
data.getTemplateList();
+ progressMonitor.update(3);
// copy native project template and generate .cproject and .project file
copyNativeProjectTemplate();
+ progressMonitor.update(7);
+
+ progressMonitor.endTask();
return data;
}
public void setBuildConfigMap(String projectType)
{
String tempPath = pg.extractBuiltinJarFiles("templates" + File.separator + "Executables");
- if(tempPath == null){
+ if (tempPath == null)
+ {
log.error("No jar folder!");
return;
}
-
+
tempPath = tempPath.substring(0, tempPath.lastIndexOf(File.separator));
cProjectTemplatePath = tempPath.substring(0, tempPath.lastIndexOf(File.separator));
}
} catch (Exception e)
{
- log.error("Error occurred during reading app/shared/static teamplate!\n{}",e.getMessage());
+ log.error("Error occurred during reading app/shared/static teamplate!\n{}", e.getMessage());
}
}
* Shingil Kang <shingil.kang@samsung.com>
* Hyeongseok Heo <hyeongseok.heo@samsung.com>
* Kangho Kim <kh5325.kim@samsung.com>
- *
+ *
* 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
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import org.tizen.common.util.FileUtil;
import org.tizen.common.util.FreeMarkerUtil;
import org.tizen.common.util.IOUtil;
+import org.tizen.core.ide.TextProgressMonitor;
import org.tizen.ncli.ide.messages.TizenCLIMessages;
import org.tizen.web.apptemplate.model.LibraryElement;
import org.tizen.web.apptemplate.model.OptionElement;
/**
* @author Shingil Kang{@literal <shingil.kang@samsung.com>} (S-core)
- *
+ *
*/
public class CreateWebProjectCommand extends AbstractSubCommand<CreateProjectCommandData>
{
private TizenTemplateLibrariesPool libraryPool;
+ private static final String CREATE_WEB_PROJECT_TASK = "Create Web Project";
+
/*
* create web project from template.
- *
+ *
* 1. get template list
* 2. copy web project template
* 3. copy the dependent library
@Override
protected CreateProjectCommandData call()
{
+ progressMonitor = new TextProgressMonitor(new PrintWriter(System.out));
+ progressMonitor.beginTask(CREATE_WEB_PROJECT_TASK,10);
+
// 1. get template list
data.getTemplateList();
+ progressMonitor.update(1);
// 2. copy web project template
copyWebProjectTemplate();
+ progressMonitor.update(3);
// 3. copy the dependent library
copyLibrary();
+ progressMonitor.update(3);
// 4. generate configuration
copyConfiguration();
+ progressMonitor.update(1);
// 5. generate file from template
processOption();
-
+ progressMonitor.update(1);
+
// 6. generate tizen description file
makeTizenDescription();
+ progressMonitor.update(1);
+
+ progressMonitor.endTask();
return data;
}
-
+
public void setTemplateName(String projectName)
{
this.data.setTemplateName(projectName);
{
this.data.setOutputName(projectName);
}
-
+
public String getOutputName()
{
return this.data.getOutputName();
// extract jar file contained built-in library
String rootPath = pg.extractBuiltinJarFiles(WebConstant.BUILTIN_TEMPLATE_LIBRARIES_FOLDER);
-
+
// get library pool
libraryPool = new TizenTemplateLibrariesPool(profileInfo, rootPath);
// TODO Auto-generated catch block
log.error(e.getMessage());
}
-
+
if (tizenAppTemplate == null)
return;
{
buildModelForSupportLibraries(supportLibraries);
}
-
+
// building option model
for (OptionGroup optionGroup : options.getOptionGroup())
{
// group1
}
}
-
+
// building config model
buildModelForConfigFile();
/**
* find widget configuration file in a project
- *
+ *
* @return the configuration file. null if no such file exists.
*/
private File findConfiguration()
else
return null;
}
-
+
private void makeTizenDescription()
{
// get latest profile info
ProfileInfo latestProfileInfo = InstallPathConfig.getLatestProfileInfo();
-
+
ObjectFactory objFactory = new ObjectFactory();
Tproject tProject = objFactory.createTproject();
Platform platform = objFactory.createPlatform();
platform.setName(latestProfileInfo.getLatestPlatformName());
platforms.getPlatform().add(platform);
tProject.setPlatforms(platforms);
-
- // make tizen project description file
+
+ // make tizen project description file
File file = new File(data.getDestTizenProjectDescriptionFile());
-
+
// marshall
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName());
/**
* get widget configuration file in a project
- *
+ *
* @return the configuration file. default configuration file if no such
* file exists.
*/
/**
* initialize Widget configuration with app ID generation.
- *
+ *
* @param monitor
* {@link IProgressMonitor}. if this is null,
* {@link NullProgressMonitor} is used.
/**
* Widget URI getter for the ID of configuration
- *
+ *
* @return Widget URI String in the preferences. If cannot get this, return
* default URI String.
* {@value org.tizen.web.common.WebConstant#WIDGET_BASE_IDENTIFIER}
class ProjectGenUtil
{
protected final Logger logger = LoggerFactory.getLogger( getClass() );
-
+
private final String CONFIG_FILE = "/config/Tizen/config.xml";
private final String CONFIG_EXTRA_TIZEN_INFO = " <tizen:application id=\"${APP_ID}.${WIDGET_ID}\" package=\"${APP_ID}\" required_version=\"2.2\"/>";
private final String CONFIG_EXTRA_NAME_INFO = " <name>${WIDGET_ID}</name>";
/* extract jar file and get the extracted folder path
* when jar file is already extracted in a folder, return the folder path.
- * folder path has the name appended '_dir' to jar file name.
+ * folder path has the name appended '_dir' to jar file name.
*/
-
+
public String extractBuiltinJarFiles(String resource)
{
URL url = getClass().getClassLoader().getResource(resource);
-
+
if(url == null){
logger.error("not found jar file");
return null;
}
-
+
String urlPath = url.getPath();
-
+
String templateLibPath = urlPath + File.separator;
-
+
// if the url is not expressed jar file
if(urlPath.contains("!"))
{
String urlPathTemp = urlPath.replaceAll("file:", "");
String jarPath = urlPathTemp.substring(0, urlPathTemp.lastIndexOf('!'));
-
+
String destDirPath = jarPath + "_dir";
-
+
templateLibPath = destDirPath + File.separator + resource + File.separator;
-
- // make it if the destination directory is not created.
+
+ // make it if the destination directory is not created.
File destDirFile = new File(destDirPath);
if (destDirFile.isDirectory())
{
{
destDirFile.mkdir();
}
-
+
try
{
JarFile jar = new JarFile(jarPath);
logger.error(e.getMessage());
}
}
-
+
return templateLibPath;
}
}