X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fgui%2FProjectPage.java;h=c319e94947a3298372413bcae146eba6ab9658e8;hb=8bc7a8f2372639a9fbeea34f9cbee9697f34ba3f;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..c319e94 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; @@ -144,6 +143,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D I18nContainer.getInstance().registerRunnable(new Runnable() { + @Override public void run() { setHeading(I18n.getMessage("jsite.project.heading")); setDescription(I18n.getMessage("jsite.project.description")); @@ -158,13 +158,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); } @@ -207,6 +207,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D private void createActions() { projectLocalPathBrowseAction = new AbstractAction(I18n.getMessage("jsite.project.action.browse")) { + @Override @SuppressWarnings("synthetic-access") public void actionPerformed(ActionEvent actionEvent) { actionLocalPathBrowse(); @@ -218,6 +219,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectAddAction = new AbstractAction(I18n.getMessage("jsite.project.action.add-project")) { + @Override @SuppressWarnings("synthetic-access") public void actionPerformed(ActionEvent actionEvent) { actionAdd(); @@ -228,6 +230,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectDeleteAction = new AbstractAction(I18n.getMessage("jsite.project.action.delete-project")) { + @Override @SuppressWarnings("synthetic-access") public void actionPerformed(ActionEvent actionEvent) { actionDelete(); @@ -239,6 +242,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectCloneAction = new AbstractAction(I18n.getMessage("jsite.project.action.clone-project")) { + @Override @SuppressWarnings("synthetic-access") public void actionPerformed(ActionEvent actionEvent) { actionClone(); @@ -250,6 +254,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectCopyURIAction = new AbstractAction(I18n.getMessage("jsite.project.action.copy-uri")) { + @Override @SuppressWarnings("synthetic-access") public void actionPerformed(ActionEvent actionEvent) { actionCopyURI(); @@ -261,6 +266,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectManageKeysAction = new AbstractAction(I18n.getMessage("jsite.project.action.manage-keys")) { + @Override @SuppressWarnings("synthetic-access") public void actionPerformed(ActionEvent actionEvent) { actionManageKeys(); @@ -272,6 +278,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectResetEditionAction = new AbstractAction(I18n.getMessage("jsite.project.action.reset-edition")) { + @Override @SuppressWarnings("synthetic-access") public void actionPerformed(ActionEvent actionEvent) { actionResetEdition(); @@ -283,6 +290,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D I18nContainer.getInstance().registerRunnable(new Runnable() { + @Override @SuppressWarnings("synthetic-access") public void run() { projectLocalPathBrowseAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.browse")); @@ -367,16 +375,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); @@ -394,6 +416,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D I18nContainer.getInstance().registerRunnable(new Runnable() { + @Override public void run() { projectInformationLabel.setText("" + I18n.getMessage("jsite.project.project.information") + ""); projectNameLabel.setText(I18n.getMessage("jsite.project.project.name") + ":"); @@ -427,7 +450,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 +618,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 +641,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)); } } @@ -622,6 +663,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * {@inheritDoc} */ + @Override public void valueChanged(ListSelectionEvent listSelectionEvent) { int selectedRow = projectList.getSelectedIndex(); Project selectedProject = (Project) projectList.getSelectedValue(); @@ -661,6 +703,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * {@inheritDoc} */ + @Override public void insertUpdate(DocumentEvent documentEvent) { setTextField(documentEvent); } @@ -668,6 +711,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * {@inheritDoc} */ + @Override public void removeUpdate(DocumentEvent documentEvent) { setTextField(documentEvent); } @@ -675,6 +719,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * {@inheritDoc} */ + @Override public void changedUpdate(DocumentEvent documentEvent) { setTextField(documentEvent); } @@ -686,6 +731,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * {@inheritDoc} */ + @Override public void lostOwnership(Clipboard clipboard, Transferable contents) { /* ignore. */ }