--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@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.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<ProfileTabItem> items
+ = new ArrayList<ProfileTabItem>(5);
+ private ArrayList<ImageButton> buttons
+ = new ArrayList<ImageButton>(5);
+
+ private ArrayList<ImageButton> rightButtons
+ = new ArrayList<ImageButton>(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;
+ }
+}
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@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.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();
+ }
+}