org.tizen.dynamicanalyzer.widgets.progress,
org.tizen.dynamicanalyzer.widgets.scale,
org.tizen.dynamicanalyzer.widgets.timeline,
- org.tizen.dynamicanalyzer.widgets.timer
+ org.tizen.dynamicanalyzer.widgets.timer,
+ org.tizen.dynamicanalyzer.widgets.tooltip
Import-Package: org.tizen.dynamicanalyzer.widgets.scale
import java.util.List;
import java.util.Map;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
-import org.tizen.dynamicanalyzer.widgets.helper.FontResources;
+import org.tizen.dynamicanalyzer.widgets.tooltip.DACustomTooltip;
-public abstract class DACustomComboTooltip {
- public static final int TOOLTIP_MARGIN = 10;
- public static final int TOOLTIP_HEIGHT = 18;
- public static final int TOOLTIP_TEXT_HEIGHT = 10;
- public static final int TOOLTIP_TEXT_MARGIN = 8;
- public static final int TOOLTIP_LOCATION_LEFT = 10;
- public static final int TOOLTIP_LOCATION_TOP = 20;
-
- private int height = 0;
- private int width = 0;
- private Color backgroundColor = ColorResources.CHART_TOOLTIP_BACKGROUND;
- private Color foregroundColor = ColorResources.CHART_TOOLTIP_FOREGROUND;
- private Color strokeColor = ColorResources.CHART_TOOLTIP_LINE;
- private Color fontColor = ColorResources.CHART_TOOLTIP_TEXT;
- private Font font = FontResources.TIMELINE_FONT;
-
- private Shell parent = null;
- private Shell tooltipShell = null;
- private Canvas tooltipCanvas = null;
+public abstract class DACustomComboTooltip extends DACustomTooltip {
private Map<String, List<String>> tooltipTextListMap = null;
- private String seletedItem = null;
public DACustomComboTooltip() {
// make tooltip information
makeTooltipInfo();
}
- public void openAndMove(Shell parent) {
- List<String> tooltipInfo = tooltipTextListMap.get(seletedItem);
- if (tooltipInfo != null) {
- if (null == tooltipShell) {
- open(parent);
- } else {
- move();
- }
- } else {
- close();
- }
- }
-
- public void open(Shell parent) {
- this.parent = parent;
-
- // create tooltip shell and canvas
- if (null == tooltipShell) {
- tooltipShell = new Shell(parent, SWT.NO_TRIM);
-
- // set size size and location
- settooltipShellSizeAndLocation();
- tooltipShell.setLayout(new FillLayout());
-
- tooltipCanvas = new Canvas(tooltipShell, SWT.DOUBLE_BUFFERED);
- tooltipCanvas.setBackground(backgroundColor);
- tooltipCanvas.addPaintListener(new PaintListener() {
-
- @Override
- public void paintControl(PaintEvent e) {
- drawTooltip(e.gc);
- }
- });
-
- // tooltipShell open
- tooltipShell.open();
- }
- }
-
- public void move() {
- if (null != tooltipShell) {
- // set size size and location
- settooltipShellSizeAndLocation();
- }
- }
-
- public void close() {
- if (null != tooltipShell && !tooltipShell.isDisposed()) {
- tooltipShell.dispose();
- tooltipShell = null;
- }
- }
-
public Map<String, List<String>> getTooltipTextListMap() {
if (tooltipTextListMap == null) {
tooltipTextListMap = new HashMap<String, List<String>>();
}
return tooltipTextListMap;
}
-
- public void setSeletedItem(String seletedItem) {
- this.seletedItem = seletedItem;
- }
-
- private void drawTooltip(GC gc) {
- // draw background
- Rectangle rect = tooltipCanvas.getClientArea();
- gc.setForeground(foregroundColor);
- gc.setBackground(backgroundColor);
- gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, false);
-
- // draw stroke
- gc.setForeground(strokeColor);
- gc.drawRectangle(0, 0, rect.width-1, rect.height-1);
- // draw text
- gc.setForeground(fontColor);
- gc.setFont(font);
- List<String> tooltipInfo = tooltipTextListMap.get(seletedItem);
- for (int i = 0; i < tooltipInfo.size(); i++) {
- gc.drawText(tooltipInfo.get(i), TOOLTIP_MARGIN,
- TOOLTIP_MARGIN + TOOLTIP_HEIGHT * i,
- SWT.DRAW_DELIMITER | SWT.DRAW_TRANSPARENT);
+ @Override
+ public void setTooltipMessage() {
+ tooltipMessage.clear();
+ List<String> selectedTooltipInfo = tooltipTextListMap.get(selectedItem);
+ if (null != selectedTooltipInfo) {
+ tooltipMessage.addAll(selectedTooltipInfo);
}
}
-
- private void settooltipShellSizeAndLocation() {
- generateTooltipSize();
- Point p = Display.getCurrent().getCursorLocation();
- tooltipShell.setSize(width, height);
- tooltipShell.setLocation(p.x + TOOLTIP_LOCATION_LEFT,
- p.y + TOOLTIP_LOCATION_TOP);
- }
- private void generateTooltipSize() {
- List<String> tooltipInfo = tooltipTextListMap.get(seletedItem);
- if (tooltipInfo != null) {
- // set height
- height = tooltipInfo.size() * TOOLTIP_TEXT_HEIGHT +
- (tooltipInfo.size() - 1) * TOOLTIP_TEXT_MARGIN +
- (TOOLTIP_MARGIN * 2);
-
- // set width
- GC gc = new GC(parent.getDisplay(), SWT.NONE);
- gc.setFont(font);
- int max = 0;
- for (int i = 0; i < tooltipInfo.size(); i++) {
- Point p = gc.textExtent(tooltipInfo.get(i), SWT.DRAW_MNEMONIC);
- if (p.x > max) {
- max = p.x;
- }
- }
- width = max + (TOOLTIP_MARGIN * 2);
- gc.dispose();
- }
- }
-
- public abstract boolean makeTooltipInfo();
+ public abstract boolean makeTooltipInfo();
}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.dynamicanalyzer.widgets.tooltip;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+import org.tizen.dynamicanalyzer.widgets.helper.FontResources;
+
+public abstract class DACustomTooltip {
+ public static final int TOOLTIP_MARGIN = 10;
+ public static final int TOOLTIP_HEIGHT = 18;
+ public static final int TOOLTIP_TEXT_HEIGHT = 10;
+ public static final int TOOLTIP_TEXT_MARGIN = 8;
+ public static final int TOOLTIP_LOCATION_LEFT = 10;
+ public static final int TOOLTIP_LOCATION_TOP = 20;
+
+ private int height = 0;
+ private int width = 0;
+ private Color backgroundColor = ColorResources.CHART_TOOLTIP_BACKGROUND;
+ private Color foregroundColor = ColorResources.CHART_TOOLTIP_FOREGROUND;
+ private Color strokeColor = ColorResources.CHART_TOOLTIP_LINE;
+ private Color fontColor = ColorResources.CHART_TOOLTIP_TEXT;
+ private Font font = FontResources.TIMELINE_FONT;
+
+ protected Shell parent = null;
+ protected Shell tooltipShell = null;
+ protected Canvas tooltipCanvas = null;
+ protected String selectedItem = null;
+ protected List<String> tooltipMessage = new ArrayList<String>();
+
+ public void openAndMove(Shell parent) {
+ if (!tooltipMessage.isEmpty()) {
+ if (null == tooltipShell) {
+ open(parent);
+ } else {
+ move();
+ }
+ } else {
+ close();
+ }
+ }
+
+ public void open(Shell parent) {
+ this.parent = parent;
+
+ // create tooltip shell and canvas
+ if (null == tooltipShell) {
+ tooltipShell = new Shell(parent, SWT.NO_TRIM);
+
+ // set size size and location
+ setTooltipShellSizeAndLocation();
+ tooltipShell.setLayout(new FillLayout());
+
+ tooltipCanvas = new Canvas(tooltipShell, SWT.DOUBLE_BUFFERED);
+ tooltipCanvas.setBackground(backgroundColor);
+ tooltipCanvas.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ drawTooltip(e.gc);
+ }
+ });
+
+ tooltipCanvas.addKeyListener(keyListener);
+
+ // tooltipShell open
+ tooltipShell.open();
+ }
+ }
+
+ public void move() {
+ if (null != tooltipShell) {
+ // set size size and location
+ setTooltipShellSizeAndLocation();
+ }
+ }
+
+ public void close() {
+ if (null != tooltipShell && !tooltipShell.isDisposed()) {
+ tooltipShell.dispose();
+ tooltipShell = null;
+ }
+ }
+
+ public String getSelectedItem() {
+ return selectedItem;
+ }
+
+ public void setSeletedItem(String selectedItem) {
+ this.selectedItem = selectedItem;
+
+ if (null != selectedItem) {
+ // update tooltip message
+ setTooltipMessage();
+ } else {
+ tooltipMessage.clear();
+ }
+ }
+
+ private void drawTooltip(GC gc) {
+ // draw background
+ Rectangle rect = tooltipCanvas.getClientArea();
+ gc.setForeground(foregroundColor);
+ gc.setBackground(backgroundColor);
+ gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, false);
+
+ // draw stroke
+ gc.setForeground(strokeColor);
+ gc.drawRectangle(0, 0, rect.width-1, rect.height-1);
+
+ // draw text
+ gc.setForeground(fontColor);
+ gc.setFont(font);
+ for (int i = 0; i < tooltipMessage.size(); i++) {
+ gc.drawText(tooltipMessage.get(i), TOOLTIP_MARGIN,
+ TOOLTIP_MARGIN + TOOLTIP_HEIGHT * i,
+ SWT.DRAW_DELIMITER | SWT.DRAW_TRANSPARENT);
+ }
+
+ }
+
+ private void setTooltipShellSizeAndLocation() {
+ generateTooltipSize();
+ Point p = Display.getCurrent().getCursorLocation();
+ tooltipShell.setSize(width, height);
+ tooltipShell.setLocation(p.x + TOOLTIP_LOCATION_LEFT,
+ p.y + TOOLTIP_LOCATION_TOP);
+ }
+
+ private void generateTooltipSize() {
+ if (!tooltipMessage.isEmpty()) {
+ // set height
+ height = tooltipMessage.size() * TOOLTIP_TEXT_HEIGHT +
+ (tooltipMessage.size() - 1) * TOOLTIP_TEXT_MARGIN +
+ (TOOLTIP_MARGIN * 2);
+
+ // set width
+ GC gc = new GC(parent.getDisplay(), SWT.NONE);
+ gc.setFont(font);
+ int max = 0;
+ for (int i = 0; i < tooltipMessage.size(); i++) {
+ Point p = gc.textExtent(tooltipMessage.get(i), SWT.DRAW_MNEMONIC);
+ if (p.x > max) {
+ max = p.x;
+ }
+ }
+ width = max + (TOOLTIP_MARGIN * 2);
+ gc.dispose();
+ }
+ }
+
+ private KeyListener keyListener = new KeyListener() {
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ // TODO Auto-generated method stub
+ }
+ };
+
+ public abstract void setTooltipMessage();
+}
public static final String CMD_UPLOAD_FILE_LIST = "du -b " + //$NON-NLS-1$
PathConstants.DA_REMOTE_PATH + AnalyzerConstants.READELF_BIN;
public static final String CMD_PROCESS_NAME = "ps -p %d -o comm=rcu_sched";
+ public static final String CMD_BINARY_DETAIL_INFO = "rpm -qf";
// via da_command
public static final String DACOMMAND_KILL_MANAGER = "da killmanager";
private static List<String> checkVersionResult = new ArrayList<String>();
private static boolean isRunning = false;
-
+ private static String binaryDetailInfo = null;
+
public static void init(List<DeviceInfo> devices) {
for (DeviceInfo device : devices) {
HostResult result = device.initCommunicator();
return false;
}
}
+
+ public static String getBinaryDetailInfomationCommand(String path) {
+ CommunicatorUtils.execShellCommand(AnalyzerShellCommands.CMD_BINARY_DETAIL_INFO
+ + CommonConstants.SPACE + path, new MultiLineReceiver() {
+
+ @Override
+ public void processNewLines(String[] lines) {
+ if (null != lines[0]) {
+ binaryDetailInfo = lines[0];
+ }
+ }
+ });
+
+ return binaryDetailInfo;
+ }
}
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.dynamicanalyzer.communicator.DACommunicator;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.swap.platform.ui.ExplorerUtil;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
import org.tizen.dynamicanalyzer.widgets.da.base.DAButton;
import org.tizen.dynamicanalyzer.widgets.da.base.DAText;
+import org.tizen.dynamicanalyzer.widgets.tooltip.DACustomTooltip;
import org.tizen.sdblib.IDevice;
import org.tizen.sdblib.service.FileEntry;
import org.tizen.sdblib.service.FileEntryType;
inputText.getControl().setSelection(0, length);
}
};
+
+ // tooltip
+ private DACustomTooltip tooltip = new DACustomTooltip() {
+
+ @Override
+ public void setTooltipMessage() {
+ tooltipMessage.clear();
+ String binaryDetailInfo = DACommunicator.getBinaryDetailInfomationCommand(getSelectedItem());
+ if ((null != binaryDetailInfo) && (!binaryDetailInfo.isEmpty())) {
+ tooltipMessage.add(binaryDetailInfo);
+ }
+ }
+ };
+
+ private Listener tableTooltipListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+
+ // tooltip open and move
+ if (event.type == SWT.MouseEnter || event.type == SWT.MouseMove) {
+ // get table item
+ GridItem item = table.getItem(new Point(event.x, event.y));
+ if (null == item) {
+ return;
+ }
+
+ // check folder and file
+ FileEntry file = (FileEntry) item.getData(ExplorerUtil.DATA_FIEL_KEY);
+ if (file.isDirectory() || file.isRoot()) {
+ tooltip.setSeletedItem(null);
+ tooltip.close();
+ } else {
+ tooltip.setSeletedItem(file.getFullPath());
+ tooltip.openAndMove(table.getShell());
+ }
+ }
+
+ // tooltip close
+ if (event.type == SWT.MouseExit) {
+ tooltip.close();
+ }
+ }
+ };
public DeviceExplorer(Composite parent) {
super(parent, SWT.NONE);
table.addSelectionListener(tableSelectionListener);
table.addMouseListener(tableMouseListener);
+ setTableToolTipListener(); // set table tooltip listener
}
+ public void setTableToolTipListener() {
+ table.addListener(SWT.MouseEnter, tableTooltipListener);
+ table.addListener(SWT.MouseExit, tableTooltipListener);
+ table.addListener(SWT.MouseMove, tableTooltipListener);
+ }
+
public void setColumns() {
GridColumn fileColumn = new GridColumn(table, SWT.NONE);
fileColumn.setCellRenderer(new DAFileExplorerTableRenderer());
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
+import org.tizen.dynamicanalyzer.communicator.DACommunicator;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
private DACustomButton removeButton = null;
private int index = -1;
+
+ private String binaryName = null;
private DACustomButtonClickEventListener findDebugButtonListener = new DACustomButtonClickEventListener() {
index = i;
}
- public void setBinaryText(String text) {
- binaryNameLabel.setText(text);
+ public void setBinaryName(String binaryName) {
+ this.binaryName = binaryName;
+
+ String binaryDetailInfo = DACommunicator.getBinaryDetailInfomationCommand(binaryName);
+ if ((null != binaryDetailInfo) && (!binaryDetailInfo.isEmpty())) {
+ binaryNameLabel.setText(binaryName + CommonConstants.SPACE +
+ CommonConstants.OPEN_BRACKET + binaryDetailInfo + CommonConstants.CLOSE_BRACKET);
+ } else {
+ binaryNameLabel.setText(binaryName);
+ }
}
- public String getBinaryText() {
- return binaryNameLabel.getText();
+ public String getBinaryName() {
+ return binaryName;
}
public void setDebugText(String text) {
@Override
public void handleClickEvent(DACustomButton button) {
- String binaryPath = ((InputRow) button.getParent()).getBinaryText();
+ String binaryPath = ((InputRow) button.getParent()).getBinaryName();
removeInputRow(binaryPath);
Composite inputComposite = button.getParent().getParent();
for (int i = 0; i < binarySettings.size(); i++) {
InputRow inputRow = new InputRow(inputComposite, removeButtonListener);
- inputRow.setBinaryText(binarySettings.get(i).getBinaryPath());
+ inputRow.setBinaryName(binarySettings.get(i).getBinaryPath());
inputRow.setDebugText(binarySettings.get(i).getDebugRpmPath());
inputRow.setSourceText(binarySettings.get(i).getUserSourceDir());
inputRowList.add(inputRow);
for (int i = 0; i < inputRowList.size(); i++) {
BinarySettingManager.getInstance().removeBinarySettingData(
- inputRowList.get(i).getBinaryText());
+ inputRowList.get(i).getBinaryName());
inputRowList.get(i).dispose();
}
inputRowList.clear();
public void doApply() {
// dirty check and update path
for (InputRow inputRow : inputRowList) {
- String binary = inputRow.getBinaryText();
+ String binary = inputRow.getBinaryName();
String debug = inputRow.getDebugText();
String source = inputRow.getSourceText();
BinarySettingData binData = BinarySettingManager.getInstance().getBinarySetting(binary);
clearLayout();
for (int i = 0; i < binData.size(); i++) {
InputRow inputRow = new InputRow(inputComposite, removeButtonListener);
- inputRow.setBinaryText(binData.get(i).getBinaryPath());
+ inputRow.setBinaryName(binData.get(i).getBinaryPath());
// String debug = binData.get(i).getDebugFilePath();
String debug = binData.get(i).getDebugRpmPath();
if (null != debug && !debug.isEmpty()) {
next = null;
}
- if (cur.getBinaryText().equals(path)) {
+ if (cur.getBinaryName().equals(path)) {
// modify layout of next input row
if (next != null) {
FormData nextData = (FormData) next.getLayoutData();
@Override
public void handleClickEvent(DACustomButton button) {
- String binaryPath = ((InputRow) button.getParent()).getBinaryText();
+ String binaryPath = ((InputRow) button.getParent()).getBinaryName();
removeInputRow(binaryPath);
Composite inputComposite = button.getParent().getParent();
for (int i = 0; i < binarySettings.size(); i++) {
InputRow inputRow = new InputRow(inputComposite, removeButtonListener);
- inputRow.setBinaryText(binarySettings.get(i).getBinaryPath());
+ inputRow.setBinaryName(binarySettings.get(i).getBinaryPath());
inputRow.setDebugText(binarySettings.get(i).getDebugRpmPath());
inputRow.setSourceText(binarySettings.get(i).getUserSourceDir());
inputRowList.add(inputRow);
for (int i = 0; i < inputRowList.size(); i++) {
BinarySettingManager.getInstance().removeBinarySettingData(
- inputRowList.get(i).getBinaryText());
+ inputRowList.get(i).getBinaryName());
inputRowList.get(i).dispose();
}
inputRowList.clear();
public void doApply() {
// dirty check and update path
for (InputRow inputRow : inputRowList) {
- String binary = inputRow.getBinaryText();
+ String binary = inputRow.getBinaryName();
String debug = inputRow.getDebugText();
String source = inputRow.getSourceText();
BinarySettingData binData = BinarySettingManager.getInstance().getBinarySetting(binary);
clearLayout();
for (int i = 0; i < binData.size(); i++) {
InputRow inputRow = new InputRow(inputComposite, removeButtonListener);
- inputRow.setBinaryText(binData.get(i).getBinaryPath());
+ inputRow.setBinaryName(binData.get(i).getBinaryPath());
// String debug = binData.get(i).getDebugFilePath();
String debug = binData.get(i).getDebugRpmPath();
if (null != debug && !debug.isEmpty()) {
next = null;
}
- if (cur.getBinaryText().equals(path)) {
+ if (cur.getBinaryName().equals(path)) {
// modify layout of next input row
if (next != null) {
FormData nextData = (FormData) next.getLayoutData();