Skip to content

Commit a267667

Browse files
committed
Abstract version of ViewOwner that makes it easier to remember which methods are the essential ones.
Documentation change. Provided an actually usable implementation of the idea, complete with default methods that reference the original ViewOwner. @APinote is not supported by Gradle Javadoc plugin. Added a CustomViewOwner class that makes ViewOwner controls explicit. Otherwise harmonious with existing ViewOwner.
1 parent 8d9aa98 commit a267667

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

src/snap/view/CustomViewOwner.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package snap.view;
2+
3+
/**
4+
* Helper class to create custom ViewOwners with novel interpretations.
5+
*/
6+
public abstract class CustomViewOwner extends ViewOwner {
7+
8+
/**
9+
* Creates the top level view for this owner.
10+
* <br><br>
11+
* API Note: If you want the vanilla interaction of this class, return {@code default_createUI();}
12+
*/
13+
@Override
14+
abstract protected View createUI();
15+
16+
/**
17+
* Initializes the UI panel.
18+
* <br><br>
19+
* API Note: If you want the vanilla interaction of this class, return {@code default_initUI();}
20+
*/
21+
@Override
22+
abstract protected void initUI();
23+
24+
/**
25+
* Reset UI controls.
26+
* <br><br>
27+
* API Note: If you want the vanilla interaction of this class, return {@code default_resetUI();}
28+
*/
29+
@Override
30+
abstract protected void resetUI();
31+
32+
/**
33+
* Respond to UI controls.
34+
* <br><br>
35+
* API Note: If you want the vanilla interaction of this class, return {@code default_respondUI(ViewEvent);}
36+
* @param anEvent Any event that has been caught by this ViewOwner.
37+
*/
38+
@Override
39+
abstract protected void respondUI(ViewEvent anEvent);
40+
41+
/**
42+
* Default implementation of {@link ViewOwner#createUI()}
43+
* @return View loaded from snp file of the same name as the class.
44+
*/
45+
final protected View default_createUI() {return super.createUI();}
46+
47+
/**
48+
* Default implementation of {@link ViewOwner#initUI()}
49+
*/
50+
final protected void default_initUI() {super.initUI();}
51+
52+
/**
53+
* Default implementation of {@link ViewOwner#resetUI()}
54+
*/
55+
final protected void default_resetUI() {super.resetUI();}
56+
57+
/**
58+
* Default implementation of {@link ViewOwner#respondUI(ViewEvent)}
59+
* @param anEvent An event which has been captured by the view.
60+
*/
61+
final protected void default_respondUI(ViewEvent anEvent) {super.respondUI(anEvent);}
62+
}

0 commit comments

Comments
 (0)