[Title] Removed duplicated codes
authordonghyuk.yang <donghyuk.yang@samsung.com>
Wed, 10 Jul 2013 06:20:14 +0000 (15:20 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Wed, 10 Jul 2013 06:20:14 +0000 (15:20 +0900)
18 files changed:
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/ui/GBSBuildConfigurationTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegateForAttach.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformCommonTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectAttachLaunchShortcut.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectCommonLaunchShortcut.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectCoredumpLaunchShortcut.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectLaunchShortcut.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/TizenPathInputDialog.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchCommonPage.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingBinPage.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRepoDialog.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/CommonTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/ModifyRepoDialog.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoCommonDialog.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtil.java

index 51ff10c..8f7d7e3 100644 (file)
@@ -27,7 +27,6 @@
 
 package org.tizen.nativeplatform.build.ui;
 
-
 import java.util.ArrayList;
 
 import org.eclipse.cdt.core.settings.model.ICResourceDescription;
@@ -53,409 +52,363 @@ import org.tizen.nativeplatform.gbs.GBSOptionManager;
 
 @SuppressWarnings("restriction")
 public class GBSBuildConfigurationTab extends AbstractCBuildPropertyTab {
-       protected boolean checked;
-       private Button option_clean;
-       private Button option_ccache;
-       private Button option_overwrite;
-       private Button option_includeall;
-       private Button option_skipRepos;
-       private Button option_noConfigure;
-       private Button option_commit;
-       private Button option_extraPacks;
-       private Button option_threads;
-       private Button option_exclude;
-       private Button option_keepPacks;
-       private Button option_noinit;
-       private Button option_incremental;
-       private Text text_extraPacks;
-       private Text text_exclude;
-       private Text text_threads;
-       private Text text_commit;       
-
-       private final String EMPTY_STRING = "";
-       private final String PREFIX_DESC = ": ";
-       private final String ERROR_LABEL = "Check if GBS(>= %s) is installed."; 
-       
-       private String[] avaiableOptions = {
-                       "--clean",
-                       "--ccache",
-                       "--overwrite",
-                       "--include-all",
-                       "--skip-conf-repos",
-                       "--no-configure",
-                       "--threads",
-                       "--commit",
-                       "--exclude",
-                       "--extra-packs",                        
-                       "--keep-packs",                 
-                       "--noinit",                     
-                       "--incremental"                 
-               };
-       
-       private boolean[] checkOptions = {
-                       false,
-                       false,
-                       false,
-                       false,
-                       false,
-                       false,
-                       false,
-                       false,
-                       false,
-                       false,
-                       false,
-                       false,
-                       false
-       };
-       
-       private Button[] buttons = {
-                       option_clean, 
-                       option_ccache, 
-                       option_overwrite, 
-                       option_includeall,
-                       option_skipRepos,
-                       option_noConfigure,
-                       option_threads,
-                       option_commit,
-                       option_exclude,
-                       option_extraPacks,
-                       option_keepPacks,
-                       option_noinit,
-                       option_incremental
-                       
-               };
-       
-       private Text[] texts = {
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       text_threads,
-                       text_commit,
-                       text_exclude,
-                       text_extraPacks,
-                       null,
-                       null,
-                       null                    
-               };
-       
-       public void createControls(Composite _parent, ICPropertyProvider _provider) {
-               page = _provider;
-               if (canBeVisible()) {
-                       createControls(_parent);
-               }
-       }
-
-       @Override
-       protected void createControls(Composite parent) {
-               super.createControls(parent);
-               usercomp.setLayout(new GridLayout(1, false));
-               
-               if (!GBSOptionManager.isInitialized()) {
-                       GBSOptionManager.initOptions();
-               }
-               
-               if (GBSOptionManager.getOptions().isEmpty()) {
-                       createErrorComposite(usercomp);
-                       return;
-               }
-               
-               Composite composite = new Composite(usercomp, SWT.NONE);
-               GridLayout gridLayout = new GridLayout(2,false);
-               gridLayout.marginBottom = 0;
-               gridLayout.marginTop = 0;
-               gridLayout.marginLeft = 0;
-               gridLayout.marginRight = 0;
-               GridData gd = new GridData(GridData.BEGINNING, GridData.FILL, false, false);            
-               gd.widthHint = 800;
-               composite.setLayout(gridLayout);
-               composite.setLayoutData(gd);
-               
-               createCleanOption(composite, 0);
-               createCcacheOption(composite, 1);
-               createOverwriteOption(composite, 2);
-               createIncludeAllOption(composite, 3);
-               createSkipReposOption(composite, 4);
-               createNoConfigureOption(composite, 5);
-               createThreadsOption(composite, 6);
-               createCommitOption(composite, 7);
-               createExcludeOption(composite, 8);
-               createExtraPacksOption(composite, 9);           
-               createKeepPacksOption(composite, 10);           
-               createNoInitOption(composite, 11);              
-               createIncrementalOption(composite, 12);         
-       }
-       
-       private void createErrorComposite(Composite parent) {
-               Composite composite = new Composite(usercomp, SWT.NONE);
-               GridLayout gridLayout = new GridLayout(1,false);
-               gridLayout.marginBottom = 0;
-               gridLayout.marginTop = 0;
-               gridLayout.marginLeft = 0;
-               gridLayout.marginRight = 0;
-               GridData gd = new GridData(GridData.BEGINNING, GridData.FILL, false, false);            
-               gd.widthHint = 800;
-               composite.setLayout(gridLayout);
-               composite.setLayoutData(gd);
-               
-               Label errorLabel = new Label(composite, SWT.NONE);
-               errorLabel.setText(String.format(ERROR_LABEL, Double.toString(GBSOptionManager.MIN_GBS_VERSION)));
-       }
-       
-       private void createCcacheOption(Composite parent, int index) {
-               createOption(parent, index);
-       }
-       
-       private void createCleanOption(Composite parent, int index) {
-               createOption(parent, index);
-       }
-       
-       private void createOverwriteOption(Composite parent, int index) {
-               createOption(parent, index);
-       }
-       
-       private void createIncludeAllOption(Composite parent, int index) {
-               createOption(parent, index);
-       }
-       
-       private void createSkipReposOption(Composite parent, int index) {
-               createOption(parent, index);
-       }
-       
-       private void createNoConfigureOption(Composite parent, int index) {
-               createOption(parent, index);
-       }
-       
-       private void createExtraPacksOption(Composite parent, int index) {
-               createOptionWithText(parent, index);
-       }
-       
-       private void createExcludeOption(Composite parent, int index) {
-               createOptionWithText(parent, index);
-       }
-       
-       private void createCommitOption(Composite parent, int index) {
-               createOptionWithText(parent, index);
-       }
-       
-       private void createThreadsOption(Composite parent, final int index) {
-               createOptionWithText(parent, index);    
-       }
-       
-       private void createKeepPacksOption(Composite parent, int index) {
-               createOption(parent, index);
-       }
-
-       private void createNoInitOption(Composite parent, int index) {
-               createOption(parent, index);
-       }
-
-       private void createIncrementalOption(Composite parent, int index) {
-               createOption(parent, index);
-       }
-
-       private void createOptionWithText(Composite parent, final int index) {          
-               
-               GBSOption op = GBSOptionManager.getOption(avaiableOptions[index]);
-               if (op == null) {
-                       return;
-               }
-
-               buttons[index] = new Button(parent, SWT.CHECK);
-               buttons[index].setText(op.getOption());
-               buttons[index].setSelection(checkOptions[index]);
-               
-               buttons[index].addSelectionListener(new SelectionAdapter() {
-                       public void widgetSelected(SelectionEvent event) {                              
-                               Button button = (Button) event.widget;
-                               if (button.getSelection()) {
-                                       texts[index].setEnabled(true);
-                                       checkOptions[index] = true;                                     
-                                       if (!isMultiConfiguration()) {
-                                               String value = texts[index].getText();
-                                               String option = String.format("%s=%s", avaiableOptions[index], value);
-                                               PlatformConfigurationManager.addGBSOptions(getCfg(), option);
-                                       }
-                               } else {
-                                       texts[index].setEnabled(false);
-                                       checkOptions[index] = false;
-                                       if (!isMultiConfiguration()) {
-                                               PlatformConfigurationManager.removeGBSOptions(getCfg(), avaiableOptions[index]);
-                                       }
-                               }
-                       }
-               });
-               
-               Label desc = new Label(parent, SWT.NONE);
-               desc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-               desc.setText(getDesc(op));
-               
-               texts[index] = new Text(parent, SWT.BORDER);
-               GridData gd = new GridData(GridData.FILL_BOTH);
-               gd.horizontalSpan = 2;
-               texts[index].setLayoutData(gd);
-               texts[index].setEnabled(checkOptions[index]);
-               texts[index].addModifyListener(new ModifyListener() {
-                       public void modifyText(ModifyEvent event) {
-                               Text text = (Text)event.widget;
-                               String value = text.getText();
-                               if (value.isEmpty()) {
-                                       return;
-                               }                               
-                               if (!isMultiConfiguration()) {
-                                       String option = String.format("%s=%s", avaiableOptions[index], value);
-                                       PlatformConfigurationManager.replaceGBSOptions(getCfg(), option);
-                               }
-                       }
-               });
-               
-       }
-       
-       private void createOption(Composite parent, final int index) {
-               
-               GBSOption op = GBSOptionManager.getOption(avaiableOptions[index]);
-               if (op == null) {
-                       return;
-               }
-               buttons[index] = new Button(parent, SWT.CHECK);
-               buttons[index].setText(op.getOption());
-               buttons[index].setSelection(checkOptions[index]);               
-               buttons[index].addSelectionListener(new SelectionAdapter() {
-                       public void widgetSelected(SelectionEvent event) {                              
-                               Button button = (Button) event.widget;
-                               if (button.getSelection()) {                                    
-                                       if (!isMultiConfiguration()) {
-                                               PlatformConfigurationManager.addGBSOptions(getCfg(), avaiableOptions[index]);
-                                       }
-                                       checkOptions[index] = true;
-                               } else {
-                                       if (!isMultiConfiguration()) {
-                                               PlatformConfigurationManager.removeGBSOptions(getCfg(), avaiableOptions[index]);
-                                       }
-                                       checkOptions[index] = false;                                            
-                               }
-                       }
-               });
-               
-               GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
-               buttons[index].setLayoutData(gd);       
-               
-               Label desc = new Label(parent, SWT.NONE);
-               desc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-               desc.setText(getDesc(op));              
-       }       
-
-       @Override
-       protected void performOK() {
-               // if multi configuration, set new gbs options. 
-               if (isMultiConfiguration()) {
-                       ArrayList<String> newOptions = new ArrayList<String>();
-                       for (int i = 0 ; i < avaiableOptions.length ; i++) {
-                               boolean checked = checkOptions[i];
-                               if (checked) {
-                                       String option = EMPTY_STRING;
-                                       if (texts[i] != null) {
-                                               String value = texts[i].getText();
-                                               option = String.format("%s=%s", avaiableOptions[i], value); 
-                                       } else {
-                                               option = avaiableOptions[i];
-                                       }
-                                       newOptions.add(option);
-                               }                       
-                       }
-                       PlatformConfigurationManager.setGBSOptions(getCfg(), newOptions);
-               }
-       }
-       
-       @Override
-       public boolean canBeVisible() {
-               IManagedProject managedProject =  getCfg().getManagedProject();
-               String projectArtifactType = managedProject.getProjectType() != null ? 
-                               managedProject.getProjectType().getBuildArtefactType().getId() : null;
-               if (    projectArtifactType != null &&
-                               projectArtifactType.equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE)) {
-                       return true;
-               }
-               
-               return false;
-       }
-
-       @Override
-       protected void performApply(ICResourceDescription src,
-                       ICResourceDescription dst) { 
-       }
-
-       @Override
-       protected void performDefaults() {              
-       }
-
-       @Override
-       protected void updateData(ICResourceDescription cfg) {
-
-               // if multi configuration, just do initialize.
-               if (isMultiConfiguration()) {
-                       for (int i = 0 ; i < avaiableOptions.length ; i++) {
-                               initControl(i);
-                       }
-               } else {
-                       IConfiguration conf = getCfg();
-                       ArrayList<String> options = PlatformConfigurationManager.getGBSOptions(conf);
-                       for (int i = 0 ; i < avaiableOptions.length ; i++) {
-                               initControl(i);
-                               String op = avaiableOptions[i];                 
-                               for (String s : options) {
-                                       String[] strs = s.split("=");                           
-                                       s = strs[0].trim();
-                                       if (s.equals(op)) {
-                                               checkOptions[i] = true;
-                                               buttons[i].setSelection(true);                                  
-                                               if (texts[i] != null) {
-                                                       texts[i].setEnabled(true);
-                                                       if (strs.length == 2) {
-                                                               texts[i].setText(strs[1]);
-                                                       }
-                                               }                                       
-                                       }
-                               }
-                       }               
-               }
-       }
-       
-       private void initControl(int index) {
-               checkOptions[index] = false;
-               buttons[index].setSelection(false);
-               if (texts[index] != null) {
-                       texts[index].setEnabled(false);
-                       texts[index].setText(EMPTY_STRING);
-               }
-       }
-       
-       private boolean isMultiConfiguration() {
-               IConfiguration config = getCfg();
-               return (config instanceof MultiConfiguration);
-       }
-       
-       private String getDesc(GBSOption op) {
-               return PREFIX_DESC + filterDesc(op.getDesc());
-       }
-
-
-       @Override
-       protected void updateButtons() {                
-       }
-       
-       private String filterDesc(String desc) {
-               if (desc.length() > 85) {
-                       int index = desc.indexOf(" ", 85);
-                       if (index < 85) {
-                               return desc;
-                       }
-                       String desc1 = desc.substring(0, index);
-                       String desc2 = desc.substring(index).trim();
-                       return desc1 + "\n  " + filterDesc(desc2);
-               }
-               return desc;
-       }
+    protected boolean checked;
+    private Button option_clean;
+    private Button option_ccache;
+    private Button option_overwrite;
+    private Button option_includeall;
+    private Button option_skipRepos;
+    private Button option_noConfigure;
+    private Button option_commit;
+    private Button option_extraPacks;
+    private Button option_threads;
+    private Button option_exclude;
+    private Button option_keepPacks;
+    private Button option_noinit;
+    private Button option_incremental;
+    private Text text_extraPacks;
+    private Text text_exclude;
+    private Text text_threads;
+    private Text text_commit;
+
+    private final String EMPTY_STRING = "";
+    private final String PREFIX_DESC = ": ";
+    private final String ERROR_LABEL = "Check if GBS(>= %s) is installed.";
+
+    private String[] avaiableOptions = { "--clean", "--ccache", "--overwrite", "--include-all",
+            "--skip-conf-repos", "--no-configure", "--threads", "--commit", "--exclude",
+            "--extra-packs", "--keep-packs", "--noinit", "--incremental" };
+
+    private boolean[] checkOptions = { false, false, false, false, false, false, false, false,
+            false, false, false, false, false };
+
+    private Button[] buttons = { option_clean, option_ccache, option_overwrite, option_includeall,
+            option_skipRepos, option_noConfigure, option_threads, option_commit, option_exclude,
+            option_extraPacks, option_keepPacks, option_noinit, option_incremental
+
+    };
+
+    private Text[] texts = { null, null, null, null, null, null, text_threads, text_commit,
+            text_exclude, text_extraPacks, null, null, null };
+
+    public void createControls(Composite _parent, ICPropertyProvider _provider) {
+        page = _provider;
+        if (canBeVisible()) {
+            createControls(_parent);
+        }
+    }
+
+    @Override
+    protected void createControls(Composite parent) {
+        super.createControls(parent);
+        usercomp.setLayout(new GridLayout(1, false));
+
+        if (!GBSOptionManager.isInitialized()) {
+            GBSOptionManager.initOptions();
+        }
+
+        if (GBSOptionManager.getOptions().isEmpty()) {
+            createErrorComposite(usercomp);
+            return;
+        }
+
+        Composite composite = new Composite(usercomp, SWT.NONE);
+        GridLayout gridLayout = new GridLayout(2, false);
+        gridLayout.marginBottom = 0;
+        gridLayout.marginTop = 0;
+        gridLayout.marginLeft = 0;
+        gridLayout.marginRight = 0;
+        GridData gd = new GridData(GridData.BEGINNING, GridData.FILL, false, false);
+        gd.widthHint = 800;
+        composite.setLayout(gridLayout);
+        composite.setLayoutData(gd);
+
+        createCleanOption(composite, 0);
+        createCcacheOption(composite, 1);
+        createOverwriteOption(composite, 2);
+        createIncludeAllOption(composite, 3);
+        createSkipReposOption(composite, 4);
+        createNoConfigureOption(composite, 5);
+        createThreadsOption(composite, 6);
+        createCommitOption(composite, 7);
+        createExcludeOption(composite, 8);
+        createExtraPacksOption(composite, 9);
+        createKeepPacksOption(composite, 10);
+        createNoInitOption(composite, 11);
+        createIncrementalOption(composite, 12);
+    }
+
+    private void createErrorComposite(Composite parent) {
+        Composite composite = new Composite(usercomp, SWT.NONE);
+        GridLayout gridLayout = new GridLayout(1, false);
+        gridLayout.marginBottom = 0;
+        gridLayout.marginTop = 0;
+        gridLayout.marginLeft = 0;
+        gridLayout.marginRight = 0;
+        GridData gd = new GridData(GridData.BEGINNING, GridData.FILL, false, false);
+        gd.widthHint = 800;
+        composite.setLayout(gridLayout);
+        composite.setLayoutData(gd);
+
+        Label errorLabel = new Label(composite, SWT.NONE);
+        errorLabel.setText(String.format(ERROR_LABEL,
+                Double.toString(GBSOptionManager.MIN_GBS_VERSION)));
+    }
+
+    private void createCcacheOption(Composite parent, int index) {
+        createOption(parent, index);
+    }
+
+    private void createCleanOption(Composite parent, int index) {
+        createOption(parent, index);
+    }
+
+    private void createOverwriteOption(Composite parent, int index) {
+        createOption(parent, index);
+    }
+
+    private void createIncludeAllOption(Composite parent, int index) {
+        createOption(parent, index);
+    }
+
+    private void createSkipReposOption(Composite parent, int index) {
+        createOption(parent, index);
+    }
+
+    private void createNoConfigureOption(Composite parent, int index) {
+        createOption(parent, index);
+    }
+
+    private void createExtraPacksOption(Composite parent, int index) {
+        createOptionWithText(parent, index);
+    }
+
+    private void createExcludeOption(Composite parent, int index) {
+        createOptionWithText(parent, index);
+    }
+
+    private void createCommitOption(Composite parent, int index) {
+        createOptionWithText(parent, index);
+    }
+
+    private void createThreadsOption(Composite parent, final int index) {
+        createOptionWithText(parent, index);
+    }
+
+    private void createKeepPacksOption(Composite parent, int index) {
+        createOption(parent, index);
+    }
+
+    private void createNoInitOption(Composite parent, int index) {
+        createOption(parent, index);
+    }
+
+    private void createIncrementalOption(Composite parent, int index) {
+        createOption(parent, index);
+    }
+
+    private void createOptionWithText(Composite parent, final int index) {
+
+        GBSOption op = GBSOptionManager.getOption(avaiableOptions[index]);
+        if (op == null) {
+            return;
+        }
+
+        buttons[index] = new Button(parent, SWT.CHECK);
+        buttons[index].setText(op.getOption());
+        buttons[index].setSelection(checkOptions[index]);
+
+        buttons[index].addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent event) {
+                Button button = (Button) event.widget;
+                if (button.getSelection()) {
+                    texts[index].setEnabled(true);
+                    checkOptions[index] = true;
+                    if (!isMultiConfiguration()) {
+                        String value = texts[index].getText();
+                        String option = String.format("%s=%s", avaiableOptions[index], value);
+                        PlatformConfigurationManager.addGBSOptions(getCfg(), option);
+                    }
+                } else {
+                    texts[index].setEnabled(false);
+                    checkOptions[index] = false;
+                    if (!isMultiConfiguration()) {
+                        PlatformConfigurationManager.removeGBSOptions(getCfg(),
+                                avaiableOptions[index]);
+                    }
+                }
+            }
+        });
+
+        Label desc = new Label(parent, SWT.NONE);
+        desc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+        desc.setText(getDesc(op));
+
+        texts[index] = new Text(parent, SWT.BORDER);
+        GridData gd = new GridData(GridData.FILL_BOTH);
+        gd.horizontalSpan = 2;
+        texts[index].setLayoutData(gd);
+        texts[index].setEnabled(checkOptions[index]);
+        texts[index].addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent event) {
+                Text text = (Text) event.widget;
+                String value = text.getText();
+                if (value.isEmpty()) {
+                    return;
+                }
+                if (!isMultiConfiguration()) {
+                    String option = String.format("%s=%s", avaiableOptions[index], value);
+                    PlatformConfigurationManager.replaceGBSOptions(getCfg(), option);
+                }
+            }
+        });
+
+    }
+
+    private void createOption(Composite parent, final int index) {
+
+        GBSOption op = GBSOptionManager.getOption(avaiableOptions[index]);
+        if (op == null) {
+            return;
+        }
+        buttons[index] = new Button(parent, SWT.CHECK);
+        buttons[index].setText(op.getOption());
+        buttons[index].setSelection(checkOptions[index]);
+        buttons[index].addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent event) {
+                Button button = (Button) event.widget;
+                if (button.getSelection()) {
+                    if (!isMultiConfiguration()) {
+                        PlatformConfigurationManager
+                                .addGBSOptions(getCfg(), avaiableOptions[index]);
+                    }
+                    checkOptions[index] = true;
+                } else {
+                    if (!isMultiConfiguration()) {
+                        PlatformConfigurationManager.removeGBSOptions(getCfg(),
+                                avaiableOptions[index]);
+                    }
+                    checkOptions[index] = false;
+                }
+            }
+        });
+
+        GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+        buttons[index].setLayoutData(gd);
+
+        Label desc = new Label(parent, SWT.NONE);
+        desc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+        desc.setText(getDesc(op));
+    }
+
+    @Override
+    protected void performOK() {
+        // if multi configuration, set new gbs options.
+        if (isMultiConfiguration()) {
+            ArrayList<String> newOptions = new ArrayList<String>();
+            for (int i = 0; i < avaiableOptions.length; i++) {
+                boolean checked = checkOptions[i];
+                if (checked) {
+                    String option = EMPTY_STRING;
+                    if (texts[i] != null) {
+                        String value = texts[i].getText();
+                        option = String.format("%s=%s", avaiableOptions[i], value);
+                    } else {
+                        option = avaiableOptions[i];
+                    }
+                    newOptions.add(option);
+                }
+            }
+            PlatformConfigurationManager.setGBSOptions(getCfg(), newOptions);
+        }
+    }
+
+    @Override
+    public boolean canBeVisible() {
+        IManagedProject managedProject = getCfg().getManagedProject();
+        String projectArtifactType = managedProject.getProjectType() != null ? managedProject
+                .getProjectType().getBuildArtefactType().getId() : null;
+        if (projectArtifactType != null
+                && projectArtifactType
+                        .equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE)) {
+            return true;
+        }
+
+        return false;
+    }
+
+    @Override
+    protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
+    }
+
+    @Override
+    protected void performDefaults() {
+    }
+
+    @Override
+    protected void updateData(ICResourceDescription cfg) {
+
+        // if multi configuration, just do initialize.
+        if (isMultiConfiguration()) {
+            for (int i = 0; i < avaiableOptions.length; i++) {
+                initControl(i);
+            }
+        } else {
+            IConfiguration conf = getCfg();
+            ArrayList<String> options = PlatformConfigurationManager.getGBSOptions(conf);
+            for (int i = 0; i < avaiableOptions.length; i++) {
+                initControl(i);
+                String op = avaiableOptions[i];
+                for (String s : options) {
+                    String[] strs = s.split("=");
+                    s = strs[0].trim();
+                    if (s.equals(op)) {
+                        checkOptions[i] = true;
+                        buttons[i].setSelection(true);
+                        if (texts[i] != null) {
+                            texts[i].setEnabled(true);
+                            if (strs.length == 2) {
+                                texts[i].setText(strs[1]);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private void initControl(int index) {
+        checkOptions[index] = false;
+        buttons[index].setSelection(false);
+        if (texts[index] != null) {
+            texts[index].setEnabled(false);
+            texts[index].setText(EMPTY_STRING);
+        }
+    }
+
+    private boolean isMultiConfiguration() {
+        IConfiguration config = getCfg();
+        return (config instanceof MultiConfiguration);
+    }
+
+    private String getDesc(GBSOption op) {
+        return PREFIX_DESC + filterDesc(op.getDesc());
+    }
+
+    @Override
+    protected void updateButtons() {
+    }
+
+    private String filterDesc(String desc) {
+        if (desc.length() > 85) {
+            int index = desc.indexOf(" ", 85);
+            if (index < 85) {
+                return desc;
+            }
+            String desc1 = desc.substring(0, index);
+            String desc2 = desc.substring(index).trim();
+            return desc1 + "\n  " + filterDesc(desc2);
+        }
+        return desc;
+    }
 }
index 628e83e..b18b4ac 100644 (file)
@@ -148,7 +148,6 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
             tizenCommand = new TizenLaunchCommand(currentDevice, null);
 
             activateProgressView();
-
             verifyDeviceReachability();
             setRootstrap(config);
             setPkgCommandTarget();
@@ -606,6 +605,10 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
 
     protected void setDebugConfigAttributes(ILaunchConfiguration config) throws CoreException {
         ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+        setAttributes(wc);
+    }
+
+    protected void setAttributes(ILaunchConfigurationWorkingCopy wc) throws CoreException {
         wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, true);
         wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST,
                 TizenPlatformConstants.LOCALHOST);
@@ -761,7 +764,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
     }
 
     protected boolean needsSetConfiguration(ILaunchConfiguration config) throws CoreException {
-        // If the project is EFL app or launching is not from shorcut, need set
+        // If the project is EFL app or launching is not from shortcut, need set
         // configurations.
         IProject project = getProject(config);
         boolean isEflApp = PlatformProjectUtil.isEFLApplication(project);
index 74fe67e..45fca91 100644 (file)
@@ -28,7 +28,6 @@
 package org.tizen.nativeplatform.launch;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
@@ -37,7 +36,6 @@ import java.util.List;
 import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.core.IProcessInfo;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants;
 import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.cdt.utils.PathUtil;
@@ -46,12 +44,10 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.core.ILaunchManager;
 import org.tizen.common.TizenPlatformConstants;
-import org.tizen.common.util.StringUtil;
 import org.tizen.nativecommon.ProjectUtil;
 import org.tizen.nativecommon.build.SmartBuildInterface;
 import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
@@ -61,10 +57,7 @@ import org.tizen.nativeplatform.pkg.commander.IPkgLauncher;
 import org.tizen.nativeplatform.pkg.commander.factory.PkgLauncherFactory;
 import org.tizen.nativeplatform.pkg.model.IPackage;
 import org.tizen.nativeplatform.types.LaunchTypes;
-import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.ProcessSelector;
-import org.tizen.sdblib.exception.SdbCommandRejectedException;
-import org.tizen.sdblib.exception.TimeoutException;
 
 public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate {
 
@@ -73,37 +66,10 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate {
 
     @Override
     protected void setDebugConfigAttributes(ILaunchConfiguration config) throws CoreException {
-
         setSharedlibrarySearchPath(config);
         ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
-
         pid = wc.getAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSID_OPTION, -1);
-        wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, true);
-        wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST,
-                TizenPlatformConstants.LOCALHOST);
-        String gdbserverPort = wc.getAttribute(
-                TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT,
-                TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT);
-        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
-                ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
-        try {
-            int localDebugPort = getDebugPort();
-            if (localDebugPort < 0) {
-                newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, null);
-            }
-            currentDevice.createForward(localDebugPort, Integer.parseInt(gdbserverPort));
-            String localPort = Integer.valueOf(localDebugPort).toString();
-            wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, localPort);
-            wc.doSave();
-        } catch (TimeoutException e) {
-            newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
-        } catch (SdbCommandRejectedException e) {
-            newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
-        } catch (CoreException e) {
-            newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
-        } catch (IOException e) {
-            newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
-        }
+        setAttributes(wc);
     }
 
     private void setSharedlibrarySearchPath(ILaunchConfiguration config) throws CoreException {
@@ -179,56 +145,14 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate {
         installPackages(config, mode, monitor);
     }
 
-    @Override
-    protected void launchApplicationWithGDBServer(ILaunch launch, ILaunchConfiguration config,
-            IProgressMonitor monitor) throws CoreException {
-
-        try {
-            monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER, 1);
-            monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER);
-
-            IPath path = getHostPath(TizenPlatformConstants.HOST_GDBSERVER_PATH, config);
-            PlatformLaunchUtil.readyGdbServer(currentDevice, tizenCommand, path);
-
-            if (pid.equals(Integer.valueOf(-1)) || pid.equals(Integer.valueOf(0))) {
-                newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER
-                        + ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID, null);
-            }
-
-            String gdbserverRunCommand = getGdbserverRunCommand(config);
-            String resultCommand = null;
-
-            // is gdbserver running now ? then
-            resultCommand = String.format(TizenPlatformConstants.PROCESS_GET_PROCESS_ID_COMMAND,
-                    gdbserverRunCommand.trim());
-            tizenCommand.run(resultCommand, null);
-            if (tizenCommand.getEndLine() != null) {
-                if (StringUtil.isInteger(tizenCommand.getEndLine().trim())) {
-                    resultCommand = String.format(TizenPlatformConstants.PROCESS_SIGKILL_COMMAND,
-                            tizenCommand.getEndLine() + TizenPlatformConstants.CMD_RESULT_CHECK);
-                    try {
-                        tizenCommand.run(resultCommand, "0");
-                    } catch (CoreException e) {
-                        newCoreException(TizenLaunchMessages.GDBSERVER_ALREADY_RUNNING, null);
-                    } catch (Exception e) {
-                        newCoreException(TizenLaunchMessages.GDBSERVER_ALREADY_RUNNING, null);
-                    }
-                }
-            }
-            // Run gdbserver as blocking mode!
-            tizenCommand.run(gdbserverRunCommand, null, true);
-        } catch (CoreException e) {
-            newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
-        } catch (Exception e) {
-            newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
-        } finally {
-            monitor.done();
-        }
-    }
-
     protected String getGdbserverRunCommand(ILaunchConfiguration config) throws CoreException,
             Exception {
 
+        if (pid.equals(Integer.valueOf(-1)) || pid.equals(Integer.valueOf(0))) {
+            newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER
+                    + ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID, null);
+        }
+
         String gdbserverPort = config.getAttribute(
                 TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT,
                 TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT);
