[Title] Applied site-based proxy setting
authordonghee yang <donghee.yang@samsung.com>
Fri, 9 Nov 2012 20:46:10 +0000 (05:46 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Fri, 9 Nov 2012 20:46:10 +0000 (05:46 +0900)
16 files changed:
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentPackager.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/FileGitIndexParser.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/GitIndexParserFactory.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/IGitIndexParser.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/WebGitIndexParser.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RPMPackageDialog.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/PreferencesManager.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/ui/GitConfUIMessages.properties
org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/ui/SiteConfigurationDialog.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/ui/SiteConfigurationPreferencePage.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/SnapshotURLParser.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/AddRootstrapDialog.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RootstrapUIMessages.properties
org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RootstrapView.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TemplateTizenPlatformNewWizard.java

index 0d5811c..f5b2c66 100644 (file)
@@ -94,7 +94,7 @@ public class PlatformProjectDependentPackager extends CommonProjectDependentPack
                String workingDir = getWorkingDir(config);
                
                String passwd = SudoPasswdManager.getSudoPassword();            
-               String httpProxy = PreferencesManager.getHttpProxy();
+               String httpProxy = PreferencesManager.getHttpProxyURL();
                if (httpProxy.isEmpty()) {
                        httpProxy = "noproxy";
                }
index 47cae9d..18a27a4 100644 (file)
@@ -14,7 +14,7 @@ public class FileGitIndexParser implements IGitIndexParser {
        ArrayList<GitDescription> GitDescs = new ArrayList<GitDescription>();
 
        @Override
-       public ArrayList<GitDescription> parse(PreferencesManager.GitConfiguration config) {
+       public ArrayList<GitDescription> parse(PreferencesManager.SiteConfiguration config) {
                BufferedReader reader = null;
                try {
                        reader = new BufferedReader(new FileReader(config.listLocation));                       
index a58d6c3..3dfe54e 100644 (file)
@@ -3,7 +3,7 @@ package org.tizen.nativeplatform.git;
 import org.tizen.nativeplatform.preferences.PreferencesManager;
 
 public class GitIndexParserFactory {
-       public static IGitIndexParser getIndexParser(PreferencesManager.GitConfiguration config)  {
+       public static IGitIndexParser getIndexParser(PreferencesManager.SiteConfiguration config)  {
                if ( config.listType.equals(PreferencesManager.GIT_LIST_WEB)) {
                        return new WebGitIndexParser();
                } 
index c3dd19c..850f717 100644 (file)
@@ -6,5 +6,5 @@ import org.tizen.nativeplatform.git.model.GitDescription;
 import org.tizen.nativeplatform.preferences.PreferencesManager;
 
 public interface IGitIndexParser {
-       public ArrayList<GitDescription> parse(PreferencesManager.GitConfiguration config);
+       public ArrayList<GitDescription> parse(PreferencesManager.SiteConfiguration config);
 }
index 2da317c..3a15768 100644 (file)
@@ -14,7 +14,7 @@ import org.tizen.nativeplatform.preferences.PreferencesManager;
 public class WebGitIndexParser implements IGitIndexParser {
 
        @Override
-       public ArrayList<GitDescription> parse(PreferencesManager.GitConfiguration config) {
+       public ArrayList<GitDescription> parse(PreferencesManager.SiteConfiguration config) {
                boolean startTable = false;
                boolean startTr = false;
                boolean getProjectName = false;
index f9d8977..e59a50d 100644 (file)
@@ -30,12 +30,7 @@ package org.tizen.nativeplatform.pkgmgr.ui;
 
 import java.util.ResourceBundle;
 
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
 import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.FileLocator;
@@ -63,7 +58,6 @@ import org.tizen.nativecommon.build.CurrentEnabledProject;
 import org.tizen.nativeplatform.Activator;
 import org.tizen.nativeplatform.build.PlatformConfigurationManager;
 import org.tizen.sdblib.IDevice;
-import org.tizen.nativeplatform.password.SudoPasswdManager;
 import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
 import org.tizen.nativeplatform.pkgmgr.model.LocalPkgProvider;
 import org.tizen.nativeplatform.pkgmgr.model.PackageProvider;
@@ -73,8 +67,6 @@ import org.tizen.nativeplatform.views.model.PlatformRootstrap;
 
 public class RPMPackageDialog extends Dialog { 
        
-       
-       private String configuration;   
        private IDevice device; 
        private TabFolder tabFolder;    
        
@@ -102,8 +94,8 @@ public class RPMPackageDialog extends Dialog {
         x = bounds.x + (bounds.width - width)/2;
         y = bounds.y + (bounds.height - height)/2;
         
-        http_proxy = PreferencesManager.getHttpProxy();
-        RPMPackageCommander.setHttpProxy(PreferencesManager.getHttpProxy());
+        http_proxy = PreferencesManager.getHttpProxyURL();
+        RPMPackageCommander.setHttpProxy(PreferencesManager.getHttpProxyURL());
         
         this.rootstrap = rootstrap;
        }
@@ -119,10 +111,7 @@ public class RPMPackageDialog extends Dialog {
         y = bounds.y + (bounds.height - height)/2;
                
                if (enableRootstrap) {
-                       IProject _project = CurrentEnabledProject.getCurrentProject();
-                       IConfiguration config = ManagedBuildManager.getBuildInfo( _project ).getDefaultConfiguration();
-                       configuration = config.getName();
-               http_proxy = PreferencesManager.getHttpProxy();
+               http_proxy = PreferencesManager.getHttpProxyURL();
                RPMPackageCommander.setHttpProxy(http_proxy);
                }
                if (enableTarget) {
@@ -130,19 +119,6 @@ public class RPMPackageDialog extends Dialog {
                }       
        }
        
-       private String getHttpProxy(IProject project) {
-               IManagedBuildInfo info = ManagedBuildManager.getBuildInfo( project ) ;
-               IConfiguration cfg = info.getDefaultConfiguration();
-               ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
-               IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
-
-               // append "OBS_HTTP_PROXY"
-               IEnvironmentVariable var = mngr.getVariable("OBS_HTTP_PROXY", cfgDes, true);
-               if ( var != null ) {
-                       return var.getValue();
-               }
-               return "";
-       }
 
        private void setImage(Shell parentShell) {
                try {
index 32845e7..da3f02e 100644 (file)
@@ -5,6 +5,9 @@ import java.io.BufferedWriter;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.Proxy;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
@@ -19,16 +22,15 @@ import org.osgi.util.tracker.ServiceTracker;
 
 
 public class PreferencesManager {
-       public static final String HTTPPROXY_KEY = "org.tizen.nativeplatform.http.proxy.addr";
-       public static final String PROXYPORT_KEY = "org.tizen.nativeplatform.http.proxy.port";
-       
        public static final String PASSWORD_KEY = "org.tizen.nativeplatform.sudo.password";
 
        private static final String GIT_ACTIVE_CONFIG = "org.tizen.nativeplatform.git.active.config";
-       private static final String GIT_CONFIG_NAME = "org.tizen.nativeplatform.git.config.name";
+       private static final String GIT_CONFIG_NAME = "org.tizen.nativeplatform.site.config.name";
        private static final String GIT_BASE_URI = "org.tizen.nativeplatform.git.base.uri";
        private static final String GIT_LIST_TYPE = "org.tizen.nativeplatform.git.list.type";
        private static final String GIT_LIST_LOCATION = "org.tizen.nativeplatform.git.list.location";
+       private static final String USE_SITE_PROXY = "org.tizen.nativeplatform.site.use.proxy";
+       private static final String PROXY_URL = "rg.tizen.nativeplatform.site.use.proxy.url";
        private static final String GIT_CONFIG_DELIMITER = "|";
        public static final String GIT_LIST_WEB = "WEB";
        public static final String GIT_LIST_LOCAL = "LOCAL";
@@ -36,6 +38,8 @@ public class PreferencesManager {
        private static final String DEFAULT_GIT_BASE_URI = "review.tizen.org";
        private static final String DEFAULT_GIT_LIST_TYPE = GIT_LIST_WEB;
        private static final String DEFAULT_GIT_LIST_LOCATION = "https://review.tizen.org/git/";
+       private static final boolean DEFAULT_USE_SITE_PROXY = false;
+       private static final String DEFAULT_PROXY_URL = "";
        private static final String GIT_LIST_CACHE_FILE_FORMAT = ".%s.index.html";
        
        private static IPreferenceStore prefStore = org.tizen.nativecommon.Activator.getDefault().getPreferenceStore();
@@ -43,10 +47,12 @@ public class PreferencesManager {
        
        public static void setDefaultValues() {
                if ( !prefStore.contains(GIT_CONFIG_NAME) ) {
-                       addGitConfiguration(DEFAULT_GIT_CONFIG_NAME, 
+                       addSiteConfiguration(DEFAULT_GIT_CONFIG_NAME, 
                                        DEFAULT_GIT_BASE_URI, 
                                        DEFAULT_GIT_LIST_TYPE, 
-                                       DEFAULT_GIT_LIST_LOCATION);
+                                       DEFAULT_GIT_LIST_LOCATION,
+                                       DEFAULT_USE_SITE_PROXY,
+                                       DEFAULT_PROXY_URL);
                }
        }
        
@@ -56,47 +62,158 @@ public class PreferencesManager {
        }
        
 
-       public static String getHttpProxy() {
-               IProxyData data = getHttpProxyData();
-               if ( data != null ) {
-                       if ( data.getUserId() != null && data.getPassword() != null ) {
-                               return String.format("http://%s:%s@%s:%d", 
-                                               data.getUserId(), data.getPassword(), data.getHost(), data.getPort());
+       
+       public static boolean isProxyUsed() {
+               if ( isSiteProxyUsed() ) return true;
+               if ( isSystemProxyUsed() ) return true;
+               return false;
+       }
+
+
+       public static Proxy getProxy() {
+               if ( isProxyUsed() ) {
+                       String host = getProxyHost();
+                       int port = getProxyPort();
+                       String protocol = getProxyProtocol();
+                       Proxy.Type proxyType;
+                       if ( protocol.equals("http") || protocol.equals("https")) {
+                               proxyType = Proxy.Type.HTTP;
                        }
-                       else if ( data.getUserId() != null && data.getPassword() != null ) {
-                               return String.format("http://%s@%s:%d", 
-                                               data.getUserId(), data.getHost(), data.getPort());
-                       } 
                        else {
-                               return String.format("http://%s:%d", data.getHost(), data.getPort());
+                               proxyType = Proxy.Type.SOCKS;
                        }
+                       
+                       return new Proxy(proxyType, new InetSocketAddress(host, port));
+               }
+               else {
+                       return null;
+               }
+       }
+       
+
+       public static String getProxyURL() {
+               String proxyURL =  getSiteProxyURL();
+               if ( proxyURL == null ) {
+                       proxyURL = getSystemProxyURL();
                }
                
-               return "";
+               return proxyURL;
+       }
+
+
+       public static String getProxyProtocol() {
+               String proxyURL = getProxyURL();
+               if ( proxyURL == null ) return null;
+               URL url;
+               
+               try {
+                       url = new URL(proxyURL);
+               } catch (MalformedURLException e) {
+                       e.printStackTrace();
+                       return null;
+               }
+               
+               return url.getProtocol();
+       }
+
+       
+       public static String getProxyHost() {
+               String proxyURL = getProxyURL();
+               if ( proxyURL == null ) return null;
+               URL url;
+               
+               try {
+                       url = new URL(proxyURL);
+               } catch (MalformedURLException e) {
+                       e.printStackTrace();
+                       return null;
+               }
+               
+               return url.getHost();
        }
+
        
+       public static int getProxyPort() {
+               String proxyURL = getProxyURL();
+               if ( proxyURL == null ) return -1;
+               URL url;
+               
+               try {
+                       url = new URL(proxyURL);
+               } catch (MalformedURLException e) {
+                       e.printStackTrace();
+                       return -1;
+               }
+               
+               return url.getPort();
+       }
        
-       public static String getHttpProxyHost() {
-               IProxyData data = getHttpProxyData();
-               if ( data != null ) {
-                       return data.getHost();
+
+       
+       
+       private static boolean isSiteProxyUsed() {
+               SiteConfiguration activeConf = loadActiveSiteConfiguration();
+               if ( activeConf == null ) return false;
+               
+               return activeConf.isSiteProxyUsed;
+       }
+       
+
+       private static String getSiteProxyURL() {
+               SiteConfiguration activeConf = loadActiveSiteConfiguration();
+               if ( activeConf == null ) return null;
+               
+               if ( activeConf.isSiteProxyUsed ) {
+                       return activeConf.proxyURL;
                }
                else {
-                       return "";
+                       return null;
                }
        }
        
+
+       private static boolean isSystemProxyUsed() {
+               return  getSystemProxyURL() != null ? true:false;
+       }
+
        
-       public static String getHttpProxyPort() {
-               IProxyData data = getHttpProxyData();
+       private static String getSystemProxyURL() {
+               IProxyData data = getProxyData(IProxyData.SOCKS_PROXY_TYPE);
+               if ( data != null ) {
+                       return String.format("socks://%s:%d", data.getHost(), data.getPort());
+               }
+               
+               data = getProxyData(IProxyData.HTTP_PROXY_TYPE);
                if ( data != null ) {
-                       return String.format("%d", data.getPort() );
+                       return String.format("http://%s:%d", data.getHost(), data.getPort());
                }
+
+               data = getProxyData(IProxyData.HTTPS_PROXY_TYPE);
+               if ( data != null ) {
+                       return String.format("https://%s:%d", data.getHost(), data.getPort());
+               }
+
+               return null;
+       }
+
+       
+       public static String getHttpProxyURL() {
+               String proxyURL = getSiteProxyURL();
+               if ( proxyURL.split(":")[0].equals("http") ) {
+                       return proxyURL;
+               }
+               else {
+                       IProxyData data = getProxyData(IProxyData.HTTP_PROXY_TYPE);
+                       if ( data != null ) {
+                               return String.format("http://%s:%d", data.getHost(), data.getPort());
+                       }
+               }
+               
                return "";
        }
        
        
-    private static IProxyData getHttpProxyData() {
+    private static IProxyData getProxyData( String proxyType ) {
        if ( proxyTracker == null ) {
                proxyTracker = new ServiceTracker<IProxyService,IProxyService>(FrameworkUtil.getBundle(
                                PreferencesManager.class).getBundleContext(), IProxyService.class
@@ -106,15 +223,15 @@ public class PreferencesManager {
        
        IProxyService service = proxyTracker.getService();
                if ( service.isProxiesEnabled() ) {
-                       IProxyData data = service.getProxyData(IProxyData.HTTP_PROXY_TYPE);
-                       if ( data != null && data.getHost() != null ) {
+                       IProxyData data = service.getProxyData( proxyType );
+                       if ( data != null && data.getHost() != null  && !data.getHost().isEmpty()) {
                                return data;
                        } 
                }
                
                return null;
     }
-    
+
     
        public static String getPassword() {
                return prefStore.getString(PASSWORD_KEY);
@@ -163,40 +280,49 @@ public class PreferencesManager {
        }
        
        
-       public static synchronized GitConfiguration loadActiveGitConfiguration() { 
-               ArrayList<String> names = loadGitConfigName();
+       public static synchronized SiteConfiguration loadActiveSiteConfiguration() { 
+               ArrayList<String> names = loadSiteConfigName();
                ArrayList<String> baseURIs  = loadGitBaseURI();
                ArrayList<String> listTypes  = loadGitListType();
                ArrayList<String> listLocations  = loadGitListLocation();
+               ArrayList<String> listUseSiteProxies  = loadUseSiteProxies();
+               ArrayList<String> listProxyURLs = loadProxyURLs();
+               
                int activeId = prefStore.getInt(GIT_ACTIVE_CONFIG);
                if ( activeId == -1 ) {
                        return null;
                }
                
-               GitConfiguration newConfig = new GitConfiguration(
+               SiteConfiguration newConfig = new SiteConfiguration(
                                names.get(activeId),
                                baseURIs.get(activeId), 
                                listTypes.get(activeId), 
-                               listLocations.get(activeId) );
+                               listLocations.get(activeId),
+                               listUseSiteProxies.get(activeId).equals("YES") ? true:false,
+                               listProxyURLs.get(activeId));
                newConfig.setActive(true);
                
                return newConfig;               
        }
 
        
-       public static synchronized ArrayList<GitConfiguration> loadGitConfigurations() { 
-               ArrayList<String> names = loadGitConfigName();
+       public static synchronized ArrayList<SiteConfiguration> loadSiteConfigurations() { 
+               ArrayList<String> names = loadSiteConfigName();
                ArrayList<String> baseURIs  = loadGitBaseURI();
                ArrayList<String> listTypes  = loadGitListType();
                ArrayList<String> listLocations  = loadGitListLocation();
+               ArrayList<String> listUseSiteProxies  = loadUseSiteProxies();
+               ArrayList<String> listProxyURLs = loadProxyURLs();
                int activeId = prefStore.getInt(GIT_ACTIVE_CONFIG);
                
-               ArrayList<GitConfiguration> list = new ArrayList<GitConfiguration>();
+               ArrayList<SiteConfiguration> list = new ArrayList<SiteConfiguration>();
                for( int idx = 0; idx < names.size(); idx++ ) {
-                       GitConfiguration newConfig = new GitConfiguration( names.get(idx),
+                       SiteConfiguration newConfig = new SiteConfiguration( names.get(idx),
                                        baseURIs.get(idx), 
                                        listTypes.get(idx), 
-                                       listLocations.get(idx) );
+                                       listLocations.get(idx),
+                                       listUseSiteProxies.get(idx).equals("YES") ? true:false,
+                                       listProxyURLs.get(idx) );
                        if ( activeId == idx ) {
                                newConfig.setActive(true);
                        }
@@ -207,10 +333,10 @@ public class PreferencesManager {
        }
 
        
-       public static synchronized void addGitConfiguration( String name, String baseURI, 
-                       String listType, String location) {
+       public static synchronized void addSiteConfiguration( String name, String baseURI, 
+                       String listType, String location, boolean useSiteProxy, String proxyURL ) {
                
-               ArrayList<String> newList = loadGitConfigName();
+               ArrayList<String> newList = loadSiteConfigName();
                newList.add(name);
                saveGitConfigName( newList );
                
@@ -225,16 +351,24 @@ public class PreferencesManager {
                newList = loadGitListLocation();
                newList.add(location);
                saveGitListLocation( newList );
-               
+
+               newList = loadUseSiteProxies();
+               newList.add(useSiteProxy ? "YES": "NO");
+               saveUseSiteProxies( newList );
+
+               newList = loadProxyURLs();
+               newList.add(proxyURL);
+               saveProxyURLs( newList );
+
                if (newList.size() == 1 )
-                       setActiveGitConfiguration( 0 );
+                       setActiveSiteConfiguration( 0 );
        }
        
        
-       public static synchronized void updateGitConfiguration( int id, String name, String baseURI, 
-                       String listType, String location) {
+       public static synchronized void updateSiteConfiguration( int id, String name, String baseURI, 
+                       String listType, String location, boolean useSiteProxy, String proxyURL ) {
                
-               ArrayList<String> newList = loadGitConfigName();
+               ArrayList<String> newList = loadSiteConfigName();
                newList.set(id, name);
                saveGitConfigName( newList );
                
@@ -249,16 +383,24 @@ public class PreferencesManager {
                newList = loadGitListLocation();
                newList.set(id, location);
                saveGitListLocation( newList );
+
+               newList = loadUseSiteProxies();
+               newList.set(id, useSiteProxy ? "YES":"NO");
+               saveUseSiteProxies( newList );
+               
+               newList = loadProxyURLs();
+               newList.set(id, proxyURL);
+               saveProxyURLs( newList );
        }
        
        
-       public static synchronized void setActiveGitConfiguration( int id ) {
+       public static synchronized void setActiveSiteConfiguration( int id ) {
                prefStore.setValue(GIT_ACTIVE_CONFIG, id);
        }
        
        
-       public static synchronized void removeGitConfiguration( int id ) {
-               ArrayList<String> newList = loadGitConfigName();
+       public static synchronized void removeSiteConfiguration( int id ) {
+               ArrayList<String> newList = loadSiteConfigName();
                newList.remove(id);
                saveGitConfigName( newList );
                
@@ -277,14 +419,14 @@ public class PreferencesManager {
                int prevActiveId = prefStore.getInt(GIT_ACTIVE_CONFIG);
                if ( prevActiveId == id ) {
                        if (newList.size() == 0 ) {
-                               setActiveGitConfiguration( -1 );
+                               setActiveSiteConfiguration( -1 );
                        }
                        else {
-                               setActiveGitConfiguration( 0 );
+                               setActiveSiteConfiguration( 0 );
                        }
                }
                else if ( prevActiveId > id ) {
-                       setActiveGitConfiguration( id - 1 );
+                       setActiveSiteConfiguration( id - 1 );
                }
                else {
                        // do nothing
@@ -293,7 +435,7 @@ public class PreferencesManager {
        
        
        public static synchronized void refreshGitWebConfiguration( int idx ) throws IOException {
-               String name = loadGitConfigName().get(idx);
+               String name = loadSiteConfigName().get(idx);
                String path  = loadGitListLocation().get(idx);
                
                URL u = new URL(path);
@@ -309,7 +451,7 @@ public class PreferencesManager {
        }
        
        
-       private static ArrayList<String> loadGitConfigName() {
+       private static ArrayList<String> loadSiteConfigName() {
                String values = prefStore.getString(GIT_CONFIG_NAME);
                if ( !values.isEmpty() ) {
                        return new ArrayList<String>(Arrays.asList( values.split("[|]") ) );
@@ -372,7 +514,59 @@ public class PreferencesManager {
                prefStore.setValue(GIT_LIST_LOCATION, generateListString( list ));
        }
        
+       
+       private static ArrayList<String> loadUseSiteProxies() {
+               String values = prefStore.getString(USE_SITE_PROXY);
+               if ( !values.isEmpty() ) {
+                       return new ArrayList<String>(Arrays.asList( values.split("[|]") ) );
+               }
+               else {
+                       return new ArrayList<String>();
+               }
+       }
+
+       
+       private static void saveUseSiteProxies( ArrayList<String> list ) {
+               prefStore.setValue(USE_SITE_PROXY, generateListString( list ));
+       }
+       
+       
+       private static ArrayList<String> loadProxyURLs() {
+               String values = prefStore.getString(PROXY_URL);
+               if ( !values.isEmpty() ) {
+                       ArrayList<String> newList = new ArrayList<String>();
+                       for( String url: values.split("[|]") ) {
+                               if ( url.equals("EMPTY") ) {
+                                       newList.add("");
+                               }
+                               else {
+                                       newList.add(url);
+                               }
+                       }
+                       
+                       return newList;
+               }
+               else {
+                       return new ArrayList<String>();
+               }
+       }
+
+       
+       private static void saveProxyURLs( ArrayList<String> list ) {
+               ArrayList<String> newList = new ArrayList<String>();
+               for( String url: list ) {
+                       if ( url.isEmpty() ) {
+                               newList.add("EMPTY");
+                       }
+                       else {
+                               newList.add(url);
+                       }
+               }
+               
+               prefStore.setValue(PROXY_URL, generateListString( newList ));
+       }
 
+       
        private static String generateListString( ArrayList<String> list ) {
                String newList = "";
                for( String item : list ) {
@@ -384,18 +578,24 @@ public class PreferencesManager {
        }
        
        
-       public static class GitConfiguration {
+       public static class SiteConfiguration {
                public String name;
                public String baseURI;
                public String listType;
                public String listLocation;
                public boolean isActive;
+               public boolean isSiteProxyUsed;
+               public String proxyURL;
                
-               public GitConfiguration(String name1, String baseURI1, String listType1, String listLocation1) {
+               public SiteConfiguration(String name1, String baseURI1, String listType1, String listLocation1,
+                               boolean isSiteProxyUsed1, String proxyURL1 ) {
                        name = name1;
                        baseURI = baseURI1;
                        listType = listType1;
                        listLocation = listLocation1;
+                       isSiteProxyUsed = isSiteProxyUsed1;
+                       proxyURL = proxyURL1;
+                       
                        isActive = false;
                }
                
index 3b0de3b..56bba5e 100644 (file)
@@ -9,10 +9,19 @@ GitConfDlg.Info.Input.SshConn = SSH alias should be input for cloning git projec
 GitConfDlg.Info.Input.GitWeb = Git web address should be input for listing git project
 GitConfDlg.Info.Input.GitListFile = Git list file should be input for listing git project
 
-GitConfDlg.Label.GitConfigName = Name:
-GitConfDlg.Label.GitBaseURI = Base URI:
-GitConfDlg.Label.GitListType = Type:
-GitConfDlg.Label.GitListLocation = Location:
+SiteConfDlg.Label.ConfigName = Name:
+
+SiteConfDlg.Group.Git = Git Configuration
+SiteConfDlg.Label.GitBaseURI = Git Base URI:
+SiteConfDlg.Label.GitBaseURI.Ex = ex) ssh://myid:mypasswd@my.host.name:29418
+SiteConfDlg.Label.GitListType = Type:
+SiteConfDlg.Label.GitListLocation = Location:
+SiteConfDlg.Button.Browse = Browse
+
+SiteConfDlg.Group.Proxy = Proxy Configuration
+SiteConfDlg.Button.UseSiteProxy = Use Site Proxy
+SiteConfDlg.Label.ProxyURL = Proxy URL:
+SiteConfDlg.Label.ProxyURL.Ex = ex) http://proxy.host.name:8080
 
 GitConfPref.Button.Add = Add
 GitConfPref.Button.Edit = Edit
@@ -31,4 +40,6 @@ FileDlg.Filter.Ext = txt
 
 GitConfDlg.Error.NoName = Must specify configuration name field!
 GitConfDlg.Error.NoBaseURI = Must specify base URI field!
-GitConfDlg.Error.NoLocation = Must specify location field!
\ No newline at end of file
+GitConfDlg.Error.NoLocation = Must specify location field!
+GitConfDlg.Error.NoProxyURL = Must specify proxy URL!
+GitConfDlg.Error.MalformedURL = Malformed URL is used!
\ No newline at end of file
index 35c1901..784bd5a 100644 (file)
@@ -1,5 +1,7 @@
 package org.tizen.nativeplatform.preferences.ui;
 
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ResourceBundle;
 
 import org.eclipse.core.runtime.IPath;
@@ -14,6 +16,7 @@ import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
@@ -31,16 +34,19 @@ public class SiteConfigurationDialog extends Dialog {
        private Combo gitListTypeCombo;
        private Text gitListLocationText;
        private Button fileBrowseBt;
-       
+       private Button useSiteProxyBt;
+       private Text proxyURLText;
+
        private String siteConfigName = "";
        private String gitBaseURI = "";
        private String gitListType = "";
        private String gitListLocation = "";
+       private boolean useSiteProxy = false;
+       private String proxyURL = "";
        
        private int x = 0;
        private int y = 0;
        private final int width = 500;
-       private final int height = 250;
        private Shell shell;
        
        private final String BUNDLE_NAME = SiteConfigurationDialog.class.getPackage().getName() + ".GitConfUIMessages";//$NON-NLS-1$
@@ -52,19 +58,24 @@ public class SiteConfigurationDialog extends Dialog {
                gitBaseURI = "";
                gitListType = "";
                gitListLocation = "";
+               useSiteProxy= false;
+               proxyURL = "";
 
                this.shell = parentShell;
        }
 
        
        protected SiteConfigurationDialog(Shell parentShell, 
-                       String gitConfigName1, String gitBaseURI1 , String gitListType1, String gitListLocation1 ) {
+                       String gitConfigName1, String gitBaseURI1 , String gitListType1, String gitListLocation1,
+                       boolean useSiteProxy1, String proxyURL1 ) {
                super(parentShell);     
                
                siteConfigName = gitConfigName1;
                gitBaseURI = gitBaseURI1;
                gitListType = gitListType1;
                gitListLocation = gitListLocation1;
+               useSiteProxy= useSiteProxy1;
+               proxyURL = proxyURL1;
                
                this.shell = parentShell;
        }
@@ -82,9 +93,8 @@ public class SiteConfigurationDialog extends Dialog {
                }
                Rectangle bounds = newShell.getBounds();
         x = bounds.x + (bounds.width - width)/2;
-        y = bounds.y + (bounds.height - height)/2;
                newShell.setLocation(x, y);
-               newShell.setSize(width, height);
+               newShell.setMinimumSize(width, 0);
        }
        
        
@@ -95,69 +105,84 @@ public class SiteConfigurationDialog extends Dialog {
                composite.setLayoutData(new GridData(GridData.FILL_BOTH));
                composite.setLayout(new GridLayout(1, false));       
 
-               createGitConfigNameComposite(composite);        
-        createGitBaseURIComposite(composite);        
-        createGitListComposite(composite);
+               createSiteConfigNameComposite(composite);
+               createGitConfigGroupComposite( composite );
+               createProxyConfigGroupComposite( composite );
         
                return null;
        }
        
 
-       private void createGitConfigNameComposite(Composite parent) {
+       private void createSiteConfigNameComposite(Composite parent) {
                Composite composite = new Composite( parent, SWT.NONE);
                composite.setLayoutData(new GridData(GridData.FILL_BOTH));
                composite.setLayout(new GridLayout(2, false));
 
         Label configNameLabel = new Label(composite, SWT.NONE);
         GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-               gridData.widthHint = 70;
+               gridData.widthHint = 50;
                configNameLabel.setLayoutData(gridData);
                configNameLabel.setAlignment(SWT.RIGHT);
-        configNameLabel.setText(resources.getString("GitConfDlg.Label.GitConfigName"));
+        configNameLabel.setText(resources.getString("SiteConfDlg.Label.ConfigName"));
         
         siteConfigNameText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
         gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
-               gridData.minimumHeight = 0;
+               gridData.minimumWidth = 200;
         siteConfigNameText.setLayoutData(gridData);
         siteConfigNameText.setText(siteConfigName);
        }
        
-    
-       private void createGitBaseURIComposite(Composite parent) {
-               Composite composite = new Composite( parent, SWT.NONE);
-               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-               composite.setLayout(new GridLayout(2, false));
+
+       private void createGitConfigGroupComposite(Composite parent) {
+               Group group = new Group(parent, SWT.NONE);
+               group.setLayout(new GridLayout(3, false));
+               group.setText(resources.getString("SiteConfDlg.Group.Git"));
+               GridData gridData = new GridData(GridData.FILL_BOTH);
+               group.setLayoutData(gridData);
+
+               createGitBaseURIComposite(group);        
+        createGitListComposite(group);
+       }
+       
+       
+       private void createGitBaseURIComposite(Composite composite) {
                
         Label gitBaseURILebel = new Label(composite, SWT.NONE);
         GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-               gridData.widthHint = 70;
+               gridData.widthHint = 100;
                gitBaseURILebel.setLayoutData(gridData);
                gitBaseURILebel.setAlignment(SWT.RIGHT);
-               gitBaseURILebel.setText(resources.getString("GitConfDlg.Label.GitBaseURI"));
+               gitBaseURILebel.setText(resources.getString("SiteConfDlg.Label.GitBaseURI"));
                
         gitBaseURIText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
         gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
-               gridData.minimumHeight = 0;
+               gridData.horizontalSpan = 2;
         gitBaseURIText.setLayoutData(gridData);
         gitBaseURIText.setText(gitBaseURI);
+        
+        new Label( composite, SWT.NONE );
+        
+        Label gitBaseURIExLabel = new Label(composite, SWT.NONE);
+        gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gridData.horizontalSpan = 2;
+               gitBaseURIExLabel.setLayoutData(gridData);
+               gitBaseURIExLabel.setText(resources.getString("SiteConfDlg.Label.GitBaseURI.Ex"));
+
        }
 
        
-       private void createGitListComposite(Composite parent) {
-               Composite composite = new Composite( parent, SWT.NONE);
-               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-               composite.setLayout(new GridLayout(2, false));
+       private void createGitListComposite(Composite composite) {
 
                Label gitListTypeLebel = new Label(composite, SWT.NONE);
         GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-               gridData.widthHint = 70;
+               gridData.widthHint = 100;
                gitListTypeLebel.setLayoutData(gridData);
                gitListTypeLebel.setAlignment(SWT.RIGHT);
-        gitListTypeLebel.setText(resources.getString("GitConfDlg.Label.GitListType"));
+        gitListTypeLebel.setText(resources.getString("SiteConfDlg.Label.GitListType"));
         
         gitListTypeCombo = new Combo(composite, SWT.READ_ONLY);
         gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
-               gridData.minimumHeight = 0;
+               gridData.horizontalSpan = 2;
                gitListTypeCombo.setLayoutData(gridData);
                String newItems[] = { PreferencesManager.GIT_LIST_LOCAL, PreferencesManager.GIT_LIST_WEB };
         gitListTypeCombo.setItems(newItems);
@@ -186,30 +211,26 @@ public class SiteConfigurationDialog extends Dialog {
                gitListTypeCombo.select(1);
         }
 
-               Label gitListLocationLebel = new Label(composite, SWT.NONE);
+               Label gitListLocationLabel = new Label(composite, SWT.NONE);
         gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-               gridData.widthHint = 70;
-               gitListLocationLebel.setLayoutData(gridData);
-               gitListLocationLebel.setAlignment(SWT.RIGHT);
-        gitListLocationLebel.setText(resources.getString("GitConfDlg.Label.GitListLocation"));
+               gridData.widthHint = 100;
+               gitListLocationLabel.setLayoutData(gridData);
+               gitListLocationLabel.setAlignment(SWT.RIGHT);
+        gitListLocationLabel.setText(resources.getString("SiteConfDlg.Label.GitListLocation"));
         
         createGitListLocationComposite(composite);
        }
        
        
-       private void createGitListLocationComposite(Composite parent) {
-               Composite composite = new Composite( parent, SWT.NONE);
-               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-               composite.setLayout(new GridLayout(2, false));
+       private void createGitListLocationComposite(Composite composite) {
 
                gitListLocationText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
                GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
-               gridData.minimumHeight = 0;
                gitListLocationText.setLayoutData(gridData);
                gitListLocationText.setText(gitListLocation);
                
         fileBrowseBt = new Button(composite, SWT.PUSH);
-        fileBrowseBt.setText("Browse");
+        fileBrowseBt.setText(resources.getString("SiteConfDlg.Button.Browse"));
         
         fileBrowseBt.addMouseListener(new MouseListener()
         {
@@ -244,24 +265,110 @@ public class SiteConfigurationDialog extends Dialog {
        }
 
        
+       private void createProxyConfigGroupComposite( Composite parent ) {
+               Group group = new Group(parent, SWT.NONE);
+               group.setLayout(new GridLayout(2, false));
+               group.setText(resources.getString("SiteConfDlg.Group.Proxy"));
+               GridData gridData = new GridData(GridData.FILL_BOTH);
+               group.setLayoutData(gridData);
+               
+               // check box
+               useSiteProxyBt = new Button(group, SWT.CHECK);
+               useSiteProxyBt.setText(resources.getString("SiteConfDlg.Button.UseSiteProxy"));
+               gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gridData.horizontalSpan = 2;
+               useSiteProxyBt.setLayoutData(gridData);
+               useSiteProxyBt.setSelection(useSiteProxy);
+               useSiteProxyBt.addSelectionListener( new SelectionListener() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               useSiteProxy = useSiteProxyBt.getSelection();
+                               proxyURLText.setEnabled(useSiteProxy);
+                       }
+
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       
+               });
+               
+               // label , text
+        Label proxyURLLabel = new Label(group, SWT.NONE);
+        gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gridData.widthHint = 100;
+               proxyURLLabel.setLayoutData(gridData);
+               proxyURLLabel.setAlignment(SWT.RIGHT);
+               proxyURLLabel.setText(resources.getString("SiteConfDlg.Label.ProxyURL"));
+               
+        proxyURLText = new Text(group, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
+        gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+               proxyURLText.setLayoutData(gridData);
+               proxyURLText.setText(proxyURL);
+               proxyURLText.setEnabled(false);
+               
+        new Label( group, SWT.NONE );
+        
+        Label gitBaseURIExLabel = new Label(group, SWT.NONE);
+        gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gitBaseURIExLabel.setLayoutData(gridData);
+               gitBaseURIExLabel.setText(resources.getString("SiteConfDlg.Label.ProxyURL.Ex"));
+       }
+
+       
        @Override
        protected void okPressed() {
                siteConfigName = siteConfigNameText.getText().trim();
                gitBaseURI = gitBaseURIText.getText().trim();
                gitListType = gitListTypeCombo.getText();
                gitListLocation = gitListLocationText.getText().trim();
+               useSiteProxy = useSiteProxyBt.getSelection();
+               proxyURL = proxyURLText.getText().trim();
+               
                if ( siteConfigName.isEmpty()) {
                        DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.NoName"));
+                       return;
                }
-               else if ( gitBaseURI.isEmpty() ) {
+               if ( gitBaseURI.isEmpty() ) {
                        DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.NoBaseURI"));
+                       return;
                }
-               else if ( gitListLocation.isEmpty() ) {
+               if ( gitListLocation.isEmpty() ) {
                        DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.NoLocation"));
+                       return;
                }
-               else {
-                       super.okPressed();
+               if ( useSiteProxy ) {
+                       if ( proxyURL.isEmpty() ) {
+                               DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.NoProxyURL"));
+                       }
+                       
+                       try {
+                               URL url = new URL(proxyURL);
+                               String protocol = url.getProtocol();
+                               String host = url.getHost();
+                               int port = url.getPort();
+                               
+                               if ( ( protocol.compareToIgnoreCase("socks") != 0 &&
+                                               protocol.compareToIgnoreCase("http")  != 0 &&
+                                               protocol.compareToIgnoreCase("https")  != 0 ) ||
+                                               host == null ||host.isEmpty() ) {
+                                       DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.MalformedURL"));
+                                       return;
+                               }
+                               // use default port
+                               if ( port == -1 ) port = 8080;
+                               
+                               // make new URL
+                               proxyURL = String.format("%s://%s:%d", protocol, host, port);
+                               
+                       } catch (MalformedURLException e) {
+                               DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.MalformedURL"));
+                               return;
+                       }
+
                }
+
+               super.okPressed();
        }
 
        public String getSiteConfigName() {
@@ -282,4 +389,19 @@ public class SiteConfigurationDialog extends Dialog {
        public String getGitListLocation() {
                return gitListLocation;
        }
+       
+       
+       public boolean isSiteProxyUsed() {
+               return useSiteProxy;
+       }
+       
+       
+       public String getProxyURL() {
+               if ( useSiteProxy ) {
+                       return proxyURL;
+               }
+               else {
+                       return "";
+               }
+       }
 }
index 9458e4a..ddb71dc 100644 (file)
@@ -34,7 +34,7 @@ import org.tizen.nativeplatform.preferences.PreferencesManager;
 
 public class SiteConfigurationPreferencePage extends PreferencePage implements IWorkbenchPreferencePage{
 
-    private ArrayList<PreferencesManager.GitConfiguration> gitConfigList;
+    private ArrayList<PreferencesManager.SiteConfiguration> siteConfigList;
     private TableViewer gitConfigTable;
     private Button addBt;
     private Button editBt;
@@ -46,7 +46,7 @@ public class SiteConfigurationPreferencePage extends PreferencePage implements I
        private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
     
     public SiteConfigurationPreferencePage() {
-       gitConfigList = new ArrayList<PreferencesManager.GitConfiguration>();
+       siteConfigList = new ArrayList<PreferencesManager.SiteConfiguration>();
     }
     
     @Override
@@ -134,7 +134,7 @@ public class SiteConfigurationPreferencePage extends PreferencePage implements I
                        public void selectionChanged(SelectionChangedEvent event) {
                                int idx = gitConfigTable.getTable().getSelectionIndex();
                                if ( idx != -1 ) {
-                                       String gitListType = gitConfigList.get(idx).listType;
+                                       String gitListType = siteConfigList.get(idx).listType;
                                        if ( gitListType.equals(PreferencesManager.GIT_LIST_WEB) ) {
                                                updateBt.setEnabled(true);
                                        }
@@ -155,15 +155,15 @@ public class SiteConfigurationPreferencePage extends PreferencePage implements I
                
         });
         
-        gitConfigTable.setInput(gitConfigList);
+        gitConfigTable.setInput(siteConfigList);
     }
     
     
     private void updateData() {
-       gitConfigList = PreferencesManager.loadGitConfigurations();
+       siteConfigList =        PreferencesManager.loadSiteConfigurations();
        
        if (gitConfigTable != null ) {
-               gitConfigTable.setInput(gitConfigList);
+               gitConfigTable.setInput(siteConfigList);
        }
     }
     
@@ -191,11 +191,13 @@ public class SiteConfigurationPreferencePage extends PreferencePage implements I
                                SiteConfigurationDialog dialog = new SiteConfigurationDialog(getShell());
                                
                                if (dialog.open() == SiteConfigurationDialog.OK) {
-                                       PreferencesManager.addGitConfiguration( 
+                                       PreferencesManager.addSiteConfiguration( 
                                                        dialog.getSiteConfigName(),
                                                        dialog.getGitBaseURI(),
                                                        dialog.getGitListType(),
-                                                       dialog.getGitListLocation()     );
+                                                       dialog.getGitListLocation(),
+                                                       dialog.isSiteProxyUsed(),
+                                                       dialog.getProxyURL());
 
                                        updateData();
                                }
@@ -221,20 +223,25 @@ public class SiteConfigurationPreferencePage extends PreferencePage implements I
                        @Override
                        public void mouseDown(MouseEvent e) {   
                                int idx = gitConfigTable.getTable().getSelectionIndex();
-                               String gitConfigName = gitConfigList.get(idx).name; 
-                               String gitBaseURI = gitConfigList.get(idx).baseURI; 
-                               String gitListType = gitConfigList.get(idx).listType; 
-                               String gitListLocation = gitConfigList.get(idx).listLocation;
+                               String siteConfigName = siteConfigList.get(idx).name; 
+                               String gitBaseURI = siteConfigList.get(idx).baseURI; 
+                               String gitListType = siteConfigList.get(idx).listType; 
+                               String gitListLocation = siteConfigList.get(idx).listLocation;
+                               boolean useSiteProxy =  siteConfigList.get(idx).isSiteProxyUsed;
+                               String proxyURL =  siteConfigList.get(idx).proxyURL;
                                
                                SiteConfigurationDialog dialog = new SiteConfigurationDialog(getShell(), 
-                                               gitConfigName, gitBaseURI, gitListType, gitListLocation );
+                                               siteConfigName, gitBaseURI, gitListType, gitListLocation,
+                                               useSiteProxy, proxyURL );
                                if (dialog.open() == SiteConfigurationDialog.OK) {
-                                       PreferencesManager.updateGitConfiguration(
+                                       PreferencesManager.updateSiteConfiguration(
                                                        gitConfigTable.getTable().getSelectionIndex(),
                                                        dialog.getSiteConfigName(),
                                                        dialog.getGitBaseURI(),
                                                        dialog.getGitListType(),
-                                                       dialog.getGitListLocation()     );
+                                                       dialog.getGitListLocation(),
+                                                       dialog.isSiteProxyUsed(),
+                                                       dialog.getProxyURL() );
                                        updateData();
                                }
                        }
@@ -285,7 +292,7 @@ public class SiteConfigurationPreferencePage extends PreferencePage implements I
 
                        @Override
                        public void mouseDown(MouseEvent e) {   
-                               PreferencesManager.setActiveGitConfiguration(
+                               PreferencesManager.setActiveSiteConfiguration(
                                                gitConfigTable.getTable().getSelectionIndex());
                                
                                updateData();
@@ -309,7 +316,7 @@ public class SiteConfigurationPreferencePage extends PreferencePage implements I
 
                        @Override
                        public void mouseDown(MouseEvent e) {   
-                               PreferencesManager.removeGitConfiguration(
+                               PreferencesManager.removeSiteConfiguration(
                                                gitConfigTable.getTable().getSelectionIndex());
                                updateData();
                        }
@@ -335,7 +342,7 @@ public class SiteConfigurationPreferencePage extends PreferencePage implements I
 
                @Override
                public String getColumnText(Object element, int columnIndex) {
-                       PreferencesManager.GitConfiguration config = (PreferencesManager.GitConfiguration)element;
+                       PreferencesManager.SiteConfiguration config = (PreferencesManager.SiteConfiguration)element;
                        
                        switch(columnIndex) {
                        case 0:
index 9330073..a70599e 100644 (file)
@@ -30,6 +30,7 @@ import org.tizen.nativecommon.build.exception.SBIException;
 import org.tizen.nativecommon.build.model.SBIModel;
 import org.tizen.nativecommon.build.model.Target;
 import org.tizen.nativeplatform.password.SudoPasswdManager;
+import org.tizen.nativeplatform.preferences.PreferencesManager;
 import org.tizen.nativeplatform.views.model.PlatformRootstrap;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
@@ -62,8 +63,8 @@ public class RootstrapManager {
                                String path = sbi.getRootstrapPathFromRootstrapID(id);
                                ArrayList<String> reposURLs = new ArrayList<String>();
                                String rootstrapPath = sbi.getRootstrapPropertyValue(id, "REPOSITORY_URLS");
-                               if ( rootstrapPath != null && rootstrapPath.split("|").length >= 1 ) {
-                                       for ( String url : rootstrapPath.split("|") ) {
+                               if ( rootstrapPath != null && rootstrapPath.split("[|]").length >= 1 ) {
+                                       for ( String url : rootstrapPath.split("[|]") ) {
                                                reposURLs.add( url );
                                        }
                                }
@@ -261,7 +262,21 @@ public class RootstrapManager {
                for(  String url: reposURLs ) {
                        urlData += (urlData.isEmpty() ? url : "," + url );
                }
-               String command = String.format( "%s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform", rogen, id, baseArch, urlData );
+               
+               String command;
+               if ( PreferencesManager.isProxyUsed() ) {
+                       String protocol = PreferencesManager.getProxyProtocol();
+                       String host = PreferencesManager.getProxyHost();
+                       int port = PreferencesManager.getProxyPort();
+                       String envSetup = String.format("%s_proxy=%s://%s:%d", protocol, protocol, host, port);
+                       command = String.format( "%s %s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform",
+                                       envSetup, rogen, id, baseArch, urlData );
+               } 
+               else {
+                       command = String.format( "%s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform", 
+                                       rogen, id, baseArch, urlData );
+               }
+               
                if ( !commandWithSudo( command, "Platform Internal") ) {
                        return false;
                }
index a570d50..1d2a270 100644 (file)
@@ -3,10 +3,8 @@ package org.tizen.nativeplatform.rootstrap;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
 import java.net.Proxy;
-import java.net.SocketAddress;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
@@ -24,14 +22,6 @@ public class SnapshotURLParser {
        public ArrayList<ICheckTreeItem> parse(String url) 
                        throws MalformedURLException, IOException {
                
-               String proxyHost = PreferencesManager.getHttpProxyHost(); 
-
-               Proxy p = null;
-               if (proxyHost != null && !proxyHost.isEmpty() ) {
-                       int porxyPort = Integer.parseInt(PreferencesManager.getHttpProxyPort());
-                       SocketAddress addr = new InetSocketAddress(proxyHost, porxyPort);
-                       p = new Proxy(Proxy.Type.HTTP, addr);                   
-               }
                if (url.endsWith("/")) {
                        url = url.substring(0, url.length() - 1);                       
                }
@@ -43,6 +33,7 @@ public class SnapshotURLParser {
                        
                URL u = new URL(repoPath);                      
                URLConnection yc;
+               Proxy p = PreferencesManager.getProxy();
                if (p == null) {
                        yc = u.openConnection();                                
                } else {
index 2fbfb22..02d3df5 100644 (file)
@@ -196,13 +196,16 @@ public class AddRootstrapDialog extends Dialog {
                                                        monitor.beginTask(resources.getString("GenRootDlg.Progress.Msg.Searching"), -1);
                                                        try {
                                                                final SnapshotURLParser c = new SnapshotURLParser();                    
+                                                               snapshotInfos = null;
                                                                snapshotInfos = c.parse(snapshotUrl);
                                                        } catch (final IOException e) {
                                                                e.printStackTrace();
                                                                SWTUtil.getDisplay().asyncExec( new Runnable() {
                                                        @Override
                                                        public void run() {
-                                                               DialogUtil.openErrorDialog(e.toString());
+                                                               DialogUtil.openErrorDialog(
+                                                                               resources.getString("GenRootDlg.Error.Snapshot.Failed")+
+                                                                               "("+e.toString()+")");
                                                        }
                                                    });
                                                        }
@@ -214,12 +217,13 @@ public class AddRootstrapDialog extends Dialog {
                                        return;
                                } 
                                
+                               archCombo.removeAll();
                                if (snapshotInfos == null || snapshotInfos.size() == 0 ) {
+                                       UpdateRepositoryURL();
                                        return;
                                }
                                
                                // add architecture list
-                               archCombo.removeAll();
                                for ( ICheckTreeItem item: snapshotInfos ) {
                                        archCombo.add(item.getText());
                                }
@@ -275,9 +279,11 @@ public class AddRootstrapDialog extends Dialog {
                int selectIdx = archCombo.getSelectionIndex();
                // show repository URLs
                ArrayList<String> data = new ArrayList<String>();
-               ArrayList<ICheckTreeItem> children = snapshotInfos.get(selectIdx).getChildren();
-               for ( int idx = 0; idx < children.size(); idx++ ) {
-                       data.add(String.format("url%d|%s", idx, children.get(idx).getText() ) );
+               if ( selectIdx >= 0 ) {
+                       ArrayList<ICheckTreeItem> children = snapshotInfos.get(selectIdx).getChildren();
+                       for ( int idx = 0; idx < children.size(); idx++ ) {
+                               data.add(String.format("url%d|%s", idx, children.get(idx).getText() ) );
+                       }
                }
                reposURLViewer.setInput(data);
        }
index 046e29e..0e0dec1 100644 (file)
@@ -33,6 +33,8 @@ GenRootDlg.Progress.Msg.Searching = Seaching repositories
 GenRootDlg.Error.Fail.Generate = Failed to generate rootstrap
 GenRootDlg.Error.Empty.Snapshot = Snapshot URL is empty
 GenRootDlg.Error.Empty.Rootstrap = Rootstrap is empty
+GenRootDlg.Error.Snapshot.Failed = Getting snapshot information failed!\n
+GenRootDlg.Error.Gen.Rootstrap.Failed = Generating rootstrap failed!!\n
 
 SelectRootDlg.Title = Warning
 SelectRootDlg.Msg.LastOne = "%s [%s]" rootstrap is the last one. You can not remove it
index a618c70..c20f0f3 100644 (file)
@@ -309,7 +309,7 @@ public class RootstrapView extends ViewPart {
                        });                                     
                } catch (Exception e1) {
                        e1.printStackTrace();
-                       DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Progress.Msg.Generating") );
+                       DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed") );
                        return;
                }
 
index 71342d5..3c42c27 100644 (file)
@@ -83,7 +83,7 @@ public class TemplateTizenPlatformNewWizard extends TemplateTizenNewWizard {
         
         /* create git items */
         String projTypeName = PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE;
-        PreferencesManager.GitConfiguration config = PreferencesManager.loadActiveGitConfiguration();
+        PreferencesManager.SiteConfiguration config = PreferencesManager.loadActiveSiteConfiguration();
         
         if (config != null ) {
                EntryDescriptor gitEntryDes = null;