COMMON: PREFERENCES: Added SDB preferences page 38/12638/4
authoryoonki.park <yoonki.park@samsung.com>
Wed, 20 Nov 2013 13:51:11 +0000 (22:51 +0900)
committeryoonki.park <yoonki.park@samsung.com>
Thu, 21 Nov 2013 06:32:58 +0000 (15:32 +0900)
Added sdb preference page

Signed-off-by: yoonki.park <yoonki.park@samsung.com>
Change-Id: Iae374d3c2b50337d042a7b53ba5cf9167043df57

org.tizen.common.connection/OSGI-INF/l10n/bundle.properties
org.tizen.common.connection/plugin.xml
org.tizen.common.ui/src/org/tizen/common/ui/preferences/Messages.java
org.tizen.common/OSGI-INF/l10n/bundle.properties
org.tizen.common/plugin.xml
org.tizen.common/src/org/tizen/common/CommonPlugin.java
org.tizen.common/src/org/tizen/common/sdb/command/SdbCommand.java
org.tizen.common/src/org/tizen/common/ui/page/preference/Messages.java
org.tizen.common/src/org/tizen/common/ui/page/preference/Messages.properties
org.tizen.common/src/org/tizen/common/ui/page/preference/SdbPreferencePage.java [new file with mode: 0644]
org.tizen.common/src/org/tizen/common/ui/page/preference/TizenToolsPreferencePage.java [moved from org.tizen.common.connection/src/org/tizen/common/connection/preference/TizenToolsPreferencePage.java with 96% similarity]

index 1f6ae0f..6b89494 100644 (file)
@@ -8,7 +8,6 @@ view.log = Log
 properties.page.info = Info
 properties.page.permission = Permission
 
-tools.name = Tools
 connectionexplorer.name = Connection Explorer
 log.name = Log
 
index b4c6f15..ec0f287 100644 (file)
             restorable="true">
       </view>
    </extension>
-   
-   <extension
-        point="org.eclipse.ui.preferencePages">
-        <page
-            class="org.tizen.common.connection.preference.TizenToolsPreferencePage"
-            id="org.tizen.common.connection.preferences.tizentools"
-            name="%tools.name"
-            category="org.tizen.common.preferences.tizencommon">
-        </page>
-    </extension>
-    
+
     <extension
         point="org.eclipse.ui.preferencePages">
         <page
             class="org.tizen.common.connection.preference.TizenConnectionExplorerPreferencePage"
             id="org.tizen.common.connection.preferences.tizenconnectionexplorer"
             name="%connectionexplorer.name"
-            category="org.tizen.common.connection.preferences.tizentools">
+            category="org.tizen.common.preferences.tizentools">
         </page>
     </extension>
 
-    <!--<extension
-        point="org.eclipse.ui.preferencePages">
-        <page
-            class="org.tizen.common.connection.preference.TizenLogPreferencePage"
-            id="org.tizen.common.connection.preferences.tizenlog"
-            name="%log.name"
-            category="org.tizen.common.connection.preferences.tizentools">
-        </page>
-   </extension>-->
-
-   <extension
+    <extension
          point="org.eclipse.ui.views">
       <view
             name="%view.log"