index fbf063f..3453ab5 100644 (file)
@@ -18,18 +18,10 @@ import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.tizen.common.connection.ConnectionPlugin;
-import org.tizen.common.connection.ui.TizenRemoteFileDialog;
-import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult;
-import org.tizen.nativecommon.launch.TizenLaunchMessages;
 import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
-import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.service.FileEntry;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 
 @SuppressWarnings({ "restriction" })
 public class PlatformCommonTab extends CMainTab {
@@ -83,40 +75,19 @@ public class PlatformCommonTab extends CMainTab {
         });
     }
 
-    protected void handleRemoteBrowseButtonSelected() {
-        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-        if (window == null) {
-            IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
-            window = windows[0];
-        }
-
-        final Shell shell = window.getShell();
-        if (shell != null) {
-            IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
-            if (device == null) {
-                MessageBox msgBox = new MessageBox(shell, SWT.ICON_INFORMATION);
-                msgBox.setMessage(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
-                msgBox.open();
-                return;
-            }
+    protected String handleRemoteBrowseButtonSelected() {
+        final Shell shell = getAvailableShell();
+        String path = PlatformLaunchUtil.selectRemoteFile(shell,
+                resources.getString("Remote.Dialog.Title"));
+        return path;
+    }
 
-            shell.getDisplay().syncExec(new Runnable() {
-                public void run() {
-                    IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
-                    TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, resources
-                            .getString("Remote.Dialog.Title"), device, false, device
-                            .getAppInstallPath() + "/");
-                    if (dlg.open() == TizenRemoteFileDialogResult.OK) {
-                        FileEntry selectedFile = dlg.getSelectedFileEntry();
-                        filePath = selectedFile.getFullPath();
-                        fBinPathText.setText(filePath);
-                    } else {
-                        filePath = null;
-                    }
-                }
-            });
+    protected Shell getAvailableShell() {
+        Shell shell = getShell();
+        if (shell == null) {
+            shell = PlatformLaunchUtil.getAvaiableShell();
         }
-        return;
+        return shell;
     }
 
     @Override
index 36678b8..af4ce87 100644 (file)
@@ -425,7 +425,10 @@ public class PlatformMainTab extends PlatformCommonTab {
         fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent evt) {
-                handleRemoteBrowseButtonSelected();
+                String path = handleRemoteBrowseButtonSelected();
+                if (path != null) {
+                    fBinPathText.setText(path);
+                }
                 updateLaunchConfigurationDialog();
             }
         });
