update actions when language changes
[jSite2.git] / src / net / pterodactylus / jsite / gui / ProjectPanel.java
index 03f91cc..e15b257 100644 (file)
@@ -26,6 +26,7 @@ import java.awt.GridBagLayout;
 import java.awt.Insets;
 import java.awt.event.ActionEvent;
 import java.util.List;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.swing.BorderFactory;
@@ -51,7 +52,6 @@ import net.pterodactylus.util.logging.Logging;
  * the properties of the project.
  * 
  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
- * @version $Id$
  */
 public class ProjectPanel extends JPanel implements DocumentListener, I18nable {
 
@@ -68,6 +68,9 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable {
        /** The “change base path” action. */
        private I18nAction changeBasePathAction;
 
+       /** The “edit files” action. */
+       private I18nAction editFilesAction;
+
        /** The “name” label. */
        private I18nLabel nameLabel;
 
@@ -99,6 +102,7 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable {
         */
        public ProjectPanel(SwingInterface swingInterface, Project project) {
                super(new BorderLayout(12, 12));
+               logger.log(Level.FINEST, "project: " + project);
                this.swingInterface = swingInterface;
                this.project = project;
                initActions();
@@ -136,6 +140,16 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable {
                                changeBasePath();
                        }
                };
+               editFilesAction = new I18nAction("projectPanel.button.editFiles") {
+
+                       /**
+                        * {@inheritDoc}
+                        */
+                       @SuppressWarnings("synthetic-access")
+                       public void actionPerformed(ActionEvent actionEvent) {
+                               editFiles();
+                       }
+               };
        }
 
        /**
@@ -163,25 +177,27 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable {
                nameTextField.getDocument().addDocumentListener(this);
                nameLabel = new I18nLabel("projectPanel.label.name", nameTextField);
                propertiesPanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
-               propertiesPanel.add(nameTextField, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 6, 0, 0), 0, 0));
+               propertiesPanel.add(nameTextField, new GridBagConstraints(1, 0, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 6, 0, 0), 0, 0));
 
                descriptionTextField = new JTextField(project.getDescription());
                descriptionTextField.getDocument().addDocumentListener(this);
                descriptionLabel = new I18nLabel("projectPanel.label.description", descriptionTextField);
                propertiesPanel.add(descriptionLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 0, 0, 0), 0, 0));
-               propertiesPanel.add(descriptionTextField, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
+               propertiesPanel.add(descriptionTextField, new GridBagConstraints(1, 1, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
 
                basePathTextField = new JTextField(project.getBasePath());
                basePathTextField.setEditable(false);
                basePathLabel = new I18nLabel("projectPanel.label.basePath");
-               basePathInformationLabel = new JLabel("");
+               basePathInformationLabel = new JLabel(I18n.get("projectPanel.basePathInformation.fileCount", project.getBasePathEntries().size()));
                JButton changeBasePathButton = new JButton(changeBasePathAction);
+               JButton editFilesButton = new JButton(editFilesAction);
                propertiesPanel.add(basePathLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 0, 0, 0), 0, 0));
                propertiesPanel.add(basePathTextField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
                propertiesPanel.add(changeBasePathButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
-               propertiesPanel.add(basePathInformationLabel, new GridBagConstraints(1, 3, 2, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 6, 0, 0), 0, 0));
+               propertiesPanel.add(editFilesButton, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
+               propertiesPanel.add(basePathInformationLabel, new GridBagConstraints(1, 3, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
 
-               propertiesPanel.add(new JPanel(), new GridBagConstraints(0, 4, 3, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
+               propertiesPanel.add(new JPanel(), new GridBagConstraints(0, 4, 4, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
 
                return propertiesPanel;
        }
@@ -232,6 +248,7 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable {
                        basePathTextField.setText(newBasePath);
                        basePathInformationLabel.setText(I18n.get("projectPanel.basePathInformation.scanning"));
                        project.setBasePath(newBasePath);
+                       changeBasePathAction.setEnabled(false);
                        swingInterface.getThreadPool().execute(new Runnable() {
 
                                /**
@@ -242,11 +259,21 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable {
                                        project.rescanBasePath();
                                        List<Entry> projectEntries = project.getBasePathEntries();
                                        basePathInformationLabel.setText(I18n.get("projectPanel.basePathInformation.fileCount", projectEntries.size()));
+                                       changeBasePathAction.setEnabled(true);
                                }
                        });
                }
        }
 
+       /**
+        * Pops up the file manager and lets the user edit the parameters for the
+        * physical and virtual files.
+        */
+       private void editFiles() {
+               FileManager fileManager = new FileManager(swingInterface.getMainWindow(), project);
+               fileManager.setVisible(true);
+       }
+
        //
        // INTERFACE I18nable
        //
@@ -257,6 +284,8 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable {
        public void updateI18n() {
                nameLabel.updateI18n();
                descriptionLabel.updateI18n();
+               changeBasePathAction.updateI18n();
+               editFilesAction.updateI18n();
        }
 
        //