private DACustomButton openTraceButton;
private DACustomButton replayButton;
private DACustomButton configButton;
- private DACustomButton binarySettingsButton;
+// private DACustomButton binarySettingsButton;
private DACustomButton aboutButton;
}
});
- binarySettingsButton
- .addClickListener(new DACustomButtonClickEventListener() {
-
- @Override
- public void handleClickEvent(DACustomButton button) {
- BinaryAnalyzingConfigDialog dialog = new BinaryAnalyzingConfigDialog(
- shell);
- dialog.open();
- }
- });
+// binarySettingsButton
+// .addClickListener(new DACustomButtonClickEventListener() {
+//
+// @Override
+// public void handleClickEvent(DACustomButton button) {
+// BinaryAnalyzingConfigDialog dialog = new BinaryAnalyzingConfigDialog(
+// shell);
+// dialog.open();
+// }
+// });
aboutButton.addClickListener(new DACustomButtonClickEventListener() {
buttons.put(REPLAY_BUTTON, replayButton);
// create binarySettingButton
- binarySettingsButton = new DACustomButton(parent,
- ImageResources.SCREEN_SHOT_TOGGLE,
- ImageResources.SCREEN_SHOT_TOGGLE_PUSH,
- ImageResources.SCREEN_SHOT_TOGGLE_HOVER,
- ImageResources.SCREEN_SHOT_DISABLE);
- binarySettingsButton.setToolTipText("Binary Settings");
- buttons.put(SETTING_BUTTON, binarySettingsButton);
+// binarySettingsButton = new DACustomButton(parent,
+// ImageResources.SCREEN_SHOT_TOGGLE,
+// ImageResources.SCREEN_SHOT_TOGGLE_PUSH,
+// ImageResources.SCREEN_SHOT_TOGGLE_HOVER,
+// ImageResources.SCREEN_SHOT_DISABLE);
+// binarySettingsButton.setToolTipText("Binary Settings");
+// buttons.put(SETTING_BUTTON, binarySettingsButton);
// Creates config button
configButton = new DACustomButton(parent,
data.height = 30;
configButton.setLayoutData(data);
- data = new FormData();
- data.top = new FormAttachment(0, 4);
- data.right = new FormAttachment(configButton, 0);
- data.width = 34; // 31
- data.height = 30;
- binarySettingsButton.setLayoutData(data);
+// data = new FormData();
+// data.top = new FormAttachment(0, 4);
+// data.right = new FormAttachment(configButton, 0);
+// data.width = 34; // 31
+// data.height = 30;
+// binarySettingsButton.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(0, 4);
- data.right = new FormAttachment(binarySettingsButton, -5);
+ data.right = new FormAttachment(configButton, -5);
data.width = 32;
data.height = 30;
viewSourceButton.setLayoutData(data);
setRepalyButtonEnable(enabled);
}
- public void setBinarySettingsButtonEnablement(boolean enabled) {
- binarySettingsButton.setButtonEnabled(enabled);
- }
+// public void setBinarySettingsButtonEnablement(boolean enabled) {
+// binarySettingsButton.setButtonEnabled(enabled);
+// }
public void startTimer() {
timerClock.start();
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.toolbar.configuration;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
+import org.tizen.dynamicanalyzer.common.CommonConstants;
+import org.tizen.dynamicanalyzer.communicator.DACommunicator;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData;
+import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
+import org.tizen.dynamicanalyzer.swap.platform.ui.BinaryAddDialog;
+import org.tizen.dynamicanalyzer.swap.platform.ui.InputRow;
+import org.tizen.dynamicanalyzer.swap.platform.ui.LoadSettingDialog;
+import org.tizen.dynamicanalyzer.swap.platform.ui.SaveSettingDialog;
+import org.tizen.dynamicanalyzer.ui.page.DAPageComposite;
+import org.tizen.dynamicanalyzer.ui.widgets.DAButton;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.dynamicanalyzer.widgets.button.radio.DARadioButton;
+import org.tizen.dynamicanalyzer.widgets.button.radio.DARadioGroup;
+import org.tizen.dynamicanalyzer.widgets.button.radio.DARadioSelectionListener;
+
+public class BinarySettingsPage extends DAPageComposite {
+ public static final String ID = BinarySettingsPage.class.getName();
+
+ private HashMap<String, InputRow> inputRowHash = null;
+ private List<InputRow> inputRowList = null;
+
+ private ScrolledComposite scrolledComposite = null;
+ private Composite inputComposite = null;
+ // private DACustomToggleButton enableButton = null;
+ private DARadioButton addLibButton = null;
+ private DARadioButton removeLibButton = null;
+
+ private DAButton cleanButton = null;
+ private DAButton addButton = null;
+ private DAButton saveButton = null;
+ private DAButton loadButton = null;
+
+ private boolean isLoaded = false;
+ private boolean addLib = true;
+
+ private DARadioSelectionListener addLibButtonListener = new DARadioSelectionListener() {
+
+ @Override
+ public void handleSelectionEvent(DARadioButton radio) {
+ addLib = true;
+ }
+ };
+
+ private DARadioSelectionListener removeLibButtonListener = new DARadioSelectionListener() {
+
+ @Override
+ public void handleSelectionEvent(DARadioButton radio) {
+ addLib = false;
+ }
+ };
+ private DACustomButtonClickEventListener addButtonListener = new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ BinaryAddDialog dialog = new BinaryAddDialog(button.getParent()
+ .getShell());
+ Object result = dialog.open();
+
+ if (result != null) {
+ @SuppressWarnings("unchecked")
+ List<String> paths = (List<String>) result;
+ InputRow inputRow = new InputRow(inputComposite);
+ inputRow.setBinaryText(paths.get(0));
+ inputRow.setSourceText(paths.get(1));
+ inputRowHash.put(paths.get(0), inputRow);
+ inputRowList.add(inputRow);
+ inputComposite.layout();
+ }
+ }
+ };
+
+ private DACustomButtonClickEventListener loadButtonListener = new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ LoadSettingDialog dialog = new LoadSettingDialog(button.getParent()
+ .getShell());
+ Object result = dialog.open();
+ if (result == null) {
+ return;
+ }
+
+ cleanButtonListener.handleClickEvent(null);
+
+ String path = (String) result;
+ File saveFile = new File(path);
+ BufferedReader br = null;
+ String content = null;
+ try {
+ br = new BufferedReader(new FileReader(saveFile));
+ while (null != (content = br.readLine())) {
+ InputRow inputRow = new InputRow(inputComposite);
+ String[] splitContent = content
+ .split(CommonConstants.COMMA);
+ inputRow.setBinaryText(new String(splitContent[0]));
+ inputRow.setSourceText(new String(splitContent[1]));
+ inputRowList.add(inputRow);
+ inputRowHash.put(inputRow.getBinaryText(), inputRow);
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ AnalyzerUtil.tryClose(br);
+ }
+ inputComposite.layout();
+ }
+ };
+
+ private DACustomButtonClickEventListener saveButtonListener = new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ SaveSettingDialog dialog = new SaveSettingDialog(button.getParent()
+ .getShell(), inputRowList);
+ dialog.open();
+ // save dialog
+ // filename.setting
+ }
+ };
+
+ private DACustomButtonClickEventListener cleanButtonListener = new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ for (int i = 0; i < inputRowList.size(); i++) {
+ inputRowList.get(i).dispose();
+ }
+ inputRowList.clear();
+ inputRowHash.clear();
+ }
+ };
+
+ public BinarySettingsPage(Composite parent, int style) {
+ super(parent, style);
+
+ name = "Binary Settings";
+ inputRowHash = BinarySettingManager.getInstance().getInputRowHash();
+ inputRowList = BinarySettingManager.getInstance().getInputRowList();
+
+ String settingPath = AnalyzerPaths.DYNAMIC_ANALYZER_SETTING_PATH;
+ File settingFolder = new File(settingPath);
+ if (!settingFolder.exists() || !settingFolder.isDirectory()) {
+ settingFolder.mkdirs();
+ }
+
+ this.setLayout(new FormLayout());
+ this.setBackground(ColorResources.DIALOG_BG_UPPER);
+
+ Label msgTypeLabel = new Label(this, SWT.TRANSPARENT);
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 6);
+ data.left = new FormAttachment(0, 8);
+ data.height = 16;
+ data.width = 60;
+ msgTypeLabel.setLayoutData(data);
+ msgTypeLabel.setText("Msessage :");
+ msgTypeLabel.setBackground(ColorResources.DIALOG_BG_UPPER);
+
+ DARadioGroup radioGroup = new DARadioGroup();
+ addLibButton = new DARadioButton(this, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(0, 6);
+ data.left = new FormAttachment(msgTypeLabel, 22);
+ data.height = 16;
+ data.width = 100;
+ addLibButton.setLayoutData(data);
+ addLibButton.setForeground(ColorResources.BLACK);
+ addLibButton.setBackground(ColorResources.DIALOG_BG_UPPER);
+ addLibButton.setText("Add Libarry");
+ addLibButton.addSelectionListener(addLibButtonListener);
+ radioGroup.addChild(addLibButton);
+
+ removeLibButton = new DARadioButton(this, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(0, 6);
+ data.left = new FormAttachment(addLibButton, 22);
+ data.height = 16;
+ data.width = 120;
+ removeLibButton.setLayoutData(data);
+ removeLibButton.setForeground(ColorResources.BLACK);
+ removeLibButton.setBackground(ColorResources.DIALOG_BG_UPPER);
+ removeLibButton.setText("Remove Library");
+ removeLibButton.addSelectionListener(removeLibButtonListener);
+ radioGroup.addChild(removeLibButton);
+
+ Label binaryLabel = new Label(this, SWT.TRANSPARENT);
+ data = new FormData();
+ data.top = new FormAttachment(msgTypeLabel, 12);
+ data.left = new FormAttachment(0, 20);
+ data.height = 10;
+ data.width = 148 + 80;
+ binaryLabel.setLayoutData(data);
+ binaryLabel.setForeground(ColorResources.BLACK);
+ binaryLabel.setText("Binary Name");
+ binaryLabel.setBackground(ColorResources.DIALOG_BG_UPPER);
+ binaryLabel.setForeground(ColorResources.BLUE);
+ binaryLabel.setFont(FontResources.ADDITEM_BUTTON_FONT);
+
+ Label sourceLabel = new Label(this, SWT.TRANSPARENT);
+ data = new FormData();
+ data.top = new FormAttachment(msgTypeLabel, 12);
+ data.left = new FormAttachment(binaryLabel, 3);
+ data.height = 10;
+ data.width = 207 + 60;
+ sourceLabel.setLayoutData(data);
+ sourceLabel.setForeground(ColorResources.BLACK);
+ sourceLabel.setText("Source Path");
+ sourceLabel.setBackground(ColorResources.DIALOG_BG_UPPER);
+ sourceLabel.setForeground(ColorResources.BLUE);
+ sourceLabel.setFont(FontResources.ADDITEM_BUTTON_FONT);
+
+ scrolledComposite = new ScrolledComposite(this, SWT.BORDER
+ | SWT.V_SCROLL | SWT.H_SCROLL);
+ data = new FormData();
+ data.top = new FormAttachment(binaryLabel, 6);
+ data.left = new FormAttachment(0, 6);
+ data.height = 210;
+ data.width = 590;
+ scrolledComposite.setLayoutData(data);
+ scrolledComposite.setLayout(new FormLayout());
+ scrolledComposite.setBackground(ColorResources.BLUE);
+ scrolledComposite.setExpandHorizontal(true);
+ scrolledComposite.setExpandVertical(true);
+
+ // scrolledComposite.setMinSize(WIDTH - 30, 200);
+
+ inputComposite = new Composite(scrolledComposite, SWT.NONE);
+ scrolledComposite.setContent(inputComposite);
+ scrolledComposite.setMinSize(inputComposite.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT));
+ scrolledComposite.setShowFocusedControl(true);
+ data = new FormData();
+ data.top = new FormAttachment(binaryLabel, 5);
+ data.left = new FormAttachment(0, 15);
+ data.height = 210;
+ data.width = 590;
+ inputComposite.setLayoutData(data);
+ inputComposite.setLayout(new FormLayout());
+ inputComposite.setBackground(ColorResources.DIALOG_BG_UPPER);
+
+ saveButton = new DAButton(this, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(scrolledComposite, 5);
+ data.left = new FormAttachment(0, 6);
+ data.height = 22;
+ data.width = 100;
+ saveButton.setLayoutData(data);
+ saveButton.setText("Save Settings");
+ saveButton.addClickListener(saveButtonListener);
+
+ loadButton = new DAButton(this, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(scrolledComposite, 5);
+ data.left = new FormAttachment(saveButton, 8);
+ data.height = 22;
+ data.width = 100;
+ loadButton.setLayoutData(data);
+ loadButton.setText("Load Settings");
+ loadButton.addClickListener(loadButtonListener);
+
+ addButton = new DAButton(this, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(scrolledComposite, 5);
+ data.right = new FormAttachment(100, -8);
+ data.height = 22;
+ data.width = 100;
+ addButton.setLayoutData(data);
+ addButton.setText("Add");
+ addButton.addClickListener(addButtonListener);
+
+ cleanButton = new DAButton(this, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(scrolledComposite, 5);
+ data.right = new FormAttachment(addButton, -8);
+ data.height = 22;
+ data.width = 100;
+ cleanButton.setLayoutData(data);
+ cleanButton.setText("Clear All");
+ cleanButton.addClickListener(cleanButtonListener);
+
+ inputRowList.clear();
+ inputRowHash.clear();
+
+ this.addListener(SWT.Show, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("show listener");
+ initInputRows();
+ }
+ });
+
+ }
+
+ public void deApply() {
+ List<BinarySettingData> tempBinarySettings = new ArrayList<BinarySettingData>();
+ for (InputRow input : inputRowList) {
+ BinarySettingData binaryData = new BinarySettingData();
+ binaryData.setBinaryPath(input.getBinaryText());
+ binaryData.setDebugPath(input.getSourceText());
+ tempBinarySettings.add(binaryData);
+ }
+ BinarySettingManager.getInstance().putBinarySettingData(
+ tempBinarySettings);
+ BinarySettingManager.getInstance().checkSourcePath();
+
+ DACommunicator.sendBinaryInfoMessageForLib();
+ int swapMsg = AnalyzerConstants.MSG_SWAP_INST_ADD;
+ if (!addLib) {
+ swapMsg = AnalyzerConstants.MSG_SWAP_INST_REMOVE;
+ }
+ DACommunicator.sendSWAPMessage(swapMsg);
+ }
+
+ public void initInputRows() {
+ if (!isLoaded) {
+ List<BinarySettingData> binData = BinarySettingManager
+ .getInstance().getBinarySettings();
+ for (int i = 0; i < binData.size(); i++) {
+ InputRow inputRow = new InputRow(inputComposite);
+ inputRow.setBinaryText(binData.get(i).getBinaryPath());
+ String source = binData.get(i).getSourcePath();
+ if (null != source && !source.isEmpty()) {
+ inputRow.setSourceText(source);
+ // String[] splitSource =
+ // source.split(CommonConstants.SLASH);
+ // String comboSel = new String(
+ // splitSource[splitSource.length - 1]);
+ // inputRow.setSourceComboText(comboSel);
+ }
+ inputRowHash.put(binData.get(i).getBinaryPath(), inputRow);
+ inputRowList.add(inputRow);
+ }
+ inputComposite.layout();
+ isLoaded = true;
+ }
+ }
+}
public class ConfigurationDialog extends DAMessageBox {
private static boolean opened = false;
private DACustomButton applyButton = null;
- private DACustomButton okButton = null;
+ // private DACustomButton okButton = null;
private DACustomButton cancelButton = null;
DATabComposite tabView = null;
}
};
- private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
-
- @Override
- public void handleClickEvent(DACustomButton button) {
- doApply();
- shell.dispose();
- }
- };
private DACustomButtonClickEventListener cancelButtonListener = new DACustomButtonClickEventListener() {
@Override
};
private void doApply() {
- ConfigurationDialogValues.getInstance().applySettingValueToConfigFile();
-
- DACommunicator.sendRuntimeMessage(DACommunicator.MSG_TYPE_CONFIG, null);
+ Composite selectedComposite = tabView.getTopComposite();
+ if (!(selectedComposite instanceof BinarySettingsPage)) {
+ ConfigurationDialogValues.getInstance()
+ .applySettingValueToConfigFile();
+
+ DACommunicator.sendRuntimeMessage(DACommunicator.MSG_TYPE_CONFIG,
+ null);
+ } else {
+ BinarySettingsPage page = (BinarySettingsPage) selectedComposite;
+ page.deApply();
+ }
}
private void doBack() {
tabView.getContentComposite(), SWT.NONE);
tabView.addView(settingPage, false);
+ Composite binarySettings = new BinarySettingsPage(
+ tabView.getContentComposite(), SWT.NONE);
+ tabView.addView(binarySettings, false);
// button
Composite buttonContentsComp = new Composite(shell, SWT.NONE);
buttonContentsComp.addPaintListener(new PaintListener() {
cancelButton = new DAButton(buttonContentsComp, SWT.NONE);
cancelButton.addClickListener(cancelButtonListener);
- cancelButton.setText(AnalyzerLabels.CANCEL);
+ cancelButton.setText(AnalyzerLabels.CLOSE);
cancelButton.setFont(FontResources.DIALOG_BUTTON_FONT);
FormData buttonData = new FormData();
- buttonData.right = new FormAttachment(100, -9);
+ buttonData.left = new FormAttachment(50, 4);
buttonData.top = new FormAttachment(0, 11);
buttonData.width = 100;
buttonData.height = 28;
cancelButton.setLayoutData(buttonData);
- okButton = new DAButton(buttonContentsComp, SWT.NONE);
- okButton.addClickListener(okButtonListener);
- okButton.setText(AnalyzerLabels.OK);
- okButton.setFont(FontResources.DIALOG_BUTTON_FONT);
- buttonData = new FormData();
- buttonData.right = new FormAttachment(cancelButton, -8);
- buttonData.top = new FormAttachment(0, 11);
- buttonData.width = 100;
- buttonData.height = 28;
- okButton.setLayoutData(buttonData);
+ // okButton = new DAButton(buttonContentsComp, SWT.NONE);
+ // okButton.addClickListener(okButtonListener);
+ // okButton.setText(AnalyzerLabels.OK);
+ // okButton.setFont(FontResources.DIALOG_BUTTON_FONT);
+ // buttonData = new FormData();
+ // buttonData.right = new FormAttachment(50, -4);
+ // buttonData.top = new FormAttachment(0, 11);
+ // buttonData.width = 100;
+ // buttonData.height = 28;
+ // okButton.setLayoutData(buttonData);
applyButton = new DAButton(buttonContentsComp, SWT.NONE);
applyButton.addClickListener(applyButtonListener);
applyButton.setText(AnalyzerLabels.APPLY);
applyButton.setFont(FontResources.DIALOG_BUTTON_FONT);
buttonData = new FormData();
- buttonData.right = new FormAttachment(okButton, -8);
+ buttonData.right = new FormAttachment(50, -4);
buttonData.top = new FormAttachment(0, 11);
buttonData.width = 100;
buttonData.height = 28;