index e8556d9..d441a79 100644 (file)
 
 package org.tizen.nativeplatform.launch.ui.shortcut;
 
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.ICDebugConfiguration;
-import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
 import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
 import org.eclipse.cdt.debug.ui.ICDebuggerPage;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationType;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.Shell;
-import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
 import org.tizen.nativeplatform.build.PlatformConfigurationManager;
 import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
 import org.tizen.nativeplatform.launch.wizards.PlatformAttachLaunchWizard;
@@ -72,36 +67,11 @@ public class PlatformProjectAttachLaunchShortcut extends PlatformProjectCommonLa
                 return null;
             }
 
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
+            setAttributes(wc, project);
             wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSNAME_OPTION, procName);
             wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSID_OPTION, pid);
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, true);
-
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
-            wc.setMappedResources(new IResource[] { project });
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
             wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
                     ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID,
-                    TizenLaunchConfigurationConstants.DEBUGGER_ID);
-            wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY,
-                    ITizenLaunchConfigurationConstants.COMMAND_FACTORY_ID);
-            wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
-            wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS,
-                    false);
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
-                    ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
-
-            ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
-            if (projDes != null) {
-                String buildConfigID = projDes.getActiveConfiguration().getId();
-                wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID,
-                        buildConfigID);
-            }
-
             // Load up the debugger page to set the defaults. There should
             // probably be a separate extension point for this.
             ICDebuggerPage page = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID());
