public DeleteRoutes(UndoCatalogModel catalogModel, List<RouteModel> routes) { this.catalogModel = catalogModel; this.routes = routes; for (RouteModel route : routes) { categories.add(route.getCategory()); descriptions.add(route.getDescription() != null ? route.getDescription() : route.getName()); try { files.add(route.getRoute().getUrl()); } catch (IOException e) { files.add(null); } urls.add(route.getRoute().getHref()); } }
public static String formatUrl(RouteModel route) { String url = route.getUrl(); url = url.replaceAll("file:/", ""); try { url = decodeUri(url); } catch (IllegalArgumentException e) { // intentionally left empty } return url; } }
public int hashCode() { return Objects.hash(getCategory(), getRoute()); } }
public String getName() { try { return getRoute().getName(); } catch (Exception e) { log.severe("Cannot get name: " + e); return "?"; } }
public static List<CategoryTreeNode> asParentsFromRoutes(List<RouteModel> routes) { List<CategoryTreeNode> parents = new ArrayList<>(routes.size()); for (RouteModel routeModel : routes) { parents.add(routeModel.getCategory()); } return parents; }
public void addRoute(final CategoryTreeNode category, final String description, final File file, final String url, final AddRouteCallback callback) { operator.executeOperation(new RouteServiceOperator.Operation() { public String getName() { return "AddRoute"; } public void run() throws IOException { Route route = file != null ? category.getCategory().createRoute(description, file) : category.getCategory().createRoute(description, url); final RouteModel routeModel = new RouteModel(category, route); callback.setRoute(routeModel); invokeLater(new Runnable() { public void run() { routesTableModel.addRoute(routeModel); } }); } }); }
public static String formatName(RouteModel route) { String name = route.getName(); if (name == null) name = RouteConverter.getBundle().getString("no-name"); return name; }
public void run() { List<RouteModel> routes = getSelectedRouteModels(table); if (routes.size() == 0) return; for (final RouteModel route : routes) { String name = (String) showInputDialog(WindowHelper.getFrame(), format(getBundle().getString("rename-route-label"), formatName(route)), WindowHelper.getFrame().getTitle(), QUESTION_MESSAGE, null, null, route.getDescription()); if (trim(name) == null) return; catalogModel.renameRoute(route, name, new Runnable() { public void run() { final int row = ((RoutesTableModel) table.getModel()).getIndex(route); scrollToPosition(table, row); selectRoute(table, route); } }); } } }
public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; RouteModel that = (RouteModel) o; return Objects.equals(getCategory(), that.getCategory()) && Objects.equals(getRoute(), that.getRoute()); }
public String getDescription() { try { return getRoute().getDescription(); } catch (Exception e) { log.severe("Cannot get description: " + e); return "?"; } }
public void setCurrentCategory(CategoryTreeNode category) { List<Route> routes = category.getRoutes(); List<RouteModel> routeModels = new ArrayList<>(); if (routes != null) { Route[] routesArray = routes.toArray(new Route[0]); sort(routesArray, routeComparator); for (Route route : routesArray) routeModels.add(new RouteModel(category, route)); } getRoutesTableModel().setRoutes(routeModels); }
void renameRoute(RouteModel route, String newName, Runnable invokeLaterRunnable, boolean trackUndo) { String oldName = route.getName(); delegate.renameRoute(route, newName, invokeLaterRunnable); if (trackUndo) undoManager.addEdit(new RenameRoute(this, route, oldName, newName)); }
public void run() throws IOException { for (int i = 0; i < routes.size(); i++) { RouteModel route = routes.get(i); CategoryTreeNode parent = parents.get(i); CategoryTreeNode category = route.getCategory(); if (category.isLocal() && parent.isRemote()) throw new IOException("cannot move local route " + route.getName() + " to remote parent " + parent.getName()); if (category.isRemote() && parent.isLocal()) throw new IOException("cannot move remote route " + route.getName() + " to local parent " + parent.getName()); route.getRoute().update(parent.getCategory(), route.getDescription() != null ? route.getDescription() : route.getName()); } invokeLater(new Runnable() { public void run() { for (CategoryTreeNode parent : parents) { setCurrentCategory(parent); } if (invokeLaterRunnable != null) invokeLaterRunnable.run(); } }); } });
public void run() throws IOException { route.getRoute().update(route.getCategory().getCategory(), name); invokeLater(new Runnable() { public void run() { routesTableModel.updateRoute(route); if (invokeLaterRunnable != null) invokeLaterRunnable.run(); } }); } });
public void run() throws IOException { for (final RouteModel route : routes) { route.getRoute().delete(); invokeLater(new Runnable() { public void run() { routesTableModel.deleteRoute(route); } }); } } });
public void run() throws IOException { Route route = file != null ? category.getCategory().createRoute(description, file) : category.getCategory().createRoute(description, url); final RouteModel routeModel = new RouteModel(category, route); callback.setRoute(routeModel); invokeLater(new Runnable() { public void run() { routesTableModel.addRoute(routeModel); } }); } });
public String getUrl() { try { return getRoute().getUrl(); } catch (Exception e) { log.severe("Cannot get URL: " + e); return "?"; } }
public static void selectRoute(JTable table, RouteModel route) { // search for RouteModel with same Route (Category might be different due to move) RoutesTableModel model = (RoutesTableModel) table.getModel(); for(int i = 0; i < model.getRowCount(); i++) { if(model.getRoute(i).getRoute().equals(route.getRoute())) { scrollToPosition(table, i); table.getSelectionModel().addSelectionInterval(i, i); break; } } }
public static String formatCreator(RouteModel route) { String creator; try { creator = route.getRoute().getCreator(); if (creator == null) creator = RouteConverter.getBundle().getString("no-creator"); } catch (Exception e) { creator = RouteConverter.getBundle().getString("loading"); } return creator; }
public static String formatDescription(RouteModel route) { String description = ""; try { description = route.getRoute().getDescription(); if(description == null) formatName(route); } catch (Exception e) { // intentionally left empty } return description; }