--- /dev/null
+/* Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * MunKyu Im <munkyu.im@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.emulator.manager.ui.detail.item.template;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.tizen.emulator.manager.resources.ColorResources;
+import org.tizen.emulator.manager.resources.FontResources;
+import org.tizen.emulator.manager.resources.PatchImageResources;
+import org.tizen.emulator.manager.ui.detail.item.ItemChangeState;
+import org.tizen.emulator.manager.ui.widgets.ImageLabel;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMPropertyValue;
+import org.tizen.emulator.manager.vms.xml.template.Item;
+
+public class TextSubViewItem extends SubViewItem {
+
+ protected String oldValue;
+ protected String newValue;
+
+ // for modify view
+ protected Text text;
+ protected Image INPUTBOX_ON_IMAGE = null;
+ protected Image INPUTBOX_OFF_IMAGE = null;
+
+ public TextSubViewItem(LabelViewItem parentItem, Composite comp,
+ Item template) {
+ super(parentItem, comp, template);
+ }
+
+ public void drawModify() {
+ makeCategory();
+
+ if (INPUTBOX_ON_IMAGE == null) {
+ INPUTBOX_ON_IMAGE = PatchImageResources.getInputBoxON(LABEL_WIDTH);
+ }
+
+ if (INPUTBOX_OFF_IMAGE == null) {
+ INPUTBOX_OFF_IMAGE = PatchImageResources.getInputBoxOff(LABEL_WIDTH);
+ }
+
+ valueLabel = new ImageLabel(comp, SWT.NONE);
+ valueLabel.setEnableImage(INPUTBOX_ON_IMAGE);
+ valueLabel.setDisableImage(INPUTBOX_OFF_IMAGE);
+ valueLabel.setLayout(new FormLayout());
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(category, 4);
+ data.top = new FormAttachment(0, TOP_GAP);
+ data.width = valueLabel.getSize().x;
+ data.height = valueLabel.getSize().y;
+ valueLabel.setLayoutData(data);
+
+ text = new Text(valueLabel, SWT.NONE);
+ text.setBackground(ColorResources.DETAIL_INPUT_BOX_COLOR.getColor());
+ text.setFont(FontResources.DETAIL_LABEL_FONT.getFont());
+ text.setForeground(ColorResources.DETAIL_ENABLE_FONT_COLOR.getColor());
+ text.setTextLimit(VMProperty.MAX_NAME_LEN);
+
+ data = new FormData();
+ data.left = new FormAttachment(0, 5);
+ data.top = new FormAttachment(0, 2);
+ data.right = new FormAttachment(100, -5);
+ data.bottom = new FormAttachment(100, -2);
+ text.setLayoutData(data);
+
+ addListener();
+ }
+
+ protected void addListener() {
+ text.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ newValue = text.getText();
+
+ if (!parentItem.isCreateMode()) {
+ parentItem.getListener().ChangeValue(parentItem.getThis());
+ }
+ }
+ });
+
+ text.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent event) {
+ switch (event.keyCode) {
+ case SWT.CR:
+ case SWT.KEYPAD_CR:
+ //TODO
+ parentItem.getListener().ChangeState(ItemChangeState.CREATE);
+ break;
+ case SWT.ESC:
+ parentItem.getListener().ChangeState(ItemChangeState.CANCEL);
+ break;
+ default:
+ // TODO
+ break;
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean settingDetailItem(VMPropertyValue value) {
+ valueLabel.setText(value.getAdvancedOptionSubValue(parentItem.getName(), name));
+ return true;
+ }
+
+ @Override
+ public void setValue(VMPropertyValue value) {
+ value.setAdvancedOptionSub(parentItem.getName(), name, newValue);
+ }
+
+ @Override
+ public boolean settingModifyItem(VMPropertyValue value) {
+ newValue = value.getAdvancedOptionSubValue(parentItem.getName(), name);
+ return false;
+ }
+
+}
package org.tizen.emulator.manager.ui.detail.item.template;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.tizen.emulator.manager.resources.FontResources;
import org.tizen.emulator.manager.resources.PatchImageResources;
import org.tizen.emulator.manager.ui.detail.item.AdvancedViewItem;
+import org.tizen.emulator.manager.ui.detail.item.ItemChangeState;
import org.tizen.emulator.manager.ui.widgets.ImageLabel;
import org.tizen.emulator.manager.vms.VMProperty;
import org.tizen.emulator.manager.vms.VMPropertyValue;
data.bottom = new FormAttachment(100, -2);
text.setLayoutData(data);
+ addListener();
}
@Override
}
}
+ public void addListener() {
+ text.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ newValue = text.getText();
+
+ if (!isCreateMode()) {
+ getListener().ChangeValue(getThis());
+ }
+ }
+ });
+
+
+ text.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent event) {
+ switch (event.keyCode) {
+ case SWT.CR:
+ case SWT.KEYPAD_CR:
+ //TODO
+ getListener().ChangeState(ItemChangeState.CREATE);
+ break;
+ case SWT.ESC:
+ getListener().ChangeState(ItemChangeState.CANCEL);
+ break;
+ default:
+ // TODO
+ break;
+ }
+ }
+ });
+ }
+
@Override
public boolean settingDetailItem(VMPropertyValue value) {