From 38428a56860080bdb66dcebaf0d37be5a4c8381a Mon Sep 17 00:00:00 2001 From: "jy.exe.lee" Date: Thu, 5 Jul 2012 17:17:05 +0900 Subject: [PATCH] [Title] Profile table bug fix and custom widget fix [Type] bug fix [Module] DynamicAnalyzer [Priority] major [CQ#] [Redmine#] 5597 [Problem] [Cause] [Solution] [TestCase] --- .../listeners/DAButtonClickEventListener.java | 45 -- .../listeners/DAComboSelectionListener.java | 25 - .../model/FunctionUsageProfilingData.java | 22 +- .../tizen/dynamicanalyzer/nl/SummaryLables.java | 2 +- .../dynamicanalyzer/nl/SummaryLables.properties | 2 +- .../TitleComboPopupRenderer.java | 2 +- .../combo => renderers}/TitleComboRenderer.java | 12 +- .../dynamicanalyzer/ui/views/CoolbarArea.java | 89 ++-- .../summaryPage/FunctionUsageProfilingView.java | 6 +- .../dynamicanalyzer/ui/widgets/AboutDialog.java | 3 - .../dynamicanalyzer/ui/widgets/LicenseDialog.java | 2 - .../ui/widgets/button/DAButton.java | 296 ----------- .../ui/widgets/button/DAButtonAction.java | 9 - .../ui/widgets/button/DAButtonEvent.java | 7 - .../ui/widgets/button/DAButtonRenderer.java | 10 - .../ui/widgets/button/DAToggleButton.java | 22 - .../ui/widgets/button/DefaultButtonRenderer.java | 137 ----- .../ui/widgets/combo/ComboButtonAction.java | 41 -- .../dynamicanalyzer/ui/widgets/combo/DACombo.java | 555 --------------------- .../ui/widgets/combo/DAComboPopupRenderer.java | 19 - .../ui/widgets/combo/DAComboRenderer.java | 11 - .../widgets/combo/DefaultDAComboPopupRenderer.java | 50 -- .../ui/widgets/combo/DefaultDAComboRenderer.java | 50 -- .../utils/FunctionUsageProfiler.java | 15 +- 24 files changed, 71 insertions(+), 1361 deletions(-) delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/DAButtonClickEventListener.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/DAComboSelectionListener.java rename org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/{widgets/combo => renderers}/TitleComboPopupRenderer.java (97%) rename org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/{widgets/combo => renderers}/TitleComboRenderer.java (88%) delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButton.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonAction.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonEvent.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonRenderer.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAToggleButton.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DefaultButtonRenderer.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/ComboButtonAction.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DACombo.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DAComboPopupRenderer.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DAComboRenderer.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DefaultDAComboPopupRenderer.java delete mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DefaultDAComboRenderer.java diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/DAButtonClickEventListener.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/DAButtonClickEventListener.java deleted file mode 100644 index ecdad45..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/DAButtonClickEventListener.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.tizen.dynamicanalyzer.listeners; - -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.tizen.dynamicanalyzer.ui.widgets.button.DAButton; - - -public abstract class DAButtonClickEventListener implements Listener { - - protected DAButton button; - private boolean enabled = true; - - public DAButtonClickEventListener(DAButton button) { - this.button = button; - } - - @Override - public void handleEvent(Event event) { - if (!enabled) { - return; - } - - if (null != button) { - Rectangle rectangle = button.getBounds(); - int x = event.x; - int y = event.y; - - if (x < 0 || x > rectangle.width || y < 0 || y > rectangle.height) { - return; - } - -// button.setHoverState(); - } - - handleClickEvent(event); - } - - public abstract void handleClickEvent(Event event); - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/DAComboSelectionListener.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/DAComboSelectionListener.java deleted file mode 100644 index f587200..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/DAComboSelectionListener.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.tizen.dynamicanalyzer.listeners; - -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.tizen.dynamicanalyzer.ui.widgets.combo.DACombo; - - - -public abstract class DAComboSelectionListener implements Listener { - - private DACombo combo; - - public DAComboSelectionListener(DACombo control) { - combo = control; - } - - @Override - public void handleEvent(Event event) { - if (null != combo) { - selectionEvent(event); - } - } - - public abstract void selectionEvent(Event event); -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/FunctionUsageProfilingData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/FunctionUsageProfilingData.java index f75d8dc..7a3a35c 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/FunctionUsageProfilingData.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/FunctionUsageProfilingData.java @@ -28,6 +28,7 @@ public class FunctionUsageProfilingData { private String key = null; private ProfilingChildData children = null; private int exeTime = 0; + private int lastExeTime = 0; private int inExeTime = 0; public FunctionUsageProfilingData(CallStackUnit inputData, boolean isParent) { @@ -174,27 +175,16 @@ public class FunctionUsageProfilingData { } public void addExeTime(int time) { + lastExeTime = time; exeTime += time; } public int getExeTime() { - List seqs = getChildData().getChildren(); - if (seqs.isEmpty()) { - return exeTime; - } - FunctionUsageProfiler profiler = AnalyzerManager - .getFunctionUserProfiler(); + return exeTime; + } - int size = seqs.size(); - int time = 0; - for (int i = 0; i < size; i++) { - FunctionUsageProfilingData data = profiler.getProfilingDataMap() - .get(seqs.get(i)); - if (null != data) { - time += data.getExeTime(); - } - } - return time; + public int getLastExeTime() { + return lastExeTime; } public void addInclusiveExeTime(int time) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/SummaryLables.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/SummaryLables.java index 239c623..3c4b0c2 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/SummaryLables.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/SummaryLables.java @@ -20,7 +20,7 @@ public class SummaryLables extends NLS { public static String FUNCTION_USER_PROFILING_VIEW_INCLUSIVE_CPU_RATE; public static String FUNCTION_USER_PROFILING_VIEW_INCLUSIVE_CPU_TIME; public static String FUNCTION_USER_PROFILING_VIEW_NAME; - public static String FUNCTION_USER_PROFILING_VIEW_ELASPED_TIME; + public static String FUNCTION_USER_PROFILING_VIEW_EXCLUSIVE_ELASPED_TIME; public static String FUNCTION_USER_PROFILING_VIEW_INCLUSIVE_ELASPED_TIME; public static String FUNCTION_USER_PROFILING_VIEW_TITLE; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/SummaryLables.properties b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/SummaryLables.properties index 714e2b5..8435915 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/SummaryLables.properties +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/SummaryLables.properties @@ -15,7 +15,7 @@ FUNCTION_USER_PROFILING_VIEW_EXCLUSIVE_CPU_TIME=Excl. Cpu Time FUNCTION_USER_PROFILING_VIEW_INCLUSIVE_CPU_RATE=Incl. Cpu Rate FUNCTION_USER_PROFILING_VIEW_INCLUSIVE_CPU_TIME=Incl. Cpu Time FUNCTION_USER_PROFILING_VIEW_NAME=Name -FUNCTION_USER_PROFILING_VIEW_ELASPED_TIME=Elapsed Time +FUNCTION_USER_PROFILING_VIEW_EXCLUSIVE_ELASPED_TIME=Excl. Elapsed Time FUNCTION_USER_PROFILING_VIEW_INCLUSIVE_ELASPED_TIME=Incl. Elapsed Time FUNCTION_USER_PROFILING_VIEW_TITLE=Function Usage Profiling diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/TitleComboPopupRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/renderers/TitleComboPopupRenderer.java similarity index 97% rename from org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/TitleComboPopupRenderer.java rename to org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/renderers/TitleComboPopupRenderer.java index 4624ddb..44b7729 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/TitleComboPopupRenderer.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/renderers/TitleComboPopupRenderer.java @@ -1,4 +1,4 @@ -package org.tizen.dynamicanalyzer.ui.widgets.combo; +package org.tizen.dynamicanalyzer.ui.renderers; import java.util.List; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/TitleComboRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/renderers/TitleComboRenderer.java similarity index 88% rename from org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/TitleComboRenderer.java rename to org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/renderers/TitleComboRenderer.java index 01f93d6..7c6808b 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/TitleComboRenderer.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/renderers/TitleComboRenderer.java @@ -1,4 +1,4 @@ -package org.tizen.dynamicanalyzer.ui.widgets.combo; +package org.tizen.dynamicanalyzer.ui.renderers; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.GC; @@ -8,9 +8,9 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Canvas; import org.tizen.dynamicanalyzer.ColorResources; import org.tizen.dynamicanalyzer.FontResources; +import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo; import org.tizen.dynamicanalyzer.widgets.combo.DACustomComboRenderer; - public class TitleComboRenderer extends DACustomComboRenderer { @Override @@ -58,16 +58,16 @@ public class TitleComboRenderer extends DACustomComboRenderer { } private void setColors(int state, GC gc) { - if (state == DACombo.STATE_NORMAL) { + if (state == DACustomCombo.STATE_NORMAL) { gc.setForeground(ColorResources.BAR_GRAY2); gc.setBackground(ColorResources.WINDOW_BG_COLOR); - } else if (state == DACombo.STATE_HOVER) { + } else if (state == DACustomCombo.STATE_HOVER) { gc.setForeground(ColorResources.BAR_GRAY2); gc.setBackground(ColorResources.ITEM_BLUE_DARK); - } else if (state == DACombo.STATE_PUSH) { + } else if (state == DACustomCombo.STATE_PUSH) { gc.setForeground(ColorResources.BAR_GRAY2); gc.setBackground(ColorResources.BLUE); - } else if (state == DACombo.STATE_DISABLE) { + } else if (state == DACustomCombo.STATE_DISABLE) { gc.setForeground(ColorResources.BAR_GRAY2); gc.setBackground(ColorResources.BAR_GRAY1); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/CoolbarArea.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/CoolbarArea.java index 8609c93..f91f1b1 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/CoolbarArea.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/CoolbarArea.java @@ -46,13 +46,12 @@ import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; import org.tizen.dynamicanalyzer.services.RecordStateSourceProvider; import org.tizen.dynamicanalyzer.theme.DAThemeBlack; import org.tizen.dynamicanalyzer.theme.DAThemeWhite; +import org.tizen.dynamicanalyzer.ui.renderers.TitleComboPopupRenderer; +import org.tizen.dynamicanalyzer.ui.renderers.TitleComboRenderer; import org.tizen.dynamicanalyzer.ui.widgets.AboutDialog; import org.tizen.dynamicanalyzer.ui.widgets.ConfigurationDialog; import org.tizen.dynamicanalyzer.ui.widgets.OpenTraceDialog; import org.tizen.dynamicanalyzer.ui.widgets.TimerClock; -import org.tizen.dynamicanalyzer.ui.widgets.button.DAButton; -import org.tizen.dynamicanalyzer.ui.widgets.combo.TitleComboPopupRenderer; -import org.tizen.dynamicanalyzer.ui.widgets.combo.TitleComboRenderer; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; import org.tizen.dynamicanalyzer.widgets.button.DACustomButton; import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener; @@ -737,35 +736,33 @@ public class CoolbarArea { } }); - startButton - .addClickListener(new DACustomButtonClickEventListener() { + startButton.addClickListener(new DACustomButtonClickEventListener() { - @Override - public void handleClickEvent(DACustomButton button) { - String state = AnalyzerUtil.getRecordState(); - if (state - .equals(RecordStateSourceProvider.RECORD_READY)) { - AnalyzerUtil - .setRecordState(RecordStateSourceProvider.RECORD_RECORDING); - button.setHoverImage(stopHoverImage); - setStartToolbarState(true); - // timerClock.start(); - setToolbarEnablement(false); - ResourceCommunicator.changePage(0); - } else { - AnalyzerUtil - .setRecordState(RecordStateSourceProvider.RECORD_READY); - button.setHoverImage(startHoverImage); - setStartToolbarState(false); - // timerClock.stop(); - setToolbarEnablement(true); - StateManager.getInstance().StopProcessStart( - "stop button pressed"); - } - button.setEnabled(false); - AnalyzerUtil.executeCommand(StartStopTraceHandler.ID); - } - }); + @Override + public void handleClickEvent(DACustomButton button) { + String state = AnalyzerUtil.getRecordState(); + if (state.equals(RecordStateSourceProvider.RECORD_READY)) { + AnalyzerUtil + .setRecordState(RecordStateSourceProvider.RECORD_RECORDING); + button.setHoverImage(stopHoverImage); + setStartToolbarState(true); + // timerClock.start(); + setToolbarEnablement(false); + ResourceCommunicator.changePage(0); + } else { + AnalyzerUtil + .setRecordState(RecordStateSourceProvider.RECORD_READY); + button.setHoverImage(startHoverImage); + setStartToolbarState(false); + // timerClock.stop(); + setToolbarEnablement(true); + StateManager.getInstance().StopProcessStart( + "stop button pressed"); + } + button.setEnabled(false); + AnalyzerUtil.executeCommand(StartStopTraceHandler.ID); + } + }); saveTraceButton .addClickListener(new DACustomButtonClickEventListener() { @@ -841,14 +838,14 @@ public class CoolbarArea { .addClickListener(new DACustomButtonClickEventListener() { @Override public void handleClickEvent(DACustomButton button) { - DACustomToggleButton toggle = (DACustomToggleButton)button; - -// sourceViewToggleState = !sourceViewToggleState; -// viewSourceButton.setToggled(sourceViewToggleState); + DACustomToggleButton toggle = (DACustomToggleButton) button; + + // sourceViewToggleState = !sourceViewToggleState; + // viewSourceButton.setToggled(sourceViewToggleState); AnalyzerManager.getCurrentPage().setSourceView( toggle.isToggled()); - + // theme test if (toggle.isToggled()) { AnalyzerManager.setTheme(DAThemeBlack.getInstance()); @@ -1056,7 +1053,7 @@ public class CoolbarArea { viewSourceButton = new DACustomToggleButton(sourceViewComposite, viewSourceImage, viewSourcePushImage, viewSourceHoverImage, viewSourceDisableImage, viewSourceToggleImage); -// viewSourceButton.setImage(viewSourceImage); + // viewSourceButton.setImage(viewSourceImage); viewSourceButton.setToolTipText(AnalyzerLabels.VIEW_SOURCE); // tutorialButton = new Label(pickaxeComposite, SWT.NONE); @@ -1605,15 +1602,15 @@ public class CoolbarArea { this.windowHeight = height; } -// public void setSourceViewButtonToggleState(boolean isToggled) { -// if (!isToggled) { -// sourceViewToggleState = false; -// viewSourceButton.setImage(viewSourceImage); -// } else if (isToggled) { -// sourceViewToggleState = true; -// viewSourceButton.setImage(viewSourceToggleImage); -// } -// } + // public void setSourceViewButtonToggleState(boolean isToggled) { + // if (!isToggled) { + // sourceViewToggleState = false; + // viewSourceButton.setImage(viewSourceImage); + // } else if (isToggled) { + // sourceViewToggleState = true; + // viewSourceButton.setImage(viewSourceToggleImage); + // } + // } public boolean getSourceViewToggleState() { return viewSourceButton.isToggled(); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/summaryPage/FunctionUsageProfilingView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/summaryPage/FunctionUsageProfilingView.java index ffcc773..ea5c0fe 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/summaryPage/FunctionUsageProfilingView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/summaryPage/FunctionUsageProfilingView.java @@ -22,9 +22,9 @@ public class FunctionUsageProfilingView extends DAView { SummaryLables.FUNCTION_USER_PROFILING_VIEW_INCLUSIVE_CPU_TIME, SummaryLables.FUNCTION_USER_PROFILING_VIEW_INCLUSIVE_CPU_RATE, SummaryLables.FUNCTION_USER_PROFILING_VIEW_CALL_COUNT, - SummaryLables.FUNCTION_USER_PROFILING_VIEW_ELASPED_TIME, - SummaryLables.FUNCTION_USER_PROFILING_VIEW_INCLUSIVE_ELASPED_TIME }; - private int[] columnSizes = { 200, 90, 90, 90, 90, 90, 90, 90 }; + SummaryLables.FUNCTION_USER_PROFILING_VIEW_INCLUSIVE_ELASPED_TIME, + SummaryLables.FUNCTION_USER_PROFILING_VIEW_EXCLUSIVE_ELASPED_TIME }; + private int[] columnSizes = { 200, 0, 0, 0, 0, 0, 0, 0 }; private boolean[] columnVisibility = { true, true, true, true, true, true, true, true }; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/AboutDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/AboutDialog.java index 9bc1f34..d2b573f 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/AboutDialog.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/AboutDialog.java @@ -7,16 +7,13 @@ 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.Label; import org.eclipse.swt.widgets.Shell; import org.tizen.dynamicanalyzer.ColorResources; import org.tizen.dynamicanalyzer.ConfigureManager; import org.tizen.dynamicanalyzer.FontResources; import org.tizen.dynamicanalyzer.ImageResources; -import org.tizen.dynamicanalyzer.listeners.DAButtonClickEventListener; import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; -import org.tizen.dynamicanalyzer.ui.widgets.button.DAButton; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; import org.tizen.dynamicanalyzer.widgets.button.DACustomButton; import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/LicenseDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/LicenseDialog.java index ed71614..3e059f1 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/LicenseDialog.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/LicenseDialog.java @@ -13,7 +13,6 @@ 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.Shell; import org.eclipse.swt.widgets.Text; import org.tizen.dynamicanalyzer.ColorResources; @@ -21,7 +20,6 @@ import org.tizen.dynamicanalyzer.FontResources; import org.tizen.dynamicanalyzer.ImageResources; import org.tizen.dynamicanalyzer.constants.AnalyzerConstants; import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; -import org.tizen.dynamicanalyzer.ui.widgets.button.DAButton; import org.tizen.dynamicanalyzer.widgets.button.DACustomButton; import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButton.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButton.java deleted file mode 100644 index ebb26bb..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButton.java +++ /dev/null @@ -1,296 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.button; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.MouseTrackListener; -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.Image; -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.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.tizen.dynamicanalyzer.ColorResources; -import org.tizen.dynamicanalyzer.listeners.DAButtonClickEventListener; -import org.tizen.dynamicanalyzer.ui.widgets.DAWidgetAttribute; - - -public class DAButton extends Composite { - public static final int MAX_SIZE = 100; - public static final int STATE_NORMAL = 0; - public static final int STATE_PUSH = 1; - public static final int STATE_HOVER = 2; - public static final int STATE_DISABLE = 3; - public static final int STATE_ONE = 4; - public static final int STATE_ENTER = 5; - public static final int STATE_EXIT = 6; - - Composite parent; - private Canvas button; - private boolean enabled = true; - - private int state = STATE_NORMAL; - private DAWidgetAttribute attr; - private Listener mouseUpListener = null; - private DAButtonRenderer buttonRenderer = null; - private DAButtonEvent buttonAction = null; - - public void addClickListener(DAButtonClickEventListener listener) { - mouseUpListener = listener; - button.addListener(SWT.MouseUp, mouseUpListener); - } - - public void addMouseListener(MouseListener listener){ - button.addMouseListener(listener); - } - - public void addKeyListener(KeyListener listener){ - button.addKeyListener(listener); - } - - public void addMouseTrackListener(MouseTrackListener listener){ - button.addMouseTrackListener(listener); - } - - public void addPaintListener(PaintListener listener){ - button.addPaintListener(listener); - } - - public void addListener(int eventType, Listener listener){ - button.addListener(eventType,listener); - } - - public void addListeners() { - button.addListener(SWT.MouseEnter, buttonMouseListener); - // button.addListener(SWT.MouseHover, buttonMouseListener); - button.addListener(SWT.MouseExit, buttonMouseListener); - button.addListener(SWT.MouseDown, buttonMouseListener); - // button.addListener(SWT.MouseMove, buttonMouseListener); - button.addListener(SWT.MouseUp, buttonMouseListener); - } - - public DAButton(Composite parent, int style) { - super(parent, style); - - this.parent = parent; - FillLayout layout = new FillLayout(SWT.HORIZONTAL); - this.setLayout(layout); - - button = new Canvas(this, style); - button.setForeground(ColorResources.WHITE); - button.addPaintListener(buttonPaintListener); - addListeners(); - buttonRenderer = new DefaultButtonRenderer(); - attr = new DAWidgetAttribute(); - } - - public DAButton(Composite parent, int style, String titleText) { - this(parent, style); - attr.setTitle(titleText); - } - - public DAButton(Composite parent, Image normal, Image mouseDown, - Image hover, Image disable) { - this(parent, SWT.TRANSPARENT); - setImages(normal, mouseDown, hover, disable); - } - - private void changeButtonState(int s) { - state = s; - button.redraw(); - } - - private Listener buttonMouseListener = new Listener() { - - @Override - public void handleEvent(Event event) { - if (state == STATE_DISABLE) - return; - if (event.type == SWT.MouseEnter) { - changeButtonState(STATE_HOVER); - } - - // if (event.type == SWT.MouseHover) { - // - // changeButtonState(STATE_HOVER); - // } - - if (event.type == SWT.MouseExit) { - changeButtonState(STATE_NORMAL); - if (null != buttonAction) { - buttonAction.mouseExit(event); - } - } - - if (event.type == SWT.MouseDown) { - changeButtonState(STATE_PUSH); - } - - if (event.type == SWT.MouseUp) { // FIXME - changeButtonState(STATE_HOVER); - - // if (state == STATE_PUSH) { - // changeButtonState(STATE_NORMAL); - // } else { - // changeButtonState(STATE_NORMAL); - // } - } - - // if (event.type == SWT.MouseMove) { - // - // } - } - }; - private PaintListener buttonPaintListener = new PaintListener() { - - @Override - public void paintControl(PaintEvent e) { - buttonRenderer.draw(e.gc, button, state, attr); - } - }; - - public void setTitle(String newTitle) { - attr.setTitle(newTitle); - } - - public void setText(String newTitle) { - attr.setTitle(newTitle); - } - - public void setRenderer(DAButtonRenderer newRenderer) { - buttonRenderer = newRenderer; - } - - public Rectangle getBounds() { - return button.getBounds(); - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - if (enabled) { - changeButtonState(STATE_NORMAL); - } else { - changeButtonState(STATE_DISABLE); - } - - if (null != mouseUpListener) { - ((DAButtonClickEventListener) mouseUpListener).setEnabled(enabled); - } - } - - public boolean getEnabled() { - if (STATE_DISABLE != state) - return true; - else - return false; - } - - // public void setHoverState() { - // setButtonImage(hoverImage); - // } - // public void setImage(Image image) { - // label.setImage(image); - // } - - public void setToolTipText(String text) { - if (null != text && !text.isEmpty()) { - button.setToolTipText(text); - } - } - - // public void setLayoutData(Object layoutData) { - // this.setLayoutData(layoutData); - // } - - public void setHoverImage(Image image) { - attr.setHoverImage(image); - } - - public void setNormalImage(Image image) { - attr.setNormalImage(image); - } - - public void setPushImage(Image image) { - attr.setMouseDownImage(image); - } - - public void setDisableImage(Image image) { - attr.setDisableImage(image); - } - - public void setImage(Image image) { - attr.setOneImage(image); - changeButtonState(STATE_ONE); - } - - public Image getHoverImage() { - return attr.getHoverImage(); - } - - public Image getNormalImage() { - return attr.getNormalImage(); - } - - public Image getPushImage() { - return attr.getMouseDownImage(); - } - - public Image getDisableImage(Image image) { - return attr.getDisableImage(); - } - - public void setHoverColor(Color color) { - attr.setHoverColor(color); - } - - public void setNormalColor(Color color) { - attr.setNormalColor(color); - } - - public void setPushColor(Color color) { - attr.setMouseDownColor(color); - } - - public void setDisableColor(Color color) { - attr.setDisableColor(color); - } - - public void setColor(Color color) { - attr.setOneColor(color); - changeButtonState(STATE_ONE); - } - - public void setVisible(boolean visible) { - button.setVisible(visible); - } - - public void setFont(Font font) { - attr.setFont(font); - } - - public void setFontPoint(Point p) { - attr.setFontPoint(p); - } - - public void setImages(Image normal, Image mouseDown, Image hover, - Image disable) { - attr.setNormalImage(normal); - attr.setMouseDownImage(mouseDown); - attr.setHoverImage(hover); - attr.setDisableImage(disable); - } - - public void setDAButtonAction(DAButtonEvent action) { - buttonAction = action; - } - public Control getControl(){ - return button; - } -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonAction.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonAction.java deleted file mode 100644 index 399019f..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonAction.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.button; - -import org.eclipse.swt.widgets.Event; - -public class DAButtonAction implements DAButtonEvent{ - public void mouseExit(Event event) { - - } -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonEvent.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonEvent.java deleted file mode 100644 index 0e756bd..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonEvent.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.button; - -import org.eclipse.swt.widgets.Event; - -public interface DAButtonEvent { - public void mouseExit(Event evnet); -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonRenderer.java deleted file mode 100644 index cb963fc..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAButtonRenderer.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.button; - -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.widgets.Canvas; -import org.tizen.dynamicanalyzer.ui.widgets.DAWidgetAttribute; - - -public abstract class DAButtonRenderer { - public abstract void draw(GC gc, Canvas canvas, int state, DAWidgetAttribute attr); -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAToggleButton.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAToggleButton.java deleted file mode 100644 index b62f878..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DAToggleButton.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.button; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class DAToggleButton extends DAButton { - - private Image toggleImage; - - public DAToggleButton(Composite parent, Image normal, Image mouseDown, - Image hover, Image disable, Image toggle) { - super(parent, normal, mouseDown, hover, disable); - - toggleImage = toggle; - } - - public void setToggled(boolean toggled) { - Image buf = getNormalImage(); - setNormalImage(toggleImage); - toggleImage = buf; - } -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DefaultButtonRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DefaultButtonRenderer.java deleted file mode 100644 index 7b5a2b9..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/button/DefaultButtonRenderer.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.button; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Display; -import org.tizen.dynamicanalyzer.ColorResources; -import org.tizen.dynamicanalyzer.ui.widgets.DAWidgetAttribute; - - -public class DefaultButtonRenderer extends DAButtonRenderer { - - @Override - public void draw(GC gc, Canvas canvas, int state, DAWidgetAttribute attr) { - Rectangle rect = canvas.getBounds(); - // Background - Image i; - Color c; - switch (state) { - case DAButton.STATE_HOVER: - if (null != (i = attr.getHoverImage())) { - gc.drawImage(i, rect.x, rect.y); - drawButtonText(gc, rect, attr); - } else { - if (null == (c = attr.getHoverColor())) { - c = new Color(Display.getCurrent(), 0, 134, 185); - attr.setHoverColor(c); - } - drawButton(gc, rect, c, attr); - } - break; - case DAButton.STATE_NORMAL: - if (null != (i = attr.getNormalImage())) { - gc.drawImage(i, rect.x, rect.y); - drawButtonText(gc, rect, attr); - } else { - if (null == (c = attr.getNormalColor())) { - c = new Color(Display.getCurrent(), 67, 67, 67); - attr.setNormalColor(c); - } - drawButton(gc, rect, c, attr); - } - break; - case DAButton.STATE_PUSH: - if (null != (i = attr.getMouseDownImage())) { - gc.drawImage(i, rect.x, rect.y); - drawButtonText(gc, rect, attr); - } else { - if (null == (c = attr.getMouseDownColor())) { - c = new Color(Display.getCurrent(), 29, 109, 140); - attr.setMouseDownColor(c); - } - drawButton(gc, rect, c, attr); - } - break; - case DAButton.STATE_DISABLE: - if (null != (i = attr.getDisableImage())) { - gc.drawImage(i, rect.x, rect.y); - drawButtonText(gc, rect, attr); - } else { - if (null == (c = attr.getDisableColor())) { - c = new Color(Display.getCurrent(), 48, 48, 48); - attr.setDisableColor(c); - } - drawButton(gc, rect, c, attr); - } - break; - case DAButton.STATE_ONE: - if (null != (i = attr.getOneImage())) { - gc.drawImage(i, rect.x, rect.y); - drawButtonText(gc, rect, attr); - } else { - if (null == (c = attr.getOneColor())) { - c = new Color(Display.getCurrent(), 67, 67, 67); - attr.setOneColor(c); - } - drawButton(gc, rect, c, attr); - } - break; - default: - gc.setBackground(new Color(Display.getCurrent(), 67, 67, 67)); - } - } - - public int computeFontSize(Rectangle rect) { - if (rect.height > 20) - return 10; - else - return 8; - } - - public void drawButton(GC gc, Rectangle rect, Color c, - DAWidgetAttribute attr) { - gc.setBackground(c); - gc.fillRectangle(rect); - drawButtonText(gc, rect, attr); - Rectangle r = new Rectangle(0, 0, rect.width - 1, rect.height - 1); - c = gc.getForeground(); - gc.setForeground(ColorResources.BLACK); - gc.drawRectangle(r); - gc.setForeground(c); - } - - private void drawButtonText(GC gc, Rectangle rect, DAWidgetAttribute attr) { - String s = null; - Font f = null; - Point p = null; - if (null != (s = attr.getTitle())) { - if (null == (f = attr.getFont())) { - f = new Font(Display.getCurrent(), "Arial", //$NON-NLS-1$ - computeFontSize(rect), SWT.BOLD); - attr.setFont(f); - } - gc.setFont(f); - - int x = 0, y = 0; - int offset = 0; - if (null == (p = attr.getFontPoint())) { - p = gc.textExtent(s, SWT.DRAW_MNEMONIC); - x = (rect.width - p.x) / 2; - y = (rect.height - p.y) / 2; - x = (x < 0) ? 0 : x; - // rect size < text length -> insert offset - offset = ((x - rect.x) < 4) ? 4 : 0; - } else { - x = p.x; - y = p.y; - } - gc.drawString(s, x + offset, y, true); - } - } -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/ComboButtonAction.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/ComboButtonAction.java deleted file mode 100644 index eecb75e..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/ComboButtonAction.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.combo; - -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Shell; -import org.tizen.dynamicanalyzer.ui.widgets.button.DAButton; -import org.tizen.dynamicanalyzer.ui.widgets.button.DAButtonEvent; - - -public class ComboButtonAction implements DAButtonEvent { - private DAButton button = null; - private Shell child = null; - private boolean up = true; - - public ComboButtonAction(Shell child, DAButton button, boolean up) { - this.button = button; - this.child = child; - this.up = up; - } - - @Override - public void mouseExit(Event event) { - if (child == null) { - return; - } - Rectangle rect = button.getClientArea(); - if (up) { - if (rect.y + rect.height > event.y) { - child.close(); - child = null; - } - } else { - if (rect.y < event.y) { - child.close(); - child = null; - } - } - - } - -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DACombo.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DACombo.java deleted file mode 100644 index 48d45fb..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DACombo.java +++ /dev/null @@ -1,555 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.combo; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.tizen.dynamicanalyzer.ColorResources; -import org.tizen.dynamicanalyzer.listeners.DAButtonClickEventListener; -import org.tizen.dynamicanalyzer.listeners.DAComboSelectionListener; -import org.tizen.dynamicanalyzer.ui.widgets.button.DAButton; - -public class DACombo extends Composite { - public static final int MAX_SIZE = 10; - public static final int STATE_NORMAL = 0; - public static final int STATE_HOVER = 1; - public static final int STATE_PUSH = 2; - public static final int STATE_DISABLE = 3; - - private static final int pageSize = 5; - - Composite parent; - private Canvas combo; - private Canvas popup = null; - private int itemHeight = 0; - private DAButton upArrowButton = null; - private DAButton downArrowButton = null; - private int itemIndex = 0; - - private List items; - private List rects = null; - - private List images = null; - private boolean enabled = true; - private Shell childShell = null; - private int selection = 0; - private String text = ""; //$NON-NLS-1$ - private boolean imgCombo = false; - private int state = STATE_NORMAL; // 0 normal 1 hover 2 push 3 disable - private DAComboRenderer comboRenderer = new DefaultDAComboRenderer();; - private DAComboPopupRenderer popupRenderer = new DefaultDAComboPopupRenderer(); - - public DACombo(Composite parent, int style) { - super(parent, style); - - this.parent = parent; - this.setLayout(new FormLayout()); - combo = new Canvas(this, style); - combo.addPaintListener(comboPaintListener); - - FormData data = new FormData(); - data.top = new FormAttachment(0, 0); - data.bottom = new FormAttachment(100, 0); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(100, 0); - combo.setLayoutData(data); - combo.setForeground(ColorResources.WHITE); - addListeners(); - } - - public void addListeners() { - combo.addListener(SWT.MouseEnter, comboMouseListener); - combo.addListener(SWT.MouseHover, comboMouseListener); - combo.addListener(SWT.MouseExit, comboMouseListener); - combo.addListener(SWT.MouseDown, comboMouseListener); - combo.addListener(SWT.MouseMove, comboMouseListener); - combo.addListener(SWT.MouseUp, comboMouseListener); - } - - public String getText() { - if (getItems().size() > 0) { - return getItems().get(itemIndex + selection); - } - return null; - } - - public List getItems() { - if (null == items) { - items = new ArrayList(); - } - return items; - } - - private List getRects() { - if (null == rects) { - rects = new ArrayList(); - } - return rects; - } - - private void changeComboState(int s) { - state = s; - combo.redraw(); - } - - private Listener comboMouseListener = new Listener() { - @Override - public void handleEvent(Event event) { - if (enabled) { - if (event.type == SWT.MouseEnter) { - changeComboState(STATE_HOVER); - } - - if (event.type == SWT.MouseHover) { - if (!isOutOfBounds(event.x, event.y)) { - if (0 != (event.stateMask & SWT.BUTTON1)) { - changeComboState(STATE_PUSH); - } else if (0 == (event.stateMask & SWT.BUTTON1)) { - changeComboState(STATE_HOVER); - } - } - } - - if (event.type == SWT.MouseExit) { - changeComboState(STATE_NORMAL); - // if (null != childShell && !childShell.isDisposed()) { - // Rectangle rect = combo.getBounds(); - // if (rect.y + rect.height > event.y) { - // childShell.close(); - // childShell = null; - // } - // } - } - - if (event.type == SWT.MouseDown) { - changeComboState(STATE_PUSH); - } - - if (event.type == SWT.MouseUp) { - changeComboState(STATE_HOVER); - if (childShell == null || childShell.isDisposed()) { - openChildShell(); - } else { - childShell.close(); - childShell = null; - } - } - - if (event.type == SWT.MouseMove) { - if (isOutOfBounds(event.x, event.y)) { - changeComboState(STATE_NORMAL); - } else if (isOutOfBounds(event.x, event.y)) { - if (0 != (event.stateMask & SWT.BUTTON1)) { - changeComboState(STATE_PUSH); - } else if (0 == (event.stateMask & SWT.BUTTON1)) { - changeComboState(STATE_HOVER); - } - } - } - } - } - }; - - protected boolean isOutOfBounds(int x, int y) { - Rectangle rectangle = combo.getBounds(); - - if (x < 0 || x > rectangle.width || y < 0 || y > rectangle.height) { - return true; - } - - return false; - } - - private int getShellWidth() { - if (getItems().isEmpty()) { - return 0; - } - int max = 0; - int size = items.size(); - GC gc = new GC(parent.getDisplay(), SWT.NONE); - for (int i = 0; i < size; i++) { - Point p = gc.textExtent(items.get(i), SWT.DRAW_MNEMONIC); - if (p.x > max) { - max = p.x; - } - } - max += 10; - gc.dispose(); - return max; - } - - public int getItemHeight() { - return itemHeight; - } - - public void setItemHeight(int height) { - itemHeight = height; - } - - private void openChildShell() { - childShell = new Shell(parent.getShell(), SWT.ON_TOP); - // childShell.setLayout(new FillLayout()); - childShell.setLayout(new FormLayout()); - - Point p = combo.toDisplay(0, 0); - Rectangle rect = combo.getBounds(); - int size = getItems().size(); - - int boundSize = (size > MAX_SIZE) ? MAX_SIZE : (size > 0) ? size : 1; - - int textSize = getShellWidth() + 4; - int shellWidth = (textSize > rect.width) ? textSize : rect.width + 4; - int height = 0; - - if (getItemHeight() == 0) { - height = rect.height; - } else { - height = getItemHeight(); - } - int shellHeight = height * boundSize + 5; - - childShell.setSize(shellWidth, shellHeight); - childShell.setLocation(p.x, p.y + rect.height); - - popup = new Canvas(childShell, SWT.DOUBLE_BUFFERED); - popup.setBackground(ColorResources.WINDOW_BG_COLOR); - popup.addPaintListener(popupPaintListener); - popup.addListener(SWT.MouseUp, canvasMouseEventListener); - popup.addListener(SWT.MouseExit, canvasMouseEventListener); - popup.addListener(SWT.MouseMove, canvasMouseEventListener); - popup.addListener(SWT.MouseUp, canvasMouseUpListener); - popup.addListener(SWT.FocusOut, canvasMouseEventListener); - popup.addListener(SWT.MouseWheel, canvasMouseEventListener); - - if (size > MAX_SIZE) { - upArrowButton = new DAButton(childShell, SWT.NONE); - upArrowButton.setText("up"); //$NON-NLS-1$ - FormData data = new FormData(); - data.top = new FormAttachment(0, 0); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(100, 0); - data.height = height; - upArrowButton.setLayoutData(data); - upArrowButton.addClickListener(upArrowListener); - // upArrowButton.setDAButtonAction(new ComboButtonAction(childShell, - // upArrowButton, true)); - shellHeight += height; - - data = new FormData(); - data.top = new FormAttachment(upArrowButton, 0); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(100, 0); - data.height = height * boundSize + 5 - 2; - popup.setLayoutData(data); - - downArrowButton = new DAButton(childShell, SWT.NONE); - downArrowButton.setText("down"); //$NON-NLS-1$ - data = new FormData(); - data.top = new FormAttachment(popup, 0); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(100, 0); - data.height = height; - downArrowButton.setLayoutData(data); - downArrowButton.addClickListener(downArrowListener); - // downArrowButton.setDAButtonAction(new - // ComboButtonAction(childShell, - // downArrowButton, false)); - shellHeight += height; - - childShell.setSize(shellWidth, shellHeight); - } else { - FormData data = new FormData(); - data.top = new FormAttachment(0, 0); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(100, 0); - data.height = shellHeight - 2; - popup.setLayoutData(data); - } - - size = (size > MAX_SIZE) ? MAX_SIZE : size; - getRects().clear(); - for (int i = 0; i < size; i++) { - Rectangle r = new Rectangle(2, 2 + i * height, shellWidth - 2, - height); - getRects().add(r); - } - childShell.open(); - } - - private DAButtonClickEventListener upArrowListener = new DAButtonClickEventListener( - upArrowButton) { - - @Override - public void handleClickEvent(Event event) { - int size = getItems().size(); - if (itemIndex - pageSize < 0) { - itemIndex = 0; - upArrowListener.setEnabled(false); - } else { - itemIndex -= pageSize; - } - - if (itemIndex + pageSize < size - 1) { - downArrowButton.setEnabled(true); - } - popup.redraw(); - } - }; - - private DAButtonClickEventListener downArrowListener = new DAButtonClickEventListener( - downArrowButton) { - - @Override - public void handleClickEvent(Event event) { - int size = getItems().size(); - if (itemIndex + pageSize + MAX_SIZE >= size - 1) { - itemIndex = size - MAX_SIZE; - downArrowListener.setEnabled(false); - } else { - itemIndex += pageSize; - } - - if (itemIndex - pageSize > 0) { - upArrowButton.setEnabled(true); - } - popup.redraw(); - } - }; - - private PaintListener popupPaintListener = new PaintListener() { - - @Override - public void paintControl(PaintEvent e) { - List items = getItems(); - List input = new ArrayList(); - int size = (items.size() > MAX_SIZE) ? MAX_SIZE : items.size(); - for (int i = 0; i < size; i++) { - input.add(items.get(itemIndex + i)); - } - popupRenderer - .draw(e.gc, popup, state, getRects(), selection, input); - } - }; - - public void setText(String text) { - if (!setSelect(text)) { - this.text = text; - combo.redraw(); - } - } - - private boolean setSelect(String text) { - if (getItems().isEmpty()) { - return false; - } - - int index = items.indexOf(text); - if (index < 0) { - return false; - } - int size = items.size(); - if (index + MAX_SIZE >= size) { - int lower = size - index; - selection = MAX_SIZE - lower; - itemIndex = size - MAX_SIZE; - select(selection); - } else { - selection = index - itemIndex; - select(selection); - } - return true; - } - - public void upEvent() { - if (getItems().size() > 0) { - setText(getItems().get(itemIndex + selection)); - } else { - setText(""); //$NON-NLS-1$ - } - childShell.close(); - childShell = null; - } - - private Listener canvasMouseEventListener = new Listener() { - - @Override - public void handleEvent(Event event) { - if (event.type == SWT.MouseUp) { - upEvent(); - } - - if (event.type == SWT.MouseMove) { - List rs = getRects(); - int size = rs.size(); - for (int i = 0; i < size; i++) { - if (rs.get(i).contains(event.x, event.y)) { - selection = i; - popup.redraw(); - break; - } - } - } - - // if (event.type == SWT.MouseExit) { - // if (null != upArrowButton && null != downArrowButton) { - // Rectangle rect = popup.getClientArea(); - // if (rect.y < event.y && rect.y + rect.height > event.y) { - // childShell.close(); - // childShell = null; - // } - // } else { - // childShell.close(); - // childShell = null; - // } - // } - if (event.type == SWT.FocusOut) { - childShell.close(); - childShell = null; - } - - if (event.type == SWT.MouseWheel) { - int size = getItems().size(); - if (event.count < 0) { - if (itemIndex - event.count + MAX_SIZE >= size - 1) { - itemIndex = size - MAX_SIZE; - downArrowButton.setEnabled(false); - } else { - itemIndex -= event.count; - } - - if (itemIndex - pageSize > 0) { - upArrowButton.setEnabled(true); - } - } else { - - if (itemIndex - event.count < 0) { - itemIndex = 0; - upArrowButton.setEnabled(false); - } else { - itemIndex -= event.count; - } - - if (itemIndex + event.count < size - 1) { - downArrowButton.setEnabled(true); - } - } - popup.redraw(); - } - } - }; - private Listener canvasMouseUpListener = new Listener() { - - @Override - public void handleEvent(Event event) { - upEvent(); - } - }; - - public void addSelectionListener(DAComboSelectionListener listener) { - canvasMouseUpListener = listener; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - if (enabled) { - changeComboState(STATE_NORMAL); - if (isImageCombo()) { - combo.setBackgroundImage(images.get(STATE_NORMAL)); - } - } else { - changeComboState(STATE_DISABLE); - if (isImageCombo()) { - combo.setBackgroundImage(images.get(STATE_DISABLE)); - - } - } - } - - public Canvas getControl() { - return combo; - } - - private PaintListener comboPaintListener = new PaintListener() { - - @Override - public void paintControl(PaintEvent e) { - if (!isImageCombo()) { - comboRenderer.draw(e.gc, combo, text, state); - } else { - comboRenderer.drawImage(e.gc, combo, images.get(state), text, - state); - } - } - }; - - public void setComboRender(DAComboRenderer newRenderer) { - comboRenderer = newRenderer; - } - - public void setComboPopupRender(DAComboPopupRenderer newRenderer) { - popupRenderer = newRenderer; - } - - public void removeAll() { - getItems().clear(); - } - - public void add(String item) { - getItems().add(item); - } - - public void select(int index) { - selection = index; - this.text = items.get(itemIndex + selection); - combo.redraw(); - } - - public String getItem(int index) { - if (getItems().size() > 0) { - return getItems().get(index); - } - return ""; //$NON-NLS-1$ - } - - public void setImages(Image normal, Image hover, Image push, Image disable) { - if (null == normal || null == hover || null == push || null == disable) { - return; - } - List imgs = getImages(); - - imgs.add(normal); - imgs.add(hover); - imgs.add(push); - imgs.add(disable); - setImageCombo(true); - } - - private List getImages() { - if (null == images) { - images = new ArrayList(); - } - return images; - } - - private void setImageCombo(boolean b) { - this.imgCombo = b; - } - - public boolean isImageCombo() { - return imgCombo; - } -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DAComboPopupRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DAComboPopupRenderer.java deleted file mode 100644 index 44ecd42..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DAComboPopupRenderer.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.combo; - -import java.util.List; - -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; - -public abstract class DAComboPopupRenderer { - public abstract void draw(GC gc, Canvas canvas, int state, - List rects, int selection, List items); - - public abstract void drawPattern(GC gc, Canvas canvas, Image patternImage, - int state, List rects, int selection, List items); - - public abstract void drawImage(GC gc, Canvas canvas, Image image, - int state, List rects, int selection, List items); -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DAComboRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DAComboRenderer.java deleted file mode 100644 index 6ca24cf..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DAComboRenderer.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.combo; - -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Canvas; - -public abstract class DAComboRenderer { - public abstract void draw(GC gc, Canvas canvas, String text, int state); - public abstract void drawPattern(GC gc, Canvas canvas, Image patternImage, String text, int state); - public abstract void drawImage(GC gc, Canvas canvas, Image image, String text, int state); -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DefaultDAComboPopupRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DefaultDAComboPopupRenderer.java deleted file mode 100644 index 24cbafc..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DefaultDAComboPopupRenderer.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.combo; - -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -import org.tizen.dynamicanalyzer.ColorResources; - - -public class DefaultDAComboPopupRenderer extends DAComboPopupRenderer { - - @Override - public void draw(GC gc, Canvas canvas, int state, List rects, - int selection, List items) { - int size = rects.size(); - for (int i = 0; i < size; i++) { - Rectangle r = rects.get(i); - gc.setBackground(ColorResources.WINDOW_BG_COLOR); - if (selection == i) { - gc.setBackground(ColorResources.RED); - gc.fillRectangle(r); - gc.setBackground(ColorResources.WINDOW_BG_COLOR); - } - gc.setForeground(ColorResources.WHITE); - gc.drawRectangle(r.x, r.y, r.width - 1, r.height - 1); - Point p = gc.textExtent(items.get(i), SWT.DRAW_MNEMONIC); - gc.drawString(items.get(i), 5, (r.height - p.y) / 2 + i * r.height, - true); - } - } - - @Override - public void drawPattern(GC gc, Canvas canvas, Image patternImage, - int state, List rects, int selection, List items) { - // TODO Auto-generated method stub - - } - - @Override - public void drawImage(GC gc, Canvas canvas, Image image, int state, - List rects, int selection, List items) { - // TODO Auto-generated method stub - - } - -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DefaultDAComboRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DefaultDAComboRenderer.java deleted file mode 100644 index edb46ba..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/combo/DefaultDAComboRenderer.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.tizen.dynamicanalyzer.ui.widgets.combo; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -import org.tizen.dynamicanalyzer.ColorResources; - - -public class DefaultDAComboRenderer extends DAComboRenderer { - - @Override - public void draw(GC gc, Canvas canvas, String text, int state) { - Rectangle rect = canvas.getBounds(); - if (state == DACombo.STATE_NORMAL) { - gc.setBackground(ColorResources.WINDOW_BG_COLOR); - } else if (state == DACombo.STATE_HOVER) { - gc.setBackground(ColorResources.ITEM_BLUE_DARK); - } else if (state == DACombo.STATE_PUSH) { - gc.setBackground(ColorResources.BLUE); - } else if (state == DACombo.STATE_DISABLE) { - gc.setBackground(ColorResources.BAR_GRAY1); - } - gc.fillRectangle(rect); - gc.drawRectangle(rect.x, rect.y, rect.width - 20, rect.height - 1); - - if (null == text) { - text = ""; //$NON-NLS-1$ - } - Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC); - gc.drawString(text, 5, (rect.height - p.y)/2, true); - gc.fillRectangle(rect.x + rect.width - 20, rect.y, 19, rect.height - 1); - gc.drawRectangle(rect.x + rect.width - 20, rect.y, 19, rect.height - 1); - } - - @Override - public void drawPattern(GC gc, Canvas canvas, Image patternImage, - String text, int state) { - - } - - @Override - public void drawImage(GC gc, Canvas canvas, Image image, String text, - int state) { - - } - -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/FunctionUsageProfiler.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/FunctionUsageProfiler.java index 99624d9..c3aa252 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/FunctionUsageProfiler.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/FunctionUsageProfiler.java @@ -34,9 +34,9 @@ public class FunctionUsageProfiler { public int getInclusiveExeTime() { int cTime = 0; for (int i = 0; i < children.size(); i++) { - cTime += children.get(i).getThis().getExeTime(); + cTime += children.get(i).getThis().getLastExeTime(); } - return (me.getExeTime() - cTime); + return me.getLastExeTime() - cTime; } public FunctionUsageProfilingData getThis() { @@ -132,9 +132,11 @@ public class FunctionUsageProfiler { inputCallstackApiData, false); parent.addChild(child); child.addExCount(); - child.setParent(parent.getName()); - child.addCallCount(); child.addExeTime(exeTime); + child.setParent(parent.getName()); + if (type != LogCenterConstants.USER_FUNCTION_EVENT_TYPE_EXIT) { + child.addCallCount(); + } } else { FunctionUsageProfilingData child = getProfilingDataByKey(inputCallstackApiData .getSymbol()); @@ -143,13 +145,16 @@ public class FunctionUsageProfiler { parent.addChild(child); child.setParent(parent.getName()); } - child.addCallCount(); child.addExeTime(exeTime); + if (type != LogCenterConstants.USER_FUNCTION_EVENT_TYPE_EXIT) { + child.addCallCount(); + } // calculate internal time if (type == LogCenterConstants.USER_FUNCTION_EVENT_TYPE_EXIT) { if (null == current) { // bug + System.out.println("bug found!!"); } else { child.addInclusiveExeTime(current.getInclusiveExeTime()); current = current.getParent(); -- 2.7.4