From: jihye424.kim Date: Fri, 8 May 2015 09:42:59 +0000 (+0900) Subject: Tab Item: add profile tab item and tab folder X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48a0e258a1d3cdadb9edea734b44d25b9c7638dc;p=sdk%2Femulator%2Femulator-manager.git Tab Item: add profile tab item and tab folder - add tab item and tab folder for profile. - add 'current profile' variable to MainView Change-Id: Ibfcdcb0d0c13df90508198bf0682a571365aebc9 Signed-off-by: jihye424.kim --- diff --git a/common-project/src/org/tizen/emulator/manager/ui/VMsMainView.java b/common-project/src/org/tizen/emulator/manager/ui/VMsMainView.java index 494ce1c..66be492 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/VMsMainView.java +++ b/common-project/src/org/tizen/emulator/manager/ui/VMsMainView.java @@ -40,6 +40,7 @@ import org.eclipse.swt.widgets.Display; import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.platform.BaseImage; import org.tizen.emulator.manager.platform.Platform; +import org.tizen.emulator.manager.platform.Profile; import org.tizen.emulator.manager.platform.TotalPlatform; import org.tizen.emulator.manager.resources.ColorResources; import org.tizen.emulator.manager.resources.StringResources; @@ -157,8 +158,42 @@ public class VMsMainView { private Platform currentPlatform = null; private BaseImage currentImage = null; + private Profile currentProfile = null; private VMProperty currentProperty = null; + public Profile getProfile() { + return currentProfile; + } + + public void setProfile(Profile profile) { + setProfile(profile, false); + } + + public void setProfile(Profile profile, boolean isRefresh) { + if (profile == null) { + return; + } + + this.currentProfile = profile; + // TODO + /* + detailView.changeProfile(); + listView.drawProfile(profile, isRefresh); + */ + } + + public void resetProfile() { + if (detailView != null && currentProfile != null) { + detailView.reset(); + setProfile(currentProfile, true); + } + } + + public void clearProfile() { + currentProfile = null; + currentProperty = null; + } + public Platform getCurrentPlatform() { return currentPlatform; } @@ -233,6 +268,19 @@ public class VMsMainView { } } + public void drawVMList(Profile profile) { + isCreateMode = false; + if (profile.getEmulatorList().isEmpty()) { + drawEmptyVMList(); + } else { + /* TODO + listView.drawVMList((currentProperty == null ? 0 + : profile.getEmulatorList().indexOf(currentProperty), + false)); + */ + } + } + public void drawEmptyVMList() { detailView.drawEmptyVM(); listView.drawEmptyVMList(); @@ -240,7 +288,6 @@ public class VMsMainView { public void drawEmptyDetailVM() { isCreateMode = false; - //listView.cancelModify(-1); detailView.drawEmptyDetailVM(); } diff --git a/common-project/src/org/tizen/emulator/manager/ui/tabfolder/ProfileTabFolder.java b/common-project/src/org/tizen/emulator/manager/ui/tabfolder/ProfileTabFolder.java new file mode 100644 index 0000000..c5b77bb --- /dev/null +++ b/common-project/src/org/tizen/emulator/manager/ui/tabfolder/ProfileTabFolder.java @@ -0,0 +1,298 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JiHye Kim + * Minkee Lee + * SeokYeon Hwang + * Sangho Park + * + * 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.tabfolder; + +import java.util.ArrayList; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FillLayout; +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.tizen.emulator.manager.EmulatorManager; +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.tool.SettingInfoFile; +import org.tizen.emulator.manager.ui.VMsMainView; +import org.tizen.emulator.manager.ui.widgets.ImageButton; +import org.tizen.emulator.manager.ui.widgets.WSTATE; + +public class ProfileTabFolder { + private static final int TAB_WIDTH = 120; + private static final int TAB_HEIGHT = 29; + private static final int RIGHT_BUTTON_WIDTH = 18; + private static final int RIGHT_BUTTON_HEIGHT = 18; + private static final int RIGHT_BUTTON_GAP = 11; + + private ArrayList items + = new ArrayList(5); + private ArrayList buttons + = new ArrayList(5); + + private ArrayList rightButtons + = new ArrayList(5); + + private Composite mainComposite = null; + private Composite tabComposite = null; + private Composite contentsComposite = null; + + // + private static VMsMainView view; + + public Composite getTabComposite() { + return tabComposite; + } + + public Composite getComposite() { + return mainComposite; + } + + public ProfileTabFolder(Composite parent) { + mainComposite = new Composite(parent, SWT.NONE); + mainComposite.setLayout(new FormLayout()); + // + mainComposite.setBackground(ColorResources.TAB_BG_COLOR.getColor()); + // + + tabComposite = new Composite(mainComposite, SWT.DOUBLE_BUFFERED); + tabComposite.setLayout(new FormLayout()); + + contentsComposite = new Composite(mainComposite, SWT.DOUBLE_BUFFERED); + contentsComposite.setLayout(new FillLayout()); + + // initialize main view + view = VMsMainView.getInstance(); + view.setInit(contentsComposite); + + FormData data = new FormData(); + data.top = new FormAttachment(0, 0); + data.left = new FormAttachment(0, 2); + data.right = new FormAttachment(100, -2); + data.height = TAB_HEIGHT + 1; + tabComposite.setLayoutData(data); + tabComposite.setBackground(ColorResources.TAB_BG_COLOR.getColor()); + + data = new FormData(); + data.top = new FormAttachment(tabComposite, 0); + data.left = new FormAttachment(0, 2); + data.right = new FormAttachment(100, -2); + data.bottom = new FormAttachment(100, 0); + contentsComposite.setLayoutData(data); + contentsComposite.setBackground(ColorResources.TAB_CONTENTS_BG_COLOR.getColor()); + } + + public void draw() { + if(!items.isEmpty()) { + // clear + if (!buttons.isEmpty()) { + for (ImageButton b : buttons) { + b.dispose(); + } + buttons.clear(); + } + + for (ProfileTabItem item : items) { + buttons.add(makeTabButton(item)); + } + + int index = SettingInfoFile.getLastTapIndex(); + if (index >= buttons.size()) { + index = 0; + } + selectionItem(buttons.get(index)); + } + + if(!rightButtons.isEmpty()) { + int size = rightButtons.size() - 1; + for (int i = rightButtons.size() - 1; i >= 0; i--) { + FormData data = new FormData(); + data.top = new FormAttachment(0, 6); + if (i == size) { + data.right = new FormAttachment(99, 0); + } else { + data.right = new FormAttachment(rightButtons.get(i+1), -RIGHT_BUTTON_GAP); + } + data.width = RIGHT_BUTTON_WIDTH; + data.height = RIGHT_BUTTON_HEIGHT; + rightButtons.get(i).setLayoutData(data); + } + } + } + + public void redraw() { + items.get(getSelectionIndex()).redraw(); + } + + private ImageButton makeTabButton(ProfileTabItem item) { + ImageButton tabButton = new ImageButton(tabComposite, SWT.NONE); + Image unselectTab = PatchImageResources.getUnselectedTabFolder(120, 29); + Image selectTab = PatchImageResources.getSelectTabFolder(120, 29); + tabButton.setImages(unselectTab, unselectTab, selectTab, + selectTab, selectTab, selectTab, + unselectTab); + tabButton.setFont(FontResources.TAB_BUTTON_FONT.getFont()); + tabButton.setFontColor(WSTATE.NORMAL, ColorResources.TAB_NORMAL_FONT_COLOR.getColor()); + tabButton.setFontColor(WSTATE.SELECTED, ColorResources.TAB_SELECTED_FONT_COLOR.getColor()); + tabButton.setFontColor(WSTATE.HOVER, ColorResources.TAB_HOVER_FONT_COLOR.getColor()); + tabButton.setFontColor(WSTATE.PUSH, ColorResources.TAB_SELECTED_FONT_COLOR.getColor()); + tabButton.setFontColor(WSTATE.SELECTED_HOVER, ColorResources.TAB_SELECTED_FONT_COLOR.getColor()); + tabButton.setFontColor(WSTATE.SELECTED_PUSH, ColorResources.TAB_SELECTED_FONT_COLOR.getColor()); + tabButton.setText(item.getTitle()); + tabButton.setEnabled(true); + + FormData data = new FormData(); + data.top = new FormAttachment(0, 2); + if (buttons.size() == 0) { + data.left = new FormAttachment(0, 0); + } else { + data.left = new FormAttachment(buttons.get(buttons.size() - 1), 2); + } + + data.width = TAB_WIDTH; + data.height = TAB_HEIGHT; + tabButton.setLayoutData(data); + + tabButton.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + selectionItem((ImageButton)e.widget); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + } + }); + + return tabButton; + } + + private void selectionItem(ImageButton button) { + ImageButton b = null; + for (int i = 0; i < buttons.size(); i++) { + b = buttons.get(i); + if (button == b) { + if (!b.isSelection()) { + // draw main view using selected platform + items.get(i).draw(); + /* + // this is temp code..please fix me + if (items.get(i).ProfileTabItem().getName().equals("all")) { + items.get(i).draw(); + } + */ + contentsComposite.layout(true, false); + EmulatorManager.setCurrentTabIndex(i); + } + this.setSelection(i); + b.setSelection(true); + } else { + b.setSelection(false); + } + } + } + + private int selection = -1; + + public void setSelection(int index) { + selection = index; + } + + public ProfileTabItem getSelection() { + if (selection == -1) { + return items.get(0); + } else { + return items.get(selection); + } + } + + public int getSelectionIndex() { + return selection; + } + + public void clear() { + // TODO + } + + public VMsMainView getView() { + return view; + } + + public void addTabItem(ProfileTabItem item) { + items.add(item); + } + + public void addTabItem(int index, ProfileTabItem item) { + items.add(index, item); + } + + public void removeTabItem(ProfileTabItem item) { + items.remove(item); + } + + public ProfileTabItem removeTabItem(int index) { + return items.remove(index); + } + + public void addTabRightButton(ImageButton button) { + rightButtons.add(button); + } + + public void addTabRightButton(int index, ImageButton button) { + rightButtons.add(index, button); + } + + public void removeTabRightButton(ImageButton button) { + rightButtons.remove(button); + } + + public ImageButton removeTabRightButton(int index) { + return rightButtons.remove(index); + } + + public int width() { + int width = 0; + if (!buttons.isEmpty()) { + width += buttons.size() * TAB_WIDTH; + } + + if (!rightButtons.isEmpty()) { + width += rightButtons.size() * (RIGHT_BUTTON_WIDTH + RIGHT_BUTTON_GAP); + } + + return width; + } +} diff --git a/common-project/src/org/tizen/emulator/manager/ui/tabfolder/ProfileTabItem.java b/common-project/src/org/tizen/emulator/manager/ui/tabfolder/ProfileTabItem.java new file mode 100644 index 0000000..50827a7 --- /dev/null +++ b/common-project/src/org/tizen/emulator/manager/ui/tabfolder/ProfileTabItem.java @@ -0,0 +1,75 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JiHye Kim + * Minkee Lee + * SeokYeon Hwang + * Sangho Park + * + * 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.tabfolder; + +import org.tizen.emulator.manager.platform.Profile; +import org.tizen.emulator.manager.ui.VMsMainView; + +public class ProfileTabItem { + private static VMsMainView view; + private Profile profile; + private String title; + + public ProfileTabItem(Profile profile, ProfileTabFolder mainTab) { + this.profile = profile; + this.title = this.profile.getName(); + view = mainTab.getView(); + + mainTab.addTabItem(this); + } + + public Profile getProfile() { + return profile; + } + + public void setProfile(Profile profile) { + this.profile = profile; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public void draw() { + // TODO + view.clearPlatform(); + view.setProfile(profile); + } + + public void redraw() { + // TODO + view.resetProfile(); + } +}