Issue #2130 - Fix ordering of columns in Subsciption Manager Dialog
Change-Id: I97ce5323002d6c1ae230c446de9837e541e02c86 Former-commit-id:cd511c1a0c
[formerlycd511c1a0c
[formerly d2fbc8fca1efa7c1a467fe9970da74d47d0ba759]] Former-commit-id:5c7fd77f98
Former-commit-id:053082cb80
This commit is contained in:
parent
3d6754337a
commit
0f4b98626b
1 changed files with 51 additions and 25 deletions
|
@ -21,7 +21,6 @@ package com.raytheon.uf.viz.datadelivery.subscription;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
@ -61,6 +60,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.SubColumnNames;
|
||||||
* Mar 9, 2012 418 jpiatt Updates for load, save & set default xml.
|
* Mar 9, 2012 418 jpiatt Updates for load, save & set default xml.
|
||||||
* Jun 07, 2012 687 lvenable Table data refactor.
|
* Jun 07, 2012 687 lvenable Table data refactor.
|
||||||
* Jan 03, 2013 1437 bgonzale Put default configuration file code here.
|
* Jan 03, 2013 1437 bgonzale Put default configuration file code here.
|
||||||
|
* Jun 21, 2013 2130 mpduff Fix ordering of columns.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -135,7 +135,8 @@ public class SubscriptionConfigurationManager {
|
||||||
private void readXML() {
|
private void readXML() {
|
||||||
try {
|
try {
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
LocalizationContext context = pm.getContext(LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
LocalizationContext context = pm.getContext(
|
||||||
|
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||||
|
|
||||||
LocalizationFile locFile = pm
|
LocalizationFile locFile = pm
|
||||||
.getLocalizationFile(context, fileName);
|
.getLocalizationFile(context, fileName);
|
||||||
|
@ -144,14 +145,15 @@ public class SubscriptionConfigurationManager {
|
||||||
File file = locFile.getFile();
|
File file = locFile.getFile();
|
||||||
|
|
||||||
if (file != null && file.exists()) {
|
if (file != null && file.exists()) {
|
||||||
xml = (SubscriptionManagerConfigXML)unmarshaller.unmarshal(file);
|
xml = (SubscriptionManagerConfigXML) unmarshaller
|
||||||
}
|
.unmarshal(file);
|
||||||
else {
|
} else {
|
||||||
xml = new SubscriptionManagerConfigXML();
|
xml = new SubscriptionManagerConfigXML();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (JAXBException e1) {
|
} catch (JAXBException e1) {
|
||||||
statusHandler.handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1);
|
statusHandler
|
||||||
|
.handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||||
|
@ -169,7 +171,8 @@ public class SubscriptionConfigurationManager {
|
||||||
|
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
|
|
||||||
LocalizationContext context = pm.getContext(LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
LocalizationContext context = pm.getContext(
|
||||||
|
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||||
LocalizationFile locFile = pm.getLocalizationFile(context, fileName);
|
LocalizationFile locFile = pm.getLocalizationFile(context, fileName);
|
||||||
|
|
||||||
File file = null;
|
File file = null;
|
||||||
|
@ -211,10 +214,11 @@ public class SubscriptionConfigurationManager {
|
||||||
private void populateAlignmentMap() {
|
private void populateAlignmentMap() {
|
||||||
for (int i = 0; i < SubColumnNames.values().length; i++) {
|
for (int i = 0; i < SubColumnNames.values().length; i++) {
|
||||||
if ((i == 2) || (i == 3)) {
|
if ((i == 2) || (i == 3)) {
|
||||||
alignmentMap.put(SubColumnNames.values()[i].toString(), SWT.CENTER);
|
alignmentMap.put(SubColumnNames.values()[i].toString(),
|
||||||
}
|
SWT.CENTER);
|
||||||
else {
|
} else {
|
||||||
alignmentMap.put(SubColumnNames.values()[i].toString(), SWT.LEFT);
|
alignmentMap.put(SubColumnNames.values()[i].toString(),
|
||||||
|
SWT.LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,31 +325,53 @@ public class SubscriptionConfigurationManager {
|
||||||
* Set the hidden and visible columns in the configuration.
|
* Set the hidden and visible columns in the configuration.
|
||||||
*
|
*
|
||||||
* @param visibleColumns
|
* @param visibleColumns
|
||||||
|
* List of visible columns
|
||||||
* @param hiddenColumns
|
* @param hiddenColumns
|
||||||
|
* List of hidden columns
|
||||||
*/
|
*/
|
||||||
public void setVisibleAndHidden(String[] visibleColumns,
|
public void setVisibleAndHidden(String[] visibleColumns,
|
||||||
String[] hiddenColumns) {
|
String[] hiddenColumns) {
|
||||||
ArrayList<ColumnXML> columnList = new ArrayList<ColumnXML>();
|
ArrayList<ColumnXML> columnList = new ArrayList<ColumnXML>();
|
||||||
Arrays.sort(visibleColumns);
|
|
||||||
Arrays.sort(hiddenColumns);
|
for (String columnName : visibleColumns) {
|
||||||
for (ColumnXML column :xml.getColumnList()) {
|
ColumnXML columnXml = getColumnXml(columnName);
|
||||||
int visibleIndex = Arrays.binarySearch(visibleColumns, column.getName());
|
if (columnXml == null) {
|
||||||
if (visibleIndex < 0) {
|
continue;
|
||||||
// not in visible, check hidden
|
|
||||||
int hiddenIndex = Arrays.binarySearch(hiddenColumns, column.getName());
|
|
||||||
if (hiddenIndex >= 0) {
|
|
||||||
column.setVisible(false);
|
|
||||||
columnList.add(column);
|
|
||||||
}
|
}
|
||||||
} else {
|
columnXml.setVisible(true);
|
||||||
column.setVisible(true);
|
columnList.add(columnXml);
|
||||||
columnList.add(column);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (String columnName : hiddenColumns) {
|
||||||
|
ColumnXML columnXml = getColumnXml(columnName);
|
||||||
|
if (columnXml == null) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
columnXml.setVisible(false);
|
||||||
|
columnList.add(columnXml);
|
||||||
|
}
|
||||||
|
|
||||||
xml.setColumnList(columnList);
|
xml.setColumnList(columnList);
|
||||||
saveXml();
|
saveXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the columnXML object for the provided column name.
|
||||||
|
*
|
||||||
|
* @param columnName
|
||||||
|
* The column name
|
||||||
|
* @return the ColumnXML object or null if no column by that name exists
|
||||||
|
*/
|
||||||
|
private ColumnXML getColumnXml(String columnName) {
|
||||||
|
for (ColumnXML col : xml.getColumnList()) {
|
||||||
|
if (col.getName().equals(columnName)) {
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the passed in LocalizationFile the current config?
|
* Is the passed in LocalizationFile the current config?
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue