[Title] Modify NFC UI
authorjihye1128.kim <jihye1128.kim@samsung.com>
Fri, 16 Dec 2011 07:30:45 +0000 (16:30 +0900)
committerjihye1128.kim <jihye1128.kim@samsung.com>
Fri, 16 Dec 2011 07:30:45 +0000 (16:30 +0900)
parent of record list composite is modified.(parent -> message composite)
[Type] Enhancement
[Module] event injector nfc
[Priority] Minor
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]

com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcDialog.java
com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcPage.java

index c9e6b54..128bca6 100644 (file)
@@ -12,13 +12,26 @@ public abstract class NfcDialog
     }
 
     public static void openInfoDialog(final Shell shell, final String message) {
-       openInfoDialog(shell, "Info", message);
+       Shell s;
+       if (shell == null) {
+               s = new Shell();
+       } else {
+               s = shell;
+       }
+       openInfoDialog(s, "Info", message);
     }
 
     public static void openInfoDialog(final Shell shell, final String title, final String message) {
-        Display.getDefault().syncExec(new Runnable() {
+       final Shell s;
+       if (shell == null) {
+               s = new Shell();
+       } else {
+               s = shell;
+       }
+  
+       Display.getDefault().syncExec(new Runnable() {
             public void run() {
-                MessageBox dialog = new MessageBox(shell, SWT.OK | SWT.MODELESS | SWT.ICON_INFORMATION);
+                MessageBox dialog = new MessageBox(s, SWT.OK | SWT.MODELESS | SWT.ICON_INFORMATION);
                 dialog.setText(title);
                 dialog.setMessage(message);
                 dialog.open();
@@ -31,13 +44,25 @@ public abstract class NfcDialog
     }
     
     public static void openErrorDialog(final Shell shell, final String message) {
-       openErrorDialog(shell, "Error", message);
+       Shell s;
+       if (shell == null) {
+               s = new Shell();
+       } else {
+               s = shell;
+       }
+       openErrorDialog(s, "Error", message);
     }
 
     public static void openErrorDialog(final Shell shell, final String title, final String message) {
-        Display.getDefault().syncExec(new Runnable() {
+       final Shell s;
+       if (shell == null) {
+               s = new Shell();
+       } else {
+               s = shell;
+       }
+       Display.getDefault().syncExec(new Runnable() {
             public void run() {
-                MessageBox dialog = new MessageBox(shell, SWT.OK | SWT.MODELESS | SWT.ICON_ERROR);
+                MessageBox dialog = new MessageBox(s, SWT.OK | SWT.MODELESS | SWT.ICON_ERROR);
                 dialog.setText(title);
                 dialog.setMessage(message);
                 dialog.open();
index 893b879..34a3236 100644 (file)
@@ -139,7 +139,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                        }
                });
 
-               Composite RecordComposite = formUtil.createComposite(parent, 2);
+               Composite RecordComposite = formUtil.createComposite(messageComposite, 2);
                GridData gd2 = new GridData();
                gd2.widthHint = 160;
                lblRecords = formUtil.createLabel(RecordComposite, "Records [0/4000] ");
@@ -181,23 +181,12 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                for (int i = 0; i < text.length(); i++) {
                        char c = textArray[i];
                        if (c == '\n') {
-                               if (shell != null)
-                                       NfcDialog.openInfoDialog(shell,
-                                                       "Can not enter a newline character.");
-                               else
-                                       NfcDialog
-                                                       .openInfoDialog("Can not enter a newline character.");
+                               NfcDialog.openInfoDialog(shell, "Can not enter a newline character.");
                                return false;
                        }
 
                        if (c >= 0x80) {
-                               if (shell != null)
-                                       NfcDialog
-                                                       .openInfoDialog(shell,
-                                                                       "Invalid characters are entered.\nOnly ASCII characters can be entered.\n");
-                               else
-                                       NfcDialog
-                                                       .openInfoDialog("Invalid characters are entered.\nOnly ASCII characters can be entered.\n");
+                               NfcDialog.openInfoDialog(shell, "Invalid characters are entered.\nOnly ASCII characters can be entered.\n");
                                return false;
                        }
                }
@@ -451,12 +440,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
        private void addRecord()
        {
                if (RecordList.size() >= 5) {
-                       if (shell != null)
-                               NfcDialog.openInfoDialog(shell,
-                                                                            "The number of NDEF records has reached the maximum limit of 5.\n");
-                       else
-                               NfcDialog.openInfoDialog("The number of NDEF records has reached the maximum limit of 5.\n");
-
+                       NfcDialog.openInfoDialog(shell, "The number of NDEF records has reached the maximum limit of 5.\n");
                        return;
                }
 
@@ -555,11 +539,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
        {
                for (NDEFRecord record : RecordList) {
                        if (id.equals(record.getId())) {
-                               if (shell != null)
-                                       NfcDialog.openInfoDialog(shell,
-                                                       "Duplicate ID is not allowed.\n");
-                               else
-                                       NfcDialog.openInfoDialog("Duplicate ID is not allowed.\n");
+                               NfcDialog.openInfoDialog(shell, "Duplicate ID is not allowed.\n");
                                return false;
                        }
                }
@@ -576,10 +556,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
 
                        record = RecordList.get(i);
                        if (id.equals(record.getId())) {
-                               if (shell != null)
-                                       NfcDialog.openInfoDialog(shell, "Duplicate ID is not allowed.\n");
-                               else
-                                       NfcDialog.openInfoDialog("Duplicate ID is not allowed.\n");
+                               NfcDialog.openInfoDialog(shell, "Duplicate ID is not allowed.\n");
                                return false;
                        }
                }
@@ -598,12 +575,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                }
 
                if (strValue.length() > 4000) {
-                       if (shell != null)
-                               NfcDialog.openInfoDialog(shell,
-                                                               "The length of the NDEF message has reached the maxium limit of 4,000 bytes\n");
-                       else
-                               NfcDialog
-                                               .openInfoDialog("The length of the NDEF message has reached the maxium limit of 4,000 bytes\n");
+                       NfcDialog.openInfoDialog(shell, "The length of the NDEF message has reached the maxium limit of 4,000 bytes\n");
                        return false;
                }
 
@@ -634,31 +606,18 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                }
 
                if (MediaFilePath == null) {
-                       if (shell != null)
-                               NfcDialog.openErrorDialog(shell, "Please choose media file.\n");
-                       else
-                               NfcDialog.openErrorDialog("Please choose media file.\n");
+                       NfcDialog.openErrorDialog(shell, "Please choose media file.\n");
                } else {
                        int index = MediaFilePath.lastIndexOf('.');
                        if (index == -1) {
-                               if (shell != null)
-                                       NfcDialog.openErrorDialog(shell,
-                                                       "This file's type is not mime media type.\n");
-                               else
-                                       NfcDialog
-                                                       .openErrorDialog("This file's type is not mime media type.\n");
+                               NfcDialog.openErrorDialog(shell, "This file's type is not mime media type.\n");
                        } else {
                                String ex = MediaFilePath.substring(index + 1);
                                MimeTypeList typelist = MimeTypeList.getInstance();
 
                                String type = typelist.findMimeType(ex);
                                if (type == null) {
-                                       if (shell != null)
-                                               NfcDialog.openErrorDialog(shell,
-                                                               "This file's type is not mime media type.\n");
-                                       else
-                                               NfcDialog
-                                                               .openErrorDialog("This file's type is not mime media type.\n");
+                                       NfcDialog.openErrorDialog(shell, "This file's type is not mime media type.\n");
                                } else {
                                        txtRecordTypeName.setEnabled(true);
                                        txtRecordTypeName.setEditable(false);
@@ -691,11 +650,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                                                + String.valueOf(tagtype) + records + "\n";
 
                        } else {
-                               if (shell != null)
-                                       NfcDialog.openErrorDialog(shell, "Select Tag Type\n");
-                               else
-                                       NfcDialog.openErrorDialog("Select Tag Type\n");
-
+                               NfcDialog.openErrorDialog(shell, "Select Tag Type\n");
                                return null;
                        }
                }
@@ -713,8 +668,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                boolean result = false;
                try {
                        /*// add for test
-                        * if (shell != null) NfcDialog.openInfoDialog(shell, msg); else
-                        * NfcDialog.openInfoDialog(msg);
+                        * NfcDialog.openInfoDialog(shell, msg); 
                         */
                        result = injectorSocket.sendNfc(msg);
                } catch (Exception e1) {