--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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.widgets;
+
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+public class DragController {
+
+ private Shell dialog;
+ private int posX;
+ private int posY;
+ private boolean isMouseDown;
+
+ /**
+ * This makes shell move by dragging controls.
+ * @param shell
+ * @param controls to receive drag event.
+ */
+ public static void set(Shell shell, Control... controls) {
+ DragController controller = new DragController();
+ controller.setTargetShell(shell);
+ controller.setControls(controls);
+ }
+
+
+ // set dialog (shell)
+ private void setTargetShell(Shell shell) {
+ this.dialog = shell;
+ }
+
+ // set controls that receive drag event
+ private void setControls(Control... controls) {
+ for (Control control : controls) {
+ if (control == null) {
+ continue;
+ }
+
+ control.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseDoubleClick(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ isMouseDown = true;
+ posX = e.x;
+ posY = e.y;
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ isMouseDown = false;
+ }
+ });
+
+ control.addMouseMoveListener(new MouseMoveListener() {
+ @Override
+ public void mouseMove(MouseEvent e) {
+ if (isMouseDown && dialog != null) {
+ dialog.setLocation(dialog.getLocation().x + (e.x - posX),
+ dialog.getLocation().y + (e.y - posY));
+ }
+ }
+ });
+ }
+ }
+}