From 699a76a1eeb4b2f19d1340e3db3a8f66609fa157 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Fri, 5 Feb 2016 12:06:49 +0900 Subject: [PATCH 01/11] bug fix - top menu dynamic apply --- .../client/views/ObjectNavigationView.java | 159 ++++++++++-------- 1 file changed, 91 insertions(+), 68 deletions(-) diff --git a/scouter.client/src/scouter/client/views/ObjectNavigationView.java b/scouter.client/src/scouter/client/views/ObjectNavigationView.java index 6ac61fb9e..9814192b7 100644 --- a/scouter.client/src/scouter/client/views/ObjectNavigationView.java +++ b/scouter.client/src/scouter/client/views/ObjectNavigationView.java @@ -116,7 +116,6 @@ import scouter.lang.counters.CounterEngine; import scouter.lang.value.Value; import scouter.util.CastUtil; -import scouter.util.CompareUtil; import scouter.util.FormatUtil; import scouter.util.HashUtil; @@ -146,9 +145,6 @@ enum PresentMode { HIERACHY_MODE, FLAT_MODE } IMenuManager collectorMenuManager; IMenuManager hostMenuManager; IMenuManager objectMenuManager; - HierarchyObject lastSelectedCollector; - HierarchyObject lastSelectedHost; - HierarchyObject lastSelectedObject; public void refresh() { if (mode == PresentMode.HIERACHY_MODE) { @@ -270,70 +266,6 @@ public void handleEvent(Event event) { TreeItem item = objTreeViewer.getTree().getItem(point); if (item != null) { selectedItem = true; - ISelection selection = objTreeViewer.getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection sel = (IStructuredSelection)selection; - Object[] elements = sel.toArray(); - if (elements == null || elements.length < 1) { - return; - } - Object selObject = elements[elements.length - 1]; - if (selObject instanceof ServerObject) { - if (!CompareUtil.equals(selObject, lastSelectedCollector)) { - // Update Collector TopMenu - lastSelectedCollector = fillTopMenu((HierarchyObject) selObject, collectorMenuManager); - resetTopMenu(hostMenuManager, "Choose Host in ObjectView"); - lastSelectedHost = null; - resetTopMenu(objectMenuManager, "Choose Object in ObjectView"); - lastSelectedObject = null; - topMenuManager.update(true); - } - } else if (selObject instanceof AgentObject) { - AgentObject agent = (AgentObject) selObject; - int serverId = agent.getServerId(); - Server server = ServerManager.getInstance().getServer(serverId); - ServerObject serverObject = root.get(server.getName()); - CounterEngine engine = server.getCounterEngine(); - if (engine.isChildOf(agent.getObjType(), CounterConstants.FAMILY_HOST)) { - if (!CompareUtil.equals(agent, lastSelectedHost)) { - // Update Host TopMenu - resetTopMenu(objectMenuManager, "Choose Object in ObjectView"); - lastSelectedObject = null; - lastSelectedHost = fillTopMenu(agent, hostMenuManager); - if (!CompareUtil.equals(serverObject, lastSelectedCollector)) { - // Update Collector TopMenu - if (serverObject != null) { - lastSelectedCollector = fillTopMenu(serverObject, collectorMenuManager); - } - } - topMenuManager.update(true); - } - } else { - if (!CompareUtil.equals(agent, lastSelectedObject)) { - // Update Object TopMenu - lastSelectedObject = fillTopMenu(agent, objectMenuManager); - String objName = agent.getObjName(); - String host = objName.substring(0, objName.indexOf("/", 1)); - AgentObject hostAgent = agentThread.getAgentObject(HashUtil.hash(host)); - if (hostAgent == null) { - resetTopMenu(hostMenuManager, "Cannot find Host agent"); - lastSelectedHost = null; - } else { - if (!CompareUtil.equals(hostAgent, lastSelectedHost)) { - lastSelectedHost = fillTopMenu(hostAgent, hostMenuManager); - } - } - if (!CompareUtil.equals(serverObject, lastSelectedCollector)) { - // Update Collector TopMenu - if (serverObject != null) { - lastSelectedCollector = fillTopMenu(serverObject, collectorMenuManager); - } - } - topMenuManager.update(true); - } - } - } - } } else { selectedItem = false; } @@ -409,6 +341,97 @@ private void initTopMenuMangers() { hostMenuManager.add(new DummyAction("Choose Host in ObjectView", Images.alert)); objectMenuManager.add(new DummyAction("Choose Object in ObjectView", Images.alert)); topMenuManager.update(true); + collectorMenuManager.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager mgr) { + ISelection selection = objTreeViewer.getSelection(); + if (selection instanceof IStructuredSelection) { + IStructuredSelection sel = (IStructuredSelection)selection; + Object[] elements = sel.toArray(); + ServerObject serverObject = null; + if (elements == null || elements.length < 1) { + Server defServer = ServerManager.getInstance().getDefaultServer(); + serverObject = root.get(defServer.getName()); + } else { + Object selObject = elements[elements.length - 1]; + if (selObject instanceof ServerObject) { + serverObject = (ServerObject) selObject; + } else if (selObject instanceof AgentObject) { + AgentObject ao = (AgentObject) selObject; + Server server = ServerManager.getInstance().getServer(ao.getServerId()); + serverObject = root.get(server.getName()); + } + } + if (serverObject != null) { + fillTopMenu(serverObject, mgr); + } else { + resetTopMenu(collectorMenuManager, "Choose Collector in ObjectView"); + } + + } + } + }); + hostMenuManager.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager mgr) { + ISelection selection = objTreeViewer.getSelection(); + if (selection instanceof IStructuredSelection) { + IStructuredSelection sel = (IStructuredSelection)selection; + Object[] elements = sel.toArray(); + AgentObject hostObject = null; + if (elements == null || elements.length < 1) { + return; + } else { + Object selObject = elements[elements.length - 1]; + if (selObject instanceof AgentObject) { + AgentObject agent = (AgentObject) selObject; + int serverId = agent.getServerId(); + Server server = ServerManager.getInstance().getServer(serverId); + CounterEngine engine = server.getCounterEngine(); + if (engine.isChildOf(agent.getObjType(), CounterConstants.FAMILY_HOST)) { + hostObject = agent; + } else { + String objName = agent.getObjName(); + String host = objName.substring(0, objName.indexOf("/", 1)); + hostObject = agentThread.getAgentObject(HashUtil.hash(host)); + } + } + } + if (hostObject != null) { + fillTopMenu(hostObject, mgr); + } else { + resetTopMenu(hostMenuManager, "Choose Host in ObjectView"); + } + } + } + }); + objectMenuManager.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager mgr) { + ISelection selection = objTreeViewer.getSelection(); + if (selection instanceof IStructuredSelection) { + IStructuredSelection sel = (IStructuredSelection)selection; + Object[] elements = sel.toArray(); + AgentObject object = null; + if (elements == null || elements.length < 1) { + return; + } else { + Object selObject = elements[elements.length - 1]; + if (selObject instanceof AgentObject) { + AgentObject agent = (AgentObject) selObject; + int serverId = agent.getServerId(); + Server server = ServerManager.getInstance().getServer(serverId); + CounterEngine engine = server.getCounterEngine(); + if (!engine.isChildOf(agent.getObjType(), CounterConstants.FAMILY_HOST)) { + object = agent; + } + } + } + if (object != null) { + fillTopMenu(object, mgr); + } else { + resetTopMenu(objectMenuManager, "Choose Object in ObjectView"); + } + } + } + }); } private void createQuickMenus(){ From c38115f5df48f9d9b0910de5efd775d150e1a72f Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Fri, 12 Feb 2016 10:52:00 +0900 Subject: [PATCH 02/11] change line selecting way - current all --- .../counter/views/CounterRealTimeAllView.java | 102 ++++++------------ .../src/scouter/client/util/ScouterUtil.java | 46 +++++++- 2 files changed, 73 insertions(+), 75 deletions(-) diff --git a/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java b/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java index 32647295b..cbae36ee4 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java @@ -24,6 +24,7 @@ import java.util.Map; import org.csstudio.swt.xygraph.dataprovider.CircularBufferDataProvider; +import org.csstudio.swt.xygraph.dataprovider.ISample; import org.csstudio.swt.xygraph.dataprovider.Sample; import org.csstudio.swt.xygraph.figures.Trace; import org.csstudio.swt.xygraph.figures.Trace.PointStyle; @@ -42,12 +43,7 @@ import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -109,6 +105,7 @@ public class CounterRealTimeAllView extends ScouterViewPart implements Refreshab protected XYGraph xyGraph; protected Map datas = new HashMap(); protected FigureCanvas canvas; + boolean selectedMode = false; ArrayList traces = new ArrayList(); @@ -183,52 +180,45 @@ public void controlMoved(ControlEvent e) { toolTip.setFont(new Font(null, "Arial", 10, SWT.BOLD)); toolTip.setBackgroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); canvas.addMouseListener(new MouseListener() { + Trace nearestTrace = null; + public void mouseUp(MouseEvent e) { - onDeselectObject(); + if (nearestTrace != null) { + nearestTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); + nearestTrace = null; + } toolTip.hide(); + selectedMode = false; } + public void mouseDown(MouseEvent e) { double x = xyGraph.primaryXAxis.getPositionValue(e.x, false); double y = xyGraph.primaryYAxis.getPositionValue(e.y, false); if (x < 0 || y < 0) { return; } - Image image = new Image(e.display, 1, 10); - GC gc = new GC((FigureCanvas)e.widget); - gc.copyArea(image, e.x, e.y > 5 ? e.y - 5 : 0); - ImageData imageData = image.getImageData(); - PaletteData palette = imageData.palette; - RGB white = new RGB(255, 255, 255); - int point = 5; - int offset = 0; - while (point >= 0 && point < 10) { - int pixelValue = imageData.getPixel(0, point); - RGB rgb = palette.getRGB(pixelValue); - if (white.equals(rgb) == false) { - int objHash = AgentColorManager.getInstance().getObjectHash(rgb); - if (objHash != 0) { - String objName = TextProxy.object.getText(objHash); - double time = xyGraph.primaryXAxis.getPositionValue(e.x, false); - double v = 0.0d; - for (Trace t : traces) { - if (t.getName().equals(objName)) { - v = ScouterUtil.getNearestValue(t.getDataProvider(), time); - String value = FormatUtil.print(v, "#,###.##"); - toolTip.setText(objName + "\nvalue : " + value); - toolTip.show(new Point(e.x, e.y)); - onSelectObject(objHash, objName, objType); - break; - } - } - break; + double minDistance = 30.0d; + double value = 0; + for (Trace t : traces) { + ISample s = ScouterUtil.getNearestPoint(t.getDataProvider(), x); + if (s != null) { + int x2 = xyGraph.primaryXAxis.getValuePosition(s.getXValue(), false); + int y2 = xyGraph.primaryYAxis.getValuePosition(s.getYValue(), false); + double distance = ScouterUtil.getPointDistance(e.x, e.y, x2, y2); + if (minDistance > distance) { + minDistance = distance; + nearestTrace = t; + value = s.getYValue(); } } - offset = offset >= 0 ? offset + 1 : offset - 1; - offset *= -1; - point += offset; } - gc.dispose(); - image.dispose(); + if (nearestTrace != null) { + int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); + nearestTrace.setLineWidth(width + 2); + toolTip.setText(nearestTrace.getName() + "\nvalue : " + FormatUtil.print(value, "#,###.##")); + toolTip.show(new Point(e.x, e.y)); + selectedMode = true; + } } public void mouseDoubleClick(MouseEvent e) {} }); @@ -270,7 +260,7 @@ public void run() { counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter); counterUnit = server.getCounterEngine().getCounterUnit(objType, counter); } - desc = "ⓢ" + svrName + " | (Realtime) All " + counterDisplay + (!"".equals(counterUnit) ? " (" + counterUnit + ")" : ""); + desc = "ⓢ" + svrName + " | (Current All) " + counterDisplay + (!"".equals(counterUnit) ? " (" + counterUnit + ")" : ""); try { setViewTab(objType, counter, serverId); } catch (Exception e1) { @@ -491,38 +481,6 @@ public void redraw() { } } - boolean selectedMode = false; - - public void onSelectObject(int objHash, final String objName, String objType) { - if (this.objType.equals(objType) == false) { - return; - } - ExUtil.exec(canvas, new Runnable() { - public void run() { - int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); - for (Trace t : traces) { - if (t.getName().equals(objName)) { - t.setLineWidth(width + 2); - selectedMode = true; - break; - } - } - } - }); - } - - public void onDeselectObject() { - ExUtil.exec(canvas, new Runnable() { - public void run() { - int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); - for (Trace t : traces) { - t.setLineWidth(width); - } - selectedMode = false; - } - }); - } - public void notifyChangeState() { ExUtil.asyncRun(new Runnable() { public void run() { diff --git a/scouter.client/src/scouter/client/util/ScouterUtil.java b/scouter.client/src/scouter/client/util/ScouterUtil.java index dea5e33cf..bc4589eaa 100644 --- a/scouter.client/src/scouter/client/util/ScouterUtil.java +++ b/scouter.client/src/scouter/client/util/ScouterUtil.java @@ -48,15 +48,12 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.part.ViewPart; import scouter.client.Images; import scouter.client.constants.MenuStr; import scouter.client.group.GroupManager; import scouter.client.model.AgentModelThread; import scouter.client.model.AgentObject; -import scouter.client.model.DetachedManager; import scouter.client.net.INetReader; import scouter.client.net.TcpProxy; import scouter.io.DataInputX; @@ -523,6 +520,45 @@ public static double getNearestValue(IDataProvider provider, double time) { } } } + + public static ISample getNearestPoint(IDataProvider provider, double time) { + int high = provider.getSize() - 1; + int low = 0; + while (true) { + int mid = (high + low) / 2; + ISample s = provider.getSample(mid); + double x = s.getXValue(); + if (x == time) { + return s; + } else { + if (x > time) { + high = mid; + } else { + low = mid; + } + if ((high - low) <= 1) { + ISample highSample = provider.getSample(high); + ISample lowSample = provider.getSample(low); + if (highSample == null && lowSample == null) { + return null; + } + if (highSample == null) { + return lowSample; + } + if (lowSample == null) { + return highSample; + } + double highGap = highSample.getXValue() - time; + double lowGqp = time - lowSample.getXValue(); + if (highGap < lowGqp) { + return highSample; + } else { + return lowSample; + } + } + } + } + } public static String humanReadableByteCount(long bytes, boolean si) { int unit = 1024; @@ -547,4 +583,8 @@ public static void addHorizontalRangeListener(PlotArea plotArea, PropertyChangeL plotArea.enableZoom(withZoom); plotArea.addPropertyChangeListener("horizontal_range", listener); } + + public static double getPointDistance(double x1, double y1, double x2, double y2) { + return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)); + } } From c177f31249f26734710a8da9ebc6900da7549111 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Sat, 13 Feb 2016 15:58:10 +0900 Subject: [PATCH 03/11] change line selecting way --- .../views/CounterPastLongDateAllView.java | 55 ++++++++++- .../counter/views/CounterPastTimeAllView.java | 53 ++++++++++- .../counter/views/CounterRealTimeAllView.java | 7 +- .../views/CounterRealTimeTotalView.java | 2 +- .../counter/views/CounterTodayAllView.java | 95 ++++++------------- .../counter/views/CounterTodayTotalView.java | 2 +- 6 files changed, 134 insertions(+), 80 deletions(-) diff --git a/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java b/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java index 9b4b397db..caf9b3a2e 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java @@ -26,6 +26,7 @@ import java.util.Map; import org.csstudio.swt.xygraph.dataprovider.CircularBufferDataProvider; +import org.csstudio.swt.xygraph.dataprovider.ISample; import org.csstudio.swt.xygraph.dataprovider.Sample; import org.csstudio.swt.xygraph.figures.Trace; import org.csstudio.swt.xygraph.figures.Trace.PointStyle; @@ -40,13 +41,18 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.window.DefaultToolTip; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -79,6 +85,7 @@ import scouter.client.util.ExUtil; import scouter.client.util.ImageUtil; import scouter.client.util.MenuUtil; +import scouter.client.util.ScouterUtil; import scouter.client.util.TimeUtil; import scouter.client.util.TimedSeries; import scouter.client.util.UIUtil; @@ -104,6 +111,7 @@ public class CounterPastLongDateAllView extends ScouterViewPart implements DualC Combo periodCombo; Composite headerComp; Button applyBtn; + Trace nearestTrace; IWorkbenchWindow window; IToolBarManager man; @@ -135,9 +143,9 @@ public void setInput(String sDate, String eDate, String objType, String counter, if(server != null){ counterUnit = server.getCounterEngine().getCounterUnit(objType, counter); counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter); - desc = "(Period) [" + sDate.substring(0, 4) + "-" + sDate.substring(4, 6) + "-" + sDate.substring(6, 8) + + desc = "(Daily All) [" + sDate.substring(0, 4) + "-" + sDate.substring(4, 6) + "-" + sDate.substring(6, 8) + " ~ " + eDate.substring(0, 4) + "-" + eDate.substring(4, 6) + "-" + eDate.substring(6, 8) + - "] All " + counterDisplay; + "]" + counterDisplay; } serverText.setText("ⓢ"+((server == null)? "?":server.getName())+" |"+(!"".equals(counterUnit)?" ("+counterUnit+")":"")); sDateText.setText(DateUtil.format(stime, "yyyy-MM-dd")); @@ -296,7 +304,48 @@ public void controlMoved(ControlEvent e) { man = getViewSite().getActionBars().getToolBarManager(); - + final DefaultToolTip toolTip = new DefaultToolTip(canvas, DefaultToolTip.RECREATE, true); + toolTip.setFont(new Font(null, "Arial", 10, SWT.BOLD)); + toolTip.setBackgroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + canvas.addMouseListener(new MouseListener() { + public void mouseUp(MouseEvent e) { + if (nearestTrace != null) { + nearestTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); + nearestTrace = null; + } + toolTip.hide(); + } + + public void mouseDown(MouseEvent e) { + double x = xyGraph.primaryXAxis.getPositionValue(e.x, false); + double y = xyGraph.primaryYAxis.getPositionValue(e.y, false); + if (x < 0 || y < 0) { + return; + } + double minDistance = 30.0d; + double value = 0; + for (Trace t : traces.values()) { + ISample s = ScouterUtil.getNearestPoint(t.getDataProvider(), x); + if (s != null) { + int x2 = xyGraph.primaryXAxis.getValuePosition(s.getXValue(), false); + int y2 = xyGraph.primaryYAxis.getValuePosition(s.getYValue(), false); + double distance = ScouterUtil.getPointDistance(e.x, e.y, x2, y2); + if (minDistance > distance) { + minDistance = distance; + nearestTrace = t; + value = s.getYValue(); + } + } + } + if (nearestTrace != null) { + int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); + nearestTrace.setLineWidth(width + 2); + toolTip.setText(nearestTrace.getName() + "\nvalue : " + FormatUtil.print(value, "#,###.##")); + toolTip.show(new Point(e.x, e.y)); + } + } + public void mouseDoubleClick(MouseEvent e) {} + }); canvas.addKeyListener(new KeyListener() { public void keyReleased(KeyEvent e) { } diff --git a/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java b/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java index 3bdfa4cf6..c20efec49 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java @@ -27,6 +27,7 @@ import java.util.Map; import org.csstudio.swt.xygraph.dataprovider.CircularBufferDataProvider; +import org.csstudio.swt.xygraph.dataprovider.ISample; import org.csstudio.swt.xygraph.dataprovider.Sample; import org.csstudio.swt.xygraph.figures.Trace; import org.csstudio.swt.xygraph.figures.Trace.PointStyle; @@ -41,11 +42,16 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.window.DefaultToolTip; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -78,6 +84,7 @@ import scouter.client.util.ExUtil; import scouter.client.util.ImageUtil; import scouter.client.util.MenuUtil; +import scouter.client.util.ScouterUtil; import scouter.client.util.TimeUtil; import scouter.client.util.TimedSeries; import scouter.client.util.UIUtil; @@ -102,6 +109,7 @@ public class CounterPastTimeAllView extends ScouterViewPart implements CalendarD Label serverText, sDateText, sTimeText, eTimeText; CalendarDialog calDialog; Composite headerComp; + Trace nearestTrace; IWorkbenchWindow window; IToolBarManager man; @@ -123,7 +131,7 @@ public void setInput(long stime, long etime, String objType, String counter, int String counterDisplay = ""; if(server != null){ counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter); - desc = "(Past) [" + DateUtil.format(stime, "yyyy-MM-dd HH:mm:ss") + " ~ " + DateUtil.format(etime, "HH:mm:ss") + "] All " + counterDisplay; + desc = "(Past All) [" + DateUtil.format(stime, "yyyy-MM-dd HH:mm:ss") + " ~ " + DateUtil.format(etime, "HH:mm:ss") + "]" + counterDisplay; } serverText.setText("ⓢ"+((server == null)? "?":server.getName())+" |"); @@ -312,7 +320,48 @@ public void controlMoved(ControlEvent e) { xyGraph.primaryXAxis.setTitle(""); xyGraph.primaryYAxis.setTitle(""); - + final DefaultToolTip toolTip = new DefaultToolTip(canvas, DefaultToolTip.RECREATE, true); + toolTip.setFont(new Font(null, "Arial", 10, SWT.BOLD)); + toolTip.setBackgroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + canvas.addMouseListener(new MouseListener() { + public void mouseUp(MouseEvent e) { + if (nearestTrace != null) { + nearestTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); + nearestTrace = null; + } + toolTip.hide(); + } + + public void mouseDown(MouseEvent e) { + double x = xyGraph.primaryXAxis.getPositionValue(e.x, false); + double y = xyGraph.primaryYAxis.getPositionValue(e.y, false); + if (x < 0 || y < 0) { + return; + } + double minDistance = 30.0d; + double value = 0; + for (Trace t : traces.values()) { + ISample s = ScouterUtil.getNearestPoint(t.getDataProvider(), x); + if (s != null) { + int x2 = xyGraph.primaryXAxis.getValuePosition(s.getXValue(), false); + int y2 = xyGraph.primaryYAxis.getValuePosition(s.getYValue(), false); + double distance = ScouterUtil.getPointDistance(e.x, e.y, x2, y2); + if (minDistance > distance) { + minDistance = distance; + nearestTrace = t; + value = s.getYValue(); + } + } + } + if (nearestTrace != null) { + int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); + nearestTrace.setLineWidth(width + 2); + toolTip.setText(nearestTrace.getName() + "\nvalue : " + FormatUtil.print(value, "#,###.##")); + toolTip.show(new Point(e.x, e.y)); + } + } + public void mouseDoubleClick(MouseEvent e) {} + }); canvas.addKeyListener(new KeyListener() { public void keyReleased(KeyEvent e) { } diff --git a/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java b/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java index cbae36ee4..43ab39042 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java @@ -105,7 +105,7 @@ public class CounterRealTimeAllView extends ScouterViewPart implements Refreshab protected XYGraph xyGraph; protected Map datas = new HashMap(); protected FigureCanvas canvas; - boolean selectedMode = false; + Trace nearestTrace; ArrayList traces = new ArrayList(); @@ -180,7 +180,6 @@ public void controlMoved(ControlEvent e) { toolTip.setFont(new Font(null, "Arial", 10, SWT.BOLD)); toolTip.setBackgroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); canvas.addMouseListener(new MouseListener() { - Trace nearestTrace = null; public void mouseUp(MouseEvent e) { if (nearestTrace != null) { @@ -188,7 +187,6 @@ public void mouseUp(MouseEvent e) { nearestTrace = null; } toolTip.hide(); - selectedMode = false; } public void mouseDown(MouseEvent e) { @@ -217,7 +215,6 @@ public void mouseDown(MouseEvent e) { nearestTrace.setLineWidth(width + 2); toolTip.setText(nearestTrace.getName() + "\nvalue : " + FormatUtil.print(value, "#,###.##")); toolTip.show(new Point(e.x, e.y)); - selectedMode = true; } } public void mouseDoubleClick(MouseEvent e) {} @@ -345,7 +342,7 @@ public void run() { int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); synchronized (traces) { for (Trace t : traces) { - if (selectedMode == false && t.getLineWidth() != width) { + if (nearestTrace == null && t.getLineWidth() != width) { t.setLineWidth(width); } int objHash = HashUtil.hash(t.getName()); diff --git a/scouter.client/src/scouter/client/counter/views/CounterRealTimeTotalView.java b/scouter.client/src/scouter/client/counter/views/CounterRealTimeTotalView.java index b1fef149b..fb1228855 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterRealTimeTotalView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterRealTimeTotalView.java @@ -194,7 +194,7 @@ public void run() { counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter); counterUnit = server.getCounterEngine().getCounterUnit(objType, counter); } - desc = "ⓢ"+svrName+" | (Realtime) Total " + counterDisplay + (!"".equals(counterUnit)?" ("+counterUnit+")":""); + desc = "ⓢ"+svrName+" | (Current Total) " + counterDisplay + (!"".equals(counterUnit)?" ("+counterUnit+")":""); try { setViewTab(objType, counter, serverId); } catch (Exception e1) { diff --git a/scouter.client/src/scouter/client/counter/views/CounterTodayAllView.java b/scouter.client/src/scouter/client/counter/views/CounterTodayAllView.java index 33928bc74..3fdec773d 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterTodayAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterTodayAllView.java @@ -23,6 +23,7 @@ import java.util.Map; import org.csstudio.swt.xygraph.dataprovider.CircularBufferDataProvider; +import org.csstudio.swt.xygraph.dataprovider.ISample; import org.csstudio.swt.xygraph.dataprovider.Sample; import org.csstudio.swt.xygraph.figures.Trace; import org.csstudio.swt.xygraph.figures.Trace.PointStyle; @@ -101,6 +102,7 @@ public class CounterTodayAllView extends ScouterViewPart implements Refreshable, IWorkbenchWindow window; IToolBarManager man; + Trace nearestTrace; public void init(IViewSite site) throws PartInitException { super.init(site); @@ -187,7 +189,7 @@ public void run() { int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); synchronized (traces) { for (Trace t : traces) { - if (selectedMode == false && t.getLineWidth() != width) { + if (nearestTrace == null && t.getLineWidth() != width) { t.setLineWidth(width); } int objHash = HashUtil.hash(t.getName()); @@ -283,51 +285,40 @@ public void controlMoved(ControlEvent e) { toolTip.setBackgroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); canvas.addMouseListener(new MouseListener() { public void mouseUp(MouseEvent e) { - onDeselectObject(); + if (nearestTrace != null) { + nearestTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); + nearestTrace = null; + } toolTip.hide(); } + public void mouseDown(MouseEvent e) { double x = xyGraph.primaryXAxis.getPositionValue(e.x, false); double y = xyGraph.primaryYAxis.getPositionValue(e.y, false); if (x < 0 || y < 0) { return; } - Image image = new Image(e.display, 1, 10); - GC gc = new GC((FigureCanvas)e.widget); - gc.copyArea(image, e.x, e.y > 5 ? e.y - 5 : 0); - ImageData imageData = image.getImageData(); - PaletteData palette = imageData.palette; - RGB white = new RGB(255, 255, 255); - int point = 5; - int offset = 0; - while (point >= 0 && point < 10) { - int pixelValue = imageData.getPixel(0, point); - RGB rgb = palette.getRGB(pixelValue); - if (white.equals(rgb) == false) { - int objHash = AgentColorManager.getInstance().getObjectHash(rgb); - if (objHash != 0) { - String objName = TextProxy.object.getText(objHash); - double time = xyGraph.primaryXAxis.getPositionValue(e.x, false); - double v = 0.0d; - for (Trace t : traces) { - if (t.getName().equals(objName)) { - v = ScouterUtil.getNearestValue(t.getDataProvider(), time); - String value = FormatUtil.print(v, "#,###.##"); - toolTip.setText(objName + "\nvalue : " + value); - toolTip.show(new Point(e.x, e.y)); - onSelectObject(objHash, objName, objType); - break; - } - } - break; + double minDistance = 30.0d; + double value = 0; + for (Trace t : traces) { + ISample s = ScouterUtil.getNearestPoint(t.getDataProvider(), x); + if (s != null) { + int x2 = xyGraph.primaryXAxis.getValuePosition(s.getXValue(), false); + int y2 = xyGraph.primaryYAxis.getValuePosition(s.getYValue(), false); + double distance = ScouterUtil.getPointDistance(e.x, e.y, x2, y2); + if (minDistance > distance) { + minDistance = distance; + nearestTrace = t; + value = s.getYValue(); } } - offset = offset >= 0 ? offset + 1 : offset - 1; - offset *= -1; - point += offset; } - gc.dispose(); - image.dispose(); + if (nearestTrace != null) { + int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); + nearestTrace.setLineWidth(width + 2); + toolTip.setText(nearestTrace.getName() + "\nvalue : " + FormatUtil.print(value, "#,###.##")); + toolTip.show(new Point(e.x, e.y)); + } } public void mouseDoubleClick(MouseEvent e) {} }); @@ -358,7 +349,7 @@ public void keyPressed(KeyEvent e) { counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter); counterUnit = server.getCounterEngine().getCounterUnit(objType, counter); } - desc = "ⓢ"+svrName+" | (Today) [" + date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8) + "] All " + counterDisplay+(!"".equals(counterUnit)?" ("+counterUnit+")":""); + desc = "ⓢ"+svrName+" | (Today All) [" + date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8) + "]" + counterDisplay+(!"".equals(counterUnit)?" ("+counterUnit+")":""); try { setViewTab(objType, counter, serverId); } catch (Exception e1) { @@ -412,38 +403,6 @@ public void dispose() { ObjectSelectManager.getInstance().removeObjectCheckStateListener(this); } - boolean selectedMode = false; - - public void onSelectObject(int objHash, final String objName, String objType) { - if (this.objType.equals(objType) == false) { - return; - } - ExUtil.exec(canvas, new Runnable() { - public void run() { - int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); - for (Trace t : traces) { - if (t.getName().equals(objName)) { - t.setLineWidth(width + 2); - selectedMode = true; - break; - } - } - } - }); - } - - public void onDeselectObject() { - ExUtil.exec(canvas, new Runnable() { - public void run() { - int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); - for (Trace t : traces) { - t.setLineWidth(width); - } - selectedMode = false; - } - }); - } - public void redraw() { if (canvas != null && canvas.isDisposed() == false) { canvas.redraw(); diff --git a/scouter.client/src/scouter/client/counter/views/CounterTodayTotalView.java b/scouter.client/src/scouter/client/counter/views/CounterTodayTotalView.java index 04503164b..b783d78d5 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterTodayTotalView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterTodayTotalView.java @@ -291,7 +291,7 @@ public void keyPressed(KeyEvent e) { counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter); counterUnit = server.getCounterEngine().getCounterUnit(objType, counter); } - desc = "ⓢ"+svrName+" | (Today) [" + date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8) + "] Total " + counterDisplay+(!"".equals(counterUnit)?" ("+counterUnit+")":""); + desc = "ⓢ"+svrName+" | (Today Total) [" + date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8) + "]" + counterDisplay+(!"".equals(counterUnit)?" ("+counterUnit+")":""); try { setViewTab(objType, counter, serverId); } catch (Exception e1) { From 660d9321d2c2e809e1bd3503c09fceebcddc8500 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Mon, 15 Feb 2016 10:35:33 +0900 Subject: [PATCH 04/11] add time in tooltip --- .../client/counter/views/CounterPastLongDateAllView.java | 6 +++++- .../client/counter/views/CounterPastTimeAllView.java | 6 +++++- .../client/counter/views/CounterRealTimeAllView.java | 6 +++++- .../scouter/client/counter/views/CounterTodayAllView.java | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java b/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java index caf9b3a2e..2a987636a 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java @@ -323,6 +323,7 @@ public void mouseDown(MouseEvent e) { return; } double minDistance = 30.0d; + long time = 0; double value = 0; for (Trace t : traces.values()) { ISample s = ScouterUtil.getNearestPoint(t.getDataProvider(), x); @@ -333,6 +334,7 @@ public void mouseDown(MouseEvent e) { if (minDistance > distance) { minDistance = distance; nearestTrace = t; + time = (long) s.getXValue(); value = s.getYValue(); } } @@ -340,7 +342,9 @@ public void mouseDown(MouseEvent e) { if (nearestTrace != null) { int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); nearestTrace.setLineWidth(width + 2); - toolTip.setText(nearestTrace.getName() + "\nvalue : " + FormatUtil.print(value, "#,###.##")); + toolTip.setText(nearestTrace.getName() + + "\nTime : " + DateUtil.format(time, "HH:mm") + + "\nValue : " + FormatUtil.print(value, "#,###.##")); toolTip.show(new Point(e.x, e.y)); } } diff --git a/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java b/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java index c20efec49..a26daa563 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java @@ -339,6 +339,7 @@ public void mouseDown(MouseEvent e) { return; } double minDistance = 30.0d; + long time = 0; double value = 0; for (Trace t : traces.values()) { ISample s = ScouterUtil.getNearestPoint(t.getDataProvider(), x); @@ -349,6 +350,7 @@ public void mouseDown(MouseEvent e) { if (minDistance > distance) { minDistance = distance; nearestTrace = t; + time = (long) s.getXValue(); value = s.getYValue(); } } @@ -356,7 +358,9 @@ public void mouseDown(MouseEvent e) { if (nearestTrace != null) { int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); nearestTrace.setLineWidth(width + 2); - toolTip.setText(nearestTrace.getName() + "\nvalue : " + FormatUtil.print(value, "#,###.##")); + toolTip.setText(nearestTrace.getName() + + "\nTime : " + DateUtil.format(time, "HH:mm:ss") + + "\nValue : " + FormatUtil.print(value, "#,###.##")); toolTip.show(new Point(e.x, e.y)); } } diff --git a/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java b/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java index 43ab39042..935545102 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java @@ -196,6 +196,7 @@ public void mouseDown(MouseEvent e) { return; } double minDistance = 30.0d; + long time = 0; double value = 0; for (Trace t : traces) { ISample s = ScouterUtil.getNearestPoint(t.getDataProvider(), x); @@ -206,6 +207,7 @@ public void mouseDown(MouseEvent e) { if (minDistance > distance) { minDistance = distance; nearestTrace = t; + time = (long) s.getXValue(); value = s.getYValue(); } } @@ -213,7 +215,9 @@ public void mouseDown(MouseEvent e) { if (nearestTrace != null) { int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); nearestTrace.setLineWidth(width + 2); - toolTip.setText(nearestTrace.getName() + "\nvalue : " + FormatUtil.print(value, "#,###.##")); + toolTip.setText(nearestTrace.getName() + + "\nTime : " + DateUtil.format(time, "HH:mm:ss") + + "\nValue : " + FormatUtil.print(value, "#,###.##")); toolTip.show(new Point(e.x, e.y)); } } diff --git a/scouter.client/src/scouter/client/counter/views/CounterTodayAllView.java b/scouter.client/src/scouter/client/counter/views/CounterTodayAllView.java index 3fdec773d..634b184af 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterTodayAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterTodayAllView.java @@ -299,6 +299,7 @@ public void mouseDown(MouseEvent e) { return; } double minDistance = 30.0d; + long time = 0; double value = 0; for (Trace t : traces) { ISample s = ScouterUtil.getNearestPoint(t.getDataProvider(), x); @@ -309,6 +310,7 @@ public void mouseDown(MouseEvent e) { if (minDistance > distance) { minDistance = distance; nearestTrace = t; + time = (long) s.getXValue(); value = s.getYValue(); } } @@ -316,7 +318,9 @@ public void mouseDown(MouseEvent e) { if (nearestTrace != null) { int width = PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH); nearestTrace.setLineWidth(width + 2); - toolTip.setText(nearestTrace.getName() + "\nvalue : " + FormatUtil.print(value, "#,###.##")); + toolTip.setText(nearestTrace.getName() + + "\nTime : " + DateUtil.format(time, "HH:mm") + + "\nValue : " + FormatUtil.print(value, "#,###.##")); toolTip.show(new Point(e.x, e.y)); } } From 18af57af9fee92e26f4d2e29a350440cd4dcb29c Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Mon, 15 Feb 2016 13:48:19 +0900 Subject: [PATCH 05/11] change total value finding way --- .../src/scouter/client/util/ScouterUtil.java | 57 +++++++++---------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/scouter.client/src/scouter/client/util/ScouterUtil.java b/scouter.client/src/scouter/client/util/ScouterUtil.java index bc4589eaa..99bcca6d0 100644 --- a/scouter.client/src/scouter/client/util/ScouterUtil.java +++ b/scouter.client/src/scouter/client/util/ScouterUtil.java @@ -41,12 +41,7 @@ import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import scouter.client.Images; @@ -265,34 +260,34 @@ public void mouseUp(MouseEvent e) { } public void mouseDown(MouseEvent e) { - Image image = new Image(e.display, 1, 10); - GC gc = new GC((FigureCanvas) e.widget); - gc.copyArea(image, e.x, e.y > 5 ? e.y - 5 : 0); - ImageData imageData = image.getImageData(); - PaletteData palette = imageData.palette; - int point = 5; - int offset = 0; - while (point >= 0 && point < 10) { - int pixelValue = imageData.getPixel(0, point); - RGB rgb = palette.getRGB(pixelValue); - if (ColorUtil.getInstance().TOTAL_CHART_COLOR.getRGB().equals(rgb)) { - double time = xyGraph.primaryXAxis.getPositionValue(e.x, false); - Trace t = xyGraph.getPlotArea().getTraceList().get(0); - if (t == null) { - return; - } - double d = getNearestValue(t.getDataProvider(), time); - String value = FormatUtil.print(d, "#,###.##"); - toolTip.setText("value : " + value); - toolTip.show(new Point(e.x, e.y)); - break; + double x = xyGraph.primaryXAxis.getPositionValue(e.x, false); + double y = xyGraph.primaryYAxis.getPositionValue(e.y, false); + if (x < 0 || y < 0) { + return; + } + double minDistance = 30.0d; + long time = 0; + double value = 0; + Trace t = xyGraph.getPlotArea().getTraceList().get(0); + if (t == null) { + return; + } + ISample s = getNearestPoint(t.getDataProvider(), x); + if (s != null) { + int x2 = xyGraph.primaryXAxis.getValuePosition(s.getXValue(), false); + int y2 = xyGraph.primaryYAxis.getValuePosition(s.getYValue(), false); + double distance = ScouterUtil.getPointDistance(e.x, e.y, x2, y2); + if (minDistance > distance) { + minDistance = distance; + time = (long) s.getXValue(); + value = s.getYValue(); } - offset = offset >= 0 ? offset + 1 : offset - 1; - offset *= -1; - point += offset; } - gc.dispose(); - image.dispose(); + if (t != null) { + toolTip.setText("Time : " + DateUtil.format(time, "HH:mm:ss") + + "\nValue : " + FormatUtil.print(value, "#,###.##")); + toolTip.show(new Point(e.x, e.y)); + } } public void mouseDoubleClick(MouseEvent e) { From df210293d4d676c45fdb84c47bacdf5720707999 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Thu, 18 Feb 2016 11:30:39 +0900 Subject: [PATCH 06/11] bug fix --- scouter.client/src/scouter/client/util/ScouterUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scouter.client/src/scouter/client/util/ScouterUtil.java b/scouter.client/src/scouter/client/util/ScouterUtil.java index 99bcca6d0..834cea69d 100644 --- a/scouter.client/src/scouter/client/util/ScouterUtil.java +++ b/scouter.client/src/scouter/client/util/ScouterUtil.java @@ -519,7 +519,7 @@ public static double getNearestValue(IDataProvider provider, double time) { public static ISample getNearestPoint(IDataProvider provider, double time) { int high = provider.getSize() - 1; int low = 0; - while (true) { + while (high >= low) { int mid = (high + low) / 2; ISample s = provider.getSample(mid); double x = s.getXValue(); @@ -553,6 +553,7 @@ public static ISample getNearestPoint(IDataProvider provider, double time) { } } } + return null; } public static String humanReadableByteCount(long bytes, boolean si) { From 5b8aa4a75779ae383bda802ab97e52a31aef5dae Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Thu, 18 Feb 2016 14:55:41 +0900 Subject: [PATCH 07/11] bug fix - chart buffer size --- .../scouter/client/counter/views/CounterPastTimeAllView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java b/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java index a26daa563..2bf087c8a 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java @@ -454,7 +454,7 @@ private synchronized Trace intern(int objHash) { return trace; CircularBufferDataProvider traceDataProvider = new CircularBufferDataProvider(true); - traceDataProvider.setBufferSize(7200); + traceDataProvider.setBufferSize((int) ((endTime - startTime) / (DateUtil.MILLIS_PER_SECOND * 2)) + 1); traceDataProvider.setCurrentXDataArray(new double[] {}); traceDataProvider.setCurrentYDataArray(new double[] {}); From 988847bc4be9ecafa2e386425da67dce46d74e02 Mon Sep 17 00:00:00 2001 From: Gunhee Lee Date: Sun, 21 Feb 2016 23:01:26 +0900 Subject: [PATCH 08/11] refactoring - rename method - TraceContextManager.getLocalContext() --> getContext() --- scouter.agent.java/src/scouter/AnyTrace.java | 10 ++--- .../src/scouter/agent/plugin/WrContext.java | 2 +- .../src/scouter/agent/trace/TraceApiCall.java | 10 ++--- .../agent/trace/TraceContextManager.java | 6 +-- .../src/scouter/agent/trace/TraceMain.java | 24 +++++------ .../src/scouter/agent/trace/TraceSQL.java | 40 +++++++++---------- .../src/scouter/jdbc/DetectConnection.java | 8 ++-- 7 files changed, 49 insertions(+), 51 deletions(-) diff --git a/scouter.agent.java/src/scouter/AnyTrace.java b/scouter.agent.java/src/scouter/AnyTrace.java index 2555ec137..43ba332c7 100644 --- a/scouter.agent.java/src/scouter/AnyTrace.java +++ b/scouter.agent.java/src/scouter/AnyTrace.java @@ -18,13 +18,11 @@ package scouter; import scouter.agent.netio.data.DataProxy; -import scouter.agent.trace.AlertProxy; import scouter.agent.trace.TraceApiCall; import scouter.agent.trace.TraceContext; import scouter.agent.trace.TraceContextManager; import scouter.agent.trace.TraceMain; import scouter.lang.pack.XLogTypes; -import scouter.util.HashUtil; import scouter.util.KeyGen; public class AnyTrace { @@ -42,7 +40,7 @@ public static void setServiceName(String name) { } public static void serviceError(String emsg) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null && ctx.error != 0) { // already started ctx.error = DataProxy.sendError(emsg); } @@ -70,7 +68,7 @@ public static Object startApicall(String name, long apiTxid) { public static void setApicallName(String name) { try { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { if (ctx.apicall_name != null) { // already started subcall only ctx.apicall_name = name; @@ -86,7 +84,7 @@ public static void endApicall(Object stat, Throwable thr) { public static void desc(String desc) { try { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { ctx.desc = desc; } @@ -96,7 +94,7 @@ public static void desc(String desc) { public static void login(String login) { try { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { ctx.login = login; } diff --git a/scouter.agent.java/src/scouter/agent/plugin/WrContext.java b/scouter.agent.java/src/scouter/agent/plugin/WrContext.java index 99364ad1d..e23d4b83e 100644 --- a/scouter.agent.java/src/scouter/agent/plugin/WrContext.java +++ b/scouter.agent.java/src/scouter/agent/plugin/WrContext.java @@ -101,7 +101,7 @@ public void profile(String msg) { /** * add xlog profile - * profile diplay like --> msg #value elapsed + * profile display like --> msg #value elapsed * @param msg message * @param value any value to display on a profile. * @param elapsed any value to display on a profile. diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java b/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java index b6bafa527..177241c3f 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java @@ -53,14 +53,14 @@ public Stat(TraceContext ctx) { } } public static void apiInfo(String className, String methodName, String methodDesc, Object _this, Object[] arg) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null && arg.length >= 2) { ctx.apicall_target = arg[0] + ":" + arg[1]; } } public static Object startApicall(String className, String methodName, String methodDesc, Object _this, Object[] arg) { try { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) { return null; } @@ -85,7 +85,7 @@ public static Object startApicall(String className, String methodName, String me return null; } public static Object startApicall(String name, long apiTxid) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return null; if (ctx.apicall_name != null) { @@ -153,7 +153,7 @@ public static void endApicall(Object stat, Object returnValue, Throwable thr) { public static Object startSocket(Socket socket, SocketAddress addr, int timeout) { if (!(addr instanceof InetSocketAddress)) return null; - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) { if (Configure.getInstance().trace_background_socket_enabled) { InetSocketAddress inet = (InetSocketAddress) addr; @@ -211,7 +211,7 @@ public static void endSocket(Object stat, Throwable thr) { } } public static void open(File file) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { MessageStep m = new MessageStep(); m.start_time = (int) (System.currentTimeMillis() - ctx.startTime); diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceContextManager.java b/scouter.agent.java/src/scouter/agent/trace/TraceContextManager.java index d063da231..f9bc6698d 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceContextManager.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceContextManager.java @@ -17,12 +17,12 @@ package scouter.agent.trace; -import java.util.Enumeration; - import scouter.agent.Configure; import scouter.util.LongEnumer; import scouter.util.LongKeyMap; +import java.util.Enumeration; + public class TraceContextManager { private static LongKeyMap entry = new LongKeyMap(); @@ -66,7 +66,7 @@ public static TraceContext getContext(long key) { return entry.get(key); } - public static TraceContext getLocalContext() { + public static TraceContext getContext() { return local.get(); } diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java index 4eac04cb9..523b37318 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java @@ -64,7 +64,7 @@ public Stat(TraceContext ctx) { public static Object startHttpService(Object req, Object res) { try { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { return null; } @@ -77,7 +77,7 @@ public static Object startHttpService(Object req, Object res) { public static Object startHttpFilter(Object req, Object res) { try { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { return null; } @@ -206,7 +206,7 @@ public static void endHttpService(Object stat, Throwable thr) { if (thr == null) return; try { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null && ctx.error == 0) { Configure conf = Configure.getInstance(); String emsg = thr.toString(); @@ -350,7 +350,7 @@ public static boolean isStaticContents(String serviceName) { public static Object startService(String name, String className, String methodName, String methodDesc, Object _this, Object[] arg, byte xType) { try { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { return null; } @@ -484,7 +484,7 @@ private static int errorCheck(TraceContext ctx, Throwable thr) { } public static void capArgs(String className, String methodName, String methodDesc, Object this1, Object[] arg) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; // MessageStep step = new MessageStep(); @@ -499,7 +499,7 @@ public static void capArgs(String className, String methodName, String methodDes } public static void jspServlet(Object[] arg) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null || arg.length < 3) return; HashedMessageStep step = new HashedMessageStep(); @@ -556,7 +556,7 @@ private static String toStringTHIS(String type, String className, String methodD } public static void capThis(String className, String methodDesc, Object this0) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; // MessageStep step = new MessageStep(); @@ -571,7 +571,7 @@ public static void capThis(String className, String methodDesc, Object this0) { } public static void capReturn(String className, String methodName, String methodDesc, Object this1, Object rtn) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; PluginCaptureTrace.capReturn(ctx, new HookReturn(className, methodName, methodDesc, this1, rtn)); @@ -580,7 +580,7 @@ public static void capReturn(String className, String methodName, String methodD public static Object startMethod(int hash, String classMethod) { if (conf.profile_method_enabled == false) return null; - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) { if (conf._trace_auto_service_enabled) { Object localContext = startService(classMethod, null, null, null, null, null, XLogTypes.APP_SERVICE); @@ -630,7 +630,7 @@ public static void endMethod(Object localContext, Throwable thr) { } public static void setServiceName(String name) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null || name == null) return; ctx.serviceName = name; @@ -638,7 +638,7 @@ public static void setServiceName(String name) { } public static void setStatus(int httpStatus) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; ctx.status = httpStatus; @@ -669,7 +669,7 @@ public static XLogPack txperf(long endtime, long txid, int service_hash, String } public static void addMessage(String msg) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; MessageStep p = new MessageStep(); diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java b/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java index 99e3a64a1..58e238e27 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java @@ -61,42 +61,42 @@ public class TraceSQL { static DBURL unknown = new DBURL(0, null); public static void set(int idx, boolean p) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { ctx.sql.put(idx, Boolean.toString(p)); } } public static void set(int idx, int p) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { ctx.sql.put(idx, Integer.toString(p)); } } public static void set(int idx, float p) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { ctx.sql.put(idx, Float.toString(p)); } } public static void set(int idx, long p) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { ctx.sql.put(idx, Long.toString(p)); } } public static void set(int idx, double p) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { ctx.sql.put(idx, Double.toString(p)); } } public static void set(int idx, String p) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { if (p == null) { ctx.sql.put(idx, "null"); @@ -108,7 +108,7 @@ public static void set(int idx, String p) { } public static void set(int idx, Object p) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { if (p == null) { ctx.sql.put(idx, "null"); @@ -120,14 +120,14 @@ public static void set(int idx, Object p) { } public static void clear(Object o) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { ctx.sql.clear(); } } public static Object start(Object o) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) { return null; } @@ -151,7 +151,7 @@ public static Object start(Object o) { } public static Object start(Object o, String sql, byte methodType) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) { if (conf._log_background_sql) { Logger.println("background: " + sql); @@ -290,14 +290,14 @@ public static void end(Object stat, Throwable thr, int updatedCount) { tCtx.profile.pop(step); } public static void prepare(Object o, String sql) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { ctx.sql.clear(); ctx.sql.setSql(sql); } } public static boolean rsnext(boolean b) { - TraceContext c = TraceContextManager.getLocalContext(); + TraceContext c = TraceContextManager.getContext(); if (c != null) { if (b) { if (c.rs_start == 0) { @@ -334,7 +334,7 @@ private static void fetch(TraceContext c) { } public static void rsclose(Object rs) { - TraceContext c = TraceContextManager.getLocalContext(); + TraceContext c = TraceContextManager.getContext(); if (c != null) { if (c.rs_start != 0) { fetch(c); @@ -402,7 +402,7 @@ public static void clear(Object o, SqlParameter args) { } public static Object start(Object o, SqlParameter args, byte methodType) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) { if (conf._log_background_sql && args != null) { Logger.println("background: " + args.getSql()); @@ -481,14 +481,14 @@ public static Connection driverConnect(Connection conn, String url) { public static void driverConnect(String url, Throwable thr) { AlertProxy.sendAlert(AlertLevel.ERROR, "CONNECT", url + " " + thr); - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { ServiceSummary.getInstance().process(connectionOpenFailException, 0, ctx.serviceHash, ctx.txid, 0, 0); } } public static void userTxOpen() { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; ctx.userTransaction++; @@ -498,7 +498,7 @@ public static void userTxOpen() { } public static void userTxClose(String method) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; if (ctx.userTransaction > 0) { @@ -510,7 +510,7 @@ public static void userTxClose(String method) { } public static Object dbcOpenStart(int hash, String msg, Object pool) { - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return null; if (conf.profile_connection_open_enabled == false) @@ -647,7 +647,7 @@ public static void dbcOpenEnd(Object stat, Throwable thr) { public static void sqlMap(String methodName, String sqlname) { if (Configure.getInstance().profile_sqlmap_name_enabled == false) return; - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; HashedMessageStep p = new HashedMessageStep(); @@ -688,7 +688,7 @@ public static int getIntArraySum(int[] arr) { */ public static int incUpdateCount(int cnt) { Logger.trace("stmt.getUpdateCount()=" + cnt); - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) { return cnt; } diff --git a/scouter.agent.java/src/scouter/jdbc/DetectConnection.java b/scouter.agent.java/src/scouter/jdbc/DetectConnection.java index d3c39edf3..7a379a0c9 100644 --- a/scouter.agent.java/src/scouter/jdbc/DetectConnection.java +++ b/scouter.agent.java/src/scouter/jdbc/DetectConnection.java @@ -46,7 +46,7 @@ public DetectConnection(java.sql.Connection inner) { int serviceHash = 0; long txid = 0; - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx != null) { serviceHash = ctx.serviceHash; txid = ctx.txid; @@ -121,7 +121,7 @@ final public void close() throws java.sql.SQLException { this.inner.close(); long etime = System.currentTimeMillis(); - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; @@ -200,7 +200,7 @@ final public java.lang.String nativeSQL(java.lang.String a0) throws java.sql.SQL final public void setAutoCommit(boolean a0) throws java.sql.SQLException { this.inner.setAutoCommit(a0); - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; @@ -223,7 +223,7 @@ final public void commit() throws java.sql.SQLException { this.inner.commit(); long etime = System.currentTimeMillis(); - TraceContext ctx = TraceContextManager.getLocalContext(); + TraceContext ctx = TraceContextManager.getContext(); if (ctx == null) return; From 01d012ac7d40cf6260a4fe64cf085e07158d952b Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Tue, 23 Feb 2016 19:34:57 +0900 Subject: [PATCH 09/11] special menu definition xml -> code --- .../actions/OpenActiveServiceListAction.java | 4 +- .../client/actions/OpenActiveSpeedAction.java | 4 +- .../actions/OpenDailyServiceCountAction.java | 8 +- .../counter/views/CounterPastCountView.java | 2 +- .../counter/views/CounterTodayCountView.java | 2 +- .../group/view/GroupNavigationView.java | 42 ++++--- .../src/scouter/client/util/MenuUtil.java | 119 ++++-------------- .../client/views/ObjectDailyListView.java | 15 +-- .../client/views/ObjectNavigationView.java | 47 +------ .../xlog/actions/OpenXLogLoadTimeAction.java | 6 +- .../client/xlog/views/XLogLoadTimeView.java | 2 +- .../lang/counters/CounterConstants.java | 9 -- .../scouter/lang/counters/CounterEngine.java | 1 - .../src/scouter/lang/counters/counters.xml | 13 +- 14 files changed, 66 insertions(+), 208 deletions(-) diff --git a/scouter.client/src/scouter/client/actions/OpenActiveServiceListAction.java b/scouter.client/src/scouter/client/actions/OpenActiveServiceListAction.java index 52997c4d4..1a0c0c312 100644 --- a/scouter.client/src/scouter/client/actions/OpenActiveServiceListAction.java +++ b/scouter.client/src/scouter/client/actions/OpenActiveServiceListAction.java @@ -36,10 +36,10 @@ public class OpenActiveServiceListAction extends Action { private String objType; private int serverId; - public OpenActiveServiceListAction(IWorkbenchWindow window, String label, String objType, Image image, int serverId) { + public OpenActiveServiceListAction(IWorkbenchWindow window, String objType, Image image, int serverId) { this.window = window; this.serverId = serverId; - setText(label); + setText("Active Service List"); setId(ID); setImageDescriptor(ImageUtil.getImageDescriptor(image)); this.objType = objType; diff --git a/scouter.client/src/scouter/client/actions/OpenActiveSpeedAction.java b/scouter.client/src/scouter/client/actions/OpenActiveSpeedAction.java index dc8ef540d..639aabc77 100644 --- a/scouter.client/src/scouter/client/actions/OpenActiveSpeedAction.java +++ b/scouter.client/src/scouter/client/actions/OpenActiveSpeedAction.java @@ -36,11 +36,11 @@ public class OpenActiveSpeedAction extends Action { private String objType; private int serverId; - public OpenActiveSpeedAction(IWorkbenchWindow window, String label, String objType, Image image, int serverId) { + public OpenActiveSpeedAction(IWorkbenchWindow window, String objType, Image image, int serverId) { this.window = window; this.objType = objType; this.serverId = serverId; - setText(label); + setText("Active Speed"); setId(ID); setImageDescriptor(ImageUtil.getImageDescriptor(image)); } diff --git a/scouter.client/src/scouter/client/counter/actions/OpenDailyServiceCountAction.java b/scouter.client/src/scouter/client/counter/actions/OpenDailyServiceCountAction.java index 0a7e31b92..4c75c15f4 100644 --- a/scouter.client/src/scouter/client/counter/actions/OpenDailyServiceCountAction.java +++ b/scouter.client/src/scouter/client/counter/actions/OpenDailyServiceCountAction.java @@ -38,17 +38,17 @@ public class OpenDailyServiceCountAction extends Action implements CalendarDialo private int serverId; private String date; - public OpenDailyServiceCountAction(IWorkbenchWindow window, String label, String objType, String counter, Image image, int serverId) { - this(window, label, objType, counter, image, serverId, null); + public OpenDailyServiceCountAction(IWorkbenchWindow window, String objType, String counter, Image image, int serverId) { + this(window, objType, counter, image, serverId, null); } - public OpenDailyServiceCountAction(IWorkbenchWindow window, String label, String objType, String counter, Image image, int serverId, String date) { + public OpenDailyServiceCountAction(IWorkbenchWindow window, String objType, String counter, Image image, int serverId, String date) { this.window = window; this.objType = objType; this.counter = counter; this.serverId = serverId; this.date = date; - setText(label); + setText("24H Service Count"); setId(ID); setImageDescriptor(ImageUtil.getImageDescriptor(image)); } diff --git a/scouter.client/src/scouter/client/counter/views/CounterPastCountView.java b/scouter.client/src/scouter/client/counter/views/CounterPastCountView.java index bc3f93b41..26d5a246b 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterPastCountView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterPastCountView.java @@ -106,7 +106,7 @@ public void setInput(final String date, final String objType, final String count final IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); mgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager mgr) { - mgr.add(new OpenDailyServiceCountAction(win, "Load", objType, counter, Images.bar, serverId, date)); + mgr.add(new OpenDailyServiceCountAction(win, objType, counter, Images.bar, serverId, date)); } }); Menu menu = mgr.createContextMenu(canvas); diff --git a/scouter.client/src/scouter/client/counter/views/CounterTodayCountView.java b/scouter.client/src/scouter/client/counter/views/CounterTodayCountView.java index dfa4ddb02..052cdae93 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterTodayCountView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterTodayCountView.java @@ -322,7 +322,7 @@ public void mouseDoubleClick(MouseEvent e) {} final IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); mgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager mgr) { - mgr.add(new OpenDailyServiceCountAction(win, "Load", objType, counter, Images.bar, serverId)); + mgr.add(new OpenDailyServiceCountAction(win, objType, counter, Images.bar, serverId)); } }); Menu menu = mgr.createContextMenu(canvas); diff --git a/scouter.client/src/scouter/client/group/view/GroupNavigationView.java b/scouter.client/src/scouter/client/group/view/GroupNavigationView.java index b6a4cd0b8..a3015b199 100644 --- a/scouter.client/src/scouter/client/group/view/GroupNavigationView.java +++ b/scouter.client/src/scouter/client/group/view/GroupNavigationView.java @@ -204,26 +204,18 @@ public void menuAboutToShow(IMenuManager manager){ } } manager.add(new Separator()); - if (isActionEnable(objType, CounterConstants.ACTIVE_EQ)) { + if (isChildOf(objType, CounterConstants.FAMILY_JAVAEE)) { manager.add(new OpenEQGroupViewAction(win, grpObj.getName())); - } - if (isActionEnable(objType, CounterConstants.TOTAL_ACTIVE_SPEED)) { manager.add(new OpenActiveSpeedGroupViewAction(win, MenuStr.ACTIVE_SPEED_REAL, grpObj)); - } - MenuManager xLogMenu = new MenuManager(MenuStr.XLOG, ImageUtil.getImageDescriptor(Images.transrealtime), MenuStr.XLOG_ID); - manager.add(xLogMenu); - if (isActionEnable(objType, CounterConstants.TRANX_REALTIME)) { - xLogMenu.add(new OpenRealTimeTranXGroupViewAction(win, MenuStr.REALTIME_XLOG, grpObj)); - xLogMenu.add(new OpenPastTimeTranXGroupViewAction(win, MenuStr.PASTTIME_XLOG, grpObj)); - } - MenuManager scMenu = new MenuManager(MenuStr.HOURLY_CHART, ImageUtil.getImageDescriptor(Images.bar), MenuStr.HOURLY_CHART_ID); - manager.add(scMenu); - if (isActionEnable(objType, CounterConstants.TODAY_SERVICE_COUNT)) { - scMenu.add(new OpenTodayGroupCountViewAction(win, MenuStr.TODAY_SERVICE_COUNT, CounterConstants.WAS_SERVICE_COUNT, grpObj)); - scMenu.add(new OpenPastDateGroupCountViewAction(win, MenuStr.LOAD_SERVICE_COUNT, CounterConstants.WAS_SERVICE_COUNT, grpObj)); - } - if (isActionEnable(objType, CounterConstants.SERVICE_GROUP)) { - manager.add(new OpenServiceGroupGroupAction(win, grpName)); + MenuManager xLogMenu = new MenuManager(MenuStr.XLOG, ImageUtil.getImageDescriptor(Images.transrealtime), MenuStr.XLOG_ID); + manager.add(xLogMenu); + xLogMenu.add(new OpenRealTimeTranXGroupViewAction(win, MenuStr.REALTIME_XLOG, grpObj)); + xLogMenu.add(new OpenPastTimeTranXGroupViewAction(win, MenuStr.PASTTIME_XLOG, grpObj)); + MenuManager scMenu = new MenuManager(MenuStr.HOURLY_CHART, ImageUtil.getImageDescriptor(Images.bar), MenuStr.HOURLY_CHART_ID); + manager.add(scMenu); + scMenu.add(new OpenPastDateGroupCountViewAction(win, MenuStr.LOAD_SERVICE_COUNT, CounterConstants.WAS_SERVICE_COUNT, grpObj)); + scMenu.add(new OpenTodayGroupCountViewAction(win, MenuStr.TODAY_SERVICE_COUNT, CounterConstants.WAS_SERVICE_COUNT, grpObj)); + manager.add(new OpenServiceGroupGroupAction(win, grpName)); } } } else if (selObject instanceof AgentObject) { @@ -335,6 +327,20 @@ private boolean isActionEnable(String objType, String attrName) { return result; } + private boolean isChildOf(String objType, String family) { + boolean result = false; + Set serverList = ServerManager.getInstance().getOpenServerList(); + for (int serverId : serverList) { + Server server = ServerManager.getInstance().getServer(serverId); + CounterEngine engine = server.getCounterEngine(); + if (engine.isChildOf(objType, family)) { + result = true; + break; + } + } + return result; + } + class TreeContentProvider implements ITreeContentProvider { public void dispose() { diff --git a/scouter.client/src/scouter/client/util/MenuUtil.java b/scouter.client/src/scouter/client/util/MenuUtil.java index 8eb309837..1d32c160f 100644 --- a/scouter.client/src/scouter/client/util/MenuUtil.java +++ b/scouter.client/src/scouter/client/util/MenuUtil.java @@ -206,9 +206,7 @@ public static void createMenu(IWorkbenchWindow window, IToolBarManager man, } public static HashMap getCounterActionList(IWorkbenchWindow window, CounterEngine counterEngine, int serverId){ - HashMap actions = new HashMap(); - ArrayList objTypeAndCounter = counterEngine.getAllCounterList(); for (int inx = 0; inx < objTypeAndCounter.size(); inx++) { String[] splitedKey = objTypeAndCounter.get(inx).split(":"); @@ -220,77 +218,6 @@ public static HashMap getCounterActionList(IWorkbenchWindow wind new OpenRealTimeAllAction(window, label, objType, counterName, Images .getCounterImage(objType, counterName, serverId), serverId)); } - - ArrayList objTypeList = counterEngine.getObjTypeListWithDisplay(CounterConstants.TOTAL_ACTIVE_SPEED); - for (int inx = 0; inx < objTypeList.size(); inx++) { - String[] splitedKey = objTypeList.get(inx).split(":"); - String objTypeDisplay = splitedKey[0]; - String objType = splitedKey[1]; - actions.put(objType + ":" + CounterConstants.TOTAL_ACTIVE_SPEED, new OpenActiveSpeedAction(window, - objTypeDisplay, objType, Images.getObjectIcon(objType, true, serverId), serverId)); - } - - objTypeList = counterEngine.getObjTypeListWithDisplay(CounterConstants.ACTIVE_EQ); - for (int inx = 0; inx < objTypeList.size(); inx++) { - String[] splitedKey = objTypeList.get(inx).split(":"); - String objType = splitedKey[1]; - actions.put(objType + ":" + CounterConstants.ACTIVE_EQ, new OpenEQViewAction(window, serverId, objType)); - } - - objTypeList = counterEngine.getObjTypeListWithDisplay(CounterConstants.ACTIVE_THREAD_LIST); - for (int inx = 0; inx < objTypeList.size(); inx++) { - String[] splitedKey = objTypeList.get(inx).split(":"); - String objTypeDisplay = splitedKey[0]; - String objType = splitedKey[1]; - actions.put(objType + ":" + CounterConstants.ACTIVE_THREAD_LIST, new OpenActiveServiceListAction(window, - objTypeDisplay, objType, Images.getObjectIcon(objType, true, serverId), serverId)); - } - - objTypeList = counterEngine.getObjTypeListWithDisplay(CounterConstants.TRANX_REALTIME); - for (int inx = 0; inx < objTypeList.size(); inx++) { - String[] splitedKey = objTypeList.get(inx).split(":"); - String objType = splitedKey[1]; - actions.put( - objType + ":" + CounterConstants.TRANX_REALTIME, - new OpenXLogRealTimeAction(window, MenuStr.XLOG, objType, Images.star, serverId)); - } - - objTypeList = counterEngine.getObjTypeListWithDisplay(CounterConstants.TODAY_SERVICE_COUNT); - for (int inx = 0; inx < objTypeList.size(); inx++) { - String[] splitedKey = objTypeList.get(inx).split(":"); - String objType = splitedKey[1]; - actions.put( - objType + ":" + CounterConstants.TODAY_SERVICE_COUNT, - new OpenTodayServiceCountAction(window, MenuStr.SERVICE_COUNT, objType, CounterConstants.WAS_SERVICE_COUNT, Images.bar, serverId)); - } - - objTypeList = counterEngine.getObjTypeListWithDisplay(CounterConstants.SERVICE_GROUP); - for (int inx = 0; inx < objTypeList.size(); inx++) { - String[] splitedKey = objTypeList.get(inx).split(":"); - String objType = splitedKey[1]; - actions.put( - objType + ":" + CounterConstants.SERVICE_GROUP, - new OpenServiceGroupAction(window, serverId, objType)); - } - - objTypeList = counterEngine.getObjTypeListWithDisplay(CounterConstants.UNIQUE_VISITOR); - for (int inx = 0; inx < objTypeList.size(); inx++) { - String[] splitedKey = objTypeList.get(inx).split(":"); - String objType = splitedKey[1]; - actions.put( - objType + ":" + CounterConstants.UNIQUE_VISITOR, - new OpenUniqueTotalVisitorAction(window, serverId, objType)); - } - - objTypeList = counterEngine.getObjTypeListWithDisplay(CounterConstants.SERVICE_SUMMARY); - for (int inx = 0; inx < objTypeList.size(); inx++) { - String[] splitedKey = objTypeList.get(inx).split(":"); - String objType = splitedKey[1]; - actions.put( - objType + ":" + CounterConstants.SERVICE_SUMMARY, - new OpenTypeSummaryAction(window, serverId, objType)); - } - return actions; } @@ -341,28 +268,6 @@ public static HashMap getPastCounterActionList(IWorkbenchWindow new OpenPastLongDateTotalAction(window, label, objType, counterName, Images.getCounterImage(objType, counterName, serverId), curdate, curdate, serverId)); } - - ArrayList objTypeList = counterEngine.getObjTypeListWithDisplay(CounterConstants.TRANX_REALTIME); - for (int inx = 0; inx < objTypeList.size(); inx++) { - String[] splitedKey = objTypeList.get(inx).split(":"); - String objTypeDisplay = splitedKey[0]; - String objType = splitedKey[1]; - actions.put( - objType + ":" + CounterConstants.TRANX_REALTIME, - new OpenXLogLoadTimeAction(window, objTypeDisplay, objType, Images.getObjectIcon( - objType, true, serverId), serverId, st, et)); - } - - objTypeList = counterEngine.getObjTypeListWithDisplay(CounterConstants.TODAY_SERVICE_COUNT); - for (int inx = 0; inx < objTypeList.size(); inx++) { - String[] splitedKey = objTypeList.get(inx).split(":"); - String objTypeDisplay = splitedKey[0]; - String objType = splitedKey[1]; - actions.put( - objType + ":" + CounterConstants.TODAY_SERVICE_COUNT, - new OpenDailyServiceCountAction(window, objTypeDisplay, objType, CounterConstants.WAS_SERVICE_COUNT, Images.getObjectIcon( - objType, true, serverId), serverId, curdate)); - } return actions; } @@ -580,4 +485,28 @@ public void menuAboutToShow(IMenuManager mgr) { Menu menu = mgr.createContextMenu(control); control.setMenu(menu); } + + public static void addObjTypeSpecialMenu(IWorkbenchWindow win, IMenuManager mgr, int serverId, String objType, CounterEngine counterEngine) { + if (counterEngine.isChildOf(objType, CounterConstants.FAMILY_JAVAEE)) { + mgr.add(new Separator()); + mgr.add(new OpenEQViewAction(win, serverId, objType)); + mgr.add(new OpenActiveServiceListAction(win, objType, Images.thread, serverId)); + mgr.add(new OpenActiveSpeedAction(win,objType, Images.TYPE_ACTSPEED, serverId)); + mgr.add(new OpenXLogRealTimeAction(win, MenuStr.XLOG, objType, Images.star, serverId)); + mgr.add(new OpenTodayServiceCountAction(win, MenuStr.SERVICE_COUNT, objType, CounterConstants.WAS_SERVICE_COUNT, Images.bar, serverId)); + mgr.add(new OpenServiceGroupAction(win, serverId, objType)); + mgr.add(new OpenUniqueTotalVisitorAction(win, serverId, objType)); + mgr.add(new OpenTypeSummaryAction(win, serverId, objType)); + } + } + + public static void addPastObjTypeSpecialMenu(IWorkbenchWindow win, IMenuManager mgr, int serverId, String objType, CounterEngine counterEngine, String date) { + long st = DateUtil.yyyymmdd(date); + long et = st + DateUtil.MILLIS_PER_FIVE_MINUTE; + if (counterEngine.isChildOf(objType, CounterConstants.FAMILY_JAVAEE)) { + mgr.add(new Separator()); + mgr.add(new OpenXLogLoadTimeAction(win, objType, Images.transrealtime, serverId, st, et)); + mgr.add(new OpenDailyServiceCountAction(win, objType, CounterConstants.WAS_SERVICE_COUNT, Images.TYPE_SERVICE_COUNT, serverId, date)); + } + } } diff --git a/scouter.client/src/scouter/client/views/ObjectDailyListView.java b/scouter.client/src/scouter/client/views/ObjectDailyListView.java index 183de1ef4..3de14b192 100644 --- a/scouter.client/src/scouter/client/views/ObjectDailyListView.java +++ b/scouter.client/src/scouter/client/views/ObjectDailyListView.java @@ -264,20 +264,7 @@ private void fillTreeViewerContextMenu(IMenuManager mgr){ objTitle.add(counterMenuManager); } - objTitle.add(new Separator()); - - Action act = actions.get(objType + ":" + CounterConstants.TRANX_REALTIME); - if(act != null){ - act.setText(MenuStr.PASTTIME_XLOG); - act.setImageDescriptor(ImageUtil.getImageDescriptor(Images.transrealtime)); - objTitle.add(act); - } - act = actions.get(objType + ":" + CounterConstants.TODAY_SERVICE_COUNT); - if(act != null){ - act.setText(MenuStr.LOAD_SERVICE_COUNT); - act.setImageDescriptor(ImageUtil.getImageDescriptor(Images.TYPE_SERVICE_COUNT)); - objTitle.add(act); - } + MenuUtil.addPastObjTypeSpecialMenu(win, objTitle, serverId, objType, counterEngine, curdate); } } } diff --git a/scouter.client/src/scouter/client/views/ObjectNavigationView.java b/scouter.client/src/scouter/client/views/ObjectNavigationView.java index 9814192b7..da7b15ad4 100644 --- a/scouter.client/src/scouter/client/views/ObjectNavigationView.java +++ b/scouter.client/src/scouter/client/views/ObjectNavigationView.java @@ -621,6 +621,7 @@ private void addExistObjectTypeMenus(IWorkbenchWindow win, IMenuManager mgr, Cou MenuManager objTitle = new MenuManager(displayName, objImage, "scouter.menu.id."+displayName); mgr.add(objTitle); addObjectTypeMenu(objTitle, counterEngine, actionMap, serverId, objType); + MenuUtil.addObjTypeSpecialMenu(win, objTitle, serverId, objType, counterEngine); } } @@ -634,52 +635,6 @@ private void addObjectTypeMenu(IMenuManager objTitle, CounterEngine counterEngin objTitle.add(realtimeAllAct); } } - - objTitle.add(new Separator()); - - Action act = actionMap.get(objType + ":" + CounterConstants.ACTIVE_EQ); - if(act != null){ - objTitle.add(act); - } - - act = actionMap.get(objType + ":" + CounterConstants.ACTIVE_THREAD_LIST); - if(act != null){ - act.setText(MenuStr.ACTIVE_SERVICE_LIST); - act.setImageDescriptor(ImageUtil.getImageDescriptor(Images.thread)); - objTitle.add(act); - } - - act = actionMap.get(objType + ":" + CounterConstants.TOTAL_ACTIVE_SPEED); - if(act != null){ - act.setText(MenuStr.ACTIVE_SPEED_REAL); - act.setImageDescriptor(ImageUtil.getImageDescriptor(Images.TYPE_ACTSPEED)); - objTitle.add(act); - } - - act = actionMap.get(objType + ":" + CounterConstants.TRANX_REALTIME); - if(act != null){ - objTitle.add(act); - } - - act = actionMap.get(objType + ":" + CounterConstants.TODAY_SERVICE_COUNT); - if(act != null){ - objTitle.add(act); - } - - act = actionMap.get(objType + ":" + CounterConstants.SERVICE_GROUP); - if(act != null){ - objTitle.add(act); - } - - act = actionMap.get(objType + ":" + CounterConstants.UNIQUE_VISITOR); - if(act != null){ - objTitle.add(act); - } - - act = actionMap.get(objType + ":" + CounterConstants.SERVICE_SUMMARY); - if(act != null){ - objTitle.add(act); - } } private static void removeActionCache(int serverId) { diff --git a/scouter.client/src/scouter/client/xlog/actions/OpenXLogLoadTimeAction.java b/scouter.client/src/scouter/client/xlog/actions/OpenXLogLoadTimeAction.java index b14fdc698..78a892466 100644 --- a/scouter.client/src/scouter/client/xlog/actions/OpenXLogLoadTimeAction.java +++ b/scouter.client/src/scouter/client/xlog/actions/OpenXLogLoadTimeAction.java @@ -39,19 +39,19 @@ public class OpenXLogLoadTimeAction extends Action implements CalendarDialog.ILo private long stime, etime; - public OpenXLogLoadTimeAction(IWorkbenchWindow window, String label, String objType, Image image, int serverId, long stime, long etime) { + public OpenXLogLoadTimeAction(IWorkbenchWindow window, String objType, Image image, int serverId, long stime, long etime) { this.window = window; this.objType = objType; this.serverId = serverId; this.stime = stime; this.etime = etime; - setText(label); + setText("XLog"); setId(ID); setImageDescriptor(ImageUtil.getImageDescriptor(image)); } public OpenXLogLoadTimeAction(IWorkbenchWindow window, String label, String objType, Image image, int serverId) { - this(window, label, objType, image, serverId, 0, 0); + this(window, objType, image, serverId, 0, 0); } public void run() { diff --git a/scouter.client/src/scouter/client/xlog/views/XLogLoadTimeView.java b/scouter.client/src/scouter/client/xlog/views/XLogLoadTimeView.java index 7fb185ef7..f6292d9ed 100644 --- a/scouter.client/src/scouter/client/xlog/views/XLogLoadTimeView.java +++ b/scouter.client/src/scouter/client/xlog/views/XLogLoadTimeView.java @@ -117,7 +117,7 @@ public void run() { loadXLogItem.setText("Load"); loadXLogItem.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { - new OpenXLogLoadTimeAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), "Load XLog", objType, Images.server, serverId, stime, etime).run(); + new OpenXLogLoadTimeAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), objType, Images.server, serverId, stime, etime).run(); } }); diff --git a/scouter.common/src/scouter/lang/counters/CounterConstants.java b/scouter.common/src/scouter/lang/counters/CounterConstants.java index 52738ed33..8d14768aa 100644 --- a/scouter.common/src/scouter/lang/counters/CounterConstants.java +++ b/scouter.common/src/scouter/lang/counters/CounterConstants.java @@ -122,15 +122,6 @@ public class CounterConstants { public final static String PAST_TIME = "pt"; public final static String PAST_DATE = "pd"; - public final static String TOTAL_ACTIVE_SPEED = "totactsp"; - public final static String ACTIVE_EQ = "acteq"; - public final static String TRANX_REALTIME = "txreal"; - public final static String ACTIVE_THREAD_LIST = "actthrli"; - public final static String TODAY_SERVICE_COUNT = "tdservcnt"; - public final static String SERVICE_GROUP = "svcgrp"; - public final static String UNIQUE_VISITOR = "unqvst"; - public final static String SERVICE_SUMMARY = "sersum"; - public final static String[] COUNTER_MENU_ARRAY = { REAL_TIME_ALL, REAL_TIME_TOTAL, TODAY_ALL, TODAY_TOTAL, PAST_TIME_ALL, PAST_TIME_TOTAL, PAST_DATE_ALL, PAST_DATE_TOTAL }; diff --git a/scouter.common/src/scouter/lang/counters/CounterEngine.java b/scouter.common/src/scouter/lang/counters/CounterEngine.java index 8382945c7..02642bfd7 100644 --- a/scouter.common/src/scouter/lang/counters/CounterEngine.java +++ b/scouter.common/src/scouter/lang/counters/CounterEngine.java @@ -479,7 +479,6 @@ public static void main(String[] args) { CounterEngine ce = new CounterEngine(); ce.parse(content); System.out.println(ce.getAllObjectType()); - System.out.println(ce.getObjTypeListWithDisplay(CounterConstants.TOTAL_ACTIVE_SPEED)); System.out.println(ce.getDisplayNameObjectType("tomcat")); System.out.println(ce.getAllCounterList()); System.out.println(ce.getTotalCounterList()); diff --git a/scouter.common/src/scouter/lang/counters/counters.xml b/scouter.common/src/scouter/lang/counters/counters.xml index 1a1047fe9..338caa794 100644 --- a/scouter.common/src/scouter/lang/counters/counters.xml +++ b/scouter.common/src/scouter/lang/counters/counters.xml @@ -1,14 +1,5 @@