--- /dev/null
+/*
+ * Web IDE - Command Line Interface
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GyeongSeok Seo <gyeongseok.seo@samsung.com>
+ * BonYong Lee <bonyong.lee@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.cli.exec;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.tizen.common.core.command.Prompter;
+import org.tizen.common.core.command.prompter.Option;
+import org.tizen.common.core.command.sdb.DevicesSdbCommand;
+import org.tizen.common.core.command.sdb.SmartDevelopmentBridgeManager;
+import org.tizen.common.util.ArrayUtil;
+import org.tizen.common.util.StringUtil;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.SmartDevelopmentBridge;
+
+public class
+TargetDeviceSelector
+{
+ protected Prompter prompter;
+
+ public TargetDeviceSelector(Prompter prompter) {
+ this.prompter = prompter;
+ }
+
+ protected SmartDevelopmentBridgeManager createSDBManager() {
+ return new SmartDevelopmentBridgeManager();
+ }
+
+ protected void printDeviceList( IDevice[] devices ) {
+ prompter.notify( "currnet connected target List\n" );
+ prompter.notify( "-----------------------------\n" );
+ for( int i = 0; i < devices.length; i++ ) {
+ prompter.notify( (i+1) + ") " + devices[i].toString() +"\n" );
+ }
+ }
+
+ public IDevice[] getConnectDevices() {
+ SmartDevelopmentBridgeManager mgr = createSDBManager();
+ return mgr.getDevices();
+ }
+
+ public boolean isDeviceConnected() {
+ boolean isConnected = false;
+ IDevice[] devices = getConnectDevices();
+ if ( devices != null ) {
+ isConnected = true;
+ }
+
+ return isConnected;
+ }
+
+ public boolean isDeviceConnected( String name ) {
+ boolean isConnected = false;
+ IDevice[] devices = getConnectDevices();
+
+ for( int i = 0; i < devices.length; i++ ) {
+ if ( name.equals( devices[i].toString() ) ) {
+ isConnected = true;
+ break;
+ }
+ }
+
+ return isConnected;
+ }
+
+ public boolean isDeviceConnected( IDevice device ) {
+ boolean isConnected = false;
+ IDevice[] devices = getConnectDevices();
+
+ if ( ArrayUtil.contains( devices, device) ) {
+ isConnected = true;
+ }
+ return isConnected;
+ }
+
+ public IDevice getDevice( String name ) {
+ IDevice device = null;
+ IDevice[] devices = getConnectDevices();
+ for( int i = 0; i < devices.length; i++ ) {
+ if ( name.equals( devices[i].toString() ) ) {
+ device = devices[i];
+ break;
+ }
+ }
+ return device;
+ }
+
+ public IDevice selectDevice() {
+ IDevice selectDevice = null;
+ IDevice[] devices = getConnectDevices();
+
+ if( devices == null ) {
+ return selectDevice;
+ }
+
+ if ( devices.length == 1 ) {
+ selectDevice = ArrayUtil.pickupFirst( devices );
+ } else if ( devices.length > 1 ) {
+ Option yes = new Option( "Yes" );
+ Option no = new Option( "No", true );
+
+ final Option option = prompter.interact(
+ MessageFormat.format( "device is not selected\n" +
+ "[{0}] device select and\n" +
+ "Do you want to be continue?", devices[0].toString() ),
+ yes,
+ no
+ );
+
+ if ( yes.equals(option) ) {
+ selectDevice = ArrayUtil.pickupFirst( devices );
+ } else if ( no.equals( option ) ) {
+ printDeviceList( devices );
+
+ Option num = new Option( "Num" );
+
+ final Option op = prompter.interact(
+ "select device or cancel process\n",
+ num,
+ no
+ );
+
+ if( no.equals( op ) ) {
+ prompter.notify( "Process is canceled, please selected device" );
+
+ } else {
+ // TODO : Needed implement - select device using option value
+ }
+ }
+ }
+
+ return selectDevice;
+ }
+}
--- /dev/null
+/*
+* Web IDE - Command Line Interface
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* GyeongSeok Seo <gyeongseok.seo@samsung.com>
+* BonYong Lee <bonyong.lee@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.cli.exec;
+
+import java.util.List;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.tizen.common.core.command.ExecutionContext;
+import org.tizen.common.core.command.Prompter;
+import org.tizen.sdblib.IDevice;
+
+/**
+ * <p>
+ * WRTLauncher.
+ *
+ * class for simple WRT command.
+ *
+ * provide {@link ExecutionContext} for command line
+ * </p>
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ */
+public class
+WRTLauncher
+extends AbstractLauncher
+{
+ /**
+ * <p>
+ * Option for select device
+ * </p>
+ */
+ protected static final String OPT_DEVICE = "select device";
+
+ /**
+ * <p>
+ * Description for select device
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_DEVICE
+ */
+ protected static final String DESC_DEVICE = "Command is performed of selected device";
+
+ /**
+ * <p>
+ * Target device
+ *
+ * command is running in this device
+ * </p>
+ */
+ protected IDevice device = null;
+
+ /**
+ * Get target device
+ *
+ * @return device
+ */
+ public IDevice getDevice() {
+ return device;
+ }
+
+ /**
+ * Set target device
+ *
+ * @param device
+ */
+ public void setDevice(IDevice device) {
+ this.device = device;
+ }
+
+ /**
+ * {@link Options} for usage
+ *
+ * @return defined {@link Options}
+ */
+ @SuppressWarnings("static-access")
+ protected
+ Options
+ getOptions()
+ {
+ final Options opts = super.getOptions();
+ opts.addOption( OptionBuilder.hasArg().withLongOpt( OPT_DEVICE ).withDescription( DESC_DEVICE ).create( OPT_DEVICE.substring( 0, 1 ) ) );
+
+ return opts;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.AbstractLauncher#execute(org.apache.commons.cli.CommandLine)
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void execute(CommandLine cmdLine) throws Exception {
+ final Prompter prompter = getPrompter();
+ final List<String> args = cmdLine.getArgList();
+ final TargetDeviceSelector deviceSelector = new TargetDeviceSelector(prompter);
+ logger.trace( "arguments :{}", args );
+
+ logger.trace("check connected devices");
+ if ( !deviceSelector.isDeviceConnected() ) {
+ prompter.notify( "Device is not connected. Process is canceled" );
+ return ;
+ }
+
+ int nArgs = args.size();
+ // user using device select option
+ if ( nArgs > 0 ) {
+ // user select device check
+ String deviceName = cmdLine.getOptionValue( OPT_DEVICE );
+ logger.debug( "Device option :{}", deviceName );
+
+ setDevice( deviceSelector.getDevice( deviceName ) );
+ }
+ // user not using device select option
+ else if ( nArgs == 0 ) {
+ logger.trace( "user can't use device select option" );
+ setDevice( deviceSelector.selectDevice() );
+ }
+ }
+}
--- /dev/null
+/*
+* Web IDE - Command Line Interface
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* GyeongSeok Seo <gyeongseok.seo@samsung.com>
+* BonYong Lee <bonyong.lee@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.cli.exec.debug;
+
+import java.text.MessageFormat;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.tizen.cli.exec.WRTLauncher;
+import org.tizen.common.core.command.Executor;
+import org.tizen.common.core.command.Prompter;
+import org.tizen.common.core.command.sdb.PushSdbCommand;
+import org.tizen.common.file.FileHandler;
+import org.tizen.common.file.FileHandler.Attribute;
+import org.tizen.web.launch.cli.command.CheckInstallCommand;
+import org.tizen.web.launch.cli.command.DebugCommand;
+import org.tizen.web.launch.cli.command.InstallCommand;
+import org.tizen.web.launch.cli.command.RunCommand;
+
+/**
+ * Command Line Interface for debug run widget in target
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ */
+public class
+Main
+extends WRTLauncher
+{
+ /**
+ * <p>
+ * Option for target widget file
+ * </p>
+ */
+ protected static final String OPT_WIDGETFILE = "target widget file";
+
+ /**
+ * <p>
+ * Description for target widget file
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_WIDGETFILE
+ */
+ protected static final String DESC_WIDGETFILE = "Command is performed of widget file install in target";
+
+ /**
+ * <p>
+ * Option for target widget id
+ * </p>
+ */
+ protected static final String OPT_WIDGETID = "target widget id";
+
+ /**
+ * <p>
+ * Description for target widget id
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_WIDGETID
+ */
+ protected static final String DESC_WIDGETID = "Command is performed of widget id uninstall in target, widget id is user written id in config.xml";
+
+ /**
+ * Entry point for cli main
+ *
+ * @param args user input parameter
+ *
+ * @throws Exception If unhandled exception occur
+ */
+ public static
+ void
+ main(
+ final String[] args
+ )
+ throws Exception
+ {
+ final Main instance = new Main();
+ instance.run( args );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.AbstractLauncher#execute(org.apache.commons.cli.CommandLine)
+ */
+ @Override
+ protected
+ void
+ execute(
+ final CommandLine cmdLine
+ )
+ throws Exception
+ {
+ super.execute( cmdLine );
+
+ final Prompter prompter = getPrompter();
+ final FileHandler fileHandler = getFileHandler();
+ final Executor exec = getExecutor();
+
+ // device not connect then exit
+ if ( getDevice() == null ) {
+ prompter.notify( "Process is stoped, please select connect device" );
+ return ;
+ }
+
+ // local widget file path control
+ String localWidgetFileName = cmdLine.getOptionValue( OPT_WIDGETFILE );
+ String localWidgetFilePath = (String)fileHandler.get( localWidgetFileName, Attribute.PATH );
+
+ // core operation
+ InstallCommand install_command = new InstallCommand();
+ install_command.setDevice( getDevice() );
+ String remotePath = install_command.getRemotePath();
+
+ PushSdbCommand push_command = new PushSdbCommand( localWidgetFilePath, remotePath );
+ push_command.setDevice( getDevice() );
+
+
+ // widget push
+ exec.execute( push_command );
+
+ // widget install
+ exec.execute( install_command );
+
+ // install check
+ String widgetID = cmdLine.getOptionValue( OPT_WIDGETID );
+ CheckInstallCommand install_check_command = new CheckInstallCommand( widgetID );
+ exec.execute( install_check_command );
+ if ( !install_check_command.isInstalled() ) {
+ prompter.notify(
+ MessageFormat.format( "Process is stoped, [{0}] widget is not installed", widgetID )
+ );
+ return ;
+ }
+
+ // widget debug run
+ DebugCommand run_command = new DebugCommand( widgetID );
+ exec.execute( run_command );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.AbstractLauncher#getOptions()
+ */
+ @Override
+ @SuppressWarnings("static-access")
+ protected
+ Options
+ getOptions()
+ {
+ final Options opts = super.getOptions();
+ opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETFILE ).withDescription( DESC_WIDGETFILE ).create( OPT_WIDGETFILE.substring( 0, 1 ) ) );
+ opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETID ).withDescription( DESC_WIDGETID ).create( OPT_WIDGETID.substring( 0, 1 ) ) );
+
+ return opts;
+ }
+}
--- /dev/null
+/*
+* Web IDE - Command Line Interface
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* GyeongSeok Seo <gyeongseok.seo@samsung.com>
+* BonYong Lee <bonyong.lee@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.cli.exec.install;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+
+import org.tizen.cli.exec.WRTLauncher;
+import org.tizen.common.core.command.Prompter;
+import org.tizen.common.core.command.sdb.PushSdbCommand;
+import org.tizen.common.file.FileHandler;
+import org.tizen.common.file.FileHandler.Attribute;
+import org.tizen.web.launch.cli.command.InstallCommand;
+
+/**
+ * Command Line Interface for install widget in target
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ */
+public class
+Main
+extends WRTLauncher
+{
+ /**
+ * <p>
+ * Option for target widget file
+ * </p>
+ */
+ protected static final String OPT_WIDGETFILE = "target widget file";
+
+ /**
+ * <p>
+ * Description for target widget file
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_WIDGETFILE
+ */
+ protected static final String DESC_WIDGETFILE = "Command is performed of widget file install in target";
+
+ /**
+ * Entry point for cli main
+ *
+ * @param args user input parameter
+ *
+ * @throws Exception If unhandled exception occur
+ */
+ public static
+ void
+ main(
+ final String[] args
+ )
+ throws Exception
+ {
+ final Main instance = new Main();
+ instance.run( args );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.AbstractLauncher#execute(org.apache.commons.cli.CommandLine)
+ */
+ @Override
+ protected
+ void
+ execute(
+ final CommandLine cmdLine
+ )
+ throws Exception
+ {
+ super.execute( cmdLine );
+
+ final Prompter prompter = getPrompter();
+ final FileHandler fileHandler = getFileHandler();
+
+ // device not connect then exit
+ if ( getDevice() == null ) {
+ prompter.notify( "Process is stoped, please select connect device" );
+ return ;
+ }
+
+ // local widget file path control
+ String localWidgetFileName = cmdLine.getOptionValue( OPT_WIDGETFILE );
+ String localWidgetFilePath = (String)fileHandler.get( localWidgetFileName, Attribute.PATH );
+
+ // core operation
+ InstallCommand install_command = new InstallCommand();
+ install_command.setDevice( getDevice() );
+ String remotePath = install_command.getRemotePath();
+
+ PushSdbCommand push_command = new PushSdbCommand( localWidgetFilePath, remotePath );
+ push_command.setDevice( getDevice() );
+
+ // widget push
+ getExecutor().execute( push_command );
+ // widget install
+ getExecutor().execute( install_command );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.AbstractLauncher#getOptions()
+ */
+ @Override
+ @SuppressWarnings("static-access")
+ protected
+ Options
+ getOptions()
+ {
+ final Options opts = super.getOptions();
+ opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETFILE ).withDescription( DESC_WIDGETFILE ).create( OPT_WIDGETFILE.substring( 0, 1 ) ) );
+
+ return opts;
+ }
+}
--- /dev/null
+/*
+* Web IDE - Command Line Interface
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* GyeongSeok Seo <gyeongseok.seo@samsung.com>
+* BonYong Lee <bonyong.lee@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.cli.exec.query;
+
+import org.apache.commons.cli.CommandLine;
+
+import org.tizen.cli.exec.WRTLauncher;
+import org.tizen.common.core.command.Prompter;
+import org.tizen.web.launch.cli.command.QueryCommand;
+
+/**
+ * Command Line Interface for show widget list in target's installed
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ */
+public class
+Main
+extends WRTLauncher
+{
+ /**
+ * Entry point for cli main
+ *
+ * @param args user input parameter
+ *
+ * @throws Exception If unhandled exception occur
+ */
+ public static
+ void
+ main(
+ final String[] args
+ )
+ throws Exception
+ {
+ final Main instance = new Main();
+ instance.run( args );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.AbstractLauncher#execute(org.apache.commons.cli.CommandLine)
+ */
+ @Override
+ protected
+ void
+ execute(
+ final CommandLine cmdLine
+ )
+ throws Exception
+ {
+ super.execute( cmdLine );
+
+ final Prompter prompter = getPrompter();
+
+ // device not connect then exit
+ if ( getDevice() == null ) {
+ prompter.notify( "Process is stoped, please select connect device" );
+ return ;
+ }
+
+ // core operation
+ QueryCommand command = new QueryCommand();
+ command.setDevice( getDevice() );
+ getExecutor().execute( command );
+ }
+}
--- /dev/null
+/*
+* Web IDE - Command Line Interface
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* GyeongSeok Seo <gyeongseok.seo@samsung.com>
+* BonYong Lee <bonyong.lee@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.cli.exec.run;
+
+import java.text.MessageFormat;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.tizen.cli.exec.WRTLauncher;
+import org.tizen.common.core.command.Executor;
+import org.tizen.common.core.command.Prompter;
+import org.tizen.common.core.command.sdb.PushSdbCommand;
+import org.tizen.common.file.FileHandler;
+import org.tizen.common.file.FileHandler.Attribute;
+import org.tizen.web.launch.cli.command.CheckInstallCommand;
+import org.tizen.web.launch.cli.command.InstallCommand;
+import org.tizen.web.launch.cli.command.RunCommand;
+
+/**
+ * Command Line Interface for run widget in target
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ */
+public class
+Main
+extends WRTLauncher
+{
+ /**
+ * <p>
+ * Option for target widget file
+ * </p>
+ */
+ protected static final String OPT_WIDGETFILE = "target widget file";
+
+ /**
+ * <p>
+ * Description for target widget file
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_WIDGETFILE
+ */
+ protected static final String DESC_WIDGETFILE = "Command is performed of widget file install in target";
+
+ /**
+ * <p>
+ * Option for target widget id
+ * </p>
+ */
+ protected static final String OPT_WIDGETID = "target widget id";
+
+ /**
+ * <p>
+ * Description for target widget id
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_WIDGETID
+ */
+ protected static final String DESC_WIDGETID = "Command is performed of widget id uninstall in target, widget id is user written id in config.xml";
+
+ /**
+ * Entry point for cli main
+ *
+ * @param args user input parameter
+ *
+ * @throws Exception If unhandled exception occur
+ */
+ public static
+ void
+ main(
+ final String[] args
+ )
+ throws Exception
+ {
+ final Main instance = new Main();
+ instance.run( args );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.AbstractLauncher#execute(org.apache.commons.cli.CommandLine)
+ */
+ @Override
+ protected
+ void
+ execute(
+ final CommandLine cmdLine
+ )
+ throws Exception
+ {
+ super.execute( cmdLine );
+
+ final Prompter prompter = getPrompter();
+ final FileHandler fileHandler = getFileHandler();
+ final Executor exec = getExecutor();
+
+ // device not connect then exit
+ if ( getDevice() == null ) {
+ prompter.notify( "Process is stoped, please select connect device" );
+ return ;
+ }
+
+ // local widget file path control
+ String localWidgetFileName = cmdLine.getOptionValue( OPT_WIDGETFILE );
+ String localWidgetFilePath = (String)fileHandler.get( localWidgetFileName, Attribute.PATH );
+
+ // core operation
+ InstallCommand install_command = new InstallCommand();
+ install_command.setDevice( getDevice() );
+ String remotePath = install_command.getRemotePath();
+
+ PushSdbCommand push_command = new PushSdbCommand( localWidgetFilePath, remotePath );
+ push_command.setDevice( getDevice() );
+
+
+ // widget push
+ exec.execute( push_command );
+
+ // widget install
+ exec.execute( install_command );
+
+ // install check
+ String widgetID = cmdLine.getOptionValue( OPT_WIDGETID );
+ CheckInstallCommand install_check_command = new CheckInstallCommand( widgetID );
+ exec.execute( install_check_command );
+ if ( !install_check_command.isInstalled() ) {
+ prompter.notify(
+ MessageFormat.format( "Process is stoped, [{0}] widget is not installed", widgetID )
+ );
+ return ;
+ }
+
+ // widget run
+ RunCommand run_command = new RunCommand( widgetID );
+ exec.execute( run_command );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.AbstractLauncher#getOptions()
+ */
+ @Override
+ @SuppressWarnings("static-access")
+ protected
+ Options
+ getOptions()
+ {
+ final Options opts = super.getOptions();
+ opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETFILE ).withDescription( DESC_WIDGETFILE ).create( OPT_WIDGETFILE.substring( 0, 1 ) ) );
+ opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETID ).withDescription( DESC_WIDGETID ).create( OPT_WIDGETID.substring( 0, 1 ) ) );
+
+ return opts;
+ }
+}
--- /dev/null
+/*
+* Web IDE - Command Line Interface
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* GyeongSeok Seo <gyeongseok.seo@samsung.com>
+* BonYong Lee <bonyong.lee@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.cli.exec.uninstall;
+
+import java.text.MessageFormat;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.tizen.cli.exec.WRTLauncher;
+import org.tizen.common.core.command.Executor;
+import org.tizen.common.core.command.Prompter;
+import org.tizen.web.launch.cli.command.CheckInstallCommand;
+import org.tizen.web.launch.cli.command.KillCommand;
+import org.tizen.web.launch.cli.command.UninstallCommand;
+
+/**
+ * Command Line Interface for uninstall widget in target
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ */
+public class
+Main
+extends WRTLauncher
+{
+ /**
+ * <p>
+ * Option for target widget id
+ * </p>
+ */
+ protected static final String OPT_WIDGETID = "target widget id";
+
+ /**
+ * <p>
+ * Description for target widget id
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_WIDGETID
+ */
+ protected static final String DESC_WIDGETID = "Command is performed of widget id uninstall in target, widget id is user written id in config.xml";
+
+ /**
+ * Entry point for cli main
+ *
+ * @param args user input parameter
+ *
+ * @throws Exception If unhandled exception occur
+ */
+ public static
+ void
+ main(
+ final String[] args
+ )
+ throws Exception
+ {
+ final Main instance = new Main();
+ instance.run( args );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.AbstractLauncher#execute(org.apache.commons.cli.CommandLine)
+ */
+ @Override
+ protected
+ void
+ execute(
+ final CommandLine cmdLine
+ )
+ throws Exception
+ {
+ super.execute( cmdLine );
+
+ final Prompter prompter = getPrompter();
+ final Executor exec = getExecutor();
+
+ // device not connect then exit
+ if ( getDevice() == null ) {
+ prompter.notify( "Process is stoped, please select connect device" );
+ return ;
+ }
+
+ // core operation
+ String widgetID = cmdLine.getOptionValue( OPT_WIDGETID );
+
+ // install check
+ CheckInstallCommand install_check_command = new CheckInstallCommand( widgetID );
+ exec.execute( install_check_command );
+ if ( !install_check_command.isInstalled() ) {
+ prompter.notify(
+ MessageFormat.format( "Process is stoped, [{0}] widget is not installed", widgetID )
+ );
+ return ;
+ }
+
+ // kill
+ KillCommand kill_command = new KillCommand( widgetID );
+ exec.execute( kill_command );
+
+ // uninstall
+ UninstallCommand uninstall_command = new UninstallCommand( widgetID );
+ exec.execute( uninstall_command );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.AbstractLauncher#getOptions()
+ */
+ @Override
+ @SuppressWarnings("static-access")
+ protected
+ Options
+ getOptions()
+ {
+ final Options opts = super.getOptions();
+ opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETID ).withDescription( DESC_WIDGETID ).create( OPT_WIDGETID.substring( 0, 1 ) ) );
+
+ return opts;
+ }
+}