import org.tizen.emulator.skin.dbi.RotationType;
import org.tizen.emulator.skin.dialog.AboutDialog;
import org.tizen.emulator.skin.dialog.DetailInfoDialog;
+import org.tizen.emulator.skin.dialog.RamdumpDialog;
import org.tizen.emulator.skin.exception.ScreenShotException;
import org.tizen.emulator.skin.image.ImageRegistry;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
ramdumpItem.addSelectionListener(new SelectionAdapter() {
@Override
- public void widgetSelected( SelectionEvent e ) {
+ public void widgetSelected(SelectionEvent e) {
logger.info("Ram dump menu is selected");
+ communicator.setRamdumpFlag(true);
communicator.sendToQEMU(SendCommand.RAM_DUMP, null);
+
+ RamdumpDialog ramdumpDialog;
+ try {
+ ramdumpDialog = new RamdumpDialog(EmulatorSkin.this.shell, communicator, config);
+ ramdumpDialog.open();
+ } catch (IOException ee) {
+ logger.log( Level.SEVERE, ee.getMessage(), ee);
+ }
}
});
/*
// Force close menu
final MenuItem forceCloseItem = new MenuItem(menu, SWT.PUSH);
- forceCloseItem.setText("Force Close");
+ forceCloseItem.setText("&Force Close");
+ //forceCloseItem.setImage(imageRegistry.getIcon(IconName.XXX));
+ forceCloseItem.addSelectionListener( new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ logger.info("Force close is selected");
+
+ //TODO : y or n popup
+ System.exit(-1);
+ }
+ });
*/
new MenuItem( menu, SWT.SEPARATOR );
private AtomicInteger heartbeatCount;
private boolean isTerminated;
private boolean isSensorDaemonStarted;
- private boolean isRamdumpCompleted;
+ private boolean isRamdump;
private ScheduledExecutorService heartbeatExecutor;
private DataTranfer screenShotDataTransfer;
}
case RAMDUMP_COMPLETE: {
logger.info("received RAMDUMP_COMPLETE from QEMU.");
- synchronized ( this ) {
- isRamdumpCompleted = true;
- }
+ setRamdumpFlag(false);
break;
}
case SENSOR_DAEMON_START: {
synchronized ( dataTransfer ) {
- if( null != dataTransfer.timer ) {
+ if ( null != dataTransfer.timer ) {
dataTransfer.timer.cancel();
}
if( null != data ) {
logger.info( "finished receiving data from QEMU." );
- }else {
+ } else {
logger.severe( "Fail to receiving data from QEMU." );
}
return isSensorDaemonStarted;
}
- public synchronized boolean isRamdumpCompleted() {
- return isRamdumpCompleted;
+ public synchronized void setRamdumpFlag(boolean flag) {
+ isRamdump = flag;
+ }
+
+ public synchronized boolean getRamdumpFlag() {
+ return isRamdump;
}
private void increaseHeartbeatCount() {
--- /dev/null
+package org.tizen.emulator.skin.dialog;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
+import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.log.SkinLogger;
+import org.tizen.emulator.skin.util.SkinUtil;
+
+public class RamdumpDialog extends SkinDialog {
+ private SocketCommunicator communicator;
+ private ImageData[] frames;
+
+ private Logger logger = SkinLogger.getSkinLogger(RamdumpDialog.class).getLogger();
+
+ public RamdumpDialog(Shell parent,
+ SocketCommunicator communicator, EmulatorConfig config) throws IOException {
+ super(parent, SkinUtil.makeEmulatorName(config),
+ SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
+ this.communicator = communicator;
+ }
+
+ @Override
+ protected Composite createArea(Composite parent) {
+ Composite composite;
+
+ try {
+ composite = createContents(parent);
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ return null;
+ }
+
+ RamdumpDialog.this.shell.addListener(SWT.Close, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ // do nothing
+ logger.info("do nothing");
+
+ if (communicator.getRamdumpFlag() == true) {
+ event.doit = false;
+ }
+ }
+ } );
+
+ return composite;
+ }
+
+ private Composite createContents(Composite parent) throws IOException {
+ Composite composite = new Composite(parent, SWT.NONE);
+
+ composite.setLayout(new GridLayout(2, false));
+
+ final Display display = Display.getDefault();
+
+ ImageLoader loader = new ImageLoader();
+
+ try {
+ frames = loader.load("indicator.gif");
+ } catch (Exception e) {
+ // TODO: register a indicator file
+ frames = null;
+ }
+
+ final Label label = new Label(composite, SWT.NONE);
+ if (frames != null) {
+ label.setImage(new Image(display, frames[0]));
+ }
+
+ Label waitMsg = new Label(composite, SWT.NONE);
+ waitMsg.setText(" Please wait...");
+
+ Thread animation = new Thread() {
+ int currentFrame = 0;
+ boolean isDisposed = false;
+
+ @Override
+ public void run() {
+ while (!isDisposed) {
+ try {
+ if (frames != null) {
+ sleep(frames[currentFrame].delayTime * 10);
+ } else {
+ sleep(500);
+ }
+ } catch (InterruptedException e) {
+ logger.warning("InterruptedException");
+ }
+
+ if (frames != null) {
+ currentFrame = (currentFrame + 1) % frames.length;
+ }
+ if (display.isDisposed()) {
+ return;
+ }
+
+ if (frames != null) {
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Image newImage = new Image(display, frames[currentFrame]);
+ label.getImage().dispose();
+ label.setImage(newImage);
+ } catch (SWTException e) {
+ isDisposed = true;
+ }
+ }
+ }); //end of asyncExec
+ }
+
+ if (communicator.getRamdumpFlag() == false) {
+ isDisposed = true;
+ }
+ }
+
+ display.syncExec(new Runnable() {
+ @Override
+ public void run() {
+ logger.info("close the Ramdump dialog");
+ RamdumpDialog.this.shell.close();
+ }
+ });
+ }
+ };
+ animation.start();
+
+ return composite;
+ }
+
+ @Override
+ protected void setShellSize() {
+ shell.setSize(240, 120);
+ }
+}