package net.pterodactylus.jsite.gui;
import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
+import javax.swing.JButton;
import javax.swing.JPanel;
+import net.pterodactylus.jsite.core.Project;
+
/**
* A panel that contains all information about a project and lets the user edit
* the properties of the project.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
public class ProjectPanel extends JPanel {
+ /** The Swing interface. */
+ private final SwingInterface swingInterface;
+
+ /** The project to show. */
+ private final Project project;
+
/**
* Creates a new project panel.
+ *
+ * @param swingInterface
+ * The Swing interface
+ * @param project
+ * The project to display
*/
- public ProjectPanel() {
+ public ProjectPanel(SwingInterface swingInterface, Project project) {
super(new BorderLayout(12, 12));
+ this.swingInterface = swingInterface;
+ this.project = project;
initComponents();
}
//
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the project that is displayed in this panel.
+ *
+ * @return The project of this panel
+ */
+ public Project getProject() {
+ return project;
+ }
+
+ //
// PRIVATE METHODS
//
*/
private void initComponents() {
setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
-
+
+ JPanel propertiesPanel = createPropertiesPanel();
+ add(propertiesPanel, BorderLayout.CENTER);
+
+ JPanel buttonPanel = createButtonPanel();
+ add(buttonPanel, BorderLayout.PAGE_END);
+ }
+
+ /**
+ * Creates the properties panel.
+ *
+ * @return The properties panel
+ */
+ private JPanel createPropertiesPanel() {
+ JPanel propertiesPanel = new JPanel(new GridBagLayout());
+
+ return propertiesPanel;
+ }
+
+ /**
+ * Creates the button panel.
+ *
+ * @return The button panel
+ */
+ private JPanel createButtonPanel() {
+ 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()));
+
+ return buttonPanel;
}
}