@@ -118,8 +88,8 @@ public class PlatformProjectAttachLaunchShortcut extends PlatformProjectCommonLa
     private boolean setLaunchConfiguration(IProject project, String mode) {
         IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
         final Shell shell = getAvaiableShell();
-        PlatformAttachLaunchWizard wizard = new PlatformAttachLaunchWizard(shell, project,
-                config, target, mode);
+        PlatformAttachLaunchWizard wizard = new PlatformAttachLaunchWizard(shell, project, config,
+                target, mode);
         PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard);
         dlg.create();
         if (Window.OK == dlg.open()) {
index 51ee025..0ab9e5d 100644 (file)
@@ -31,6 +31,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.core.model.CoreModel;
 import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
 import org.eclipse.cdt.core.settings.model.ICProjectDescription;
@@ -40,6 +41,7 @@ import org.eclipse.cdt.debug.core.ICDebugConfiguration;
 import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
 import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
 import org.eclipse.cdt.debug.internal.ui.launch.CApplicationLaunchShortcut;
+import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -64,8 +66,6 @@ import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.dialogs.ElementListSelectionDialog;
 import org.tizen.common.connection.ConnectionPlugin;
 import org.tizen.common.util.DialogUtil;
@@ -74,6 +74,7 @@ import org.tizen.nativecommon.build.SmartBuildInterface;
 import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
 import org.tizen.nativecommon.launch.TizenLaunchMessages;
 import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
 import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
 import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
 import org.tizen.nativeplatform.pkg.model.IPackage;
@@ -315,6 +316,53 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa
         }
     }
 
