Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/com/parafield/storming/Icons.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ private static ImageIcon loadIcon(String name, int width, int height) {

public static final ImageIcon EXE_ICON = loadIcon("exe-icon", 18, 18);
public static final ImageIcon GIT = loadIcon("Git", 18, 18);
public static final ImageIcon COMMIT = loadIcon("commit", 18, 18);
public static final ImageIcon PR = loadIcon("PR", 18, 18);
public static final ImageIcon GRID = loadIcon("grid", 16, 16);
public static final ImageIcon MAGNET = loadIcon("magnet", 16, 16);
public static final ImageIcon PLUS = loadIcon("plus", 16, 16);
Expand Down
110 changes: 110 additions & 0 deletions src/main/java/com/parafield/storming/ui/panels/GitPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.parafield.storming.ui.panels;

import com.formdev.flatlaf.FlatClientProperties;
import com.parafield.storming.Icons;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;

public class GitPanel extends JPanel {

private final JPanel changesList;
private final JTextArea commitMessage;
private final JLabel branchLabel;

public GitPanel() {
setLayout(new BorderLayout());

// --- 1. Header (Branch Info) ---
JPanel header = new JPanel(new BorderLayout());
header.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("Component.borderColor")));
header.setPreferredSize(new Dimension(0, 32));
header.setBackground(UIManager.getColor("Panel.background"));

branchLabel = new JLabel(" master", Icons.GIT, SwingConstants.LEFT);
branchLabel.setFont(UIManager.getFont("defaultFont").deriveFont(Font.BOLD, 11f));
header.add(branchLabel, BorderLayout.WEST);

JPanel actions = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 2));
actions.setOpaque(false);
JButton refreshBtn = new JButton(Icons.RESTART); // Reuse icon
refreshBtn.putClientProperty(FlatClientProperties.BUTTON_TYPE, FlatClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON);
refreshBtn.setToolTipText("Refresh Status");
actions.add(refreshBtn);
header.add(actions, BorderLayout.EAST);

add(header, BorderLayout.NORTH);

// --- 2. Changes List ---
changesList = new JPanel();
changesList.setLayout(new BoxLayout(changesList, BoxLayout.Y_AXIS));
changesList.setBackground(UIManager.getColor("TextArea.background"));

// Mock data for now
addChangeItem("src/main/java/MainWindow.java", "modified");
addChangeItem("Engine/2D/src/Renderer.cpp", "modified");
addChangeItem("assets/textures/player.png", "untracked");

JScrollPane scrollPane = new JScrollPane(changesList);
scrollPane.setBorder(null);

// --- 3. Commit Section ---
JPanel commitSection = new JPanel(new BorderLayout(0, 5));
commitSection.setBorder(new EmptyBorder(10, 10, 10, 10));

commitMessage = new JTextArea();
commitMessage.putClientProperty(FlatClientProperties.PLACEHOLDER_TEXT, "Commit message...");
commitMessage.setLineWrap(true);
commitMessage.setWrapStyleWord(true);
commitMessage.setFont(new Font("SansSerif", Font.PLAIN, 12));
commitMessage.putClientProperty(FlatClientProperties.STYLE, "arc: 8; background: darken($Panel.background, 3%)");

JScrollPane msgScroll = new JScrollPane(commitMessage);
msgScroll.setPreferredSize(new Dimension(0, 80));
msgScroll.setBorder(BorderFactory.createLineBorder(UIManager.getColor("Component.borderColor")));

JPanel btnPanel = new JPanel(new GridLayout(1, 2, 5, 0));
JButton commitBtn = new JButton("Commit");
commitBtn.putClientProperty(FlatClientProperties.STYLE, "background: #3498db; foreground: #ffffff; hoverBackground: #2980b9");

JButton pushBtn = new JButton("Commit and Push...");

btnPanel.add(commitBtn);
btnPanel.add(pushBtn);

commitSection.add(msgScroll, BorderLayout.CENTER);
commitSection.add(btnPanel, BorderLayout.SOUTH);

// --- Layout ---
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, commitSection);
split.setDividerLocation(300);
split.setDividerSize(3);
split.setBorder(null);
split.setResizeWeight(1.0);

add(split, BorderLayout.CENTER);
}

