From 05d0978bf781fe4572146ff4620a29e5cc02b99e Mon Sep 17 00:00:00 2001 From: jooyoul_lee Date: Mon, 11 Nov 2013 17:43:32 +0900 Subject: [PATCH] [Title] take screenshot added [Desc.] [Issue] --- .../dynamicanalyzer/common/AnalyzerConstants.java | 1 + .../communicator/DACommunicator.java | 8 +++++ .../swap/communicator/Communicator30.java | 35 +++++++++++++++++++ .../platform/ui/DeviceExplorer/DeviceExplorer.java | 27 +++++++++------ .../platform/ui/FileExplorer/DAFileExplorer.java | 29 ++++++++++------ .../dynamicanalyzer/ui/toolbar/ToolbarArea.java | 40 ++++++++++++++++------ 6 files changed, 110 insertions(+), 30 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java index 05573c7..3f50207 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java @@ -313,6 +313,7 @@ public class AnalyzerConstants { public final static int MSG_TARGET_INFO = 0x0007; public final static int MSG_SWAP_INST_ADD = 0x0008; public final static int MSG_SWAP_INST_REMOVE = 0x0009; + public final static int MSG_GET_SCREENSHOT = 0x0010; public final static int MSG_KEEP_ALIVE_ACK = 0x1001; public final static int MSG_START_ACK = 0x1002; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java index 6b53fff..61e7b7a 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java @@ -691,6 +691,14 @@ public class DACommunicator { return null; } + public static HostResult sendScreenShotMessage() { + if (isSWAPVersion()) { + return ((Communicator30) currentDevice.getCommunicator()) + .sendScreenShotRequest(); + } + return null; + } + public static HostResult sendKeepAliveMessage(DeviceInfo device) { return device.getCommunicator().sendKeepAliveMessage(device); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java index da0934d..6e3ad63 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java @@ -805,6 +805,41 @@ public class Communicator30 extends BaseCommunicator { } } + public HostResult sendScreenShotRequest() { + byte[] msg = ByteUtils.getByte(AnalyzerConstants.MSG_GET_SCREENSHOT, 0, + 0); + HostResult result = HostResult.SUCCESS; + Socket controlSock = DACommunicator.getSelectedDevice() + .getControlSock(); + + try { + if (null != controlSock && !controlSock.isClosed()) { + controlSock.getOutputStream().write(msg); + } else { + System.out.println("control socket is closed"); + result = HostResult.ERR_CONTROL_SOCKET_CONNECTION_CLOSED; + } + } catch (SocketException e) { + result = HostResult.ERR_EXCEPTION_OCCURRED; + result.setMessage(e.getMessage()); + e.printStackTrace(); + return result; + } catch (SocketTimeoutException e) { + result = HostResult.ERR_EXCEPTION_OCCURRED; + result.setMessage(e.getMessage()); + e.printStackTrace(); + return result; + } catch (IOException e) { + result = HostResult.ERR_EXCEPTION_OCCURRED; + result.setMessage(e.getMessage()); + e.printStackTrace(); + return result; + } finally { + blocked = false; + } + return result; + } + public HostResult sendSWAPMessage(int messageId, List settings) { HashMap targetBinInfoMap = BinarySettingManager diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/DeviceExplorer/DeviceExplorer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/DeviceExplorer/DeviceExplorer.java index 88f07d1..7795943 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/DeviceExplorer/DeviceExplorer.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/DeviceExplorer/DeviceExplorer.java @@ -4,6 +4,8 @@ import org.eclipse.nebula.widgets.grid.Grid; import org.eclipse.nebula.widgets.grid.GridColumn; import org.eclipse.nebula.widgets.grid.GridItem; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.SelectionEvent; @@ -116,17 +118,21 @@ public class DeviceExplorer extends Composite { inputText.setBackground(ColorResources.RED); info.setText("Invalid path"); } + } + }; + + private KeyListener inputKeyListener = new KeyListener() { + + @Override + public void keyReleased(KeyEvent e) { + if (e.keyCode == 13) { + goButtonClickListener.handleClickEvent(null); + inputText.setSelection(inputText.getText().length()); + } + } - // FileEntry file = device.getFileEntry(path); - // if (null == file || (!file.isDirectory() && !file.isRoot())) { - // System.out.println("target path is invalid"); - // inputText.setBackground(ColorResources.RED); - // info.setText("Invalid path"); - // return; - // } - // inputText.setBackground(ColorResources.WHITE); - // current = file; - // updateData(); + @Override + public void keyPressed(KeyEvent e) { } }; @@ -142,6 +148,7 @@ public class DeviceExplorer extends Composite { data.right = new FormAttachment(100, -80); data.height = 18; inputText.setLayoutData(data); + inputText.addKeyListener(inputKeyListener); goButton = new DAButton(this, SWT.NONE); data = new FormData(); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/FileExplorer/DAFileExplorer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/FileExplorer/DAFileExplorer.java index 1dc7887..3b6929d 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/FileExplorer/DAFileExplorer.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/FileExplorer/DAFileExplorer.java @@ -6,6 +6,8 @@ import org.eclipse.nebula.widgets.grid.Grid; import org.eclipse.nebula.widgets.grid.GridColumn; import org.eclipse.nebula.widgets.grid.GridItem; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.SelectionEvent; @@ -113,16 +115,21 @@ public class DAFileExplorer extends Composite { inputText.setBackground(ColorResources.RED); info.setText("Invalid path"); } - // File file = new File(path); - // if (!file.exists() || !file.isDirectory()) { - // System.out.println("target path is invalid"); - // inputText.setBackground(ColorResources.RED); - // info.setText("Invalid path"); - // return; - // } - // inputText.setBackground(ColorResources.WHITE); - // current = file; - // updateData(); + } + }; + + private KeyListener inputKeyListener = new KeyListener() { + + @Override + public void keyReleased(KeyEvent e) { + if (e.keyCode == 13) { + goButtonClickListener.handleClickEvent(null); + inputText.setSelection(inputText.getText().length()); + } + } + + @Override + public void keyPressed(KeyEvent e) { } }; @@ -138,6 +145,7 @@ public class DAFileExplorer extends Composite { data.right = new FormAttachment(100, -80); data.height = 18; inputText.setLayoutData(data); + inputText.addKeyListener(inputKeyListener); goButton = new DAButton(this, SWT.NONE); data = new FormData(); @@ -304,4 +312,5 @@ public class DAFileExplorer extends Composite { } return result; } + } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java index 1abec76..fbec8ff 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java @@ -86,6 +86,7 @@ public class ToolbarArea { public static final int ABOUT_BUTTON = 5; public static final int CONFIG_BUTTON = 6; public static final int SETTING_BUTTON = 7; + public static final int SCREENSHOT_BUTTON = 8; String selectedDevice = null; PackageInfo selectedApp = null; @@ -109,6 +110,7 @@ public class ToolbarArea { private DACustomButton openTraceButton; private DACustomButton replayButton; private DACustomButton configButton; + private DACustomButton screenshotButton; private DACustomButton aboutButton; @@ -414,6 +416,15 @@ public class ToolbarArea { } }); + screenshotButton + .addClickListener(new DACustomButtonClickEventListener() { + + @Override + public void handleClickEvent(DACustomButton button) { + DACommunicator.sendScreenShotMessage(); + } + }); + aboutButton.addClickListener(new DACustomButtonClickEventListener() { @Override @@ -595,6 +606,15 @@ public class ToolbarArea { configButton.setToolTipText(ShortCutManager.COOLBAR_AREA_SETTING); buttons.put(CONFIG_BUTTON, configButton); + // Creates screenshot button + screenshotButton = new DACustomButton(parent, + ImageResources.SCREEN_SHOT_NORMAL, + ImageResources.SCREEN_SHOT_PUSH, + ImageResources.SCREEN_SHOT_HOVER, + ImageResources.SCREEN_SHOT_DISABLE); + screenshotButton.setToolTipText("Capture screen"); + buttons.put(SCREENSHOT_BUTTON, screenshotButton); + // Creates about button. aboutButton = new DACustomButton(parent, ImageResources.ABOUT, ImageResources.ABOUT_PUSH, ImageResources.ABOUT_HOVER, @@ -676,16 +696,16 @@ public class ToolbarArea { data.height = 30; configButton.setLayoutData(data); -// data = new FormData(); -// data.top = new FormAttachment(0, 4); -// data.right = new FormAttachment(configButton, 0); -// data.width = 34; // 31 -// data.height = 30; -// binarySettingsButton.setLayoutData(data); + data = new FormData(); + data.top = new FormAttachment(0, 4); + data.right = new FormAttachment(configButton, 0); + data.width = 34; // 31 + data.height = 30; + screenshotButton.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(0, 4); - data.right = new FormAttachment(configButton, -5); + data.right = new FormAttachment(screenshotButton, -5); data.width = 32; data.height = 30; viewSourceButton.setLayoutData(data); @@ -1020,9 +1040,9 @@ public class ToolbarArea { setRepalyButtonEnable(enabled); } -// public void setBinarySettingsButtonEnablement(boolean enabled) { -// binarySettingsButton.setButtonEnabled(enabled); -// } + // public void setBinarySettingsButtonEnablement(boolean enabled) { + // binarySettingsButton.setButtonEnabled(enabled); + // } public void startTimer() { timerClock.start(); -- 2.7.4