Merge "Issue #1523 - Fix problem with legend keys." into 13.2.1_delivery
Former-commit-id:695f441e3f
[formerly0767f1a50b
] [formerly9756c431fd
] [formerlye4142b63c9
[formerly9756c431fd
[formerly 2dcf981656f547cc07f8124eadc32ca0204b4b46]]] Former-commit-id:e4142b63c9
Former-commit-id: 3db7896ccb9207afe3cea12b611de87c2bb0fbeb [formerly063ffa26eb
] Former-commit-id:4bf28dd204
This commit is contained in:
commit
e2f088c003
6 changed files with 201 additions and 41 deletions
|
@ -20,7 +20,7 @@
|
||||||
package com.raytheon.uf.viz.stats.ui;
|
package com.raytheon.uf.viz.stats.ui;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* Grouping Composite for the Stats Graph.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -35,10 +35,14 @@ package com.raytheon.uf.viz.stats.ui;
|
||||||
* @author mpduff
|
* @author mpduff
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
@ -108,6 +112,8 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
||||||
/** Grouping callback */
|
/** Grouping callback */
|
||||||
private final IStatsGroup callback;
|
private final IStatsGroup callback;
|
||||||
|
|
||||||
|
private final List<SelectionEntry> selectionEntries = new ArrayList<SelectionEntry>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
@ -193,12 +199,26 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
||||||
*/
|
*/
|
||||||
private void createControls() {
|
private void createControls() {
|
||||||
List<String> keyArray = graphData.getKeysWithData();
|
List<String> keyArray = graphData.getKeysWithData();
|
||||||
|
Map<String, List<String>> grpNameMap = graphData.getGroupAndNamesMap();
|
||||||
|
|
||||||
|
// Create the Selection Entry objects
|
||||||
for (String key : keyArray) {
|
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);
|
GridData gd = new GridData(20, 10);
|
||||||
Label lbl = new Label(controlComp, SWT.BORDER);
|
Label lbl = new Label(controlComp, SWT.BORDER);
|
||||||
lbl.setLayoutData(gd);
|
lbl.setLayoutData(gd);
|
||||||
lbl.setData(key);
|
lbl.setData(se);
|
||||||
lbl.addMouseListener(new MouseAdapter() {
|
lbl.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseDown(MouseEvent e) {
|
public void mouseDown(MouseEvent e) {
|
||||||
|
@ -208,8 +228,9 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
||||||
});
|
});
|
||||||
|
|
||||||
Button btn = new Button(controlComp, SWT.CHECK);
|
Button btn = new Button(controlComp, SWT.CHECK);
|
||||||
btn.setText(key);
|
btn.setText(se.toString());
|
||||||
btn.setSelection(true);
|
btn.setSelection(true);
|
||||||
|
btn.setData(se);
|
||||||
btn.addSelectionListener(new SelectionAdapter() {
|
btn.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
@ -218,8 +239,8 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
labelMap.put(key, lbl);
|
labelMap.put(se.toString(), lbl);
|
||||||
checkBtnMap.put(key, btn);
|
checkBtnMap.put(se.toString(), btn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +307,7 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
||||||
*/
|
*/
|
||||||
private void handleLabelClickEvent(Label lbl) {
|
private void handleLabelClickEvent(Label lbl) {
|
||||||
RGB rgb = lbl.getBackground().getRGB();
|
RGB rgb = lbl.getBackground().getRGB();
|
||||||
String key = (String) lbl.getData();
|
String key = ((SelectionEntry) lbl.getData()).toString();
|
||||||
|
|
||||||
ColorDialog colorDlg = new ColorDialog(this.getShell());
|
ColorDialog colorDlg = new ColorDialog(this.getShell());
|
||||||
colorDlg.setRGB(rgb);
|
colorDlg.setRGB(rgb);
|
||||||
|
@ -364,8 +385,6 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setSelections(Map<String, Map<String, Boolean>> selectionMap) {
|
public void setSelections(Map<String, Map<String, Boolean>> selectionMap) {
|
||||||
List<String> keySequence = graphData.getKeySequence();
|
|
||||||
|
|
||||||
Multimap<String, String> offMap = ArrayListMultimap.create();
|
Multimap<String, String> offMap = ArrayListMultimap.create();
|
||||||
for (String key : selectionMap.keySet()) {
|
for (String key : selectionMap.keySet()) {
|
||||||
for (String selection : selectionMap.get(key).keySet()) {
|
for (String selection : selectionMap.get(key).keySet()) {
|
||||||
|
@ -383,14 +402,12 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String btnKey : checkBtnMap.keySet()) {
|
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 key : offMap.keySet()) {
|
||||||
for (String part : parts) {
|
Collection<String> valueList = offMap.get(key);
|
||||||
int idx = keySequence.indexOf(part);
|
if (valueList.contains(se.getValue(key))) {
|
||||||
if (idx >= 0
|
|
||||||
&& offMap.get(group).contains(
|
|
||||||
keySequence.get(idx))) {
|
|
||||||
checkBtnMap.get(btnKey).setSelection(false);
|
checkBtnMap.get(btnKey).setSelection(false);
|
||||||
keyRgbMap.remove(btnKey);
|
keyRgbMap.remove(btnKey);
|
||||||
} else {
|
} else {
|
||||||
|
@ -401,7 +418,6 @@ public class GroupingComp extends Composite implements IGroupSelection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fireCallback();
|
fireCallback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param parentShell
|
* @param parentShell
|
||||||
* @param graphData
|
* @param selectionEntries
|
||||||
* @param callback
|
* @param callback
|
||||||
*/
|
*/
|
||||||
public SelectionManagerDlg(Shell parentShell, GraphData graphData,
|
public SelectionManagerDlg(Shell parentShell, GraphData graphData,
|
||||||
|
@ -89,8 +89,8 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
|
||||||
| CAVE.INDEPENDENT_SHELL);
|
| CAVE.INDEPENDENT_SHELL);
|
||||||
setText("Selection Manager");
|
setText("Selection Manager");
|
||||||
|
|
||||||
this.graphData = graphData;
|
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
this.graphData = graphData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,7 +254,6 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
|
||||||
private void populateTree() {
|
private void populateTree() {
|
||||||
Map<String, List<String>> grpMemberMap = graphData
|
Map<String, List<String>> grpMemberMap = graphData
|
||||||
.getGroupAndNamesMap();
|
.getGroupAndNamesMap();
|
||||||
Map<String, Boolean> stateMap = callback.getStates();
|
|
||||||
|
|
||||||
for (String key : grpMemberMap.keySet()) {
|
for (String key : grpMemberMap.keySet()) {
|
||||||
TreeItem treeItem = new TreeItem(selectionTree, SWT.NONE);
|
TreeItem treeItem = new TreeItem(selectionTree, SWT.NONE);
|
||||||
|
@ -265,8 +264,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
|
||||||
for (String subKey : array) {
|
for (String subKey : array) {
|
||||||
TreeItem subTreeItem = new TreeItem(treeItem, SWT.NONE);
|
TreeItem subTreeItem = new TreeItem(treeItem, SWT.NONE);
|
||||||
subTreeItem.setText(subKey);
|
subTreeItem.setText(subKey);
|
||||||
|
subTreeItem.setChecked(true);
|
||||||
subTreeItem.setChecked(stateMap.get(subKey));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ import com.raytheon.uf.common.time.TimeRange;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Aug 21, 2012 jsanchez Initial creation.
|
* Aug 21, 2012 jsanchez Initial creation.
|
||||||
* Nov 09, 2012 dhladky Changed to CSV output
|
* Nov 09, 2012 dhladky Changed to CSV output
|
||||||
|
* Jan 24, 2013 1357 mpduff Fix comma output and paths.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -91,6 +92,8 @@ public class Archiver {
|
||||||
|
|
||||||
private static final String COMMA = ",";
|
private static final String COMMA = ",";
|
||||||
|
|
||||||
|
private static final Pattern NLPattern = Pattern.compile("[\\n\\r]+");
|
||||||
|
|
||||||
private static final IUFStatusHandler statusHandler = UFStatus
|
private static final IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(Archiver.class);
|
.getHandler(Archiver.class);
|
||||||
|
|
||||||
|
@ -116,15 +119,13 @@ public class Archiver {
|
||||||
* @param items
|
* @param items
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String createFilename(TimeRange tr, String eventType, String group) {
|
private String createFilename(TimeRange tr, String eventType) {
|
||||||
|
|
||||||
SimpleDateFormat fileDateFormatter = new SimpleDateFormat(
|
SimpleDateFormat fileDateFormatter = new SimpleDateFormat(
|
||||||
FILE_DATE_FORMAT);
|
FILE_DATE_FORMAT);
|
||||||
StringBuilder sb = new StringBuilder("stats/aggregates");
|
StringBuilder sb = new StringBuilder("stats/aggregates");
|
||||||
String[] chunks = PERIOD_PATTERN.split(eventType);
|
String[] chunks = PERIOD_PATTERN.split(eventType);
|
||||||
sb.append("/");
|
sb.append("/");
|
||||||
sb.append(group);
|
|
||||||
sb.append("/");
|
|
||||||
sb.append(chunks[chunks.length - 1]);
|
sb.append(chunks[chunks.length - 1]);
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
sb.append(fileDateFormatter.format(tr.getStart()));
|
sb.append(fileDateFormatter.format(tr.getStart()));
|
||||||
|
@ -156,24 +157,29 @@ public class Archiver {
|
||||||
double count = agrec.getCount();
|
double count = agrec.getCount();
|
||||||
|
|
||||||
if (eventType != null) {
|
if (eventType != null) {
|
||||||
sb.append(eventType).append(COMMA);
|
sb.append(eventType);
|
||||||
}
|
}
|
||||||
|
sb.append(COMMA);
|
||||||
|
|
||||||
if (startDate != null) {
|
if (startDate != null) {
|
||||||
sb.append(dateFormat.format(startDate.getTime()))
|
sb.append(dateFormat.format(startDate.getTime()));
|
||||||
.append(COMMA);
|
|
||||||
}
|
}
|
||||||
|
sb.append(COMMA);
|
||||||
|
|
||||||
if (endDate != null) {
|
if (endDate != null) {
|
||||||
sb.append(dateFormat.format(endDate.getTime())).append(
|
sb.append(dateFormat.format(endDate.getTime()));
|
||||||
COMMA);
|
|
||||||
}
|
}
|
||||||
|
sb.append(COMMA);
|
||||||
|
|
||||||
if (grouping != null) {
|
if (grouping != null) {
|
||||||
sb.append(grouping).append(COMMA);
|
sb.append(NLPattern.matcher(grouping).replaceAll(""));
|
||||||
}
|
}
|
||||||
|
sb.append(COMMA);
|
||||||
|
|
||||||
if (field != null) {
|
if (field != null) {
|
||||||
sb.append(field).append(COMMA);
|
sb.append(field);
|
||||||
}
|
}
|
||||||
|
sb.append(COMMA);
|
||||||
|
|
||||||
sb.append(max).append(COMMA);
|
sb.append(max).append(COMMA);
|
||||||
sb.append(min).append(COMMA);
|
sb.append(min).append(COMMA);
|
||||||
|
@ -212,10 +218,9 @@ public class Archiver {
|
||||||
for (StatisticsKey key : statisticsMap.keySet()) {
|
for (StatisticsKey key : statisticsMap.keySet()) {
|
||||||
|
|
||||||
String eventType = key.eventType;
|
String eventType = key.eventType;
|
||||||
String grouping = key.grouping;
|
|
||||||
List<AggregateRecord> records = statisticsMap.get(key);
|
List<AggregateRecord> records = statisticsMap.get(key);
|
||||||
|
|
||||||
String filename = createFilename(key.timeRange, eventType, grouping);
|
String filename = createFilename(key.timeRange, eventType);
|
||||||
try {
|
try {
|
||||||
writeToFile(filename, records);
|
writeToFile(filename, records);
|
||||||
} catch (JAXBException e) {
|
} catch (JAXBException e) {
|
||||||
|
@ -243,8 +248,7 @@ public class Archiver {
|
||||||
siteLocalization.getFile().getParentFile().mkdirs();
|
siteLocalization.getFile().getParentFile().mkdirs();
|
||||||
// Write this to output CSV
|
// Write this to output CSV
|
||||||
try {
|
try {
|
||||||
bw = new BufferedWriter(new FileWriter(
|
bw = new BufferedWriter(new FileWriter(outputFilePath));
|
||||||
outputFilePath));
|
|
||||||
if (bw != null) {
|
if (bw != null) {
|
||||||
for (AggregateRecord agrec : records) {
|
for (AggregateRecord agrec : records) {
|
||||||
bw.write(getCSVOutput(agrec, dateFormatter));
|
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.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.datadelivery.service"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.units"/>
|
<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"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</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