From 1685a77adeec98c624a1aaba1afad90c2c55fedd Mon Sep 17 00:00:00 2001 From: "minkee.lee" Date: Wed, 13 Jan 2016 17:19:51 +0900 Subject: [PATCH] message-dialog: support new message-dialog Open dialog selectively according to UI mode. (new UI mode or not) Change-Id: Ifbe2073386cb32e19fa0e9a1a664fde650463a35 Signed-off-by: minkee.lee --- .../emulator/manager/ui/dialog/MessageDialog.java | 41 ++- .../manager/ui/renewal/dialog/MessageDialog.java | 322 --------------------- .../dialog/network/TapDeviceDialogForWin.java | 3 +- 3 files changed, 38 insertions(+), 328 deletions(-) delete mode 100644 src/org/tizen/emulator/manager/ui/renewal/dialog/MessageDialog.java diff --git a/src/org/tizen/emulator/manager/ui/dialog/MessageDialog.java b/src/org/tizen/emulator/manager/ui/dialog/MessageDialog.java index f85f191..a2c4dfb 100644 --- a/src/org/tizen/emulator/manager/ui/dialog/MessageDialog.java +++ b/src/org/tizen/emulator/manager/ui/dialog/MessageDialog.java @@ -42,15 +42,29 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Shell; +import org.tizen.emulator.manager.EmulatorManager; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.ui.MainDialog; import org.tizen.emulator.manager.ui.Messages; +import org.tizen.emulator.manager.ui.renewal.dialog.MessageBox; public class MessageDialog { + private static boolean isNewUI = EmulatorManager.isNewUIMode(); + private Shell shell; + int msgResponse = 0; + private Shell dialog = null; + + private MessageBox messageBox = null; + public MessageDialog() { - this.shell = MainDialog.getShell(); + if (isNewUI) { + this.shell = org.tizen.emulator.manager.ui.renewal.MainDialog.getShell(); + + } else { + this.shell = MainDialog.getShell(); + } } public MessageDialog(Shell shell) { @@ -62,8 +76,15 @@ public class MessageDialog } public void close() { - if (dialog != null && !dialog.isDisposed()) { - dialog.close(); + if (isNewUI) { + if (messageBox != null) { + messageBox.dispose(); + } + + } else { + if (dialog != null && !dialog.isDisposed()) { + dialog.close(); + } } } @@ -226,9 +247,19 @@ public class MessageDialog return msgResponse; } - int msgResponse = 0; - private Shell dialog = null; + private int openMessageBox(String title, String message, final int icon_style, final int style) { + // TODO icon_style + messageBox = new MessageBox(shell, style, true); + messageBox.setTitle(title); + messageBox.setMessage(message); + return messageBox.open(); + } + public int openMessageDialog(final String title, final String message, final int icon_style, final int style) { + if (isNewUI) { + return openMessageBox(title, message, icon_style, style); + } + dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setText(title); GridLayout layout = new GridLayout(2, false); diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/MessageDialog.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/MessageDialog.java deleted file mode 100644 index a9d0ec0..0000000 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/MessageDialog.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Emulator Manager - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * MunKyu Im - * SeokYeon Hwang - * JiHye Kim - * YeongKyoon Lee - * - * 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.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.swt.widgets.Shell; -import org.tizen.emulator.manager.resources.StringResources; -import org.tizen.emulator.manager.ui.MainDialog; -import org.tizen.emulator.manager.ui.Messages; - -public class MessageDialog -{ - private Shell shell; - public MessageDialog() { - this.shell = MainDialog.getShell(); - } - - public MessageDialog(Shell shell) { - if (shell == null) { - this.shell = new Shell(); - } else { - this.shell = shell; - } - } - - public void close() { - if (dialog != null && !dialog.isDisposed()) { - dialog.close(); - } - } - - public void openNoButtonInfoDialog(final String message) { - String title = Messages.getString("MessageDialog.0"); //$NON-NLS-1$ - int icon_style = SWT.ICON_INFORMATION; - dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); - dialog.setText(title); - dialog.setLayout(new GridLayout(2, false)); - dialog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); - - Label icon = new Label(dialog, SWT.NONE); - icon.setImage(Display.getCurrent().getSystemImage(icon_style)); - icon.pack(); - - Label text = new Label(dialog, SWT.NONE); - text.setText(message); - text.pack(); - - int x = icon.getSize().x + text.getSize().x; - int y = 0; - if (icon.getSize().y > text.getSize().y ) { - y = icon.getSize().y; - } else { - y = text.getSize().y; - } - - dialog.setSize(x + 50, y + 60); - - if (MainDialog.getShell() != null) { - Point p = MainDialog.getShell().getLocation(); - Point s = MainDialog.getShell().getSize(); - dialog.setLocation(p.x + (s.x>>2), p.y + (s.y>>2)); - } - - dialog.open(); - - } - - public int openInfoDialog(final String message) { - return openInfoDialog(Messages.getString("MessageDialog.0"), message); //$NON-NLS-1$ - } - - public int openInfoDialog(final String title, final String message) { - return openMessageDialog(title, message, SWT.ICON_INFORMATION, SWT.OK ); - } - - public int openWarningDialog(final String message) { - return openWarningDialog(Messages.getString("MessageDialog.0"), message); //$NON-NLS-1$ - } - - public int openWarningDialog(final String title, final String message) { - return openMessageDialog(title, message, SWT.ICON_WARNING, SWT.OK); - } - - public int openSelectionDialog(final String message) { - return openSelectionDialog(Messages.getString("MessageDialog.0"), message); //$NON-NLS-1$ - } - - public int openSelectionDialog(final String title, final String message) { - return openMessageDialog(title, message, SWT.ICON_QUESTION, SWT.OK | SWT.CANCEL); - } - - public int openWarningAndSelectionDialog(final String message) { - return openMessageDialog(Messages.getString("MessageDialog.0"), message, SWT.ICON_WARNING, SWT.OK | SWT.CANCEL); //$NON-NLS-1$ - } - - public int openRemoveVMFailDialog(final String path, final String vmName) { - msgResponse = 0; - return openRemoveVMFailDialog(Messages.getString("MessageDialog.0"), path, vmName, SWT.ICON_WARNING, SWT.OK); //$NON-NLS-1$ - } - - public int openRemoveVMFailDialog(final String title, final String path, final String vmName, - final int icon_style, final int style) { - dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); - dialog.setText(title); - dialog.setLayout(new GridLayout(2, false)); - dialog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); - - Label icon = new Label(dialog, SWT.NONE); - icon.setImage(Display.getCurrent().getSystemImage(icon_style)); - icon.pack(); - Composite textComp = new Composite(dialog, SWT.NONE); - GridLayout layout = new GridLayout(1, true); - layout.horizontalSpacing = 0; - layout.verticalSpacing = 0; - layout.marginBottom = 0; - layout.marginHeight = 0; - layout.marginLeft = 5; - layout.marginRight = 10; - layout.marginTop = 0; - layout.marginWidth = 0; - textComp.setLayout(layout); - textComp.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, false, false)); - - Label content = new Label(textComp, SWT.NONE); - content.setText(Messages.getString("MessageDialog.RemoveError.0") + vmName + Messages.getString("MessageDialog.RemoveError.1") //$NON-NLS-1$ //$NON-NLS-2$ - + Messages.getString("MessageDialog.RemoveError.2") //$NON-NLS-1$ - + Messages.getString("MessageDialog.RemoveError.3")); //$NON-NLS-1$ - content.pack(); - - Link vmDirectory = new Link(textComp, SWT.NONE); - vmDirectory.setText("" + path +""); //$NON-NLS-1$ //$NON-NLS-2$ - vmDirectory.addSelectionListener(new SelectionListener() { - @Override - public void widgetDefaultSelected(SelectionEvent arg0) { - } - @Override - public void widgetSelected(SelectionEvent arg0) { - try { - org.eclipse.swt.program.Program.launch(path); - } catch (Throwable e) { - return; - } - } - }); - vmDirectory.pack(); - - textComp.pack(); - int x = icon.getSize().x + textComp.getSize().x; - int y = 0; - if (icon.getSize().y > textComp.getSize().y ) { - y = icon.getSize().y; - } else { - y = textComp.getSize().y; - } - - dialog.setSize(x + 50, y + 100); - - if (MainDialog.getShell() != null) { - Point p = MainDialog.getShell().getLocation(); - Point s = MainDialog.getShell().getSize(); - dialog.setLocation(p.x + (s.x>>2), p.y + (s.y>>2)); - } - - //TODO : dummy label - new Label(dialog, SWT.NONE); - new Label(dialog, SWT.NONE); - new Label(dialog, SWT.NONE); - - makeButtonComposite(style); - - dialog.open(); - while(!dialog.isDisposed()) { - if(!Display.getCurrent().readAndDispatch()) { - Display.getCurrent().sleep(); - } - } - - return msgResponse; - } - - int msgResponse = 0; - private Shell dialog = null; - public int openMessageDialog(final String title, final String message, final int icon_style, final int style) { - dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); - dialog.setText(title); - dialog.setLayout(new GridLayout(2, false)); - dialog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); - - Label icon = new Label(dialog, SWT.NONE); - icon.setImage(Display.getCurrent().getSystemImage(icon_style)); - icon.pack(); - - Label text = new Label(dialog, SWT.NONE); - text.setText(message); - text.pack(); - - int x = icon.getSize().x + text.getSize().x; - int y = 0; - if (icon.getSize().y > text.getSize().y ) { - y = icon.getSize().y; - } else { - y = text.getSize().y; - } - - dialog.setSize(x + 50, y + 100); - - if (MainDialog.getShell() != null) { - Point p = MainDialog.getShell().getLocation(); - Point s = MainDialog.getShell().getSize(); - dialog.setLocation(p.x + (s.x>>2), p.y + (s.y>>2)); - } - - //TODO : dummy label - new Label(dialog, SWT.NONE); - new Label(dialog, SWT.NONE); - new Label(dialog, SWT.NONE); - - makeButtonComposite(style); - - dialog.open(); - while(!dialog.isDisposed()) { - if(!Display.getCurrent().readAndDispatch()) { - Display.getCurrent().sleep(); - } - } - - return msgResponse; - } - - private void makeButtonComposite(int style) { - // button - Composite buttonComposite = new Composite(dialog, SWT.NONE); - GridLayout layout = new GridLayout(2, false); - layout.horizontalSpacing = 5; - layout.verticalSpacing = 0; - layout.marginBottom = 0; - layout.marginHeight = 0; - layout.marginLeft = 0; - layout.marginRight = 0; - layout.marginTop = 0; - layout.marginWidth = 0; - buttonComposite.setLayout(layout); - buttonComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, false, false)); - //buttonComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - - if ((style & SWT.CANCEL) != 0 ) { - Button cancleButton = new Button(buttonComposite, SWT.PUSH); - cancleButton.setLayoutData(new GridData(90, SWT.DEFAULT)); - cancleButton.setText(StringResources.CANCEL); - cancleButton.setFocus(); - cancleButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - dialog.close(); - msgResponse = SWT.CANCEL; - } - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - cancleButton.setFocus(); - } else { - new Label(dialog, SWT.NONE); - } - - Button okButton = new Button(buttonComposite, SWT.PUSH); - okButton.setLayoutData(new GridData(90, SWT.DEFAULT)); - okButton.setText(StringResources.OK); - okButton.setFocus(); - okButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - dialog.close(); - msgResponse = SWT.OK; - } - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - if ((style & SWT.CANCEL) == 0 ) { - okButton.setFocus(); - } - } - - public void dispose() { - shell.dispose(); - } -} diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/network/TapDeviceDialogForWin.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/network/TapDeviceDialogForWin.java index 7c39dc4..f777cdb 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/network/TapDeviceDialogForWin.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/network/TapDeviceDialogForWin.java @@ -55,10 +55,11 @@ import org.tizen.emulator.manager.resources.FilePathResources; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.tool.TapUtil; import org.tizen.emulator.manager.ui.Messages; +import org.tizen.emulator.manager.ui.dialog.MessageDialog; +import org.tizen.emulator.manager.ui.dialog.TapGuideDialogForWin; import org.tizen.emulator.manager.ui.renewal.MainDialog; import org.tizen.emulator.manager.ui.renewal.dialog.Dialog; import org.tizen.emulator.manager.ui.renewal.dialog.MessageBox; -import org.tizen.emulator.manager.ui.renewal.dialog.MessageDialog; import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem; import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetTapDeviceItemForWin; import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox; -- 2.7.4