From f59265823e29d8bc65e0029940d8ffd3c30ed14f Mon Sep 17 00:00:00 2001 From: Lee Date: Tue, 24 Jul 2012 17:18:51 +0900 Subject: [PATCH] [Title] warning message box added [Type] bug fix [Module] Dynamic Analyzer [Priority] normal [CQ#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- .../META-INF/MANIFEST.MF | 3 +- .../widgets/button/DACustomButton.java | 496 ++++++++--------- .../widgets/button/DACustomWidgetAttribute.java | 213 ++++---- .../dynamicanalyzer/widgets/daialog/DADailog.java | 126 +++++ org.tizen.dynamicanalyzer.workbench/.classpath | 14 +- .../META-INF/MANIFEST.MF | 1 + .../ApplicationWorkbenchWindowAdvisor.java | 131 +++-- org.tizen.dynamicanalyzer/META-INF/MANIFEST.MF | 4 +- .../org/tizen/dynamicanalyzer/AnalyzerManager.java | 87 --- .../tizen/dynamicanalyzer/ConfigureManager.java | 3 +- .../src/org/tizen/dynamicanalyzer/PathManager.java | 12 +- .../constants/AnalyzerConstants.java | 1 + .../tizen/dynamicanalyzer/model/DeviceCurrent.java | 600 +++++++++++---------- .../ui/renderers/TabButtonRenderer.java | 15 +- .../dynamicanalyzer/ui/views/CoolbarArea.java | 20 +- .../dynamicanalyzer/ui/widgets/AboutDialog.java | 20 +- .../dynamicanalyzer/ui/widgets/DATabComposite.java | 10 +- 17 files changed, 907 insertions(+), 849 deletions(-) create mode 100644 org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/daialog/DADailog.java diff --git a/org.tizen.dynamicanalyzer.widgets/META-INF/MANIFEST.MF b/org.tizen.dynamicanalyzer.widgets/META-INF/MANIFEST.MF index 1b28e0f..99ed4dc 100644 --- a/org.tizen.dynamicanalyzer.widgets/META-INF/MANIFEST.MF +++ b/org.tizen.dynamicanalyzer.widgets/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Widgets -Bundle-SymbolicName: org.tizen.dynamicanalyzer.widgets +Bundle-SymbolicName: org.tizen.dynamicanalyzer.widgets;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Activator: org.tizen.dynamicanalyzer.widgets.Activator Require-Bundle: org.eclipse.ui, @@ -12,6 +12,7 @@ Export-Package: org.tizen.dynamicanalyzer.widgets, org.tizen.dynamicanalyzer.widgets.button, org.tizen.dynamicanalyzer.widgets.button.toggle, org.tizen.dynamicanalyzer.widgets.combo, + org.tizen.dynamicanalyzer.widgets.daialog, org.tizen.dynamicanalyzer.widgets.graph.bar, org.tizen.dynamicanalyzer.widgets.graph.circular, org.tizen.dynamicanalyzer.widgets.helper, diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/DACustomButton.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/DACustomButton.java index 3e0b088..0fe0505 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/DACustomButton.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/DACustomButton.java @@ -1,3 +1,5 @@ + + package org.tizen.dynamicanalyzer.widgets.button; import org.eclipse.swt.SWT; @@ -15,274 +17,230 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.tizen.dynamicanalyzer.widgets.helper.ColorResources; + public class DACustomButton extends Canvas { - 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 TYPE_IMAGE = 0; - public static final int TYPE_COLOR = 1; - public static final int TYPE_GRADATION = 2; - - Composite parent; - protected boolean enabled = true; - - protected int state = STATE_NORMAL; - protected DACustomWidgetAttribute attr; - protected DACustomButtonDefaultRenderer buttonRenderer = null; - - public void addListeners() { - this.addListener(SWT.MouseEnter, buttonMouseListener); - this.addListener(SWT.MouseExit, buttonMouseListener); - this.addListener(SWT.MouseDown, buttonMouseListener); - this.addListener(SWT.MouseUp, buttonMouseListener); - } - - public DACustomButton(Composite parent, int style) { - super(parent, style); - - this.parent = parent; - FillLayout layout = new FillLayout(SWT.HORIZONTAL); - this.setLayout(layout); - - this.setForeground(ColorResources.WHITE); - this.addPaintListener(buttonPaintListener); - addListeners(); - buttonRenderer = new DACustomButtonRenderer(); - attr = new DACustomWidgetAttribute(); - setDefaultColors(); - } - - public DACustomButton(Composite parent, int style, String titleText) { - this(parent, style); - attr.setText(titleText); - } - - public DACustomButton(Composite parent, Image normal, Image mouseDown, - Image hover, Image disable) { - this(parent, SWT.TRANSPARENT); - setImages(normal, mouseDown, hover, disable); - attr.setDrawType(TYPE_IMAGE); - } - - public DACustomButton(Composite parent, Color normalStart, Color normalEnd, - Color pushStart, Color pushEnd, Color hoverStart, Color hoverEnd, - Color disableStart, Color disableEnd) { - this(parent, SWT.NONE); - attr.setColor(0, normalStart); - attr.setColor(1, normalEnd); - attr.setColor(2, pushStart); - attr.setColor(3, pushEnd); - attr.setColor(4, hoverStart); - attr.setColor(5, hoverEnd); - attr.setColor(6, disableStart); - attr.setColor(7, disableEnd); - attr.setDrawType(TYPE_GRADATION); - } - - protected void changeButtonState(int s) { - state = s; - this.redraw(); - } - - protected 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.MouseExit) { - changeButtonState(STATE_NORMAL); - } - - if (event.type == SWT.MouseDown) { - changeButtonState(STATE_PUSH); - } - - if (event.type == SWT.MouseUp) { // FIXME - changeButtonState(STATE_HOVER); - } - } - }; - - private void setDefaultColors() { - attr.setColor(STATE_DISABLE, - new Color(Display.getCurrent(), 48, 48, 48)); - attr.setColor(STATE_PUSH, new Color(Display.getCurrent(), 29, 109, 140)); - attr.setColor(STATE_HOVER, new Color(Display.getCurrent(), 0, 134, 185)); - attr.setColor(STATE_NORMAL, new Color(Display.getCurrent(), 67, 67, 67)); - } - - private PaintListener buttonPaintListener = new PaintListener() { - - @Override - public void paintControl(PaintEvent e) { - buttonRenderer.draw(e.gc, (Canvas) e.widget, state, attr); - } - }; - - public void setTitle(String newTitle) { - attr.setText(newTitle); - } - - public void setText(String newTitle) { - attr.setText(newTitle); - } - - public void setButtonImage(Image img) { - attr.setButtonImage(img); - } - - public void setRenderer(DACustomButtonDefaultRenderer newRenderer) { - buttonRenderer = newRenderer; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - if (enabled) { - changeButtonState(STATE_NORMAL); - } else { - changeButtonState(STATE_DISABLE); - } - } - - public boolean getEnabled() { - return this.enabled; - } - - public void setImage(int state, Image image) { - attr.setImage(state, image); - } - - // public void setHoverImage(Image image) { - // attr.setImage(STATE_HOVER, image); - // } - // - // public void setNormalImage(Image image) { - // attr.setImage(STATE_NORMAL, image); - // } - // - // public void setPushImage(Image image) { - // attr.setImage(STATE_PUSH, image); - // } - // - // public void setDisableImage(Image image) { - // attr.setImage(STATE_DISABLE, image); - // } - - public Image getImage(int state) { - return attr.getImage(state); - } - - // public Image getHoverImage() { - // return attr.getImage(STATE_HOVER); - // } - // - // public Image getNormalImage() { - // return attr.getImage(STATE_NORMAL); - // } - // - // public Image getPushImage() { - // return attr.getImage(STATE_PUSH); - // } - // - // public Image getDisableImage(Image image) { - // return attr.getImage(STATE_DISABLE); - // } - - public void setColor(int state, Color color) { - attr.setColor(state, color); - } - - // public void setHoverColor(Color color) { - // attr.setColor(STATE_HOVER, color); - // } - // - // public void setNormalColor(Color color) { - // attr.setColor(STATE_NORMAL, color); - // } - // - // public void setPushColor(Color color) { - // attr.setColor(STATE_PUSH, color); - // } - // - // public void setDisableColor(Color color) { - // attr.setColor(STATE_DISABLE, color); - // } - - public void setVisible(boolean visible) { - setVisible(visible); - } - - public void setFont(Font font) { - attr.setFont(font); - } - - public void setFontPoint(Point p) { - attr.setFontPoint(p); - } - - public void setColors(Color normal, Color push, Color hover, Color disable) { - attr.setColor(STATE_NORMAL, normal); - attr.setColor(STATE_PUSH, push); - attr.setColor(STATE_HOVER, hover); - attr.setColor(STATE_DISABLE, disable); - attr.setDrawType(TYPE_COLOR); - } - - public void setImages(Image normal, Image push, Image hover, Image disable) { - attr.setImage(STATE_NORMAL, normal); - attr.setImage(STATE_PUSH, push); - attr.setImage(STATE_HOVER, hover); - attr.setImage(STATE_DISABLE, disable); - attr.setDrawType(TYPE_IMAGE); - } - - public void addClickListener(DACustomButtonClickEventListener listener) { - addListener(SWT.MouseUp, listener); - } - - public int getState() { - return state; - } - - public void setGradation(Color normalStart, Color normalEnd, - Color pushStart, Color pushEnd, Color hoverStart, Color hoverEnd, - Color disableStart, Color disableEnd) { - attr.setColor(0, normalStart); - attr.setColor(1, normalEnd); - attr.setColor(2, pushStart); - attr.setColor(3, pushEnd); - attr.setColor(4, hoverStart); - attr.setColor(5, hoverEnd); - attr.setColor(6, disableStart); - attr.setColor(7, disableEnd); - attr.setDrawType(TYPE_GRADATION); - } - - public void setGradationColor(int state, Color start, Color end) { - attr.setColor(state * 2, start); - attr.setColor(state * 2 + 1, end); - } - - public void setFontColors(Color normal, Color push, Color hover, - Color disable) { - attr.setFontColor(STATE_NORMAL, normal); - attr.setFontColor(STATE_PUSH, push); - attr.setFontColor(STATE_HOVER, hover); - attr.setFontColor(STATE_DISABLE, disable); - } - - public void setFontColor(int state, Color color) { - attr.setFontColor(state, color); - } + 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 TYPE_IMAGE = 0; + public static final int TYPE_COLOR = 1; + public static final int TYPE_GRADATION = 2; + + Composite parent; + protected boolean enabled = true; + + protected int state = STATE_NORMAL; + protected DACustomWidgetAttribute attr; + protected DACustomButtonDefaultRenderer buttonRenderer = null; + + public void addListeners() { + this.addListener(SWT.MouseEnter, buttonMouseListener); + this.addListener(SWT.MouseExit, buttonMouseListener); + this.addListener(SWT.MouseDown, buttonMouseListener); + this.addListener(SWT.MouseUp, buttonMouseListener); + } + + public DACustomButton(Composite parent, int style) { + super(parent, style); + + this.parent = parent; + FillLayout layout = new FillLayout(SWT.HORIZONTAL); + this.setLayout(layout); + + this.setForeground(ColorResources.WHITE); + this.addPaintListener(buttonPaintListener); + addListeners(); + buttonRenderer = new DACustomButtonRenderer(); + attr = new DACustomWidgetAttribute(); + setDefaultColors(); + } + + public DACustomButton(Composite parent, int style, String titleText) { + this(parent, style); + attr.setText(titleText); + } + + public DACustomButton(Composite parent, Image normal, Image mouseDown, Image hover, + Image disable) { + this(parent, SWT.TRANSPARENT); + setImages(normal, mouseDown, hover, disable); + attr.setDrawType(TYPE_IMAGE); + } + + public DACustomButton(Composite parent, Color normalStart, Color normalEnd, Color pushStart, + Color pushEnd, Color hoverStart, Color hoverEnd, Color disableStart, Color disableEnd) { + this(parent, SWT.NONE); + attr.setColor(0, normalStart); + attr.setColor(1, normalEnd); + attr.setColor(2, pushStart); + attr.setColor(3, pushEnd); + attr.setColor(4, hoverStart); + attr.setColor(5, hoverEnd); + attr.setColor(6, disableStart); + attr.setColor(7, disableEnd); + attr.setDrawType(TYPE_GRADATION); + } + + protected void changeButtonState(int s) { + state = s; + this.redraw(); + } + + protected 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.MouseExit) { + changeButtonState(STATE_NORMAL); + } + + if (event.type == SWT.MouseDown) { + changeButtonState(STATE_PUSH); + } + + if (event.type == SWT.MouseUp) { // FIXME + changeButtonState(STATE_HOVER); + } + } + }; + + private void setDefaultColors() { + attr.setColor(STATE_DISABLE, new Color(Display.getCurrent(), 48, 48, 48)); + attr.setColor(STATE_PUSH, new Color(Display.getCurrent(), 29, 109, 140)); + attr.setColor(STATE_HOVER, new Color(Display.getCurrent(), 0, 134, 185)); + attr.setColor(STATE_NORMAL, new Color(Display.getCurrent(), 67, 67, 67)); + } + + private PaintListener buttonPaintListener = new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + buttonRenderer.draw(e.gc, (Canvas) e.widget, state, attr); + } + }; + + public void setTitle(String newTitle) { + attr.setText(newTitle); + } + + public void setText(String newTitle) { + attr.setText(newTitle); + } + + public void setButtonImage(Image img) { + attr.setButtonImage(img); + } + + public void setRenderer(DACustomButtonDefaultRenderer newRenderer) { + buttonRenderer = newRenderer; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + if (enabled) { + changeButtonState(STATE_NORMAL); + } else { + changeButtonState(STATE_DISABLE); + } + } + + public boolean getEnabled() { + return this.enabled; + } + + public void setImage(int state, Image image) { + attr.setImage(state, image); + } + + public Image getImage(int state) { + return attr.getImage(state); + } + + public void setColor(int state, Color color) { + attr.setColor(state, color); + } + + public void setVisible(boolean visible) { + setVisible(visible); + } + + public void setFont(Font font) { + attr.setFont(font); + } + + public void setFontPoint(Point p) { + attr.setFontPoint(p); + } + + public void setColors(Color normal, Color push, Color hover, Color disable) { + attr.setColor(STATE_NORMAL, normal); + attr.setColor(STATE_PUSH, push); + attr.setColor(STATE_HOVER, hover); + attr.setColor(STATE_DISABLE, disable); + attr.setDrawType(TYPE_COLOR); + } + + public void setImages(Image normal, Image push, Image hover, Image disable) { + attr.setImage(STATE_NORMAL, normal); + attr.setImage(STATE_PUSH, push); + attr.setImage(STATE_HOVER, hover); + attr.setImage(STATE_DISABLE, disable); + attr.setDrawType(TYPE_IMAGE); + } + + public void setOutlineColors(Color normal, Color push, Color hover, Color disable) { + attr.setOutlineColor(STATE_NORMAL, normal); + attr.setOutlineColor(STATE_PUSH, push); + attr.setOutlineColor(STATE_HOVER, hover); + attr.setOutlineColor(STATE_DISABLE, disable); + } + + public void addClickListener(DACustomButtonClickEventListener listener) { + addListener(SWT.MouseUp, listener); + } + + public int getState() { + return state; + } + + public void setGradation(Color normalStart, Color normalEnd, Color pushStart, Color pushEnd, + Color hoverStart, Color hoverEnd, Color disableStart, Color disableEnd) { + attr.setColor(0, normalStart); + attr.setColor(1, normalEnd); + attr.setColor(2, pushStart); + attr.setColor(3, pushEnd); + attr.setColor(4, hoverStart); + attr.setColor(5, hoverEnd); + attr.setColor(6, disableStart); + attr.setColor(7, disableEnd); + attr.setDrawType(TYPE_GRADATION); + } + + public void setGradationColor(int state, Color start, Color end) { + attr.setColor(state * 2, start); + attr.setColor(state * 2 + 1, end); + } + + public void setFontColors(Color normal, Color push, Color hover, Color disable) { + attr.setFontColor(STATE_NORMAL, normal); + attr.setFontColor(STATE_PUSH, push); + attr.setFontColor(STATE_HOVER, hover); + attr.setFontColor(STATE_DISABLE, disable); + } + + public void setFontColor(int state, Color color) { + attr.setFontColor(state, color); + } } diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/DACustomWidgetAttribute.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/DACustomWidgetAttribute.java index f5f244d..a30ab76 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/DACustomWidgetAttribute.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/DACustomWidgetAttribute.java @@ -1,3 +1,5 @@ + + package org.tizen.dynamicanalyzer.widgets.button; import java.util.ArrayList; @@ -8,105 +10,116 @@ import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; + public class DACustomWidgetAttribute { - private final int MAX_SIZE = 10; - private String text; - private Image buttonImage = null; - private Font font; - private Point fontPoint; - private int drawType = DACustomButton.TYPE_COLOR; - - private List images = new ArrayList(); - private List colors = new ArrayList(); - private List fontColors = new ArrayList(); - private boolean enabled; - - public DACustomWidgetAttribute() { - enabled = true; - - // init array - for (int i = 0; i < MAX_SIZE; i++) { - images.add(null); - colors.add(null); - fontColors.add(null); - } - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public Image getButtonImage() { - return buttonImage; - } - - public void setButtonImage(Image img) { - buttonImage = img; - } - - public Font getFont() { - return font; - } - - public void setFont(Font font) { - this.font = font; - } - - public Point getFontPoint() { - return fontPoint; - } - - public void setFontPoint(Point fontPoint) { - this.fontPoint = fontPoint; - } - - public int getDrawType() { - return drawType; - } - - public void setDrawType(int type) { - drawType = type; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public Image getImage(int state) { - if (!images.isEmpty()) { - return images.get(state); - } - return null; - } - - public void setImage(int state, Image img) { - images.set(state, img); - } - - public Color getColor(int state) { - if (!colors.isEmpty()) { - return colors.get(state); - } - return null; - } - - public void setColor(int state, Color color) { - colors.set(state, color); - } - - public void setFontColor(int state, Color color) { - fontColors.set(state, color); - } - - public Color getFontColor(int state) { - return fontColors.get(state); - } + private final int MAX_SIZE = 10; + private String text; + private Image buttonImage = null; + private Font font; + private Point fontPoint; + private int drawType = DACustomButton.TYPE_COLOR; + + private List images = new ArrayList(); + private List colors = new ArrayList(); + private List fontColors = new ArrayList(); + private List outlineColors = new ArrayList(); + private boolean enabled; + + public DACustomWidgetAttribute() { + enabled = true; + + // init array + for (int i = 0; i < MAX_SIZE; i++) { + images.add(null); + colors.add(null); + fontColors.add(null); + outlineColors.add(null); + } + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Image getButtonImage() { + return buttonImage; + } + + public void setButtonImage(Image img) { + buttonImage = img; + } + + public Font getFont() { + return font; + } + + public void setFont(Font font) { + this.font = font; + } + + public Point getFontPoint() { + return fontPoint; + } + + public void setFontPoint(Point fontPoint) { + this.fontPoint = fontPoint; + } + + public int getDrawType() { + return drawType; + } + + public void setDrawType(int type) { + drawType = type; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public Image getImage(int state) { + if (!images.isEmpty()) { + return images.get(state); + } + return null; + } + + public void setImage(int state, Image img) { + images.set(state, img); + } + + public Color getColor(int state) { + if (!colors.isEmpty()) { + return colors.get(state); + } + return null; + } + + public void setColor(int state, Color color) { + colors.set(state, color); + } + + public void setFontColor(int state, Color color) { + fontColors.set(state, color); + } + + public Color getFontColor(int state) { + return fontColors.get(state); + } + + public void setOutlineColor(int state, Color color) { + outlineColors.set(state, color); + } + + public Color getOutlineColor(int state) { + return outlineColors.get(state); + } } diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/daialog/DADailog.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/daialog/DADailog.java new file mode 100644 index 0000000..e0a9463 --- /dev/null +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/daialog/DADailog.java @@ -0,0 +1,126 @@ + + +package org.tizen.dynamicanalyzer.widgets.daialog; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +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.Shell; +import org.tizen.dynamicanalyzer.widgets.button.DACustomButton; +import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonDefaultRenderer; +import org.tizen.dynamicanalyzer.widgets.helper.ColorResources; + + +public class DADailog { + + private Canvas infoArea = null; + private String info = null; + private Image icon = null; + private DACustomButton okButton = null; + private Color bgColor = ColorResources.BLACK; + private Color fgColor = ColorResources.WHITE; + private Shell shell = null; + + public DADailog(Shell parent, int style) { + shell = new Shell(parent, style | SWT.APPLICATION_MODAL | SWT.TITLE); + shell.setSize(446, 157); + shell.setLayout(new FormLayout()); + + infoArea = new Canvas(shell, SWT.DOUBLE_BUFFERED); + FormData data = new FormData(); + data.top = new FormAttachment(0, 0); + data.left = new FormAttachment(0, 0); + data.right = new FormAttachment(100, 0); + data.height = 76; + infoArea.setLayoutData(data); + infoArea.addPaintListener(infoPaintListener); + + okButton = new DACustomButton(shell, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(infoArea, 12); + data.right = new FormAttachment(100, -9); + data.width = 100; + data.height = 34; + okButton.setLayoutData(data); + okButton.setText("OK"); + + // okButton.addClickListener(new DACustomButtonClickEventListener() { + // + // @Override + // public void handleClickEvent(DACustomButton button) { + // shell.dispose(); + // } + // }); + } + + public void open() { + shell.open(); +// while (!shell.isDisposed()) { +// if (shell.getDisplay().readAndDispatch()) { +// shell.getDisplay().sleep(); +// } +// } + } + + private PaintListener infoPaintListener = new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + Canvas canvas = (Canvas) e.widget; + Rectangle rect = canvas.getClientArea(); + e.gc.setBackground(bgColor); + e.gc.fillRectangle(rect); + int textX = 15; + int textY = 15; + + if (null != icon) { + e.gc.drawImage(icon, textX, 15); + Rectangle imgRect = icon.getBounds(); + + textX += (imgRect.width + 15); + } + + if (null != info) { + e.gc.setForeground(fgColor); + // FIXME: new line logic + e.gc.drawText(info, textX, textY); + } + } + }; + + public void setMessage(String msg) { + info = msg; + } + + public void setBgColor(Color color) { + bgColor = color; + } + + public void setFgColor(Color color) { + fgColor = color; + } + + public void setIcon(Image img) { + icon = img; + } + + public void setButtonRenderer(DACustomButtonDefaultRenderer renderer) { + okButton.setRenderer(renderer); + } + + public DACustomButton getOkButton() { + return okButton; + } + + public boolean isDisposed() { + boolean disposed = shell.isDisposed(); + return disposed; + } +} diff --git a/org.tizen.dynamicanalyzer.workbench/.classpath b/org.tizen.dynamicanalyzer.workbench/.classpath index 8a8f166..16d067f 100644 --- a/org.tizen.dynamicanalyzer.workbench/.classpath +++ b/org.tizen.dynamicanalyzer.workbench/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/org.tizen.dynamicanalyzer.workbench/META-INF/MANIFEST.MF b/org.tizen.dynamicanalyzer.workbench/META-INF/MANIFEST.MF index 72c7dc2..3675d8f 100644 --- a/org.tizen.dynamicanalyzer.workbench/META-INF/MANIFEST.MF +++ b/org.tizen.dynamicanalyzer.workbench/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Bundle-Version: 1.0.0.qualifier Bundle-Vendor: %providerName Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui, + org.tizen.dynamicanalyzer.widgets;bundle-version="1.0.0", org.tizen.dynamicanalyzer;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: org.tizen.dynamicanalyzer.workbench; diff --git a/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/workbench/ApplicationWorkbenchWindowAdvisor.java b/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/workbench/ApplicationWorkbenchWindowAdvisor.java index 7d73f4b..694f8f8 100644 --- a/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/workbench/ApplicationWorkbenchWindowAdvisor.java +++ b/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/workbench/ApplicationWorkbenchWindowAdvisor.java @@ -1,3 +1,5 @@ + + package org.tizen.dynamicanalyzer.workbench; import org.eclipse.swt.SWT; @@ -11,60 +13,89 @@ import org.eclipse.ui.application.IActionBarConfigurer; import org.eclipse.ui.application.IWorkbenchWindowConfigurer; import org.eclipse.ui.application.WorkbenchWindowAdvisor; import org.tizen.dynamicanalyzer.AnalyzerManager; +import org.tizen.dynamicanalyzer.ColorResources; +import org.tizen.dynamicanalyzer.ImageResources; +import org.tizen.dynamicanalyzer.constants.AnalyzerConstants; import org.tizen.dynamicanalyzer.ui.views.CoolbarArea; +import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; +import org.tizen.dynamicanalyzer.widgets.button.DACustomButton; +import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener; +import org.tizen.dynamicanalyzer.widgets.daialog.DADailog; public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { - private static final int DEFAULT_WIDTH = 1024; - private static final int DEFAULT_HEIGHT = 768; - private static final int MIN_WIDTH = 800; - private static final int MIN_HEIGHT = 600; - private int width = DEFAULT_WIDTH; - private int height = DEFAULT_HEIGHT; - - public static String deviceName; - public static String appName; - - public ApplicationWorkbenchWindowAdvisor( - IWorkbenchWindowConfigurer configurer) { - super(configurer); - } - - @Override - public ActionBarAdvisor createActionBarAdvisor( - IActionBarConfigurer configurer) { - return new ApplicationActionBarAdvisor(configurer); - } - - @Override - public void createWindowContents(Shell shell) { - CoolbarArea.createInstance(getWindowConfigurer(), shell); -// CoolbarArea.getInstance().setShellSize(width, height); - } - - @Override - public void preWindowOpen() { - Monitor[] monitors = PlatformUI.getWorkbench().getDisplay() - .getMonitors(); - Rectangle rectangle = null; - rectangle = monitors[0].getBounds(); - if (rectangle.width < DEFAULT_WIDTH - || rectangle.height < DEFAULT_HEIGHT) { - width = MIN_WIDTH; - height = MIN_HEIGHT; - } - - IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); - configurer.setInitialSize(new Point(width, height)); - configurer.setShowStatusLine(false); - configurer.setShellStyle(SWT.SHELL_TRIM/* | SWT.NO_BACKGROUND*/); - } - - public void postWindowOpen() { - AnalyzerManager.setAutoStartDeviceName(deviceName); + private static final int DEFAULT_WIDTH = 1024; + private static final int DEFAULT_HEIGHT = 768; + private static final int MIN_WIDTH = 800; + private static final int MIN_HEIGHT = 600; + private int width = DEFAULT_WIDTH; + private int height = DEFAULT_HEIGHT; + + public static String deviceName; + public static String appName; + + public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + @Override + public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { + return new ApplicationActionBarAdvisor(configurer); + } + + @Override + public void createWindowContents(Shell shell) { + CoolbarArea.createInstance(getWindowConfigurer(), shell); + // CoolbarArea.getInstance().setShellSize(width, height); + } + + @Override + public void preWindowOpen() { + Monitor[] monitors = PlatformUI.getWorkbench().getDisplay().getMonitors(); + Rectangle rectangle = null; + rectangle = monitors[0].getBounds(); + if (rectangle.width < DEFAULT_WIDTH || rectangle.height < DEFAULT_HEIGHT) { + width = MIN_WIDTH; + height = MIN_HEIGHT; + } + + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(width, height)); + configurer.setShowStatusLine(false); + configurer.setShellStyle(SWT.SHELL_TRIM/* | SWT.NO_BACKGROUND */); + } + + public void postWindowOpen() { + + errorCheck(); + AnalyzerManager.setAutoStartDeviceName(deviceName); AnalyzerManager.setAutoStartApplicationName(appName); - CoolbarArea.getInstance().autoStart(); - - } + CoolbarArea.getInstance().autoStart(); + + } + + private void errorCheck() { + + if (null != AnalyzerConstants.TIZEN_ROOT_PATH) { + return; + } + + final Shell shell = AnalyzerUtil.getWorkbenchWindow().getShell(); + DADailog daDailog = new DADailog(shell, SWT.NONE); + DADailog dialog = daDailog; + dialog.setBgColor(ColorResources.VIEW_BG_COLOR); + dialog.setIcon(ImageResources.REPLAY); + dialog.setMessage("Tizen SDK is not installed"); + + dialog.getOkButton().addClickListener(new DACustomButtonClickEventListener() { + + @Override + public void handleClickEvent(DACustomButton button) { + PlatformUI.getWorkbench().close(); + } + }); + + dialog.open(); + } } diff --git a/org.tizen.dynamicanalyzer/META-INF/MANIFEST.MF b/org.tizen.dynamicanalyzer/META-INF/MANIFEST.MF index c71471b..8ee5dba 100644 --- a/org.tizen.dynamicanalyzer/META-INF/MANIFEST.MF +++ b/org.tizen.dynamicanalyzer/META-INF/MANIFEST.MF @@ -24,4 +24,6 @@ Bundle-ClassPath: ., lib/jfreechart-1.0.14-swt.jar, lib/jfreechart-1.0.14.jar Export-Package: org.tizen.dynamicanalyzer, - org.tizen.dynamicanalyzer.ui.views + org.tizen.dynamicanalyzer.constants, + org.tizen.dynamicanalyzer.ui.views, + org.tizen.dynamicanalyzer.utils diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/AnalyzerManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/AnalyzerManager.java index 11cdbae..c88e53f 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/AnalyzerManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/AnalyzerManager.java @@ -20,11 +20,7 @@ package org.tizen.dynamicanalyzer; -import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -346,89 +342,6 @@ public class AnalyzerManager { return null; } -// public static String getTizenSdkDataPath() { -// String defaultPath = null; -// if (AnalyzerUtil.isLinux()) { -// defaultPath = -// System.getenv(AnalyzerConstants.LINUX_INSTALL_ENV) + File.separator -// + AnalyzerConstants.TIZEN_SDK_DATA; -// } else if (AnalyzerUtil.isWin()) { -// defaultPath = -// getRegistryValue(AnalyzerConstants.WIN_INSTALL_NODE, -// AnalyzerConstants.WIN_INSTALL_KEY) -// + File.separator -// + AnalyzerConstants.TIZEN_SDK_DATA; -// } -// -// return defaultPath; -// } - -// public static String getDefaultRoot() { -// String rootPath = null; -// BufferedReader br = null; -// String line = null; -// try { -// rootPath = -// AnalyzerConstants.TIZEN_SDK_DATA_PATH + File.separator -// + AnalyzerConstants.INSTALL; -// File file = new File(rootPath); -// if (!file.isFile()) { -// // FIXME: message box and exit -// return null; -// } -// br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); -// line = br.readLine(); -// return line.substring(line.indexOf(AnalyzerConstants.EQUAL) + 1); -// } catch (IOException e) { -// System.out.println("Fail to read."); //$NON-NLS-1$ -// e.printStackTrace(); -// } finally { -// if (null != br) { -// try { -// br.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// } -// -// return rootPath; -// } - -// public static String getRegistryValue(String node, String key) { -// BufferedReader br = null; -// String value = ""; -// -// String query = "reg query " + "\"" + node + "\" /v " + "\"" + key + "\""; -// try { -// Process process = Runtime.getRuntime().exec(query); -// String encoding = System.getProperty("sun.jnu.encoding"); -// -// br = new BufferedReader(new InputStreamReader(process.getInputStream(), encoding)); -// -// String line = null; -// while ((line = br.readLine()) != null) { -// int index = line.indexOf("REG_SZ"); -// if (index >= 0) { -// value = line.substring(index + "REG_SZ".length()).trim(); -// } -// } -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } finally { -// if (br != null) { -// try { -// br.close(); -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } -// -// return value; -// } public static List getAvailableLogCenters() { String path = diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ConfigureManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ConfigureManager.java index 4c4b6ba..0c0f0db 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ConfigureManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ConfigureManager.java @@ -123,7 +123,8 @@ public class ConfigureManager { configFolder.mkdirs(); } - File configFile = new File(configFolder, AnalyzerConstants.CONFIG_FILE_NAME); + File configFile = + new File(configFolder, AnalyzerConstants.CONFIG_FILE_NAME); if (!configFile.isFile()) { try { configFile.createNewFile(); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/PathManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/PathManager.java index 1fc4865..e60e2ec 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/PathManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/PathManager.java @@ -9,8 +9,6 @@ import java.io.IOException; import java.io.InputStreamReader; import org.tizen.dynamicanalyzer.constants.AnalyzerConstants; -import org.tizen.dynamicanalyzer.handlers.ExitHandler; -import org.tizen.dynamicanalyzer.handlers.OpenTraceCompleteHandler; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; @@ -77,8 +75,6 @@ public class PathManager { + AnalyzerConstants.INSTALL; File file = new File(rootPath); if (!file.isFile()) { - AnalyzerUtil.executeCommand(ExitHandler.ID); - // FIXME: message box and exit return null; } br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); @@ -101,7 +97,7 @@ public class PathManager { } public static String getInstallPath() { - String installPath = getDefaultRoot(); + String installPath = AnalyzerConstants.TIZEN_ROOT_PATH; if (null != installPath) { installPath += File.separator + AnalyzerConstants.TOOLS_FOLDER_NAME + File.separator @@ -121,9 +117,9 @@ public class PathManager { } public static String getSdbPath() { - String path = null; - if (null != getDefaultRoot()) { - path = getDefaultRoot() + File.separator + "tools" + File.separator + "sdb"; + String path = AnalyzerConstants.TIZEN_ROOT_PATH; + if (null != path) { + path += File.separator + "tools" + File.separator + "sdb"; } return path; } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/constants/AnalyzerConstants.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/constants/AnalyzerConstants.java index 670a29b..16e9ac4 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/constants/AnalyzerConstants.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/constants/AnalyzerConstants.java @@ -60,6 +60,7 @@ public class AnalyzerConstants { /* paths */ public static final String TIZEN_SDK_DATA_PATH = PathManager.getTizenSdkDataPath(); + public static final String TIZEN_ROOT_PATH = PathManager.getDefaultRoot(); // public static final String DYNAMIC_ANALYZER_INSTALL_PATH = PathManager.getDefaultRoot() // + File.separator + TOOLS_FOLDER_NAME + File.separator + DYNAMIC_ANALYZER_FOLDER_NAME; public static final String DYNAMIC_ANALYZER_INSTALL_PATH = PathManager.getInstallPath(); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceCurrent.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceCurrent.java index a598468..236b3ff 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceCurrent.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/DeviceCurrent.java @@ -1,3 +1,5 @@ + + package org.tizen.dynamicanalyzer.model; import java.io.BufferedReader; @@ -14,304 +16,306 @@ import org.tizen.dynamicanalyzer.constants.AnalyzerConstants; import org.tizen.sdblib.MultiLineReceiver; + public class DeviceCurrent { - public static int[][] value = new int[11][10]; - public static String deviceName = null; - private static List deviceList = new ArrayList();; - private static HashMap deviceIndex = new HashMap();; - - private static final int DEFAULT_VOLTAGE = 4000000; - - private static final int CPU_FREQUENCY_100K = 100000; - private static final int CPU_FREQUENCY_200K = 200000; - private static final int CPU_FREQUENCY_400K = 400000; - private static final int CPU_FREQUENCY_500K = 500000; - private static final int CPU_FREQUENCY_800K = 800000; - private static final int CPU_FREQUENCY_1000K = 1000000; - private static final int CPU_FREQUENCY_1200K = 1200000; - - private static final int STATE_MAX = 9; - private static String CMD_TARGET_DEVICE_NAME = "uname -n"; //$NON-NLS-1$ - private static String CURRENT_TABLE_PREFIX = "system_panel_battery_table_"; //$NON-NLS-1$ - private static String CURRENT_TABLE_DEFAULT = "default"; //$NON-NLS-1$ - - private static enum deviceNameList { - F1("F1"), U1("U1"), Emulator("Emulator"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - - private final String name; - - deviceNameList(String device) { - name = device; - } - - public String getDevice() { - return name; - } - } - - private static enum devicePartList { - AUDIO(0), RSSI(1), BRIGHTNESS(2), VIDEO(3), CALL(4), WIFI(5), BT(6), DNET( - 7), GPS(8), CAMERA(9), CPU(10); - - private final int value; - - devicePartList(int index) { - value = index; - } - - public int getIndex() { - return value; - } - } - - public DeviceCurrent() { - clear(); - - for (deviceNameList device : deviceNameList.values()) { - deviceList.add(device.getDevice()); - } - - for (devicePartList devicePart : devicePartList.values()) { - deviceIndex.put(devicePart, devicePart.getIndex()); - } - } - - public static void clear() { - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 10; j++) { - value[i][j] = 0; - } - } - deviceName = null; - } - - private static MultiLineReceiver getDeviceName = new MultiLineReceiver() { - @Override - public void processNewLines(String[] lines) { - if (0 != lines.length && !lines[0].isEmpty()) { - deviceName = lines[0]; - deviceName.trim(); - } - } - }; - - private static boolean isExistDeviceName() { - int size = deviceList.size(); - if (0 < size) { - for (int i = 0; i < size; i++) { - if (deviceName.equals(deviceList.get(i))) { - return true; - } - } - } - return false; - } - - public static void init() { - String tablePath = AnalyzerConstants.CONFIG_FOLDER_PATH - + CURRENT_TABLE_PREFIX; - clear(); - DACommunicator.execShellCommand(CMD_TARGET_DEVICE_NAME, getDeviceName); - if (isExistDeviceName()) { - tablePath += deviceName; - } else { - tablePath += CURRENT_TABLE_DEFAULT; - } - setDeviceCurrentInfo(tablePath); - - } - - public static int getValue(int rowIndex, int columnIndex) { - return value[rowIndex][columnIndex]; - } - - public static void setDeviceCurrentInfo(String path) { - String line = null; - String[] values = null; - int lineNum = 0; - - try { - File file = new File(path); - BufferedReader br = new BufferedReader(new FileReader(file)); - while (null != (line = br.readLine())) { - if (line.isEmpty()) { - continue; - } - values = line.split(AnalyzerConstants.SPACE, 10); - if (10 != values.length) { - System.out.println("DeviceCurrent - wrong size columns : " //$NON-NLS-1$ - + values.length); - break; - } - - for (int index = 0; index < 10; index++) { - value[lineNum][index] = Integer.parseInt(values[index]); - } - - lineNum++; - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (NumberFormatException e) { - e.printStackTrace(); - } finally { - if (11 != lineNum) { - System.out.println("DeviceCurrent - wrong size rows : " //$NON-NLS-1$ - + lineNum); - } - } - } - - public static int calculatePower() { - return 0; - } - - public static long calculatePower(String audio, String rssi, - String brightness, String video, String call, String wifi, - String bt, String dnet, String gps, String camera, String freq, - String sys, String call_plus, String rssi_plus, String voltage) { - - //FIXME remove these -// System.out.println("audio : " + audio); -// System.out.println("rssi : " + rssi); -// System.out.println("brightness : " + brightness); -// System.out.println("video : " + video); -// System.out.println("call : " + call); -// System.out.println("wifi : " + wifi); -// System.out.println("bt : " + bt); -// System.out.println("dnet : " + dnet); -// System.out.println("gps : " + gps); -// System.out.println("camera : " + camera); -// System.out.println("freq : " + freq); -// System.out.println("sys : " + sys); -// System.out.println("call_plus : " + call_plus); -// System.out.println("rssi_plus : " + rssi_plus); -// System.out.println("voltage : " + voltage); -// System.out.println(""); - - long result = 0; - try { - int audioUsage = Integer.parseInt(audio); - int rssiUsage = Integer.parseInt(rssi); - int brightnessUsage = Integer.parseInt(brightness); - if (brightnessUsage > STATE_MAX) { - brightnessUsage = STATE_MAX; - } - int videoUsage = Integer.parseInt(video); - if (videoUsage > 0) { - videoUsage = 1; - } else { - videoUsage = 0; - } - int callUsage = Integer.parseInt(call); - if (callUsage < 0) { - callUsage = 0; - } - int wifiUsage = Integer.parseInt(wifi); - int btUsage = Integer.parseInt(bt); - if (0 == btUsage) { - btUsage = 0; - } else if (4 <= btUsage) { - btUsage = 1; - } else { - btUsage = 2; - } - int dnetUsage = Integer.parseInt(dnet); - int gpsUsage = Integer.parseInt(gps); - int cameraUsage = Integer.parseInt(camera); - if (cameraUsage < 0) { - cameraUsage = 0; - } - int freqUsage = Integer.parseInt(freq); - if (0 > freqUsage) { - freqUsage = CPU_FREQUENCY_100K; // TODO : emul set - } - long systemUsage = Integer.parseInt(sys); - int call_plusUsage = Integer.parseInt(call_plus); - int rssi_plusUsage = Integer.parseInt(rssi_plus); - long voltageUsage = Integer.parseInt(voltage); - if (voltageUsage < 0) { - voltageUsage = DEFAULT_VOLTAGE; // TODO : emul set - } - voltageUsage /= 1000; // to mV - - int cpuMin = 0; - int cpuMax = 0; - long cpuUsage = 0; - long current = 0; - - switch (freqUsage) { - case CPU_FREQUENCY_100K: - case CPU_FREQUENCY_200K: - cpuMin = value[devicePartList.CPU.getIndex()][0]; - cpuMax = value[devicePartList.CPU.getIndex()][1]; - break; - case CPU_FREQUENCY_400K: - case CPU_FREQUENCY_500K: - cpuMin = value[devicePartList.CPU.getIndex()][2]; - cpuMax = value[devicePartList.CPU.getIndex()][3]; - break; - case CPU_FREQUENCY_800K: - cpuMin = value[devicePartList.CPU.getIndex()][4]; - cpuMax = value[devicePartList.CPU.getIndex()][5]; - break; - case CPU_FREQUENCY_1000K: - cpuMin = value[devicePartList.CPU.getIndex()][6]; - cpuMax = value[devicePartList.CPU.getIndex()][7]; - break; - case CPU_FREQUENCY_1200K: - cpuMin = value[devicePartList.CPU.getIndex()][8]; - cpuMax = value[devicePartList.CPU.getIndex()][9]; - break; - default: -// System.out.println("invalid freq..."); - break; - } - - cpuUsage = ((systemUsage * (cpuMax - cpuMin)) / 100) + cpuMin; - - current = value[devicePartList.AUDIO.getIndex()][audioUsage] - + value[devicePartList.RSSI.getIndex()][rssiUsage] - * (1 + rssi_plusUsage) - + value[devicePartList.BRIGHTNESS.getIndex()][brightnessUsage] - + value[devicePartList.VIDEO.getIndex()][videoUsage] - + value[devicePartList.CALL.getIndex()][callUsage] - * (1 + call_plusUsage) - + value[devicePartList.WIFI.getIndex()][wifiUsage] - + value[devicePartList.BT.getIndex()][btUsage] - + value[devicePartList.DNET.getIndex()][dnetUsage] - + value[devicePartList.GPS.getIndex()][gpsUsage] - + value[devicePartList.CAMERA.getIndex()][cameraUsage] - + cpuUsage; - - result = current * voltageUsage; // mA x mV - - //FIXME remove this -// System.out.println(value[devicePartList.AUDIO.getIndex()][audioUsage]); -// System.out.println(value[devicePartList.RSSI.getIndex()][rssiUsage]); -// System.out.println(value[devicePartList.BRIGHTNESS.getIndex()][brightnessUsage]); -// System.out.println(value[devicePartList.VIDEO.getIndex()][videoUsage]); -// System.out.println(value[devicePartList.CALL.getIndex()][callUsage]); -// System.out.println(value[devicePartList.WIFI.getIndex()][wifiUsage]); -// System.out.println(value[devicePartList.BT.getIndex()][btUsage]); -// System.out.println(value[devicePartList.DNET.getIndex()][dnetUsage]); -// System.out.println(value[devicePartList.GPS.getIndex()][gpsUsage]); -// System.out.println(value[devicePartList.CAMERA.getIndex()][cameraUsage]); -// System.out.println(cpuUsage); - -// System.out.println("Current : " + current); -// System.out.println("voltage : " + voltageUsage); -// System.out.println("Result : " + result); - - result /= 1000; // to mW - - } catch (Exception e) { - e.printStackTrace(); - } - - return result; - } + public static int[][] value = new int[11][10]; + public static String deviceName = null; + private static List deviceList = new ArrayList();; + private static HashMap deviceIndex = + new HashMap();; + + private static final int DEFAULT_VOLTAGE = 4000000; + + private static final int CPU_FREQUENCY_100K = 100000; + private static final int CPU_FREQUENCY_200K = 200000; + private static final int CPU_FREQUENCY_400K = 400000; + private static final int CPU_FREQUENCY_500K = 500000; + private static final int CPU_FREQUENCY_800K = 800000; + private static final int CPU_FREQUENCY_1000K = 1000000; + private static final int CPU_FREQUENCY_1200K = 1200000; + + private static final int STATE_MAX = 9; + private static String CMD_TARGET_DEVICE_NAME = "uname -n"; //$NON-NLS-1$ + private static String CURRENT_TABLE_PREFIX = "system_panel_battery_table_"; //$NON-NLS-1$ + private static String CURRENT_TABLE_DEFAULT = "default"; //$NON-NLS-1$ + + private static enum deviceNameList { + F1("F1"), U1("U1"), Emulator("Emulator"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + private final String name; + + deviceNameList(String device) { + name = device; + } + + public String getDevice() { + return name; + } + } + + private static enum devicePartList { + AUDIO(0), RSSI(1), BRIGHTNESS(2), VIDEO(3), CALL(4), WIFI(5), BT(6), DNET(7), GPS(8), CAMERA( + 9), CPU(10); + + private final int value; + + devicePartList(int index) { + value = index; + } + + public int getIndex() { + return value; + } + } + + public DeviceCurrent() { + clear(); + + for (deviceNameList device : deviceNameList.values()) { + deviceList.add(device.getDevice()); + } + + for (devicePartList devicePart : devicePartList.values()) { + deviceIndex.put(devicePart, devicePart.getIndex()); + } + } + + public static void clear() { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + value[i][j] = 0; + } + } + deviceName = null; + } + + private static MultiLineReceiver getDeviceName = new MultiLineReceiver() { + @Override + public void processNewLines(String[] lines) { + if (0 != lines.length && !lines[0].isEmpty()) { + deviceName = lines[0]; + deviceName.trim(); + } + } + }; + + private static boolean isExistDeviceName() { + int size = deviceList.size(); + if (0 < size) { + for (int i = 0; i < size; i++) { + if (deviceName.equals(deviceList.get(i))) { + return true; + } + } + } + return false; + } + + public static void init() { + String tablePath = + AnalyzerConstants.CONFIG_FOLDER_PATH + File.separator + CURRENT_TABLE_PREFIX; + clear(); + DACommunicator.execShellCommand(CMD_TARGET_DEVICE_NAME, getDeviceName); + if (isExistDeviceName()) { + tablePath += deviceName; + } else { + tablePath += CURRENT_TABLE_DEFAULT; + } + setDeviceCurrentInfo(tablePath); + + } + + public static int getValue(int rowIndex, int columnIndex) { + return value[rowIndex][columnIndex]; + } + + public static void setDeviceCurrentInfo(String path) { + String line = null; + String[] values = null; + int lineNum = 0; + + try { + File file = new File(path); + BufferedReader br = new BufferedReader(new FileReader(file)); + while (null != (line = br.readLine())) { + if (line.isEmpty()) { + continue; + } + values = line.split(AnalyzerConstants.SPACE, 10); + if (10 != values.length) { + System.out.println("DeviceCurrent - wrong size columns : " //$NON-NLS-1$ + + values.length); + break; + } + + for (int index = 0; index < 10; index++) { + value[lineNum][index] = Integer.parseInt(values[index]); + } + + lineNum++; + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (NumberFormatException e) { + e.printStackTrace(); + } finally { + if (11 != lineNum) { + System.out.println("DeviceCurrent - wrong size rows : " //$NON-NLS-1$ + + lineNum); + } + } + } + + public static int calculatePower() { + return 0; + } + + public static long calculatePower(String audio, String rssi, String brightness, String video, + String call, String wifi, String bt, String dnet, String gps, + String camera, String freq, String sys, String call_plus, + String rssi_plus, String voltage) { + + // FIXME remove these + // System.out.println("audio : " + audio); + // System.out.println("rssi : " + rssi); + // System.out.println("brightness : " + brightness); + // System.out.println("video : " + video); + // System.out.println("call : " + call); + // System.out.println("wifi : " + wifi); + // System.out.println("bt : " + bt); + // System.out.println("dnet : " + dnet); + // System.out.println("gps : " + gps); + // System.out.println("camera : " + camera); + // System.out.println("freq : " + freq); + // System.out.println("sys : " + sys); + // System.out.println("call_plus : " + call_plus); + // System.out.println("rssi_plus : " + rssi_plus); + // System.out.println("voltage : " + voltage); + // System.out.println(""); + + long result = 0; + try { + int audioUsage = Integer.parseInt(audio); + int rssiUsage = Integer.parseInt(rssi); + int brightnessUsage = Integer.parseInt(brightness); + if (brightnessUsage > STATE_MAX) { + brightnessUsage = STATE_MAX; + } + int videoUsage = Integer.parseInt(video); + if (videoUsage > 0) { + videoUsage = 1; + } else { + videoUsage = 0; + } + int callUsage = Integer.parseInt(call); + if (callUsage < 0) { + callUsage = 0; + } + int wifiUsage = Integer.parseInt(wifi); + int btUsage = Integer.parseInt(bt); + if (0 == btUsage) { + btUsage = 0; + } else if (4 <= btUsage) { + btUsage = 1; + } else { + btUsage = 2; + } + int dnetUsage = Integer.parseInt(dnet); + int gpsUsage = Integer.parseInt(gps); + int cameraUsage = Integer.parseInt(camera); + if (cameraUsage < 0) { + cameraUsage = 0; + } + int freqUsage = Integer.parseInt(freq); + if (0 > freqUsage) { + freqUsage = CPU_FREQUENCY_100K; // TODO : emul set + } + long systemUsage = Integer.parseInt(sys); + int call_plusUsage = Integer.parseInt(call_plus); + int rssi_plusUsage = Integer.parseInt(rssi_plus); + long voltageUsage = Integer.parseInt(voltage); + if (voltageUsage < 0) { + voltageUsage = DEFAULT_VOLTAGE; // TODO : emul set + } + voltageUsage /= 1000; // to mV + + int cpuMin = 0; + int cpuMax = 0; + long cpuUsage = 0; + long current = 0; + + switch (freqUsage) { + case CPU_FREQUENCY_100K: + case CPU_FREQUENCY_200K: + cpuMin = value[devicePartList.CPU.getIndex()][0]; + cpuMax = value[devicePartList.CPU.getIndex()][1]; + break; + case CPU_FREQUENCY_400K: + case CPU_FREQUENCY_500K: + cpuMin = value[devicePartList.CPU.getIndex()][2]; + cpuMax = value[devicePartList.CPU.getIndex()][3]; + break; + case CPU_FREQUENCY_800K: + cpuMin = value[devicePartList.CPU.getIndex()][4]; + cpuMax = value[devicePartList.CPU.getIndex()][5]; + break; + case CPU_FREQUENCY_1000K: + cpuMin = value[devicePartList.CPU.getIndex()][6]; + cpuMax = value[devicePartList.CPU.getIndex()][7]; + break; + case CPU_FREQUENCY_1200K: + cpuMin = value[devicePartList.CPU.getIndex()][8]; + cpuMax = value[devicePartList.CPU.getIndex()][9]; + break; + default: + // System.out.println("invalid freq..."); + break; + } + + cpuUsage = ((systemUsage * (cpuMax - cpuMin)) / 100) + cpuMin; + + current = + value[devicePartList.AUDIO.getIndex()][audioUsage] + + value[devicePartList.RSSI.getIndex()][rssiUsage] + * (1 + rssi_plusUsage) + + value[devicePartList.BRIGHTNESS.getIndex()][brightnessUsage] + + value[devicePartList.VIDEO.getIndex()][videoUsage] + + value[devicePartList.CALL.getIndex()][callUsage] + * (1 + call_plusUsage) + + value[devicePartList.WIFI.getIndex()][wifiUsage] + + value[devicePartList.BT.getIndex()][btUsage] + + value[devicePartList.DNET.getIndex()][dnetUsage] + + value[devicePartList.GPS.getIndex()][gpsUsage] + + value[devicePartList.CAMERA.getIndex()][cameraUsage] + cpuUsage; + + result = current * voltageUsage; // mA x mV + + // FIXME remove this + // System.out.println(value[devicePartList.AUDIO.getIndex()][audioUsage]); + // System.out.println(value[devicePartList.RSSI.getIndex()][rssiUsage]); + // System.out.println(value[devicePartList.BRIGHTNESS.getIndex()][brightnessUsage]); + // System.out.println(value[devicePartList.VIDEO.getIndex()][videoUsage]); + // System.out.println(value[devicePartList.CALL.getIndex()][callUsage]); + // System.out.println(value[devicePartList.WIFI.getIndex()][wifiUsage]); + // System.out.println(value[devicePartList.BT.getIndex()][btUsage]); + // System.out.println(value[devicePartList.DNET.getIndex()][dnetUsage]); + // System.out.println(value[devicePartList.GPS.getIndex()][gpsUsage]); + // System.out.println(value[devicePartList.CAMERA.getIndex()][cameraUsage]); + // System.out.println(cpuUsage); + + // System.out.println("Current : " + current); + // System.out.println("voltage : " + voltageUsage); + // System.out.println("Result : " + result); + + result /= 1000; // to mW + + } catch (Exception e) { + e.printStackTrace(); + } + + return result; + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/renderers/TabButtonRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/renderers/TabButtonRenderer.java index b005f62..1d36b8b 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/renderers/TabButtonRenderer.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/renderers/TabButtonRenderer.java @@ -61,25 +61,12 @@ public class TabButtonRenderer extends DACustomButtonDefaultRenderer { drawButtonText(gc, r, state, attr); } Color c = gc.getForeground(); - Color outline = getOutlineColor(state); + Color outline = attr.getOutlineColor(state); gc.setForeground((outline == null) ?c : outline); gc.drawRectangle(r); gc.setForeground(c); } - private Color getOutlineColor(int state) { - if (state == DACustomButton.STATE_NORMAL) { - return ColorResources.TAB_OUTLINE_NORMAL_COLOR; - } else if (state == DACustomButton.STATE_PUSH) { - return ColorResources.TAB_OUTLINE_PUSH_COLOR; - } else if (state == DACustomButton.STATE_HOVER) { - return ColorResources.TAB_OUTLINE_HOVER_COLOR; - } else if (state == DACustomButton.STATE_DISABLE) { - return ColorResources.TAB_OUTLINE_SELECTED_COLOR; - } - return null; - } - protected void drawButtonImage(GC gc, Rectangle rect, DACustomWidgetAttribute attr) { if (attr != null && attr.getButtonImage() != null) { Image img = attr.getButtonImage(); 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 bcea5bd..c9733e1 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 @@ -52,6 +52,7 @@ import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomToggleButton; import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo; import org.tizen.dynamicanalyzer.widgets.combo.DACustomComboSelectionListener; +import org.tizen.dynamicanalyzer.widgets.daialog.DADailog; import org.tizen.dynamicanalyzer.widgets.timer.TimerClock; @@ -630,6 +631,10 @@ public class CoolbarArea { ColorResources.TAB_HOVER_FONT_COLOR); pageTab.get(TAB_MAIN).setFontColor(DACustomButton.STATE_DISABLE, ColorResources.TAB_SELECTED_FONT_COLOR); + pageTab.get(TAB_MAIN).setOutlineColors(ColorResources.TAB_OUTLINE_NORMAL_COLOR, + ColorResources.TAB_OUTLINE_PUSH_COLOR, + ColorResources.TAB_OUTLINE_HOVER_COLOR, + ColorResources.TAB_OUTLINE_SELECTED_COLOR); pageTab.get(TAB_MAIN).setEnabled(false); pageTab.get(TAB_MAIN).setFont(FontResources.TAB_BUTTON_FONT); @@ -646,6 +651,10 @@ public class CoolbarArea { ColorResources.TAB_SELECTED_FONT_COLOR); pageTab.get(TAB_ANALYSIS).setFont(FontResources.TAB_BUTTON_FONT); pageTab.get(TAB_ANALYSIS).setText(AnalyzerLabels.COOLBAR_AREA_SUMMARY); + pageTab.get(TAB_ANALYSIS).setOutlineColors(ColorResources.TAB_OUTLINE_NORMAL_COLOR, + ColorResources.TAB_OUTLINE_PUSH_COLOR, + ColorResources.TAB_OUTLINE_HOVER_COLOR, + ColorResources.TAB_OUTLINE_SELECTED_COLOR); pageTab.get(TAB_FILE).setRenderer(new TabButtonRenderer()); pageTab.get(TAB_FILE).setFontColor(DACustomButton.STATE_NORMAL, @@ -658,6 +667,10 @@ public class CoolbarArea { ColorResources.TAB_SELECTED_FONT_COLOR); pageTab.get(TAB_FILE).setFont(FontResources.TAB_BUTTON_FONT); pageTab.get(TAB_FILE).setText(AnalyzerLabels.COOLBAR_AREA_FILE); + pageTab.get(TAB_FILE).setOutlineColors(ColorResources.TAB_OUTLINE_NORMAL_COLOR, + ColorResources.TAB_OUTLINE_PUSH_COLOR, + ColorResources.TAB_OUTLINE_HOVER_COLOR, + ColorResources.TAB_OUTLINE_SELECTED_COLOR); pageTab.get(TAB_THREAD).setRenderer(new TabButtonRenderer()); pageTab.get(TAB_THREAD).setFontColor(DACustomButton.STATE_NORMAL, @@ -670,6 +683,10 @@ public class CoolbarArea { ColorResources.TAB_SELECTED_FONT_COLOR); pageTab.get(TAB_THREAD).setFont(FontResources.TAB_BUTTON_FONT); pageTab.get(TAB_THREAD).setText(AnalyzerLabels.COOLBAR_AREA_THREAD); + pageTab.get(TAB_THREAD).setOutlineColors(ColorResources.TAB_OUTLINE_NORMAL_COLOR, + ColorResources.TAB_OUTLINE_PUSH_COLOR, + ColorResources.TAB_OUTLINE_HOVER_COLOR, + ColorResources.TAB_OUTLINE_SELECTED_COLOR); Composite whiteLine = new Composite(parent, SWT.NONE); whiteLine.setBackground(ColorResources.WHITE); @@ -833,7 +850,8 @@ public class CoolbarArea { public void setAppComboText(String text) { AppDesktopInfo appInfo = DACommunicator.getAppDesktopInfoByName(text); if (null != appInfo) { - System.out.println("combo set communicator appinfo :" + appInfo.getName() + " exec : " + appInfo.getExecPath()); + System.out.println("combo set communicator appinfo :" + appInfo.getName() + " exec : " + + appInfo.getExecPath()); DACommunicator.setSelectedApp(appInfo); appCombo.setText(text); } 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 7d92ca0..ceb6798 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 @@ -1,5 +1,6 @@ package org.tizen.dynamicanalyzer.ui.widgets; +import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FormAttachment; @@ -19,7 +20,7 @@ import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener public class AboutDialog { private Shell parent = null; - private DAWindow shell = null; + private Shell shell = null; private DACustomButton licenseButton = null; private DACustomButton okButton = null; @@ -53,21 +54,22 @@ public class AboutDialog { public int open() { - shell = new DAWindow(parent, SWT.APPLICATION_MODAL); +// shell = new DAWindow(parent, SWT.APPLICATION_MODAL); + shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.TITLE); shell.setSize(456, 184); FormLayout shellLayout = new FormLayout(); shell.setLayout(shellLayout); shell.setText(AnalyzerLabels.ABOUT); - shell.setMoveable(true); - shell.setCenter(); +// shell.setMoveable(true); +// shell.setCenter(); - Composite base = new Composite(shell.getShell(), SWT.NONE); + Composite base = new Composite(shell, SWT.NONE); base.setLayout(new FormLayout()); FormData baseData = new FormData(); - baseData.top = new FormAttachment(0, 30); - baseData.left = new FormAttachment(0, 10); - baseData.right = new FormAttachment(100, -10); - baseData.bottom = new FormAttachment(100, -10); + baseData.top = new FormAttachment(0, 0); + baseData.left = new FormAttachment(0, 0); + baseData.right = new FormAttachment(100, 0); + baseData.bottom = new FormAttachment(100, 0); base.setLayoutData(baseData); base.setVisible(true); base.setBackground(ColorResources.WINDOW_BG_COLOR); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DATabComposite.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DATabComposite.java index 7e84840..18ad865 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DATabComposite.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DATabComposite.java @@ -54,7 +54,7 @@ public class DATabComposite extends DAView { data.height = DesignConstants.VIEW_TITLEBAR_HEIGHT; tabComposite.setLayoutData(data); tabComposite.addPaintListener(tabCompositePaintListener); -// tabComposite.setBackground(ColorResources.RED); + // tabComposite.setBackground(ColorResources.RED); data = new FormData(); data.top = new FormAttachment(tabComposite, 0); @@ -81,6 +81,10 @@ public class DATabComposite extends DAView { ColorResources.TAB_PUSH_FONT_COLOR, ColorResources.TAB_HOVER_FONT_COLOR, ColorResources.TAB_SELECTED_FONT_COLOR); + tabButton.setOutlineColors(ColorResources.TAB_OUTLINE_NORMAL_COLOR, + ColorResources.TAB_OUTLINE_PUSH_COLOR, + ColorResources.TAB_OUTLINE_HOVER_COLOR, + ColorResources.TAB_OUTLINE_SELECTED_COLOR); tabButton.setRenderer(new TabButtonRenderer()); tabButton.setEnabled(true); tabButton.setFont(FontResources.TAB_BUTTON_FONT); @@ -225,9 +229,9 @@ public class DATabComposite extends DAView { // ((ViewAction) children.get(i)).updateView(data); // } } - + private PaintListener tabCompositePaintListener = new PaintListener() { - + @Override public void paintControl(PaintEvent e) { Composite comp = (Composite) e.widget; -- 2.7.4