From: jihye424.kim Date: Tue, 25 Aug 2015 02:04:31 +0000 (+0900) Subject: VMWorker: modify delete vm function X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=34cc76cb5fd3a2d8bbf6021c08b0cad936938220;p=sdk%2Femulator%2Femulator-manager.git VMWorker: modify delete vm function Change-Id: Ibbc152e54223a568d16648f521f3d810b2b17d80 Signed-off-by: jihye424.kim --- diff --git a/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java b/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java index 1c2959b..755dadb 100644 --- a/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java +++ b/src/org/tizen/emulator/manager/renewal/resources/ColorResources.java @@ -36,6 +36,7 @@ import org.eclipse.swt.widgets.Display; public enum ColorResources { WHITE(255, 255, 255), BLACK(0, 0, 0), + RED(255, 0, 0), // nine patch button GRAY_BTN_NORMAL(149, 159, 164), @@ -43,13 +44,11 @@ public enum ColorResources { GRAY_BTN_PUSH(100, 110, 144), GRAY_BTN_DISABLE(208, 208, 208), - RED(255, 0, 0), - MESSAGE_BOX_TITLE_BG(111, 125, 149), MESSAGE_BOX_TITLE_FONT(255, 255, 255), MESSAGE_BOX_CONTENTS_BG(255, 255, 255), MESSAGE_BOX_CONTENTS_FONT(102, 102, 102), - MESSAGE_BOX_BOTTOM_BG(224, 224, 224), + MESSAGE_BOX_BG(224, 224, 224), MESSAGE_BOX_BUTTON_BG(149, 159, 165), MESSAGE_BOX_BUTTON_FONT(255, 255, 255); diff --git a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/MenuHandling.java b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/MenuHandling.java index e045c47..a806d86 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/MenuHandling.java +++ b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/MenuHandling.java @@ -37,7 +37,6 @@ import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.resources.FilePathResources; import org.tizen.emulator.manager.resources.StringResources; import org.tizen.emulator.manager.ui.renewal.MainDialog; -import org.tizen.emulator.manager.ui.renewal.tableviewer.MessageBox; import org.tizen.emulator.manager.vms.VMProperty; import org.tizen.emulator.manager.vms.helper.VMLauncherException; import org.tizen.emulator.manager.vms.helper.VMWorkerException; @@ -81,8 +80,8 @@ public class MenuHandling { if (le.isCritical()) { EMLogger.getLogger().warning(msg); msg += StringResources.NEW_LINE + StringResources.NEW_LINE - + "This virtual machine has problem." + StringResources.NEW_LINE - + "Do you want to delete this virtual machine?"; + + "This virtual machine has problem." + StringResources.NEW_LINE + + "Do you want to delete this virtual machine?"; int response = openMessageBox(msg, SWT.YES | SWT.NO, false); if (response == SWT.OK) { @@ -122,11 +121,11 @@ public class MenuHandling { property.getWorker().resetVM(); } catch(VMWorkerException e) { String errorMsg = "[Failure]" - + StringResources.NEW_LINE - + "Failed to reset [ " - + property.getName() + " ] virtual machine." - + StringResources.NEW_LINE - + e.getMessage(); + + StringResources.NEW_LINE + + "Failed to reset [ " + + property.getName() + " ] virtual machine." + + StringResources.NEW_LINE + + e.getMessage(); openMessageBox(errorMsg); throw e; } @@ -153,7 +152,8 @@ public class MenuHandling { if (!isRunning.isEmpty()) { message = message + StringResources.NEW_LINE + isRunning + StringResources.NEW_LINE - + "virtual machines are already running. So, these will be not reset."; + + "virtual machines are already running. So, these will be not reset." + + StringResources.NEW_LINE; } message += StringResources.NEW_LINE + "Do you want to be continue?"; @@ -186,13 +186,13 @@ public class MenuHandling { dialog.addMessage("[Success]" + StringResources.NEW_LINE + "'" + prop.getName() + "' virtual machine has been reset." - + StringResources.NEW_LINE); + + StringResources.NEW_LINE + StringResources.NEW_LINE); } catch(VMWorkerException e) { dialog.addMessage("[Failure]" + StringResources.NEW_LINE + "'" + prop.getName() + "' virtual machine has been failed to reset." + StringResources.NEW_LINE); - dialog.addMessage(e.getMessage() + StringResources.NEW_LINE); + dialog.addMessage(e.getMessage() + StringResources.NEW_LINE + StringResources.NEW_LINE); errorMessage += e.getMessage() + StringResources.NEW_LINE; if (!isNeedRefresh) { @@ -227,11 +227,11 @@ public class MenuHandling { property.getWorker().deleteVM(); } catch(VMWorkerException e) { String errorMsg = "[Failure]" - + StringResources.NEW_LINE - + "Failed to reset [ " - + property.getName() + " ] virtual machine." - + StringResources.NEW_LINE - + e.getMessage(); + + StringResources.NEW_LINE + + "Failed to delete [ " + + property.getName() + " ] virtual machine." + + StringResources.NEW_LINE + + e.getMessage(); openMessageBox(errorMsg); throw e; } @@ -258,7 +258,7 @@ public class MenuHandling { message = message + StringResources.NEW_LINE + isRunning + StringResources.NEW_LINE + "virtual machines are already running. So, these will be not deleted." - + StringResources.NEW_LINE + + StringResources.NEW_LINE + StringResources.NEW_LINE + "Do you want to be continue?"; } @@ -282,13 +282,13 @@ public class MenuHandling { try { prop.getWorker().deleteVM(); dialog.addMessage("[Success]" + StringResources.NEW_LINE - + "'" + prop.getName() + "' vm image has been deleted." - + StringResources.NEW_LINE); + + "'" + prop.getName() + "' vm image has been deleted." + + StringResources.NEW_LINE + StringResources.NEW_LINE); } catch(VMWorkerException e) { dialog.addMessage("[Failure]" + StringResources.NEW_LINE + "'" + prop.getName() + "' vm image has been failed to delete." + StringResources.NEW_LINE); - dialog.addMessage(e.getMessage() + StringResources.NEW_LINE); + dialog.addMessage(e.getMessage() + StringResources.NEW_LINE + StringResources.NEW_LINE); errorMessage += e.getMessage() + StringResources.NEW_LINE; if (!isNeedRefresh) { diff --git a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/MessageBox.java b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/MessageBox.java index 440b863..d27c0ef 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/tableviewer/MessageBox.java +++ b/src/org/tizen/emulator/manager/ui/renewal/tableviewer/MessageBox.java @@ -32,11 +32,7 @@ package org.tizen.emulator.manager.ui.renewal.tableviewer; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; @@ -121,7 +117,6 @@ public class MessageBox { if (isOpen) { return SWT.NONE; } - isOpen = true; makeDialog(); @@ -150,7 +145,7 @@ public class MessageBox { makeContentsBox(); // need contentsBox size - dialog.setBackgroundMode(SWT.INHERIT_FORCE); + dialog.setBackground(ColorResources.MESSAGE_BOX_BG.getColor()); dialog.setBounds(computeDialogBounds()); // need dialog size @@ -158,8 +153,6 @@ public class MessageBox { titleLabel.setBounds(0, 0, width, TITLE_HEIGHT); scrolledList.setBounds(0, TITLE_HEIGHT, width, height - TITLE_HEIGHT - BOTTOM_HEIGHT); - - dialog.addPaintListener(painter); } private void makeTitleLabel() { @@ -169,7 +162,7 @@ public class MessageBox { titleLabel.setForeground(ColorResources.MESSAGE_BOX_TITLE_FONT.getColor()); titleLabel.setFont(FontResources.MESSAGE_BOX_TITLE.getFont()); titleLabel.setLeftMargin(SPACING); - titleLabel.setTopMargin(10); + titleLabel.setTopMargin(7); } private void makeContentsBox() { @@ -185,6 +178,7 @@ public class MessageBox { contentsBox.setFont(FontResources.MESSAGE_BOX_CONTENTS.getFont()); contentsBox.setLeftMargin(SPACING); contentsBox.setTopMargin(SPACING); + contentsBox.setRightMargin(SPACING); contentsBox.setEnabled(false); contentsBox.pack(); } @@ -200,7 +194,7 @@ public class MessageBox { @Override public void handleEvent(Event event) { if (event.type == SWT.Selection) { - returnValue = SWT.OK; + returnValue = buttonType; dispose(); } } @@ -234,21 +228,6 @@ public class MessageBox { return result; } - private PaintListener painter = new PaintListener() { - @Override - public void paintControl(PaintEvent e) { - GC gc = e.gc; - Rectangle rect = ((Composite)e.widget).getClientArea(); - - // Bottom - Rectangle buttonRect = new Rectangle(0, rect.height - BOTTOM_HEIGHT, - rect.width, BOTTOM_HEIGHT); - gc.setClipping(buttonRect); - gc.setBackground(ColorResources.MESSAGE_BOX_BOTTOM_BG.getColor()); - gc.fillRectangle(buttonRect); - } - }; - public void setTitle(final String title) { if (title == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); diff --git a/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java b/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java index 1e0e19c..65d7b07 100644 --- a/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java +++ b/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java @@ -308,6 +308,7 @@ public class VMWorkerCommon implements IVMWorker { isError = false; } + @Override public void run() { // File file = new File(FilePathResources.getTizenVmsPath() @@ -365,7 +366,18 @@ public class VMWorkerCommon implements IVMWorker { } if (vmDirectory.exists()) { - result = deleteFile(vmDirectory); + if (!deleteFile(vmDirectory)) { + if (vmDirectory.exists()) { + if(!deleteFile(vmDirectory)) { + String message = Messages.getString("MessageDialog.RemoveError.0") + property.getName() //$NON-NLS-1$ + + Messages.getString("MessageDialog.RemoveError.1") //$NON-NLS-1$ + + Messages.getString("MessageDialog.RemoveError.2") //$NON-NLS-1$ + + Messages.getString("MessageDialog.RemoveError.3") //$NON-NLS-1$ + + "[ " + vmDirectory.getAbsolutePath() + " ]"; + throw new VMWorkerException(message, true); + } + } + } } } catch (VMWorkerException e) { throw e;