From 9f02d6246f6eefc8eb2ba2d1d4dccfa4d915f4a9 Mon Sep 17 00:00:00 2001 From: Gun Kim Date: Wed, 29 May 2013 16:20:32 +0900 Subject: [PATCH] [Title] ProjectDecorator is moved from native-eplugin & add projectType of unittest project. [Type] [Module] [Priority] [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] Change-Id: Ib59b4df1ead7da09795a7f6c834ffe524299e6c1 --- org.tizen.common/plugin.xml | 16 +++ .../src/org/tizen/common/TizenProjectType.java | 4 + .../org/tizen/common/sdb/command/SdbCommand.java | 25 +++-- .../common/ui/LightweightProjectDecorator.java | 113 +++++++++++++++++++++ .../src/org/tizen/common/util/ProjectUtil.java | 14 +++ 5 files changed, 161 insertions(+), 11 deletions(-) create mode 100644 org.tizen.common/src/org/tizen/common/ui/LightweightProjectDecorator.java diff --git a/org.tizen.common/plugin.xml b/org.tizen.common/plugin.xml index 6721fe5..050597d 100644 --- a/org.tizen.common/plugin.xml +++ b/org.tizen.common/plugin.xml @@ -401,5 +401,21 @@ + + + + Indicates whether a project is referenced + + + + + + diff --git a/org.tizen.common/src/org/tizen/common/TizenProjectType.java b/org.tizen.common/src/org/tizen/common/TizenProjectType.java index c3e16dd..137fdb7 100644 --- a/org.tizen.common/src/org/tizen/common/TizenProjectType.java +++ b/org.tizen.common/src/org/tizen/common/TizenProjectType.java @@ -38,6 +38,7 @@ public enum TizenProjectType { TIZEN_CPP_SERVICE_APPLICATION(false, false, true), TIZEN_CPP_SHAREDLIBRARY(false, false, false), TIZEN_CPP_STATICLIBRARY(false, false, false), + TIZEN_CPP_UNITTEST(true, false, false), TIZEN_PLATFORM_PROJECT(false, false, false), TIZEN_WEB_APPLICATION(false, true, false), @@ -88,6 +89,7 @@ public enum TizenProjectType { case TIZEN_CPP_SERVICE_APPLICATION : case TIZEN_CPP_SHAREDLIBRARY : case TIZEN_CPP_STATICLIBRARY : + case TIZEN_CPP_UNITTEST : case TIZEN_PLATFORM_PROJECT : return true; default : @@ -106,6 +108,7 @@ public enum TizenProjectType { case TIZEN_CPP_UI_APPLICATION : case TIZEN_C_SERVICE_APPLICATION : case TIZEN_CPP_SERVICE_APPLICATION : + case TIZEN_CPP_UNITTEST : return true; default : break; @@ -151,6 +154,7 @@ public enum TizenProjectType { switch (this) { case TIZEN_CPP_UI_APPLICATION : case TIZEN_CPP_SERVICE_APPLICATION : + case TIZEN_CPP_UNITTEST: return true; default : break; diff --git a/org.tizen.common/src/org/tizen/common/sdb/command/SdbCommand.java b/org.tizen.common/src/org/tizen/common/sdb/command/SdbCommand.java index 16239fa..45c9c72 100644 --- a/org.tizen.common/src/org/tizen/common/sdb/command/SdbCommand.java +++ b/org.tizen.common/src/org/tizen/common/sdb/command/SdbCommand.java @@ -80,8 +80,20 @@ public class SdbCommand { public Process runLaunchCommand(String command, boolean isBlock) throws IOException { Process process = null; + + + SmartDevelopmentBridge sdb = SmartDevelopmentBridge.getBridge(); + if (sdb == null) { + throw new IOException("Cannot find sdb command"); + } + String sdbPath = sdb.getSdbOsLocation(); + if (sdbPath == null) { + throw new IOException("Cannot find sdb command"); + } + + final String sdbCommand = String.format("%s -s %s launch %s", sdbPath, device.getSerialNumber(), command); if (console != null) { - console.println("$ sdb launch " + command); + console.println(String.format("$ %s", sdbCommand)); } if ( isBlock ) { @@ -91,16 +103,7 @@ public class SdbCommand { this.commandOutput = receiver.getCommandOutput(); } else { - SmartDevelopmentBridge sdb = SmartDevelopmentBridge.getBridge(); - if (sdb == null) { - throw new IOException("Cannot find sdb command"); - } - String sdbPath = sdb.getSdbOsLocation(); - if (sdbPath == null) { - throw new IOException("Cannot find sdb command"); - } - command = String.format("%s -s %s launch %s", sdbPath, device.getSerialNumber(), command); - process = Runtime.getRuntime().exec(command); + process = Runtime.getRuntime().exec(sdbCommand); } return process; diff --git a/org.tizen.common/src/org/tizen/common/ui/LightweightProjectDecorator.java b/org.tizen.common/src/org/tizen/common/ui/LightweightProjectDecorator.java new file mode 100644 index 0000000..899cad5 --- /dev/null +++ b/org.tizen.common/src/org/tizen/common/ui/LightweightProjectDecorator.java @@ -0,0 +1,113 @@ +/* +* Common +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: +* Kangho Kim +* +* 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.common.ui; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.viewers.IDecoration; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ILightweightLabelDecorator; +import org.tizen.common.ITizenProject; +import org.tizen.common.TizenProjectType; +import org.tizen.common.util.ProjectUtil; +import org.tizen.common.util.StringUtil; + +public class LightweightProjectDecorator implements ILightweightLabelDecorator { + private static final String SUFFIX_ROOT = " [Root]"; + private static final String SUFFIX_REFERENCED = " [with %s]"; + //private final ImageDescriptor OVERLAY = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/lock.gif"); + + public LightweightProjectDecorator() { + super(); + } + + @Override + public void decorate(Object element, IDecoration decoration) { + if (element instanceof IProject) { + IProject project = (IProject) element; + /* + try { + if (project.getReferencedProjects().length > 0) { + //decoration.addOverlay(OVERLAY, IDecoration.BOTTOM_LEFT); + decoration.addSuffix(SUFFIX_ROOT); + } + } catch (CoreException e) { + } + */ + + ITizenProject tizenProject = ProjectUtil.getTizenProject(project); + if ( tizenProject == null ) { + return; + } + TizenProjectType projectType = tizenProject.getTizenProjectType(); + if ( projectType == null || projectType.isReferencedProject() == false ) { + return; + } + + IProject[] refPrjs = project.getReferencingProjects(); + if (refPrjs != null && refPrjs.length > 0) { + String refs = ""; + tizenProject = null; + for (int i = 0; i < refPrjs.length; i++) { + tizenProject = ProjectUtil.getTizenProject(refPrjs[i]); + if ( tizenProject == null ) { + continue; + } + projectType = tizenProject.getTizenProjectType(); + if ( projectType == null || projectType.isRootProject() == false ) { + continue; + } + + if ( StringUtil.isEmpty(refs) ) { + refs += refPrjs[i].getName(); + } + else { + refs += "," + refPrjs[i].getName(); + } + } + if ( !StringUtil.isEmpty(refs) ) { + decoration.addSuffix(String.format(SUFFIX_REFERENCED, refs)); + } + } + } + } + + @Override + public void dispose() { + } + + @Override + public void addListener(ILabelProviderListener listener) { + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + } +} diff --git a/org.tizen.common/src/org/tizen/common/util/ProjectUtil.java b/org.tizen.common/src/org/tizen/common/util/ProjectUtil.java index 486b926..6bdcad6 100644 --- a/org.tizen.common/src/org/tizen/common/util/ProjectUtil.java +++ b/org.tizen.common/src/org/tizen/common/util/ProjectUtil.java @@ -230,6 +230,20 @@ public class ProjectUtil { throw new IllegalArgumentException("Project can not be adapted (obj - " + obj + ", adapter - " + adapter + ")"); return (ITizenProject) obj; } + + /** + * Returns {@link ITizenProject} object for the given project. + * @return {@link ITizenProject} + */ + public static ITizenProject getTizenProject(IProject project) { + if ( ProjectUtil.isTizenNativeProject(project) ) { + return getTizenProject(project, ITizenNativeProject.class); + } + else if ( ProjectUtil.isTizenWebProject(project) ) { + return ProjectUtil.getTizenProject(project, ITizenWebProject.class); + } + return null; + } /** * Checks whether project is for Tizen native or not. -- 2.7.4