Skip to content

Commit

Permalink
started reimplement gui drawing in js - for now done just a base idea
Browse files Browse the repository at this point in the history
  • Loading branch information
klesun authored and klesun committed Jan 14, 2016
1 parent fd5494c commit e172328
Show file tree
Hide file tree
Showing 15 changed files with 9,710 additions and 407 deletions.
10 changes: 10 additions & 0 deletions src/org/klesun_model/AbstractModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
// AbstractModel is used to store field list, since an interface can't have properties...


import org.json.JSONException;
import org.json.JSONObject;
import org.klesun_model.field.Arr;
import org.klesun_model.field.Field;
import org.klesun_model.field.IField;
import org.shmidusic.stuff.tools.Logger;

import java.util.Collection;
import java.util.LinkedHashMap;
Expand All @@ -19,6 +21,14 @@ public abstract class AbstractModel implements IModel
{
private Map<String, IField> fieldStorage = new LinkedHashMap<>();

/** use this constructor when creating new object */
public AbstractModel() {}

/** use this constructor when restoring object from json */
public AbstractModel(JSONObject state) {
Logger.fatal("Please override this constructor!");
}

@Override
public String toString() {
return this.getJsonRepresentation().toString();
Expand Down
8 changes: 8 additions & 0 deletions src/org/klesun_model/IKeyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// we handle event ONLY ONCE - in the deepest focused child (+ root) we found

import org.shmidusic.Main;
import org.shmidusic.stuff.tools.Logger;

import javax.swing.*;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -37,6 +38,13 @@ default Explain handleKey(Combo combo)
return result != null ? result : new Explain(false, "No Action For This Combination").setImplicit(true);
}

/** @read "abstract" */
static LinkedHashMap<Combo, ContextAction> getActionMap()
{
Logger.fatal("This Class method is abstract - please override it in the subclass!");
return null;
}

// we use this to (de)generate [File,Menu,Edit]-like menu that would
// (with few esthetic exclusions) completely correspond whole model key mapping.
// the sad thing is, due to Java not supporting abstract class methods, we generate
Expand Down
1 change: 1 addition & 0 deletions src/org/klesun_model/IModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ default JSONObject getJsonRepresentation()
return dict;
}

/** read "protected" */
default IModel reconstructFromJson(JSONObject jsObject) throws JSONException
{
for (Map.Entry<String, IField> e: getFieldStorage().entrySet()) {
Expand Down
Loading

0 comments on commit e172328

Please sign in to comment.