import org.eclipse.swt.layout.FormLayout;
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.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.FontResources;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
import org.tizen.emulator.manager.ui.dialog.AboutDialog;
+import org.tizen.emulator.manager.ui.renewal.widgets.Hyperlink;
import org.tizen.emulator.manager.ui.renewal.widgets.ImageButton;
-import org.tizen.emulator.manager.ui.table.FontResources;
public abstract class AbstractTableViewer {
private static final int BUTTON_MENU_WIDTH = 20;
private static ImageButton infoButton;
private List<ImageButton> buttonMenuList = new ArrayList<ImageButton>();
- private List<Label> linkMenuList = new ArrayList<Label>();
+ private List<Hyperlink> linkMenuList = new ArrayList<Hyperlink>();
public AbstractTableViewer(Shell shell, String key) {
this.key = key;
}
}
- public void addLinkMenu(Label menu) {
+ public void addLinkMenu(Hyperlink menu) {
linkMenuList.add(menu);
}
if (i == 0) {
data.top = new FormAttachment (0, 5);
} else {
- data.top = new FormAttachment(linkMenuList.get(i-1), 5);
+ data.top = new FormAttachment(linkMenuList.get(i - 1), 5);
}
data.right = new FormAttachment(100, -8);
- linkMenuList.get(i).setLayoutData(data);
- linkMenuList.get(i).setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND));
- linkMenuList.get(i).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- linkMenuList.get(i).setFont(FontResources.setSizeDefaultFont(10));
+ Hyperlink menu = linkMenuList.get(i);
+ menu.setLayoutData(data);
+ menu.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND));
+ menu.setForeground(ColorResources.LINK_MENU_FONT.getColor());
+ menu.setFont(FontResources.TABLE_VIEWER_LINK_MENU.getFont());
}
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.MainDialog;
+import org.tizen.emulator.manager.ui.renewal.widgets.Hyperlink;
import org.tizen.emulator.manager.ui.renewal.widgets.ImageButton;
public class VMListTableViewer extends AbstractTableViewer {
- Label templateList;
- Label baseImageList;
+ Hyperlink templateList;
+ Hyperlink baseImageList;
ImageButton refreshButton;
VMListTable table;
@Override
void setLinkerMenu() {
// add linker
- templateList = new Label(getTopComp(), SWT.None);
+ templateList = new Hyperlink(getTopComp(), SWT.None);
templateList.setText("Templates");
- // templateList.addSelectionListener(new SelectionListener(){
- //
- // @Override
- // public void widgetDefaultSelected(SelectionEvent arg0) {
- // // TODO Auto-generated method stub
- // }
- //
- // @Override
- // public void widgetSelected(SelectionEvent arg0) {
- // // TODO Auto-generated method stub
- // }
- // });
- baseImageList = new Label(getTopComp(), SWT.None);
+ templateList.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Selection) {
+ MessageBox dialog = new MessageBox(MainDialog.getShell());
+ dialog.setMessage("Click Templates menu");
+ dialog.open();
+ }
+ }
+
+ });
+
+ baseImageList = new Hyperlink(getTopComp(), SWT.None);
baseImageList.setText("Base Images");
+ baseImageList.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Selection) {
+ if (event.type == SWT.Selection) {
+ MessageBox dialog = new MessageBox(MainDialog.getShell());
+ dialog.setMessage("Click BaseImages menu");
+ dialog.open();
+ }
+ }
+ }
+ });
addLinkMenu(templateList);
addLinkMenu(baseImageList);
--- /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.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+
+public class Hyperlink extends Canvas {
+ private String text = "";
+ private boolean underlined = true;
+ private Color focusBoxColor;
+
+ public Hyperlink(Composite parent, int style) {
+ super(parent, checkStyle(style));
+ this.addPaintListener(paintListener);
+ this.addMouseListener(mouseListener);
+ this.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+ focusBoxColor = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
+ }
+
+ private static int checkStyle(int style) {
+ return style | SWT.NO_BACKGROUND;
+ }
+
+ public String getText() {
+ checkWidget();
+ return text;
+ }
+
+ public void setText(String text) {
+ checkWidget();
+ if (text == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ this.text = text;
+ }
+
+ public boolean isUnderlined() {
+ checkWidget();
+ return underlined;
+ }
+
+ public void setUnderlined(boolean underlined) {
+ checkWidget();
+ this.underlined = underlined;
+ }
+
+ @Override
+ public Point computeSize(int wHint, int hHint, boolean changes) {
+ checkWidget();
+
+ if (wHint != SWT.DEFAULT && wHint < 0) {
+ wHint = 0;
+ }
+
+ if (hHint != SWT.DEFAULT && hHint < 0) {
+ hHint = 0;
+ }
+
+ Point size = new Point(0, 0);
+ Point textSize = getTextSize();
+ size.x = Math.max(wHint, textSize.x + 2);
+ if (underlined) {
+ textSize.y += 1;
+ }
+ size.y = Math.max(hHint, textSize.y);
+
+ return size;
+ }
+
+ private Point getTextSize() {
+ Point size = new Point(0, 0);
+ GC gc = new GC(this);
+ if (text != null && text.length() > 0) {
+ Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ size.x += p.x;
+ size.y = Math.max(size.y, p.y);
+ } else {
+ size.y = Math.max(size.y, gc.getFontMetrics().getHeight());
+ }
+
+ gc.dispose();
+ return size;
+ }
+
+ private PaintListener paintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ Point extent = getTextSize();
+
+ GC gc = e.gc;
+
+ if ((getStyle() & SWT.NO_BACKGROUND) != 0) {
+ Rectangle rect = ((Hyperlink)e.widget).getClientArea();
+ gc.setBackground(getBackground());
+ gc.fillRectangle(rect);
+ }
+
+ gc.setForeground(focusBoxColor);
+ if (isMouseDown) {
+ gc.setLineStyle(SWT.LINE_DOT);
+ gc.drawRectangle(0, 0, extent.x, extent.y - 2);
+ }
+
+ gc.setForeground(getForeground());
+ gc.drawText(text, 0, 0, true);
+
+ if (underlined) {
+ gc.setLineStyle(SWT.LINE_SOLID);
+ gc.drawLine(0, extent.y - 2, extent.x, extent.y - 2);
+ }
+ }
+ };
+
+ private boolean isMouseDown = false;
+ private MouseListener mouseListener = new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ isMouseDown = false;
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ isMouseDown = true;
+ redraw();
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ if (isMouseDown) {
+ isMouseDown = false;
+ Event event = new Event();
+ event.widget = e.widget;
+ event.type = SWT.Selection;
+ e.widget.notifyListeners(SWT.Selection, event);
+ }
+ }
+ };
+}