--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Heeyoung Hwang <heeyoung1008.hwang@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.ui.toolbar.setting;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
+
+public class FeatureData {
+
+ public static final int FEATURE_TYPE_MAIN = 0;
+ public static final int FEATURE_TYPE_SUB = 1;
+ public static final int FEATURE_TYPE_DETAIL = 2;
+
+ private String targetName = null;
+
+ private String featureName = null;
+ private int featureType = FEATURE_TYPE_MAIN;
+ private String parentName = null;
+ private String description = null;
+ private List<String> pageList = null;
+ private List<String> chartList = null;
+
+ private int minValue = 0;
+ private int maxValue = 0;
+ private long swapValue = AnalyzerConstants.FEATURE_OFF; // 0x0000
+ private long overheadValue = AnalyzerConstants.FEATURE_OFF; // 0x0000
+
+ public FeatureData(String targetName, String featureName) {
+ this.targetName = targetName;
+ this.featureName = featureName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getFeatureName() {
+ return featureName;
+ }
+
+ public void setFeatureName(String featureName) {
+ this.featureName = featureName;
+ }
+
+ public int getFeatureType() {
+ return featureType;
+ }
+
+ public void setFeatureType(int featureType) {
+ this.featureType = featureType;
+ }
+
+ public String getParentName() {
+ return parentName;
+ }
+
+ public void setParentName(String parentName) {
+ this.parentName = parentName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int getMinValue() {
+ return minValue;
+ }
+
+ public void setMinValue(String minValue) {
+ if (isValidValue(minValue)) {
+ this.minValue = Integer.parseInt(minValue);
+ }
+ }
+
+ public int getMaxValue() {
+ return maxValue;
+ }
+
+ public void setMaxValue(String maxValue) {
+ if (isValidValue(maxValue)) {
+ this.maxValue = Integer.parseInt(maxValue);
+ }
+ }
+
+ public long getSwapValue() {
+ return swapValue;
+ }
+
+ public void setSwapValue(String swapValue) {
+ if (isValidValue(swapValue)) {
+ this.swapValue = Long.parseLong(swapValue);
+ }
+ }
+
+ public long getOverheadValue() {
+ return overheadValue;
+ }
+
+ public void setOverheadValue(String overheadValue) {
+ if (isValidValue(overheadValue)) {
+ this.overheadValue = Long.parseLong(overheadValue);
+ }
+ }
+
+ public List<String> getPageList() {
+ if (pageList == null) {
+ pageList = new ArrayList<String>();
+ }
+ return pageList;
+ }
+
+ public List<String> getChartList() {
+ if (chartList == null) {
+ chartList = new ArrayList<String>();
+ }
+ return chartList;
+ }
+
+ /**
+ * When choosing a feature, which generates a list of pages.
+ * (example Timeline, File, Thread, etc)
+ *
+ * @param data Page Information
+ */
+ public void makePageList(String data) {
+ if (data != null) {
+ List<String> pages = getPageList();
+
+ String list[] = data.split(CommonConstants.DASH);
+ for (int i = 0; i < list.length; i++) {
+ pages.add(list[i]);
+ }
+ } // else : do nothing
+ }
+
+ /**
+ * When choosing a feature, which generates a list of charts.
+ * (example CPU, Disk IO, Energy, etc)
+ *
+ * @param data Chart Information
+ */
+ public void makeChartList(String data) {
+ if (data != null) {
+ List<String> charts = getChartList();
+
+ String list[] = data.split(CommonConstants.DASH);
+ for (int i = 0; i < list.length; i++) {
+ charts.add(list[i]);
+ }
+ } // else : do nothing
+ }
+
+ private boolean isValidValue(String value) {
+ if ((null != value) && (CommonConstants.EMPTY.equals(value) == false)) {
+ return true;
+ }
+ return false;
+ }
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Heeyoung Hwang <heeyoung1008.hwang@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.ui.toolbar.setting;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
+import org.tizen.dynamicanalyzer.util.Logger;
+
+public class TargetData {
+
+ private String targetName = null;
+
+ // feature key index
+ public static final int FEATURE_KEY_TARGET_NAME = 0;
+ public static final int FEATURE_KEY_FEATURE_NAME = 1;
+ public static final int FEATURE_KEY_FEATURE_TYPE = 2;
+ public static final int FEATURE_KEY_PARENT_NAME = 3;
+ public static final int FEATURE_KEY_DESCRIPTION = 4;
+ public static final int FEATURE_KEY_PAGE_LIST = 5;
+ public static final int FEATURE_KEY_CHART_LIST = 6;
+ public static final int FEATURE_KEY_MIN_VALUE = 7;
+ public static final int FEATURE_KEY_MAX_VALUE = 8;
+ public static final int FEATURE_KEY_SWAP_VALUE = 9;
+ public static final int FEATURE_KEY_OVERHEAD_VALUE = 10;
+
+ // template key index
+ public static final int TEMPLATE_KEY_TARGET_NAME = 0;
+ public static final int TEMPLAT_KEY_TEMPLAT_NAME = 1;
+ public static final int TEMPLAT_KEY_DESCRIPTION = 2;
+
+ // available information
+ private HashMap<String, TemplateData> availableTemplateListMap = null;
+ private HashMap<String, FeatureData> availableFeatureListMap = null;
+
+ // dialog selected information
+ private String selectedTemplate = null;
+ private List<FeatureValueData> selectedFeatureList = null;
+
+ // init selected information : for revert button
+ private String initTemplate = null;
+ private List<FeatureValueData> initFeatureList = null;
+
+
+ public TargetData(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getSelectedTemplate() {
+ return selectedTemplate;
+ }
+
+ public void setSelectedTemplate(String selectedTemplate) {
+ if (this.initTemplate == null) {
+ this.initTemplate = selectedTemplate;
+ }
+ this.selectedTemplate = selectedTemplate;
+ }
+
+ public HashMap<String, TemplateData> getAvailableTemplateListMap() {
+ if (availableTemplateListMap == null) {
+ availableTemplateListMap = new HashMap<String, TemplateData>();
+ }
+ return availableTemplateListMap;
+ }
+
+ public boolean isAvailableTemplate(String templateName) {
+ HashMap<String, TemplateData> map = getAvailableTemplateListMap();
+ if (map.get(templateName) == null) {
+ return false;
+ }
+ return true;
+ }
+
+ public TemplateData getAvailableTemplate(String templateName) {
+ HashMap<String, TemplateData> map = getAvailableTemplateListMap();
+ return map.get(templateName);
+ }
+
+ public HashMap<String, FeatureData> getAvailableFeatureListMap() {
+ if (availableFeatureListMap == null) {
+ availableFeatureListMap = new HashMap<String, FeatureData>();
+ }
+ return availableFeatureListMap;
+ }
+
+ private boolean isAvailableFeature(String featureName) {
+ HashMap<String, FeatureData> map = getAvailableFeatureListMap();
+ if (map.get(featureName) == null) {
+ return false;
+ }
+ return true;
+ }
+
+ public FeatureData getAvailableFeature(String featureName) {
+ HashMap<String, FeatureData> map = getAvailableFeatureListMap();
+ return map.get(featureName);
+ }
+
+ public String getParentFeatureName(String featureName) {
+ if (isAvailableFeature(featureName) == true) {
+ HashMap<String, FeatureData> map = getAvailableFeatureListMap();
+ FeatureData feature = map.get(featureName);
+ return feature.getParentName();
+ } else {
+ Logger.debug("does not exist featureName : " + featureName);
+ }
+ return null;
+ }
+
+ public String getOptionFeatureName(String featureName) {
+ if (isAvailableFeature(featureName) == true) {
+ HashMap<String, FeatureData> map = getAvailableFeatureListMap();
+ for (Map.Entry<String, FeatureData> entry : map.entrySet()) {
+ FeatureData feature = entry.getValue();
+ if ((feature.getFeatureType() == FeatureData.FEATURE_TYPE_DETAIL) &&
+ (featureName.equals(feature.getParentName()) == true)) {
+ return feature.getFeatureName();
+ } // else : do nothing
+ }
+ } else {
+ Logger.debug("does not exist featureName : " + featureName);
+ }
+ return null;
+ }
+
+ public List<FeatureValueData> getSelectedFeatureList() {
+ if (selectedFeatureList == null) {
+ selectedFeatureList = new ArrayList<FeatureValueData>();
+ }
+ return selectedFeatureList;
+ }
+
+ public boolean isSelectedFeature(String featureName) {
+ List<FeatureValueData> selectedFeatures = getSelectedFeatureList();
+ FeatureValueData feature = getFeatureValueData(selectedFeatures, featureName);
+ if (feature != null) {
+ return true;
+ }
+ return false;
+ }
+
+ private FeatureValueData getFeatureValueData(List<FeatureValueData> featureList, String featureName) {
+ // null check
+ if ((featureList == null) || (featureName == null)) {
+ return null;
+ } // else : search FeatureValueData object
+
+ for (int i = 0; i < featureList.size(); i++) {
+ if (featureList.get(i).getFeatureName().equals(featureName) == true) {
+ return featureList.get(i);
+ } // else : do nothing
+ }
+ return null;
+ }
+
+ /**
+ * Add the selected feature.
+ *
+ * @param featureName featureName
+ * @param featureValue featureValue
+ */
+ public void addSelectedFeature(String featureName, int featureValue) {
+ List<FeatureValueData> featureList = getSelectedFeatureList();
+ FeatureValueData feature = getFeatureValueData(featureList, featureName);
+ // create FeatureValueData
+ if (feature == null) {
+ feature = new FeatureValueData();
+ feature.setFeatureName(featureName);
+ featureList.add(feature);
+ } // else : set value
+
+ feature.setValue(featureValue);
+ }
+
+ /**
+ * Delete from the list of features that have been deselected.
+ *
+ * @param featureName featureName
+ */
+ public void deleteSelectedFeature(String featureName) {
+ List<FeatureValueData> featureList = getSelectedFeatureList();
+ for (int i = 0; i < featureList.size(); i++) {
+ if (featureList.get(i).getFeatureName().equals(featureName) == true) {
+ featureList.remove(i);
+ } // else : do nothing
+ }
+ }
+
+ /**
+ * Get the value of the selected feature.
+ *
+ * @param featureName featureName
+ *
+ * @return featureValue (If the feature is not selected, returns -1.)
+ */
+ public int getSelectedFeatureValue(String featureName) {
+ List<FeatureValueData> selectedFeatures = getSelectedFeatureList();
+ FeatureValueData feature = getFeatureValueData(selectedFeatures, featureName);
+ if (feature == null) {
+ return -1;
+ }
+ return feature.getValue();
+ }
+
+ /**
+ * Get the swap value of the selected feature.
+ *
+ * @param featureName featureName
+ *
+ * @return feature swap value (If the feature is not selected, returns 0x0000.)
+ */
+ public long getSelectedFeatureSwapValue(String featureName) {
+ if (isSelectedFeature(featureName) == true) {
+ HashMap<String, FeatureData> map = getAvailableFeatureListMap();
+ FeatureData feature = map.get(featureName);
+ return feature.getSwapValue();
+ }
+ return AnalyzerConstants.FEATURE_OFF;
+ }
+
+ /**
+ * Generates a list of available template.
+ *
+ * @param list Template information list
+ */
+ public void makeAvailableTemplateListMap(String list[]) {
+ HashMap<String, TemplateData> map = getAvailableTemplateListMap();
+ TemplateData template = null;
+
+ // search template
+ if (isAvailableTemplate(list[TEMPLAT_KEY_TEMPLAT_NAME]) == false) {
+ template = new TemplateData(list[TEMPLATE_KEY_TARGET_NAME], list[TEMPLAT_KEY_TEMPLAT_NAME]);
+ map.put(list[TEMPLAT_KEY_TEMPLAT_NAME], template);
+ } else {
+ template = map.get(list[TEMPLAT_KEY_TEMPLAT_NAME]);
+ }
+
+ template.setDescription(list[TEMPLAT_KEY_DESCRIPTION]);
+
+ // make feature list
+ for (int i = 3; i < list.length; i++) {
+ template.makeFeatureList(list[i]);
+ }
+ }
+
+ /**
+ * Generates a list of available feature.
+ *
+ * @param list Feature information list
+ */
+ public void makeAvailableFeatureListMap(String list[]) {
+ HashMap<String, FeatureData> map = getAvailableFeatureListMap();
+ FeatureData feature = null;
+
+ // search feature
+ if (isAvailableFeature(list[FEATURE_KEY_FEATURE_NAME]) == false) {
+ feature = new FeatureData(list[FEATURE_KEY_TARGET_NAME], list[FEATURE_KEY_FEATURE_NAME]);
+ map.put(list[FEATURE_KEY_FEATURE_NAME], feature);
+ } else {
+ feature = map.get(list[FEATURE_KEY_FEATURE_NAME]);
+ }
+
+ feature.setFeatureType(Integer.parseInt(list[FEATURE_KEY_FEATURE_TYPE]));
+
+ // set parentName
+ if ((null != list[FEATURE_KEY_PARENT_NAME]) &&
+ (CommonConstants.EMPTY.equals(list[FEATURE_KEY_PARENT_NAME]) == false)) {
+ if (isAvailableFeature(list[FEATURE_KEY_PARENT_NAME]) == true) {
+ feature.setParentName(list[FEATURE_KEY_PARENT_NAME]);
+ }
+ } // else : main feature
+
+ feature.setDescription(list[FEATURE_KEY_DESCRIPTION]);
+ feature.makePageList(list[FEATURE_KEY_PAGE_LIST]);
+ feature.makeChartList(list[FEATURE_KEY_CHART_LIST]);
+ feature.setMinValue(list[FEATURE_KEY_MIN_VALUE]);
+ feature.setMaxValue(list[FEATURE_KEY_MAX_VALUE]);
+ feature.setSwapValue(list[FEATURE_KEY_SWAP_VALUE]);
+ feature.setOverheadValue(list[FEATURE_KEY_OVERHEAD_VALUE]);
+ }
+
+ /**
+ * Generates a list of selected feature.
+ *
+ * @param list Feature information list
+ */
+ public void makeSelectedFeatureList(String list[]) {
+ List<FeatureValueData> featureList = getSelectedFeatureList();
+
+ for (int i = 2; i < list.length; i++) {
+ String valueList[] = list[i].split(CommonConstants.COLON);
+ FeatureValueData feature = new FeatureValueData();
+ feature.setFeatureName(valueList[0]);
+
+ if (valueList.length > 1) {
+ feature.setValue(Integer.parseInt(valueList[1]));
+ } // else : feature is check status
+
+ // validation : available feature
+ if (isAvailableFeature(valueList[0]) == true) {
+ featureList.add(feature);
+ } // else : invalid feature
+ }
+
+ // init Feature list
+ if (initFeatureList == null) {
+ initFeatureList = new ArrayList<FeatureValueData>();
+ initFeatureList.addAll(featureList);
+ }
+ }
+
+ /**
+ * Write the selected template/feature information in the setting file.
+ *
+ * @param writer setting file Writer
+ *
+ * @throws IOException
+ */
+ public void writeSelectedData(PrintWriter writer) throws IOException {
+ writer.println(SettingDataManager.KEY_SELECTED_TEMPLATE + CommonConstants.COMMA +
+ targetName + CommonConstants.COMMA + selectedTemplate);
+ writer.println(SettingDataManager.KEY_SELECTED_FEATURE_LIST + CommonConstants.COMMA +
+ targetName + CommonConstants.COMMA + writeSelectedFeatureListData());
+ writer.checkError();
+ }
+
+ private String writeSelectedFeatureListData() {
+ StringBuffer buffer = new StringBuffer();
+ List<FeatureValueData> list = getSelectedFeatureList();
+ for (int i = 0; i < list.size(); i++) {
+ FeatureValueData feature = list.get(i);
+
+ buffer.append(feature.getFeatureName());
+ 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 < list.size() -1) {
+ buffer.append(CommonConstants.COMMA);
+ } // else : the last value will be written to a csv file does not contain a comma.
+ }
+ return buffer.toString();
+ }
+
+ public boolean changedFeatures() {
+ // check template
+ if (initTemplate.equals(selectedTemplate) == false) {
+ return true;
+ }
+
+ // check feature
+ List<FeatureValueData> featureList = getSelectedFeatureList();
+ if (featureList.size() != initFeatureList.size()) {
+ return true;
+ }
+
+ for (int i = 0; i < featureList.size(); i++) {
+ // check featureName
+ FeatureValueData selectedFeature = featureList.get(i);
+ FeatureValueData initFeature = getFeatureValueData(initFeatureList, selectedFeature.getFeatureName());
+ if (initFeature == null) {
+ return true;
+ } else {
+ // check value
+ if (getAvailableFeature(selectedFeature.getFeatureName()).getFeatureType()
+ == FeatureData.FEATURE_TYPE_DETAIL) {
+ if (selectedFeature.getValue() != initFeature.getValue()) {
+ return true;
+ } // else : return false;
+ }
+ }
+ }
+ return false;
+ }
+
+ public Set<String> getSelectedPageList() {
+ Set<String> selectedPageList = new HashSet<String>();
+ List<FeatureValueData> featureList = getSelectedFeatureList();
+ for (int i = 0; i < featureList.size(); i++) {
+ FeatureData feature = getAvailableFeature(featureList.get(i).getFeatureName());
+ selectedPageList.addAll(feature.getPageList());
+ }
+
+ return selectedPageList;
+ }
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Heeyoung Hwang <heeyoung1008.hwang@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.ui.toolbar.setting;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
+
+public class TemplateData {
+
+ private String targetName = null;
+
+ private String templateName = null;
+ private String description = null;
+ private List<FeatureValueData> featureList = null;
+
+ public TemplateData(String targetName, String templateName) {
+ this.targetName = targetName;
+ this.templateName = templateName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ public void setTemplateName(String templateName) {
+ this.templateName = templateName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public List<FeatureValueData> getFeatureList() {
+ if (featureList == null) {
+ featureList = new ArrayList<FeatureValueData>();
+ }
+ return featureList;
+ }
+
+ /**
+ * Generates a list of features included in the template.
+ *
+ * @param data Feature information
+ */
+ public void makeFeatureList(String data) {
+ if (data != null) {
+ List<FeatureValueData> features = getFeatureList();
+
+ // format : "featureName:featureValue"
+ String valueList[] = data.split(CommonConstants.COLON);
+
+ // set featureName
+ FeatureValueData feature = getFeatureValueData(valueList[0]);
+ if (feature == null) {
+ feature = new FeatureValueData();
+ feature.setFeatureName(valueList[0]);
+ features.add(feature);
+ }
+
+ // set featureValue
+ if (valueList.length > 1) {
+ feature.setValue(Integer.parseInt(valueList[1]));
+ } // else : feature is check status
+ } // else : do nothing
+ }
+
+ private FeatureValueData getFeatureValueData(String featureName) {
+ // null check
+ List<FeatureValueData> features = getFeatureList();
+ if ((features == null) || (featureName == null)) {
+ return null;
+ } // else : search FeatureValueData object
+
+ for (int i = 0; i < features.size(); i++) {
+ if (features.get(i).getFeatureName().equals(featureName) == true) {
+ return features.get(i);
+ } // else : do nothing
+ }
+ return null;
+ }
+
+}