categoryId="rtosBuild.commands.category"
id="rtosBuild.commands.buildCommand">
</command>
-
<command
- name="Flash"
categoryId="rtosBuild.commands.category"
- id="rtosBuild.commands.flashCommand">
+ id="rtosBuild.commands.flashCommand"
+ name="Flash">
+ </command>
+ <category
+ id="rtosBuild.commands.clean.category"
+ name="Rtos Clean Category">
+ </category>
+ <command
+ categoryId="rtosBuild.commands.clean.category"
+ id="rtosBuild.commands.cleanCommand"
+ name="Clean">
</command>
+
</extension>
</reference>
</enabledWhen>
</handler>
+ <handler
+ class="org.tizen.rt.ide.handlers.CleanHandler"
+ commandId="rtosBuild.commands.cleanCommand">
+ <enabledWhen>
+ <reference
+ definitionId="org.tizen.rt.product.hasNature">
+ </reference>
+ </enabledWhen>
+ </handler>
<!-- modify class-->
<handler
contextId="org.eclipse.ui.contexts.window"
sequence="M1+7"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </key>
+ <key
+ commandId="rtosBuild.commands.cleanCommand"
+ contextId="org.eclipse.ui.contexts.window"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+8">
</key>
</extension>
<menuContribution
locationURI="menu:project?after=additions">
<separator
- name="rtosBuild.menus.sampleMenu">
+ name="rtosBuild.menus.sampleMenu1">
</separator>
<command
commandId="rtosBuild.commands.buildCommand"
</reference>
</visibleWhen>
</command>
+ <separator
+ name="rtosBuild.menus.sampleMenu2">
+ </separator>
+ <command
+ commandId="rtosBuild.commands.cleanCommand"
+ icon="icons/tools/tool_build_nor.png"
+ id="rtosBuild.menus.cleanCommand"
+ mnemonic="S">
+ <visibleWhen
+ checkEnabled="true">
+ <reference
+ definitionId="org.tizen.rt.product.rt_perspective">
+ </reference>
+ </visibleWhen>
+ </command>
</menuContribution>
<menuContribution
disabledIcon="icons/tools/tool_build_dim.png"
icon="icons/tools/tool_build_nor.png"
id="rtosBuild.toolbars.buildCommand"
- tooltip="build rtos project">
+ tooltip="Build TizenRT Project">
<visibleWhen
checkEnabled="true">
<reference
disabledIcon="icons/tools/tool_flash_dim.png"
icon="icons/tools/tool_flash_nor.png"
id="rtosBuild.toolbars.flsahCommand"
- tooltip="flash rtos project">
+ tooltip="Flash TizenRT Project">
<visibleWhen
checkEnabled="true">
<reference
</command>
</toolbar>
</menuContribution>
+ <menuContribution
+ locationURI="popup:org.tizen.rt.product.RtProjectExplorer?before=group.build">
+ <separator
+ name="rtosClean.menus.sampleMenu1">
+ </separator>
+ <command
+ commandId="rtosBuild.commands.buildCommand">
+ </command>
+ <command
+ commandId="rtosBuild.commands.flashCommand"
+ mnemonic="S">
+ </command>
+ <separator
+ name="rtosClean.menus.sampleMenu1">
+ </separator>
+ <command
+ commandId="rtosBuild.commands.cleanCommand">
+ </command>
+ </menuContribution>
</extension>
<extension
id="product"
</extension>
<extension
point="org.eclipse.ui.navigator.viewer">
+ <viewer
+ helpContext="org.eclipse.ui.project_explorer_context"
+ viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+ <popupMenu
+ allowsPlatformContributions="true"
+ id="org.tizen.rt.product.RtProjectExplorer">
+ <insertionPoint
+ name="group.new">
+ </insertionPoint>
+ <insertionPoint
+ name="group.build"
+ separator="true">
+ </insertionPoint>
+ <insertionPoint
+ name="group.launch"
+ separator="true">
+ </insertionPoint>
+ <insertionPoint
+ name="group.validate"
+ separator="true">
+ </insertionPoint>
+ <insertionPoint
+ name="group.edit"
+ separator="true">
+ </insertionPoint>
+ <insertionPoint
+ name="group.reorganize">
+ </insertionPoint>
+ <insertionPoint
+ name="additions"
+ separator="true">
+ </insertionPoint>
+ <insertionPoint
+ name="group.open"
+ separator="true">
+ </insertionPoint>
+ <insertionPoint
+ name="group.openWith">
+ </insertionPoint>
+ <insertionPoint
+ name="group.port"
+ separator="true">
+ </insertionPoint>
+ <insertionPoint
+ name="group.search"
+ separator="true">
+ </insertionPoint>
+ <insertionPoint
+ name="group.properties"
+ separator="true">
+ </insertionPoint>
+ </popupMenu>
+ <options>
+ <property
+ name="org.eclipse.ui.navigator.customizeViewDialogHelpContext"
+ value="org.eclipse.ui.project_explorer_customization_dialog">
+ </property>
+ </options>
+ </viewer>
<viewerActionBinding
viewerId="org.tizen.rt.product.RtProjectExplorer">
<includes>
--- /dev/null
+/*
+ * Common
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Daeryong Park <bdragon.park@samsung.com>
+ * Hyeongseok Heo <harry.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.rt.ide;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.tizen.rt.ide.console.ConsoleManager;
+import org.tizen.rt.ide.util.MacroUtil;
+import org.tizen.rt.ide.util.ProcUtil;
+import org.tizen.rt.ide.util.SDKUtil;
+import org.tizen.rt.ide.util.XMLUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @since 2017. 5. 17.
+ * @author Daeryong Park {@literal <bdragon.park@samsung.com>}
+ */
+public class CleanCommand {
+
+ private static final String FILE_NAME_BUILD_SCRIPT = "build.xml"; //$NON-NLS-1$
+
+ private List<String> resultBuildExecute = new ArrayList<String>();
+
+ private class BuildScript {
+ public String cmdStr;
+ public String curDir;
+ public boolean isShellCmd;
+ public String shell;
+
+ public BuildScript(String cmdStr, String curDir, boolean isShellCmd, String shell) {
+ this.cmdStr = cmdStr;
+ this.curDir = curDir;
+ this.isShellCmd = isShellCmd;
+ this.shell = shell;
+ }
+ }
+
+ private Map<String, BuildScript> getBuildScripts(File buildScriptFile, Map<String, String> macros) {
+ Document doc = XMLUtil.readXML(buildScriptFile);
+
+ NodeList commands = XMLUtil.getDOMNodes(doc.getDocumentElement(), "/sbi/build/command");
+ if (commands == null || commands.getLength() <= 0) {
+ return null;
+ }
+
+ Map<String, BuildScript> scripts = new HashMap<String, BuildScript>();
+
+ int len = commands.getLength();
+ for (int i = 0; i < len; i++) {
+ Node node = commands.item(i);
+ if (node instanceof Element) {
+ Element elm = (Element) node;
+
+ String name = elm.getAttribute("name");
+ String cmd = elm.getAttribute("command");
+ cmd = MacroUtil.processMacro(cmd, macros);
+ String curdir = elm.getAttribute("curdir");
+ curdir = MacroUtil.processMacro(curdir, macros);
+ String shellcmd = elm.getAttribute("shellcmd");
+ boolean isShellCmd = Boolean.valueOf(shellcmd);
+ String shell = elm.getAttribute("shell");
+
+ scripts.put(name, new BuildScript(cmd, curdir, isShellCmd, shell));
+ }
+ }
+
+ return scripts;
+ }
+
+ protected int executeClean(IProject project, ConsoleManager consoleManager, IProgressMonitor monitor) {
+ String activeProjectName = project.getLocation().toString();
+ String homePath = activeProjectName;
+
+ String sdkPath = SDKUtil.getSdkPath();
+ File buildScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts"
+ + File.separator + FILE_NAME_BUILD_SCRIPT);
+ if (!buildScriptFile.exists()) {
+ buildScriptFile = new File(homePath, FILE_NAME_BUILD_SCRIPT);
+ if (!buildScriptFile.exists()) {
+ return 1;
+ }
+ }
+
+ Map<String, String> macros = new HashMap<String, String>();
+ macros.put("PROJECT_PATH", homePath);
+
+ Map<String, BuildScript> scripts = getBuildScripts(buildScriptFile, macros);
+
+ ProcessBuilder pb = ProcUtil.genProcessBuilder(null);
+
+ String buildCmdName = "clean";
+ BuildScript script = scripts.get(buildCmdName);
+ if (script == null) {
+ consoleManager.println("Cannot found clean command : " + buildCmdName); //$NON-NLS-1$
+ return 1;
+ }
+ int result = ProcUtil.executeProcess(pb, new String[] { script.cmdStr }, script.isShellCmd, script.shell,
+ script.curDir, consoleManager, resultBuildExecute);
+
+ monitor.worked(1);
+ if (result != 0) {
+ return result;
+ }
+
+ return result;
+ }
+
+}
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
return processResult(result, consoleManager);
}
+ public static boolean runClean(IProject project, ConsoleManager consoleManager, IProgressMonitor monitor) {
+ if (consoleManager == null) {
+ logger.error("ConsoleManager is null"); //$NON-NLS-1$
+ return false;
+ }
+ CleanCommand cleanCommand = new CleanCommand();
+ int result = cleanCommand.executeClean(project, consoleManager, monitor);
+
+ return processResult(result, consoleManager);
+ }
+
/**
* Print success status to the Console and if failed print error messages to the Console
* @param result
private static boolean processResult(int result, ConsoleManager consoleManager) {
boolean success = result == 0;
if (consoleManager != null) {
- consoleManager.print("[STATUS] ", SWT.BOLD, ResourceManager.BLACK); //$NON-NLS-1$
+ consoleManager.print("[STATUS] ", SWT.BOLD, ResourceManager.INTENSE_BLACK); //$NON-NLS-1$
if (success) { // success
- consoleManager.println(SUCCEED, SWT.BOLD, ResourceManager.GREEN);
+ consoleManager.println(SUCCEED, SWT.BOLD, ResourceManager.INTENSE_GREEN);
} else { // fail
- consoleManager.println(FAILED, SWT.BOLD, ResourceManager.RED);
+ consoleManager.println(FAILED, SWT.BOLD, ResourceManager.INTENSE_RED);
}
// consoleManager.println("[RESULT]" + result.toString(), SWT.BOLD,
// ResourceManager.BLACK);
--- /dev/null
+/*
+ * Common
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Daeryong Park <bdragon.park@samsung.com>
+ * Hyeongseok Heo <harry.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.rt.ide.handlers;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.progress.IProgressService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.rt.ide.Activator;
+import org.tizen.rt.ide.RtosCommandManager;
+import org.tizen.rt.ide.console.ConsoleManager;
+import org.tizen.rt.ide.util.ResourceUtil;
+import org.tizen.rt.ide.util.Util;
+
+/**
+ * @since 2017. 5. 16.
+ * @author Daeryong Park {@literal <bdragon.park@samsung.com>}
+ */
+public class CleanHandler extends AbstractHandler {
+
+ private final Logger logger = LoggerFactory.getLogger(CleanHandler.class);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IProject project = ResourceUtil.getCurrentProject();
+ if (project == null) {
+ return null;
+ }
+
+ boolean ok = MessageDialog.openQuestion(Util.getDisplay().getActiveShell(),
+ "Clean Project", "Are you sure you want to clean selected project?"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (!ok) {
+ return null;
+ }
+
+ IWorkbench workbench = Activator.getDefault().getWorkbench();
+ IProgressService progressService = workbench.getProgressService();
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ monitor.beginTask("Clean Project", 3); //$NON-NLS-1$
+
+ RtosCommandManager.runClean(project, new ConsoleManager(true), monitor);
+ monitor.worked(1);
+
+ try {
+ project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ monitor.worked(1);
+ } catch (CoreException e) {
+ logger.error(e.getMessage(), e);
+ }
+
+ monitor.done();
+ }
+ };
+ try {
+ progressService.busyCursorWhile(runnable);
+ } catch (InvocationTargetException e) {
+ logger.error(e.getMessage(), e);
+ } catch (InterruptedException e) {
+ logger.error(e.getMessage(), e);
+ }
+
+ return null;
+ }
+
+}
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ return null;
+ }
ISelectionService selectionService = window.getSelectionService();
if (selectionService != null) {
ISelection selection = selectionService.getSelection();