--- /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.renewal.dialog;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.platform.BaseImage;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.FontResources;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.renewal.widgets.CheckBoxButton;
+import org.tizen.emulator.manager.ui.renewal.widgets.CustomScrolledComposite;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class DeleteMessageBox extends MessageBox {
+ private final int CONTENTS_WIDTH = 450;
+ private final int CONTENTS_HEIGHT = 150;
+ private final int ADD_EMULATORS_HEIGHT = 50;
+ private final int SPACING = 15;
+
+ private BaseImage image;
+ private boolean needDeleteFile = false;
+ private CheckBoxButton deleteCheck;
+
+ public DeleteMessageBox(BaseImage image) {
+ super(shell, SWT.CANCEL | SWT.OK, true);
+ this.image = image;
+ }
+
+
+
+ @Override
+ protected void makeContentsBox() {
+ scrolledList = new CustomScrolledComposite(dialog, SWT.V_SCROLL | SWT.H_SCROLL);
+ Composite contentsBox = new Composite(scrolledList, SWT.NONE);
+ scrolledList.setContent(contentsBox);
+ scrolledList.setBackground(ColorResources.MESSAGE_BOX_CONTENTS_BG.getColor());
+ contentsBox.setBackground(ColorResources.MESSAGE_BOX_CONTENTS_BG.getColor());
+
+ // TOOD
+ contentsWidth = CONTENTS_WIDTH;
+ contentsHeight = CONTENTS_HEIGHT;
+ if (!image.isEemulatorListEmpty()) {
+ contentsHeight += ADD_EMULATORS_HEIGHT;
+ }
+ contentsBox.setBounds(0, 0, contentsWidth, contentsHeight);
+
+ int spacing = SPACING;
+ int textHeight = 20;
+ int checkBoxWidth = 15;
+
+ Label label = new Label(contentsBox, SWT.WRAP);
+ label.setText("Are you sure you want to delete base image from the table?");
+ label.setBackground(ColorResources.MESSAGE_BOX_CONTENTS_BG.getColor());
+ label.setForeground(ColorResources.MESSAGE_BOX_CONTENTS_FONT.getColor());
+ label.setFont(FontResources.MESSAGE_BOX_CONTENTS.getFont());
+ label.setBounds(SPACING, spacing, CONTENTS_WIDTH, textHeight);
+ spacing = spacing + SPACING + textHeight;
+
+ if (!image.isEemulatorListEmpty()) {
+ String name = "";
+
+ for (VMProperty prop : image.getEmulatorList()) {
+ if (!name.isEmpty()) {
+ name += ", ";
+ }
+ name += prop.getName();
+ }
+ String message =
+ "Emulators using this base image may not work."
+ + StringResources.NEW_LINE
+ + "Emulator name: " + name;
+ label = new Label(contentsBox, SWT.WRAP);
+ label.setText(message);
+ label.setBackground(ColorResources.MESSAGE_BOX_CONTENTS_BG.getColor());
+ label.setForeground(ColorResources.MESSAGE_BOX_CONTENTS_FONT.getColor());
+ label.setFont(FontResources.MESSAGE_BOX_CONTENTS_BOLD.getFont());
+ label.setBounds(SPACING, spacing, CONTENTS_WIDTH, textHeight * 2);
+ spacing = spacing + SPACING + textHeight * 2;
+
+ }
+
+ if (image.isFilePathExist()) {
+ deleteCheck = new CheckBoxButton(contentsBox, SWT.NONE);
+ deleteCheck.setSelection(false);
+ deleteCheck.addListener(SWT.Selection, checkBoxListener);
+ deleteCheck.setBounds(SPACING, spacing, checkBoxWidth, checkBoxWidth);
+
+ label = new Label(contentsBox, SWT.WRAP);
+ label.setText("Delete base image file on disk(cannot be undone)");
+ label.setBackground(ColorResources.MESSAGE_BOX_CONTENTS_BG.getColor());
+ label.setForeground(ColorResources.MESSAGE_BOX_CONTENTS_FONT.getColor());
+ label.setFont(FontResources.MESSAGE_BOX_CONTENTS_BOLD.getFont());
+ label.setBounds(SPACING + 15 + 5, spacing, CONTENTS_WIDTH, textHeight);
+
+ spacing = spacing + SPACING + textHeight;
+ } else {
+ label = new Label(contentsBox, SWT.WRAP);
+ label.setText("Base image file has already been deleted.");
+ label.setBackground(ColorResources.MESSAGE_BOX_CONTENTS_BG.getColor());
+ label.setForeground(ColorResources.MESSAGE_BOX_CONTENTS_FONT.getColor());
+ label.setFont(FontResources.MESSAGE_BOX_CONTENTS_BOLD.getFont());
+ label.setBounds(SPACING, spacing, CONTENTS_WIDTH, textHeight);
+
+ spacing = spacing + SPACING + textHeight;
+ }
+
+ label = new Label(contentsBox, SWT.WRAP);
+ label.setText("Base image loaction:"
+ + StringResources.NEW_LINE
+ + " " + image.getPath());
+ label.setBackground(ColorResources.MESSAGE_BOX_CONTENTS_BG.getColor());
+ label.setForeground(ColorResources.MESSAGE_BOX_CONTENTS_FONT.getColor());
+ label.setFont(FontResources.MESSAGE_BOX_CONTENTS.getFont());
+ label.setBounds(SPACING, spacing, contentsWidth, contentsHeight - spacing);
+ }
+
+ private Listener checkBoxListener = new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ switch(e.type) {
+ case SWT.Selection:
+ needDeleteFile = ((CheckBoxButton)e.widget).isSelection();
+ default:
+ break;
+ }
+ }
+ };
+
+ @Override
+ public void setMessage(final String message) {
+ // not used
+ }
+
+ public boolean needDeleteFile() {
+ return needDeleteFile;
+ }
+}
private final int SPACING = 15;
private Shell parent;
- private Shell dialog;
+ protected Shell dialog;
private int width = MIN_WIDTH;
private int height = MIN_HEIGHT;
private int returnValue = SWT.OK;
private Label titleLabel = null;
- private CustomScrolledComposite scrolledList = null;
+ protected CustomScrolledComposite scrolledList = null;
private StyledText contentsBox = null;
+ protected int contentsWidth = 0;
+ protected int contentsHeight = 0;
private Composite titleComp = null;
// TODO: Icon SWT.ICON_ERROR ...
- private static final Shell shell;
+ protected static final Shell shell;
static {
shell = MainDialog.getShell();
}
DragHandler.set(dialog, null, titleLabel, titleComp);
}
- private void makeContentsBox() {
+ protected void makeContentsBox() {
scrolledList = new CustomScrolledComposite(dialog, SWT.V_SCROLL | SWT.H_SCROLL);
contentsBox = new StyledText(scrolledList, SWT.NONE);
contentsBox.setRightMargin(SPACING);
contentsBox.setEnabled(false);
contentsBox.pack();
+
+ contentsWidth = contentsBox.getSize().x;
+ contentsHeight = contentsBox.getSize().y;
}
private int buttonCount = 1;
private Rectangle computeDialogBounds() {
Rectangle result = new Rectangle(0, 0, 0, 0);
Rectangle parentRect = parent.getBounds();
- width = Math.max(width, contentsBox.getSize().x + 6); // add scroll bar spacing
- height = Math.max(height, contentsBox.getSize().y + TITLE_HEIGHT + BOTTOM_HEIGHT + 6);
+ width = Math.max(width, contentsWidth + 6); // add scroll bar spacing
+ height = Math.max(height, contentsHeight + TITLE_HEIGHT + BOTTOM_HEIGHT + 6);
result.width = width = Math.min(width, MAX_WIDTH);
result.height = height = Math.min(height, MAX_HEIGHT);