[Title] make MessageDialog not using MessageBox
authorjihye kim <jihye1128.kim@samsung.com>
Fri, 7 Sep 2012 12:43:22 +0000 (21:43 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Fri, 7 Sep 2012 12:43:22 +0000 (21:43 +0900)
MessageBox make beep in Windows
[Type] work
[Module] emulator manager
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

package/emulator-manager.install.linux
package/pkginfo.manifest
src/org/tizen/emulator/manager/ui/MessageDialog.java

index 345db99..91babda 100755 (executable)
@@ -7,6 +7,7 @@ echo $tizen_vms_path> $TIZEN_SDK_INSTALL_PATH/tools/emulator/bin/.$USER.lock
 ## User Define for desktop menu
 currentPath=`pwd`
 desktoppath=~/.local/share/applications
+iconpath=~/.local/share/icons
 
 ## Do not modify the followings (Make desktop menu)
 TIZEN_SDK_INSTALL_PATH=`echo $INSTALLED_PATH`
@@ -16,7 +17,9 @@ then
    exit 2;
 fi
 
-iconpath=~/.local/share/icons
+## make $USERNAME.lock file
+tizen_vms_path="${HOME}/tizen-sdk-data"
+echo $tizen_vms_path> $TIZEN_SDK_INSTALL_PATH/tools/emulator/bin/.$USER.lock
 
 ## em shortcut
 em_desktopfile=$desktoppath/tizen-sdk-em.desktop
index 063ed8c..6cebb56 100644 (file)
@@ -1,5 +1,5 @@
 Source: emulator-manager
-Version: 1.3.37
+Version: 1.3.38
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
 
 Package: emulator-manager
index 25a4fa7..03df7a5 100644 (file)
 package org.tizen.emulator.manager.ui;
 
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.MessageBox;
+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.Shell;
 import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.tool.StringResource;
 
 public class MessageDialog
 {
@@ -50,40 +59,132 @@ public class MessageDialog
                }
        }
 
-    public int openInfoDialog(final String message) {
-       return openInfoDialog("Info", message);
-    }
-
-    public int openInfoDialog(final String title, final String message) {
-       return openMessageDialog(title, message, SWT.OK | SWT.MODELESS | SWT.ICON_INFORMATION);
-    }
-
-    public int openWarningDialog(final String message) {
-       return openWarningDialog("Warning", message);
-    }
-
-    public int openWarningDialog(final String title, final String message) {
-       return openMessageDialog(title, message, SWT.OK | SWT.MODELESS | SWT.ICON_WARNING);
-    }
-
-    public int openSelectionDialog(final String message) {
-       return openSelectionDialog("Warning", message);
-    }
-
-    public int openSelectionDialog(final String title, final String message) {
-       return openMessageDialog(title, message, SWT.OK | SWT.CANCEL | SWT.MODELESS | SWT.ICON_WARNING);
-    }
-
-    int msgResponse = 0;
-    public int openMessageDialog(final String title, final String message, final int style) {
-        MessageBox dialog = new MessageBox(shell, style);
-        dialog.setText(title);
-        dialog.setMessage(message);
-        msgResponse = dialog.open();
-       return msgResponse;
-    }
-
-    public void dispose() {
-        shell.dispose();
-    }
+       public int openInfoDialog(final String message) {
+               return openInfoDialog("Info", message);
+       }
+
+       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("Warning", message);
+       }
+
+       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("Warning", message);
+       }
+
+       public int openSelectionDialog(final String title, final String message) {
+               return openMessageDialog(title, message,  SWT.ICON_WARNING, SWT.OK | SWT.CANCEL);
+       }
+
+       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 + 25, y + 100);
+
+               if (EmulatorManager.getInstance() != null
+                               && EmulatorManager.getInstance().getMainDialog() != null) {
+                       Point p = EmulatorManager.getInstance().getMainDialog().getShell().getLocation();
+                       Point s = EmulatorManager.getInstance().getMainDialog().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(StringResource.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(100, SWT.DEFAULT));
+               okButton.setText(StringResource.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();
+       }
 }