+    protected void setAttributes(ILaunchConfigurationWorkingCopy wc, IProject project) {
+        if (programPath != null) {
+            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
+        }
+        setOptionsAttr(wc);
+        setProjectAttr(wc, project);
+        setWorkingDirAttr(wc);
+        setDebuggerAttr(wc);
+        setBuildAttr(wc, project);
+    }
+
+    protected void setProjectAttr(ILaunchConfigurationWorkingCopy wc, IProject project) {
+        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
+        wc.setMappedResources(new IResource[] { project });
+    }
+
+    protected void setWorkingDirAttr(ILaunchConfigurationWorkingCopy wc) {
+        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
+    }
+
+    protected void setOptionsAttr(ILaunchConfigurationWorkingCopy wc) {
+        wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
+        wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
+        wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, true);
+    }
+
+    protected void setDebuggerAttr(ILaunchConfigurationWorkingCopy wc) {
+        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
+        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID,
+                TizenLaunchConfigurationConstants.DEBUGGER_ID);
+        wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY,
+                ITizenLaunchConfigurationConstants.COMMAND_FACTORY_ID);
+        wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
+        wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, false);
+    }
+
+    protected void setBuildAttr(ILaunchConfigurationWorkingCopy wc, IProject project) {
+        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
+                ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
+        ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
+        if (projDes != null) {
+            String buildConfigID = projDes.getActiveConfiguration().getId();
+            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID,
+                    buildConfigID);
+        }
+    }
+
     protected boolean checkPackaging(IProject project) {
         IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
         List<IPackage> pkgs = pkgUtil.getPackages(project, config);
@@ -355,12 +403,7 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa
     protected Shell getAvaiableShell() {
         Shell shell = getShell();
         if (shell == null) {
-            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-            if (window == null) {
-                IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
-                window = windows[0];
-            }
-            shell = window.getShell();
+            shell = PlatformLaunchUtil.getAvaiableShell();
         }
         return shell;
     }
index 55fcf51..7094c19 100644 (file)
 
 package org.tizen.nativeplatform.launch.ui.shortcut;
 
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.ICDebugConfiguration;
-import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
 import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
 import org.eclipse.cdt.debug.ui.ICDebuggerPage;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.debug.core.ILaunchConfiguration;
@@ -43,11 +39,7 @@ import org.eclipse.debug.core.ILaunchConfigurationType;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
 import org.tizen.nativeplatform.Activator;
-import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
 import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
 
 @SuppressWarnings("restriction")
@@ -66,29 +58,12 @@ public class PlatformProjectCoredumpLaunchShortcut extends PlatformProjectCommon
             if (programName != null) {
                 wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programName);
             }
