}
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();
}
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();
}
});
- 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] ");
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;
}
}
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;
}
{
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;
}
}
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;
}
}
}
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;
}
}
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);
+ 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;
}
}
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) {