X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FProjectPanel.java;h=c3b9a7803671482d35c75feba341b2c51cdd4c98;hb=f90ad0c003cda73146628ac6d4e9d1cfa8164d85;hp=d0fb1af2ba875aeebe208639343f8aef4d1205fd;hpb=80e93840dac03f7775bdf3053e04639e45cfcf91;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/gui/ProjectPanel.java b/src/net/pterodactylus/jsite/gui/ProjectPanel.java index d0fb1af..c3b9a78 100644 --- a/src/net/pterodactylus/jsite/gui/ProjectPanel.java +++ b/src/net/pterodactylus/jsite/gui/ProjectPanel.java @@ -25,20 +25,26 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; +import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.AbstractAction; +import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.Document; +import net.pterodactylus.jsite.core.Project; +import net.pterodactylus.jsite.i18n.I18n; import net.pterodactylus.jsite.i18n.I18nable; import net.pterodactylus.jsite.i18n.gui.I18nAction; import net.pterodactylus.jsite.i18n.gui.I18nLabel; -import net.pterodactylus.jsite.project.Project; import net.pterodactylus.util.logging.Logging; /** @@ -46,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 { @@ -63,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; @@ -81,6 +89,15 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable { /** The “base path” textfield. */ private JTextField basePathTextField; + /** The “node” label. */ + private I18nLabel nodeLabel; + + /** The “node” action. */ + private Action nodeAction; + + /** The “node” combo box. */ + private JComboBox nodeComboBox; + /** * Creates a new project panel. * @@ -91,6 +108,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(); @@ -128,6 +146,25 @@ 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(); + } + }; + nodeAction = new AbstractAction() { + + /** + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent actionEvent) { + /* TODO */ + } + }; } /** @@ -155,23 +192,31 @@ 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, 12, 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(descriptionLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 0, 0, 0), 0, 0)); + propertiesPanel.add(descriptionTextField, new GridBagConstraints(1, 1, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0)); basePathTextField = new JTextField(project.getBasePath()); basePathTextField.setEditable(false); basePathLabel = new I18nLabel("projectPanel.label.basePath"); JButton changeBasePathButton = new JButton(changeBasePathAction); - 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)); + 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(12, 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(12, 12, 0, 0), 0, 0)); + propertiesPanel.add(changeBasePathButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0)); + propertiesPanel.add(editFilesButton, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0)); - propertiesPanel.add(new JPanel(), new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + nodeComboBox = new JComboBox(); + nodeComboBox.addActionListener(nodeAction); + nodeLabel = new I18nLabel("projectPanel.label.node", nodeComboBox); + propertiesPanel.add(nodeLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 0, 0, 0), 0, 0)); + propertiesPanel.add(nodeComboBox, new GridBagConstraints(1, 3, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 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; } @@ -185,8 +230,8 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable { JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 12, 12)); buttonPanel.setBorder(BorderFactory.createEmptyBorder(-12, -12, -12, -12)); - buttonPanel.add(new JButton(swingInterface.getDeleteProjectAction())); - buttonPanel.add(new JButton(swingInterface.getCloneProjectAction())); + buttonPanel.add(new JButton(swingInterface.getDeleteProjectAction(project))); + buttonPanel.add(new JButton(swingInterface.getCloneProjectAction(project))); return buttonPanel; } @@ -212,8 +257,25 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable { /** * Lets the user select a new base path and repopulates the file list. */ - private void changeBasePath() { - /* TODO - edit base path */ + void changeBasePath() { + JFileChooser fileChooser = new JFileChooser(project.getBasePath()); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fileChooser.setApproveButtonText(I18n.get("projectPanel.button.approve.name")); + int chooseAction = fileChooser.showOpenDialog(this); + if (chooseAction == JFileChooser.APPROVE_OPTION) { + String newBasePath = fileChooser.getSelectedFile().getPath(); + basePathTextField.setText(newBasePath); + project.setBasePath(newBasePath); + } + } + + /** + * 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, project); + fileManager.setVisible(true); } // @@ -226,6 +288,9 @@ public class ProjectPanel extends JPanel implements DocumentListener, I18nable { public void updateI18n() { nameLabel.updateI18n(); descriptionLabel.updateI18n(); + basePathLabel.updateI18n(); + changeBasePathAction.updateI18n(); + editFilesAction.updateI18n(); } //