reorganized view into some sub components.
This commit is contained in:
parent
238c6b44db
commit
cb6841cdac
|
@ -5,11 +5,15 @@ import lombok.Getter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BookContents {
|
||||
public class Book {
|
||||
@Getter
|
||||
private final List<BookPage> pages;
|
||||
|
||||
public BookContents() {
|
||||
public Book() {
|
||||
this.pages = new ArrayList<>();
|
||||
}
|
||||
|
||||
public int getPageCount() {
|
||||
return this.pages.size();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package nl.andrewlalis.blockbookbinder.view;
|
||||
|
||||
import nl.andrewlalis.blockbookbinder.model.Book;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* A customized panel that's dedicated to showing a book's contents.
|
||||
*/
|
||||
public class BookPreviewPanel extends JPanel {
|
||||
private Book book;
|
||||
|
||||
public BookPreviewPanel() {
|
||||
super(new BorderLayout());
|
||||
|
||||
this.add(new JLabel("Book Preview"), BorderLayout.NORTH);
|
||||
this.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
|
||||
JTextArea previewPageTextArea = new JTextArea();
|
||||
JScrollPane previewPageScrollPane = new JScrollPane(previewPageTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
this.add(previewPageScrollPane, BorderLayout.CENTER);
|
||||
|
||||
JPanel previewButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||
previewButtonPanel.add(new JButton("<"));
|
||||
previewButtonPanel.add(new JButton(">"));
|
||||
this.add(previewButtonPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
}
|
|
@ -4,9 +4,7 @@ import nl.andrewlalis.blockbookbinder.control.ImportAction;
|
|||
import nl.andrewlalis.blockbookbinder.util.ApplicationProperties;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
|
@ -58,45 +56,16 @@ public class MainFrame extends JFrame {
|
|||
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
|
||||
JPanel doublePanel = new JPanel(new GridLayout(1, 2));
|
||||
doublePanel.add(new BookPreviewPanel());
|
||||
doublePanel.add(new SourceTextPanel());
|
||||
mainPanel.add(doublePanel, BorderLayout.CENTER);
|
||||
final Insets innerPanelInsets = new Insets(5, 5, 5, 5);
|
||||
|
||||
|
||||
JPanel leftPanel = new JPanel(new BorderLayout());
|
||||
doublePanel.add(leftPanel);
|
||||
leftPanel.add(new JLabel("Book Preview"), BorderLayout.NORTH);
|
||||
leftPanel.setBorder(new EmptyBorder(innerPanelInsets));
|
||||
|
||||
JTextArea previewPageTextArea = new JTextArea();
|
||||
JScrollPane previewPageScrollPane = new JScrollPane(previewPageTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
leftPanel.add(previewPageScrollPane, BorderLayout.CENTER);
|
||||
|
||||
JPanel previewButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||
previewButtonPanel.add(new JButton("<"));
|
||||
previewButtonPanel.add(new JButton(">"));
|
||||
leftPanel.add(previewButtonPanel, BorderLayout.SOUTH);
|
||||
|
||||
|
||||
JPanel rightPanel = new JPanel(new BorderLayout());
|
||||
doublePanel.add(rightPanel);
|
||||
rightPanel.add(new JLabel("Source Text"), BorderLayout.NORTH);
|
||||
rightPanel.setBorder(new EmptyBorder(innerPanelInsets));
|
||||
|
||||
JTextArea mainTextArea = new JTextArea();
|
||||
JScrollPane scrollWrappedMainTextArea = new JScrollPane(mainTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
rightPanel.add(scrollWrappedMainTextArea, BorderLayout.CENTER);
|
||||
|
||||
JPanel rightPanelButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
rightPanel.add(rightPanelButtonPanel, BorderLayout.SOUTH);
|
||||
rightPanelButtonPanel.add(new JButton(this.importAction));
|
||||
|
||||
|
||||
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
JButton exportButton = new JButton("Export to Book");
|
||||
exportButton.addActionListener(e -> {
|
||||
System.out.println("Starting export.");
|
||||
final String fullText = mainTextArea.getText().trim();
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(fullText.substring(0, 200)), null);
|
||||
// final String fullText = mainTextArea.getText().trim();
|
||||
// Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(fullText.substring(0, 200)), null);
|
||||
});
|
||||
bottomPanel.add(exportButton);
|
||||
mainPanel.add(bottomPanel, BorderLayout.SOUTH);
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package nl.andrewlalis.blockbookbinder.view;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* A panel dedicated to displaying an interacting with a raw source of text for
|
||||
* a book.
|
||||
*/
|
||||
public class SourceTextPanel extends JPanel {
|
||||
public SourceTextPanel() {
|
||||
super(new BorderLayout());
|
||||
|
||||
this.add(new JLabel("Source Text"), BorderLayout.NORTH);
|
||||
this.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
|
||||
JTextArea mainTextArea = new JTextArea();
|
||||
JScrollPane scrollWrappedMainTextArea = new JScrollPane(mainTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
this.add(scrollWrappedMainTextArea, BorderLayout.CENTER);
|
||||
|
||||
JPanel rightPanelButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
this.add(rightPanelButtonPanel, BorderLayout.SOUTH);
|
||||
JButton importButton = new JButton("Import");
|
||||
importButton.setActionCommand("importSource");
|
||||
rightPanelButtonPanel.add(importButton);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue