/** * Load in the {@link ucar.unidata.idv.ui.ParamInfo}-s defined in the xml from the given root * Element. Create a new JTable and add it into the GUI. * * @param root The xml root * @param i Which resource is this */ private void addList(Element root, int i) { List infos; boolean isWritable = resources.isWritableResource(i); if (root != null) { infos = createParamInfoList(root); } else { if (!isWritable) { return; } infos = new ArrayList(); } if (infos.size() == 0) { // infos.add(new ParamInfo("", null, null, null, null)); } ParamDefaultsTable table = new ParamDefaultsTable(infos, isWritable); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); String editableStr = ""; if (!isWritable) { editableStr = " (" + Msg.msg("non-editable") + ") "; } JLabel label = new JLabel( "<html>" + Msg.msg("Path: ${param1}", resources.get(i) + editableStr) + "</html>"); JPanel tablePanel = GuiUtils.topCenter(GuiUtils.inset(label, 4), new JScrollPane(table)); table.label = resources.getShortName(i); tableTabbedPane.add(resources.getShortName(i), tablePanel); myTables.add(table); }
/** Intialize me */ private void init() { myTables = new ArrayList(); tableTabbedPane = new JTabbedPane(); tableTabbedPane.setPreferredSize(new Dimension(450, 200)); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); fileMenu.add(GuiUtils.makeMenuItem("New Row", this, "addNewRow")); fileMenu.addSeparator(); fileMenu.add(GuiUtils.makeMenuItem("Open", this, "doOpen")); fileMenu.add(GuiUtils.makeMenuItem("Import", this, "doImport")); fileMenu.addSeparator(); fileMenu.add(GuiUtils.makeMenuItem("Export to File", this, "doSaveAs")); fileMenu.add(GuiUtils.makeMenuItem("Export to Plugin", this, "exportToPlugin")); fileMenu.add( GuiUtils.makeMenuItem("Export Selected to Plugin", this, "exportSelectedToPlugin")); fileMenu.addSeparator(); fileMenu.add(GuiUtils.makeMenuItem("Close", this, "doClose")); JMenu helpMenu = new JMenu("Help"); menuBar.add(helpMenu); helpMenu.add(GuiUtils.makeMenuItem("Parameter Defaults Help", this, "showHelp")); JComponent bottom = GuiUtils.wrap(GuiUtils.makeButton("Close", this, "doClose")); contents = GuiUtils.topCenterBottom(menuBar, GuiUtils.inset(tableTabbedPane, 2), bottom); setMenuBar(menuBar); loadResources(resources); }
/** * Copy the given ParamInfo object into the user's editable table * * @param i the param fino object to copy */ protected void copyToUsers(ParamInfo i) { ParamInfo copy = new ParamInfo(i); ParamDefaultsTable to = (ParamDefaultsTable) myTables.get(0); to.add(copy); tableTabbedPane.setSelectedIndex(0); to.editRow(copy, true); }
/** * Return the ParamDefaultsTable which is currently being shown in the tabbed pane * * @return The current ParamDefaultsTable */ public ParamDefaultsTable getCurrentTable() { int index = tableTabbedPane.getSelectedIndex(); return (ParamDefaultsTable) myTables.get(index); }