From: Maria Guseva Date: Thu, 30 Mar 2017 17:52:24 +0000 (+0300) Subject: [RELEASE] DA 2.5.3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad520dff253f42afb7e9a4210156f928d2d0dc21;p=sdk%2Ftools%2Fdynamic-analyzer.git [RELEASE] DA 2.5.3 - Introduce new UX of progress bars for time-consuming operations (SRADA-1332) - Improve strategy of choosing target in Feature dialog for run from IDE case (SPTSDKUX-3595) - Fix getting port number on Pride device (SRADA-1428) - Fix JIRA defects: SPTSDKUX-3428: Tracing data is not being saved in given path but no failure message shown SPTSDKUX-3732: Tooltips are not always shown properly in Feature dialog Change-Id: Ifd3b1e18ca7fa5de5b556475bfd024d8809d14d0 --- diff --git a/org.tizen.dynamicanalyzer.cli/src/org/tizen/dynamicanalyzer/cli/commands/StopCommand.java b/org.tizen.dynamicanalyzer.cli/src/org/tizen/dynamicanalyzer/cli/commands/StopCommand.java index 5ccd62e..5f49c90 100644 --- a/org.tizen.dynamicanalyzer.cli/src/org/tizen/dynamicanalyzer/cli/commands/StopCommand.java +++ b/org.tizen.dynamicanalyzer.cli/src/org/tizen/dynamicanalyzer/cli/commands/StopCommand.java @@ -1,7 +1,6 @@ package org.tizen.dynamicanalyzer.cli.commands; import java.io.File; -import java.io.IOException; import java.rmi.ConnectException; import org.tizen.dynamicanalyzer.cli.CliInternals; @@ -9,6 +8,7 @@ import org.tizen.dynamicanalyzer.cli.manager.TracingProcessContext; import org.tizen.dynamicanalyzer.cli.utils.HumanReadableTimeFormat; import org.tizen.dynamicanalyzer.common.DAResult; import org.tizen.dynamicanalyzer.common.DAResult.ErrorCode; +import org.tizen.dynamicanalyzer.common.path.PathManager; public class StopCommand extends Command { @@ -68,6 +68,20 @@ public class StopCommand extends Command { System.err.println("Can't get time from TracingProcessManager"); return ExitCode.EX_OPERATION_FAILED; } + File out = new File(ctx.getArgs().getOutput()); + if (!out.exists()){ + String path = PathManager.DA_TEMP_FOLDER_PATH + File.separator + "unsaved_trace.zip"; + CliInternals.saveTrace(path); + System.out.format( + "DA tracing finished.%n" + + "Total time: %s%n" + + "Tracing time: %s%n" + + "Failed to save in %s%n" + + "Raw data can be found in %s%n", + duration, + tracingTime, ctx.getArgs().getOutput(), path); + return ExitCode.EX_OPERATION_FAILED; + } System.out.format( "DA tracing finished.%n" + "Total time: %s%n" + diff --git a/org.tizen.dynamicanalyzer.common.test/pom.xml b/org.tizen.dynamicanalyzer.common.test/pom.xml index be978ae..d2377fe 100644 --- a/org.tizen.dynamicanalyzer.common.test/pom.xml +++ b/org.tizen.dynamicanalyzer.common.test/pom.xml @@ -6,7 +6,7 @@ dynamic-analyzer org.tizen.dynamicanalyzer - 2.5.2-SNAPSHOT + 2.5.3-SNAPSHOT .. org.tizen.dynamicanalyzer diff --git a/org.tizen.dynamicanalyzer.test/pom.xml b/org.tizen.dynamicanalyzer.test/pom.xml index b8beb85..540abfd 100644 --- a/org.tizen.dynamicanalyzer.test/pom.xml +++ b/org.tizen.dynamicanalyzer.test/pom.xml @@ -6,7 +6,7 @@ dynamic-analyzer org.tizen.dynamicanalyzer - 2.5.2-SNAPSHOT + 2.5.3-SNAPSHOT .. org.tizen.dynamicanalyzer diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/DAWidgetConstants.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/DAWidgetConstants.java index 8878595..88fc318 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/DAWidgetConstants.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/DAWidgetConstants.java @@ -29,4 +29,6 @@ package org.tizen.dynamicanalyzer.widgets; public class DAWidgetConstants { public static final String EMPTY_STRING = ""; //$NON-NLS-1$ public static final String EMPTY_STRING_ID = "da.id.dummy.empty"; + public static final String DEFAULT_PROGRESS_MESSAGE = "Time consuming process(es) is(are) in progress"; + public static final String DEFAULT_PROGRESS_INFO = "Please wait"; } diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/toggle/DACustomFeatureToggleButtonGroup.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/toggle/DACustomFeatureToggleButtonGroup.java index 778ae69..3556232 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/toggle/DACustomFeatureToggleButtonGroup.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/toggle/DACustomFeatureToggleButtonGroup.java @@ -56,6 +56,20 @@ public class DACustomFeatureToggleButtonGroup { } } + /** + * Set selection on the button with the specified name. + * + * @param toggleButtonName name of the button + */ + public void setSelection(String toggleButtonName) { + for (DACustomFeatureToggleButton toggleButton : getToggleButtonList()) { + if (toggleButtonName.equals(toggleButton.getText())) { + setSelection(toggleButton); + return; + } + } + } + private List getToggleButtonList() { if (toggleButtonList == null) { toggleButtonList = new ArrayList(); diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/da/base/ProgressDialog.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/da/base/ProgressDialog.java index 8d723e9..f8f878e 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/da/base/ProgressDialog.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/da/base/ProgressDialog.java @@ -29,19 +29,14 @@ package org.tizen.dynamicanalyzer.widgets.da.base; -import java.util.ArrayList; -import java.util.List; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; @@ -54,55 +49,39 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.tizen.dynamicanalyzer.resources.ColorResources; import org.tizen.dynamicanalyzer.resources.FontResources; -import org.tizen.dynamicanalyzer.resources.ImageResources; -import org.tizen.dynamicanalyzer.util.Logger; import org.tizen.dynamicanalyzer.widgets.DAWidgetConstants; -import org.tizen.dynamicanalyzer.widgets.animation.DAAnimationIcon; -import org.tizen.dynamicanalyzer.widgets.progress.Progress; +import org.tizen.dynamicanalyzer.widgets.progress.CircleProgress; +import org.tizen.dynamicanalyzer.widgets.progress.ProgressHolder; public class ProgressDialog { + private static final int WIDTH = 300; - private static final int HEIGHT = 110; + private static final int HEIGHT = 86; public static final int PROGRESS_STYLE_DEFAULT = 0;// default - public static final int PROGRESS_STYLE_CANCEL = 1; - public static final int PROGRESS_STYLE_WARNING = 2; - public static final int PROGRESS_STYLE_INDETERMINATE = 3; - - public static final int DIALOG_TYPE_SMALL = 0; // default, 41 letters in 1 line (max 3 line) - public static final int DIALOG_TYPE_MIDDLE = 1; // 41 letters in 1 line (max 6 line) - public static final int DIALOG_TYPE_LARGE = 2; // 41 letters in 1 line (max 10 line) - - private int progressStyle = PROGRESS_STYLE_DEFAULT; - private int dialogType = DIALOG_TYPE_SMALL; - + public static final int PROGRESS_STYLE_CANCEL = 1; + public static final int PROGRESS_STYLE_INDETERMINATE = 2; + private Shell parent = null; private Shell shell = null; - private Progress progress = null; private Composite baseComposite = null; - private Composite msgComp = null; - private Composite progressComp = null; + Composite progressComposite; + private Composite progressDialogComposite = null; + + private Label header = null; + + String headerText = DAWidgetConstants.DEFAULT_PROGRESS_MESSAGE; + + Button cancelButton = null; + private Button runInBackgroundButton = null; - private String upperText = DAWidgetConstants.EMPTY_STRING; - private String bottomText = DAWidgetConstants.EMPTY_STRING; - private String warningText = DAWidgetConstants.EMPTY_STRING; - - private Image iconImage = ImageResources.DIALOG_WARNING_ICON; - private Button cancelButton = null; - private Button okButton = null; - - private SelectionListener okButtonListener = null; - private SelectionListener cancelButtonListener = null; private SelectionListener defaultCancelButtonListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { close(); } }; - - // loading animation - private DAAnimationIcon progressIcon = null; private Listener shellMouseListener = new Listener() { boolean down = false; @@ -140,400 +119,264 @@ public class ProgressDialog { } }; - public ProgressDialog(Shell parent, Composite base) { + /** + * Constructor available from package only. + * + * @param parent parent shell + * @param base base composite + */ + ProgressDialog(Shell parent, Composite base) { this.parent = parent; this.baseComposite = base; } public void open() { - switch (progressStyle) { - case PROGRESS_STYLE_DEFAULT: - case PROGRESS_STYLE_CANCEL: - // create progress dialog - createProgress(false); - break; - case PROGRESS_STYLE_WARNING: - // create warning progress dialog - createWarningProgress(); - break; - case PROGRESS_STYLE_INDETERMINATE: - createProgress(true); - default: - break; + if (shell == null) { + createProgressDialog(); + createProgressesFromUI(); } - - if(shell != null) { - shell.setLayout(new FormLayout()); - shell.addPaintListener(new PaintListener() { - @Override - public void paintControl(PaintEvent e) { - Rectangle rect = shell.getClientArea(); - e.gc.setForeground(ColorResources.STOP_PROGRESS_LINE2_COLOR); - e.gc.drawRectangle(rect.x , rect.y, rect.width - 1, - rect.height - 1); - e.gc.setForeground(ColorResources.STOP_PROGRESS_LINE1_COLOR); - e.gc.drawRectangle(rect.x + 1, rect.y + 1, rect.width - 3, - rect.height - 3); - } + shell.notifyListeners(SWT.MouseUp, new Event()); + shell.setLayout(new FormLayout()); + shell.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + if (shell == null) + return; + Rectangle rect = shell.getClientArea(); + e.gc.setForeground(ColorResources.STOP_PROGRESS_LINE2_COLOR); + e.gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1); + e.gc.setForeground(ColorResources.STOP_PROGRESS_LINE1_COLOR); + e.gc.drawRectangle(rect.x + 1, rect.y + 1, rect.width - 3, rect.height - 3); - }); + } + }); - shell.getDisplay().addFilter(SWT.MouseDown, shellMouseListener); - shell.getDisplay().addFilter(SWT.MouseUp, shellMouseListener); - shell.getDisplay().addFilter(SWT.MouseMove, shellMouseListener); - - shell.addListener(SWT.Traverse, new Listener() { - @Override - public void handleEvent(Event event) { - if (event.detail == SWT.TRAVERSE_ESCAPE) { - event.doit = false; - } + shell.getDisplay().addFilter(SWT.MouseDown, shellMouseListener); + shell.getDisplay().addFilter(SWT.MouseUp, shellMouseListener); + shell.getDisplay().addFilter(SWT.MouseMove, shellMouseListener); + + shell.addListener(SWT.Traverse, new Listener() { + @Override + public void handleEvent(Event event) { + if (event.detail == SWT.TRAVERSE_ESCAPE) { + event.doit = false; } - }); + } + }); + if (cancelButton.getListeners(SWT.Selection).length == 0) + cancelButton.addSelectionListener(defaultCancelButtonListener); + if (!ProgressManager.INSTANCE.isBackgroundOnly()) { shell.open(); baseComposite.setEnabled(false); } + CircleProgress.getCircleProgress().setVisible(true); } - - public void createProgress(boolean isIndeterminate) { - shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.NO_TRIM ); - int dialogLocationX = shell.getParent().getLocation().x + (shell.getParent().getSize().x - WIDTH)/2; - int dialogLocationY = shell.getParent().getLocation().y + (shell.getParent().getSize().y - HEIGHT)/2; - shell.setLocation(dialogLocationX, dialogLocationY); - shell.setSize(WIDTH, HEIGHT); - - progressComp = new Composite(shell, SWT.NONE); - progressComp.setLayout(new FormLayout()); - progressComp.setBackground(ColorResources.WHITE); - FormData data = new FormData(); - data.top = new FormAttachment(0, 2); - data.left = new FormAttachment(0, 2); - data.right = new FormAttachment(100, -2); - data.bottom = new FormAttachment(100, -2); - progressComp.setLayoutData(data); - - // upper text - Label upperLabel = new Label(progressComp, SWT.TRANSPARENT | SWT.LEFT); - upperLabel.setText(upperText); - upperLabel.setFont(FontResources.DIALOG_CONTENTS_NORMAL_FONT); - upperLabel.setForeground(ColorResources.BLACK); - upperLabel.setBackground(ColorResources.WHITE); + /** + * Public method that may draw entire {@link ProgressDialog}. Should be + * called from UIThread. + */ + public void draw() { + if (shell == null) + createProgressDialog(); + createProgressesFromUI(); + open(); + } - data = new FormData(); - data.top = new FormAttachment(0, 17); - data.left = new FormAttachment(0, 10); - data.right = new FormAttachment(100, 0); - upperLabel.setLayoutData(data); - - // progress - Composite progressCom = new Composite(progressComp, SWT.NONE); - data = new FormData(); - data.top = new FormAttachment(0, 44); - data.left = new FormAttachment(0, 10); - data.width = 276; - data.height = 22; - progressCom.setLayoutData(data); - progressCom.setLayout(new FillLayout()); - - if (!isIndeterminate) { - progress = new Progress(progressCom, SWT.NONE); - progress.setPercentageFont(FontResources.PROGRESS_PERCENTAGE_FONT); - progress.setFontColor(ColorResources.PROGRESS_PERCENTAGE_FONT_COLOR); - } else { - progressIcon = createProgressIcon(progressCom); - progressIcon.start(); + /** + * Public method that closes {@link ProgressDialog} and hides + * CircleProgress. Should be called from UIThread. + */ + public void close() { + CircleProgress.getCircleProgress().setVisible(false); + if (shell != null) { + shell.close(); + shell = null; } + baseComposite.setEnabled(true); + } - // bottom text - Label bottomLabel = new Label(progressComp, SWT.LEFT | SWT.TRANSPARENT); - bottomLabel.setText(bottomText); - bottomLabel.setFont(FontResources.STOP_PROGRESS_FONT); - bottomLabel.setForeground(ColorResources.BLACK); - bottomLabel.setBackground(ColorResources.WHITE); - - data = new FormData(); - data.left = new FormAttachment(0, 12); - data.top = new FormAttachment(progressCom, 10); - data.height = 20; - bottomLabel.setLayoutData(data); - - FormData cancelData = new FormData(); - cancelData.top = new FormAttachment(progressCom, 10); - cancelData.right = new FormAttachment(100, -8); - cancelData.width = 88; - cancelData.height = 22; + /** + * Set header of ProgressDialog equals to the specified message, if the + * message is not empty or null. Otherwise header is set equals to + * {@code DAWidgetConstants.DEFAULT_PROGRESS_MESSAGE} + * + * @param message message + */ + public void setHeaderMessage(String message) { + if (message != null && !message.isEmpty()) + headerText = message; + else + headerText = DAWidgetConstants.DEFAULT_PROGRESS_MESSAGE; + if (header != null) + header.setText(headerText); + } - // cancel button - if(progressStyle == PROGRESS_STYLE_CANCEL || - progressStyle == PROGRESS_STYLE_INDETERMINATE) { - cancelButton = createButton(progressComp, "Cancel", cancelData); - cancelButton.setLayoutData(cancelData); - - if (cancelButtonListener != null) - cancelButton.addSelectionListener(cancelButtonListener); - else - cancelButton.addSelectionListener(defaultCancelButtonListener); - } - + public void setCancelEnabled(final boolean enable) { + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + cancelButton.setEnabled(enable); + cancelButton.redraw(); + } + }); } - public void createWarningProgress() { - - List sizeInfo = new ArrayList(); - for(DADialogEnum.progressDialogInfo info : DADialogEnum.progressDialogInfo.values() ) { - switch(dialogType) { - case DIALOG_TYPE_SMALL : - sizeInfo.add(info.getSmall()); - break; - case DIALOG_TYPE_MIDDLE: - sizeInfo.add(info.getMiddle()); - break; - case DIALOG_TYPE_LARGE: - sizeInfo.add(info.getLarge()); - break; - default: - Logger.warning("Invalid dialogType:" + dialogType); - break; + /** + * Indicate whether separate window for progress bar should be created or + * not. + */ + private boolean backgroundOnly = false; + + /** + * @return whether progress should be shown in background only. + */ + public boolean isBackgroundOnly() { + return backgroundOnly; + } + + /** + * Set {@code backgroundOnly} property of ProgressDialog and hide or show it + * according to the specified value. + * + * @param backgroundOnly indicate whether dialog should be hidden or not + */ + public void setBackgroundOnly(boolean backgroundOnly) { + this.backgroundOnly = backgroundOnly; + if (backgroundOnly) { + CircleProgress.getCircleProgress().setVisible(true); + if (shell != null) { + shell.close(); + shell = null; } + baseComposite.setEnabled(true); + } else { + open(); } - + } + + // ----------------------------Utility methods--------------------------------------------- + + /** + * Create progress dialog. Should be called from UI. + */ + private void createProgressDialog() { + // define shell size. Can be redefined by adding new progress bars. shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.NO_TRIM ); - int dialogLocationX = shell.getParent().getLocation().x + (shell.getParent().getSize().x - 350)/2; - int dialogLocationY = shell.getParent().getLocation().y + (shell.getParent().getSize().y - sizeInfo.get(0))/2; + int height = HEIGHT + ProgressHolder.HEIGHT * ProgressManager.INSTANCE.progresses.size(); + int dialogLocationX = shell.getParent().getLocation().x + + (shell.getParent().getSize().x - WIDTH) / 2; + int dialogLocationY = shell.getParent().getLocation().y + + (shell.getParent().getSize().y - height) / 2; shell.setLocation(dialogLocationX, dialogLocationY); - shell.setSize(350, sizeInfo.get(0)); - - msgComp = new Composite(shell, SWT.NONE); - msgComp.setLayout(new FormLayout()); - FormData baseData = new FormData(); - baseData.top = new FormAttachment(0, 2); - baseData.left = new FormAttachment(0, 2); - baseData.right = new FormAttachment(100, -2); - baseData.height = sizeInfo.get(1); - - msgComp.setLayoutData(baseData); - msgComp.setBackground(ColorResources.WHITE); - msgComp.setVisible(true); - - // warning icon - Label icon = new Label(msgComp, SWT.TRANSPARENT); - icon.setImage(iconImage); - - FormData formData = new FormData(); - formData.left = new FormAttachment(0, 15); - formData.top = new FormAttachment(0, sizeInfo.get(2)); - formData.height = 64; - formData.width = 64; - icon.setLayoutData(formData); - - // upper text - Label upperLabel = new Label(msgComp, SWT.TRANSPARENT | SWT.LEFT); - upperLabel.setText(upperText); - upperLabel.setFont(FontResources.PROGRESS_FONT); - upperLabel.setForeground(ColorResources.BLACK); - upperLabel.setBackground(ColorResources.WHITE); - - formData = new FormData(); - formData.left = new FormAttachment(0, 92); - formData.right = new FormAttachment(95, 0); - formData.top = new FormAttachment(0, 15); - upperLabel.setLayoutData(formData); - - // warning message - Label strMessage = new Label(msgComp, SWT.WRAP | SWT.TRANSPARENT | SWT.LEFT); - strMessage.setText(warningText); - strMessage.setFont(FontResources.STOP_PROGRESS_FONT); - strMessage.setForeground(ColorResources.BLACK); - strMessage.setBackground(ColorResources.WHITE); - - formData = new FormData(); - formData.left = new FormAttachment(0, 92); - formData.right = new FormAttachment(95, 0); - formData.top = new FormAttachment(upperLabel, 5); - formData.bottom = new FormAttachment(100, 0); - strMessage.setLayoutData(formData); - - // progress composite - progressComp = new Composite(shell, SWT.NONE); - progressComp.setLayout(new FormLayout()); - progressComp.setBackground(ColorResources.DIALOG_BG_LOWER); + shell.setSize(WIDTH, height); + // create composite for ProgressDialog + progressDialogComposite = new Composite(shell, SWT.NONE); + progressDialogComposite.setLayout(new FormLayout()); + progressDialogComposite.setBackground(ColorResources.WHITE); FormData data = new FormData(); - data.top = new FormAttachment(msgComp, 0); + data.top = new FormAttachment(0, 2); data.left = new FormAttachment(0, 2); data.right = new FormAttachment(100, -2); data.bottom = new FormAttachment(100, -2); - progressComp.setLayoutData(data); + progressDialogComposite.setLayoutData(data); - progress = new Progress(progressComp, SWT.NONE); - progress.setPercentageFont(FontResources.PROGRESS_PERCENTAGE_FONT); - progress.setFontColor(ColorResources.PROGRESS_PERCENTAGE_FONT_COLOR); + // header + createHeader(); + // progress composite + progressComposite = new Composite(progressDialogComposite, SWT.NONE); data = new FormData(); - data.left = new FormAttachment(0, 11); - data.top = new FormAttachment(0, 10); - data.width = 325; - data.height = 22; - progress.setLayoutData(data); - progress.errorOccured(); - - // bottom text - Label bottomLabel = new Label(progressComp, SWT.LEFT | SWT.TRANSPARENT); - bottomLabel.setText(bottomText); - bottomLabel.setFont(FontResources.STOP_PROGRESS_FONT); - bottomLabel.setForeground(ColorResources.BLACK); - bottomLabel.setBackground(ColorResources.WHITE); - - formData = new FormData(); - formData.left = new FormAttachment(0, 12); - formData.top = new FormAttachment(0, 41); - formData.height = 20; - bottomLabel.setLayoutData(formData); - - // ok button - FormData okData = new FormData(); - okData.top = new FormAttachment(0, 41); - okData.right = new FormAttachment(100, -12); - okData.width = 88; - okData.height = 22; - - okButton = createButton(progressComp, "OK", okData); - okButton.setEnabled(false); - okButton.setLayoutData(okData); - okButton.addSelectionListener(new SelectionListener () { - - @Override - public void widgetDefaultSelected(SelectionEvent arg0) { - } - - @Override - public void widgetSelected(SelectionEvent arg0) { - close(); - } - - }); - - if (okButtonListener != null) { - okButton.addSelectionListener(okButtonListener); - } + data.top = new FormAttachment(header, 10); + data.left = new FormAttachment(0, 10); + data.width = 276; + data.height = ProgressHolder.HEIGHT; + progressComposite.setLayoutData(data); + progressComposite.setLayout(new FormLayout()); + // buttons + createButtons(); } - public void close() { - if (progress != null) { - if (!progress.isDisposed()) { - progress.dispose(); - } - progress = null; - } - if (shell != null) { - if (!shell.isDisposed()) { - shell.dispose(); - } - shell = null; + /** + * Create UI representation of {@link ProgressHolder} instances. Should be + * called from UI. + */ + private void createProgressesFromUI() { + FormData data; + for (int i = 0; i < ProgressManager.INSTANCE.progresses.size(); i++) { + ProgressHolder progress = ProgressManager.INSTANCE.progresses.get(i); + if (progress.isVisible()) + continue; + progress.createProgress(progressComposite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(0, ProgressHolder.HEIGHT * i); + data.left = new FormAttachment(0, 0); + data.width = 276; + data.height = ProgressHolder.HEIGHT; + progress.setLayoutData(data); + if (progress.getCancelListener() != null) + this.cancelButton.addSelectionListener(progress.getCancelListener()); } - baseComposite.setEnabled(true); } - public void setIcon(Image img) { - iconImage = img; - } + /** + * Create header message of progress dialog. Should be called from UI. + */ + private void createHeader() { + header = new Label(progressDialogComposite, SWT.TRANSPARENT | SWT.LEFT); + header.setText(headerText); + header.setFont(FontResources.DIALOG_CONTENTS_NORMAL_FONT); + header.setForeground(ColorResources.BLACK); + header.setBackground(ColorResources.WHITE); - public void setProgressMessage(String message) { - upperText = message; + FormData data = new FormData(); + data.top = new FormAttachment(0, 17); + data.left = new FormAttachment(0, 10); + data.right = new FormAttachment(95, 0); + header.setLayoutData(data); } - public void setProgressInfo(String infoMessage) { - bottomText = infoMessage; - } + /** + * Create progress dialog buttons. Should be called from UI. + */ + private void createButtons() { + // cancel button + FormData cancelData = new FormData(); + cancelData.top = new FormAttachment(progressComposite, 10); + cancelData.right = new FormAttachment(100, -8); + cancelData.width = 88; + cancelData.height = 22; - public void setProgressWarningMessage(String message) { - warningText = message; - } - - public void setProgressStyle(int style) { - progressStyle = style; - } - - public void setValue(int value) { - //TODO 진행률 표시 - if(progress == null) { - return; - } - - progress.setValue(value); - // ok button enable - if ((progressStyle == PROGRESS_STYLE_WARNING) - && (null != okButton) && (value == progress.getMaxSize()) ){ - setOkEnabled(true); - } - } - - public void setValues(String progressMessage, int value) { - upperText = progressMessage; - progress.setValue(value); - } + cancelButton = createButton(progressDialogComposite, "Cancel", cancelData); + cancelButton.setLayoutData(cancelData); - public void errorOccurred(String message, String bottomMessage) { - progress.errorOccured(); - bottomText = bottomMessage; - upperText = message; - } - - private Button createButton(Composite comp, String text, FormData data) { - Button button = new Button(comp, SWT.NONE); - button.setText(text); - button.setLayoutData(data); - button.setFont(FontResources.DIALOG_BUTTON_FONT); - - return button; - } - - public void setOkEnabled(final boolean enable) { - Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - okButton.setEnabled(enable); - okButton.redraw(); - } - }); - } + // Run in Background button + FormData runInBackgroundData = new FormData(); + runInBackgroundData.top = new FormAttachment(progressComposite, 10); + runInBackgroundData.right = new FormAttachment(cancelButton, -8); + runInBackgroundData.width = 138; + runInBackgroundData.height = 22; - public void setCancelEnabled(final boolean enable) { - Display.getDefault().syncExec(new Runnable() { + runInBackgroundButton = createButton(progressDialogComposite, "Run in Background", + runInBackgroundData); + runInBackgroundButton.addSelectionListener(new SelectionAdapter() { @Override - public void run() { - cancelButton.setEnabled(enable); - cancelButton.redraw(); + public void widgetSelected(SelectionEvent e) { + ProgressManager.INSTANCE.setBackgroundOnly(true); } }); } - - public void setWarnigDialogType(int type) { - dialogType = type; - } - - public void setOkListener(SelectionListener listener) { - okButtonListener = listener; - } /** - * Replace default 'Cancel' button listener with the specified listener. - * - * @param listener listener to set as {@link SelectionListener} for 'Cancel' - * button + * Create specified button on progress dialog. Should be called from UI. */ - public void setCancelListener(SelectionListener listener) { - cancelButtonListener = listener; - } - - private DAAnimationIcon createProgressIcon(Composite comp) { - List progressImage = new ArrayList(); - - progressImage.add(ImageResources.INDETERMINATE_PROGRESS_01); - progressImage.add(ImageResources.INDETERMINATE_PROGRESS_02); - - return new DAAnimationIcon(comp, SWT.NONE, progressImage); + private Button createButton(Composite comp, String text, FormData data) { + Button button = new Button(comp, SWT.NONE); + button.setText(text); + button.setLayoutData(data); + button.setFont(FontResources.DIALOG_BUTTON_FONT); + return button; } -} \ No newline at end of file +} diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/da/base/ProgressManager.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/da/base/ProgressManager.java new file mode 100644 index 0000000..4ebf762 --- /dev/null +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/da/base/ProgressManager.java @@ -0,0 +1,156 @@ +package org.tizen.dynamicanalyzer.widgets.da.base; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.tizen.dynamicanalyzer.util.Logger; +import org.tizen.dynamicanalyzer.widgets.progress.CircleProgress; +import org.tizen.dynamicanalyzer.widgets.progress.ProgressHolder; + +/** + * Manager that can add and remove progresses to ProgressDialog. Also used to + * communicate between foreground and background representation of progresses. + * + * @author p.privalov@partner.samsung.com + */ +public class ProgressManager { + + public static ProgressManager INSTANCE; + + private static final int DELAY = 100; + + /** + * Private constructor. + * + * @param parent parent {@link Shell} + * @param base base {@link Composite} + */ + private ProgressManager(Shell parent, Composite base) { + this.dialog = new ProgressDialog(parent, base); + } + + private ProgressDialog dialog; + + List progresses = new ArrayList<>(); + + /** + * This variable may be changed from different threads. + */ + private volatile boolean backgroundOnly = true; + + /** + * Public method that calls constructor, if {@code INSTANCE} is not created + * yet. + * + * @param parent parent {@link Shell} + * @param base base {@link Composite} + * @return {@code INSTANCE} + */ + public static synchronized ProgressManager createProgressManager(Shell parent, Composite base) { + if (INSTANCE == null) + INSTANCE = new ProgressManager(parent, base); + return INSTANCE; + } + + /** + * Create new Progress and show it. + * + * @param runInBackground indicate whether progress should be shown in + * background only or not. ProgressDialog will be shown if at + * least one progress should be shown in foreground mode. + * @param progressStyle progress style from + * {@code ProgressDialog.PROGRESS_STYLE_DEFAULT}, + * {@code ProgressDialog.PROGRESS_STYLE_CANCEL} and + * {@code ProgressDialog.PROGRESS_STYLE_INDETERMINATE} + * @param upperText text on top of progress bar with a short description of + * progress + * @param bottomText text under the bar with a description of current status + * of progress + * @param cancelListener action, performed if progress canceled + * @return corresponding {@link ProgressHolder} instance + */ + public ProgressHolder createProgress(boolean runInBackground, int progressStyle, + String upperText, String bottomText, SelectionListener cancelListener) { + this.backgroundOnly = this.backgroundOnly && runInBackground; + ProgressHolder progress = new ProgressHolder(progressStyle, upperText, bottomText, + cancelListener); + progresses.add(progress); + Display.getDefault().syncExec(dialog::draw); + return progress; + } + + /** + * Stop specified progress. If it is an only progress then + * {@link ProgressDialog} is closed also. + * + * @param progress {@link ProgressDialog} to stop + */ + public void stopProgress(ProgressHolder progress) { + progresses.remove(progress); + // stopProgress(..) method may be called not only from UI thread + Display.getDefault().asyncExec(progress::dispose); + if (progresses.isEmpty()) { + Display.getDefault().asyncExec(dialog::close); + backgroundOnly = true; + } + else + dialog.draw(); + } + + /** + * Update value of {@link CircleProgress} according to value of currently + * running progresses. + */ + public void updateValue() { + int v = 0; + for (ProgressHolder p : progresses) + v += p.getValue(); + v = v / progresses.size(); + CircleProgress.getCircleProgress().setValue(v); + if (v == 100) { + try { + Thread.sleep(DELAY); + } catch (InterruptedException e) { + Logger.error(e); + Thread.currentThread().interrupt(); + } finally { + // updateValue() method may be called not only from UI thread + Display.getDefault().asyncExec(() -> { + CircleProgress.getCircleProgress().setVisible(false); + CircleProgress.getCircleProgress().setValue(0); + dialog.close(); + }); + } + } + } + + /** + * Return common header for running progresses. Return text of upper label + * if there is only one {@code headerText} + */ + public String getUpperString() { + if (progresses.size() == 1) + return progresses.get(0).getUpperText(); + return dialog.headerText; + } + + public boolean isBackgroundOnly() { + return backgroundOnly; + } + + /** + * Set value of the {@code backgroundOnly} field and notifies + * {@link ProgressDialog}. + * + * @param b flag indicates whether dialog should be run in background mode + * or not. + */ + public void setBackgroundOnly(boolean b) { + this.backgroundOnly = b; + dialog.setBackgroundOnly(b); + } +} diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/BarProgress.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/BarProgress.java new file mode 100644 index 0000000..2d8505b --- /dev/null +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/BarProgress.java @@ -0,0 +1,93 @@ +package org.tizen.dynamicanalyzer.widgets.progress; + +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; + +/** + * Class to draw foreground progress bar. + */ +public class BarProgress extends Canvas { + + /** color resources for progress bar. May be changed if error occurs */ + Color barStartColor = ColorResources.POINT; + Color barEndColor = ColorResources.POINT; + + /** Progress value in percentage */ + private int value = 0; + + /** + * Public constructor. + * + * @param parent parent composite + * @param style SWT style + */ + public BarProgress(Composite parent, int style) { + super(parent, style); + this.addPaintListener(this::drawBar); + } + + /** + * Set progress value. + * + * @param value value in percentages + */ + public void setValue(int value) { + if (value < 0 || value > 100) + return; + this.value = value; + if (!ProgressManager.INSTANCE.isBackgroundOnly()) { + Display.getDefault().syncExec(() -> { + if (this.isDisposed()) + return; + this.redraw(); + this.update(); + }); + } + } + + /** + * Draw progress bar and show percentages. + * + * @param e drawing event + */ + public void drawBar(PaintEvent e) { + Canvas canvas = (Canvas) e.widget; + Rectangle rect = canvas.getBounds(); + + // background + e.gc.setForeground(ProgressHolder.barStartBgColor); + e.gc.setBackground(ProgressHolder.barEndBgColor); + e.gc.fillGradientRectangle(0, 0, rect.width, rect.height, true); + + int width = (value * rect.width) / 100; + e.gc.setForeground(barStartColor); + e.gc.setBackground(barEndColor); + e.gc.fillGradientRectangle(0, 0, width, rect.height, true); + + // outline + e.gc.setForeground(ProgressHolder.barOutlineColor); + e.gc.drawRectangle(new Rectangle(0, 0, rect.width - 1, rect.height - 1)); + + // text percentage + Point widgetSize = getSize(); + String text = value + "%"; + if (ProgressHolder.percentageFont != null) { + e.gc.setFont(ProgressHolder.percentageFont); + } + if (ProgressHolder.fontColor != null) { + e.gc.setForeground(ProgressHolder.fontColor); + } + + Point textSize = e.gc.stringExtent(text); + e.gc.drawString(text, (widgetSize.x - textSize.x) / 2, + ((widgetSize.y - textSize.y) / 2) + 1, true); + } + +} diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/CircleProgress.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/CircleProgress.java new file mode 100644 index 0000000..923ab44 --- /dev/null +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/CircleProgress.java @@ -0,0 +1,182 @@ +package org.tizen.dynamicanalyzer.widgets.progress; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.MouseTrackListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; + +/** + * Class to draw background progress bar. Singleton. + */ +public class CircleProgress extends Canvas { + + /** color resources for progress bar. May be changed if error occurs */ + Color barStartColor = ColorResources.POINT; + Color barEndColor = ColorResources.POINT; + + /** Progress value in percentage */ + private int value = 0; + + private boolean mDown; + private boolean mHover; + + private void setMDown(boolean value) { + boolean changed = false; + if (mDown != value) + changed = true; + mDown = value; + if (changed) + Display.getDefault().syncExec(() -> { + INSTANCE.redraw(); + INSTANCE.update(); + }); + } + + private void setMHover(boolean value) { + boolean changed = false; + if (mHover != value) + changed = true; + mHover = value; + if (changed) + Display.getDefault().syncExec(() -> { + INSTANCE.redraw(); + INSTANCE.update(); + }); + } + + /** An only instance of this class */ + static CircleProgress INSTANCE; + + private CircleProgress(Composite parent, int style) { + super(parent, style); + this.addPaintListener(this::drawCircle); + this.addMouseListener(new MouseListener() { + @Override + public void mouseUp(MouseEvent e) { + setMDown(false); + } + @Override + public void mouseDown(MouseEvent e) { + setMDown(true); + if (mHover) + ProgressManager.INSTANCE.setBackgroundOnly(false); + } + @Override + public void mouseDoubleClick(MouseEvent e) { + // this event should not trigger anything + } + }); + this.addMouseTrackListener(new MouseTrackListener() { + @Override + public void mouseHover(MouseEvent e) { + setMHover(true); + } + @Override + public void mouseExit(MouseEvent e) { + setMHover(false); + } + @Override + public void mouseEnter(MouseEvent e) { + setMHover(true); + } + }); + } + + /** + * @return Instance of {@link CircleProgress}. Return {@code null} if it is + * not initialized yet. + */ + public static CircleProgress getCircleProgress() { + return INSTANCE; + } + + /** + * Return instance of {@link CircleProgress}. Create new one if it is not + * created yet. + * + * @param parent parent composite + * @param style {@link SWT} style + * @return instance of {@link CircleProgress} + */ + public static synchronized CircleProgress getCircleProgress(Composite parent, int style) { + if (INSTANCE == null) + INSTANCE = new CircleProgress(parent, style); + return INSTANCE; + } + + /** + * Set progress value. + * + * @param value value in percentages + */ + public void setValue(int value) { + if (value < 0 || value > 100) + return; + this.value = value; + Display.getDefault().syncExec(() -> { + INSTANCE.redraw(); + INSTANCE.update(); + }); + } + + /** + * Draw progress circle and show percentages. + * + * @param e drawing event + */ + private void drawCircle(PaintEvent e) { + Canvas canvas = (Canvas) e.widget; + Rectangle rect = canvas.getBounds(); + // left offset for text. It depends from rect.height, because graphical + // part is inside square, with side equals to rect.height. + int textOffset = rect.height + 2; + + // draw 'button' around Circle progress + if(mHover){ + // if 'button' is 'pressed' it is drawn with horizontal and + // vertical shift + int shift = mDown ? 1 : 0; + e.gc.drawRoundRectangle(shift, shift, rect.height, rect.height, 4, 4); + } + + // background + e.gc.setForeground(ProgressHolder.barStartBgColor); + e.gc.setBackground(ProgressHolder.barEndBgColor); + e.gc.setLineWidth(4); + e.gc.drawOval(3, 3, rect.height - 5, rect.height - 5); + + int width = (value * 360) / 100; + e.gc.setForeground(barStartColor); + e.gc.setBackground(barEndColor); + e.gc.drawArc(3, 3, rect.height - 5, rect.height - 5, 90, -width); + + // set font and color + if (ProgressHolder.percentageFont != null) { + e.gc.setFont(ProgressHolder.percentageFont); + } + if (ProgressHolder.fontColor != null) { + e.gc.setForeground(ProgressHolder.fontColor); + } + + // draw UpperLabel + String text = ProgressManager.INSTANCE.getUpperString(); + int chars = (rect.width - textOffset) / e.gc.getFontMetrics().getAverageCharWidth(); + chars = text.lastIndexOf(' ', chars); + text = text.substring(0, chars); + text += "..."; + e.gc.drawString(text, textOffset, 1, true); + + // text percentage + String percent = value + "%"; + + e.gc.drawString(percent, textOffset, rect.height / 2 + 1, true); + } +} diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/Progress.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/Progress.java deleted file mode 100644 index ad74987..0000000 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/Progress.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Dynamic Analyzer - * - * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Hyeran Kim - * Heeyoung Hwang - * Jooyoul Lee - * yeongtaik byeon - * Juyoung Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -package org.tizen.dynamicanalyzer.widgets.progress; - -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.tizen.dynamicanalyzer.widgets.helper.ColorResources; - -public class Progress extends Canvas { - // progress bar areas - private Color barStartBgColor = ColorResources.GRAY_245; - private Color barEndBgColor = ColorResources.GRAY_245; - private Color barStartColor = ColorResources.POINT; - private Color barEndColor = ColorResources.POINT; - private Color barOutlineColor = ColorResources.POINT; - - private int maxSize = 100; - private int value = 0; - - private Font percentageFont = null; - private Color fontColor = null; - - public Progress(Composite parent, int style) { - super(parent, style); - this.addPaintListener(progressPaintListener); - } - - private PaintListener progressPaintListener = new PaintListener() { - - @Override - public void paintControl(PaintEvent e) { - Canvas canvas = (Canvas) e.widget; - Rectangle rect = canvas.getBounds(); - - //background - e.gc.setForeground(barStartBgColor); - e.gc.setBackground(barEndBgColor); - e.gc.fillGradientRectangle(0, 0, rect.width,rect.height, true); - - int width = (value * rect.width) / 100; - e.gc.setForeground(barStartColor); - e.gc.setBackground(barEndColor); - e.gc.fillGradientRectangle(0, 0 , width, rect.height, true); - - //outline - e.gc.setForeground(barOutlineColor); - e.gc.drawRectangle(new Rectangle(0, 0, rect.width-1, rect.height-1)); - - //text percentage - final Point widgetSize = getSize(); - final String text = value + "%"; - if(percentageFont != null) { - e.gc.setFont(percentageFont); - } - if(fontColor != null) { - e.gc.setForeground(fontColor); - } - - final Point textSize = e.gc.stringExtent(text); - e.gc.drawString(text, ((widgetSize.x - textSize.x) / 2), - ((widgetSize.y - textSize.y) / 2) + 1, true); - - } - }; - - public void setBarStartBackgroundColor(Color color) { - barStartBgColor = color; - } - - public void setBarEndBackgroundColor(Color color) { - barEndBgColor = color; - } - - public void setBarStartColor(Color color) { - barStartColor = color; - } - - public void setBarEndColor(Color color) { - barEndColor = color; - } - - public void setBarOutlineColor(Color color) { - barOutlineColor = color; - } - - public int getMaxSize() { - return maxSize; - } - - public void setMaxSize(int maxSize) { - this.maxSize = maxSize; - } - - public int getValue() { - return value; - } - - public void setValue(int value) { - this.value = value; - this.redraw(); - this.update(); - } - - public void errorOccured() { - barStartColor = ColorResources.RED; - barEndColor = ColorResources.WHITE; - } - - public void setPercentageFont(Font font) { - this.percentageFont = font; - } - - public void setFontColor(Color color) { - this.fontColor = color; - } -} \ No newline at end of file diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/ProgressHolder.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/ProgressHolder.java new file mode 100644 index 0000000..dcd31f3 --- /dev/null +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/progress/ProgressHolder.java @@ -0,0 +1,277 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran Kim + * Heeyoung Hwang + * Jooyoul Lee + * yeongtaik byeon + * Juyoung Kim + * Petr Privalov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalyzer.widgets.progress; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.tizen.dynamicanalyzer.resources.FontResources; +import org.tizen.dynamicanalyzer.resources.ImageResources; +import org.tizen.dynamicanalyzer.widgets.animation.DAAnimationIcon; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; +import org.tizen.dynamicanalyzer.widgets.helper.ColorResources; + +/** + * Common class for progresses. Store resources and manage behavior of both + * foreground and background progress bars. + */ +public class ProgressHolder { + // progress bar areas + static final Color barStartBgColor = ColorResources.GRAY_245; + static final Color barEndBgColor = ColorResources.GRAY_245; + static final Color barOutlineColor = ColorResources.POINT; + public static final int HEIGHT = 66; + + // font settings + static Font percentageFont = FontResources.PROGRESS_PERCENTAGE_FONT; + static Color fontColor = org.tizen.dynamicanalyzer.resources.ColorResources.PROGRESS_PERCENTAGE_FONT_COLOR; + + // Current progress in percentage. + private int value; + private String upperText = ""; + private String bottomText = ""; + + private Label upperLabel; + private Label bottomLabel; + + /** Foreground progress bar instance */ + BarProgress barProgress; + + private int progressStyle; + + private SelectionListener cancelListener; + + private Composite progress; + + /** + * Public constructor. + * + * @param style progress style from + * {@code ProgressDialog.PROGRESS_STYLE_DEFAULT}, + * {@code ProgressDialog.PROGRESS_STYLE_CANCEL} and + * {@code ProgressDialog.PROGRESS_STYLE_INDETERMINATE} + * @param upperText text on top of progress bar with a short description of + * progress + * @param bottomText text under the bar with a description of current status + * of progress + * @param cancelListener action, performed if progress canceled + */ + public ProgressHolder(int style, String upperText, String bottomText, + SelectionListener cancelListener) { + this.progressStyle = style; + this.upperText = upperText; + this.bottomText = bottomText; + this.cancelListener = cancelListener; + } + + /** + * Create progress bar and labels. + * + * @param parent parent composite + * @param swtStyle style in SWT terms + */ + public void createProgress(Composite parent, int swtStyle) { + if (progress != null && !progress.isDisposed()) + progress.dispose(); + progress = new Composite(parent, swtStyle); + progress.setLayout(new FormLayout()); + progress.setBackground(ColorResources.WHITE); + upperLabel = new Label(progress, SWT.NONE); + upperLabel.setText(upperText); + FormData data = new FormData(); + data.top = new FormAttachment(0, 0); + data.left = new FormAttachment(0, 0); + data.right = new FormAttachment(100, 0); + upperLabel.setLayoutData(data); + + Composite progressComposite = new Composite(progress, SWT.NONE); + + switch (progressStyle) { + case ProgressDialog.PROGRESS_STYLE_DEFAULT: + case ProgressDialog.PROGRESS_STYLE_CANCEL: + // create progress dialog + barProgress = new BarProgress(progressComposite, SWT.NONE); + break; + case ProgressDialog.PROGRESS_STYLE_INDETERMINATE: + DAAnimationIcon progressIcon = createProgressIcon(progressComposite); + progressIcon.start(); + break; + default: + break; + } + data = new FormData(); + data.top = new FormAttachment(0, 20); + data.left = new FormAttachment(0, 0); + data.height = 22; + data.width = 276; + progressComposite.setLayoutData(data); + progressComposite.setLayout(new FillLayout()); + + bottomLabel = new Label(progress, SWT.NONE); + bottomLabel.setText(bottomText); + data = new FormData(); + data.top = new FormAttachment(progressComposite, 3); + data.left = new FormAttachment(0, 0); + bottomLabel.setLayoutData(data); + + // this is required when ProgressDialog restored from background + if (barProgress != null) + barProgress.setValue(value); + } + + /** + * Set progress bar value to progress bar. + * + * @param value value to set + */ + public void setValue(int value) { + if (value < 0) + value = 0; + if (value > 100) + value = 100; + this.value = value; + if (barProgress != null) + barProgress.setValue(value); + ProgressManager.INSTANCE.updateValue(); + } + + /** + * Set value of both {@code upperLabel} and {@code value}. + */ + public void setValues(String progressMessage, int value) { + setUpperText(progressMessage); + setValue(value); + } + + /** + * In case of error occurred, ProgressBar color is changed and user may be + * notified with new messages. + * + * @param message information message + * @param bottomMessage status message + */ + public void errorOccured(String message, String bottomMessage) { + barProgress.barStartColor = ColorResources.RED; + barProgress.barEndColor = ColorResources.WHITE; + + upperLabel.setText(message); + bottomLabel.setText(bottomMessage); + } + + /** + * Method to forward layout to inner composite. + * + * @param layout layout for inner composite + */ + public void setLayoutData(Object layout) { + progress.setLayoutData(layout); + } + + /** + * Dispose foreground progress bar and make background progress bar + * invisible. + */ + public void dispose() { + progress.dispose(); + } + + /** + * @return {@code true} if progress is already started and visible now. + */ + public boolean isVisible() { + return progress != null && !progress.isDisposed() && progress.isVisible(); + } + + /** + * @return actual value of progress. + */ + public int getValue() { + return value; + } + + /** + * @return text of upper label + */ + public String getUpperText() { + return this.upperText; + } + + /** + * Set text of upper label. + * + * @param progressMessage text to set + */ + public void setUpperText(String progressMessage) { + this.upperText = progressMessage; + } + + /** + * Create animated progress icon on the selected composite. + * + * @param comp parent composite + * @return animated icon + */ + private DAAnimationIcon createProgressIcon(Composite comp) { + List progressImage = new ArrayList<>(); + + progressImage.add(ImageResources.INDETERMINATE_PROGRESS_01); + progressImage.add(ImageResources.INDETERMINATE_PROGRESS_02); + + return new DAAnimationIcon(comp, SWT.NONE, progressImage); + } + + /** + * @return text of bottom label + */ + public String getBottomText() { + return bottomText; + } + + /** + * @return listener, that contains action that should be triggered by + * pressing cancel button. + */ + public SelectionListener getCancelListener() { + return cancelListener; + } +} \ No newline at end of file diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/tooltip/DACustomTooltip.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/tooltip/DACustomTooltip.java index dd23649..8a5079a 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/tooltip/DACustomTooltip.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/tooltip/DACustomTooltip.java @@ -82,42 +82,52 @@ public abstract class DACustomTooltip { } public void open(Shell parent) { - this.parent = parent; + // check if tooltip is already opened + if (tooltipShell != null && !tooltipShell.isDisposed()) + return; - // create tooltip shell and canvas - if (null == tooltipShell) { - tooltipShell = new Shell(parent, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL | SWT.NO_TRIM); + tooltipShell = new Shell(parent, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL | SWT.NO_TRIM); + this.parent = parent; - // set size size and location - setTooltipShellSizeAndLocation(); - tooltipShell.setLayout(new FillLayout()); + // set size size and location + setTooltipShellSizeAndLocation(); + tooltipShell.setLayout(new FillLayout()); - tooltipCanvas = new Canvas(tooltipShell, SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT); - tooltipCanvas.addPaintListener(new PaintListener() { + tooltipCanvas = new Canvas(tooltipShell, SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT); + tooltipCanvas.addPaintListener(new PaintListener() { - @Override - public void paintControl(PaintEvent e) { - drawTooltip(e.gc); - } - }); + @Override + public void paintControl(PaintEvent e) { + drawTooltip(e.gc); + } + }); - tooltipCanvas.addKeyListener(keyListener); + tooltipCanvas.addKeyListener(keyListener); - // tooltipShell open - tooltipShell.open(); - } + // tooltipShell open + tooltipShell.open(); } + /** + * Moves tooltip to the current cursor position and resizes it if the tooltip text was + * changed. + */ public void move() { - if (null != tooltipShell) { + if (null != tooltipShell && !tooltipShell.isDisposed()) { // set size size and location setTooltipShellSizeAndLocation(); } } + /** + * Closes and disposes tooltip. + */ public void close() { - if (tooltipShell != null) - tooltipShell.setVisible(false); + if (tooltipShell != null && !tooltipShell.isDisposed()) { + tooltipShell.close(); + tooltipShell.dispose(); + tooltipShell = null; + } } public String getSelectedItem() { diff --git a/org.tizen.dynamicanalyzer.workbench.product/dynamicanalyzer.product b/org.tizen.dynamicanalyzer.workbench.product/dynamicanalyzer.product index ccdecaf..547a3da 100644 --- a/org.tizen.dynamicanalyzer.workbench.product/dynamicanalyzer.product +++ b/org.tizen.dynamicanalyzer.workbench.product/dynamicanalyzer.product @@ -1,7 +1,7 @@ - + diff --git a/org.tizen.dynamicanalyzer.workbench.product/pom.xml b/org.tizen.dynamicanalyzer.workbench.product/pom.xml index 27849ba..ec2f363 100644 --- a/org.tizen.dynamicanalyzer.workbench.product/pom.xml +++ b/org.tizen.dynamicanalyzer.workbench.product/pom.xml @@ -8,13 +8,13 @@ dynamic-analyzer org.tizen.dynamicanalyzer - 2.5.2-SNAPSHOT + 2.5.3-SNAPSHOT .. org.tizen.dynamicanalyzer org.tizen.dynamicanalyzer.workbench.product - 2.5.2-SNAPSHOT + 2.5.3-SNAPSHOT eclipse-repository diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java index 8cca9ff..a80c46c 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java @@ -275,6 +275,7 @@ public class AnalyzerConstants { public final static String APPLIST_DELIMITER_STRING = "===[App List]==="; public final static String APPLIST_DELIMITER_STRING_ID = "da.id.dummy.select.applist"; public final static String LAUNCH_APP = "launch_app";//$NON-NLS-1$ + public final static String PORT_FILE = "/tmp/port.da"; //$NON-NLS-1$ public final static String CMDSCRIPT_UNKNOWN = "Unknown option";//$NON-NLS-1$ public final static String CMDSCRIPT_USAGE = "usage:";//$NON-NLS-1$ diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerShellCommands.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerShellCommands.java index 6afd586..19614bf 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerShellCommands.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerShellCommands.java @@ -57,7 +57,7 @@ public class AnalyzerShellCommands { // direct shell command public static final String CMD_FIND_IME = "/usr/bin/pkginfo --arg-flt 10 http://tizen.org/category/ime"; public static final String CMD_IS_ARM_ARCH = "uname -m"; //$NON-NLS-1$ - public static final String CMD_CAT_PORT_FILE = "cat /tmp/port.da"; //$NON-NLS-1$ + public static final String CMD_CAT_PORT_FILE = "cat " + AnalyzerConstants.PORT_FILE + " 2>/dev/null"; //$NON-NLS-1$ // direct shell command to find DA's parts public static final String FIND_SCRIPT = "find /usr/bin -name profile_command 2> /dev/null"; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java index 67fc0a9..15dbf04 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/BaseCommunicator.java @@ -28,6 +28,8 @@ package org.tizen.dynamicanalyzer.communicator; import static org.tizen.dynamicanalyzer.constant.CommonConstants.INT_SIZE; import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -37,12 +39,15 @@ import java.net.SocketTimeoutException; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; +import java.util.Scanner; import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.AnalyzerShellCommands; import org.tizen.dynamicanalyzer.common.DAResult; import org.tizen.dynamicanalyzer.common.DAResult.ErrorCode; +import org.tizen.dynamicanalyzer.common.path.PathManager; import org.tizen.dynamicanalyzer.constant.CommonConstants; import org.tizen.dynamicanalyzer.control.IProgress; import org.tizen.dynamicanalyzer.protocol.DebugLog; @@ -283,23 +288,11 @@ public class BaseCommunicator { private DAResult getRemotePort() throws InterruptedException { DAResult result = new DAResult(ErrorCode.SUCCESS); - final List portLines = new ArrayList(); long start = System.currentTimeMillis(); while ((System.currentTimeMillis() - start) < PORT_WAIT_TIME) { try { - portLines.clear(); - - // get port number by sdb shell command - CommunicatorUtils.execShellCommand(device.getIDevice(), - AnalyzerShellCommands.CMD_CAT_PORT_FILE, new MultiLineReceiver() { - @Override - public void processNewLines(String[] lines) { - if (lines.length > 0) { - portLines.add(lines[0]); - } - } - }); + final List portLines = readPortInfoFromFile(); if (!portLines.isEmpty()) { String line = portLines.get(0); @@ -329,6 +322,39 @@ public class BaseCommunicator { return result; } + private List readPortInfoFromFile() { + final List portLines = new ArrayList(); + + // Try to get port number by sdb shell cat command + CommunicatorUtils.execShellCommand(device.getIDevice(), + AnalyzerShellCommands.CMD_CAT_PORT_FILE, new MultiLineReceiver() { + @Override + public void processNewLines(String[] lines) { + if (lines.length > 0) { + portLines.add(lines[0]); + } + } + }); + if (!portLines.isEmpty()) + return portLines; + + // If cat failed - try pull then + final String TMP_PORT_FILE = PathManager.DA_TEMP_FOLDER_PATH + File.separator + "port.da"; + DAResult result = DACommunicator.pull(device, AnalyzerConstants.PORT_FILE, TMP_PORT_FILE); + if (result.isSuccess()) { + try (Scanner s = new Scanner(new File(TMP_PORT_FILE))) { + while (s.hasNextLine()) + portLines.add(s.nextLine()); + } catch (FileNotFoundException e) { + Logger.error("Failed to read from temp DA port file: " + TMP_PORT_FILE); + Logger.exception(e); + } + } else { + Logger.error("Failed to pull DA port file: " + AnalyzerConstants.PORT_FILE); + } + return portLines; + } + private DAResult createControlSocket() { DAResult result = new DAResult(ErrorCode.SUCCESS); Socket sock = null; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java index c7ff570..1534529 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java @@ -76,8 +76,24 @@ public class DACommunicator { } } - public static DAResult pull(String from, String to) { - DeviceInfo device = Global.getCurrentDeviceInfo(); + /** + * Pull the file from the currently selected device to the host + * @param from source file path on device + * @param to destination file path on host + * @return {@link DAResult} value with a success or error code + */ + public static DAResult pullFromCurrentDevice(String from, String to) { + return pull(Global.getCurrentDeviceInfo(), from, to); + } + + /** + * Pull the file from the specified device to the host + * @param device {@link DeviceInfo} of the device to pull file from + * @param from source file path on device + * @param to destination file path on host + * @return {@link DAResult} value with a success or error code + */ + public static DAResult pull(DeviceInfo device, String from, String to) { if (device != null) { SyncResult res = CommunicatorUtils.pull(device.getIDevice(), from, to); if (null != res && res.isOk()) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/control/StartTraceManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/control/StartTraceManager.java index d56436c..21a9eb0 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/control/StartTraceManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/control/StartTraceManager.java @@ -32,7 +32,6 @@ import java.util.List; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.common.DAResult; @@ -63,16 +62,16 @@ import org.tizen.dynamicanalyzer.ui.timeline.dlog.DLogDataManager; import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar; import org.tizen.dynamicanalyzer.ui.widgets.table.DATableRegistry; import org.tizen.dynamicanalyzer.util.Logger; -import org.tizen.dynamicanalyzer.util.WorkbenchUtil; import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog; -import org.tizen.dynamicanalyzer.workbench.LayoutManager; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; +import org.tizen.dynamicanalyzer.widgets.progress.ProgressHolder; public class StartTraceManager implements Runnable { private static final int PROCINFO_WAIT_TIME = 5000; // wait 5 sec for process info messages private STAGE lastStage = STAGE.NONE; private boolean cancelAction = false; - private ProgressDialog progressDlg = null; + private ProgressHolder progress; private Thread startThread = null; private IProgress initProgress = new IProgress() { @Override @@ -138,28 +137,22 @@ public class StartTraceManager implements Runnable { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); - progressDlg = new ProgressDialog(shell, LayoutManager.getBaseComposite()); - - progressDlg.setProgressStyle(ProgressDialog.PROGRESS_STYLE_CANCEL); - progressDlg.setProgressMessage(AnalyzerLabels.DLG_PREPARE_TRACE); - progressDlg.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT); - progressDlg.setCancelListener(new SelectionListener() { - @Override - public void widgetDefaultSelected(SelectionEvent arg0) { - - } - - @Override - public void widgetSelected(SelectionEvent arg0) { - cancelAction = true; - if (startThread != null) { - startThread.interrupt(); - } - } - }); - - progressDlg.open(); + progress = ProgressManager.INSTANCE.createProgress(false, + ProgressDialog.PROGRESS_STYLE_CANCEL, AnalyzerLabels.DLG_PREPARE_TRACE, + AnalyzerLabels.DLG_PLEASE_WAIT, new SelectionListener() { + @Override + public void widgetDefaultSelected(SelectionEvent arg0) { + + } + + @Override + public void widgetSelected(SelectionEvent arg0) { + cancelAction = true; + if (startThread != null) { + startThread.interrupt(); + } + } + }); } }); } @@ -182,11 +175,11 @@ public class StartTraceManager implements Runnable { } // close progress dialog - if (progressDlg != null) { + if (progress != null) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - progressDlg.close(); + ProgressManager.INSTANCE.stopProgress(progress); } }); } @@ -402,11 +395,11 @@ public class StartTraceManager implements Runnable { private void setProgressPercent(int percent) { final int per = percent; - if (progressDlg != null) { + if (progress != null) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - progressDlg.setValue(per); + progress.setValue(per); } }); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/control/StopTraceManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/control/StopTraceManager.java index 4f7f17e..85c32e6 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/control/StopTraceManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/control/StopTraceManager.java @@ -35,6 +35,7 @@ import org.tizen.dynamicanalyzer.common.DAState; import org.tizen.dynamicanalyzer.common.Global; import org.tizen.dynamicanalyzer.communicator.DACommunicator; import org.tizen.dynamicanalyzer.handlers.UIActionHolder; +import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; import org.tizen.dynamicanalyzer.nl.MenuBarLabels; import org.tizen.dynamicanalyzer.project.Project; import org.tizen.dynamicanalyzer.shortcut.ShortCutManager; @@ -52,6 +53,9 @@ import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar; import org.tizen.dynamicanalyzer.util.Logger; import org.tizen.dynamicanalyzer.util.WorkbenchUtil; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; +import org.tizen.dynamicanalyzer.widgets.progress.ProgressHolder; public class StopTraceManager implements Runnable { // timeout in nanoseconds @@ -107,6 +111,11 @@ public class StopTraceManager implements Runnable { public void run() { // DAResult result = DAResult.SUCCESS; + ProgressHolder progress = null; + if(Global.isGUIMode()) + progress = ProgressManager.INSTANCE.createProgress(true, + ProgressDialog.PROGRESS_STYLE_CANCEL, "Stop Trace actions", + AnalyzerLabels.DLG_PLEASE_WAIT, null); try { // stop resource monitor ResourceMonitor.stop(); @@ -119,7 +128,8 @@ public class StopTraceManager implements Runnable { e.printStackTrace(); } finally {} - + if (Global.isGUIMode()) + progress.setValue(2); Thread stopTimers = new Thread(new Runnable() { public void run() { if (Global.isGUIMode()) { @@ -133,6 +143,8 @@ public class StopTraceManager implements Runnable { }, "StopTimersThread"); stopTimers.start(); + if (Global.isGUIMode()) + progress.setValue(10); // if LSan is initialized wait for 2nd message for some time AnalyzerUtil.getLSanLock().lock(); @@ -155,6 +167,8 @@ public class StopTraceManager implements Runnable { } } AnalyzerUtil.getLSanLock().unlock(); + if (Global.isGUIMode()) + progress.setValue(30); // if error code equals with canceling then stop threads by force if (error.equals(DAResult.ErrorCode.ERR_BY_USER_CANCEL)) { @@ -174,11 +188,17 @@ public class StopTraceManager implements Runnable { } stopThread.start(); + if (Global.isGUIMode()) + progress.setValue(40); // change summary UI // change to summary page UIActionHolder.getUIAction().applyStopTraceUI(); + if (Global.isGUIMode()) + progress.setValue(55); DLogDataManager.getInstance().stopDlog(); + if (Global.isGUIMode()) + progress.setValue(70); if (Global.isGUIMode()) { Display.getDefault().syncExec(new Runnable() { @Override @@ -190,7 +210,14 @@ public class StopTraceManager implements Runnable { } } finally { + if (Global.isGUIMode()) + progress.setValue(90); + updateDAState(); + if (Global.isGUIMode()) { + progress.setValue(100); + ProgressManager.INSTANCE.stopProgress(progress); + } } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/ImageProcessingThread.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/ImageProcessingThread.java index d275768..845a05e 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/ImageProcessingThread.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/ImageProcessingThread.java @@ -108,7 +108,7 @@ public class ImageProcessingThread implements Runnable { int count = 0; while (count < GET_IMAGE_TRY_COUNT) { - DAResult res = DACommunicator.pull(from, to); + DAResult res = DACommunicator.pullFromCurrentDevice(from, to); if (res.isSuccess()) { DACommunicator.removeFile(from); ret = true; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java index 1ded3ed..38794b5 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java @@ -285,7 +285,7 @@ public class MessageParser extends DataThread { destination = PathManager.DA_TEMP_FOLDER_PATH + File.separator + source; // Pull LSan report file - DAResult result = DACommunicator.pull(source, destination); + DAResult result = DACommunicator.pullFromCurrentDevice(source, destination); if (!result.isSuccess()) { Logger.error("Failed to pull LeakSanitizer report file: " + source); return; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/BinarySettingProgressManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/BinarySettingProgressManager.java index 80d1b62..f5cbf51 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/BinarySettingProgressManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/BinarySettingProgressManager.java @@ -27,14 +27,13 @@ package org.tizen.dynamicanalyzer.swap.platform.ui; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; -import org.tizen.dynamicanalyzer.util.WorkbenchUtil; import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog; -import org.tizen.dynamicanalyzer.workbench.LayoutManager; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; +import org.tizen.dynamicanalyzer.widgets.progress.ProgressHolder; public class BinarySettingProgressManager { - private static ProgressDialog dialog = null; + private static ProgressHolder progress = null; private static BinarySettingProgressManager instance = new BinarySettingProgressManager(); @@ -43,36 +42,25 @@ public class BinarySettingProgressManager { } public void startProcessStart(String waitMessage) { - Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); - dialog = new ProgressDialog(shell, LayoutManager.getBaseComposite()); - if (null != dialog) { - dialog.setProgressMessage(waitMessage); - dialog.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT); - dialog.open(); - } + progress = ProgressManager.INSTANCE.createProgress(false, + ProgressDialog.PROGRESS_STYLE_DEFAULT, waitMessage, AnalyzerLabels.DLG_PLEASE_WAIT, + null); } public void setValue(final int nSelect) { - if (null != dialog) { - Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - dialog.setValue(nSelect); - } - }); + if (null != progress) { + Display.getDefault().syncExec(() -> progress.setValue(nSelect)); } } public void stopProgress() { - if (null != dialog) { - Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - dialog.setValue(100); - dialog.close(); + if (null != progress) { + Display.getDefault().syncExec(() -> { + progress.setValue(100); + ProgressManager.INSTANCE.stopProgress(progress); } - }); + ); } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/hierarchy/tree/HierarchyTreeView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/hierarchy/tree/HierarchyTreeView.java index 53fb794..66523cf 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/hierarchy/tree/HierarchyTreeView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/hierarchy/tree/HierarchyTreeView.java @@ -79,8 +79,9 @@ import org.tizen.dynamicanalyzer.util.Logger; import org.tizen.dynamicanalyzer.util.WorkbenchUtil; import org.tizen.dynamicanalyzer.widgets.da.base.DADialog; import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite; -import org.tizen.dynamicanalyzer.workbench.LayoutManager; +import org.tizen.dynamicanalyzer.widgets.progress.ProgressHolder; public class HierarchyTreeView extends DAViewComposite { private ScalableFreeformLayeredPane root; @@ -94,7 +95,7 @@ public class HierarchyTreeView extends DAViewComposite { private HierarchyTreeNodeFigure selectedNode; private List searchedNodeList = new ArrayList(); - private ProgressDialog progressDialog; + private ProgressHolder progress; public HierarchyTreeView(Composite parent, int style) { super(parent, style, true); @@ -124,9 +125,8 @@ public class HierarchyTreeView extends DAViewComposite { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - if (progressDialog != null) { - progressDialog.close(); - progressDialog = null; + if (progress != null) { + ProgressManager.INSTANCE.stopProgress(progress); } if (isSuccess) { restructTree(); @@ -186,13 +186,10 @@ public class HierarchyTreeView extends DAViewComposite { } public void startProgress() { - Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); - progressDialog = new ProgressDialog(shell, LayoutManager.getBaseComposite()); - progressDialog.setProgressStyle(ProgressDialog.PROGRESS_STYLE_INDETERMINATE); - progressDialog - .setProgressMessage(UIHierarchyPageLabels.UIHIERARCHY_PROGRESS_MESSAGE_GET_HIERARCHY); - progressDialog.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT); - progressDialog.setCancelListener(new SelectionListener() { + progress = ProgressManager.INSTANCE.createProgress(false, + ProgressDialog.PROGRESS_STYLE_INDETERMINATE, + UIHierarchyPageLabels.UIHIERARCHY_PROGRESS_MESSAGE_GET_HIERARCHY, + AnalyzerLabels.DLG_PLEASE_WAIT, new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent arg0) { @@ -203,8 +200,6 @@ public class HierarchyTreeView extends DAViewComposite { cancelProgress(); } }); - - progressDialog.open(); } public void searchUIObject() { @@ -418,9 +413,8 @@ public class HierarchyTreeView extends DAViewComposite { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - if (progressDialog != null) { - progressDialog.close(); - progressDialog = null; + if (progress != null) { + ProgressManager.INSTANCE.stopProgress(progress); } } }); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/hierarchy/tree/tool/HierarchyTreeExporter.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/hierarchy/tree/tool/HierarchyTreeExporter.java index f734e16..5c7e917 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/hierarchy/tree/tool/HierarchyTreeExporter.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/hierarchy/tree/tool/HierarchyTreeExporter.java @@ -43,7 +43,6 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; import org.tizen.dynamicanalyzer.common.Global; -import org.tizen.dynamicanalyzer.handlers.GUIAction; import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; import org.tizen.dynamicanalyzer.nl.UIHierarchyPageLabels; import org.tizen.dynamicanalyzer.resources.ColorResources; @@ -52,11 +51,12 @@ import org.tizen.dynamicanalyzer.util.Logger; import org.tizen.dynamicanalyzer.util.WorkbenchUtil; import org.tizen.dynamicanalyzer.widgets.da.base.DADialog; import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog; -import org.tizen.dynamicanalyzer.workbench.LayoutManager; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; +import org.tizen.dynamicanalyzer.widgets.progress.ProgressHolder; public class HierarchyTreeExporter { private static String latestExportDir = null; // Register the latest exportPath - private static ProgressDialog progressDialog = null; + private static ProgressHolder progress; public static void exportTreeImage(final IFigure treeView) { /* @@ -132,12 +132,10 @@ public class HierarchyTreeExporter { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); - progressDialog = new ProgressDialog(shell, LayoutManager.getBaseComposite()); - progressDialog - .setProgressMessage(UIHierarchyPageLabels.UIHIERARCHY_EXPORT_PROGRESS_MESSAGE); - progressDialog.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT); - progressDialog.open(); + progress = ProgressManager.INSTANCE.createProgress(false, + ProgressDialog.PROGRESS_STYLE_DEFAULT, + UIHierarchyPageLabels.UIHIERARCHY_EXPORT_PROGRESS_MESSAGE, + AnalyzerLabels.DLG_PLEASE_WAIT, null); } }); /* @@ -147,8 +145,8 @@ public class HierarchyTreeExporter { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - progressDialog.setValue(30); - progressDialog.setValue(70); + progress.setValue(30); + progress.setValue(70); } }); /* @@ -181,20 +179,19 @@ public class HierarchyTreeExporter { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - progressDialog.setValue(100); - progressDialog.close(); + progress.setValue(100); + ProgressManager.INSTANCE.stopProgress(progress); } }); } else { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - progressDialog.close(); + ProgressManager.INSTANCE.stopProgress(progress); showErrorDialog(); } }); } - progressDialog = null; } } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/page/BaseView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/page/BaseView.java index c16b112..c8e0b67 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/page/BaseView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/page/BaseView.java @@ -69,6 +69,7 @@ import org.tizen.dynamicanalyzer.util.Logger; import org.tizen.dynamicanalyzer.util.WorkbenchUtil; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; import org.tizen.dynamicanalyzer.widgets.button.DACustomButton; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; import org.tizen.dynamicanalyzer.widgets.da.view.DABaseComposite; import org.tizen.dynamicanalyzer.widgets.da.view.DAContainerComposite; import org.tizen.dynamicanalyzer.widgets.da.view.DATabComposite; @@ -117,6 +118,8 @@ public class BaseView extends ViewPart { setMinumumShellSize(); unbindNeedlessCommand(); addKeyListener(); + ProgressManager.createProgressManager(WorkbenchUtil.getWorkbenchWindow().getShell(), + LayoutManager.getBaseComposite()); } private void unbindNeedlessCommand() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/Toolbar.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/Toolbar.java index 96f271e..2898250 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/Toolbar.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/Toolbar.java @@ -74,6 +74,8 @@ import org.tizen.dynamicanalyzer.ui.common.explorer.DeviceExplorerDialog; import org.tizen.dynamicanalyzer.ui.page.BaseView; import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage; import org.tizen.dynamicanalyzer.ui.toolbar.opentrace.OpenTraceDialog; +import org.tizen.dynamicanalyzer.ui.toolbar.setting.FlatFeatureDialog; +import org.tizen.dynamicanalyzer.ui.toolbar.setting.FlatFeatureDialogTargetPage; import org.tizen.dynamicanalyzer.ui.toolbar.setting.PreferencesDialog; import org.tizen.dynamicanalyzer.ui.widgets.SearchDialog; import org.tizen.dynamicanalyzer.util.Logger; @@ -89,10 +91,12 @@ import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem; import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo; import org.tizen.dynamicanalyzer.widgets.combo.DACustomComboSelectionListener; import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; +import org.tizen.dynamicanalyzer.widgets.progress.CircleProgress; +import org.tizen.dynamicanalyzer.widgets.progress.ProgressHolder; import org.tizen.dynamicanalyzer.widgets.timeline.MarkerManager; import org.tizen.dynamicanalyzer.widgets.timer.IAlarm; import org.tizen.dynamicanalyzer.widgets.timer.TimerClock; -import org.tizen.dynamicanalyzer.workbench.LayoutManager; import org.tizen.sdblib.service.FileEntry; public enum Toolbar { @@ -118,6 +122,7 @@ public enum Toolbar { private DACustomCombo processCombo; private DACustomButton startButton; private TimerClock timerClock; + private CircleProgress circleProgress; private DACustomButton openTraceButton; private DACustomButton configButton; private DACustomButton screenshotButton; @@ -130,7 +135,9 @@ public enum Toolbar { private Map buttons = new HashMap(); // Progress dialog used by appcombo - private ProgressDialog progressDlg = null; + private ProgressHolder progress = null; + + private static FlatFeatureDialog flatFeatureDialog; private static final int TIMER_WIDTH = 118; @@ -502,6 +509,10 @@ public enum Toolbar { timerClock.setClockFont(FontResources.TIMER); timerClock.setFontColor(ColorResources.POINT); + // Creates background progress widget. + circleProgress = CircleProgress.getCircleProgress(parent, SWT.NONE); + circleProgress.setVisible(false); + // // Creates open trace button. openTraceButton = new DACustomButton(parent, ImageResources.OPEN, ImageResources.OPEN_PUSH, ImageResources.OPEN_HOVER, ImageResources.OPEN_DISABLE); @@ -573,6 +584,14 @@ public enum Toolbar { data.height = 24; timerClock.setLayoutData(data); + // Allocate circle progress bar on toolbar + data = new FormData(); + data.top = new FormAttachment(0, DesignConstants.DA_BUTTON_TOP); + data.left = new FormAttachment(timerClock, 3); + data.width = 200; + data.height = 30; + circleProgress.setLayoutData(data); + data = new FormData(); data.top = new FormAttachment(0, DesignConstants.DA_BUTTON_TOP); data.left = new FormAttachment(timerClock, 4, SWT.RIGHT); @@ -760,23 +779,35 @@ public enum Toolbar { @UIMethod private boolean selectDeviceCombo(String deviceName) { - boolean bret = false; + if (deviceName == null || deviceName.isEmpty()) + return false; List devicelist = deviceCombo.getItems(); int size = devicelist.size(); for (int i = 0; i < size; i++) { - if (devicelist.get(i).equals(deviceName)) { - bret = DeviceManager.onDeviceSelected(deviceName); - if (bret) { - deviceCombo.select(i); - if (!deviceName.isEmpty()) { - deviceCombo.setToolTipText(deviceName); - } + if (devicelist.get(i).equals(deviceName) + && DeviceManager.onDeviceSelected(deviceName)) { + deviceCombo.select(i); + deviceCombo.setToolTipText(deviceName); + /** + * In following if statement proper target is selected for + * {@link FlatFeatureDialog} and {@link SettingDataManager}. In + * former case if dialog is opened at the current time and in + * latter, if it is not opened. + */ + if (flatFeatureDialog != null + && flatFeatureDialog.getTargetPage() != null) { + flatFeatureDialog.getTargetPage() + .selectTarget(DeviceManager.getDeviceByName(deviceName)); + } else { + FlatFeatureDialogTargetPage.setPredefinedTarget( + DeviceManager.getDeviceByName(deviceName).getPlatformName()); } + return true; } } - return bret; + return false; } @UIMethod @@ -1122,32 +1153,21 @@ public enum Toolbar { private void onAppSelected(AppInfo appInfo) { if (appInfo == null) return; - - Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); - progressDlg = new ProgressDialog(shell, LayoutManager.getBaseComposite()); - progressDlg.setProgressStyle(ProgressDialog.PROGRESS_STYLE_CANCEL); - progressDlg.setProgressMessage(AnalyzerLabels.DLG_COPYING_BINARY); - progressDlg.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT); - progressDlg.open(); - } - }); - Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - progressDlg.setValues("Getting process information", 30); + Display.getDefault().syncExec(() -> { + progress = ProgressManager.INSTANCE.createProgress(false, + ProgressDialog.PROGRESS_STYLE_CANCEL, AnalyzerLabels.DLG_COPYING_BINARY, + AnalyzerLabels.DLG_PLEASE_WAIT, null); + progress.setValues("Getting process information", 30); } - }); + ); List binPaths = appInfo.getProcessInformation(); Display.getDefault().syncExec(new Runnable() { @Override public void run() { - progressDlg.setValues("Getting binary from device", 70); + progress.setValues("Getting binary from device", 70); } }); @@ -1156,7 +1176,7 @@ public enum Toolbar { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - progressDlg.close(); + ProgressManager.INSTANCE.stopProgress(progress); } }); } @@ -1487,8 +1507,11 @@ public enum Toolbar { public void setDlogSelection(boolean dlogSelection) { this.dlogTimeSelection = dlogSelection; } - - + + public static synchronized void setFlatFeatureDialog(FlatFeatureDialog ffd) { + flatFeatureDialog = ffd; + } + // private void checkProcessList() { // Project project = Global.getProject(); // if (null == project) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceProgressManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceProgressManager.java index 76e04a8..89aa580 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceProgressManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceProgressManager.java @@ -27,7 +27,6 @@ package org.tizen.dynamicanalyzer.ui.toolbar.opentrace; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.common.DAState; @@ -41,18 +40,18 @@ import org.tizen.dynamicanalyzer.project.Project; import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage; import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar; import org.tizen.dynamicanalyzer.util.Logger; -import org.tizen.dynamicanalyzer.util.WorkbenchUtil; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog; +import org.tizen.dynamicanalyzer.widgets.da.base.ProgressManager; import org.tizen.dynamicanalyzer.widgets.da.view.DAContainerComposite; -import org.tizen.dynamicanalyzer.workbench.LayoutManager; +import org.tizen.dynamicanalyzer.widgets.progress.ProgressHolder; public class OpenTraceProgressManager implements Runnable { public static final int INIT = 0; public static final int OPEN_TRACE_PROCESS_START = 1; public static final int OPEN_TRACE_PROCESS_END = 2; private int state = INIT; - private ProgressDialog dialog = null; + private ProgressHolder progress; private String savePath = null; private int percent = 0; @@ -98,25 +97,20 @@ public class OpenTraceProgressManager implements Runnable { @Override public void run() { state = OPEN_TRACE_PROCESS_START; - Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); - dialog = new ProgressDialog(shell, LayoutManager.getBaseComposite()); - if (null != dialog) { - dialog.setProgressMessage(EndMessage); - dialog.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT); - dialog.open(); - } + progress = ProgressManager.INSTANCE.createProgress(false, + ProgressDialog.PROGRESS_STYLE_DEFAULT, EndMessage, + AnalyzerLabels.DLG_PLEASE_WAIT, null); } }); } public void setProgressPercent(final String message, final int percent) { - if (null != dialog) { + if (null != progress) { this.percent = percent; Display.getDefault().syncExec(new Runnable() { @Override public void run() { - dialog.setValue(percent); - dialog.setProgressMessage(message); + progress.setValues(message, percent); } }); } @@ -126,7 +120,7 @@ public class OpenTraceProgressManager implements Runnable { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - dialog.setValue(percent); + progress.setValue(percent); } }); } @@ -134,15 +128,14 @@ public class OpenTraceProgressManager implements Runnable { public void openTraceComplete() { DAState.changeCurrentState(DAState.DONE); - if (null != dialog) { + if (null != progress) { // waitingThreads(); Display.getDefault().syncExec(new Runnable() { @Override public void run() { AnalyzerUtil.changePage(TimelinePage.pageID); - dialog.setValue(100); - dialog.close(); - + progress.setValue(100); + ProgressManager.INSTANCE.stopProgress(progress); } }); @@ -172,8 +165,8 @@ public class OpenTraceProgressManager implements Runnable { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - dialog.errorOccurred(errMsg, AnalyzerLabels.OPEN_TRACE_PROGRESS_ERROR); - dialog.setValue(50); + progress.errorOccured(errMsg, AnalyzerLabels.OPEN_TRACE_PROGRESS_ERROR); + progress.setValue(50); } }); @@ -181,7 +174,7 @@ public class OpenTraceProgressManager implements Runnable { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - dialog.setValue(100); + progress.setValue(100); } }); @@ -190,7 +183,7 @@ public class OpenTraceProgressManager implements Runnable { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - dialog.close(); + ProgressManager.INSTANCE.stopProgress(progress); } }); state = OPEN_TRACE_PROCESS_END; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialog.java index 8d9aa00..ef11b15 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialog.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialog.java @@ -89,6 +89,7 @@ public class FlatFeatureDialog extends DAMessageBox { public FlatFeatureDialog(Shell parentShell) { super(parentShell); + Toolbar.setFlatFeatureDialog(this); } private Listener okListener = new Listener() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialogFeatureListPage.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialogFeatureListPage.java index e8872cc..468a227 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialogFeatureListPage.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialogFeatureListPage.java @@ -361,7 +361,7 @@ public class FlatFeatureDialogFeatureListPage extends DABaseComposite { infoButton.setLayoutData(data); infoButton.setData("tooltipmsg", feature.getOverheadRankingMessage()); - infoButton.addListener(SWT.MouseHover, new Listener() { + infoButton.addListener(SWT.MouseEnter, new Listener() { @Override public void handleEvent(Event event) { DACustomButton tempButton = (DACustomButton) event.widget; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialogTargetPage.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialogTargetPage.java index 79a1fec..af10b59 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialogTargetPage.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialogTargetPage.java @@ -184,6 +184,12 @@ public class FlatFeatureDialogTargetPage extends DABaseComposite { private ScrolledComposite targetScrolledComposite = null; private Composite targetInputComposite = null; private Cursor daCursor = null; + private DACustomFeatureToggleButtonGroup targetGroup = null; + /** + * Target of device that is selected to be profiled by "Profile as" option + * of tizen studio. + */ + private static volatile String predefinedTarget; private int TARGET_TITLE_FONT_SIZE = 0; @@ -347,7 +353,7 @@ public class FlatFeatureDialogTargetPage extends DABaseComposite { data.height = height; toggle.setLayoutData(data); - toggle.addListener(SWT.MouseHover, (Event event) -> { + toggle.addListener(SWT.MouseEnter, (Event event) -> { openTooltip(toggle); }); toggle.addListener(SWT.MouseExit, (Event event) -> { @@ -393,7 +399,6 @@ public class FlatFeatureDialogTargetPage extends DABaseComposite { public void createTargetComposite() { initTargetCompositeWidget(); - // target title label targetLabel = new Label(targetComp, SWT.TRANSPARENT); FormData data = new FormData(); @@ -444,9 +449,8 @@ public class FlatFeatureDialogTargetPage extends DABaseComposite { // ToogleButtonGroup Map targetList = SettingDataManager.INSTANCE.getTargetListMap(); - String selectedTarget = SettingDataManager.INSTANCE.getConnectedTargetOrSelected().getTargetName(); - SettingDataManager.INSTANCE.setSelectedTarget(selectedTarget); - DACustomFeatureToggleButtonGroup targetGroup = new DACustomFeatureToggleButtonGroup(); + String selectedTarget = predefinedTarget; + targetGroup = new DACustomFeatureToggleButtonGroup(); int topPosition = TARGET_LIST_UPPER_MARGIN; @@ -476,10 +480,18 @@ public class FlatFeatureDialogTargetPage extends DABaseComposite { topPosition += (TARGET_LIST_ITEM_HEIGHT + TARGET_LIST_ITEM_MARGIN); // set selection target - if (selectedTarget.equals(entry.getKey()) == true) { - targetGroup.setSelection(toggle); + if (selectedTarget == null && ProfileDisplayInfo.getConnected(target.getTargetName())) { + selectedTarget = target.getTargetName(); } } + // No connected targets + if (selectedTarget == null) + selectedTarget = SettingDataManager.INSTANCE.getConnectedTargetOrSelected() + .getTargetName(); + + targetGroup.setSelection(selectedTarget); + SettingDataManager.INSTANCE.setSelectedTarget(selectedTarget); + targetComp.layout(true); targetInputComposite.layout(); targetScrolledComposite.setMinSize(targetInputComposite.computeSize(SWT.DEFAULT, @@ -514,4 +526,28 @@ public class FlatFeatureDialogTargetPage extends DABaseComposite { tooltip.setTooltipMessage((String) toggle.getData()); tooltip.setTooltipLocation(p, 0, TOOLTIP_HORIZONTAL_OFFSET); } + + /** + * Toggle the target of the specified device selected, update + * {@link SettingDataManager} and GUI of current dialog. + * + * @param device device + */ + public void selectTarget(DeviceInfo device) { + if (device == null) + return; + if (targetGroup != null) { + String platform = device.getPlatformName(); + targetGroup.setSelection(platform); + // set selected target + SettingDataManager.INSTANCE.setSelectedTarget(platform); + // update feature list, selected feature pages + featureDialog.getFeatureListPage().createFeatureListComposite(); + featureDialog.getSelectedFeaturePage().createSelectedFeatureComposite(); + } + } + + public static void setPredefinedTarget(String target) { + predefinedTarget = target; + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/DownloadContentfileManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/DownloadContentfileManager.java index 7919629..4dce102 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/DownloadContentfileManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/DownloadContentfileManager.java @@ -96,7 +96,7 @@ public class DownloadContentfileManager { * @return */ public static boolean pullFile(String from, String to) { - DAResult res = DACommunicator.pull(from, to); + DAResult res = DACommunicator.pullFromCurrentDevice(from, to); if (res.isSuccess()) { Logger.debug(from + "file copying success!!");//$NON-NLS-1$ } else { diff --git a/package/changelog b/package/changelog index c632cab..783e3c4 100644 --- a/package/changelog +++ b/package/changelog @@ -1,9 +1,17 @@ +* 2.5.3 +- Introduce new UX of progress bars for time-consuming operations (SRADA-1332) +- Improve strategy of choosing target in Feature dialog for run from IDE case (SPTSDKUX-3595) +- Fix getting port number on Pride device (SRADA-1428) +- Fix JIRA defects: + SPTSDKUX-3428: Tracing data is not being saved in given path but no failure message shown + SPTSDKUX-3732: Tooltips are not always shown properly in Feature dialog +== Maria Guseva March 31, 2017 * 2.5.2 -- Get rid of check for libdaprobe library +- Get rid of check for libdaprobe library (SRADA-1320) - Fix JIRA defects: SPTSDKUX-3594: [2.4][TCM-5848] Dynamic Analyzer gets hanged SPTSDKUX-3595: Dynamic Analyzer global bar "Start" trace button is disabled -== Maria Guseva February 08, 2017 +== Maria Guseva March 21, 2017 * 2.5.1 - Fix a regression of hidden in tracing time Call Trace table (regression in DA 2.5.0) - Show filter icon after filtering above sorting (SRADA-1364) diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index 17a2829..96b5ca9 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,5 +1,5 @@ Source:dynamic-analyzer -Version:2.5.2 +Version:2.5.3 Maintainer:Gihun Chang , WooJin Jung , Jaewon Lim , Seokgil Kang Package:dynamic-analyzer-product diff --git a/pom.xml b/pom.xml index 81db213..bd0b9b9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 org.tizen.dynamicanalyzer dynamic-analyzer - 2.5.2-SNAPSHOT + 2.5.3-SNAPSHOT pom