@Override
	public void valueChanged(TreeSelectionEvent event) {
		if (Main.debug3) {
			System.out.println("event: " + event.toString() + " tree: "
					+ tree.toString() + " rightPanel: " + rightPanel.toString()
					+ " model.tree: " + model.toString());
		}
		Element selectedElement = (Element) tree.getLastSelectedPathComponent();
		if (selectedElement == null) {
			return;
		}
		Element editor = Main.getEditor();
		if (editor == null) {
			System.err
					.println("null editor in EditingSelectionListener.valueChanged");
		} else {
			String previousTreePath = Main.getEditor().getAttributeValue(
					"adminTreePath");
			String currentTreePath = Util.getXPath(selectedElement);
			if (!currentTreePath.equals(previousTreePath)) {
				Main.setEditorSetting("adminTreePath", currentTreePath);
			}
		}

		String tagName = selectedElement.getName();
		if (tagName.equals("EDITORS")) {
			rightPanel.removeAll();
			rightPanel.repaint();
			rightPanel.add(new PermissionsPane(selectedElement));
			Main.repack();
		} else if (tagName.equals("RESERVEDNUMBERS")) {
			rightPanel.removeAll();
			rightPanel.repaint();
			rightPanel.add(new ReservedNumbersPane(selectedElement));
			Main.repack();
		} else if (tagName.equals("QUERIES")) {
			rightPanel.removeAll();
			rightPanel.repaint();
			rightPanel.add(new QueriesManagementPane(selectedElement));
			Main.repack();
		} else if (tagName.equals("CATALOG")) {
			rightPanel.removeAll();
			rightPanel.repaint();
			rightPanel.add(new CatalogSettingsPane(selectedElement));
			Main.repack();
		} else if (tagName.equals("PROGRAM")) {
			rightPanel.removeAll();
			rightPanel.repaint();
			rightPanel.add(new AddRemoveCoursePane(selectedElement));
			Main.repack();
		} else {
			return;
		}
	}