upload tizen1.0 source
[sdk/ide/eventinjector-eplugin.git] / org.tizen.nfc / src / org / tizen / nfc / page / NfcPage.java
index 4598a65..12992a0 100644 (file)
@@ -1,21 +1,27 @@
 /*
  * org.tizen.nfc.tag.page
- * 
+ *
  * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
  * Jihye kim <jihye1128.kim@samsung.com>
  * Sungmin Ha <sungmin82.ha@samsung.com>
- * DongKyun Yun <dk77.yun@samsung.com>
+ * Yeongkyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  *
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * 
  * Contributors:
  * - S-Core Co., Ltd
- * 
  */
 
 package org.tizen.nfc.page;
@@ -35,13 +41,13 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
-
-import org.tizen.injector.provider.AbstractInjectorItem;
-import org.tizen.injector.provider.AbstractInjectorPage;
 import org.tizen.common.connection.ConnectionPlugin;
 import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
 import org.tizen.common.connection.ui.TizenRemoteFileDialog;
 import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult;
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+import org.tizen.injector.view.InjectorView;
 import org.tizen.sdblib.FileListingService.FileEntry;
 import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.MultiLineReceiver;
@@ -99,8 +105,8 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
        @Override
        protected void createContents()
        {
+               InjectorView.getDefault().addSelectionListener(this);
                currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
-               ConnectionPlugin.getDefault().addSelectionListener(this);
 
                shell = parent.getShell();
 
@@ -189,7 +195,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                        private void Selected(SelectionEvent e) {
                                int i = cmbRecordFormat.getSelectionIndex();
                                if (i != -1) {
-                                       checkRecordFormat(i);
+                                       checkRecordFormat(i + 1);
                                        txtRecordTypeName.setText("");
                                        cmbRecordTypeName.select(0);
                                        txtRecordID.setText("");
@@ -359,7 +365,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                if (i != -1) {
                        NDEFRecord record = RecordList.get(i);
                        checkRecordFormat(record.getFormat());
-                       cmbRecordFormat.select(record.getFormat());
+                       cmbRecordFormat.select(record.getFormat() - 1);
 
                        if (record.getFormat() == 1) {
                                if (record.getTypeName().compareTo("U") == 0)
@@ -433,7 +439,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                        {
                                cmbRecordFormat.setEnabled(true);
 
-                               checkRecordFormat(cmbRecordFormat.getSelectionIndex());
+                               checkRecordFormat(cmbRecordFormat.getSelectionIndex() + 1);
                                txtRecordTypeName.setText("");
                                cmbRecordTypeName.select(0);
                                txtRecordID.setText("");
@@ -479,7 +485,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                        {
                                cmbRecordFormat.setEnabled(true);
 
-                               checkRecordFormat(cmbRecordFormat.getSelectionIndex());
+                               checkRecordFormat(cmbRecordFormat.getSelectionIndex() + 1);
                                txtRecordTypeName.setText("");
                                cmbRecordTypeName.select(0);
                                txtRecordID.setText("");
@@ -544,10 +550,10 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                        break;
                case 2: // NDEF_TNF_MIME_MEDIA
                        cmbRecordTypeName.setEnabled(false);
-                       txtRecordTypeName.setEnabled(true);
+                       txtRecordTypeName.setEnabled(false);
                        txtRecordTypeName.setEditable(false);
                        txtRecordID.setEnabled(true);
-                       txtRecordPayload.setEnabled(true);
+                       txtRecordPayload.setEnabled(false);
                        txtRecordPayload.setEditable(false);
                        butSelectMediaFile.setEnabled(true);
                        break;
@@ -655,9 +661,9 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
 
        private void setRecordValue(NDEFRecord record)
        {
-               record.setFormat(cmbRecordFormat.getSelectionIndex());
+               record.setFormat(cmbRecordFormat.getSelectionIndex() + 1);
 
-               if (cmbRecordFormat.getSelectionIndex() == 1) {
+               if ((cmbRecordFormat.getSelectionIndex() + 1) == 1) {
                        record.setTypeName(TypeNameList[cmbRecordTypeName.getSelectionIndex()]);
                } else {
                        if (txtRecordTypeName.getText().isEmpty() == true)
@@ -761,7 +767,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                                return;
                        }
                        if (checkFileSize(MediaFilePath) == false) {
-                               NfcDialog.openErrorDialog(shell, "Size of selected file is too big. Available file size is under of 10.\n");
+                               NfcDialog.openErrorDialog(shell, "Size of selected file is too big. Available file size is under of 10KB.\n");
                                return;
                        }
                        txtRecordTypeName.setEnabled(true);
@@ -927,7 +933,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
        @Override
        protected void finalize() throws Throwable
        {
-               ConnectionPlugin.getDefault().removeSelectionListener(this);
+               InjectorView.getDefault().removeSelectionListener(this);
                // TargetConnectionControl.removeTargetConnectionListener(this);
                super.finalize();
        }
@@ -942,11 +948,11 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
                                .isEmulator())
                        return;
 
-               if (currentDevice == null && selectedEntry.getName() != null)
+               if(currentDevice == null && selectedEntry.getName() != null) {
                        connect();
-               else if (currentDevice == null && selectedEntry.getName() == null)
+               } else if(currentDevice == null && selectedEntry.getName() == null) {
                        return;
-               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
+               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
                        disconnect();
                        connect();
                }