Issue #2358 - Move config file management code to the subscription manager dialog.
Change-Id: I61b8093b1306404006c5d01b73874997054c4f2f Former-commit-id: 100fe3e61e5156dba32419005da4473bcd6d1e8b
This commit is contained in:
parent
5b53cb4c98
commit
e1180868e7
3 changed files with 319 additions and 242 deletions
|
@ -22,8 +22,6 @@ package com.raytheon.uf.viz.datadelivery.subscription;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
@ -38,6 +36,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -61,7 +60,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.SubColumnNames;
|
|||
* Jun 07, 2012 687 lvenable Table data refactor.
|
||||
* Jan 03, 2013 1437 bgonzale Put default configuration file code here.
|
||||
* Jun 21, 2013 2130 mpduff Fix ordering of columns.
|
||||
*
|
||||
* Nov 06, 2013 2358 mpduff Remove default configuration code.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -106,6 +105,9 @@ public class SubscriptionConfigurationManager {
|
|||
/** File name */
|
||||
String fileName;
|
||||
|
||||
/** Current Configuration File */
|
||||
private LocalizationFile currentConfigFile = null;
|
||||
|
||||
/**
|
||||
* Private Constructor
|
||||
*/
|
||||
|
@ -181,10 +183,8 @@ public class SubscriptionConfigurationManager {
|
|||
}
|
||||
|
||||
try {
|
||||
|
||||
marshaller.marshal(xml, file);
|
||||
locFile.save();
|
||||
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
} catch (Exception e) {
|
||||
|
@ -274,53 +274,27 @@ public class SubscriptionConfigurationManager {
|
|||
/**
|
||||
* Set the current configuration file.
|
||||
*
|
||||
* @param currentConfigFile
|
||||
* @param configFile
|
||||
*/
|
||||
public void setConfigFile(LocalizationFile configFile) {
|
||||
File file = configFile.getFile();
|
||||
fileName = configFile.getName();
|
||||
try {
|
||||
xml = (SubscriptionManagerConfigXML) unmarshaller.unmarshal(file);
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
this.currentConfigFile = configFile;
|
||||
if (!file.exists()) {
|
||||
if (xml == null) {
|
||||
xml = new SubscriptionManagerConfigXML();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
xml = (SubscriptionManagerConfigXML) unmarshaller
|
||||
.unmarshal(file);
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available configuration files to list.
|
||||
*
|
||||
* @return Map of context:name to LocalizationFile.
|
||||
*/
|
||||
public Map<String, LocalizationFile> getConfigFileNameMap() {
|
||||
String[] extensions = new String[] { ".xml" };
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
TreeMap<String, LocalizationFile> locFileMap = new TreeMap<String, LocalizationFile>();
|
||||
ArrayList<LocalizationContext> contextList = new ArrayList<LocalizationContext>();
|
||||
contextList.add(pm.getContext(LocalizationType.CAVE_STATIC,
|
||||
LocalizationLevel.BASE));
|
||||
contextList.add(pm.getContext(LocalizationType.CAVE_STATIC,
|
||||
LocalizationLevel.SITE));
|
||||
contextList.add(pm.getContext(LocalizationType.CAVE_STATIC,
|
||||
LocalizationLevel.USER));
|
||||
LocalizationFile[] locFiles = pm.listFiles(contextList
|
||||
.toArray(new LocalizationContext[contextList.size()]),
|
||||
CONFIG_PATH, extensions, false, true);
|
||||
|
||||
if (locFiles == null) {
|
||||
return new TreeMap<String, LocalizationFile>();
|
||||
}
|
||||
|
||||
for (int i = 0; i < locFiles.length; i++) {
|
||||
String locFile = locFiles[i].getName();
|
||||
int idx = locFile.lastIndexOf("/");
|
||||
String newStr = locFile.substring(idx + 1);
|
||||
|
||||
locFileMap.put(locFiles[i].getContext().getLocalizationLevel()
|
||||
+ ":" + newStr, locFiles[i]);
|
||||
}
|
||||
return locFileMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the hidden and visible columns in the configuration.
|
||||
*
|
||||
|
@ -352,7 +326,6 @@ public class SubscriptionConfigurationManager {
|
|||
}
|
||||
|
||||
xml.setColumnList(columnList);
|
||||
saveXml();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -394,15 +367,91 @@ public class SubscriptionConfigurationManager {
|
|||
saveXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the localization (config) file path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getLocalizationPath() {
|
||||
return CONFIG_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default config file's full path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDefaultXMLConfig() {
|
||||
return DEFAULT_CONFIG_XML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default config file's name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDefaultXMLConfigFileName() {
|
||||
return DEFAULT_CONFIG_XML_FILE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sorted Column
|
||||
*
|
||||
* @param columnName
|
||||
* @param sortDirection
|
||||
*/
|
||||
public void setSortedColumn(String columnName, SortDirection sortDirection) {
|
||||
xml.setSortColumn(columnName, sortDirection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshal the file.
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws JAXBException
|
||||
*/
|
||||
public SubscriptionManagerConfigXML unmarshall(File file)
|
||||
throws JAXBException {
|
||||
Object obj = unmarshaller.unmarshal(file);
|
||||
if (obj instanceof SubscriptionManagerConfigXML) {
|
||||
return (SubscriptionManagerConfigXML) obj;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the currentConfigFile
|
||||
*/
|
||||
public LocalizationFile getCurrentConfigFile() {
|
||||
return currentConfigFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param currentConfigFile
|
||||
* the currentConfigFile to set
|
||||
*/
|
||||
public void setCurrentConfigFile(LocalizationFile currentConfigFile) {
|
||||
this.currentConfigFile = currentConfigFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the localization file.
|
||||
*
|
||||
* @param file
|
||||
* the file to delete
|
||||
*/
|
||||
public void deleteXml(LocalizationFile file) {
|
||||
try {
|
||||
boolean success = file.delete();
|
||||
if (!success) {
|
||||
statusHandler.handle(Priority.WARN,
|
||||
"Error deleting " + file.getName());
|
||||
}
|
||||
} catch (LocalizationOpFailedException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error deleting " + file.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,6 @@
|
|||
package com.raytheon.uf.viz.datadelivery.subscription;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
|
@ -31,25 +27,15 @@ import org.eclipse.swt.events.SelectionEvent;
|
|||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.datadelivery.common.ui.ITableChange;
|
||||
import com.raytheon.uf.viz.datadelivery.common.ui.LoadSaveConfigDlg;
|
||||
import com.raytheon.uf.viz.datadelivery.common.ui.LoadSaveConfigDlg.DialogType;
|
||||
import com.raytheon.uf.viz.datadelivery.common.xml.ColumnXML;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.xml.SubscriptionManagerConfigXML;
|
||||
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
import com.raytheon.viz.ui.widgets.duallist.DualList;
|
||||
import com.raytheon.viz.ui.widgets.duallist.DualListConfig;
|
||||
|
||||
|
@ -68,6 +54,7 @@ import com.raytheon.viz.ui.widgets.duallist.DualListConfig;
|
|||
* instead. Added configuration file management controls to
|
||||
* this dialog.
|
||||
* Sep 04, 2013 2314 mpduff Load/save config dialog now non-blocking.
|
||||
* Nov 06, 2013 2358 mpduff Removed configuration file management from this dialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -76,11 +63,6 @@ import com.raytheon.viz.ui.widgets.duallist.DualListConfig;
|
|||
*/
|
||||
|
||||
public class SubscriptionManagerConfigDlg extends CaveSWTDialog {
|
||||
|
||||
/** Status Handler */
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(SubscriptionManagerDlg.class);
|
||||
|
||||
/** Callback to SubscriptionManagerDialog */
|
||||
private final ITableChange callback;
|
||||
|
||||
|
@ -90,31 +72,11 @@ public class SubscriptionManagerConfigDlg extends CaveSWTDialog {
|
|||
/** Dual list widget */
|
||||
private DualList dualList;
|
||||
|
||||
/**
|
||||
* Configuration file selection combo.
|
||||
*/
|
||||
private Combo fileCombo;
|
||||
|
||||
/**
|
||||
* Map of context level:file name to LocalizationFile.
|
||||
*/
|
||||
private Map<String, LocalizationFile> configFileMap;
|
||||
|
||||
/**
|
||||
* Configuration manager.
|
||||
*/
|
||||
private final SubscriptionConfigurationManager configManager;
|
||||
|
||||
/**
|
||||
* Delete saved configuration file dialog.
|
||||
*/
|
||||
private LoadSaveConfigDlg deleteDialog;
|
||||
|
||||
/**
|
||||
* Load saved configuration file dialog.
|
||||
*/
|
||||
private LoadSaveConfigDlg loadDlg;
|
||||
|
||||
/**
|
||||
* Initialization Constructor.
|
||||
*
|
||||
|
@ -143,70 +105,10 @@ public class SubscriptionManagerConfigDlg extends CaveSWTDialog {
|
|||
shell.setLayout(gl);
|
||||
shell.setLayoutData(gd);
|
||||
|
||||
createTopControls();
|
||||
createMain();
|
||||
createBottomButtons();
|
||||
}
|
||||
|
||||
private void createTopControls() {
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
GridLayout gl = new GridLayout(2, false);
|
||||
|
||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
gl = new GridLayout(2, false);
|
||||
Composite topComp = new Composite(shell, SWT.NONE);
|
||||
topComp.setLayout(gl);
|
||||
topComp.setLayoutData(gd);
|
||||
|
||||
Composite comp = new Composite(topComp, SWT.NONE);
|
||||
|
||||
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
gl = new GridLayout(4, false);
|
||||
comp.setLayout(gl);
|
||||
comp.setLayoutData(gd);
|
||||
|
||||
Label configurationFileLabel = new Label(comp, SWT.NONE);
|
||||
configurationFileLabel.setText("Configuration:");
|
||||
|
||||
GridData comboData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
fileCombo = new Combo(comp, SWT.READ_ONLY);
|
||||
fileCombo.setLayoutData(comboData);
|
||||
fileCombo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
try {
|
||||
handleConfigSelected();
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
updateFileCombo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the file combo based on the available configurations and currently
|
||||
* selected config.
|
||||
*/
|
||||
private void updateFileCombo() {
|
||||
configFileMap = configManager.getConfigFileNameMap();
|
||||
fileCombo.removeAll();
|
||||
|
||||
int index = 0;
|
||||
for (Entry<String, LocalizationFile> entry : configFileMap.entrySet()) {
|
||||
fileCombo.add(entry.getKey());
|
||||
if (configManager.isCurrentConfig(entry.getValue())) {
|
||||
fileCombo.select(index);
|
||||
}
|
||||
++index;
|
||||
}
|
||||
|
||||
if (fileCombo.getSelectionIndex() < 0 && index > 0) {
|
||||
fileCombo.select(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void createMain() {
|
||||
GridData groupData = new GridData(SWT.CENTER, SWT.CENTER, true, true);
|
||||
GridLayout groupLayout = new GridLayout(1, false);
|
||||
|
@ -291,80 +193,6 @@ public class SubscriptionManagerConfigDlg extends CaveSWTDialog {
|
|||
close();
|
||||
}
|
||||
});
|
||||
|
||||
Button newBtn = new Button(bottomComp, SWT.PUSH);
|
||||
newBtn.setText("New");
|
||||
newBtn.setLayoutData(btnData);
|
||||
newBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
handleNew();
|
||||
}
|
||||
});
|
||||
Button deleteBtn = new Button(bottomComp, SWT.PUSH);
|
||||
deleteBtn.setText("Delete");
|
||||
deleteBtn.setLayoutData(btnData);
|
||||
deleteBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
handleDelete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Open dialog to remove a configuration.
|
||||
*/
|
||||
protected void handleDelete() {
|
||||
if (deleteDialog == null || deleteDialog.isDisposed()) {
|
||||
deleteDialog = new LoadSaveConfigDlg(shell, DialogType.DELETE,
|
||||
configManager.getLocalizationPath(),
|
||||
configManager.getDefaultXMLConfig());
|
||||
deleteDialog.setCloseCallback(new ICloseCallback() {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof LocalizationFile) {
|
||||
LocalizationFile file = (LocalizationFile) returnValue;
|
||||
try {
|
||||
file.delete();
|
||||
} catch (LocalizationOpFailedException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
updateFileCombo();
|
||||
handleApply();
|
||||
}
|
||||
}
|
||||
});
|
||||
deleteDialog.open();
|
||||
} else {
|
||||
deleteDialog.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open dialog for a new configuration.
|
||||
*/
|
||||
protected void handleNew() {
|
||||
if (loadDlg == null || loadDlg.isDisposed()) {
|
||||
loadDlg = new LoadSaveConfigDlg(shell, DialogType.SAVE_AS,
|
||||
configManager.getLocalizationPath(),
|
||||
configManager.getDefaultXMLConfig(), true);
|
||||
loadDlg.setCloseCallback(new ICloseCallback() {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof LocalizationFile) {
|
||||
LocalizationFile file = (LocalizationFile) returnValue;
|
||||
configManager.saveXml(file);
|
||||
handleApply();
|
||||
updateFileCombo();
|
||||
}
|
||||
}
|
||||
});
|
||||
loadDlg.open();
|
||||
} else {
|
||||
loadDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -389,19 +217,4 @@ public class SubscriptionManagerConfigDlg extends CaveSWTDialog {
|
|||
handleApply();
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a selected configuration.
|
||||
*
|
||||
* @throws JAXBException
|
||||
*/
|
||||
private void handleConfigSelected() throws JAXBException {
|
||||
String selectedKey = fileCombo.getItem(fileCombo.getSelectionIndex());
|
||||
LocalizationFile selectedFile = configFileMap.get(selectedKey);
|
||||
|
||||
configManager.setConfigFile(selectedFile);
|
||||
updateDualListSelections();
|
||||
callback.tableChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.datadelivery.subscription;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -28,6 +29,8 @@ import java.util.Set;
|
|||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
@ -57,6 +60,12 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
|||
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
|
||||
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlers;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
|
@ -67,16 +76,20 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
|||
import com.raytheon.uf.viz.datadelivery.actions.DataBrowserAction;
|
||||
import com.raytheon.uf.viz.datadelivery.common.ui.IGroupAction;
|
||||
import com.raytheon.uf.viz.datadelivery.common.ui.ITableChange;
|
||||
import com.raytheon.uf.viz.datadelivery.common.ui.LoadSaveConfigDlg;
|
||||
import com.raytheon.uf.viz.datadelivery.common.ui.LoadSaveConfigDlg.DialogType;
|
||||
import com.raytheon.uf.viz.datadelivery.common.ui.TableCompConfig;
|
||||
import com.raytheon.uf.viz.datadelivery.help.HelpManager;
|
||||
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceApplyPromptDisplayText;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionTableComp.SubscriptionType;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.approve.SubscriptionApprovalDlg;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.xml.SubscriptionManagerConfigXML;
|
||||
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils;
|
||||
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
||||
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
import com.raytheon.viz.ui.presenter.IDisplay;
|
||||
|
||||
/**
|
||||
|
@ -128,6 +141,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
|
|||
* Jul 26, 2013 2232 mpduff Refactored Data Delivery permissions.
|
||||
* Sep 25. 2013 2409 mpduff Add check for widget disposed after calling configuration.
|
||||
* Oct 25, 2013 2292 mpduff Move overlap checks to edex.
|
||||
* Nov 06, 2013 2358 mpduff Resurrected file management code.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -225,6 +239,15 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
/** The office display list */
|
||||
private final SortedSet<String> officeDisplayItems = new TreeSet<String>();
|
||||
|
||||
/** Load config dialog */
|
||||
private LoadSaveConfigDlg loadDlg;
|
||||
|
||||
/** Delete config dialog */
|
||||
private LoadSaveConfigDlg deleteDlg;
|
||||
|
||||
/** SaveAs config dialog */
|
||||
private LoadSaveConfigDlg saveAsDlg;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -242,13 +265,6 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
setText("Data Delivery Subscription Manager");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disposed() {
|
||||
super.disposed();
|
||||
// save any table sort direction changes
|
||||
SubscriptionConfigurationManager.getInstance().saveXml();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -371,6 +387,59 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
|
||||
new MenuItem(fileMenu, SWT.SEPARATOR);
|
||||
|
||||
MenuItem setDefaultMI = new MenuItem(fileMenu, SWT.NONE);
|
||||
setDefaultMI.setText("Set as Default");
|
||||
setDefaultMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
handleSetDefault();
|
||||
}
|
||||
});
|
||||
|
||||
MenuItem loadConfigMI = new MenuItem(fileMenu, SWT.NONE);
|
||||
loadConfigMI.setText("Load Configuration...");
|
||||
loadConfigMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
try {
|
||||
handleLoadConfig();
|
||||
} catch (JAXBException e) {
|
||||
statusHandler
|
||||
.handle(com.raytheon.uf.common.status.UFStatus.Priority.ERROR,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
MenuItem saveConfigMI = new MenuItem(fileMenu, SWT.NONE);
|
||||
saveConfigMI.setText("Save Configuration");
|
||||
saveConfigMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
handleSaveConfig();
|
||||
}
|
||||
});
|
||||
|
||||
MenuItem saveConfigAsMI = new MenuItem(fileMenu, SWT.NONE);
|
||||
saveConfigAsMI.setText("Save Configuration As...");
|
||||
saveConfigAsMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
handleSaveAsConfig();
|
||||
}
|
||||
});
|
||||
|
||||
MenuItem deleteConfigMI = new MenuItem(fileMenu, SWT.NONE);
|
||||
deleteConfigMI.setText("Delete Configuration...");
|
||||
deleteConfigMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleDeleteConfig();
|
||||
}
|
||||
});
|
||||
|
||||
new MenuItem(fileMenu, SWT.SEPARATOR);
|
||||
|
||||
MenuItem exitMI = new MenuItem(fileMenu, SWT.NONE);
|
||||
exitMI.setText("Exit");
|
||||
exitMI.addSelectionListener(new SelectionAdapter() {
|
||||
|
@ -690,6 +759,138 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default configuration file.
|
||||
*/
|
||||
private void handleSetDefault() {
|
||||
SubscriptionConfigurationManager configMan = SubscriptionConfigurationManager
|
||||
.getInstance();
|
||||
|
||||
String fileName = configMan.getDefaultXMLConfig();
|
||||
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext context = pm.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||
|
||||
LocalizationFile locFile = pm.getLocalizationFile(context, fileName);
|
||||
|
||||
try {
|
||||
configMan.setCurrentConfigFile(locFile);
|
||||
configMan.saveXml();
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(
|
||||
com.raytheon.uf.common.status.UFStatus.Priority.ERROR,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load configuration action.
|
||||
*/
|
||||
private void handleLoadConfig() throws JAXBException {
|
||||
if (loadDlg == null || loadDlg.isDisposed()) {
|
||||
final SubscriptionConfigurationManager configMan = SubscriptionConfigurationManager
|
||||
.getInstance();
|
||||
loadDlg = new LoadSaveConfigDlg(shell, DialogType.OPEN,
|
||||
configMan.getLocalizationPath(),
|
||||
configMan.getDefaultXMLConfigFileName(), true);
|
||||
loadDlg.setCloseCallback(new ICloseCallback() {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof LocalizationFile) {
|
||||
try {
|
||||
LocalizationFile fileName = (LocalizationFile) returnValue;
|
||||
// Get the name of the selected file
|
||||
if (fileName != null && fileName.exists()) {
|
||||
File file = fileName.getFile();
|
||||
|
||||
if (file != null) {
|
||||
SubscriptionManagerConfigXML xml = configMan
|
||||
.unmarshall(file);
|
||||
configMan.setXml(xml);
|
||||
configMan.setCurrentConfigFile(fileName);
|
||||
tableChanged();
|
||||
}
|
||||
}
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
loadDlg = null;
|
||||
}
|
||||
});
|
||||
|
||||
loadDlg.open();
|
||||
} else {
|
||||
loadDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save configuration action.
|
||||
*/
|
||||
private void handleSaveConfig() {
|
||||
final SubscriptionConfigurationManager configMan = SubscriptionConfigurationManager
|
||||
.getInstance();
|
||||
if (configMan.getCurrentConfigFile() == null) {
|
||||
handleSaveAsConfig();
|
||||
} else {
|
||||
// configMan.setConfigFile(configMan.getCurrentConfigFile());
|
||||
configMan.saveXml();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save as configuration action.
|
||||
*/
|
||||
private void handleSaveAsConfig() {
|
||||
final SubscriptionConfigurationManager configMan = SubscriptionConfigurationManager
|
||||
.getInstance();
|
||||
if (saveAsDlg == null || saveAsDlg.isDisposed()) {
|
||||
saveAsDlg = new LoadSaveConfigDlg(shell, DialogType.SAVE_AS,
|
||||
configMan.getLocalizationPath(),
|
||||
configMan.getDefaultXMLConfigFileName());
|
||||
saveAsDlg.setCloseCallback(new ICloseCallback() {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof LocalizationFile) {
|
||||
LocalizationFile fileName = (LocalizationFile) returnValue;
|
||||
configMan.setConfigFile(fileName);
|
||||
configMan.saveXml();
|
||||
}
|
||||
}
|
||||
});
|
||||
saveAsDlg.open();
|
||||
} else {
|
||||
saveAsDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete configuration action.
|
||||
*/
|
||||
private void handleDeleteConfig() {
|
||||
final SubscriptionConfigurationManager configMan = SubscriptionConfigurationManager
|
||||
.getInstance();
|
||||
if (deleteDlg == null || deleteDlg.isDisposed()) {
|
||||
deleteDlg = new LoadSaveConfigDlg(shell, DialogType.DELETE,
|
||||
configMan.getLocalizationPath(), true);
|
||||
deleteDlg.setCloseCallback(new ICloseCallback() {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof LocalizationFile) {
|
||||
LocalizationFile fileName = (LocalizationFile) returnValue;
|
||||
configMan.deleteXml(fileName);
|
||||
tableChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
deleteDlg.open();
|
||||
} else {
|
||||
deleteDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the copy action.
|
||||
*/
|
||||
|
@ -850,7 +1051,6 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
try {
|
||||
if (DataDeliveryServices.getPermissionsService()
|
||||
.checkPermission(user, msg, permission).isAuthorized()) {
|
||||
final List<Subscription> updatedList = new ArrayList<Subscription>();
|
||||
|
||||
int count = tableComp.getTable().getSelectionCount();
|
||||
|
||||
|
@ -1143,21 +1343,33 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
return exceptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void activateButtonUpdate(String text) {
|
||||
activateBtn.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void groupSelectionUpdate(String fileName) {
|
||||
// unused
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getGroupNameTxt() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void tableSelection() {
|
||||
// not currently used
|
||||
|
@ -1171,6 +1383,9 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
return DataDeliveryUtils.showYesNoMessage(shell, title, message) == SWT.YES;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void tableLock(boolean isLocked) {
|
||||
// no-op
|
||||
|
|
Loading…
Add table
Reference in a new issue