From: heeyoung Date: Thu, 30 Oct 2014 10:30:18 +0000 (+0900) Subject: Setting : add application detail information tooltip X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F29614%2F1;p=sdk%2Ftools%2Fdynamic-analyzer.git Setting : add application detail information tooltip Change-Id: I4d0d08a47de694cd9aff46bd1c0e6e90516bad2a Signed-off-by: heeyoung --- diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomCombo.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomCombo.java index 3ea7863..2fa5b6e 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomCombo.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomCombo.java @@ -94,6 +94,7 @@ public class DACustomCombo extends Canvas { private Font itemFont = null; private Color itemFontColor = null; private IDACustomComboPopupRenderer popupRenderer = new DACustomComboPopupRenderer(); + private DACustomComboTooltip tooltip = null; // combo button private int state = STATE_NORMAL; // 0 normal 1 hover 2 push 3 disable @@ -527,7 +528,7 @@ public class DACustomCombo extends Canvas { if (event.type == SWT.MouseExit) { Canvas canvas = (Canvas) event.widget; Rectangle rect = canvas.getClientArea(); - if (event.x < rect.x || event.x > rect.x + rect.width) { + if (event.x < rect.x || event.x >= rect.x + rect.width) { closePopup(CLOSE_WAITING_TIME); } } @@ -539,11 +540,19 @@ public class DACustomCombo extends Canvas { } } - if (event.type == SWT.FocusOut) { - closePopup(CLOSE_WAITING_TIME); + // tooltip open and move + if (event.type == SWT.MouseEnter || event.type == SWT.MouseMove) { + if (null != tooltip) { + tooltip.setSeletedItem(items.get(tmpItemIndex + tmpSelection)); + tooltip.openAndMove(childShell); + } } } }; + + public void setTooltip(DACustomComboTooltip tooltip) { + this.tooltip = tooltip; + } public void setEnabled(boolean enabled) { super.setEnabled(enabled); @@ -724,6 +733,13 @@ public class DACustomCombo extends Canvas { } popup.redraw(); } + + // tooltip close + if (event.type == SWT.MouseEnter) { + if (null != tooltip) { + tooltip.close(); + } + } } }; @@ -778,6 +794,13 @@ public class DACustomCombo extends Canvas { } popup.redraw(); } + + // tooltip close + if (event.type == SWT.MouseEnter) { + if (null != tooltip) { + tooltip.close(); + } + } } }; @@ -908,6 +931,11 @@ public class DACustomCombo extends Canvas { @Override public void run() { if (null != childShell && !childShell.isDisposed()) { + // tooltip close + if (null != tooltip) { + tooltip.close(); + } + childShell.close(); childShell = null; } else { diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboTooltip.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboTooltip.java new file mode 100644 index 0000000..2a809d0 --- /dev/null +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboTooltip.java @@ -0,0 +1,193 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Heeyoung Hwang + * Juyoung Kim + * + * 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.combo; + +import java.util.HashMap; +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; + +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; + private Map> tooltipTextListMap = null; + private String seletedItem = null; + + public DACustomComboTooltip() { + // make tooltip information + makeTooltipInfo(); + } + + public void openAndMove(Shell parent) { + List 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> getTooltipTextListMap() { + if (tooltipTextListMap == null) { + tooltipTextListMap = new HashMap>(); + } + 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 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); + } + } + + 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 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(); +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.java index 06bf931..200af08 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.java @@ -209,6 +209,12 @@ public class AnalyzerLabels extends NLS { public static String TIME_MS; + public static String DETAIL_INFORMATION_PACKAGE_NAME; + public static String DETAIL_INFORMATION_PACKAGE_VERSION; + public static String DETAIL_INFORMATION_PACKAGE_INSTALL_TIME; + public static String DETAIL_INFORMATION_APPLICATION_NAME; + public static String DETAIL_INFORMATION_APPLICATION_EXEC_PATH; + static { NLS.initializeMessages(BUNDLE_NAME, AnalyzerLabels.class); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.properties b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.properties index 0b27886..32d98b7 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.properties +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.properties @@ -174,3 +174,9 @@ HEAP_MEMORY_WARNING_PRE=The trace has been stoped automatically for out of heap HEAP_MEMORY_WARNING_POST=/dynamic-analyzer.ini. TIME_MS = ms + +DETAIL_INFORMATION_PACKAGE_NAME=Package Name : +DETAIL_INFORMATION_PACKAGE_VERSION=Package Version : +DETAIL_INFORMATION_PACKAGE_INSTALL_TIME=Package Installed Time : +DETAIL_INFORMATION_APPLICATION_NAME=Application Name : +DETAIL_INFORMATION_APPLICATION_EXEC_PATH=Application Exec Path : 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 a62167d..33d57f5 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 @@ -27,9 +27,11 @@ package org.tizen.dynamicanalyzer.ui.toolbar; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -78,6 +80,7 @@ import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer; import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomToggleButton; import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo; import org.tizen.dynamicanalyzer.widgets.combo.DACustomComboSelectionListener; +import org.tizen.dynamicanalyzer.widgets.combo.DACustomComboTooltip; import org.tizen.dynamicanalyzer.widgets.da.base.DADialog; import org.tizen.dynamicanalyzer.widgets.timer.TimerClock; import org.tizen.sdblib.IDevice; @@ -942,7 +945,7 @@ public class ToolbarArea { } } - private void addToAppCombo(List pkglist) { + private void addToAppCombo(final List pkglist) { appCombo.initCombo(); if (pkglist != null && pkglist.size() > 0) { @@ -953,6 +956,37 @@ public class ToolbarArea { } else { appCombo.add(CommonConstants.EMPTY); } + + // set tooltip + appCombo.setTooltip(new DACustomComboTooltip() { + + @Override + public boolean makeTooltipInfo() { + Map> map = getTooltipTextListMap(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + for (int i = 0; i < pkglist.size(); i++) { + AppInfo app = pkglist.get(i).getMainApp(); + if (AnalyzerConstants.RUNNING_PROCESS_LABEL.equals(app.getLabel()) || + AnalyzerConstants.COMMON_EXECUTABLE_LABEL.equals(app.getLabel()) || + AnalyzerConstants.WITHOUT_EXECUTABLE_LABEL.equals(app.getLabel())) { + continue; + } + + // set information + List info = new ArrayList(); + info.add(AnalyzerLabels.DETAIL_INFORMATION_PACKAGE_NAME + pkglist.get(i).getPackageId()); + info.add(AnalyzerLabels.DETAIL_INFORMATION_PACKAGE_VERSION + pkglist.get(i).getVersion()); + info.add(AnalyzerLabels.DETAIL_INFORMATION_PACKAGE_INSTALL_TIME + + dateFormat.format(new Date(pkglist.get(i).getInstallTime() * 1000))); + info.add(AnalyzerLabels.DETAIL_INFORMATION_APPLICATION_NAME + app.getLabel()); + info.add(AnalyzerLabels.DETAIL_INFORMATION_APPLICATION_EXEC_PATH + app.getExecPath()); + + map.put(app.getLabel(), info); + } + return true; + } + }); } // return false if target is not connected