[Title] Added TipOfTheDayDialog 88/10688/1
authorchanghyun1.lee <changhyun1.lee@samsung.com>
Tue, 1 Oct 2013 05:00:11 +0000 (14:00 +0900)
committerchanghyun1.lee <changhyun1.lee@samsung.com>
Wed, 9 Oct 2013 06:49:39 +0000 (15:49 +0900)
[Desc.]
[Issue]

Change-Id: I81427da841863bdb84b97efced0a96fe4e228f27

Conflicts:

org.tizen.common/src/org/tizen/common/CommonPlugin.java

Signed-off-by: changhyun1.lee <changhyun1.lee@samsung.com>
14 files changed:
org.tizen.common.externals/src/org/mihalis/opal/tipOfTheDay/TipOfTheDay.java
org.tizen.common.ui/META-INF/MANIFEST.MF
org.tizen.common.ui/OSGI-INF/l10n/bundle.properties
org.tizen.common.ui/plugin.xml
org.tizen.common.ui/schema/org.tizen.common.ui.tipoftheday.exsd [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/Startup.java
org.tizen.common.ui/src/org/tizen/common/ui/dialog/ColorPickerDialog.java
org.tizen.common.ui/src/org/tizen/common/ui/dialog/StartUp.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/dialog/TipOfTheDayDialog.java [new file with mode: 0644]
org.tizen.common/src/org/tizen/common/CommonPlugin.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/TizenBasePreferencePage.java
org.tizen.common/src/org/tizen/common/util/PluginUtil.java

index 4ec53c7..0efd892 100755 (executable)
@@ -65,7 +65,7 @@ public class TipOfTheDay {
        private Shell shell;\r
        private Button close;\r
        private int index;\r
-       private Browser tipArea;\r
+       protected Browser tipArea;\r
        private String fontName;\r
        private TipStyle style;\r
        private Image image;\r
@@ -241,7 +241,7 @@ public class TipOfTheDay {
        /**\r
         * Fill the tip area with the selected tip\r
         */\r
-       private void fillTipArea() {\r
+       protected void fillTipArea() {\r
                this.tipArea.setText("<html><body bgcolor=\"#ffffff\" text=\"#000000\"><p style=\"font-family:" + this.fontName + ";font-size=12px\">" //\r
                                + this.tips.get(this.index) + "</p></body></html>");\r
        }\r
@@ -312,7 +312,7 @@ public class TipOfTheDay {
         * @param composite parent composite\r
         * @param gridData associated grid data\r
         */\r
-       private void buildShowOnStartup(final Composite composite, final GridData gridData) {\r
+       protected void buildShowOnStartup(final Composite composite, final GridData gridData) {\r
                final Button checkBox = new Button(composite, SWT.CHECK);\r
                checkBox.setLayoutData(gridData);\r
                checkBox.setText(ResourceManager.getLabel(ResourceManager.SHOW_TIP_AT_STARTUP));\r
index 33d2382..df21c8c 100644 (file)
@@ -17,6 +17,8 @@ Import-Package: org.eclipse.core.resources,
  org.mihalis.opal.preferenceWindow,
  org.mihalis.opal.preferenceWindow.widgets,
  org.mihalis.opal.promptSupport,
+ org.mihalis.opal.tipOfTheDay,
+ org.mihalis.opal.utils,
  org.tizen.common.project.util,
  org.tizen.common.sign.preferences
 Export-Package: org.tizen.common.ui,
index e2ca0a7..bc53f16 100644 (file)
@@ -1,6 +1,5 @@
 Bundle-Vendor = The Linux Foundation
 Bundle-Name = Tizen Common UI
-
 wizard.preferences.name = Wizard
-
 extension-point.commandbar = Command Bar Extension
+extension-point.tipoftheday = Tip of the day Extension
\ No newline at end of file
index 200e5e4..3eb9592 100644 (file)
@@ -2,6 +2,7 @@
 <?eclipse version="3.4"?>\r
 <plugin>\r
    <extension-point id="org.tizen.common.ui.commandbar" name="%extension-point.commandbar" schema="schema/org.tizen.common.ui.commandbar.exsd"/>\r
+   <extension-point id="org.tizen.common.ui.tipoftheday" name="%extension-point.tipoftheday" schema="schema/org.tizen.common.ui.tipoftheday.exsd"/>\r
    <extension\r
          point="org.eclipse.ui.commands">\r
       <category\r
        <startup\r
              class="org.tizen.common.ui.commandbar.Startup"></startup>\r
     </extension>\r
+    <extension\r
+          point="org.eclipse.ui.startup">\r
+       <startup\r
+             class="org.tizen.common.ui.dialog.StartUp">\r
+       </startup>\r
+    </extension>\r
     <extension point="org.eclipse.ui.menus">\r
        <group id="org.tizen.common.ui.commandbar" separatorsVisible="true">\r
              <location>\r
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"\r
             sequence="M1+M2+C">\r
        </key>\r
-    </extension>\r
+    </extension>
 </plugin>\r
diff --git a/org.tizen.common.ui/schema/org.tizen.common.ui.tipoftheday.exsd b/org.tizen.common.ui/schema/org.tizen.common.ui.tipoftheday.exsd
new file mode 100644 (file)
index 0000000..c89b2e0
--- /dev/null
@@ -0,0 +1,121 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.tizen.common.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.tizen.common.ui" id="org.tizen.common.ui.tipoftheday" name="Tip of the day Extension"/>
+      </appinfo>
+      <documentation>
+         Provides the extension point for the tip of the day.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="tip"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="tip">
+      <complexType>
+         <attribute name="file" type="string">
+            <annotation>
+               <documentation>
+                  tip html file path
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="resource"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="url" type="string">
+            <annotation>
+               <documentation>
+                  tip url
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         &lt;extension
+      point=&quot;org.tizen.common.ui.tipoftheday&quot;&gt;
+      &lt;tip
+         file=&quot;tips/tip.html&quot;
+      &lt;/tip&gt;
+&lt;/extension&gt;
+
+&lt;extension
+      point=&quot;org.tizen.common.ui.tipoftheday&quot;&gt;
+      &lt;tip
+         url=&quot;http://www.tizen.org&quot;
+      &lt;/tip&gt;
+&lt;/extension&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
index d6b98b9..3b3c633 100644 (file)
@@ -6,6 +6,7 @@
 * Contact:
 * 
 * Yoonki Park <yoonki.park@samsung.com>
+* Changhyun Lee <changhyun1.lee@samsung.com>
 * Kangho Kim <kh5325.kim@samsung.com>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,10 +31,12 @@ package org.tizen.common.ui;
 import org.eclipse.ui.IStartup;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import static org.tizen.common.core.application.InstallPathConfig.*;
 
 public class Startup implements IStartup {
-    private static final Logger logger = LoggerFactory.getLogger(Startup.class);
+
+    protected static final Logger logger = LoggerFactory.getLogger(Startup.class);
 
     @Override
     public void earlyStartup() {
@@ -42,4 +45,5 @@ public class Startup implements IStartup {
         // some hack Eclipse log (because log4j might not be configured properly)
         org.tizen.common.util.log.Logger.info(info);
     }
+
 }
index d53e0de..21f4ae4 100644 (file)
@@ -29,9 +29,6 @@ package org.tizen.common.ui.dialog;
 import java.net.URL;
 import java.util.Arrays;
 
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.swt.SWT;
@@ -47,10 +44,10 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Shell;
-import org.osgi.framework.Bundle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.common.ui.Activator;
+import org.tizen.common.util.PluginUtil;
 import org.tizen.common.util.SWTUtil;
 
 /**
@@ -148,15 +145,11 @@ public class ColorPickerDialog extends Dialog {
     }
 
     public static String getColorPickerURL() {
-        Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
-        Path path = new Path(COLORPICKER_HOME);
-        URL fColorPickerUrl = null;
-        try {
-            fColorPickerUrl = FileLocator.toFileURL(FileLocator.find(bundle, path, null));
-        } catch (Exception e) {
-            logger.error("Failed to find a colorpicker", e);
+        URL fColorPickerUrl = PluginUtil.getFileURLinBundle( Activator.PLUGIN_ID, COLORPICKER_HOME );
+        if ( fColorPickerUrl != null ) {
+            return fColorPickerUrl.toString();
         }
-        return fColorPickerUrl.toString();
+        return null;
     }
 
     /**
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/dialog/StartUp.java b/org.tizen.common.ui/src/org/tizen/common/ui/dialog/StartUp.java
new file mode 100644 (file)
index 0000000..9b09e36
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+*  Common
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* 
+* Contact:
+* Changhyun Lee <changhyun1.lee@samsung.com>
+* Kangho Kim <kh5325.kim@samsung.com>
+* Hyeongseok Heo <hyeongseok.heo@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.common.ui.dialog;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IStartup;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.common.CommonPlugin;
+import org.tizen.common.ui.page.preference.TizenBasePreferencePage;
+import org.tizen.common.util.PluginUtil;
+import org.tizen.common.util.SWTUtil;
+import org.tizen.common.util.StringUtil;
+
+/**
+ * StartUp
+ * 
+ * @author Changhyun Lee {@literal <changhyun1.lee@samsung.com>} (S-Core)
+ */
+public class StartUp implements IStartup {
+
+    protected static final Logger logger = LoggerFactory.getLogger(StartUp.class);
+
+    public static final String EXTENTION_POINT_TIPOFTHEDAY = "org.tizen.common.ui.tipoftheday";
+
+    @Override
+    public void earlyStartup() {
+        tipOfTheDayStartup();
+    }
+
+    public void tipOfTheDayStartup() {
+        final IPreferenceStore prefStore = CommonPlugin.getDefault().getPreferenceStore();
+        if ( prefStore.getBoolean( TizenBasePreferencePage.KEY_TIPOFTHEDAY )) {
+            Display.getDefault().asyncExec(new Runnable() {
+                @Override
+                public void run() {
+                    TipOfTheDayDialog tip = new TipOfTheDayDialog();
+                    // set url from extension
+                    IConfigurationElement[] ces = PluginUtil.getExtensionConfigurationElements(EXTENTION_POINT_TIPOFTHEDAY);
+                    for ( IConfigurationElement ce : ces ) {
+                        String filepath = ce.getAttribute("file");
+                        String tipurl = ce.getAttribute("url");
+                        if ( !StringUtil.isEmpty( filepath ) ) {
+                            URL url = PluginUtil.getFileURLinBundle( ce.getContributor().getName(), filepath );
+                            if ( url == null ) {
+                                continue;
+                            }
+                            logger.trace( url.toString() );
+                            tip.addTip( url.toString() );
+                        } else if ( !StringUtil.isEmpty( tipurl ) ) {
+                            logger.trace( tipurl );
+                            tip.addTip( tipurl );
+                        }
+                    }
+
+                    if ( !tip.getTips().isEmpty() ) {
+                        tip.open( SWTUtil.getActiveShell() );
+                    }
+                }
+            });
+        }
+    }
+
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/dialog/TipOfTheDayDialog.java b/org.tizen.common.ui/src/org/tizen/common/ui/dialog/TipOfTheDayDialog.java
new file mode 100644 (file)
index 0000000..c15d96f
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * Kangho Kim <kh5325.kim@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.dialog;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.mihalis.opal.tipOfTheDay.TipOfTheDay;
+import org.mihalis.opal.utils.ResourceManager;
+import org.tizen.common.CommonPlugin;
+import org.tizen.common.ui.page.preference.TizenBasePreferencePage;
+
+/**
+ * TipOfTheDayDialog.
+ *
+ * @author Changhyun Lee {@literal <changhyun1.lee@samsung.com>} (S-Core)
+ */
+public class TipOfTheDayDialog extends TipOfTheDay {
+
+    public TipOfTheDayDialog() {
+        super();
+        setStyle( TipStyle.HEADER );
+    }
+
+    /**
+     * Fill the tip area with the selected tip url
+     */
+    @Override
+    protected void fillTipArea() {
+        this.tipArea.setUrl( getTips().get(getIndex()) );
+    }
+
+    @Override
+    protected void buildShowOnStartup(Composite composite, GridData gridData) {
+        final Button checkBox = new Button(composite, SWT.CHECK);
+        checkBox.setLayoutData(gridData);
+        checkBox.setText(ResourceManager.getLabel(ResourceManager.SHOW_TIP_AT_STARTUP));
+        checkBox.setSelection(isShowOnStartup());
+        final IPreferenceStore prefStore = CommonPlugin.getDefault().getPreferenceStore();
+        checkBox.addListener(SWT.Selection, new Listener() {
+            @Override
+            public void handleEvent(final Event event) {
+                boolean checked = checkBox.getSelection();
+                setShowOnStartup(checked);
+                prefStore.setValue(TizenBasePreferencePage.KEY_TIPOFTHEDAY, checked);
+            }
+        });
+    }
+
+}
index 6fc96a6..caf8182 100755 (executable)
@@ -66,21 +66,20 @@ public class CommonPlugin extends AbstractUIPlugin {
     public static final String PLUGIN_ID = "org.tizen.common"; //$NON-NLS-1$
     // The shared instance
     private static CommonPlugin plugin;
-    
+
     /**
      * {@link Prompter} using swt dialog
      */
     protected EclipsePrompter prompter = null;
-    
+
     /**
      * {@link Executor} with {@link SWTPrompter}
      */
     protected Executor executor = null;
-    
+
     //protected RepositorySelector selector = null;
-    
-    protected CrashReportService crService = null;
 
+    protected CrashReportService crService = null;
 
     /*
      * (non-Javadoc)
@@ -89,9 +88,9 @@ public class CommonPlugin extends AbstractUIPlugin {
     @Override
     public void start(BundleContext context) throws Exception {
         super.start( context );
-        
+
         getPreferenceStore().addPropertyChangeListener( new TizenLog4jConfigurator() );
-        
+
         plugin = this;
         initializeExecutor();
         initializeSmartDeviceBridge();
@@ -104,12 +103,12 @@ public class CommonPlugin extends AbstractUIPlugin {
      */
     @Override
     public void stop(BundleContext context) throws Exception {
-       finalizeSmartDeviceBridge();
+        finalizeSmartDeviceBridge();
         finalizeExecutor();
         plugin = null;
         super.stop(context);
     }
-    
+
     public static void setDefault( CommonPlugin plugin ) {
         CommonPlugin.plugin = plugin;
     }
@@ -132,7 +131,8 @@ public class CommonPlugin extends AbstractUIPlugin {
             store.setDefault(TizenBasePreferencePage.KEY_SDKLOCATION, InstallPathConfig.getSDKPath());
         }
         store.setDefault(TizenBasePreferencePage.KEY_SDKUPDATE, TizenBasePreferencePage.VALUE_SDKUPDATE_DEFAULT);
-        
+        store.setDefault(TizenBasePreferencePage.KEY_TIPOFTHEDAY, TizenBasePreferencePage.VALUE_TIPOFTHEDAY_DEFAULT);
+
         // RDS settings
         store.setDefault(RdsPreferencePage.RDS_OPTION_ID, RdsPreferencePage.RDS_MODE_DEFAULT);
     }
@@ -145,7 +145,7 @@ public class CommonPlugin extends AbstractUIPlugin {
     public void setExecutor( final Executor executor ) {
         this.executor = executor;
     }
-    
+
     /**
      * Returns {@link Executor} in eclipse plugin environment
      * @return
@@ -153,7 +153,7 @@ public class CommonPlugin extends AbstractUIPlugin {
     public Executor getExecutor() {
         return this.executor;
     }
-    
+
     /**
      * Returns {@link Prompter} in eclipse plugin environment
      * 
@@ -171,40 +171,32 @@ public class CommonPlugin extends AbstractUIPlugin {
     protected void finalizeExecutor() {
     }
 
-    protected void initializeSmartDeviceBridge()
-    {
+    protected void initializeSmartDeviceBridge() {
         String sdbPath = InstallPathConfig.getSDBPath();
-        if (!HostUtil.exists(sdbPath))
-        {
-               DialogUtil.openMessageDialog(String.format("There is no %s.", sdbPath));
-        }
-        else {
-            try
-            {
+        if (!HostUtil.exists(sdbPath)) {
+            DialogUtil.openMessageDialog(String.format("There is no %s.", sdbPath));
+        } else {
+            try {
                 SmartDevelopmentBridge bridge = SmartDevelopmentBridge.createBridge(sdbPath, false);
                 bridge.waitforStart( 5000 );
-                if ( !bridge.getStarted() )
-                {
+                if ( !bridge.getStarted() ) {
                     DialogUtil.openErrorDialog( "Failed to start sdb. Read sdb log in ${tizen_sdk}/tools for details." );
                     // Just to proceed for using IDE without sdb
                     bridge.stopBridge();
                 }
-            }
-            catch ( final Throwable t )
-            {
-               plugin.getLog().log(new Status(Status.ERROR, PLUGIN_ID, "Problem occurred while initializing sdb", t));
+            } catch ( final Throwable t ) {
+                plugin.getLog().log(new Status(Status.ERROR, PLUGIN_ID, "Problem occurred while initializing sdb", t));
                 DialogUtil.openErrorDialog("Failed to start sdb");
             }
         }
     }
-       
-       protected void finalizeSmartDeviceBridge()
-       {
-               SmartDevelopmentBridge.disconnectBridge();
-       }
-       
+
+    protected void finalizeSmartDeviceBridge() {
+        SmartDevelopmentBridge.disconnectBridge();
+    }
+
     protected void initializeCrashReportService() throws ServerException {
-       crService = new CrashReportService();
+        crService = new CrashReportService();
         final String ATTR_SCOPE = "client";
         final String ATTR_CLASS = "class";
 
@@ -221,16 +213,16 @@ public class CommonPlugin extends AbstractUIPlugin {
                             crService.addCrashReportServiceListener( (ICrashReportServiceListener) obj );
                         }
                     } catch (CoreException e) {
-                       plugin.getLog().log( new Status( Status.WARNING, PLUGIN_ID, "Error occurred while adding cs create listener" , e ) );
+                        plugin.getLog().log( new Status( Status.WARNING, PLUGIN_ID, "Error occurred while adding cs create listener" , e ) );
                     }
                 }
             }
         }
         crService.boot();
     }
-    
-    protected void destroyCrashReportService()
-    {
-       crService.down();
+
+    protected void destroyCrashReportService() {
+        crService.down();
     }
+
 }
index 6e74129..25ec748 100644 (file)
@@ -31,26 +31,28 @@ public class Messages {
     private static final String BUNDLE_NAME = Messages.class.getName();//$NON-NLS-1$
 
     public static String DESCRIPTION;
-    
+
     public static String GROUP1;
     public static String GROUP2;
-    
+    public static String GROUP3;
+
     public static String LABEL_LOCATION;
     public static String LABEL_UPDATE;
-    
+    public static String LABEL_TIPOFTHEDAY;
+
     public static String PROPERTIES_PAGE_BODY;
     public static String RDS_NOTE;
     public static String RDS_OPTION_SAVE_FAIL;
     public static String RDS_MODE_PREFERENCE;
-    
+
     public static String LOGGER_GROUP;
     public static String LABEL_LOG_LOCATION;
     public static String LABEL_LOG_CP;
-    
+
     public static String BUTTON_REPORT;
     public static String BUTTON_USAGE;
     public static String BUTTON_PERFORM;
-    
+
     static {
         // initialize resource bundle
         NLS.initializeMessages( BUNDLE_NAME, Messages.class );
index e59d6ea..1c9b35e 100644 (file)
@@ -3,6 +3,8 @@ GROUP1=SDK path
 LABEL_LOCATION=Location:
 GROUP2=SDK update
 LABEL_UPDATE=Automatically find new updates at start-up and notify me
+GROUP3=Tip of the day
+LABEL_TIPOFTHEDAY=Show on startup
 PROPERTIES_PAGE_BODY=Expand the tree to edit preferences for a specific feature.
 RDS_NOTE=Currently, this option is not supported for multi-app project.
 RDS_OPTION_SAVE_FAIL=Failed to save options.
index b6ffd4e..f1414d9 100644 (file)
@@ -62,9 +62,11 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement
 
     public static final String KEY_SDKLOCATION = "sdkpath"; //$NON-NLS-1$
     public static final String KEY_SDKUPDATE = "sdkupdate"; //$NON-NLS-1$
-    
+    public static final String KEY_TIPOFTHEDAY = "tipoftheday"; //$NON-NLS-1$
+
     public static final String VALUE_SDKLOCATION_DEFAULT = null;;
     public static final boolean VALUE_SDKUPDATE_DEFAULT = false;
+    public static final boolean VALUE_TIPOFTHEDAY_DEFAULT = true;
     private boolean applyOk = true;
     
     /**
@@ -132,6 +134,8 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement
         SWTUtil.createSpacer(composite, 1);
         createUpdateSettingPreferences(composite);
         SWTUtil.createSpacer(composite, 1);
+        createTopOfTheDayPreferences(composite);
+        SWTUtil.createSpacer(composite, 1);
         createLoggerPreferences(composite);
     }
 
@@ -155,6 +159,14 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement
         addField(startupCheckEditor);
     }
 
+    private void createTopOfTheDayPreferences(Composite parent) {
+        Composite comp = SWTUtil.createGroup(parent, Messages.GROUP3, 1);
+        Composite formatComposite = SWTUtil.createCompositeEx(comp, 1, GridData.FILL_HORIZONTAL);
+        BooleanFieldEditor tipofthedayCheckEditor = new BooleanFieldEditor(KEY_TIPOFTHEDAY,
+                Messages.LABEL_TIPOFTHEDAY, formatComposite);
+        addField(tipofthedayCheckEditor);
+    }
+
     private void createLoggerPreferences(Composite parent) {
         Composite comp = SWTUtil.createGroup(parent, Messages.LOGGER_GROUP, 1);
         SWTUtil.setGridLayout(comp, 2, false, -1, -1, -1, -1, GridData.FILL_HORIZONTAL);
index 925413d..c8f0f9e 100644 (file)
@@ -41,6 +41,10 @@ import org.eclipse.core.runtime.IExtensionRegistry;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Plugin;
 import org.eclipse.core.runtime.URIUtil;
+import org.osgi.framework.Bundle;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.tizen.common.Surrogate;
 
 /**
@@ -51,7 +55,9 @@ import org.tizen.common.Surrogate;
  * @author Ho Namkoong{@literal <ho.namkoong@samsung.com>} (S-Core)
  */
 public class PluginUtil {
-    
+
+    protected static final Logger logger = LoggerFactory.getLogger(PluginUtil.class);
+
     protected static Surrogate<IExtensionRegistry> platformSurrogate = new Surrogate<IExtensionRegistry>() {
         public IExtensionRegistry getAdapter()
         {
@@ -145,7 +151,7 @@ public class PluginUtil {
     public static URL getBuiltInURL(Plugin plugin, String entryPath) throws IOException {
         Assert.notNull( plugin );
         Assert.notNull( entryPath );
-        
+
         URL entry = plugin.getBundle().getEntry( entryPath );
         return ( entry != null ) ? FileLocator.toFileURL( entry ) : null;
     }
@@ -155,4 +161,65 @@ public class PluginUtil {
         return registry.getConfigurationElementsFor( extPointId );
     }
 
+    /**
+     * Returns the resolved bundle with the specified symbolic name that has the
+     * highest version.  If no resolved bundles are installed that have the 
+     * specified symbolic name then null is returned.
+     * <p>
+     * Clients are also able to acquire the {@link PackageAdmin} service and query
+     * it for the bundle with the specified symbolic name. Clients can ask the
+     * service for all bundles with that particular name and then determine the
+     * one with the highest version. Note that clients may want to filter
+     * the results based on the state of the bundles.
+     * </p>
+     * @param symbolicName the symbolic name of the bundle to be returned.
+     * @return the bundle that has the specified symbolic name with the 
+     * highest version, or <tt>null</tt> if no bundle is found.
+     */
+    public static Bundle getBundle( String symbolicName ) {
+        return Platform.getBundle( symbolicName );
+    }
+
+    /**
+     * Return the resolved URL with the specified symbolic name and resource full path.
+     * @param symbolicName the symbolic name of the bundle to be returned.
+     * @param filePath The filepath of the resource. See {@code ClassLoader.getResource}
+     *        for a description of the format of a resource name.
+     * @return the converted file URL or the original URL passed in if it is 
+     *     not recognized by this converter
+     */
+    public static URL getFileURLinBundle( String symbolicName, String filePath ) {
+        Bundle bundle = getBundle( symbolicName );
+        if ( bundle == null ) {
+            return null;
+        }
+        return getFileURLinBundle( bundle, filePath );
+    }
+
+    /**
+     * Return the resolved URL with the bundle and resource full path.
+     * @param bundle See {@code Bundle}
+     * @param filePath The filepath of the resource. See {@code ClassLoader.getResource}
+     *        for a description of the format of a resource name.
+     * @return the converted file URL or the original URL passed in if it is 
+     *     not recognized by this converter
+     */
+    public static URL getFileURLinBundle( Bundle bundle, String filePath ) {
+        if ( bundle == null || filePath == null ) {
+            return null;
+        }
+        URL url = bundle.getResource( filePath );
+        if ( url == null ) {
+            return null;
+        }
+        URL resolvedURL = null;
+        try {
+            // http://www.eclipsezone.com/eclipse/forums/t82616.html
+            resolvedURL = FileLocator.toFileURL( url );
+        } catch (IOException e) {
+            logger.error( e.getMessage(), e );
+        }
+        return resolvedURL;
+    }
+
 }