-
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
-            wc.setMappedResources(new IResource[] { project });
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
+            setProjectAttr(wc, project);
+            setWorkingDirAttr(wc);
+            setDebuggerAttr(wc);
+            setBuildAttr(wc, project);
             wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
                     ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID,
-                    TizenLaunchConfigurationConstants.DEBUGGER_ID);
-            wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY,
-                    ITizenLaunchConfigurationConstants.COMMAND_FACTORY_ID);
-            wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
-            wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS,
-                    false);
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
-                    ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
-
-            ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
-            if (projDes != null) {
-                String buildConfigID = projDes.getActiveConfiguration().getId();
-                wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID,
-                        buildConfigID);
-            }
 
             // Load up the debugger page to set the defaults. There should
             // probably be a separate extension point for this.
@@ -103,13 +78,7 @@ public class PlatformProjectCoredumpLaunchShortcut extends PlatformProjectCommon
     }
 
     private String getProgramName() throws CoreException {
-        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-        if (window == null) {
-            IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
-            window = windows[0];
-        }
-        final Shell shell = window.getShell();
-
+        final Shell shell = getAvaiableShell();
         TizenPathInputDialog dlg = new TizenPathInputDialog(shell,
                 APPLICATION_PATH_INPUT_DIALOG_TITLE, APPLICATION_PATH_INPUT_DIALOG_TEXT, null);
         if (Window.OK == dlg.open()) {
@@ -117,7 +86,6 @@ public class PlatformProjectCoredumpLaunchShortcut extends PlatformProjectCommon
         } else {
             newCoreException(PlatformLaunchMessages.OPERATION_CANCELED, null);
         }
-
         return null;
     }
 
index 1058bb2..8874463 100644 (file)
 
 package org.tizen.nativeplatform.launch.ui.shortcut;
 
-import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.ICDebugConfiguration;
-import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
 import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
 import org.eclipse.cdt.debug.ui.ICDebuggerPage;
 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.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationType;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.tizen.common.util.DialogUtil;
-import org.tizen.nativecommon.build.CommonBuildMessages;
-import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
 import org.tizen.nativeplatform.build.PlatformConfigurationManager;
 import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
-import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
 import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
 import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizardDialog;
 import org.tizen.nativeplatform.launch.wizards.SelectItemDialog;
 import org.tizen.nativeplatform.pkg.model.IPackage;
-import org.tizen.nativeplatform.util.PackageUtil;
 import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.PlatformProjectUtil;
 
@@ -95,10 +77,7 @@ public class PlatformProjectLaunchShortcut extends PlatformProjectCommonLaunchSh
             if (!setLaunchConfiguration(project, mode)) {
                 return null;
             }
-
-            if (programPath != null) {
-                wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
-            }
+            setAttributes(wc, project);
 
             if (appProjectName != null && !APP_PROJ_DEFAULT_SELECTION.equals(appProjectName)) {
                 wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME,
@@ -112,36 +91,10 @@ public class PlatformProjectLaunchShortcut extends PlatformProjectCommonLaunchSh
                 }
                 wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, strs);
             }
-
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, true);
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
-            wc.setMappedResources(new IResource[] { project });
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
             wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
                     ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID,
-                    TizenLaunchConfigurationConstants.DEBUGGER_ID);
-            wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY,
-                    ITizenLaunchConfigurationConstants.COMMAND_FACTORY_ID);
-            wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
-            wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS,
-                    false);
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
-                    ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
-
-            ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
-            if (projDes != null) {
-                String buildConfigID = projDes.getActiveConfiguration().getId();
-                wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID,
-                        buildConfigID);
-            }
-
             // Load up the debugger page to set the defaults. There should
-            // probably be a separate
-            // extension point for this.
+            // probably be a separate extension point for this.
             ICDebuggerPage page = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID());
             setSourceContainer(project, wc);
             page.setDefaults(wc);
index f513cfb..d3566bd 100644 (file)
@@ -39,17 +39,9 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.tizen.common.connection.ConnectionPlugin;
-import org.tizen.common.connection.ui.TizenRemoteFileDialog;
-import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult;
-import org.tizen.nativecommon.launch.TizenLaunchMessages;
-import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.service.FileEntry;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 
 public class TizenPathInputDialog extends Dialog {
     /**
@@ -76,26 +68,21 @@ public class TizenPathInputDialog extends Dialog {
      * Input text widget.
      */
     private Text text;
+    private static final String REMOTE_BROWSE = "Remote Browse...";
+    private static final String SELECT_AN_APPLICATION = "Select an Application";
 
-       private String filePath = "";
-       
-       private static final String REMOTE_BROWSE = "Remote Browse...";
-       private static final String SELECT_AN_APPLICATION = "Select an Application";
-       private static final String SELECT_A_FILE = "Select a file";
-       private static final String SELECT_A_FILE_TO_RUN = "Select a file";
-
-       public TizenPathInputDialog(Shell parentShell, String dialogTitle,
-                       String dialogMessage, String initialValue) {
+    public TizenPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage,
+            String initialValue) {
         super(parentShell);
         this.title = dialogTitle;
         message = dialogMessage;
         if (initialValue == null) {
-                       value = "";//$NON-NLS-1$
-               } else {
-                       value = initialValue;
-               }
-       }
-       
+            value = "";//$NON-NLS-1$
+        } else {
+            value = initialValue;
+        }
+    }
+
     /*
      * (non-Javadoc) Method declared on Dialog.
      */
@@ -111,27 +98,29 @@ public class TizenPathInputDialog extends Dialog {
     /*
      * (non-Javadoc)
      * 
-     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     * @see
+     * org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets
+     * .Shell)
      */
     protected void configureShell(Shell shell) {
         super.configureShell(shell);
         if (title != null) {
-                       shell.setText(title);
-               }
+            shell.setText(title);
+        }
     }
 
     /*
      * (non-Javadoc)
      * 
-     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     * @see
+     * org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse
+     * .swt.widgets.Composite)
      */
     protected void createButtonsForButtonBar(Composite parent) {
         // create OK and Cancel buttons by default
-        okButton = createButton(parent, IDialogConstants.OK_ID,
-                IDialogConstants.OK_LABEL, true);
-        createButton(parent, IDialogConstants.CANCEL_ID,
-                IDialogConstants.CANCEL_LABEL, false);
-        //do this here because setting the text will set enablement on the ok
+        okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+        createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+        // do this here because setting the text will set enablement on the ok
         // button
         text.setFocus();
         if (value != null) {
@@ -150,14 +139,13 @@ public class TizenPathInputDialog extends Dialog {
         if (message != null) {
             Label label = new Label(composite, SWT.WRAP);
             label.setText(message);
-            GridData data = new GridData(GridData.GRAB_HORIZONTAL
-                    | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
-                    | GridData.VERTICAL_ALIGN_CENTER);
+            GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
+                    | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
             data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
             label.setLayoutData(data);
             label.setFont(parent.getFont());
         }
-        
+
         Composite pathComp = new Composite(composite, SWT.NONE);
         GridLayout pathLayout = new GridLayout();
         pathLayout.numColumns = 2;
@@ -166,18 +154,18 @@ public class TizenPathInputDialog extends Dialog {
         GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
         data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
         text.setLayoutData(data);
-        
-               Button browseButton;
-               browseButton = createPushButton(pathComp, REMOTE_BROWSE, null);
-               browseButton.addSelectionListener(new SelectionAdapter() {
-                       @Override
-                       public void widgetSelected(SelectionEvent evt) {
-                               String path = handleBrowseButtonSelected();
-                               if (path != null) {
-                                       text.setText(path);
-                               }
-                       }
-               });
+
+        Button browseButton;
+        browseButton = createPushButton(pathComp, REMOTE_BROWSE, null);
+        browseButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                String path = handleBrowseButtonSelected();
+                if (path != null) {
+                    text.setText(path);
+                }
+            }
+        });
         applyDialogFont(composite);
         return composite;
     }
