WIP but usable

This commit is contained in:
UnlegitDqrk
2026-02-11 23:28:02 +01:00
parent a268926d0b
commit 197e8510a2
29 changed files with 251 additions and 1424 deletions

View File

@@ -1,7 +1,6 @@
package org.openautonomousconnection.oacswing.component;
import jdk.jshell.spi.ExecutionControl;
import org.openautonomousconnection.oacswing.component.design.Design;
import org.openautonomousconnection.oacswing.component.design.DesignManager;
import javax.swing.*;
@@ -18,32 +17,32 @@ public interface OACComponent {
// this.setBackground(design.getElements().get(this.getClass()).getColor());
}
default void init() {}
default void init() {
}
default void initOther(Component comp) {
if(comp instanceof OACComponent component)
if (comp instanceof OACComponent component)
component.initDesign();
}
default Component add(Optional<String> name, Component comp, OptionalInt index, Optional<?> constrains) throws ExecutionControl.NotImplementedException {
JComponent superclass = this.getSuperclass();
if(comp instanceof OACComponent component)
if (comp instanceof OACComponent component)
component.initDesign();
if(name.isPresent())
if (name.isPresent())
return superclass.add(name.get(), comp);
else if(constrains.isPresent())
if(index.isPresent()) {
else if (constrains.isPresent())
if (index.isPresent()) {
superclass.add(comp, constrains.get(), index.getAsInt());
return null;
}
else {
} else {
superclass.add(comp, constrains.get());
return null;
}
else if(index.isPresent())
else if (index.isPresent())
return superclass.add(comp, index.getAsInt());
else
@@ -92,11 +91,12 @@ public interface OACComponent {
/**
* Needed to run JComponent / Component methods
*
* @return JComponent type superclass
* @throws ExecutionControl.NotImplementedException superclass is not of type JComponent
*/
default JComponent getSuperclass() throws ExecutionControl.NotImplementedException {
if(this instanceof JComponent superClass)
if (this instanceof JComponent superClass)
return superClass;
else
throw new ExecutionControl.NotImplementedException("Trying to implement OACComponent interface for non-JComponent class");