Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;

@SuppressWarnings("serial")
class SplitLayoutDemo extends Composite<SplitLayout> {

private MultiSourceCodeViewer code;
private Component demo;
private SourcePosition sourcePosition;

public SplitLayoutDemo(Component demo, String sourceUrl, SourcePosition sourcePosition) {
Expand All @@ -50,35 +48,31 @@ public SplitLayoutDemo(Component demo, List<SourceCodeTab> tabs) {
properties.put("flow", Version.getFullVersion());

code = new MultiSourceCodeViewer(tabs, properties);

this.sourcePosition = code.getSourcePosition();
switch (this.sourcePosition) {
case PRIMARY:
getContent().addToPrimary(code);
getContent().addToSecondary(demo);
break;
case SECONDARY:
default:
getContent().addToPrimary(demo);
getContent().addToSecondary(code);
}
this.demo = demo;
setSourcePosition(code.getSourcePosition());

getContent().setSizeFull();
}

public void switchSourcePosition(SourcePosition position) {
if (!this.sourcePosition.equals(position)) {
toggleSourcePosition();
private void setSourcePosition(SourcePosition position) {
if (!position.equals(sourcePosition)) {
getContent().removeAll();
switch (position) {
case PRIMARY:
getContent().addToPrimary(code);
getContent().addToSecondary(demo);
break;
case SECONDARY:
default:
getContent().addToPrimary(demo);
getContent().addToSecondary(code);
}
sourcePosition = position;
}
}

public void toggleSourcePosition() {
Component primary = getContent().getPrimaryComponent();
Component secondary = getContent().getSecondaryComponent();
getContent().removeAll();
getContent().addToPrimary(secondary);
getContent().addToSecondary(primary);
this.sourcePosition = this.sourcePosition.toggle();
setSourcePosition(sourcePosition.toggle());
}

public void setOrientation(Orientation o) {
Expand Down