Skip to content

Commit 5cd09a3

Browse files
committed
Add flat page host
1 parent b13288c commit 5cd09a3

59 files changed

Lines changed: 1917 additions & 801 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Techsenger TabShell
22

33
Techsenger TabShell is a platform for building tab-based applications in JavaFX, where an application is structured
4-
as a tree of MVP components, each of which has its own lifecycle, history, etc. The platform provides abstract
4+
as a tree of MVP components, each of which has its own lifecycle, history, etc. The platform provides abstract
55
classes for creating the main types of components: tab, area, page, dialog, and popup, as well as containers for them.
66

77
It also includes ready-to-use implementations of containers (including a docking layout) and dialogs (including a
@@ -36,6 +36,7 @@ TabShell is built on top of the [PatternFX](https://github.com/techsenger/patter
3636
* [TabHost](#layout-tab-host)
3737
* [DockHost](#layout-dock-host)
3838
* [PageHost](#layout-page-host)
39+
* [TreePageHost](#layout-tree-page-host)
3940
* [Shared Components](#shared)
4041
* [FindBase](#shared-find-base)
4142
* [FindPanel](#shared-find-panel)
@@ -324,10 +325,12 @@ to which all other components are positioned. The main component can be an `Area
324325
### PageHost <a name="layout-page-host"></a>
325326

326327
`PageHost` is a simple component that displays `Page` components and performs their lazy initialization.
328+
It can be used to display navigable pages with a flat menu-like structure in diffent components - tabs, dialogs etc.
327329

328-
It can be used to display navigable pages with a menu-like structure (similar to a website layout). Additionally,
329-
it is commonly used in dialogs with a navigation tree on the left and a content page on the right. A classic example
330-
is a settings dialog.
330+
### TreePageHost <a name="layout-tree-page-host"></a>
331+
332+
`TreePageHost` is almost identical to `PageHost`, except for the menu structure: `PageHost` uses a flat menu
333+
(`ListView`), whereas `TreePageHost` uses a hierarchical menu (`TreeView`).
331334

332335
## Shared Components <a name="shared"></a>
333336

tabshell-core/src/main/java/com/techsenger/tabshell/core/page/AbstractPagePresenter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public abstract class AbstractPagePresenter<V extends PageView, C extends PageCo
2727

2828
private boolean selected;
2929

30-
private final PageItem<?> item;
30+
private final PageItem item;
3131

32-
public AbstractPagePresenter(V view, PageItem<?> item) {
32+
public AbstractPagePresenter(V view, PageItem item) {
3333
super(view);
3434
this.item = item;
3535
}
@@ -50,7 +50,7 @@ protected PageHistory getHistory() {
5050
}
5151

5252
@Override
53-
public PageItem<?> getItem() {
53+
public PageItem getItem() {
5454
return item;
5555
}
5656
}

tabshell-core/src/main/java/com/techsenger/tabshell/core/page/DefaultPageDescriptor.java

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,73 +16,27 @@
1616

1717
package com.techsenger.tabshell.core.page;
1818

19-
import com.techsenger.annotations.Unmodifiable;
2019
import com.techsenger.tabshell.material.icon.Icon;
21-
import java.util.ArrayList;
22-
import java.util.Collections;
23-
import java.util.List;
2420

2521
/**
2622
*
2723
* @author Pavel Castornii
2824
*/
29-
public class DefaultPageDescriptor implements PageDescriptor {
25+
public class DefaultPageDescriptor extends DefaultPageItem implements PageDescriptor {
3026

31-
private final Icon<?> icon;
27+
private final PageFactory<PageItem> factory;
3228

33-
private final String text;
34-
35-
private final PageFactory factory;
36-
37-
private PageDescriptor parent;
38-
39-
private final List<PageDescriptor> children = new ArrayList<>();
40-
41-
public DefaultPageDescriptor() {
42-
this(null, null, null);
43-
}
44-
45-
public DefaultPageDescriptor(String text, PageFactory factory) {
29+
public DefaultPageDescriptor(String text, PageFactory<PageItem> factory) {
4630
this(null, text, factory);
4731
}
4832

49-
public DefaultPageDescriptor(Icon<?> icon, String text, PageFactory factory) {
33+
public DefaultPageDescriptor(Icon<?> icon, String text, PageFactory<PageItem> factory) {
34+
super(icon, text);
5035
this.factory = factory;
51-
this.icon = icon;
52-
this.text = text;
5336
}
5437

5538
@Override
56-
public PageFactory getFactory() {
39+
public PageFactory<PageItem> getFactory() {
5740
return factory;
5841
}
59-
60-
@Override
61-
public PageDescriptor getParent() {
62-
return this.parent;
63-
}
64-
65-
@Override
66-
public @Unmodifiable List<PageDescriptor> getChildren() {
67-
return Collections.unmodifiableList(this.children);
68-
}
69-
70-
public void addChild(DefaultPageDescriptor item) {
71-
this.children.add(item);
72-
item.setParent(this);
73-
}
74-
75-
@Override
76-
public Icon<?> getIcon() {
77-
return icon;
78-
}
79-
80-
@Override
81-
public String getText() {
82-
return text;
83-
}
84-
85-
void setParent(DefaultPageDescriptor parent) {
86-
this.parent = parent;
87-
}
8842
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2024-2026 Pavel Castornii.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.techsenger.tabshell.core.page;
18+
19+
import com.techsenger.tabshell.material.icon.Icon;
20+
21+
/**
22+
*
23+
* @author Pavel Castornii
24+
*/
25+
public class DefaultPageItem implements PageItem {
26+
27+
private final Icon<?> icon;
28+
29+
private final String text;
30+
31+
public DefaultPageItem(Icon<?> icon, String text) {
32+
this.icon = icon;
33+
this.text = text;
34+
}
35+
36+
@Override
37+
public Icon<?> getIcon() {
38+
return icon;
39+
}
40+
41+
@Override
42+
public String getText() {
43+
return text;
44+
}
45+
46+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2024-2026 Pavel Castornii.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.techsenger.tabshell.core.page;
18+
19+
import com.techsenger.annotations.Unmodifiable;
20+
import com.techsenger.tabshell.material.icon.Icon;
21+
import java.util.ArrayList;
22+
import java.util.Collections;
23+
import java.util.List;
24+
25+
/**
26+
*
27+
* @author Pavel Castornii
28+
*/
29+
public class DefaultTreePageDescriptor extends DefaultPageItem implements TreePageDescriptor {
30+
31+
private DefaultTreePageDescriptor parent;
32+
33+
private final List<DefaultTreePageDescriptor> children = new ArrayList<>();
34+
35+
private final PageFactory<TreePageItem> factory;
36+
37+
public DefaultTreePageDescriptor() {
38+
this(null, null, null);
39+
}
40+
41+
public DefaultTreePageDescriptor(String text, PageFactory<TreePageItem> factory) {
42+
this(null, text, factory);
43+
}
44+
45+
public DefaultTreePageDescriptor(Icon<?> icon, String text, PageFactory<TreePageItem> factory) {
46+
super(icon, text);
47+
this.factory = factory;
48+
}
49+
50+
@Override
51+
public PageFactory<TreePageItem> getFactory() {
52+
return factory;
53+
}
54+
55+
@Override
56+
public TreePageDescriptor getParent() {
57+
return this.parent;
58+
}
59+
60+
@Override
61+
public @Unmodifiable List<? extends TreePageDescriptor> getChildren() {
62+
return Collections.unmodifiableList(this.children);
63+
}
64+
65+
public void addChild(DefaultTreePageDescriptor item) {
66+
this.children.add(item);
67+
item.setParent(this);
68+
}
69+
70+
private void setParent(DefaultTreePageDescriptor parent) {
71+
this.parent = parent;
72+
}
73+
}

tabshell-core/src/main/java/com/techsenger/tabshell/core/page/PageContainerFxView.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616

1717
package com.techsenger.tabshell.core.page;
1818

19+
import java.util.List;
20+
1921
/**
2022
*
2123
* @author Pavel Castornii
2224
*/
23-
public interface PageContainerFxView<P extends PageContainerPresenter<?, ?>> {
25+
public interface PageContainerFxView<P extends PageContainerPresenter<?, ?>> extends PageContainerView {
2426

2527
interface Composer extends PageContainerComposer {
2628

27-
void setPages(PageDescriptor root, boolean showRoot);
29+
void setPages(List<PageDescriptor> pages);
2830
}
2931

3032
Composer getComposer();

tabshell-core/src/main/java/com/techsenger/tabshell/core/page/PageContainerPort.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ public interface PageContainerPort {
2424

2525
PagePort getSelectedPage();
2626

27-
void selectPage(PageItem<?> item);
27+
void selectPage(PageItem item);
28+
29+
void selectPage(int index);
2830
}

tabshell-core/src/main/java/com/techsenger/tabshell/core/page/PageDescriptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author Pavel Castornii
2222
*/
23-
public interface PageDescriptor extends PageItem<PageDescriptor> {
23+
public interface PageDescriptor extends PageItem {
2424

25-
PageFactory getFactory();
25+
PageFactory<PageItem> getFactory();
2626
}

tabshell-core/src/main/java/com/techsenger/tabshell/core/page/PageFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
*
2121
* @author Pavel Castornii
2222
*/
23-
public interface PageFactory {
23+
public interface PageFactory<T extends PageItem> {
2424

2525
/**
2626
* Returns an initialized page.
2727
*
2828
* @param item
2929
* @return
3030
*/
31-
PageFxView<?> createAndInitialize(PageItem<?> item);
31+
PageFxView<?> createAndInitialize(T item);
3232
}

tabshell-core/src/main/java/com/techsenger/tabshell/core/page/PageItem.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,13 @@
1616

1717
package com.techsenger.tabshell.core.page;
1818

19-
import com.techsenger.annotations.Unmodifiable;
2019
import com.techsenger.tabshell.material.icon.Icon;
21-
import java.util.List;
2220

2321
/**
2422
*
2523
* @author Pavel Castornii
2624
*/
27-
public interface PageItem<T extends PageItem<T>> {
28-
29-
T getParent();
30-
31-
/**
32-
* Returns an unmodifiable list of children.
33-
*
34-
* @return
35-
*/
36-
@Unmodifiable List<T> getChildren();
25+
public interface PageItem {
3726

3827
Icon<?> getIcon();
3928

0 commit comments

Comments
 (0)