@@ -219,63 +207,44 @@ public class TizenPathInputDialog extends Dialog {
         return value;
     }
 
-       /**
-        * Returns the style bits that should be used for the input text field.
-        * Defaults to a single line entry. Subclasses may override.
-        * 
-        * @return the integer style bits that should be used when creating the
-        *         input text
-        * 
-        * @since 3.4
-        */
-       protected int getInputTextStyle() {
-               return SWT.SINGLE | SWT.BORDER;
-       }
-       
-       public static Button createPushButton(Composite parent, String label, Image image) {
-               Button button = new Button(parent, SWT.PUSH);
-               button.setFont(parent.getFont());
-               if (image != null) {
-                       button.setImage(image);
-               }
-               if (label != null) {
-                       button.setText(label);
-               }
-               GridData gd = new GridData();
-               button.setLayoutData(gd);       
-               return button;  
-       }
-       
-       protected String handleBrowseButtonSelected() {
-               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-               if (window == null) {
-                       IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
-                       window = windows[0];
-               }
+    /**
+     * Returns the style bits that should be used for the input text field.
+     * Defaults to a single line entry. Subclasses may override.
+     * 
+     * @return the integer style bits that should be used when creating the
+     *         input text
+     * 
+     * @since 3.4
+     */
+    protected int getInputTextStyle() {
+        return SWT.SINGLE | SWT.BORDER;
+    }
+
+    public static Button createPushButton(Composite parent, String label, Image image) {
+        Button button = new Button(parent, SWT.PUSH);
+        button.setFont(parent.getFont());
+        if (image != null) {
+            button.setImage(image);
+        }
+        if (label != null) {
+            button.setText(label);
+        }
+        GridData gd = new GridData();
+        button.setLayoutData(gd);
+        return button;
+    }
 
-               final Shell shell = window.getShell();
-               if (shell != null) {
-                       IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
-                       if (device == null) {
-                               MessageBox msgBox = new MessageBox(shell, SWT.ICON_INFORMATION);
-                               msgBox.setMessage(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
-                               msgBox.open();
-                               return null;
-                       }
+    protected String handleBrowseButtonSelected() {
+        final Shell shell = getAvailableShell();
+        String path = PlatformLaunchUtil.selectRemoteFile(shell, SELECT_AN_APPLICATION);
+        return path;
+    }
 
-                       shell.getDisplay().syncExec( new Runnable() {
-                               public void run() {
-                                       IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
-                                       TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, SELECT_AN_APPLICATION, device, false, device.getAppInstallPath() + "/");
-                                       if(dlg.open() == TizenRemoteFileDialogResult.OK) {
-                                               FileEntry selectedFile = dlg.getSelectedFileEntry();
-                                               filePath = selectedFile.getFullPath();
-                                       } else {
-                                               filePath = null;
-                                       }
-                               }
-                       });
-               }
-               return filePath;
-       }
+    protected Shell getAvailableShell() {
+        Shell shell = getShell();
+        if (shell == null) {
+            shell = PlatformLaunchUtil.getAvaiableShell();
+        }
+        return shell;
+    }
 }
\ No newline at end of file
index ad0383c..a0e9774 100644 (file)
@@ -13,6 +13,7 @@ import org.tizen.nativecommon.build.SmartBuildInterface;
 import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
 import org.tizen.nativeplatform.pkg.model.IPackage;
 import org.tizen.nativeplatform.util.PackageUtil;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.PlatformProjectUtil;
 import org.tizen.nativeplatform.views.model.PlatformRootstrap;
 
