X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fgui%2FProjectPage.java;h=756c450ad8cdbbf9a55c7d6bac3a34bfa0973c38;hb=56b5bbc99fc0179022aba3c7a847b71122963801;hp=4e3724fafaee6fd7e32bedb5c829977946ca3177;hpb=49f714c1da2673dd280bcf4c5ef087d88607b3de;p=jSite.git diff --git a/src/de/todesbaum/jsite/gui/ProjectPage.java b/src/de/todesbaum/jsite/gui/ProjectPage.java index 4e3724f..756c450 100644 --- a/src/de/todesbaum/jsite/gui/ProjectPage.java +++ b/src/de/todesbaum/jsite/gui/ProjectPage.java @@ -69,7 +69,7 @@ import de.todesbaum.util.swing.TWizardPage; /** * Wizard page that lets the user manage his projects and start inserts. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ public class ProjectPage extends TWizardPage implements ListSelectionListener, DocumentListener, ClipboardOwner { @@ -95,6 +95,9 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** The “generate key” action. */ private Action projectGenerateKeyAction; + /** The “reset edition” action. */ + private Action projectResetEditionAction; + /** The file chooser. */ private JFileChooser pathChooser; @@ -116,6 +119,9 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** The local path textfield. */ private JTextField projectLocalPathTextField; + /** The textfield for the complete URI. */ + private JTextField projectCompleteUriTextField; + /** The public key textfield. */ private JTextField projectPublicKeyTextField; @@ -125,9 +131,12 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** The project path textfield. */ private JTextField projectPathTextField; + /** Whether the “copy URI to clipboard” action was used. */ + private boolean uriCopied; + /** * Creates a new project page. - * + * * @param wizard * The wizard this page belongs to */ @@ -179,7 +188,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * Adds the given listener to the list of listeners. - * + * * @param listener * The listener to add */ @@ -189,7 +198,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * Removes the given listener from the list of listeners. - * + * * @param listener * The listener to remove */ @@ -266,6 +275,17 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectGenerateKeyAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_G); projectGenerateKeyAction.setEnabled(false); + projectResetEditionAction = new AbstractAction(I18n.getMessage("jsite.project.action.reset-edition")) { + + @SuppressWarnings("synthetic-access") + public void actionPerformed(ActionEvent actionEvent) { + actionResetEdition(); + } + }; + projectResetEditionAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.reset-edition.tooltip")); + projectResetEditionAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_R); + projectResetEditionAction.setEnabled(false); + I18nContainer.getInstance().registerRunnable(new Runnable() { @SuppressWarnings("synthetic-access") @@ -282,6 +302,8 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectCopyURIAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.copy-uri.tooltip")); projectGenerateKeyAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.generate-new-key")); projectGenerateKeyAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.generate-new-key.tooltip")); + projectResetEditionAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.reset-edition")); + projectResetEditionAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.reset-edition.tooltip")); pathChooser.setApproveButtonText(I18n.getMessage("jsite.project.action.browse.choose")); } }); @@ -289,7 +311,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * Creates the information panel. - * + * * @return The information panel */ private JComponent createInformationPanel() { @@ -302,7 +324,6 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D functionButtons.add(new JButton(projectAddAction)); functionButtons.add(new JButton(projectDeleteAction)); functionButtons.add(new JButton(projectCloneAction)); - functionButtons.add(new JButton(projectCopyURIAction)); informationPanel.add(functionButtons, BorderLayout.PAGE_START); informationPanel.add(informationTable, BorderLayout.CENTER); @@ -358,7 +379,8 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D final TLabel projectPrivateKeyLabel = new TLabel(I18n.getMessage("jsite.project.project.private-key") + ":", KeyEvent.VK_R, projectPrivateKeyTextField); informationTable.add(projectPrivateKeyLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0)); - informationTable.add(projectPrivateKeyTextField, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); + informationTable.add(projectPrivateKeyTextField, new GridBagConstraints(1, 6, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); + informationTable.add(new JButton(projectResetEditionAction), new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); projectPathTextField = new JTextField(); projectPathTextField.getDocument().putProperty("name", "project.path"); @@ -384,6 +406,16 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectPathTextField.setEnabled(false); final TLabel projectPathLabel = new TLabel(I18n.getMessage("jsite.project.project.path") + ":", KeyEvent.VK_P, projectPathTextField); + informationTable.add(projectPathLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0)); + informationTable.add(projectPathTextField, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); + + projectCompleteUriTextField = new JTextField(); + projectCompleteUriTextField.setEditable(false); + final TLabel projectUriLabel = new TLabel(I18n.getMessage("jsite.project.project.uri") + ":", KeyEvent.VK_U, projectCompleteUriTextField); + informationTable.add(projectUriLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0)); + informationTable.add(projectCompleteUriTextField, new GridBagConstraints(1, 8, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); + informationTable.add(new JButton(projectCopyURIAction), new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); + I18nContainer.getInstance().registerRunnable(new Runnable() { public void run() { @@ -395,17 +427,16 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectPublicKeyLabel.setText(I18n.getMessage("jsite.project.project.public-key") + ":"); projectPrivateKeyLabel.setText(I18n.getMessage("jsite.project.project.private-key") + ":"); projectPathLabel.setText(I18n.getMessage("jsite.project.project.path") + ":"); + projectUriLabel.setText(I18n.getMessage("jsite.project.project.uri") + ":"); } }); - informationTable.add(projectPathLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0)); - informationTable.add(projectPathTextField, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); return informationPanel; } /** * Sets the project list. - * + * * @param projects * The list of projects */ @@ -418,7 +449,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * Returns the list of projects. - * + * * @return The list of projects */ public Project[] getProjects() { @@ -427,7 +458,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * Sets the freenet interface to use. - * + * * @param freenetInterface * The freenetInterface to use */ @@ -437,7 +468,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D /** * Returns the currently selected project. - * + * * @return The currently selected project */ public Project getSelectedProject() { @@ -445,9 +476,19 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D } /** + * Returns whether the “copy URI to clipboard” button was used. + * + * @return {@code true} if the “copy URI to clipboard” button was used, + * {@code false} otherwise + */ + public boolean wasUriCopied() { + return uriCopied; + } + + /** * Updates the currently selected project with changed information from a * textfield. - * + * * @param documentEvent * The document event to process */ @@ -563,6 +604,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D Project selectedProject = (Project) projectList.getSelectedValue(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(selectedProject.getFinalRequestURI(0)), this); + uriCopied = true; } } @@ -590,6 +632,20 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D } } + /** + * Resets the edition of the currently selected project. + */ + private void actionResetEdition() { + if (JOptionPane.showConfirmDialog(this, I18n.getMessage("jsite.project.warning.reset-edition"), null, JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) { + return; + } + int selectedIndex = projectList.getSelectedIndex(); + if (selectedIndex > -1) { + Project selectedProject = (Project) projectList.getSelectedValue(); + selectedProject.setEdition(-1); + } + } + // // INTERFACE ListSelectionListener // @@ -611,6 +667,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectCloneAction.setEnabled(selectedRow > -1); projectCopyURIAction.setEnabled(selectedRow > -1); projectGenerateKeyAction.setEnabled(selectedRow > -1); + projectResetEditionAction.setEnabled(selectedRow > -1); if (selectedRow > -1) { projectNameTextField.setText(selectedProject.getName()); projectDescriptionTextField.setText(selectedProject.getDescription()); @@ -618,6 +675,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectPublicKeyTextField.setText(selectedProject.getRequestURI()); projectPrivateKeyTextField.setText(selectedProject.getInsertURI()); projectPathTextField.setText(selectedProject.getPath()); + projectCompleteUriTextField.setText("freenet:" + selectedProject.getFinalRequestURI(0)); } else { projectNameTextField.setText(""); projectDescriptionTextField.setText(""); @@ -625,6 +683,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectPublicKeyTextField.setText(""); projectPrivateKeyTextField.setText(""); projectPathTextField.setText(""); + projectCompleteUriTextField.setText(""); } }