Unverified Commit 47310a0f authored by Diego Barreiro Perez's avatar Diego Barreiro Perez Committed by GitHub

Fix Tree Structure (#3038)

parent 0c69abc1
......@@ -11,7 +11,6 @@ import static com.google.appinventor.client.Ode.MESSAGES;
import com.google.appinventor.client.editor.simple.components.MockForm;
import com.google.appinventor.client.explorer.SourceStructureExplorer;
import com.google.appinventor.client.widgets.boxes.Box;
import com.google.appinventor.common.version.AppInventorFeatures;
import com.google.gwt.user.client.ui.DockPanel;
/**
......
......@@ -87,22 +87,27 @@ public abstract class MockContainer extends MockVisibleComponent implements Drop
return layout;
}
@Override
protected TreeItem buildTree() {
return this.buildTree(1);
}
protected TreeItem buildTree(Integer view) {
TreeItem itemNode = super.buildTree();
//hide all containers except form if only nonvisible components are to be shown
//in such a case, we need only the form's treeItem because all non-visible components are attached to it
if (view == 3 && !isForm()) {
itemNode.setVisible(false);
}
itemNode.setVisible(view != 3 || isForm());
// Recursively build the tree for child components
for (MockComponent child : children) {
TreeItem childNode = child.buildTree();
boolean isVisible = true;
if (view == 2 && child instanceof MockNonVisibleComponent) {
childNode.setVisible(false);
isVisible = false;
} else if (view == 3 && child instanceof MockVisibleComponent) {
childNode.setVisible(false);
isVisible = false;
}
childNode.setVisible(isVisible);
itemNode.addItem(childNode);
}
......
......@@ -53,6 +53,8 @@ import java.util.Map;
public final class MockForm extends MockContainer {
private static final Logger LOG = Logger.getLogger(MockForm.class.getName());
private Integer view = 1;
/*
* Widget for the mock form title bar.
*/
......@@ -1341,7 +1343,7 @@ public final class MockForm extends MockContainer {
* @return tree showing the component hierarchy of the form
*/
public TreeItem buildComponentsTree() {
return buildComponentsTree(1);
return buildComponentsTree(view);
}
/**
......@@ -1351,6 +1353,7 @@ public final class MockForm extends MockContainer {
* @return tree showing the component hierarchy of the form
*/
public TreeItem buildComponentsTree(Integer view) {
this.view = view;
return buildTree(view);
}
......
......@@ -174,6 +174,8 @@ public class SourceStructureExplorer extends Composite {
VerticalPanel panel = new VerticalPanel();
panel.add(scrollPanel);
panel.add(new Label());
panel.add(buttonPanel);
panel.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_CENTER);
initWidget(panel);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment