From 8c80eee427d47636e0ba5dec8acb131c7d94f5e8 Mon Sep 17 00:00:00 2001 From: "jihye1128.kim" Date: Fri, 16 Dec 2011 16:30:45 +0900 Subject: [PATCH] [Title] Modify NFC UI 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/tag/page/NfcDialog.java | 37 ++++++++++-- .../com/samsung/tizen/nfc/tag/page/NfcPage.java | 70 ++++------------------ 2 files changed, 43 insertions(+), 64 deletions(-) diff --git a/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcDialog.java b/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcDialog.java index c9e6b54..128bca6 100644 --- a/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcDialog.java +++ b/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcDialog.java @@ -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(); diff --git a/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcPage.java b/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcPage.java index 893b879..34a3236 100644 --- a/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcPage.java +++ b/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcPage.java @@ -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) { -- 2.7.4