public String getRepositoryLocation() throws MalformedRepositoryLocationException { if (tree.getSelectionPath() != null) { Entry selectedEntry = (Entry) tree.getSelectionPath().getLastPathComponent(); RepositoryLocation selectedLocation = selectedEntry.getLocation(); if (selectedEntry instanceof Folder) { if (enforceValidRepositoryEntryName) { selectedLocation = new RepositoryLocation(selectedLocation, locationFieldRepositoryEntry.getText()); } else { selectedLocation = new RepositoryLocation(selectedLocation, locationField.getText()); } } if (RepositoryLocationChooser.this.resolveRelativeTo != null && resolveBox.isSelected()) { return selectedLocation.makeRelative(RepositoryLocationChooser.this.resolveRelativeTo); } else { return selectedLocation.getAbsoluteLocation(); } } else { if (enforceValidRepositoryEntryName) { return locationFieldRepositoryEntry.getText(); } else { return locationField.getText(); } } }
public void restoreExpansionState(JTree tree) { for (int i = 0; i < tree.getRowCount(); i++) { TreePath path = tree.getPathForRow(i); Object entryObject = path.getLastPathComponent(); if (entryObject instanceof Entry) { Entry entry = (Entry) entryObject; String absoluteLocation = entry.getLocation().getAbsoluteLocation(); if (expandedRepositories.contains(absoluteLocation) || expandedNodes.contains(absoluteLocation)) { tree.expandPath(path); } } } restoreSelectionPath(tree); }
public void saveExpansionState(JTree tree) { expandedNodes = new HashSet<String>(); expandedRepositories = new HashSet<String>(); saveSelectionPath(tree.getSelectionPath()); for (int i = 0; i < tree.getRowCount(); i++) { TreePath path = tree.getPathForRow(i); if (tree.isExpanded(path)) { Entry entry = (Entry) path.getLastPathComponent(); String absoluteLocation = entry.getLocation().getAbsoluteLocation(); if (entry instanceof Repository) { expandedRepositories.add(absoluteLocation); } else { expandedNodes.add(absoluteLocation); } } } }