forked from cmadsen/vldocking
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add sample app using vldocking - give default names of components
- Loading branch information
Showing
19 changed files
with
316 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/test/java/com/vlsolutions/swing/docking/DockingSplitDesktopTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.vlsolutions.swing.docking; | ||
|
||
import com.vlsolutions.swing.sample.MySplitDockApp; | ||
import org.assertj.swing.core.GenericTypeMatcher; | ||
import org.assertj.swing.data.TableCell; | ||
import org.assertj.swing.edt.GuiActionRunner; | ||
import org.assertj.swing.fixture.FrameFixture; | ||
import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase; | ||
import org.junit.Test; | ||
|
||
import javax.swing.JLabel; | ||
import javax.swing.JPanel; | ||
import javax.swing.SwingUtilities; | ||
import java.awt.Dimension; | ||
|
||
|
||
public class DockingSplitDesktopTest extends AssertJSwingJUnitTestCase { | ||
|
||
protected FrameFixture window; | ||
protected MySplitDockApp application; | ||
|
||
@Override | ||
protected void onSetUp() { | ||
application = GuiActionRunner.execute(() -> { | ||
MySplitDockApp frame = new MySplitDockApp(); | ||
frame.setPreferredSize(new Dimension(800, 600)); | ||
frame.setMinimumSize(new Dimension(800, 600)); | ||
frame.validate(); | ||
return frame; | ||
}); | ||
window = new FrameFixture(robot(), application); | ||
window.show(); | ||
} | ||
|
||
@Test | ||
public void testDockableSplitDesktop() { | ||
SwingUtilities.invokeLater(() -> application.setVisible(true)); | ||
window.panel("myJTablePanel").requireVisible(); | ||
window.panel("myTreePanel").requireVisible(); | ||
window.panel("myTextEditorPanel").requireVisible(); | ||
window.panel("myGridOfButtonsPanel").requireVisible(); | ||
window.panel("myGridOfButtonsPanel").button("myGridOfButtonsButton0").requireText("btn0"); | ||
window.panel("myJTablePanel").table().requireCellValue(TableCell.row(0).column(0), ""); | ||
window.panel("myJTablePanel").table().requireColumnCount(5); | ||
|
||
window.panel("DockingPanel").panel(new PanelMatcher("DockView", 0)) | ||
.panel("DockViewTitleBar").label("TitleLabel").requireText("The tree"); | ||
window.panel("DockingPanel").panel(new PanelMatcher("DockView", 1)) | ||
.panel("DockViewTitleBar").label("TitleLabel").requireText("The Grid of Buttons"); | ||
window.panel("DockingPanel").panel(new PanelMatcher("DockView", 2)) | ||
.panel("DockViewTitleBar").label("TitleLabel").requireText("The table"); | ||
|
||
window.panel("DockingPanel").panel(new PanelMatcher("DockView", 2)) | ||
.panel("DockViewTitleBar").button("DockButton").click(); | ||
window.panel("AutoHideButtonPanel").label(new AutoHideButtonMatcher("AutoHideButton", 0)).click(); | ||
window.panel("AutoHideExpandPanel").panel("DockViewTitleBar").label("TitleLabel").requireText("The table"); | ||
window.panel("AutoHideExpandPanel").panel("DockViewTitleBar").button("DockButton").click(); | ||
} | ||
|
||
private static class AutoHideButtonMatcher extends GenericTypeMatcher<JLabel> { | ||
private final String name; | ||
private final int index; | ||
private int count = 0; | ||
|
||
public AutoHideButtonMatcher(String name, int index) { | ||
super(JLabel.class); | ||
this.name = name; | ||
this.index = index; | ||
} | ||
|
||
@Override | ||
protected boolean isMatching(JLabel button) { | ||
return name.equals(button.getName()) && count++ == index; | ||
} | ||
} | ||
|
||
private static class PanelMatcher extends GenericTypeMatcher<JPanel> { | ||
private final String name; | ||
private final int index; | ||
private int count = 0; | ||
|
||
public PanelMatcher(String name, int index) { | ||
super(JPanel.class); | ||
this.name = name; | ||
this.index = index; | ||
} | ||
|
||
@Override | ||
protected boolean isMatching(JPanel jPanel) { | ||
return name.equals(jPanel.getName()) && count++ == index; | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/test/java/com/vlsolutions/swing/sample/MyGridOfButtons.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.vlsolutions.swing.sample; | ||
|
||
import com.vlsolutions.swing.docking.DockKey; | ||
import com.vlsolutions.swing.docking.Dockable; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
|
||
public class MyGridOfButtons extends JPanel implements Dockable { | ||
|
||
DockKey key = new DockKey("gridOfButtons"); | ||
|
||
public MyGridOfButtons() { | ||
setName("myGridOfButtonsPanel"); | ||
setLayout(new FlowLayout(FlowLayout.TRAILING, 3, 3)); | ||
for (int i = 0; i < 3; i++) { | ||
for (int j = 0; j < 3; j++) { | ||
int number = i * 3 + j; | ||
JButton btn = new JButton("btn" + number); | ||
btn.setName("myGridOfButtonsButton" + number); | ||
add(btn); | ||
} | ||
} | ||
setPreferredSize(new Dimension(200,300)); | ||
key.setName("The Grid of Buttons"); | ||
key.setCloseEnabled(false); | ||
key.setFloatEnabled(true); | ||
key.setMaximizeEnabled(false); | ||
key.setAutoHideEnabled(false); | ||
} | ||
|
||
@Override | ||
public DockKey getDockKey() { | ||
return key; | ||
} | ||
|
||
@Override | ||
public Component getComponent() { | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.vlsolutions.swing.sample; | ||
|
||
import com.vlsolutions.swing.docking.DockKey; | ||
import com.vlsolutions.swing.docking.Dockable; | ||
|
||
import javax.swing.*; | ||
import javax.swing.table.DefaultTableModel; | ||
import java.awt.*; | ||
|
||
|
||
class MyJTable extends JPanel implements Dockable { | ||
JTable table = new JTable(); | ||
DockKey key = new DockKey("table"); | ||
|
||
public MyJTable() { | ||
setName("myJTablePanel"); | ||
setLayout(new BorderLayout()); | ||
table.setModel(new DefaultTableModel(5, 5)); | ||
table.setName("myJTableTable"); | ||
JScrollPane jsp = new JScrollPane(table); | ||
jsp.setName("myJTableScrollPane"); | ||
jsp.setPreferredSize(new Dimension(200, 200)); | ||
add(jsp, BorderLayout.CENTER); | ||
key.setName("The table"); | ||
key.setAutoHideEnabled(true); | ||
key.setCloseEnabled(false); | ||
key.setMaximizeEnabled(false); | ||
} | ||
|
||
@Override | ||
public DockKey getDockKey() { | ||
return key; | ||
} | ||
|
||
@Override | ||
public Component getComponent() { | ||
return this; | ||
} | ||
} |
Oops, something went wrong.