X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fgui%2FProjectPage.java;h=98ad847d04d9fca07fc91aeff21497881705b430;hb=953de352675a4ad91fe307d816a4ea7780c94274;hp=770828dd2a6d4d6132fb7ef274fb69a26605441b;hpb=8fbc65af048d4ad6f4c05a3e5a609ce6582b0e94;p=jSite.git diff --git a/src/de/todesbaum/jsite/gui/ProjectPage.java b/src/de/todesbaum/jsite/gui/ProjectPage.java index 770828d..98ad847 100644 --- a/src/de/todesbaum/jsite/gui/ProjectPage.java +++ b/src/de/todesbaum/jsite/gui/ProjectPage.java @@ -1,6 +1,5 @@ /* - * jSite - a tool for uploading websites into Freenet - * Copyright (C) 2006 David Roden + * jSite - ProjectPage.java - Copyright © 2006–2012 David Roden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -103,7 +102,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D private JFileChooser pathChooser; /** The project list model. */ - private SortedListModel projectListModel; + private SortedListModel projectListModel; /** The project list scroll pane. */ private JScrollPane projectScrollPane; @@ -158,13 +157,13 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D createActions(); pathChooser = new JFileChooser(); - projectListModel = new SortedListModel(); + projectListModel = new SortedListModel(); projectList = new JList(projectListModel); projectList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); projectList.addListSelectionListener(this); - projectList.setPreferredSize(new Dimension(150, projectList.getPreferredSize().height)); add(projectScrollPane = new JScrollPane(projectList), BorderLayout.LINE_START); + projectScrollPane.setPreferredSize(new Dimension(150, projectList.getPreferredSize().height)); add(createInformationPanel(), BorderLayout.CENTER); } @@ -367,16 +366,30 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D * {@inheritDoc} */ @Override + @SuppressWarnings("synthetic-access") public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException { super.insertString(fb, offset, string.replaceAll("/", ""), attr); + updateCompleteURI(); } /** * {@inheritDoc} */ @Override + @SuppressWarnings("synthetic-access") public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException { super.replace(fb, offset, length, text.replaceAll("/", ""), attrs); + updateCompleteURI(); + } + + /** + * {@inheritDoc} + */ + @Override + @SuppressWarnings("synthetic-access") + public void remove(FilterBypass fb, int offset, int length) throws BadLocationException { + super.remove(fb, offset, length); + updateCompleteURI(); } }); projectPathTextField.setEnabled(false); @@ -427,7 +440,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D * @return The list of projects */ public Project[] getProjects() { - return (Project[]) projectListModel.toArray(new Project[projectListModel.size()]); + return projectListModel.toArray(new Project[projectListModel.size()]); } /** @@ -595,8 +608,14 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D keyDialog.setPublicKey(selectedProject.getRequestURI()); keyDialog.setVisible(true); if (!keyDialog.wasCancelled()) { + String originalPublicKey = selectedProject.getRequestURI(); + String originalPrivateKey = selectedProject.getInsertURI(); selectedProject.setInsertURI(keyDialog.getPrivateKey()); selectedProject.setRequestURI(keyDialog.getPublicKey()); + if (!originalPublicKey.equals(selectedProject.getRequestURI()) || !originalPrivateKey.equals(selectedProject.getInsertURI())) { + selectedProject.setEdition(-1); + } + updateCompleteURI(); } } } @@ -612,6 +631,18 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D if (selectedIndex > -1) { Project selectedProject = (Project) projectList.getSelectedValue(); selectedProject.setEdition(-1); + updateCompleteURI(); + } + } + + /** + * Updates the complete URI text field. + */ + private void updateCompleteURI() { + int selectedIndex = projectList.getSelectedIndex(); + if (selectedIndex > -1) { + Project selectedProject = (Project) projectList.getSelectedValue(); + projectCompleteUriTextField.setText(selectedProject.getFinalRequestURI(0)); } }