[SRADA-129] Implementation check RunningProcess Invalid
authorggh1933.go <ggh1933.go@samsung.com>
Wed, 9 Mar 2016 06:44:24 +0000 (15:44 +0900)
committerdongkyu6 lee <dongkyu6.lee@samsung.com>
Thu, 10 Mar 2016 02:36:45 +0000 (11:36 +0900)
 + Cutting Needless Argument on process
 + Comparing by "MapKey"
 + If Result is null, Avoid NullPointException and close explorer

Change-Id: Id21297fc6bfe6e4c5755c97e10d7049f183a46e2

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ProcessExplorer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ProcessExplorerDialog.java

index 5d6d658..71c8e56 100644 (file)
@@ -244,11 +244,20 @@ public class ProcessExplorer extends Composite {
                                if (maxnamelen < namelen) {
                                        maxnamelen = namelen;
                                }
-
+                               
                                GridItem item = new GridItem(table, SWT.NONE);
                                item.setCheckable(0, false);
                                item.setText(1, entry.getKey().toString());
-                               item.setText(2, name);
+                               
+                               // cut needless arguments (ex:"/usr/bin/Xorg :0 -#$%" -> "/usr/bin/Xorg")
+                               if(name.contains(" ")){
+                                       int cut_index = name.indexOf(" ");
+                                       item.setText(2, name.substring(0, cut_index));
+                               }
+                               else{
+                                       item.setText(2, name);
+                               }
+                               
 
                                if (initialProcesses != null && initialProcesses.containsKey(entry.getKey())) {
                                        item.setChecked(0, true);
index 441eea4..213e69b 100644 (file)
@@ -40,6 +40,8 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.dynamicanalyzer.appearance.DesignConstants;
 import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.communicator.DACommunicator;
+import org.tizen.dynamicanalyzer.handlers.UIAction;
 import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
 import org.tizen.dynamicanalyzer.nl.UserErrorWarningLabels;
 import org.tizen.dynamicanalyzer.nl.WidgetLabels;
@@ -119,9 +121,22 @@ public class ProcessExplorerDialog extends DAMessageBox {
                        @Override
                        public void handleClickEvent(DACustomButton button) {
                                result = explorer.getSelectedProcess();
+
                                if (null != result) {
+                                       Boolean process_validation = checkInvalidProcess((Map<Integer, String>) result);
+                                        if(process_validation){
+                                                shell.dispose();
+                                        }
+                                        else{
+                                               UIAction.showWarning("Selected Process isn't running. Reselect process");
+                                               explorer.updateData();
+                                        }
+                               }
+                               /// If result is null, close explorer
+                               else{
                                        shell.dispose();
                                }
+                               
                        }
                });
 
@@ -141,7 +156,32 @@ public class ProcessExplorerDialog extends DAMessageBox {
                        }
                });
        }
+       
+
+       public Boolean checkInvalidProcess(Map<Integer, String> result){
+               Map<Integer, String> processes = DACommunicator.getProcessList();
+
+               for(Map.Entry<Integer, String> result_entry : result.entrySet()){
+
+                       Integer result_key = result_entry.getKey();
+
+                       /// don't have selected PID
+                       if(!processes.containsKey(result_key) ){
+                               return false;
+                       }
+                       /// don't matched PROCESS_NAME
+                       else{
+                               String Compare = processes.get(result_key);
+
+                               if(!Compare.contains(result_entry.getValue())){
+                                       return false;
+                               }
+                       }
+               }
 
+               return true;
+       }
+       
        public void setProcessList(Map<Integer, String> proc) {
                explorer.setSelectedProcess(proc);
        }