index 18eed12..63fa751 100644 (file)
@@ -28,6 +28,8 @@ package org.tizen.common.ui.preferences;
 import org.eclipse.osgi.util.NLS;
 
 public class Messages extends NLS {
+    private static final String BUNDLE_NAME = "org.tizen.common.ui.preferences.messages"; //$NON-NLS-1$
+
     private Messages() {
     }
 
@@ -39,6 +41,6 @@ public class Messages extends NLS {
     public static String AppearancePreferencePage_TodShowOnStartup;
 
     static {
-        NLS.initializeMessages(Messages.class.getName(), Messages.class);
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
     }
 }
index f791cd7..f969e14 100644 (file)
@@ -26,6 +26,9 @@ org.tizen.common.preferences.rds.name = Rapid Development Support
 org.tizen.common.preferences.logging.name = Logging
 preferences.logger.name = Tizen Logger
 
+org.tizen.common.preferences.tools.name = Tools
+org.tizen.common.preferences.sdb.name = Smart Development Bridge
+
 extension-point.crashreporter = Crash Reporter
 extension-point.prompter = Prompter
 extension-point.project = ITizenProject Adapter
index c4dcd41..787e2ae 100644 (file)
             id="org.tizen.common.preferences.logging"\r
             name="%org.tizen.common.preferences.logging.name">\r
         </page>\r
+        <page\r
+            class="org.tizen.common.ui.page.preference.TizenToolsPreferencePage"\r
+            id="org.tizen.common.preferences.tizentools"\r
+            name="%org.tizen.common.preferences.tools.name"\r
+            category="org.tizen.common.preferences.tizencommon">\r
+        </page>\r
+        <page\r
+            class="org.tizen.common.ui.page.preference.SdbPreferencePage"\r
+            id="org.tizen.common.connection.preferences.sdb"\r
+            name="%org.tizen.common.preferences.sdb.name"\r
+            category="org.tizen.common.preferences.tizentools">\r
+        </page>\r
     </extension>\r
     <extension\r
         point="org.eclipse.ui.startup">\r
index 0f28a39..93fbd46 100755 (executable)
@@ -41,6 +41,7 @@ import org.tizen.common.core.command.Prompter;
 import org.tizen.common.core.command.prompter.EclipsePrompter;
 import org.tizen.common.core.command.prompter.SWTPrompter;
 import org.tizen.common.rds.ui.preference.RdsPreferencePage;
+import org.tizen.common.ui.page.preference.SdbPreferencePage;
 import org.tizen.common.ui.page.preference.TizenBasePreferencePage;
 import org.tizen.common.util.DialogUtil;
 import org.tizen.common.util.HostUtil;
@@ -134,6 +135,8 @@ public class CommonPlugin extends AbstractUIPlugin {
 
         // RDS settings
         store.setDefault(RdsPreferencePage.RDS_OPTION_ID, RdsPreferencePage.RDS_MODE_DEFAULT);
+        // SDB settings
+        store.setDefault(SdbPreferencePage.KEY_SDB_RESPONSE_TIMEOUT, SdbPreferencePage.VALUE_SDB_RESPONSE_TIMEOUT_DEFAULT);
     }
 
     /**
index caa046d..b3a46bf 100644 (file)
@@ -30,11 +30,13 @@ import java.io.IOException;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.tizen.common.CommonPlugin;
 import org.tizen.common.TizenPlatformConstants;
 import org.tizen.common.core.application.InstallPathConfig;
 import org.tizen.common.sdb.command.message.CommandErrorException;
 import org.tizen.common.sdb.command.message.CommandErrorType;
 import org.tizen.common.sdb.command.receiver.CommandOutputReceiver;
+import org.tizen.common.ui.page.preference.SdbPreferencePage;
 import org.tizen.common.ui.view.console.ITizenConsoleManager;
 import org.tizen.common.util.HostUtil;
 import org.tizen.common.util.StringUtil;
@@ -47,6 +49,10 @@ import org.tizen.sdblib.exception.TimeoutException;
 public class SdbCommand {
     protected final Logger logger = LoggerFactory.getLogger(getClass());
 
+    /**
+     * This final int is deprecated and should be removed and use SdbCommand#getDefaultTime() instead.
+    */
+    @Deprecated
     public static final int DEFAULT_TIMEOUT = 60000;
     private final String SEPARATOR = System.getProperty("line.separator");
 
@@ -57,6 +63,7 @@ public class SdbCommand {
     private CommandOutputReceiver receiver = null;
     private String sdbPath;
     private boolean showCommand = false;
+    private int defaultTimeout;
 
     public SdbCommand(IDevice device) {
         this(device, null);
@@ -72,6 +79,7 @@ public class SdbCommand {
         this.receiver = receiver;
 
         sdbPath = InstallPathConfig.getSDBPath();
+        this.defaultTimeout = CommonPlugin.getDefault().getPreferenceStore().getInt(SdbPreferencePage.KEY_SDB_RESPONSE_TIMEOUT);
     }
 
     public void runCommand(String command) throws Exception {
@@ -129,7 +137,7 @@ public class SdbCommand {
     }
 
     public CommandErrorType runCommand(String command, CommandErrorType messages) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException {
-        return runCommand(command, messages, DEFAULT_TIMEOUT);
+        return runCommand(command, messages, defaultTimeout);
     }
 
     public CommandErrorType runCommand(String command, CommandErrorType errorMessages, int timeout) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException{
@@ -154,6 +162,10 @@ public class SdbCommand {
         return commandOutput;
     }
 
+    public int getDefaultTimeout() {
+        return defaultTimeout;
+    }
+
     public String[] getResultLineStrings() {
         String strs = commandOutput.toString();
         if ( StringUtil.isEmpty(strs) ) {
index bf8f7b8..e1da46e 100644 (file)
@@ -48,6 +48,11 @@ public class Messages {
     public static String BUTTON_USAGE;
     public static String BUTTON_PERFORM;
 
+    public static String SDB_DESCRIPTION;
+    public static String SDB_RESPONSE_TIMEOUT_GROUP;
+    public static String SDB_RESPONSE_TIMEOUT_LABEL;
+    public static String SDB_RESPONSE_TIMEOUT_CAUTION;
+
     static {
         NLS.initializeMessages( BUNDLE_NAME, Messages.class );
     }
index 57df368..6392b44 100644 (file)
@@ -13,3 +13,8 @@ LABEL_LOG_CP=&Pattern
 BUTTON_REPORT=I want to contribute this information to improve Tizen IDE
 BUTTON_USAGE=Send usage data
 BUTTON_PERFORM=Send performance data
+
+SDB_DESCRIPTION=General settings for Tizen SDB:
+SDB_RESPONSE_TIMEOUT_GROUP=Communication
+SDB_RESPONSE_TIMEOUT_LABEL=Connection timeout (ms):
+SDB_RESPONSE_TIMEOUT_CAUTION='0' means waiting forever
\ No newline at end of file
diff --git a/org.tizen.common/src/org/tizen/common/ui/page/preference/SdbPreferencePage.java b/org.tizen.common/src/org/tizen/common/ui/page/preference/SdbPreferencePage.java
new file mode 100644 (file)
index 0000000..31b1bdc
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *  Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@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.common.ui.page.preference;
+
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.tizen.common.CommonPlugin;
+import org.tizen.common.util.SWTUtil;
+
+public class SdbPreferencePage extends FieldEditorPreferencePage implements
+        IWorkbenchPreferencePage
+{
+
+    public static final String id = "org.tizen.common.connection.preferences.sdb";
+    public static final String KEY_SDB_RESPONSE_TIMEOUT = "response_timeout";
+    public static final int    VALUE_SDB_RESPONSE_TIMEOUT_DEFAULT = 300000; // 5 min
+
+    public SdbPreferencePage()
+    {
+        setPreferenceStore(CommonPlugin.getDefault().getPreferenceStore());
+        setDescription(Messages.SDB_DESCRIPTION);
+    }
+
+    @Override
+    public void init(IWorkbench workbench)
+    {
+    }
+
+    @Override
+    protected void createFieldEditors()
+    {
+        Composite composite = getFieldEditorParent();
+
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 1;
+        layout.marginHeight = 0;
+        layout.marginWidth = 0;
+        composite.setLayout(layout);
+        GridData data = new GridData(GridData.FILL_BOTH);
+        data.verticalAlignment = GridData.FILL;
+        data.horizontalAlignment = GridData.FILL;
+        composite.setLayoutData(data);
+        SWTUtil.createSpacer(composite, 1);
+        createResponseTimeoutPreferences(composite);
+    }
+
+    private void createResponseTimeoutPreferences(Composite parent)
+    {
+        Composite comp = SWTUtil.createGroup(parent,Messages.SDB_RESPONSE_TIMEOUT_GROUP, 1);
+        Composite formatComposite = SWTUtil.createCompositeEx(comp, 2, GridData.FILL_HORIZONTAL);
+        IntegerFieldEditor intField = new IntegerFieldEditor(KEY_SDB_RESPONSE_TIMEOUT, Messages.SDB_RESPONSE_TIMEOUT_LABEL, formatComposite);
+        intField.setValidRange(0, Integer.MAX_VALUE);
+        intField.getTextControl(formatComposite).setToolTipText(Messages.SDB_RESPONSE_TIMEOUT_CAUTION);
+
+        addField(intField);
+    }
+}
+