- refactoring that VMNameItem, ImageItem extends TextLabelItem.
- add VMProperty to VMModifyDialog in order to give display data
to each item in dialog.
Change-Id: I6f353500faeeedae03881601b519f800bfca4763
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
import org.eclipse.swt.SWT;
import org.tizen.emulator.manager.ui.renewal.MainDialog;
-import org.tizen.emulator.manager.ui.renewal.detail.item.IModifyDialogItem;
-import org.tizen.emulator.manager.ui.renewal.detail.item.ImageItem;
-import org.tizen.emulator.manager.ui.renewal.detail.item.ProfileItem;
-import org.tizen.emulator.manager.ui.renewal.detail.item.VMNameItem;
import org.tizen.emulator.manager.ui.renewal.dialog.VMModifyDialog;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ImageItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.ProfileItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.VMNameItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IModifyDialogItem;
import org.tizen.emulator.manager.vms.VMProperty;
public class VMModifyHandler {
// open modify dialog
VMModifyDialog dialog = new VMModifyDialog(MainDialog.getShell());
- dialog.create(getItemList(property));
+ dialog.create(property, getItemList(property));
// TODO set display value to dialog
DEFAULT_FONT_10("default_font_10", resizeDefaultFont(10)),
DEFAULT_FONT_9("default_font_9", resizeDefaultFont(9));
- public static FontResources DETAIL_ITEM_TITLE = DEFAULT_FONT_9;
+ public static FontResources MODIFY_ITEM_TITLE = DEFAULT_FONT_9;
public static FontResources CONTENT = DEFAULT_FONT_9;
String name;
ICON_CREATE_TV("icon_create_tv"),
ICON_CREATE_WEARABLE("icon_create_wearable"),
+ // Modify item title icon
ICON_TITLE_VMNAME("icon_title_vmname"),
ICON_TITLE_IMAGE("icon_title_image"),
- ICON_TITLE_PROFILE("icon_title_profile");
+ ICON_TITLE_PROFILE("icon_title_profile"),
+
+ // profile select button
+ BTN_PROFILE_MOBILE_SELECTED("btn_profile_mobile_selected"),
+ BTN_PROFILE_MOBILE_UNSELECTED_HOVER("btn_profile_mobile_unselected_hover"),
+ BTN_PROFILE_MOBILE_UNSELECTED_NML("btn_profile_mobile_unselected_nml"),
+ BTN_PROFILE_WEARABLE_SELECTED("btn_profile_wearable_selected"),
+ BTN_PROFILE_WEARABLE_UNSELECTED_HOVER("btn_profile_wearable_unselected_hover"),
+ BTN_PROFILE_WEARABLEE_UNSELECTED_NML("btn_profile_wearable_unselected_nml"),
+ BTN_PROFILE_TV_SELECTED("btn_profile_tv_selected"),
+ BTN_PROFILE_TV_UNSELECTED_HOVER("btn_profile_tv_unselected_hover"),
+ BTN_PROFILE_TV_UNSELECTED_NML("btn_profile_tv_unselected_nml");
+
String name;
Image image;
+++ /dev/null
-/*
- * Emulator Manager
- *
- * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Minkee Lee <minkee.lee@samsung.com>
- * JiHye Kim <jihye424.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * Sangho Park <sangho1206.park@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.renewal.detail.item;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.emulator.manager.renewal.resources.ImageResources;
-import org.tizen.emulator.manager.ui.renewal.widgets.TextInputBox;
-
-public class VMNameItem implements IModifyDialogItem {
-
- private ModifyItem item;
- private TextInputBox textInputBox;
-
- private final String TITLE = "VM Name";
- private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_VMNAME;
- private final int TEXT_BOX_WIDTH = 236;
- private final int TEXT_BOX_HEIGHT = 23;
-
-
- @Override
- public int getHeight() {
- return item.getHeight();
- }
-
- @Override
- public void create(Composite parent) {
- item = new ModifyItem(parent, TITLE, TITLE_ICON_RESOURCE);
- makeBody();
- }
-
- private void makeBody() {
- setBodyLayout();
- makeTextInputBox();
- }
-
- private void setBodyLayout() {
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginWidth = ModifyItem.BODY_MARGIN_LEFT;
- layout.marginHeight = 0;
-
- item.getBody().setLayout(layout);
- }
-
-
- private void makeTextInputBox() {
- // text box
- GridData data = new GridData(TEXT_BOX_WIDTH, TEXT_BOX_HEIGHT);
- data.verticalAlignment = SWT.CENTER;
- data.grabExcessVerticalSpace = true;
-
- Composite bodyComp = item.getBody();
- textInputBox = new TextInputBox(bodyComp, SWT.NONE);
- textInputBox.setLayoutData(data);
- }
-
-}
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.renewal.resources.ColorResources;
-import org.tizen.emulator.manager.ui.renewal.detail.item.IModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IModifyDialogItem;
import org.tizen.emulator.manager.vms.VMProperty;
public class VMModifyDialog extends Dialog {
private Composite scrolledContent;
private List<IModifyDialogItem> itemList;
+ private VMProperty property;
public VMModifyDialog(Shell parent) {
super(parent, TITLE, WIDTH, HEIGHT, BUTTON_STYLE);
}
- public void create(List<IModifyDialogItem> itemList) {
+ public void create(VMProperty property, List<IModifyDialogItem> itemList) {
// - create title, buttons
// - init body
super.create();
// make body contents
+ this.property = property;
this.itemList = itemList;
createScrolledComposite();
}
private void makeModifyItem() {
for (IModifyDialogItem item : itemList) {
+ item.setItemData(property);
item.create(scrolledContent);
}
*
*/
-package org.tizen.emulator.manager.ui.renewal.detail.item;
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TextLabelItem;
+import org.tizen.emulator.manager.vms.VMProperty;
-public class ImageItem implements IModifyDialogItem {
-
- private ModifyItem item;
+public class ImageItem extends TextLabelItem {
private final String TITLE = "Image";
private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_IMAGE;
- private Label label;
-
- @Override
- public int getHeight() {
- return item.getHeight();
- }
-
@Override
public void create(Composite parent) {
- item = new ModifyItem(parent, TITLE, TITLE_ICON_RESOURCE);
- makeBody();
+ create(parent, TITLE, TITLE_ICON_RESOURCE);
}
- private void makeBody() {
- // TODO
+ @Override
+ public void setItemData(VMProperty property) {
+ if (property == null) {
+ return;
+ }
+ value = property.getBaseImageName();
}
}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@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.renewal.item.modify.vm;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.IModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.ModifyItem;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class ProfileItem implements IModifyDialogItem {
+
+ private ModifyItem item;
+ private Canvas canvas;
+ private String profile = "";
+
+ private final String TITLE = "Profile";
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_PROFILE;
+ private final String MOBILE = "mobile";
+ private final String WEARABLE = "wearable";
+ private final String TV = "tv";
+ private final int PROFILE_IMAGE_WIDTH = 34;
+ private final int PROFILE_IMAGE_HEIGHT = 25;
+
+
+ private void addProfileImage() {
+ item.setBodyLayoutDefault();
+
+ // init canvas
+ GridData data = new GridData(PROFILE_IMAGE_WIDTH, PROFILE_IMAGE_HEIGHT);
+ data.verticalAlignment = SWT.CENTER;
+ data.grabExcessVerticalSpace = true;
+ canvas = new Canvas(item.getBody(), SWT.NONE);
+ canvas.setLayoutData(data);
+
+ // set image
+ Image profileImage = getProfileImage(profile);
+ if (profileImage != null) {
+ canvas.setBackgroundImage(profileImage);
+ }
+ }
+
+ private Image getProfileImage(String profile) {
+ if (profile.equals(MOBILE)) {
+ return ImageResources.BTN_PROFILE_MOBILE_SELECTED.getImage();
+
+ } else if (profile.equals(WEARABLE)) {
+ return ImageResources.BTN_PROFILE_WEARABLE_SELECTED.getImage();
+
+ } else if (profile.equals(TV)) {
+ return ImageResources.BTN_PROFILE_TV_SELECTED.getImage();
+ }
+
+ return null;
+ }
+
+ @Override
+ public void setItemData(VMProperty property) {
+ if (property == null) {
+ return;
+ }
+ this.profile = property.getImageProfile();
+
+ }
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+ @Override
+ public void create(Composite parent) {
+ item = new ModifyItem(parent, TITLE, TITLE_ICON_RESOURCE);
+ addProfileImage();
+ }
+}
*
*/
-package org.tizen.emulator.manager.ui.renewal.detail.item;
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.common.TextLabelItem;
+import org.tizen.emulator.manager.vms.VMProperty;
-public class ProfileItem implements IModifyDialogItem {
-
- private ModifyItem item;
-
- private final String TITLE = "Profile";
- private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_PROFILE;
+public class VMNameItem extends TextLabelItem {
+ private final String TITLE = "VM Name";
+ private final ImageResources TITLE_ICON_RESOURCE = ImageResources.ICON_TITLE_VMNAME;
@Override
- public int getHeight() {
- return item.getHeight();
+ public void create(Composite parent) {
+ create(parent, TITLE, TITLE_ICON_RESOURCE);
}
@Override
- public void create(Composite parent) {
- item = new ModifyItem(parent, TITLE, TITLE_ICON_RESOURCE);
- makeBody();
+ public void setItemData(VMProperty property) {
+ if (property == null) {
+ return;
+ }
+ value = property.getName();
}
- private void makeBody() {
- // TODO
- }
+
}
* - S-Core Co., Ltd
*
*/
-package org.tizen.emulator.manager.ui.renewal.detail.item;
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.vms.VMProperty;
public interface IModifyDialogItem {
public void create(Composite parent);
- // to decide modify dialog.
+ /** To decide modify dialog */
public int getHeight();
+ public void setItemData(VMProperty property);
}
*
*/
-package org.tizen.emulator.manager.ui.renewal.detail.item;
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
private final int TITLE_MARGIN_LEFT = 15;
private final int TITLE_SPACING = 8;
private final int TITLE_CANVAS_WIDTH = 144;
+ private final int LINE_INDENT = 5;
private final String title;
private Image titleIcon;
// draw text
gc.setForeground(ColorResources.MODIFY_ITEM_TITLE.getColor());
- gc.setFont(FontResources.DETAIL_ITEM_TITLE.getFont());
+ gc.setFont(FontResources.MODIFY_ITEM_TITLE.getFont());
Point textExt = gc.textExtent(title);
int titleY = (itemHeight - textExt.y) / 2;
gc.drawText(title,
int lineWidth = ModifyItem.LINE_WIDTH;
gc.setForeground(ColorResources.MODIFY_ITEM_LINE.getColor());
gc.setLineWidth(lineWidth);
- gc.drawLine(lineWidth, itemHeight,
+ gc.drawLine(LINE_INDENT, itemHeight,
TITLE_CANVAS_WIDTH, itemHeight);
}
});
-package org.tizen.emulator.manager.ui.renewal.detail.item;
+package org.tizen.emulator.manager.ui.renewal.item.modify.vm.common;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
public ModifyItem(Composite parent, String title, ImageResources iconResource) {
create(parent);
-
createTitle(title, iconResource);
createEmptyBody();
}
bodyComp.setBackgroundMode(SWT.INHERIT_DEFAULT);
}
+ /** For a constructor parameter of child widget */
public Composite getBody() {
return bodyComp;
}
return ITEM_HEIGHT + LINE_WIDTH;
}
+ /** For item which has single widget. */
+ public void setBodyLayoutDefault() {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginWidth = ModifyItem.BODY_MARGIN_LEFT;
+ layout.marginHeight = 0;
+
+ bodyComp.setLayout(layout);
+ }
+
private void create(Composite parent) {
initComp(parent);
makeComp();
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@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.renewal.item.modify.vm.common;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.FontResources;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+
+public abstract class TextLabelItem implements IModifyDialogItem {
+
+ private ModifyItem item;
+ private Canvas canvas;
+
+ protected String value = "";
+
+ @Override
+ public int getHeight() {
+ return item.getHeight();
+ }
+
+ protected void create(Composite parent, String title, ImageResources iconResources) {
+ item = new ModifyItem(parent, title, iconResources);
+ makeBody();
+ }
+
+ protected void makeBody() {
+ item.setBodyLayoutDefault();
+
+ // init canvas;
+ GridData data = new GridData();
+ data.heightHint = ModifyItem.ITEM_HEIGHT;
+ data.horizontalAlignment = SWT.FILL;
+ data.grabExcessHorizontalSpace = true;
+ canvas = new Canvas(item.getBody(), SWT.NONE);
+ canvas.setLayoutData(data);
+
+ drawImageName();
+ }
+
+ private void drawImageName() {
+ canvas.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ GC gc = e.gc;
+ gc.setForeground(ColorResources.CONTENT_FONT.getColor());
+ gc.setFont(FontResources.CONTENT.getFont());
+ Point textExt = gc.textExtent(value);
+ int poxY = (ModifyItem.ITEM_HEIGHT - textExt.y) / 2;
+ gc.drawText(value, 0, poxY);
+ }
+ });
+ }
+
+}
return ninePatchResourceMap;
}
+ public void setText(String value) {
+ text.setText(value);
+ }
+
private void init() {
initBox();
text.setBackground(TEXT_BACKGROUND.getColor());
text.setLayoutData(data);
-
removeTextBorder();
addFocusListener();
addMouseListener();