package org.tizen.dynamicanalyzer.cli.commands;
import java.io.File;
-import java.io.IOException;
import java.rmi.ConnectException;
import org.tizen.dynamicanalyzer.cli.CliInternals;
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 {
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" +
<parent>
<artifactId>dynamic-analyzer</artifactId>
<groupId>org.tizen.dynamicanalyzer</groupId>
- <version>2.5.2-SNAPSHOT</version>
+ <version>2.5.3-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<groupId>org.tizen.dynamicanalyzer</groupId>
<parent>
<artifactId>dynamic-analyzer</artifactId>
<groupId>org.tizen.dynamicanalyzer</groupId>
- <version>2.5.2-SNAPSHOT</version>
+ <version>2.5.3-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<groupId>org.tizen.dynamicanalyzer</groupId>
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";
}
}
}
+ /**
+ * 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<DACustomFeatureToggleButton> getToggleButtonList() {
if (toggleButtonList == null) {
toggleButtonList = new ArrayList<DACustomFeatureToggleButton>();
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;
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;
}
};
- 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<Integer> sizeInfo = new ArrayList<Integer>();
- 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<Image> progressImage = new ArrayList<Image>();
-
- 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
+}
--- /dev/null
+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<ProgressHolder> 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);
+ }
+}
--- /dev/null
+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);
+ }
+
+}
--- /dev/null
+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);
+ }
+}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Hyeran Kim <hyeran74.kim@samsung.com>
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * yeongtaik byeon <yeongtaik.byeon@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.widgets.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
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hyeran Kim <hyeran74.kim@samsung.com>
+ * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * yeongtaik byeon <yeongtaik.byeon@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ * Petr Privalov <p.privalov@partner.samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.dynamicanalyzer.widgets.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<Image> 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
}
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() {
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
-<product name="%DynamicAnalyzer" uid="org.tizen.dynamicanalyzer.workbench.product" id="org.tizen.dynamicanalyzer.workbench.product" application="org.tizen.dynamicanalyzer.workbench.application" version="2.5.2.qualifier" useFeatures="true" includeLaunchers="true">
+<product name="%DynamicAnalyzer" uid="org.tizen.dynamicanalyzer.workbench.product" id="org.tizen.dynamicanalyzer.workbench.product" application="org.tizen.dynamicanalyzer.workbench.application" version="2.5.3.qualifier" useFeatures="true" includeLaunchers="true">
<aboutInfo>
<image path="icons/about_tizen_sdk.png"/>
<parent>
<artifactId>dynamic-analyzer</artifactId>
<groupId>org.tizen.dynamicanalyzer</groupId>
- <version>2.5.2-SNAPSHOT</version>
+ <version>2.5.3-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<groupId>org.tizen.dynamicanalyzer</groupId>
<artifactId>org.tizen.dynamicanalyzer.workbench.product</artifactId>
- <version>2.5.2-SNAPSHOT</version>
+ <version>2.5.3-SNAPSHOT</version>
<packaging>eclipse-repository</packaging>
<properties>
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$
// 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";
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;
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;
private DAResult getRemotePort() throws InterruptedException {
DAResult result = new DAResult(ErrorCode.SUCCESS);
- final List<String> portLines = new ArrayList<String>();
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<String> portLines = readPortInfoFromFile();
if (!portLines.isEmpty()) {
String line = portLines.get(0);
return result;
}
+ private List<String> readPortInfoFromFile() {
+ final List<String> portLines = new ArrayList<String>();
+
+ // 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;
}
}
- 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()) {
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;
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
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();
+ }
+ }
+ });
}
});
}
}
// close progress dialog
- if (progressDlg != null) {
+ if (progress != null) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- progressDlg.close();
+ ProgressManager.INSTANCE.stopProgress(progress);
}
});
}
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);
}
});
}
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;
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
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();
e.printStackTrace();
}
finally {}
-
+ if (Global.isGUIMode())
+ progress.setValue(2);
Thread stopTimers = new Thread(new Runnable() {
public void run() {
if (Global.isGUIMode()) {
}, "StopTimersThread");
stopTimers.start();
+ if (Global.isGUIMode())
+ progress.setValue(10);
// if LSan is initialized wait for 2nd message for some time
AnalyzerUtil.getLSanLock().lock();
}
}
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)) {
}
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
}
} finally {
+ if (Global.isGUIMode())
+ progress.setValue(90);
+
updateDAState();
+ if (Global.isGUIMode()) {
+ progress.setValue(100);
+ ProgressManager.INSTANCE.stopProgress(progress);
+ }
}
}
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;
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;
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();
}
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);
}
- });
+ );
}
}
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;
private HierarchyTreeNodeFigure selectedNode;
private List<HierarchyTreeNodeFigure> searchedNodeList = new ArrayList<HierarchyTreeNodeFigure>();
- private ProgressDialog progressDialog;
+ private ProgressHolder progress;
public HierarchyTreeView(Composite parent, int style) {
super(parent, style, true);
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();
}
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) {
cancelProgress();
}
});
-
- progressDialog.open();
}
public void searchUIObject() {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- if (progressDialog != null) {
- progressDialog.close();
- progressDialog = null;
+ if (progress != null) {
+ ProgressManager.INSTANCE.stopProgress(progress);
}
}
});
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;
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) {
/*
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);
}
});
/*
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- progressDialog.setValue(30);
- progressDialog.setValue(70);
+ progress.setValue(30);
+ progress.setValue(70);
}
});
/*
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;
}
}
}
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;
setMinumumShellSize();
unbindNeedlessCommand();
addKeyListener();
+ ProgressManager.createProgressManager(WorkbenchUtil.getWorkbenchWindow().getShell(),
+ LayoutManager.getBaseComposite());
}
private void unbindNeedlessCommand() {
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;
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 {
private DACustomCombo processCombo;
private DACustomButton startButton;
private TimerClock timerClock;
+ private CircleProgress circleProgress;
private DACustomButton openTraceButton;
private DACustomButton configButton;
private DACustomButton screenshotButton;
private Map<Integer, DACustomButton> buttons = new HashMap<Integer, DACustomButton>();
// Progress dialog used by appcombo
- private ProgressDialog progressDlg = null;
+ private ProgressHolder progress = null;
+
+ private static FlatFeatureDialog flatFeatureDialog;
private static final int TIMER_WIDTH = 118;
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);
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);
@UIMethod
private boolean selectDeviceCombo(String deviceName) {
- boolean bret = false;
+ if (deviceName == null || deviceName.isEmpty())
+ return false;
List<String> 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
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<String> 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);
}
});
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- progressDlg.close();
+ ProgressManager.INSTANCE.stopProgress(progress);
}
});
}
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) {
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;
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;
@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);
}
});
}
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- dialog.setValue(percent);
+ progress.setValue(percent);
}
});
}
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);
}
});
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);
}
});
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- dialog.setValue(100);
+ progress.setValue(100);
}
});
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- dialog.close();
+ ProgressManager.INSTANCE.stopProgress(progress);
}
});
state = OPEN_TRACE_PROCESS_END;
public FlatFeatureDialog(Shell parentShell) {
super(parentShell);
+ Toolbar.setFlatFeatureDialog(this);
}
private Listener okListener = new Listener() {
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;
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;
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) -> {
public void createTargetComposite() {
initTargetCompositeWidget();
-
// target title label
targetLabel = new Label(targetComp, SWT.TRANSPARENT);
FormData data = new FormData();
// ToogleButtonGroup
Map<String, TargetData> 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;
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,
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;
+ }
}
* @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 {
+* 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 <m.guseva@samsung.com> 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 <m.guseva@samsung.com> February 08, 2017
+== Maria Guseva <m.guseva@samsung.com> 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)
Source:dynamic-analyzer
-Version:2.5.2
+Version:2.5.3
Maintainer:Gihun Chang <gihun.chang@samsung.com>, WooJin Jung <woojin2.jung@samsung.com>, Jaewon Lim <jaewon81.lim@samsung.com>, Seokgil Kang <seokgil.kang@samsung.com>
Package:dynamic-analyzer-product
<modelVersion>4.0.0</modelVersion>
<groupId>org.tizen.dynamicanalyzer</groupId>
<artifactId>dynamic-analyzer</artifactId>
- <version>2.5.2-SNAPSHOT</version>
+ <version>2.5.3-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>