package net.pterodactylus.jsite.gui;
import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import net.pterodactylus.jsite.i18n.I18n;
import net.pterodactylus.jsite.i18n.I18nable;
+import net.pterodactylus.jsite.i18n.gui.I18nAction;
import net.pterodactylus.jsite.project.Entry;
import net.pterodactylus.jsite.project.Project;
import net.pterodactylus.util.data.Node;
/** The tree model for the project files. */
private final FileTreeModel fileTreeModel;
+ /** The “close” action. */
+ private I18nAction closeAction;
+
/** The tree that shows the files. */
private JTree fileTree;
logger.log(Level.FINEST, "project: " + project);
this.project = project;
fileTreeModel = new FileTreeModel();
+ initActions();
initComponents();
SwingUtils.repackCentered(this);
}
//
- // PRIVATE ACTIONS
+ // PRIVATE METHODS
//
/**
+ * Initializes all actions.
+ */
+ private void initActions() {
+ closeAction = new I18nAction("fileManager.button.close") {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void actionPerformed(ActionEvent e) {
+ setVisible(false);
+ }
+ };
+ }
+
+ /**
* Initializes all components.
*/
private void initComponents() {
JPanel contentPanel = new JPanel(new BorderLayout(12, 12));
+ contentPanel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
+
+ contentPanel.add(createFileManagerPanel(), BorderLayout.CENTER);
+ contentPanel.add(createButtonPanel(), BorderLayout.PAGE_END);
+
+ setContentPane(contentPanel);
+ }
+
+ /**
+ * Creates the main panel with the file tree and the file properties.
+ *
+ * @return The mail panel
+ */
+ private Component createFileManagerPanel() {
+ JPanel fileManagerPanel = new JPanel(new BorderLayout(12, 12));
+ fileManagerPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(12, 12, 12, 12)));
fileTree = new JTree(fileTreeModel);
fileTree.setShowsRootHandles(false);
- contentPanel.add(new JScrollPane(fileTree), BorderLayout.CENTER);
+ fileManagerPanel.add(new JScrollPane(fileTree), BorderLayout.CENTER);
- setContentPane(contentPanel);
+ return fileManagerPanel;
+ }
+
+ /**
+ * Creates the button panel.
+ *
+ * @return The button panel
+ */
+ private Component createButtonPanel() {
+ JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 12, 12));
+
+ buttonPanel.setBorder(BorderFactory.createEmptyBorder(-12, -12, -12, -12));
+ JButton closeButton = new JButton(closeAction);
+ buttonPanel.add(closeButton);
+
+ getRootPane().setDefaultButton(closeButton);
+ return buttonPanel;
}
//