Show a warning when the user wants to quit and copied an URI before that.
[jSite.git] / src / de / todesbaum / jsite / gui / ProjectPage.java
index 4089364..756c450 100644 (file)
@@ -119,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;
 
@@ -128,6 +131,9 @@ 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.
         *
@@ -318,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);
@@ -401,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() {
@@ -412,10 +427,9 @@ 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;
        }
@@ -462,6 +476,16 @@ 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.
         *
@@ -580,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;
                }
        }
 
@@ -650,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("");
@@ -657,6 +683,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D
                        projectPublicKeyTextField.setText("");
                        projectPrivateKeyTextField.setText("");
                        projectPathTextField.setText("");
+                       projectCompleteUriTextField.setText("");
                }
        }