package org.tizen.dynamicanalyzer.util;
-import java.util.List;
+import java.util.Collection;
public class StringUtil {
}
}
- public static String concatenate(List<String> strings, String seperator) {
+ public static String concatenate(Collection<String> strings, String delimiter) {
if (strings == null) {
return null;
}
- return concatenate(strings.toArray(new String[0]), seperator);
+ return concatenate(strings.toArray(new String[0]), delimiter);
}
- public static String concatenate(String[] strings, String seperator) {
+ public static String concatenate(String[] strings, String delimiter) {
if (strings == null) {
return null;
}
for (int i = 0; i < strings.length; i++) {
if (i != 0) {
- buffer.append(seperator);
+ buffer.append(delimiter);
}
buffer.append(strings[i]);
}
--- /dev/null
+Selected Chart List|CPU|CPU core|CPU frequency
+Default Chart List|CPU|CPU core|CPU frequency
Debug Print|N
Available Target List|mobile
Selected Target|mobile
-Selected Chart List|CPU|CPU core|CPU frequency
-Default Chart List|CPU|CPU core|CPU frequency
Options Selected Feature List|5002:0
Default Feature List|2|3|103
Total Overhead Range|1000000|3000000|7000000|15000000
public static final String READ_CSV_SEPARATOR = "\\" + CommonConstants.CMD_SPLIT;
public static final String WRITE_CSV_SEPARATOR = CommonConstants.CMD_SPLIT;
public static final String SETTING_FILE_NAME = "setting";
- public static final String FEATUER_FILE_NAME = "feature";
+ public static final String FEATURE_FILE_NAME = "feature";
public static final String TEMPLATE_FILE_NAME = "template";
- public static final String PROTOCOL_FILE_NAME = "protocol";
+ public static final String LAYOUT_FILE_NAME = "layout";
public static final String VALUE_YES = "Y";
public static final String VALUE_NO = "N";
public static final String KEY_DEBUG_PRINT = "Debug Print";
public static final String KEY_AVAILABLE_TARGET_LIST = "Available Target List";
public static final String KEY_SELECTED_TARGET = "Selected Target";
- public static final String KEY_SELECTED_CHART_LIST = "Selected Chart List";
- public static final String KEY_DEFAULT_CHART_LIST = "Default Chart List";
public static final String KEY_OPTIONS_SELECTED_FEATURE_LIST = "Options Selected Feature List";
public static final String KEY_DEFAULT_FEATURE_LIST = "Default Feature List";
public static final String KEY_TOTAL_OVERHEAD_RANGE = "Total Overhead Range";
public static final int FEATURE_KEY_MAX_VALUE = 7;
public static final int FEATURE_KEY_DEFAULT_VALUE = 8;
public static final int FEATURE_KEY_OVERHEAD_RANKING = 9;
- public static final int FEATURE_KEY_PROTOCOL_LIST = 10;
// feature type
public static final int FEATURE_TYPE_MAIN = 0;
public static final int TEMPLATE_KEY_TEMPLATE_INDEX = 0;
public static final int TEMPLATE_KEY_TEMPLATE_NAME = 1;
+ /** layout **/
+ // key name in layout file
+ public static final String KEY_DEFAULT_CHART_LIST = "Default Chart List";
+ public static final String KEY_SELECTED_CHART_LIST = "Selected Chart List";
+
/** protocol **/
// protocol key index in protocol file
public static final int PROTOCOL_KEY_PROTOCOL_INDEX = 0;
// overhead and call count measuring time = 30 sec
public static final int OVERHEAD_AVG_SECONDS = 30;
-
+
/** about UI **/
// page names
public static String PAGE_NAME_TIME_LINE = "Timeline";
private boolean parsingSuccess = true;
/** read information **/
- // setting information
+ // setting information (immutable)
private double version = 0;
private int logLevel = 0;
- private List<String> defaultChartList = new ArrayList<String>();
private List<Feature> defaultFeatureList = new ArrayList<Feature>();
private List<Long> totalOverheadRange = new ArrayList<Long>();
/** write information **/
// init selected information : for revert button
private String initTarget = null;
- private List<FeatureValueData> initOptionsSelectedFeatureList = null;
+ private List<FeatureValueData> initOptionsSelectedFeatureList = new ArrayList<FeatureValueData>();
+ // mutable information
private String selectedTarget = null;
private List<FeatureValueData> optionsSelectedFeatureList = new ArrayList<FeatureValueData>();
- private List<String> selectedChartList = new ArrayList<String>();
// available target list
private Map<String, TargetData> targetListMap = new LinkedHashMap<String, TargetData>();
SettingConstants.SettingFilePath = PathManager.DA_CONFIG_FOLDER_PATH + File.separator;
} // else : used in the unit test
- parseSettingData(SettingConstants.FEATUER_FILE_NAME);
- parseSettingData(SettingConstants.TEMPLATE_FILE_NAME);
- parseSettingData(SettingConstants.SETTING_FILE_NAME);
-
- // set chart list
- selectedChartList.addAll(getOptionsSelectedFeatureChartList());
+ readFeatureFile();
+ readTemplateFile();
+ readSettingFile();
}
public boolean isParsingSuccess() {
return parsingSuccess;
}
- private void parseSettingData(String fileName) {
- File csv = new File(SettingConstants.SettingFilePath + fileName);
+ private void readFeatureFile() {
+ File csv = new File(SettingConstants.SettingFilePath + SettingConstants.FEATURE_FILE_NAME);
BufferedReader in = null;
String content = null;
try {
in = new BufferedReader(new FileReader(csv));
- if (SettingConstants.SETTING_FILE_NAME.equals(fileName)) {
- while (null != (content = in.readLine())) {
- initSettingData(content);
- }
- } else if (SettingConstants.FEATUER_FILE_NAME.equals(fileName)) {
- while (null != (content = in.readLine())) {
- initFeatureData(content);
+ while (null != (content = in.readLine())) {
+ String list[] = content.split(SettingConstants.READ_CSV_SEPARATOR, -1);
+ if (list != null) {
+ int index = Integer.parseInt(list[SettingConstants.FEATURE_KEY_FEATURE_INDEX]);
+ Feature feature = Feature.getFeature(index);
+
+ // search feature
+ if (null == feature) {
+ Logger.error("unknown feature : "
+ + list[SettingConstants.FEATURE_KEY_FEATURE_INDEX] + ", "
+ + list[SettingConstants.FEATURE_KEY_FEATURE_NAME]);
+ continue;
+ }
+
+ FeatureData featureData = feature.getData();
+ featureData.setFeatureType(Integer
+ .parseInt(list[SettingConstants.FEATURE_KEY_FEATURE_TYPE]));
+
+ // set parentIndex
+ if ((null != list[SettingConstants.FEATURE_KEY_PARENT_INDEX])
+ && (!(list[SettingConstants.FEATURE_KEY_PARENT_INDEX]).isEmpty())) {
+ int parentIndex = Integer
+ .parseInt(list[SettingConstants.FEATURE_KEY_PARENT_INDEX]);
+ if (Feature.getFeature(parentIndex) != null) {
+ featureData.setParentIndex(parentIndex);
+ }
+ } // else : main feature
+
+ featureData.makePageList(list[SettingConstants.FEATURE_KEY_PAGE_LIST]);
+ featureData.makeChartList(list[SettingConstants.FEATURE_KEY_CHART_LIST]);
+ featureData.setMinValue(list[SettingConstants.FEATURE_KEY_MIN_VALUE]);
+ featureData.setMaxValue(list[SettingConstants.FEATURE_KEY_MAX_VALUE]);
+ featureData.setDefaultValue(list[SettingConstants.FEATURE_KEY_DEFAULT_VALUE]);
+ featureData
+ .setOverheadRanking(list[SettingConstants.FEATURE_KEY_OVERHEAD_RANKING]);
}
- } else if (SettingConstants.TEMPLATE_FILE_NAME.equals(fileName)) {
- while (null != (content = in.readLine())) {
- initTemplateData(content);
+ }
+ } catch (FileNotFoundException e) {
+ parsingSuccess = false;
+ Logger.exception(e);
+ } catch (IOException e) {
+ Logger.exception(e);
+ } finally {
+ CommonUtil.tryClose(in);
+ }
+ }
+
+ private void readTemplateFile() {
+ File csv = new File(SettingConstants.SettingFilePath + SettingConstants.TEMPLATE_FILE_NAME);
+ BufferedReader in = null;
+ String content = null;
+ try {
+ in = new BufferedReader(new FileReader(csv));
+ while (null != (content = in.readLine())) {
+ String list[] = content.split(SettingConstants.READ_CSV_SEPARATOR, -1);
+ if (list != null) {
+ int index = Integer
+ .parseInt(list[SettingConstants.TEMPLATE_KEY_TEMPLATE_INDEX]);
+ Template template = Template.getTemplate(index);
+
+ // search template
+ if (null == template) {
+ Logger.error("unknown template : "
+ + list[SettingConstants.TEMPLATE_KEY_TEMPLATE_INDEX] + ", "
+ + list[SettingConstants.TEMPLATE_KEY_TEMPLATE_NAME]);
+ continue;
+ }
+
+ TemplateData templateDate = template.getData();
+
+ // make feature list
+ for (int i = 2; i < list.length; i++) {
+ templateDate.makeFeatureList(list[i]);
+ }
+ } // else do nothing
+ }
+ } catch (FileNotFoundException e) {
+ parsingSuccess = false;
+ Logger.exception(e);
+ } catch (IOException e) {
+ Logger.exception(e);
+ } finally {
+ CommonUtil.tryClose(in);
+ }
+ }
+
+ private void readSettingFile() {
+ File csv = new File(SettingConstants.SettingFilePath + SettingConstants.SETTING_FILE_NAME);
+ BufferedReader in = null;
+ String content = null;
+ try {
+ in = new BufferedReader(new FileReader(csv));
+ while (null != (content = in.readLine())) {
+ String list[] = content.split(SettingConstants.READ_CSV_SEPARATOR);
+
+ if (list[0].equals(SettingConstants.KEY_VERSION)) {
+ version = Double.parseDouble(list[1]);
+ } else if (list[0].equals(SettingConstants.KEY_LOG_LEVEL)) {
+ logLevel = Integer.parseInt(list[1]);
+ } else if (list[0].equals(SettingConstants.KEY_DEBUG_PRINT)) {
+ DebugLog.enableDebugPrint(list[1].equals(SettingConstants.VALUE_YES));
+ } else if (list[0].equals(SettingConstants.KEY_AVAILABLE_TARGET_LIST)) {
+ for (int i = 1; i < list.length; i++) {
+ if (targetListMap.get(list[i]) == null) {
+ targetListMap.put(list[i], new TargetData(list[i]));
+ } // else do nothing
+ }
+ } else if (list[0].equals(SettingConstants.KEY_SELECTED_TARGET)) {
+ selectedTarget = list[1];
+ initTarget = new String(list[1]);
+ } else if (list[0].equals(SettingConstants.KEY_DEFAULT_FEATURE_LIST)) {
+ for (int i = 1; i < list.length; i++) {
+ defaultFeatureList.add(Feature.getFeature(Integer.parseInt(list[i])));
+ }
+ } else if (list[0].equals(SettingConstants.KEY_TOTAL_OVERHEAD_RANGE)) {
+ for (int i = 1; i < list.length; i++) {
+ totalOverheadRange.add(Long.parseLong(list[i]));
+ }
+ } else if (list[0].equals(SettingConstants.KEY_OPTIONS_SELECTED_FEATURE_LIST)) {
+ for (int i = 1; i < list.length; i++) {
+ String valueList[] = list[i].split(CommonConstants.COLON);
+ FeatureValueData feature = new FeatureValueData(Feature.getFeature(Integer
+ .parseInt(valueList[0])));
+
+ if (valueList.length > 1) {
+ feature.setValue(Integer.parseInt(valueList[1]));
+ } // else : feature is on/off type
+
+ optionsSelectedFeatureList.add(feature);
+ }
+
+ // init Feature list
+ copyFeatureList(optionsSelectedFeatureList, initOptionsSelectedFeatureList);
+ } else {
+ if (targetListMap.get(list[0]) != null) {
+ getTarget(list[0]).makeDetailInformation(list);
+ } else {
+ Logger.warning("not available target : " + list[0]);
+ }
}
- } else {
- Logger.debug("unknown setting file : " + fileName);
}
} catch (FileNotFoundException e) {
parsingSuccess = false;
}
}
- /****************************** feature operation ******************************/
+ /****************************** write setting file functions ****************************/
+
+ private void writeSettingFile() {
+ // written unit test for each of the sub method
+ File csv = new File(SettingConstants.SettingFilePath + SettingConstants.SETTING_FILE_NAME);
+
+ FileWriter fileWriter = null;
+ BufferedWriter buffWriter = null;
+ PrintWriter printWriter = null;
+ try {
+ fileWriter = new FileWriter(csv);
+ buffWriter = new BufferedWriter(fileWriter);
+ printWriter = new PrintWriter(buffWriter);
- public void initFeatureData(String readData) {
- String list[] = readData.split(SettingConstants.READ_CSV_SEPARATOR, -1);
- if (list != null) {
- int index = Integer.parseInt(list[SettingConstants.FEATURE_KEY_FEATURE_INDEX]);
- Feature feature = Feature.getFeature(index);
+ printWriter.println(SettingConstants.KEY_VERSION + SettingConstants.WRITE_CSV_SEPARATOR
+ + version);
+ printWriter.println(SettingConstants.KEY_LOG_LEVEL
+ + SettingConstants.WRITE_CSV_SEPARATOR + logLevel);
+ printWriter.println(SettingConstants.KEY_DEBUG_PRINT
+ + SettingConstants.WRITE_CSV_SEPARATOR
+ + (DebugLog.isEnabled() ? SettingConstants.VALUE_YES
+ : SettingConstants.VALUE_NO));
+ printWriter.println(writeTargetData()); // write available target list
+ printWriter.println(SettingConstants.KEY_SELECTED_TARGET
+ + SettingConstants.WRITE_CSV_SEPARATOR + selectedTarget);
+ printWriter.println(writeDefaultFeatureList(SettingConstants.KEY_DEFAULT_FEATURE_LIST));
+ printWriter.println(writeCollection(totalOverheadRange,
+ SettingConstants.KEY_TOTAL_OVERHEAD_RANGE));
+ printWriter.println(SettingConstants.KEY_OPTIONS_SELECTED_FEATURE_LIST
+ + SettingConstants.WRITE_CSV_SEPARATOR + writeOptionsSelectedFeatureListData());
- // search feature
- if (null == feature) {
- Logger.debug("unknown feature : "
- + list[SettingConstants.FEATURE_KEY_FEATURE_INDEX] + ", "
- + list[SettingConstants.FEATURE_KEY_FEATURE_NAME]);
- return;
+ // target information
+ for (Map.Entry<String, TargetData> entry : targetListMap.entrySet()) {
+ TargetData target = entry.getValue();
+ target.writeSelectedData(printWriter);
}
- FeatureData featureData = feature.getData();
- featureData.setFeatureType(Integer
- .parseInt(list[SettingConstants.FEATURE_KEY_FEATURE_TYPE]));
+ printWriter.checkError();
+ } catch (IOException e) {
+ Logger.exception(e);
+ } finally {
+ CommonUtil.tryClose(fileWriter, buffWriter, printWriter);
+ }
+ }
- // set parentIndex
- if ((null != list[SettingConstants.FEATURE_KEY_PARENT_INDEX])
- && (!(list[SettingConstants.FEATURE_KEY_PARENT_INDEX]).isEmpty())) {
- int parentIndex = Integer.parseInt(list[SettingConstants.FEATURE_KEY_PARENT_INDEX]);
- if (Feature.getFeature(parentIndex) != null) {
- featureData.setParentIndex(parentIndex);
- }
- } // else : main feature
+ private String writeTargetData() {
+ Set<String> targetNameList = targetListMap.keySet();
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(SettingConstants.KEY_AVAILABLE_TARGET_LIST);
- featureData.makePageList(list[SettingConstants.FEATURE_KEY_PAGE_LIST]);
- featureData.makeChartList(list[SettingConstants.FEATURE_KEY_CHART_LIST]);
- featureData.setMinValue(list[SettingConstants.FEATURE_KEY_MIN_VALUE]);
- featureData.setMaxValue(list[SettingConstants.FEATURE_KEY_MAX_VALUE]);
- featureData.setDefaultValue(list[SettingConstants.FEATURE_KEY_DEFAULT_VALUE]);
- featureData.setOverheadRanking(list[SettingConstants.FEATURE_KEY_OVERHEAD_RANKING]);
+ Iterator<String> iter = targetNameList.iterator();
+ while (iter.hasNext()) {
+ buffer.append(SettingConstants.WRITE_CSV_SEPARATOR + iter.next());
}
+ return buffer.toString();
}
- /****************************** template operation ******************************/
+ private String writeDefaultFeatureList(String key) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(key + SettingConstants.WRITE_CSV_SEPARATOR);
- private void initTemplateData(String readData) {
- String list[] = readData.split(SettingConstants.READ_CSV_SEPARATOR, -1);
- if (list != null) {
- int index = Integer.parseInt(list[SettingConstants.TEMPLATE_KEY_TEMPLATE_INDEX]);
- Template template = Template.getTemplate(index);
+ for (int i = 0; i < defaultFeatureList.size(); i++) {
+ if (i < defaultFeatureList.size() - 1) {
+ buffer.append(defaultFeatureList.get(i).getIndex()
+ + SettingConstants.WRITE_CSV_SEPARATOR);
+ } else {
+ buffer.append(defaultFeatureList.get(i).getIndex());
+ }
+ }
+ return buffer.toString();
+ }
- // search template
- if (null == template) {
- Logger.debug("unknown template : "
- + list[SettingConstants.TEMPLATE_KEY_TEMPLATE_INDEX] + ", "
- + list[SettingConstants.TEMPLATE_KEY_TEMPLATE_NAME]);
- return;
+ private <T> String writeCollection(Collection<T> collection, String key) {
+ StringBuffer subBuffer = new StringBuffer();
+ for (T element : collection) {
+ if (subBuffer.length() > 0) {
+ subBuffer.append(SettingConstants.WRITE_CSV_SEPARATOR);
}
+ subBuffer.append(element.toString());
+ }
- TemplateData templateDate = template.getData();
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(key);
+ buffer.append(SettingConstants.WRITE_CSV_SEPARATOR);
+ buffer.append(subBuffer);
- // make feature list
- for (int i = 2; i < list.length; i++) {
- templateDate.makeFeatureList(list[i]);
- }
- } // else do nothing
+ return buffer.toString();
+ }
+
+ private String writeOptionsSelectedFeatureListData() {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < optionsSelectedFeatureList.size(); i++) {
+ FeatureValueData feature = optionsSelectedFeatureList.get(i);
+
+ buffer.append(feature.getKey().getIndex());
+ if (feature.getValue() >= 0) { // detail feature
+ buffer.append(String.valueOf(CommonConstants.COLON + feature.getValue()));
+ } // else : (main feature or sub feature) feature does not have a value.
+
+ if (i < optionsSelectedFeatureList.size() - 1) {
+ buffer.append(SettingConstants.WRITE_CSV_SEPARATOR);
+ } // else : the last value will be written to a csv file does not contain a comma.
+ }
+ return buffer.toString();
}
/****************************** protocol operation ******************************/
return count * SettingConstants.OVERHEAD_AVG_SECONDS;
}
- /****************************** setting operation ******************************/
-
- private void initSettingData(String readData) {
- String list[] = readData.split(SettingConstants.READ_CSV_SEPARATOR);
-
- if (list[0].equals(SettingConstants.KEY_VERSION)) {
- version = Double.parseDouble(list[1]);
- } else if (list[0].equals(SettingConstants.KEY_LOG_LEVEL)) {
- logLevel = Integer.parseInt(list[1]);
- } else if (list[0].equals(SettingConstants.KEY_DEBUG_PRINT)) {
- DebugLog.enableDebugPrint(list[1].equals(SettingConstants.VALUE_YES));
- } else if (list[0].equals(SettingConstants.KEY_AVAILABLE_TARGET_LIST)) {
- makeTargetData(list);
- } else if (list[0].equals(SettingConstants.KEY_SELECTED_TARGET)) {
- selectedTarget = list[1];
- initTarget = new String(list[1]);
- } else if (list[0].equals(SettingConstants.KEY_SELECTED_CHART_LIST)) {
- convertStringArrayToStringList(selectedChartList, list);
- } else if (list[0].equals(SettingConstants.KEY_DEFAULT_CHART_LIST)) {
- convertStringArrayToStringList(defaultChartList, list);
- } else if (list[0].equals(SettingConstants.KEY_DEFAULT_FEATURE_LIST)) {
- convertStringArrayToFeatureList(defaultFeatureList, list);
- } else if (list[0].equals(SettingConstants.KEY_TOTAL_OVERHEAD_RANGE)) {
- convertStringArrayToLongList(totalOverheadRange, list);
- } else if (list[0].equals(SettingConstants.KEY_OPTIONS_SELECTED_FEATURE_LIST)) {
- makeOptionsSelectedFeatureList(list);
- } else {
- if (isTarget(list[0])) {
- getTarget(list[0]).makeDetailInformation(list);
- } else {
- Logger.debug("unknown setting key : " + list[0]);
+ /********************************** chart set manipulation ***************************/
+
+ public Set<String> getOptionsSelectedFeatureChartSet() {
+ Set<String> selectedChartSet = new HashSet<String>();
+ for (int i = 0; i < optionsSelectedFeatureList.size(); i++) {
+ FeatureData feature = optionsSelectedFeatureList.get(i).getKey().getData();
+ if (feature.getChartList().size() > 0) {
+ selectedChartSet.addAll(feature.getChartList());
}
}
+ return selectedChartSet;
}
- private void makeTargetData(String list[]) {
- if (list != null) {
- for (int i = 1; i < list.length; i++) {
- if (isTarget(list[i]) == false) {
- targetListMap.put(list[i], new TargetData(list[i]));
- } // else do nothing
+ /**
+ * Get chart information shown on the screen.
+ *
+ * @param targetName
+ * targetName
+ *
+ * @return The chart name list to be shown on the screen.
+ */
+ public Set<String> getSelectedChartSet(String targetName) {
+ TargetData target = getTarget(targetName);
+ if (null != target) {
+ Set<String> selectedChartSet = new HashSet<String>();
+ List<FeatureValueData> featureList = target.getSelectedFeatureList();
+ for (int i = 0; i < featureList.size(); i++) {
+ FeatureData feature = featureList.get(i).getKey().getData();
+ if (feature.getChartList().size() > 0) {
+ selectedChartSet.addAll(feature.getChartList());
+ }
}
- } // else do nothing
- }
-
- public boolean isTarget(String targetName) {
- if (targetListMap.get(targetName) == null) {
- return false;
+ return selectedChartSet;
} else {
- return true;
+ Logger.warning("Does not exist targetName : " + targetName);
+ return null;
}
}
- public TargetData getTarget(String targetName) {
- if (targetName == null) {
- return targetListMap.get(selectedTarget);
- } else {
- return targetListMap.get(targetName);
- }
- }
+ /**
+ * Update selected chart set by current setting
+ */
+ public void updateChartSet() {
+ /*-
+ * selected chart set = union of (default chart set, chart set of selected feature,
+ * chart set of option selected)
+ */
- private void convertStringArrayToStringList(List<String> list, String array[]) {
- for (int i = 1; i < array.length; i++) {
- list.add(array[i]);
- }
}
- private void convertStringArrayToFeatureList(List<Feature> list, String array[]) {
- for (int i = 1; i < array.length; i++) {
- list.add(Feature.getFeature(Integer.parseInt(array[i])));
- }
- }
+ /*********************************** Target manipulation ******************************/
- private void convertStringArrayToLongList(List<Long> list, String array[]) {
- for (int i = 1; i < array.length; i++) {
- list.add(Long.parseLong(array[i]));
- }
+ public String getSelectedTarget() {
+ return selectedTarget;
}
- private void makeOptionsSelectedFeatureList(String list[]) {
-
- for (int i = 1; i < list.length; i++) {
- String valueList[] = list[i].split(CommonConstants.COLON);
- FeatureValueData feature = new FeatureValueData(Feature.getFeature(Integer
- .parseInt(valueList[0])));
-
- if (valueList.length > 1) {
- feature.setValue(Integer.parseInt(valueList[1]));
- } // else : feature is on/off type
-
- optionsSelectedFeatureList.add(feature);
- }
-
- // init Feature list
- if (initOptionsSelectedFeatureList == null) {
- initOptionsSelectedFeatureList = new ArrayList<FeatureValueData>();
- copyFeatureList(optionsSelectedFeatureList, initOptionsSelectedFeatureList);
- }
+ public void setSelectedTarget(String selectedTarget) {
+ this.selectedTarget = selectedTarget;
}
- /********************************** write functions ********************************/
-
- private void writeSettingDataToFile() {
- // written unit test for each of the sub method
- File csv = new File(SettingConstants.SettingFilePath + SettingConstants.SETTING_FILE_NAME);
-
- FileWriter fileWriter = null;
- BufferedWriter buffWriter = null;
- PrintWriter printWriter = null;
- try {
- fileWriter = new FileWriter(csv);
- buffWriter = new BufferedWriter(fileWriter);
- printWriter = new PrintWriter(buffWriter);
-
- printWriter.println(SettingConstants.KEY_VERSION + SettingConstants.WRITE_CSV_SEPARATOR
- + version);
- printWriter.println(SettingConstants.KEY_LOG_LEVEL
- + SettingConstants.WRITE_CSV_SEPARATOR + logLevel);
- printWriter.println(SettingConstants.KEY_DEBUG_PRINT
- + SettingConstants.WRITE_CSV_SEPARATOR
- + (DebugLog.isEnabled() ? SettingConstants.VALUE_YES
- : SettingConstants.VALUE_NO));
- printWriter.println(writeTargetData()); // write available target list
- printWriter.println(SettingConstants.KEY_SELECTED_TARGET
- + SettingConstants.WRITE_CSV_SEPARATOR + selectedTarget);
- printWriter.println(writeList(selectedChartList,
- SettingConstants.KEY_SELECTED_CHART_LIST));
- printWriter
- .println(writeList(defaultChartList, SettingConstants.KEY_DEFAULT_CHART_LIST));
- printWriter.println(writeDefaultFeatureList(SettingConstants.KEY_DEFAULT_FEATURE_LIST));
- printWriter.println(writeList(totalOverheadRange,
- SettingConstants.KEY_TOTAL_OVERHEAD_RANGE));
- printWriter.println(SettingConstants.KEY_OPTIONS_SELECTED_FEATURE_LIST
- + SettingConstants.WRITE_CSV_SEPARATOR + writeOptionsSelectedFeatureListData());
-
- // target information
- for (Map.Entry<String, TargetData> entry : targetListMap.entrySet()) {
- TargetData target = entry.getValue();
- target.writeSelectedData(printWriter);
- }
-
- printWriter.checkError();
- } catch (IOException e) {
- Logger.exception(e);
- } finally {
- CommonUtil.tryClose(fileWriter, buffWriter, printWriter);
- }
+ public Map<String, TargetData> getTargetListMap() {
+ return Collections.unmodifiableMap(targetListMap);
}
- private String writeTargetData() {
- Set<String> targetNameList = targetListMap.keySet();
- StringBuffer buffer = new StringBuffer();
- buffer.append(SettingConstants.KEY_AVAILABLE_TARGET_LIST);
-
- Iterator<String> iter = targetNameList.iterator();
- while (iter.hasNext()) {
- buffer.append(SettingConstants.WRITE_CSV_SEPARATOR + iter.next());
+ public TargetData getTarget(String targetName) {
+ if (targetName == null) {
+ return targetListMap.get(selectedTarget);
+ } else {
+ return targetListMap.get(targetName);
}
- return buffer.toString();
}
- private String writeDefaultFeatureList(String key) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(key + SettingConstants.WRITE_CSV_SEPARATOR);
-
- for (int i = 0; i < defaultFeatureList.size(); i++) {
- if (i < defaultFeatureList.size() - 1) {
- buffer.append(defaultFeatureList.get(i).getIndex()
- + SettingConstants.WRITE_CSV_SEPARATOR);
- } else {
- buffer.append(defaultFeatureList.get(i).getIndex());
- }
- }
- return buffer.toString();
- }
+ public TargetData getConnectedTarget() {
+ // do not unit test the connected device.
+ // check connected target
+ DeviceInfo currentDevice = Global.getCurrentDeviceInfo();
- private <T> String writeList(List<T> list, String key) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(key + SettingConstants.WRITE_CSV_SEPARATOR);
+ if (null != currentDevice) {
+ String profileName = currentDevice.getPlatformName();
- for (int i = 0; i < list.size(); i++) {
- if (i < list.size() - 1) {
- buffer.append(list.get(i).toString() + SettingConstants.WRITE_CSV_SEPARATOR);
- } else {
- buffer.append(list.get(i).toString());
+ if (profileName != null && !(profileName.isEmpty())) {
+ TargetData tData = targetListMap.get(profileName);
+ if (tData != null) {
+ return tData;
+ }
}
}
- return buffer.toString();
- }
-
- private String writeOptionsSelectedFeatureListData() {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < optionsSelectedFeatureList.size(); i++) {
- FeatureValueData feature = optionsSelectedFeatureList.get(i);
-
- buffer.append(feature.getKey().getIndex());
- if (feature.getValue() >= 0) { // detail feature
- buffer.append(String.valueOf(CommonConstants.COLON + feature.getValue()));
- } // else : (main feature or sub feature) feature does not have a value.
-
- if (i < optionsSelectedFeatureList.size() - 1) {
- buffer.append(SettingConstants.WRITE_CSV_SEPARATOR);
- } // else : the last value will be written to a csv file does not contain a comma.
- }
- return buffer.toString();
- }
-
- /********************************** get / set functions *******************************/
-
- public List<String> getDefaultChartList() {
- return Collections.unmodifiableList(defaultChartList);
- }
- public List<String> getSelectedChartList() {
- return Collections.unmodifiableList(selectedChartList);
+ return targetListMap.get(selectedTarget);
}
- public Map<String, TargetData> getTargetListMap() {
- return Collections.unmodifiableMap(targetListMap);
- }
+ /********************************** Feature manipulation ******************************/
public List<Feature> getDefaultFeatureList() {
return Collections.unmodifiableList(defaultFeatureList);
}
- public List<Long> getTotalOverheadRange() {
- return Collections.unmodifiableList(totalOverheadRange);
- }
-
public List<FeatureValueData> getOptionsSelectedFeatureList() {
return Collections.unmodifiableList(optionsSelectedFeatureList);
}
- public String getSelectedTarget() {
- return selectedTarget;
- }
-
- public void setSelectedTarget(String selectedTarget) {
- this.selectedTarget = selectedTarget;
- }
-
- public int getTotalOverheadRangeCount() {
- return totalOverheadRange.size() + 1;
- }
-
- public void setSelectedChartList(Collection<String> selectedChartList) {
- this.selectedChartList.clear();
- this.selectedChartList.addAll(selectedChartList);
- }
-
public void addOptionsSelectedFeature(Feature feature, int featureValue) {
FeatureValueData featureData = getFeatureValueData(optionsSelectedFeatureList, feature);
// create FeatureValueData
return null;
}
- public Set<String> getOptionsSelectedFeatureChartList() {
- Set<String> selectedChartList = new HashSet<String>();
- for (int i = 0; i < optionsSelectedFeatureList.size(); i++) {
- FeatureData feature = optionsSelectedFeatureList.get(i).getKey().getData();
- if (feature.getChartList().size() > 0) {
- selectedChartList.addAll(feature.getChartList());
- }
- }
- return selectedChartList;
- }
-
- /******************************* miscellaneous **********************************/
-
- private void copyFeatureList(List<FeatureValueData> source, List<FeatureValueData> dest) {
- dest.clear();
-
- if (source.isEmpty()) {
- return;
- }
+ /******************************* Overhead manipulation *********************************/
- for (int i = 0; i < source.size(); i++) {
- dest.add(new FeatureValueData(source.get(i)));
- }
+ public List<Long> getTotalOverheadRange() {
+ return Collections.unmodifiableList(totalOverheadRange);
}
- public TargetData getConnectedTarget() {
- // do not unit test the connected device.
- // check connected target
- DeviceInfo currentDevice = Global.getCurrentDeviceInfo();
-
- if (null != currentDevice) {
- String profileName = currentDevice.getPlatformName();
-
- if (profileName != null && !(profileName.isEmpty())) {
- TargetData tData = targetListMap.get(profileName);
- if (tData != null) {
- return tData;
- }
- }
- }
-
- return targetListMap.get(selectedTarget);
+ public int getTotalOverheadRangeCount() {
+ return totalOverheadRange.size() + 1;
}
+ /******************************* Page list manipulation ********************************/
+
/**
* Get page information shown on the screen.
*
}
}
- /**
- * Get chart information shown on the screen.
- *
- * @param targetName
- * targetName
- *
- * @return The chart name list to be shown on the screen.
- */
- public Set<String> getSelectedChartList(String targetName) {
- TargetData target = getTarget(targetName);
- if (null != target) {
- Set<String> selectedChartList = new HashSet<String>();
- List<FeatureValueData> featureList = target.getSelectedFeatureList();
- for (int i = 0; i < featureList.size(); i++) {
- FeatureData feature = featureList.get(i).getKey().getData();
- if (feature.getChartList().size() > 0) {
- selectedChartList.addAll(feature.getChartList());
- }
- }
- return selectedChartList;
- } else {
- Logger.debug("Does not exist targetName : " + targetName);
- return null;
+ /******************************* miscellaneous **********************************/
+
+ private void copyFeatureList(List<FeatureValueData> source, List<FeatureValueData> dest) {
+ dest.clear();
+
+ if (source.isEmpty()) {
+ return;
+ }
+
+ for (int i = 0; i < source.size(); i++) {
+ dest.add(new FeatureValueData(source.get(i)));
}
}
public void applySettingData() {
// do not unit test the file write.
// write setting file
- writeSettingDataToFile();
+ writeSettingFile();
// update setting data
updateSettingData();
}
}
- public void writeSelectedChartList(List<String> selectedChartList) {
- // do not unit test the file write.
- setSelectedChartList(selectedChartList);
-
- // write setting file
- writeSettingDataToFile();
- }
-
public void writeAvailableChartList(String targetName, List<String> availableChartList) {
// do not unit test the file write.
TargetData target = getTarget(targetName);
}
// write setting file
- writeSettingDataToFile();
+ writeSettingFile();
}
public Set<Feature> getSelectedFeatureSet() {
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
+ * Woojin Jung <woojin2.jung@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.setting;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.tizen.dynamicanalyzer.common.path.PathManager;
+import org.tizen.dynamicanalyzer.util.CommonUtil;
+import org.tizen.dynamicanalyzer.util.Logger;
+
+public enum UILayoutDataManager {
+ INSTANCE;
+
+ private Set<String> defaultChartSet = new HashSet<String>();
+ private Set<String> selectedChartSet = new HashSet<String>();
+
+ private Set<String> selectedPageSet = new HashSet<String>();
+
+ private UILayoutDataManager() {
+ // set SettingFilePath
+ if (null == SettingConstants.SettingFilePath) {
+ SettingConstants.SettingFilePath = PathManager.DA_CONFIG_FOLDER_PATH + File.separator;
+ } // else : used in the unit test
+
+ readLayoutFile();
+ }
+
+ public void readLayoutFile() {
+ File csv = new File(SettingConstants.SettingFilePath + SettingConstants.LAYOUT_FILE_NAME);
+ BufferedReader in = null;
+ String content = null;
+ try {
+ in = new BufferedReader(new FileReader(csv));
+ while (null != (content = in.readLine())) {
+ String list[] = content.split(SettingConstants.READ_CSV_SEPARATOR);
+ if (list[0].equals(SettingConstants.KEY_SELECTED_CHART_LIST)) {
+ for (int i = 1; i < list.length; i++) {
+ selectedChartSet.add(list[i]);
+ }
+ } else if (list[0].equals(SettingConstants.KEY_DEFAULT_CHART_LIST)) {
+ for (int i = 1; i < list.length; i++) {
+ defaultChartSet.add(list[i]);
+ }
+ }
+ }
+ } catch (FileNotFoundException e) {
+ Logger.exception(e);
+ } catch (IOException e) {
+ Logger.exception(e);
+ } finally {
+ CommonUtil.tryClose(in);
+ }
+ }
+
+ private void writeLayoutFile() {
+ File csv = new File(SettingConstants.SettingFilePath + SettingConstants.LAYOUT_FILE_NAME);
+
+ FileWriter fileWriter = null;
+ BufferedWriter buffWriter = null;
+ PrintWriter printWriter = null;
+ try {
+ fileWriter = new FileWriter(csv);
+ buffWriter = new BufferedWriter(fileWriter);
+ printWriter = new PrintWriter(buffWriter);
+
+ printWriter.println(writeCollection(selectedChartSet,
+ SettingConstants.KEY_SELECTED_CHART_LIST));
+ printWriter.println(writeCollection(defaultChartSet,
+ SettingConstants.KEY_DEFAULT_CHART_LIST));
+
+ printWriter.checkError();
+ } catch (IOException e) {
+ Logger.exception(e);
+ } finally {
+ CommonUtil.tryClose(fileWriter, buffWriter, printWriter);
+ }
+ }
+
+ private <T> String writeCollection(Collection<T> collection, String key) {
+ StringBuffer subBuffer = new StringBuffer();
+ for (T element : collection) {
+ if (subBuffer.length() > 0) {
+ subBuffer.append(SettingConstants.WRITE_CSV_SEPARATOR);
+ }
+ subBuffer.append(element.toString());
+ }
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(key);
+ buffer.append(SettingConstants.WRITE_CSV_SEPARATOR);
+ buffer.append(subBuffer);
+
+ return buffer.toString();
+ }
+
+ /** getter and setter **/
+
+ public Set<String> getDefaultChartSet() {
+ return Collections.unmodifiableSet(defaultChartSet);
+ }
+
+ public Set<String> getSelectedChartSet() {
+ return Collections.unmodifiableSet(selectedChartSet);
+ }
+
+ public void setSelectedChartSet(Collection<String> selectedChartList) {
+ selectedChartSet.clear();
+ selectedChartSet.addAll(selectedChartList);
+
+ writeLayoutFile();
+ }
+
+ public boolean addSelectedChart(String chartName) {
+ boolean ret = selectedChartSet.add(chartName);
+ writeLayoutFile();
+ return ret;
+ }
+
+ public Set<String> getSelectedPageSet() {
+ return Collections.unmodifiableSet(selectedPageSet);
+ }
+
+ public void setSelectedPageSet(Collection<String> selectedPageList) {
+ this.selectedPageSet.clear();
+ this.selectedPageSet.addAll(selectedPageList);
+ }
+}
super(parent);
this.chartView = chartView_;
this.chartList = InteractiveDataManager.getInstance().getTimelineChartList();
- this.selectedChartList = InteractiveDataManager.getInstance().getShowTimelineChartList();
setOkButtonListener(okButtonListener);
}
TableItem[] tableitems = chartTableViewer.getTable().getItems();
ArrayList<Integer> order = new ArrayList<Integer>();
ArrayList<Boolean> showInfo = new ArrayList<Boolean>();
-
- selectedChartList.clear();
+ List<TimelineChart> selectedChartList = new ArrayList<TimelineChart>();
List<TimelineChart> tempChartList = new ArrayList<TimelineChart>(chartList);
chartList.clear();
order.add(itemData.index);
}
+ InteractiveDataManager.getInstance().setShowTimelineChartList(selectedChartList);
chartView.reArrangeChart(order, showInfo);
shell.dispose();
RunningDialog = false;
public List<TimelineChart> getShowTimelineChartList() {
return showTimelineChartList;
}
+
+ public void setShowTimelineChartList(List<TimelineChart> chartList) {
+ showTimelineChartList.clear();
+ showTimelineChartList.addAll(chartList);
+ }
public void addVariableInfo(InteractiveInfo info) {
variableInfoList.add(info);
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.setting.TargetData;
+import org.tizen.dynamicanalyzer.setting.UILayoutDataManager;
import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
import org.tizen.dynamicanalyzer.swap.logparser.Logs;
import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
private boolean newCustomChart = false;
private List<TimelineChart> chartList;
private ArrayList<TimelineChart> newChartList;
- private List<TimelineChart> selectedChartList;
private HashMap<String, TimelineChart> chartInstanceMapNameKey;
private HashMap<Integer, TimelineChart> chartInstanceMapTypeKey;
private TimelineChartManager() {
chartList = new ArrayList<TimelineChart>();
newChartList = new ArrayList<TimelineChart>();
- selectedChartList = new ArrayList<TimelineChart>();
chartInstanceMapNameKey = new HashMap<String, TimelineChart>();
chartInstanceMapTypeKey = new HashMap<Integer, TimelineChart>();
customChartMap = new HashMap<Integer, UserCustomChart>();
initChartMap(new EnergyChart());
loadSavedChartList();
- loadSelectedChartList();
}
@Override
public void loadSelectedChartList(Set<String> list) {
if (list.size() > 0) {
+ Set<String> actualSelectedChart = new HashSet<String>();
ArrayList<Boolean> showInfo = new ArrayList<Boolean>();
- selectedChartList.clear();
for (int i = 0; i < chartList.size(); i++) {
if (list.contains(chartList.get(i).getChartName())) {
- selectedChartList.add(chartList.get(i));
+ actualSelectedChart.add(chartList.get(i).getChartName());
showInfo.add(true);
} else {
showInfo.add(false);
}
}
AnalyzerUtil.getTimelineComposite().reArrangeChart(null, showInfo);
- }
- }
-
- private void loadSelectedChartList() {
- List<String> savedSelectedChartNameList = SettingDataManager.INSTANCE
- .getSelectedChartList();
- int size = savedSelectedChartNameList.size();
- if (size != 0) {
- for (int i = 0; i < size; i++) {
- TimelineChart chart = getChartInstance(savedSelectedChartNameList.get(i));
- if (chart != null) {
- selectedChartList.add(chart);
- }
- }
+ UILayoutDataManager.INSTANCE.setSelectedChartSet(actualSelectedChart);
}
}
this.chartList.addAll(chartList);
}
- public void setSelectedChartList(List<TimelineChart> chartList) {
- this.selectedChartList.clear();
- this.selectedChartList.addAll(chartList);
- }
-
public List<TimelineChart> getChartList() {
return chartList;
}
- public List<TimelineChart> getSelectedChartList() {
- return selectedChartList;
- }
-
private TimelineChart getChartInstance(String chartName) {
return chartInstanceMapNameKey.get(chartName);
}
this.newChartList.clear();
newCustomChart = false;
for (TimelineChart chart : newChartList) {
- selectedChartList.add(chart);
DAChartBoardItem item = chart.createBoardItem(chartBoard);
DAChart chartWidget = item.getChart();
chartWidget.addMouseMoveListener(timelineChartMouseEventListener);
chartWidget.addMouseTrackListener(new TimelineChartMouseTrackAdapter(chartBoard
.getTimeline()));
- }
- List<String> list = new ArrayList<String>();
- for (TimelineChart selectedChart : selectedChartList) {
- list.add(selectedChart.getChartName());
+ UILayoutDataManager.INSTANCE.addSelectedChart(chart.getChartName());
}
- SettingDataManager.INSTANCE.writeSelectedChartList(list);
}
for (TimelineChart timelineChart : chartList) {
}
chartList.clear();
- selectedChartList.clear();
loadSavedChartList();
- loadSelectedChartList();
customChartMap.clear();
customLogParser.clear();
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.setting.SettingDataManager;
+import org.tizen.dynamicanalyzer.setting.UILayoutDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.chart.TimelineChart;
import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
private final static int TITLE_COLUMN_WIDTH = 76;
private final static int TEXT_COLUMN_WIDTH = 345;
private final static int MULTILINE_MARGIN = 8;
-
+
protected TableViewer chartTableViewer;
protected List<TimelineChart> chartList = TimelineChartManager.getInstance().getChartList();
- protected List<TimelineChart> selectedChartList = TimelineChartManager.getInstance().getSelectedChartList();
private boolean DragItemStartPlg = true;
- private int swapItemIndexA = 0; // drag source
- private int swapItemIndexB = 0; // drag target
+ private int swapItemIndexA = 0; // drag source
+ private int swapItemIndexB = 0; // drag target
protected static boolean RunningDialog = false;
- private Map<Integer, Image> imageMap = new HashMap<Integer, Image>(); // for drag image
-
+ private Map<Integer, Image> imageMap = new HashMap<Integer, Image>(); // for drag image
+
public TimelineEditItemsDialog(Shell parent) {
super(parent);
}
public void setOkButtonListener(DACustomButtonClickEventListener okButtonListener) {
this.okButtonListener = okButtonListener;
}
-
+
private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
@Override
public void handleClickEvent(DACustomButton button) {
- TimelineChartManager chartManager = TimelineChartManager.getInstance();
TableItem[] tableitems = chartTableViewer.getTable().getItems();
ArrayList<Integer> order = new ArrayList<Integer>();
ArrayList<Boolean> showInfo = new ArrayList<Boolean>();
- List<TimelineChart> chartList = new ArrayList<TimelineChart>();
- List<TimelineChart> selectedChartList = new ArrayList<TimelineChart>();
-
-// StringBuffer strSaveChartNameList = new StringBuffer(
-// CommonConstants.EMPTY);
-// StringBuffer strSaveSelectedChartNameList = new StringBuffer(
-// CommonConstants.EMPTY);
- List<String> strSaveChartNameList = new ArrayList<String>();
List<String> strSaveSelectedChartNameList = new ArrayList<String>();
-
- for (TableItem item : tableitems) {
- TableItemData itemData = (TableItemData)item.getData();
- chartList.add(chartManager.getChartInstance(itemData.chartType));
- strSaveChartNameList.add(itemData.titleText);
-// strSaveChartNameList.append(CommonConstants.COMMA);
+ for (TableItem item : tableitems) {
+ TableItemData itemData = (TableItemData) item.getData();
if (itemData.isEnabled) {
- selectedChartList.add(chartManager
- .getChartInstance(itemData.chartType));
strSaveSelectedChartNameList.add(itemData.titleText);
-// strSaveSelectedChartNameList.append(CommonConstants.COMMA);
showInfo.add(true);
} else {
showInfo.add(false);
order.add(itemData.index);
}
- for (int i = tableitems.length; i < chartManager.getChartList()
- .size(); i++) {
- chartList.add(chartManager.getChartList().get(i));
- selectedChartList.add(chartManager.getChartList().get(i));
- }
-
- chartManager.setChartList(chartList);
- chartManager.setSelectedChartList(selectedChartList);
AnalyzerUtil.getTimelineComposite().reArrangeChart(order, showInfo);
- SettingDataManager.INSTANCE.writeSelectedChartList(strSaveSelectedChartNameList);
-
+ UILayoutDataManager.INSTANCE.setSelectedChartSet(strSaveSelectedChartNameList);
+
shell.dispose();
RunningDialog = false;
}
chartTableViewer.getTable().setLinesVisible(true);
chartTableViewer.getTable().setBackground(ColorResources.EDIT_CHART_TABLE_SEPARATE_COLOR);
- new TableColumn(chartTableViewer.getTable(), SWT.NONE).setWidth(TITLE_COLUMN_WIDTH); // Column for Title image
- new TableColumn(chartTableViewer.getTable(), SWT.NONE).setWidth(TEXT_COLUMN_WIDTH); // Column for Title text
+ // Column for Title image
+ new TableColumn(chartTableViewer.getTable(), SWT.NONE).setWidth(TITLE_COLUMN_WIDTH);
+ // Column for Title text
+ new TableColumn(chartTableViewer.getTable(), SWT.NONE).setWidth(TEXT_COLUMN_WIDTH);
- int chartListSize = chartList.size();
+ Set<String> selectedChartSet = UILayoutDataManager.INSTANCE.getSelectedChartSet();
+ int chartListSize = chartList.size();
final TableItem[] items = new TableItem[chartListSize];
for (int i = 0; i < chartListSize; i++) {
// setting data per table item
itemData.description = chartList.get(i).getChartDescriptor();
itemData.isEnabled = false;
itemData.isHovered = false;
-
- for (int j = 0; j < selectedChartList.size(); j++) {
- if (chartList.get(i).getChartType() == selectedChartList.get(j)
- .getChartType()) {
- itemData.isEnabled = true;
- break;
- }
+ if (selectedChartSet.contains(itemData.titleText)) {
+ itemData.isEnabled = true;
}
items[i].setData(itemData);
}
}
case SWT.PaintItem: {
int width = chartTableViewer.getTable().getClientArea().width;
-
+
TableItem item = (TableItem) event.item;
- TableItemData itemData = (TableItemData)item.getData();
+ TableItemData itemData = (TableItemData) item.getData();
GC gc = event.gc;
gc.setAdvanced(true);
gc.setBackground(background);
event.detail &= ~SWT.SELECTED;
- if (event.index == COLUMN_TITLE) { // draw column for title image
+ if (event.index == COLUMN_TITLE) { // draw column for title image
if (!itemData.isEnabled) {
gc.setAlpha(51);
}
- gc.drawImage(itemData.titleImage, TITLE_COLUMN_WIDTH / 2 - itemData.titleImage.getBounds().width / 2,
- event.y + TABLE_HEIGHT / 2 - itemData.titleImage.getBounds().height / 2);
- } else if (event.index == COLUMN_TEXT) { // draw column for title text
+ gc.drawImage(itemData.titleImage, TITLE_COLUMN_WIDTH / 2
+ - itemData.titleImage.getBounds().width / 2, event.y + TABLE_HEIGHT
+ / 2 - itemData.titleImage.getBounds().height / 2);
+ } else if (event.index == COLUMN_TEXT) { // draw column for title text
Image statusImage = ImageResources.ADD_CHART_OFF;
Color titleColor = ColorResources.ADD_CHART_DISABLE_TITLE_COLOR;
Color descriptColor = ColorResources.ADD_CHART_DISABLE_DESCRIPT_COLOR;
String[] temp = itemData.description.split("\n");
int title_point_y = TITLE_TEXT_OFFSET_Y;
int descript_point_y = DESCRIPT_TEXT_OFFSET_Y;
- if (temp.length == 2) { // multi line, support 2 lines.
+ if (temp.length == 2) { // multi line, support 2 lines.
title_point_y = TITLE_TEXT_OFFSET_Y - MULTILINE_MARGIN;
descript_point_y = DESCRIPT_TEXT_OFFSET_Y - MULTILINE_MARGIN;
}
gc.setForeground(titleColor);
gc.setFont(FontResources.EDIT_CHART_DLG_ITEM_NAME);
- gc.drawText(itemData.titleText, TITLE_TEXT_POINT_X, event.y + title_point_y, true);
+ gc.drawText(itemData.titleText, TITLE_TEXT_POINT_X,
+ event.y + title_point_y, true);
// draw descriptor text
gc.setForeground(descriptColor);
gc.setFont(FontResources.EDIT_CHART_DLG_ITEM_SUB_NAME);
- gc.drawText(itemData.description, TITLE_TEXT_POINT_X, event.y + descript_point_y, true);
+ gc.drawText(itemData.description, TITLE_TEXT_POINT_X, event.y
+ + descript_point_y, true);
// draw on/off image
- gc.drawImage(statusImage, width - statusImage.getBounds().width - ENABLE_IMAGE_OFFSET_X,
- event.y + ENABLE_IMAGE_OFFSET_Y);
+ gc.drawImage(statusImage, width - statusImage.getBounds().width
+ - ENABLE_IMAGE_OFFSET_X, event.y + ENABLE_IMAGE_OFFSET_Y);
// capture image for drag
Image itemImage = imageMap.get(itemData.chartType);
if (itemImage == null) {
- itemImage = new Image(Display.getDefault(), width-1, TABLE_HEIGHT);
+ itemImage = new Image(Display.getDefault(), width - 1, TABLE_HEIGHT);
imageMap.put(itemData.chartType, itemImage);
}
gc.copyArea(itemImage, 0, event.y);
chartTableViewer.getTable().addMouseListener(itemZoomMouseListener);
chartTableViewer.getTable().addMouseTrackListener(mouseTrackListener);
chartTableViewer.getTable().addMouseMoveListener(mouseMoveListener);
-
+
Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
- DragSource source = new DragSource(chartTableViewer.getTable(),
- DND.DROP_MOVE);
+ DragSource source = new DragSource(chartTableViewer.getTable(), DND.DROP_MOVE);
source.setTransfer(types);
source.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
event.data = sourceItem.getText();
chartTableViewer.getTable().redraw();
}
-
+
@Override
public void dragStart(DragSourceEvent event) {
// set drag image. this image will be shown below of mouse pointer.
Logger.warning("drag selection is null.");
return;
}
- Image dropImage = imageMap.get(((TableItemData)selection.getData()).chartType);
- ((TableItemData)selection.getData()).isDrag = true;
+ Image dropImage = imageMap.get(((TableItemData) selection.getData()).chartType);
+ ((TableItemData) selection.getData()).isDrag = true;
event.image = dropImage;
DragItemStartPlg = true;
chartTableViewer.getTable().redraw();
}
});
- DropTarget target = new DropTarget(chartTableViewer.getTable(),
- DND.DROP_MOVE);
+ DropTarget target = new DropTarget(chartTableViewer.getTable(), DND.DROP_MOVE);
target.setTransfer(types);
target.addDropListener(new DropTargetAdapter() {
public void dragEnter(DropTargetEvent event) {
if (DragItemStartPlg == true) {
- swapItemIndexA = chartTableViewer.getTable()
- .getSelectionIndex();
+ swapItemIndexA = chartTableViewer.getTable().getSelectionIndex();
DragItemStartPlg = false;
} else {
chartTableViewer.getTable().deselectAll();
: DND.DROP_NONE;
}
for (int i = 0, n = event.dataTypes.length; i < n; i++) {
- if (TextTransfer.getInstance().isSupportedType(
- event.dataTypes[i])) {
+ if (TextTransfer.getInstance().isSupportedType(event.dataTypes[i])) {
event.currentDataType = event.dataTypes[i];
}
}
/*
* Swap table item
*/
- TableItemData itemData_A = (TableItemData)chartTableItems[swapItemIndexA].getData();
- TableItemData itemData_B = (TableItemData)chartTableItems[swapItemIndexB].getData();
+ TableItemData itemData_A = (TableItemData) chartTableItems[swapItemIndexA]
+ .getData();
+ TableItemData itemData_B = (TableItemData) chartTableItems[swapItemIndexB]
+ .getData();
TableItemData itemData_tmp = itemData_A;
chartTableItems[swapItemIndexA].setData(itemData_B);
chartTableItems[swapItemIndexB].setData(itemData_tmp);
}
TableItem[] items = chartTableViewer.getTable().getItems();
for (int i = 0; i < items.length; i++) {
- ((TableItemData)items[i].getData()).isDrag = false;
+ ((TableItemData) items[i].getData()).isDrag = false;
}
chartTableViewer.getTable().redraw();
}
e.gc.setForeground(ColorResources.DIALOG_SUNKEN_1);
e.gc.drawLine(rect.x, rect.y, rect.x + rect.width, rect.y);
e.gc.setForeground(ColorResources.DIALOG_SUNKEN_2);
- e.gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width,
- rect.y + 1);
+ e.gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width, rect.y + 1);
}
});
private void setEditDialogButtonStyle(DAButton button) {
button.setGradation(ColorResources.EDIT_CHART_BUTTON_NORMAL_COLOR_START,
ColorResources.EDIT_CHART_BUTTON_NORMAL_COLOR_END,
- ColorResources.EDIT_CHART_BUTTON_PUSH_COLOR_START,
+ ColorResources.EDIT_CHART_BUTTON_PUSH_COLOR_START,
ColorResources.EDIT_CHART_BUTTON_PUSH_COLOR_END,
ColorResources.EDIT_CHART_BUTTON_HOVER_COLOR_START,
ColorResources.EDIT_CHART_BUTTON_HOVER_COLOR_END, null, null);
ColorResources.EDIT_CHART_BUTTON_INLINE_PUSH_COLOR,
ColorResources.EDIT_CHART_BUTTON_INLINE_HOVER_COLOR, null);
}
-
+
private MouseListener itemZoomMouseListener = new MouseAdapter() {
@Override
public void mouseUp(MouseEvent event) {
return;
}
TableItem[] chartTableItems = chartTableViewer.getTable().getItems();
- TableItemData itemData = (TableItemData)chartTableItems[selectItemIndex].getData();
- itemData.isEnabled = !itemData.isEnabled; // toggle
+ TableItemData itemData = (TableItemData) chartTableItems[selectItemIndex].getData();
+ itemData.isEnabled = !itemData.isEnabled; // toggle
table.deselectAll();
chartTableViewer.getTable().redraw();
}
};
-
+
private MouseTrackListener mouseTrackListener = new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
TableItem[] items = chartTableViewer.getTable().getItems();
for (int i = 0; i < items.length; i++) {
- ((TableItemData)items[i].getData()).isHovered = false;
+ ((TableItemData) items[i].getData()).isHovered = false;
}
chartTableViewer.getTable().redraw();
}
};
-
+
private MouseMoveListener mouseMoveListener = new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
TableItem targetItem = findTableItem(e.x, e.y);
-
+
TableItem[] items = chartTableViewer.getTable().getItems();
for (int i = 0; i < items.length; i++) {
if (items[i] == targetItem) {
- ((TableItemData)items[i].getData()).isHovered = true;
+ ((TableItemData) items[i].getData()).isHovered = true;
} else {
- ((TableItemData)items[i].getData()).isHovered = false;
+ ((TableItemData) items[i].getData()).isHovered = false;
}
}
chartTableViewer.getTable().redraw();
}
};
-
+
private TableItem findTableItem(int x, int y) {
return chartTableViewer.getTable().getItem(new Point(x, y));
}
-
+
protected static class TableItemData {
public int index;
public int chartType;
package org.tizen.dynamicanalyzer.ui.timeline.common;
import java.util.List;
+import java.util.Set;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.SelectionEvent;
import org.tizen.dynamicanalyzer.common.DASelectionData;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.setting.UILayoutDataManager;
import org.tizen.dynamicanalyzer.ui.common.SetRangeMarkerMouseMoveListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
private void initializeCharts() {
initIntervalMarkers(chartBoard);
List<TimelineChart> chartList = timelineChartManager.getChartList();
- List<TimelineChart> selectedChartList = timelineChartManager
- .getSelectedChartList();
+ Set<String> selectedChartSet = UILayoutDataManager.INSTANCE.getSelectedChartSet();
for (int i = 0; i < chartList.size(); i++) {
TimelineChart timelineChart = chartList.get(i);
.addMouseTrackListener(new TimelineChartMouseTrackAdapter(
chartBoard.getTimeline()));
- if (selectedChartList.contains(timelineChart)) {
+ if (selectedChartSet.contains(timelineChart.getChartName())) {
chartBoard.showItem(i);
} else {
chartBoard.hideItem(i);
import org.tizen.dynamicanalyzer.setting.SettingConstants;
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.setting.TargetData;
+import org.tizen.dynamicanalyzer.setting.UILayoutDataManager;
import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
import org.tizen.dynamicanalyzer.ui.page.BaseView;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineChartManager;
Set<String> selectedChartList = new HashSet<String>();
// set default chart list
- List<String> defaultChartList = SettingDataManager.INSTANCE.getDefaultChartList();
+ Set<String> defaultChartList = UILayoutDataManager.INSTANCE.getDefaultChartSet();
if (defaultChartList.size() > 0) {
selectedChartList.addAll(defaultChartList);
}
// set selected chart list
TargetData target = SettingDataManager.INSTANCE.getConnectedTarget();
- Set<String> targetChartList = SettingDataManager.INSTANCE.getSelectedChartList(target
+ Set<String> targetChartList = SettingDataManager.INSTANCE.getSelectedChartSet(target
.getTargetName());
selectedChartList.addAll(targetChartList);
- selectedChartList.addAll(SettingDataManager.INSTANCE.getOptionsSelectedFeatureChartList());
+ selectedChartList.addAll(SettingDataManager.INSTANCE.getOptionsSelectedFeatureChartSet());
// update chart list in timeline page
TimelineChartManager.getInstance().loadSelectedChartList(selectedChartList);
-
- // TODO : selectedChartList remove?
- if (selectedChartList.size() > 0) {
- SettingDataManager.INSTANCE.setSelectedChartList(selectedChartList);
- }
}
}
import org.tizen.dynamicanalyzer.setting.TargetData;
import org.tizen.dynamicanalyzer.setting.Template;
import org.tizen.dynamicanalyzer.setting.TemplateData;
+import org.tizen.dynamicanalyzer.setting.UILayoutDataManager;
import org.tizen.dynamicanalyzer.util.InternalLogger;
import org.tizen.dynamicanalyzer.util.Logger;
public class SettingDataManagerTest {
SettingDataManager setting = SettingDataManager.INSTANCE;
+ UILayoutDataManager layout = UILayoutDataManager.INSTANCE;
@BeforeClass
public static void initSettingData() {
// read file list
SettingConstants.SettingFilePath = SettingDataManagerTest.class.getResource("").getPath();
+
+ @SuppressWarnings("unused")
+ SettingDataManager s = SettingDataManager.INSTANCE;
+ @SuppressWarnings("unused")
+ UILayoutDataManager l = UILayoutDataManager.INSTANCE;
}
@AfterClass
@Test
public void testInitFeatureData() {
- SettingDataManager setting = SettingDataManager.INSTANCE;
-
FeatureData feature = Feature.SYSTEM_SAMPLING_RATE.getData();
assertEquals(ConfigureLabels.FEATURE_DETAIL_VALUE_SYSTEM_SAMPLING_RATE,
feature.getFeatureName());
feature = Feature.OPENGL_ANALYSIS.getData();
assertEquals(3, feature.getOverheadRanking());
-
- // null check
- setting.initFeatureData("10000|Auto Stop|0||||||||");
- assertNull(Feature.getFeature(10000));
}
@Test
TemplateData template = Template.TEMPLATE_BOTTLENECK.getData();
assertEquals(ConfigureLabels.TEMPLATE_NAME_BOTTLENECK, template.getTemplateName());
assertEquals(ConfigureLabels.TEMPLATE_DESCRIPTION_BOTTLENECK, template.getDescription());
-
- // null check
- try {
- Whitebox.invokeMethod(SettingDataManager.INSTANCE, "initTemplateData", "10000|Custom");
- assertNull(Template.getTemplate(10000));
- } catch (Exception e) {
- Logger.exception(e);
- }
}
@Test
// check Available Target List
Map<String, TargetData> targetListMap = setting.getTargetListMap();
assertEquals(1, targetListMap.size());
- assertTrue(setting.isTarget("mobile"));
- assertFalse(setting.isTarget("wearable"));
+ assertTrue(targetListMap.get("mobile") != null);
+ assertFalse(targetListMap.get("wearable") != null);
// check Selected Target
assertEquals("mobile", setting.getSelectedTarget());
assertEquals("mobile", initTarget);
// check Selected Chart List
- List<String> chartList = setting.getSelectedChartList();
- assertEquals(3, chartList.size());
- assertEquals("CPU", chartList.get(0));
- assertEquals("CPU core", chartList.get(1));
- assertEquals("CPU frequency", chartList.get(2));
+ Set<String> chartSet = layout.getSelectedChartSet();
+ assertEquals(3, chartSet.size());
+ assertTrue(chartSet.contains("CPU"));
+ assertTrue(chartSet.contains("CPU core"));
+ assertTrue(chartSet.contains("CPU frequency"));
// check Default Chart List
- chartList = setting.getDefaultChartList();
- assertEquals(3, chartList.size());
- assertEquals("CPU", chartList.get(0));
- assertEquals("CPU core", chartList.get(1));
- assertEquals("CPU frequency", chartList.get(2));
+ chartSet = layout.getDefaultChartSet();
+ assertEquals(3, chartSet.size());
+ assertTrue(chartSet.contains("CPU"));
+ assertTrue(chartSet.contains("CPU core"));
+ assertTrue(chartSet.contains("CPU frequency"));
// check Default Protocol List
List<Feature> defaultFeatureList = setting.getDefaultFeatureList();
public void testWriteChartList() {
try {
// check Selected Chart List
- String result = Whitebox.invokeMethod(setting, "writeList",
- (Object) setting.getSelectedChartList(),
- SettingConstants.KEY_SELECTED_CHART_LIST);
- assertEquals("Selected Chart List|CPU|CPU core|CPU frequency", result);
+ String result = Whitebox
+ .invokeMethod(layout, "writeCollection", (Object) layout.getSelectedChartSet(),
+ SettingConstants.KEY_SELECTED_CHART_LIST);
+ assertTrue(result.length() == 46);
+ assertTrue(result.startsWith("Selected Chart List|CPU"));
+ assertTrue(result.matches(".*CPU.*CPU.*CPU.*"));
// check Default Chart List
- result = Whitebox
- .invokeMethod(setting, "writeList", (Object) setting.getDefaultChartList(),
- SettingConstants.KEY_DEFAULT_CHART_LIST);
- assertEquals("Default Chart List|CPU|CPU core|CPU frequency", result);
+ result = Whitebox.invokeMethod(layout, "writeCollection",
+ (Object) layout.getDefaultChartSet(), SettingConstants.KEY_DEFAULT_CHART_LIST);
+ assertTrue(result.length() == 45);
+ assertTrue(result.startsWith("Default Chart List|CPU"));
+ assertTrue(result.matches(".*CPU.*CPU.*CPU.*"));
} catch (Exception e) {
Logger.exception(e);
}
@Test
public void testWriteOverheadRangeList() {
try {
- String result = Whitebox.invokeMethod(setting, "writeList",
+ String result = Whitebox.invokeMethod(setting, "writeCollection",
(Object) setting.getTotalOverheadRange(),
SettingConstants.KEY_TOTAL_OVERHEAD_RANGE);
assertEquals("Total Overhead Range|1000000|3000000|7000000|15000000", result);
assertEquals(Feature.THREAD_ANALYSIS.getIndex(), feature.getFeatureIndex());
FeatureValueData featureValue = Whitebox.invokeMethod(setting, "getFeatureValueData",
- (Object) setting.getOptionsSelectedFeatureList(), (Object)Feature.getFeature(0));
+ (Object) setting.getOptionsSelectedFeatureList(),
+ (Object) Feature.getFeature(0));
assertNull(featureValue);
// copyFeatureList()
assertEquals(800000, featureOverheadValue);
double count = Whitebox.invokeMethod(setting, "calculateCallcount", (Object) null,
- (Object)Feature.FUNCTION_SAMPLING_RATE, true);
+ (Object) Feature.FUNCTION_SAMPLING_RATE, true);
assertEquals(3000, count, 0);
count = Whitebox.invokeMethod(setting, "calculateCallcount", setting.getTarget(null),
- (Object)Feature.FUNCTION_SAMPLING_RATE, false);
+ (Object) Feature.FUNCTION_SAMPLING_RATE, false);
assertEquals(3000, count, 0);
} catch (Exception e) {
Logger.exception(e);
@Test
public void testSettingOperation() {
- try {
- Whitebox.invokeMethod(setting, "parseSettingData", "testConfigFile");
- assertFalse(setting.isParsingSuccess());
- } catch (Exception e) {
- Logger.exception(e);
- }
-
TargetData target = setting.getTarget("wearable");
assertNull(target);
target = setting.getTarget("mobile");
assertTrue(list.contains("Timeline"));
assertTrue(list.contains("Summary"));
- list = setting.getSelectedChartList("test-target");
+ list = setting.getSelectedChartSet("test-target");
assertNull(list);
- list = setting.getSelectedChartList("mobile");
+ list = setting.getSelectedChartSet("mobile");
assertEquals(1, list.size());
assertTrue(list.contains("CPU"));
assertEquals(10, featureValue);
// options selected feature chart list
- list = setting.getOptionsSelectedFeatureChartList();
+ list = setting.getOptionsSelectedFeatureChartSet();
assertEquals(1, list.size());
assertTrue(list.contains("Screenshot"));
--- /dev/null
+Selected Chart List|CPU|CPU core|CPU frequency
+Default Chart List|CPU|CPU core|CPU frequency
Debug Print|N
Available Target List|mobile
Selected Target|mobile
-Selected Chart List|CPU|CPU core|CPU frequency
-Default Chart List|CPU|CPU core|CPU frequency
Options Selected Feature List|5002:0
Default Feature List|2|3|103
Total Overhead Range|1000000|3000000|7000000|15000000