private void addChangeItem(String file, String status) {
JPanel item = new JPanel(new BorderLayout());
item.setMaximumSize(new Dimension(Integer.MAX_VALUE, 28));
item.setPreferredSize(new Dimension(0, 28));
item.setOpaque(false);
item.setBorder(new EmptyBorder(0, 5, 0, 5));

JCheckBox cb = new JCheckBox(file);
cb.setSelected(true);
cb.setFont(UIManager.getFont("defaultFont").deriveFont(12f));

JLabel statusLbl = new JLabel(status);
statusLbl.setFont(UIManager.getFont("defaultFont").deriveFont(Font.ITALIC, 10f));
statusLbl.setForeground(status.equals("untracked") ? new Color(155, 89, 182) : new Color(46, 204, 113));

item.add(cb, BorderLayout.CENTER);
item.add(statusLbl, BorderLayout.EAST);

changesList.add(item);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.parafield.storming.ui.panels;

import com.formdev.flatlaf.FlatClientProperties;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

public class PRDetailsCenterPanel extends JPanel {

public PRDetailsCenterPanel(String title, String author) {
setLayout(new BorderLayout());
setBackground(UIManager.getColor("Panel.background"));

// --- Header Section ---
JPanel header = new JPanel();
header.setLayout(new BoxLayout(header, BoxLayout.Y_AXIS));
header.setBorder(new EmptyBorder(20, 25, 15, 25));
header.setOpaque(false);

JLabel titleLabel = new JLabel(title);
titleLabel.setFont(new Font("SansSerif", Font.BOLD, 22));

JLabel authorLabel = new JLabel("Opened by " + author + " • 3 comments");
authorLabel.setForeground(UIManager.getColor("Label.disabledForeground"));
authorLabel.setFont(new Font("SansSerif", Font.PLAIN, 13));

header.add(titleLabel);
header.add(Box.createVerticalStrut(5));
header.add(authorLabel);

// --- Tabs (Description / Logs) ---
JTabbedPane tabs = new JTabbedPane();
tabs.putClientProperty(FlatClientProperties.TABBED_PANE_TAB_TYPE, FlatClientProperties.TABBED_PANE_TAB_TYPE_UNDERLINED);

// Description Tab
JTextArea desc = new JTextArea("This pull request introduces the new centralized PR management system.\n\n" +
"Summary of changes:\n" +
"- Added PRPanel with list and detail views.\n" +
"- Integrated with MainWindow editor tabs.\n" +
"- Improved SideBar interaction.");
desc.setEditable(false);
desc.setOpaque(false);
desc.setLineWrap(true);
desc.setWrapStyleWord(true);
desc.setBorder(new EmptyBorder(10, 10, 10, 10));
tabs.addTab("Description", new JScrollPane(desc));

// Logs Tab
JTextArea logs = new JTextArea("[SUCCESS] Build passed in 1m 24s\n" +
"[SUCCESS] All unit tests passed (124/124)\n" +
"[INFO] Deployed to staging-01");
logs.setEditable(false);
logs.setFont(new Font("JetBrains Mono", Font.PLAIN, 12));
logs.setBackground(new Color(20, 20, 25));
logs.setForeground(new Color(46, 204, 113));
logs.setBorder(new EmptyBorder(10, 10, 10, 10));
tabs.addTab("Checks & Logs", new JScrollPane(logs));

add(header, BorderLayout.NORTH);
add(tabs, BorderLayout.CENTER);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.parafield.storming.ui.panels;

import com.formdev.flatlaf.FlatClientProperties;
import com.parafield.storming.Icons;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

public class PRDetailsSidePanel extends JPanel {

private final Runnable onBack;
private final JPanel content;

public PRDetailsSidePanel(String title, Runnable onBack) {
this.onBack = onBack;
setLayout(new BorderLayout());

// --- 1. Header (Back Button) ---
JPanel header = new JPanel(new BorderLayout());
header.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("Component.borderColor")));
header.setPreferredSize(new Dimension(0, 32));
header.setBackground(UIManager.getColor("Panel.background"));

JButton backBtn = new JButton("← Back");
backBtn.putClientProperty(FlatClientProperties.BUTTON_TYPE, FlatClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON);
backBtn.addActionListener(e -> onBack.run());
header.add(backBtn, BorderLayout.WEST);

add(header, BorderLayout.NORTH);

// --- 2. Changed Files & Checks ---
content = new JPanel();
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
content.setBorder(new EmptyBorder(10, 10, 10, 10));

JLabel titleLbl = new JLabel("Files Changed");
titleLbl.setFont(UIManager.getFont("defaultFont").deriveFont(Font.BOLD, 11f));
titleLbl.setForeground(UIManager.getColor("Label.disabledForeground"));
titleLbl.setAlignmentX(Component.LEFT_ALIGNMENT);
content.add(titleLbl);
content.add(Box.createVerticalStrut(10));

addFileItem("src/main/ui/PRPanel.java", "+42 -12");
addFileItem("src/main/ui/MainWindow.java", "+15 -5");
addFileItem("Engine/Core/Log.cpp", "+2 -2");

content.add(Box.createVerticalStrut(20));

JLabel checkLbl = new JLabel("Checks (3 Passed)");
checkLbl.setFont(UIManager.getFont("defaultFont").deriveFont(Font.BOLD, 11f));
checkLbl.setForeground(new Color(46, 204, 113));
checkLbl.setAlignmentX(Component.LEFT_ALIGNMENT);
content.add(checkLbl);

addCheckItem("Build", true);
addCheckItem("Unit Tests", true);
addCheckItem("Linter", true);

JScrollPane scrollPane = new JScrollPane(content);
scrollPane.setBorder(null);
add(scrollPane, BorderLayout.CENTER);
}

private void addFileItem(String name, String diff) {
JPanel item = new JPanel(new BorderLayout());
item.setMaximumSize(new Dimension(Integer.MAX_VALUE, 26));
item.setOpaque(false);
item.setAlignmentX(Component.LEFT_ALIGNMENT);

JLabel nameLbl = new JLabel(name);
nameLbl.setFont(new Font("SansSerif", Font.PLAIN, 12));

JLabel diffLbl = new JLabel(diff);
diffLbl.setFont(new Font("Monospaced", Font.BOLD, 11));
diffLbl.setForeground(new Color(46, 204, 113));

item.add(nameLbl, BorderLayout.CENTER);
item.add(diffLbl, BorderLayout.EAST);

content.add(item);
}

private void addCheckItem(String name, boolean success) {
JLabel lbl = new JLabel(" ✓ " + name);
lbl.setFont(new Font("SansSerif", Font.PLAIN, 12));
lbl.setForeground(UIManager.getColor("Label.foreground"));
lbl.setAlignmentX(Component.LEFT_ALIGNMENT);
content.add(lbl);
}
}
110 changes: 110 additions & 0 deletions src/main/java/com/parafield/storming/ui/panels/PRPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.parafield.storming.ui.panels;

import com.formdev.flatlaf.FlatClientProperties;
import com.parafield.storming.Icons;
import com.parafield.storming.ui.windows.MainWindow;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class PRPanel extends JPanel {

private final JPanel prList;
private final CardLayout cardLayout;
private final JPanel mainContainer;

public PRPanel() {
setLayout(new BorderLayout());

cardLayout = new CardLayout();
mainContainer = new JPanel(cardLayout);

// --- 1. PR List View ---
JPanel listView = new JPanel(new BorderLayout());

JPanel header = new JPanel(new BorderLayout());
header.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("Component.borderColor")));
header.setPreferredSize(new Dimension(0, 32));
header.setBackground(UIManager.getColor("Panel.background"));

JLabel title = new JLabel(" Pull Requests", Icons.PR, SwingConstants.LEFT);
title.setFont(UIManager.getFont("defaultFont").deriveFont(Font.BOLD, 11f));
header.add(title, BorderLayout.WEST);

JButton createBtn = new JButton(Icons.PLUS);
createBtn.putClientProperty(FlatClientProperties.BUTTON_TYPE, FlatClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON);
createBtn.setToolTipText("New Pull Request");
header.add(createBtn, BorderLayout.EAST);

listView.add(header, BorderLayout.NORTH);

prList = new JPanel();
prList.setLayout(new BoxLayout(prList, BoxLayout.Y_AXIS));
prList.setBackground(UIManager.getColor("TextArea.background"));

addPRItem("#42: Refactor Renderer API", "batista", "2 hours ago");
addPRItem("#41: Add Vulkan backend support", "parafield", "Yesterday");
addPRItem("#40: Fix crash on window resize", "contributor1", "3 days ago");

JScrollPane scrollPane = new JScrollPane(prList);
scrollPane.setBorder(null);
listView.add(scrollPane, BorderLayout.CENTER);

JButton createPRBigBtn = new JButton("Create Pull Request...");
createPRBigBtn.putClientProperty(FlatClientProperties.STYLE, "background: #27ae60; foreground: #ffffff;");
JPanel footer = new JPanel(new BorderLayout());
footer.setBorder(new EmptyBorder(10, 10, 10, 10));
footer.add(createPRBigBtn, BorderLayout.CENTER);
listView.add(footer, BorderLayout.SOUTH);

mainContainer.add(listView, "LIST");
add(mainContainer, BorderLayout.CENTER);
}

