package org.tizen.common.ui.wizards;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.tizen.common.ITizenProject;
-import org.tizen.common.core.application.ProfileInfo;
-import org.tizen.common.core.application.TizenProjectDescription;
+import static org.slf4j.LoggerFactory.*;
import org.tizen.common.ui.Activator;
import org.tizen.common.util.ImageUtil;
-import org.tizen.common.util.ProjectUtil;
/**
* Base wizard class for Tizen IDE.
*
*/
public class TizenCommonWizard extends BasicNewResourceWizard implements IExecutableExtension {
- final Logger logger = LoggerFactory.getLogger(TizenCommonWizard.class);
+
+ protected final Logger logger = getLogger( getClass() );
protected IConfigurationElement fConfigElement;
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
fConfigElement = config;
}
-
- protected void createTizenProjectDescription(IProject project, ProfileInfo platformInfo) {
- if (project == null)
- throw new IllegalArgumentException("project can not be null");
- if (platformInfo == null)
- throw new IllegalArgumentException("platformInfo can not be null");
- ITizenProject tizenPrj = ProjectUtil.getTizenProject(project);
- if (tizenPrj != null) {
- TizenProjectDescription desc = new TizenProjectDescription(project);
- desc.setPlatform(platformInfo);
- tizenPrj.setDescription(desc);
- }
- }
}
import org.tizen.common.ITizenProjectAdapter;
import org.tizen.common.ITizenWebProject;
import org.tizen.common.TizenProjectType;
+import org.tizen.common.core.application.ProfileInfo;
import org.tizen.common.core.application.TizenProjectDescription;
/**
/**
* Returns {@link ITizenProject} object for the project.
* @param project
- * @return {@link ITizenProject}
+ * @return {@link ITizenProject}. If not found, return null.
*/
- public static ITizenProject getTizenProject(IProject project, Class adapter) {
- if (project == null)
- throw new IllegalArgumentException("Project can not be null");
- ITizenProject tizenProject = (ITizenProject) AdapterUtil.getAdapter(project, adapter);
- if ( tizenProject == null ) {
- logger.warn("cannot get adapter of " + project + " (adapterType - " + adapter + ")");
+ public static ITizenProject getTizenProject(IProject project, Class<? extends ITizenProject> adapter) {
+ Assert.notNull( project, "Project can not be null" );
+
+ Object tizenProject = AdapterUtil.getAdapter( project, adapter );
+ if ( tizenProject instanceof ITizenProject ) {
+ return (ITizenProject) tizenProject;
}
- return tizenProject;
+
+ logger.warn("cannot get adapter of " + project + " (adapterType - " + adapter + ")");
+ return null;
}
/**
/**
* Returns {@link TizenProjectDescription} object for the given project.
- * @return {@link TizenProjectDescription}
+ * @return {@link TizenProjectDescription}. If not found, return null.
*/
public static TizenProjectDescription getTizenProjectDescription(IProject project) {
ITizenProject tizenProject = getTizenProject( project );
- if ( tizenProject == null ) {
- return null;
- }
- TizenProjectDescription tizenDesc = tizenProject.getDescription();
- if ( tizenDesc == null ) {
- return null;
+ return ( tizenProject == null ) ? null : tizenProject.getDescription();
+ }
+
+ /**
+ * Create a Tizen project description (.tproject)
+ *
+ * @param project current project
+ * @param platformInfo
+ * @return If the project is a Tizen project and the creation succeed, return true.
+ */
+ public static boolean createTizenProjectDescription(IProject project, ProfileInfo platformInfo) {
+ Assert.notNull( project, "project can not be null" );
+ Assert.notNull( project, "platformInfo can not be null" );
+
+ ITizenProject tizenPrj = getTizenProject( project );
+ if ( tizenPrj != null ) {
+ TizenProjectDescription tPrjDesc = new TizenProjectDescription( project );
+ tPrjDesc.setPlatform( platformInfo );
+
+ return tizenPrj.setDescription( tPrjDesc );
}
- return tizenDesc;
+
+ return false;
}
/**
+ * Returns {@link TizenProjectType} object for the given project.
+ * @param project
+ * @param adapter
+ * @return {@link TizenProjectType}. If not found, return null.
+ */
+ public static TizenProjectType getTizenProjectType(IProject project, Class<? extends ITizenProject> adapter) {
+ ITizenProject tProject = getTizenProject( project, adapter );
+ return ( tProject == null ) ? null : tProject.getTizenProjectType();
+ }
+
+ /**
* Checks whether project is for Tizen native or not.
* @param project
* @return {@code true} if it is Tizen native project
*/
public static boolean isTizenNativeProject(IProject project) {
- ITizenProject adapter = getTizenProject(project, ITizenNativeProject.class);
- if ( adapter == null ) {
- return false;
- }
- return (adapter.getTizenProjectType() == null) ? false : adapter.getTizenProjectType().isNativeProject();
+ TizenProjectType type = getTizenProjectType( project, ITizenNativeProject.class );
+ return ( type == null ) ? false : type.isNativeProject();
}
/**
* @return {@code true} if it is Tizen web project
*/
public static boolean isTizenWebProject(IProject project) {
- ITizenProject adapter = getTizenProject(project, ITizenWebProject.class);
- if ( adapter == null ) {
- return false;
- }
- return (adapter.getTizenProjectType() == null) ? false : adapter.getTizenProjectType().isWebProject();
+ TizenProjectType type = getTizenProjectType( project, ITizenWebProject.class );
+ return ( type == null ) ? false : type.isWebProject();
}
/**