-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3be554d
commit aa0d55a
Showing
18 changed files
with
414 additions
and
54 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
9 changes: 9 additions & 0 deletions
9
.../main/java/edu/stanford/bmir/protege/web/client/linearization/LinearizationParentTree.css
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,9 @@ | ||
.linearizationParentLabel tr { | ||
width : 100%; | ||
cursor: pointer; | ||
} | ||
|
||
.parentSelected { | ||
background-color: rgb(17, 108, 214); | ||
color: white; | ||
} |
16 changes: 16 additions & 0 deletions
16
...main/java/edu/stanford/bmir/protege/web/client/linearization/LinearizationParentView.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,16 @@ | ||
package edu.stanford.bmir.protege.web.client.linearization; | ||
|
||
import com.google.gwt.user.client.ui.IsWidget; | ||
import edu.stanford.bmir.protege.web.shared.HasDispose; | ||
import edu.stanford.bmir.protege.web.shared.entity.OWLEntityData; | ||
import edu.stanford.bmir.protege.web.shared.icd.AncestorClassHierarchy; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public interface LinearizationParentView extends IsWidget, HasDispose { | ||
|
||
void setAncestorsTree(AncestorClassHierarchy ancestorTree); | ||
|
||
OWLEntityData getSelectedParent(); | ||
} |
97 changes: 97 additions & 0 deletions
97
.../java/edu/stanford/bmir/protege/web/client/linearization/LinearizationParentViewImpl.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,97 @@ | ||
package edu.stanford.bmir.protege.web.client.linearization; | ||
|
||
import com.google.gwt.core.client.GWT; | ||
import com.google.gwt.event.logical.shared.OpenEvent; | ||
import com.google.gwt.event.logical.shared.OpenHandler; | ||
import com.google.gwt.uibinder.client.UiBinder; | ||
import com.google.gwt.uibinder.client.UiField; | ||
import com.google.gwt.user.client.ui.*; | ||
import edu.stanford.bmir.protege.web.shared.entity.OWLEntityData; | ||
import edu.stanford.bmir.protege.web.shared.icd.AncestorClassHierarchy; | ||
import com.google.gwt.user.client.ui.TreeItem; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
public class LinearizationParentViewImpl extends Composite implements LinearizationParentView { | ||
|
||
Logger logger = java.util.logging.Logger.getLogger("LinearizationParentViewImpl"); | ||
|
||
@UiField | ||
Tree tree; | ||
|
||
private OWLEntityData selectedEntity; | ||
LinearizationParentsResourceBundle.LinearizationParentCss style = LinearizationParentsResourceBundle.INSTANCE.style(); | ||
|
||
public LinearizationParentViewImpl(AncestorClassHierarchy ancestorsTree) { | ||
style.ensureInjected(); | ||
initWidget(ourUiBinder.createAndBindUi(this)); | ||
|
||
String browserText = ancestorsTree.getCurrentNode().getBrowserText(); | ||
browserText = browserText != null && !browserText.isEmpty() ? browserText : " "; | ||
TreeItem root = new TreeItem(new Label(browserText)); | ||
addTreeItems(root, ancestorsTree.getChildren()); | ||
root.setState(true); | ||
tree.addItem(root); | ||
tree.setAnimationEnabled(true); | ||
|
||
tree.addSelectionHandler(event -> { | ||
Iterator<TreeItem> iter = tree.treeItemIterator(); | ||
while(iter.hasNext()) { | ||
TreeItem item = iter.next(); | ||
if(event.getSelectedItem().equals(item)) { | ||
item.getWidget().addStyleName(style.getParentSelected()); | ||
} else { | ||
item.getWidget().removeStyleName(style.getParentSelected()); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
|
||
@Override | ||
public void setAncestorsTree(AncestorClassHierarchy ancestorsTree) { | ||
|
||
|
||
} | ||
|
||
@Override | ||
public OWLEntityData getSelectedParent() { | ||
return selectedEntity; | ||
} | ||
|
||
|
||
private void addTreeItems(TreeItem parentItem, List<AncestorClassHierarchy> nodes) { | ||
for (AncestorClassHierarchy node : nodes) { | ||
String browserText = node.getCurrentNode().getBrowserText(); | ||
browserText = browserText != null && !browserText.isEmpty() ? browserText : " "; | ||
Label label = new Label(browserText); | ||
|
||
TreeItem treeItem = new TreeItem(label); | ||
treeItem.setStyleName(style.getLinearizationParentLabel()); | ||
label.addClickHandler(event -> { | ||
selectedEntity = node.getCurrentNode(); | ||
tree.setSelectedItem(treeItem); | ||
}); | ||
parentItem.addItem(treeItem); | ||
|
||
if (node.getChildren() != null) { | ||
addTreeItems(treeItem, node.getChildren()); | ||
} | ||
treeItem.setState(true); | ||
|
||
} | ||
} | ||
@Override | ||
public void dispose() { | ||
tree.clear(); | ||
} | ||
|
||
interface LinearizationParentViewImpllUiBinder extends UiBinder<HTMLPanel, LinearizationParentViewImpl> { | ||
|
||
} | ||
private static LinearizationParentViewImpllUiBinder ourUiBinder = GWT.create(LinearizationParentViewImpllUiBinder.class); | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...ava/edu/stanford/bmir/protege/web/client/linearization/LinearizationParentViewImpl.ui.xml
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,17 @@ | ||
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' | ||
xmlns:g='urn:import:com.google.gwt.user.client.ui'> | ||
|
||
<ui:style> | ||
.gwt-Tree { | ||
} | ||
|
||
.gwt-TreeItem-selected { | ||
background-color: #ebeff9; | ||
} | ||
</ui:style> | ||
<g:HTMLPanel> | ||
<g:ScrollPanel> | ||
<g:Tree ui:field="tree" addStyleNames="{style.gwt-Tree}"></g:Tree> | ||
</g:ScrollPanel> | ||
</g:HTMLPanel > | ||
</ui:UiBinder> |
22 changes: 22 additions & 0 deletions
22
...du/stanford/bmir/protege/web/client/linearization/LinearizationParentsResourceBundle.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,22 @@ | ||
package edu.stanford.bmir.protege.web.client.linearization; | ||
|
||
import com.google.gwt.core.client.GWT; | ||
import com.google.gwt.resources.client.ClientBundle; | ||
import com.google.gwt.resources.client.CssResource; | ||
|
||
public interface LinearizationParentsResourceBundle extends ClientBundle { | ||
|
||
LinearizationParentsResourceBundle INSTANCE = GWT.create(LinearizationParentsResourceBundle.class); | ||
|
||
@Source("LinearizationParentTree.css") | ||
LinearizationParentCss style(); | ||
|
||
|
||
interface LinearizationParentCss extends CssResource { | ||
|
||
@ClassName("linearizationParentLabel") | ||
String getLinearizationParentLabel(); | ||
@ClassName("parentSelected") | ||
String getParentSelected(); | ||
} | ||
} |
Oops, something went wrong.