private void addPRItem(String title, String author, String time) {
JPanel item = new JPanel();
item.setLayout(new BoxLayout(item, BoxLayout.Y_AXIS));
item.setMaximumSize(new Dimension(Integer.MAX_VALUE, 50));
item.setPreferredSize(new Dimension(0, 50));
item.setOpaque(false);
item.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("Component.borderColor")),
BorderFactory.createEmptyBorder(8, 12, 8, 12)
));
item.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

item.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
showDetails(title, author);
}
}
});

JLabel titleLabel = new JLabel(title);
titleLabel.setFont(UIManager.getFont("defaultFont").deriveFont(Font.BOLD, 12f));
titleLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

JLabel infoLabel = new JLabel(author + " • " + time);
infoLabel.setFont(UIManager.getFont("defaultFont").deriveFont(10f));
infoLabel.setForeground(UIManager.getColor("Label.disabledForeground"));
infoLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

item.add(titleLabel);
item.add(Box.createVerticalStrut(2));
item.add(infoLabel);

prList.add(item);
}

public void showDetails(String title, String author) {
PRDetailsSidePanel detailView = new PRDetailsSidePanel(title, () -> cardLayout.show(mainContainer, "LIST"));
mainContainer.add(detailView, "DETAIL");
cardLayout.show(mainContainer, "DETAIL");

MainWindow.getInstance().openPRDetails(title, author);
}
}
Loading
Loading