/** Import an xml param defaults file */ public void doImport() { try { String filename = FileManager.getReadFile(FileManager.FILTER_XML); if (filename == null) { return; } Element root = XmlUtil.getRoot(IOUtil.readContents(filename)); if (root == null) { return; } List infos = createParamInfoList(root); ParamDefaultsTable table = getCurrentTable(); table.getParamInfoList().addAll(infos); table.tableChanged(); saveData(); } catch (Exception exc) { LogUtil.printException(log_, "Error importing file", exc); } }
/** * Get the color table, range, etc, from the given display control and save them as the param * defaults for its data choice * * @param displayControl the display control to get state from */ public void saveDefaults(DisplayControlImpl displayControl) { try { List choices = displayControl.getMyDataChoices(); if (choices.size() != 1) { return; } DataChoice dc = (DataChoice) choices.get(0); String name = dc.getName(); String ctName = ((displayControl.getColorTable() != null) ? displayControl.getColorTable().getName() : null); ParamInfo newParamInfo = new ParamInfo( name, ctName, displayControl.getRange(), displayControl.getContourInfo(), displayControl.getDisplayUnit()); ParamDefaultsTable firstTable = getFirstTable(); if (!firstTable.editRow(newParamInfo, false)) { return; } ParamInfo origParamInfo = firstTable.findByName(dc.getName()); if (origParamInfo == null) { firstTable.addBeginning(newParamInfo); firstTable.getSelectionModel().setSelectionInterval(0, 0); } else { origParamInfo.initWith(newParamInfo); firstTable.tableChanged(); firstTable.selectParamInfo(origParamInfo); } saveData(); show(); GuiUtils.showComponentInTabs(firstTable); } catch (Exception exc) { LogUtil.printException(log_, "copying defaults", exc); } }