@@ -20,7 +21,7 @@ public class PlatformLaunchCommonPage extends WizardPage {
 
     protected Button reinstallOp;
     protected Button selectPkgOp;
-    
+
     protected IProject platformProject;
     protected IConfiguration config;
     protected List<IPackage> platformPackages = new ArrayList<IPackage>();
@@ -30,7 +31,7 @@ public class PlatformLaunchCommonPage extends WizardPage {
     protected String rootPath = "";
     protected Shell shell;
     protected PackageUtil pkgUtil = new PackageUtil(PlatformProjectUtil.getPkgType());
-    
+
     protected PlatformLaunchCommonPage(String pageName) {
         super(pageName);
     }
@@ -52,11 +53,11 @@ public class PlatformLaunchCommonPage extends WizardPage {
     public void createControl(Composite parent) {
 
     }
-    
+
     protected List<IPackage> getPackages(IProject project, IConfiguration config) {
         return pkgUtil.getPackages(project, config);
     }
-    
+
     protected void setPlatformPackages() {
         platformPackages.clear();
         platformPackages = getPackages(platformProject, config);
@@ -66,11 +67,11 @@ public class PlatformLaunchCommonPage extends WizardPage {
             packages.addAll(platformPackages);
         }
     }
-    
+
     public List<IPackage> getPackages() {
         return packages;
     }
-    
+
     public boolean getReinstallOp() {
         return reinstallOp.getSelection();
     }
@@ -78,8 +79,16 @@ public class PlatformLaunchCommonPage extends WizardPage {
     public boolean getSelectPkgOp() {
         return selectPkgOp.getSelection();
     }
-    
+
     public String getRootstrapPath() {
         return rootPath;
     }
+
+    protected Shell getAvailableShell() {
+        Shell shell = getShell();
+        if (shell == null) {
+            shell = PlatformLaunchUtil.getAvaiableShell();
+        }
+        return shell;
+    }
 }
index faeac67..e54447c 100644 (file)
@@ -29,7 +29,6 @@ package org.tizen.nativeplatform.launch.wizard.pages;
 
 import java.util.ResourceBundle;
 
-import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -37,18 +36,10 @@ import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.tizen.common.connection.ConnectionPlugin;
-import org.tizen.common.connection.ui.TizenRemoteFileDialog;
-import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult;
-import org.tizen.nativecommon.launch.TizenLaunchMessages;
 import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
-import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.service.FileEntry;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 
 public class PlatformLaunchSettingBinPage extends PlatformLaunchCommonPage {
 
@@ -58,11 +49,10 @@ public class PlatformLaunchSettingBinPage extends PlatformLaunchCommonPage {
     private PlatformLaunchWizard wizard;
 
     private Text text;
-    private String filePath = "";
 
     public PlatformLaunchSettingBinPage(PlatformLaunchWizard wizard, String pageName) {
         super(pageName);
-        
+
         this.wizard = wizard;
         setTitle(resources.getString("BinPage.Title"));
         setDescription(resources.getString("BinPage.Desc"));
@@ -100,38 +90,10 @@ public class PlatformLaunchSettingBinPage extends PlatformLaunchCommonPage {
     }
 
     protected String handleBrowseButtonSelected() {
-        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-        if (window == null) {
-            IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
-            window = windows[0];
-        }
-
-        final Shell shell = window.getShell();
-        if (shell != null) {
-            IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
-            if (device == null) {
-                MessageBox msgBox = new MessageBox(shell, SWT.ICON_INFORMATION);
-                msgBox.setMessage(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
-                msgBox.open();
-                return null;
-            }
-
-            shell.getDisplay().syncExec(new Runnable() {
-                public void run() {
-                    IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
-                    TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, resources
-                            .getString("BinPage.Remote.Dialog.Title"), device, false, device
-                            .getAppInstallPath() + "/");
-                    if (dlg.open() == TizenRemoteFileDialogResult.OK) {
-                        FileEntry selectedFile = dlg.getSelectedFileEntry();
-                        filePath = selectedFile.getFullPath().trim();
-                    } else {
-                        filePath = null;
-                    }
-                }
-            });
-        }
-        return filePath;
+        final Shell shell = getAvailableShell();
+        String path = PlatformLaunchUtil.selectRemoteFile(shell,
+                resources.getString("BinPage.Remote.Dialog.Title"));
+        return path;
     }
 
     public String getPath() {
index 658f355..ae006ec 100644 (file)
@@ -28,7 +28,6 @@
 package org.tizen.nativeplatform.pkgmgr.ui;
 
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
@@ -48,9 +47,6 @@ public class AddRepoDialog extends RepoCommonDialog {
     public AddRepoDialog(Shell parentShell, String tab, boolean supportLocalRepo) {
         super(parentShell);
         this.supportLocalRepo = supportLocalRepo;
-        Rectangle bounds = parentShell.getBounds();
-        x = bounds.x + (bounds.width - width) / 2;
-        y = bounds.y + (bounds.height - height) / 2;
     }
 
     @Override
index 67f0370..75dfbca 100644 (file)
@@ -492,30 +492,16 @@ abstract public class CommonTab {
     private void createPackageTable(Composite parent) {
         Composite composite = new Composite(parent, SWT.NONE);
         composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-        // composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
         composite.setLayout(new FillLayout());
-        // composite.setLayout(new GridLayout(1,false));
-
         pkgViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.H_SCROLL
                 | SWT.V_SCROLL | SWT.CHECK);
         createPackageTableColumns(composite);
         Table packageTable = pkgViewer.getTable();
-        /*
-         * packageTable.addListener(SWT.Selection, new Listener() {
-         * 
-         * @Override public void handleEvent(Event event) { if (event.detail ==
-         * SWT.CHECK) { PkgStatus pkg = (PkgStatus) event.item.getData();
-         * pkg.setChecked(!pkg.isChecked()); }
-         * 
-         * } });
-         */
-
         packageTable.setHeaderVisible(true);
         packageTable.setLinesVisible(true);
 
         pkgViewer.setContentProvider(new ArrayContentProvider());
         pkgViewer.setCheckStateProvider(new ICheckStateProvider() {
-
             @Override
             public boolean isChecked(Object element) {
                 PkgStatus pkg = (PkgStatus) element;
@@ -718,7 +704,6 @@ abstract public class CommonTab {
 
     protected void handleRemovePackageButton() {
         final List<PkgStatus> selectedList = getSelectedPkgList(true);
-
         if (selectedList.isEmpty()) {
             DialogUtil.openErrorDialog(resources.getString("PkgMgr.Error.Noselected.Package"));
             return;
index 80cb18d..cc967b7 100644 (file)
@@ -29,7 +29,6 @@ package org.tizen.nativeplatform.pkgmgr.ui;
 
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.eclipse.swt.widgets.Shell;
index 42c39c1..926cc1c 100644 (file)
@@ -50,13 +50,6 @@ public class ModifyRepoDialog extends RepoCommonDialog {
         super(parentShell);
     }
 
-    public ModifyRepoDialog(Shell parentShell, String tab) {
-        super(parentShell);
-        Rectangle bounds = parentShell.getBounds();
-        x = bounds.x + (bounds.width - width) / 2;
-        y = bounds.y + (bounds.height - height) / 2;
-    }
-
     public ModifyRepoDialog(Shell parentShell, String tab, String name, String url,
             boolean supportLocalRepo) {
         super(parentShell);
@@ -64,11 +57,8 @@ public class ModifyRepoDialog extends RepoCommonDialog {
         this.name = name;
         this.type = RepoManager.getURLType(url);
         this.supportLocalRepo = supportLocalRepo;
-        Rectangle bounds = parentShell.getBounds();
-        x = bounds.x + (bounds.width - width) / 2;
-        y = bounds.y + (bounds.height - height) / 2;
     }
-    
+
     @Override
     protected void configureShell(Shell newShell) {
         super.configureShell(newShell, resources.getString("ModifyRepo.Title"));
index e71935d..939641f 100644 (file)
@@ -38,6 +38,7 @@ import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -72,6 +73,9 @@ public abstract class RepoCommonDialog extends Dialog {
 
     protected RepoCommonDialog(Shell parentShell) {
         super(parentShell);
+        Rectangle bounds = parentShell.getBounds();
+        x = bounds.x + (bounds.width - width) / 2;
+        y = bounds.y + (bounds.height - height) / 2;
     }
 
     protected abstract void initControls();
@@ -83,14 +87,6 @@ public abstract class RepoCommonDialog extends Dialog {
         newShell.setSize(width, height);
     }
 
-    @Override
-    protected void configureShell(Shell newShell) {
-        super.configureShell(newShell);
-        newShell.setText(resources.getString("ModifyRepo.Title"));
-        newShell.setLocation(x, y);
-        newShell.setSize(width, height);
-    }
-
     protected void createRepoComposite(Composite parent) {
         Composite composite = new Composite(parent, SWT.NONE);
         composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING
index 71721c3..9b8fb47 100644 (file)
@@ -42,7 +42,15 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
 import org.tizen.common.TizenPlatformConstants;
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ui.TizenRemoteFileDialog;
+import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult;
 import org.tizen.common.util.DialogUtil;
 import org.tizen.nativecommon.TizenNativeException;
 import org.tizen.nativecommon.launch.LaunchUtils;
@@ -53,10 +61,24 @@ import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
 import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.exception.SdbCommandRejectedException;
 import org.tizen.sdblib.exception.TimeoutException;
+import org.tizen.sdblib.service.FileEntry;
 import org.tizen.sdblib.service.SyncResult;
 
 public class PlatformLaunchUtil {
 
+    public static Shell getAvaiableShell() {
+        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+        if (window == null) {
+            IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
+            if (windows.length > 0) {
+                window = windows[0];
+            } else {
+                return null;
+            }
+        }
+        return window.getShell();
+    }
+
     public static String[] getProjectInfo(IProject project) {
         String[] infos = new String[2];
         String name = null;
@@ -181,7 +203,7 @@ public class PlatformLaunchUtil {
             return null;
         }
     }
-    
+
     public static boolean questionPackaging(IProject project) {
         String msg = String.format(PlatformLaunchMessages.QUESTION_PACKAGING, project.getName());
         if (64 == DialogUtil.openQuestionDialog(msg)) {
@@ -190,7 +212,7 @@ public class PlatformLaunchUtil {
             return false;
         }
     }
-    
+
     public static boolean questionContinue() {
         if (64 == DialogUtil.openQuestionDialog(PlatformLaunchMessages.QUESTION_CONTINUE)) {
             return true;
@@ -198,4 +220,26 @@ public class PlatformLaunchUtil {
             return false;
         }
     }
+
+    public static String selectRemoteFile(Shell shell, String title) {
+        String filePath = null;
+        if (shell != null) {
+            IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+            if (device == null) {
+                MessageBox msgBox = new MessageBox(shell, SWT.ICON_INFORMATION);
+                msgBox.setMessage(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
+                msgBox.open();
+                return null;
+            }
+
+            device = ConnectionPlugin.getDefault().getCurrentDevice();
+            TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, title, device, false,
+                    device.getAppInstallPath() + "/");
+            if (dlg.open() == TizenRemoteFileDialogResult.OK) {
+                FileEntry selectedFile = dlg.getSelectedFileEntry();
+                filePath = selectedFile.getFullPath();
+            }
+        }
+        return filePath;
+    }
 }