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
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);
}
}
}
}
- 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);
}
popup.redraw();
}
+
+ // tooltip close
+ if (event.type == SWT.MouseEnter) {
+ if (null != tooltip) {
+ tooltip.close();
+ }
+ }
}
};
}
popup.redraw();
}
+
+ // tooltip close
+ if (event.type == SWT.MouseEnter) {
+ if (null != tooltip) {
+ tooltip.close();
+ }
+ }
}
};
@Override
public void run() {
if (null != childShell && !childShell.isDisposed()) {
+ // tooltip close
+ if (null != tooltip) {
+ tooltip.close();
+ }
+
childShell.close();
childShell = null;
} else {
--- /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.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<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);
+ }
+ }
+
+ 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();
+}
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;
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;
}
}
- private void addToAppCombo(List<PackageInfo> pkglist) {
+ private void addToAppCombo(final List<PackageInfo> pkglist) {
appCombo.initCombo();
if (pkglist != null && pkglist.size() > 0) {
} else {
appCombo.add(CommonConstants.EMPTY);
}
+
+ // set tooltip
+ appCombo.setTooltip(new DACustomComboTooltip() {
+
+ @Override
+ public boolean makeTooltipInfo() {
+ Map<String, List<String>> 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<String> info = new ArrayList<String>();
+ 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