/** * Respond to selections within the left list. * * @throws InvocationTargetException * @throws InterruptedException */ private void respondToListClick() { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); enableOrDisableActions(); int idx = archetypeList.getSelectedIndex(); if (idx == -1 || idx >= listData.size()) { // no selection if (archetypeControl == null) { return; } archetypeControl.removeNameChangeListener(this); rightPanel.removeAll(); archetypeControl = null; rightPanel.add(selectLeftLabel); rightPanel.repaint(); return; } if (archetypeControl == null) { archetypeControl = new ArchetypeControl(listData.get(idx)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); rightPanel.removeAll(); rightPanel.add(archetypeControl, BorderLayout.CENTER); rightPanel.repaint(); rightPanel.revalidate(); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); archetypeControl.addNameChangeListener(this); } else { archetypeControl.setArchetype(listData.get(idx)); archetypeControl.repaint(); } this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
/** Revert the list back to its saved state. */ protected void revertList() { int ret = JOptionPane.showConfirmDialog( this, "Revert list losing unsaved changes?", "Confirm", JOptionPane.OK_CANCEL_OPTION); if (ret == JOptionPane.CANCEL_OPTION) { return; } archetypeControl.removeNameChangeListener(this); rightPanel.removeAll(); archetypeControl = null; rightPanel.add(selectLeftLabel); rightPanel.repaint(); listData.clear(); listData.addAll(ArchetypesManager.getArchetypes()); }