Issue #1523 - Fix problem with legend keys.
Change-Id: Iea9cf5a95767b8c3a71ddc022757d9d5dda5a931 Former-commit-id:ed32adc993
[formerly478ec72102
] [formerlyba5014b162
] [formerlyc06ed9f9dc
[formerlyba5014b162
[formerly c625174317778f673a8f3b5062e1bd7832b70ed4]]] Former-commit-id:c06ed9f9dc
Former-commit-id: 1b1ac20cfdbaa8e552b23d4725c85806c869b494 [formerlyfbf92a6d06
] Former-commit-id:05e9b88566
This commit is contained in:
parent
c709c91154
commit
a09e8c5570
6 changed files with 201 additions and 41 deletions
|
@ -20,7 +20,7 @@
|
|||
package com.raytheon.uf.viz.stats.ui;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Grouping Composite for the Stats Graph.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -35,10 +35,14 @@ package com.raytheon.uf.viz.stats.ui;
|
|||
* @author mpduff
|
||||
* @version 1.0
|
||||
*/
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -108,6 +112,8 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
|||
/** Grouping callback */
|
||||
private final IStatsGroup callback;
|
||||
|
||||
private final List<SelectionEntry> selectionEntries = new ArrayList<SelectionEntry>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -193,12 +199,26 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
|||
*/
|
||||
private void createControls() {
|
||||
List<String> keyArray = graphData.getKeysWithData();
|
||||
Map<String, List<String>> grpNameMap = graphData.getGroupAndNamesMap();
|
||||
|
||||
// Create the Selection Entry objects
|
||||
for (String key : keyArray) {
|
||||
SelectionEntry se = new SelectionEntry();
|
||||
String[] parts = colonPattern.split(key);
|
||||
|
||||
Set<String> grpNames = grpNameMap.keySet();
|
||||
Iterator<String> iter = grpNames.iterator();
|
||||
for (int i = 0; i < grpNames.size(); i++) {
|
||||
se.addPair(iter.next(), parts[i]);
|
||||
}
|
||||
this.selectionEntries.add(se);
|
||||
}
|
||||
|
||||
for (SelectionEntry se : selectionEntries) {
|
||||
GridData gd = new GridData(20, 10);
|
||||
Label lbl = new Label(controlComp, SWT.BORDER);
|
||||
lbl.setLayoutData(gd);
|
||||
lbl.setData(key);
|
||||
lbl.setData(se);
|
||||
lbl.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) {
|
||||
|
@ -208,8 +228,9 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
|||
});
|
||||
|
||||
Button btn = new Button(controlComp, SWT.CHECK);
|
||||
btn.setText(key);
|
||||
btn.setText(se.toString());
|
||||
btn.setSelection(true);
|
||||
btn.setData(se);
|
||||
btn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
@ -218,8 +239,8 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
|||
}
|
||||
});
|
||||
|
||||
labelMap.put(key, lbl);
|
||||
checkBtnMap.put(key, btn);
|
||||
labelMap.put(se.toString(), lbl);
|
||||
checkBtnMap.put(se.toString(), btn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,7 +307,7 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
|||
*/
|
||||
private void handleLabelClickEvent(Label lbl) {
|
||||
RGB rgb = lbl.getBackground().getRGB();
|
||||
String key = (String) lbl.getData();
|
||||
String key = ((SelectionEntry) lbl.getData()).toString();
|
||||
|
||||
ColorDialog colorDlg = new ColorDialog(this.getShell());
|
||||
colorDlg.setRGB(rgb);
|
||||
|
@ -364,8 +385,6 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
|||
*/
|
||||
@Override
|
||||
public void setSelections(Map<String, Map<String, Boolean>> selectionMap) {
|
||||
List<String> keySequence = graphData.getKeySequence();
|
||||
|
||||
Multimap<String, String> offMap = ArrayListMultimap.create();
|
||||
for (String key : selectionMap.keySet()) {
|
||||
for (String selection : selectionMap.get(key).keySet()) {
|
||||
|
@ -383,21 +402,18 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
|||
}
|
||||
} else {
|
||||
for (String btnKey : checkBtnMap.keySet()) {
|
||||
String[] parts = colonPattern.split(btnKey);
|
||||
Button b = checkBtnMap.get(btnKey);
|
||||
SelectionEntry se = (SelectionEntry) b.getData();
|
||||
|
||||
for (String group : offMap.keySet()) {
|
||||
for (String part : parts) {
|
||||
int idx = keySequence.indexOf(part);
|
||||
if (idx >= 0
|
||||
&& offMap.get(group).contains(
|
||||
keySequence.get(idx))) {
|
||||
checkBtnMap.get(btnKey).setSelection(false);
|
||||
keyRgbMap.remove(btnKey);
|
||||
} else {
|
||||
checkBtnMap.get(btnKey).setSelection(true);
|
||||
keyRgbMap.put(btnKey, labelMap.get(btnKey)
|
||||
.getBackground().getRGB());
|
||||
}
|
||||
for (String key : offMap.keySet()) {
|
||||
Collection<String> valueList = offMap.get(key);
|
||||
if (valueList.contains(se.getValue(key))) {
|
||||
checkBtnMap.get(btnKey).setSelection(false);
|
||||
keyRgbMap.remove(btnKey);
|
||||
} else {
|
||||
checkBtnMap.get(btnKey).setSelection(true);
|
||||
keyRgbMap.put(btnKey, labelMap.get(btnKey)
|
||||
.getBackground().getRGB());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.stats.ui;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Stats Graph Item.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 24, 2013 mpduff Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SelectionEntry {
|
||||
private final Map<String, String> values = new LinkedHashMap<String, String>();
|
||||
|
||||
private boolean checked = true;
|
||||
|
||||
public SelectionEntry() {
|
||||
|
||||
}
|
||||
|
||||
public void addPair(String key, String value) {
|
||||
values.put(key, value);
|
||||
}
|
||||
|
||||
public String getValue(String key) {
|
||||
return values.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the checked
|
||||
*/
|
||||
public boolean isChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param checked
|
||||
* the checked to set
|
||||
*/
|
||||
public void setChecked(boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (Iterator<String> iter = values.values().iterator(); iter.hasNext();) {
|
||||
sb.append(iter.next());
|
||||
if (iter.hasNext()) {
|
||||
sb.append(":");
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -79,7 +79,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
|
|||
* Constructor.
|
||||
*
|
||||
* @param parentShell
|
||||
* @param graphData
|
||||
* @param selectionEntries
|
||||
* @param callback
|
||||
*/
|
||||
public SelectionManagerDlg(Shell parentShell, GraphData graphData,
|
||||
|
@ -89,8 +89,8 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
|
|||
| CAVE.INDEPENDENT_SHELL);
|
||||
setText("Selection Manager");
|
||||
|
||||
this.graphData = graphData;
|
||||
this.callback = callback;
|
||||
this.graphData = graphData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,7 +254,6 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
|
|||
private void populateTree() {
|
||||
Map<String, List<String>> grpMemberMap = graphData
|
||||
.getGroupAndNamesMap();
|
||||
Map<String, Boolean> stateMap = callback.getStates();
|
||||
|
||||
for (String key : grpMemberMap.keySet()) {
|
||||
TreeItem treeItem = new TreeItem(selectionTree, SWT.NONE);
|
||||
|
@ -265,8 +264,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
|
|||
for (String subKey : array) {
|
||||
TreeItem subTreeItem = new TreeItem(treeItem, SWT.NONE);
|
||||
subTreeItem.setText(subKey);
|
||||
|
||||
subTreeItem.setChecked(stateMap.get(subKey));
|
||||
subTreeItem.setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 21, 2012 jsanchez Initial creation.
|
||||
* Nov 09, 2012 dhladky Changed to CSV output
|
||||
* Jan 24, 2013 1357 mpduff Fix comma output and paths.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -91,6 +92,8 @@ public class Archiver {
|
|||
|
||||
private static final String COMMA = ",";
|
||||
|
||||
private static final Pattern NLPattern = Pattern.compile("[\\n\\r]+");
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(Archiver.class);
|
||||
|
||||
|
@ -116,15 +119,13 @@ public class Archiver {
|
|||
* @param items
|
||||
* @return
|
||||
*/
|
||||
private String createFilename(TimeRange tr, String eventType, String group) {
|
||||
private String createFilename(TimeRange tr, String eventType) {
|
||||
|
||||
SimpleDateFormat fileDateFormatter = new SimpleDateFormat(
|
||||
FILE_DATE_FORMAT);
|
||||
StringBuilder sb = new StringBuilder("stats/aggregates");
|
||||
String[] chunks = PERIOD_PATTERN.split(eventType);
|
||||
sb.append("/");
|
||||
sb.append(group);
|
||||
sb.append("/");
|
||||
sb.append(chunks[chunks.length - 1]);
|
||||
sb.append(".");
|
||||
sb.append(fileDateFormatter.format(tr.getStart()));
|
||||
|
@ -156,24 +157,29 @@ public class Archiver {
|
|||
double count = agrec.getCount();
|
||||
|
||||
if (eventType != null) {
|
||||
sb.append(eventType).append(COMMA);
|
||||
sb.append(eventType);
|
||||
}
|
||||
sb.append(COMMA);
|
||||
|
||||
if (startDate != null) {
|
||||
sb.append(dateFormat.format(startDate.getTime()))
|
||||
.append(COMMA);
|
||||
sb.append(dateFormat.format(startDate.getTime()));
|
||||
}
|
||||
sb.append(COMMA);
|
||||
|
||||
if (endDate != null) {
|
||||
sb.append(dateFormat.format(endDate.getTime())).append(
|
||||
COMMA);
|
||||
sb.append(dateFormat.format(endDate.getTime()));
|
||||
}
|
||||
sb.append(COMMA);
|
||||
|
||||
if (grouping != null) {
|
||||
sb.append(grouping).append(COMMA);
|
||||
sb.append(NLPattern.matcher(grouping).replaceAll(""));
|
||||
}
|
||||
sb.append(COMMA);
|
||||
|
||||
if (field != null) {
|
||||
sb.append(field).append(COMMA);
|
||||
sb.append(field);
|
||||
}
|
||||
sb.append(COMMA);
|
||||
|
||||
sb.append(max).append(COMMA);
|
||||
sb.append(min).append(COMMA);
|
||||
|
@ -212,10 +218,9 @@ public class Archiver {
|
|||
for (StatisticsKey key : statisticsMap.keySet()) {
|
||||
|
||||
String eventType = key.eventType;
|
||||
String grouping = key.grouping;
|
||||
List<AggregateRecord> records = statisticsMap.get(key);
|
||||
|
||||
String filename = createFilename(key.timeRange, eventType, grouping);
|
||||
String filename = createFilename(key.timeRange, eventType);
|
||||
try {
|
||||
writeToFile(filename, records);
|
||||
} catch (JAXBException e) {
|
||||
|
@ -243,8 +248,7 @@ public class Archiver {
|
|||
siteLocalization.getFile().getParentFile().mkdirs();
|
||||
// Write this to output CSV
|
||||
try {
|
||||
bw = new BufferedWriter(new FileWriter(
|
||||
outputFilePath));
|
||||
bw = new BufferedWriter(new FileWriter(outputFilePath));
|
||||
if (bw != null) {
|
||||
for (AggregateRecord agrec : records) {
|
||||
bw.write(getCSVOutput(agrec, dateFormatter));
|
||||
|
|
|
@ -70,5 +70,6 @@
|
|||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.edex.plugin.nwsauth"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.datadelivery.service"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.units"/>
|
||||
<classpathentry kind="src" path="/com.raytheon.uf.viz.stats"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.stats.ui;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* SelectionEntry test class.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 24, 2013 mpduff Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SelectionEntryTest {
|
||||
|
||||
@Test
|
||||
public void testCreateSelectionEntryClassAndAddKeys() {
|
||||
SelectionEntry se = new SelectionEntry();
|
||||
se.addPair("Key", "Value");
|
||||
se.addPair("Key2", "Value2");
|
||||
se.addPair("Key3", "Value3");
|
||||
assertTrue("Keys are wrong", se.toString()
|
||||
.equals("Value:Value2:Value3"));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue