Skip to content

Commit

Permalink
update 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DJ-Raven committed Nov 25, 2023
1 parent 672a6f5 commit 874651e
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 26 additions & 19 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed jar library/swing-glasspane-popup-1.1.0.jar
Binary file not shown.
Binary file added jar library/swing-glasspane-popup-1.2.0.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>raven.popup</groupId>
<artifactId>swing-glasspane-popup</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/raven/alerts/AlertsOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected static AlertsOption getAlertsOption(MessageAlerts.MessageType messageT
};
return getDefaultOption("raven/alerts/icon/error.svg", Color.decode("#ef4444"), effects);
} else {
return getDefaultOption("raven/alerts/icon/question.svg", null);
return getDefaultOption("raven/alerts/icon/information.svg", null);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/raven/alerts/SimpleAlerts.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected void paintChildren(Graphics g) {


private JPanel createActionButton(int option, Color color) {
JPanel panel = new JPanel(new MigLayout("insets 3,center,gapx 15", "center"));
JPanel panel = new JPanel(new MigLayout("insets 3,center,gapx 15", "[90,fill]"));
switch (option) {
case MessageAlerts.OK_CANCEL_OPTION:
panel.add(createButton("Cancel", null, MessageAlerts.CANCEL_OPTION));
Expand All @@ -228,7 +228,7 @@ private JButton createButton(String text, Color color, int option) {
"innerFocusWidth:0;" +
"arc:10;" +
"font:+1;" +
"margin:5,35,5,35;" +
"margin:5,5,5,5;" +
"foreground:" + (color == null ? "null" : "#F0F0F0") + ";" +
"arc:999");
if (color != null) {
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/raven/drawer/Drawer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ public static Drawer newInstance() {
}

private Drawer() {
option = new DrawerOption();
}

public void setDrawerBuilder(DrawerBuilder drawerBuilder) {
drawerPanel = new DrawerPanel(drawerBuilder);
option = new DrawerOption(drawerBuilder.getDrawerWidth());
drawerBuilder.build(drawerPanel);
}

public void showDrawer() {
if (drawerPanel == null) {
throw new NullPointerException("Drawer builder has not initialize");
}
if (!drawerPanel.isShowing()) {
if (!isShowing()) {
GlassPanePopup.showPopup(drawerPanel, option, "drawer");
}
}
Expand All @@ -43,6 +43,10 @@ public void closeDrawer() {
GlassPanePopup.closePopup("drawer");
}

public boolean isShowing() {
return GlassPanePopup.isShowing(drawerPanel);
}

public DrawerPanel getDrawerPanel() {
return drawerPanel;
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/raven/drawer/DrawerOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@

public class DrawerOption extends DefaultOption {

private final int width = 275;
private final int width;

public DrawerOption() {
this(275);
}

public DrawerOption(int width) {
this.width = width;
}

@Override
public String getLayout(Component parent, float animate) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/raven/drawer/component/DrawerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public interface DrawerBuilder {
public Component getMenu();

public Component getFooter();

public int getDrawerWidth();
}
5 changes: 5 additions & 0 deletions src/main/java/raven/drawer/component/SimpleDrawerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public Component getFooter() {
return footer;
}

@Override
public int getDrawerWidth() {
return 275;
}

public void build(DrawerPanel drawerPanel) {

}
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/raven/popup/GlassPanePopup.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,31 @@ public static void closePopupAll() {
}
}

public static boolean isShowing(String name) {
boolean act = false;
for (Component com : instance.layerPane.getComponents()) {
if (com.getName() != null && com.getName().equals(name)) {
act = true;
break;
}
}
return act;
}

public static boolean isShowing(Component component) {
boolean act = false;
for (Component com : instance.layerPane.getComponents()) {
if (com instanceof GlassPopup) {
GlassPopup popup = (GlassPopup) com;
if (popup.getComponent() == component) {
act = true;
break;
}
}
}
return act;
}

public static int getPopupCount() {
return instance.layerPane.getComponentCount();
}
Expand Down
32 changes: 32 additions & 0 deletions src/main/resources/raven/alerts/icon/information.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/test/java/test/Demo.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class Demo extends JFrame {

public Demo() {
applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
// applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
GlassPanePopup.install(this);
MyDrawerBuilder myDrawerBuilder = new MyDrawerBuilder();
Drawer.getInstance().setDrawerBuilder(myDrawerBuilder);
Expand Down
12 changes: 7 additions & 5 deletions src/test/java/test/DemoAlerts.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.fonts.roboto.FlatRobotoFont;
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
import com.formdev.flatlaf.themes.FlatMacLightLaf;
import net.miginfocom.swing.MigLayout;
import raven.alerts.MessageAlerts;
import raven.popup.GlassPanePopup;
Expand All @@ -24,10 +23,13 @@ public DemoAlerts() {
cmd.addActionListener(e -> {
String title = "Data Save Successful";
String message = getSample();
// MessageAlerts.getInstance().showMessage(title, message, MessageAlerts.MessageType.DEFAULT, MessageAlerts.YES_NO_CANCEL_OPTION, (controller, action) -> {
// System.out.println(action);
// });
MessageAlerts.getInstance().showMessage("Info", "Information Regarding Data Saving - We've Detected an Issue. Rest Assured, Our Team Is Actively Addressing This for a Swift Resolution.", MessageAlerts.MessageType.SUCCESS,MessageAlerts.OK_CANCEL_OPTION,null);
// MessageAlerts.getInstance().showMessage(title, message, MessageAlerts.MessageType.DEFAULT, MessageAlerts.YES_NO_CANCEL_OPTION, (controller, action) -> {
//if(action==MessageAlerts.CLOSED_OPTION){
// controller.consume();
// System.out.println("User press yes");
// }
// });
MessageAlerts.getInstance().showMessage("Data Saving Failure", "Oops! We encountered an issue while attempting to save your data. Please try again later or contact support for assistance. Apologies for any inconvenience caused.", MessageAlerts.MessageType.ERROR,MessageAlerts.OK_CANCEL_OPTION,null);
});
add(cmd);
}
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/test/MyDrawerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ public void build(DrawerPanel drawerPanel) {
// header.putClientProperty(FlatClientProperties.STYLE,"" +
// "background:#E36E1D");
}

@Override
public int getDrawerWidth() {
return 275;
}
}

0 comments on commit 874651e

Please sign in to comment.