forked from mit-cml/appinventor-sources
-
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.
feat(ui): Allow filtering components in source structure
Introduces a dropdown which allows to select if the source structure box should display all components, only the visible ones or the non visible ones. Change-Id: I1121c78c82a9eddab1abc696d5af865460fcad50
- Loading branch information
1 parent
a699e8c
commit 2b1a9ce
Showing
10 changed files
with
257 additions
and
22 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
24 changes: 24 additions & 0 deletions
24
appinventor/appengine/src/com/google/appinventor/client/boxes/ISourceStructureBox.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,24 @@ | ||
// -*- mode: java; c-basic-offset: 2; -*- | ||
// Copyright 2009-2011 Google, All Rights reserved | ||
// Copyright 2011-2012 MIT, All rights reserved | ||
// Released under the Apache License, Version 2.0 | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package com.google.appinventor.client.boxes; | ||
|
||
import com.google.appinventor.client.editor.simple.components.MockForm; | ||
import com.google.appinventor.client.editor.youngandroid.YaFormEditor; | ||
import com.google.appinventor.client.explorer.SourceStructureExplorer; | ||
|
||
public interface ISourceStructureBox { | ||
/** | ||
* Method to retrieve the rendered source structure explorer from the "child" boxes. | ||
* @return SourceStructureExplorer | ||
*/ | ||
SourceStructureExplorer getSourceStructureExplorer(); | ||
|
||
/** | ||
* Method render the "child" boxes. | ||
*/ | ||
void show(MockForm form); | ||
} |
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
31 changes: 31 additions & 0 deletions
31
appinventor/appengine/src/com/google/appinventor/client/boxes/SourceStructureBoxClassic.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,31 @@ | ||
// -*- mode: java; c-basic-offset: 2; -*- | ||
// Copyright 2009-2011 Google, All Rights reserved | ||
// Copyright 2011-2023 MIT, All rights reserved | ||
// Released under the Apache License, Version 2.0 | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package com.google.appinventor.client.boxes; | ||
|
||
import com.google.appinventor.client.editor.simple.components.MockForm; | ||
import com.google.appinventor.client.explorer.SourceStructureExplorer; | ||
|
||
/** | ||
* Box implementation for source structure explorer (classic style). | ||
*/ | ||
public final class SourceStructureBoxClassic implements ISourceStructureBox { | ||
private final SourceStructureExplorer sourceStructureExplorer = new SourceStructureExplorer(); | ||
|
||
public SourceStructureBoxClassic() { | ||
super(); | ||
} | ||
|
||
public void show(MockForm form) { | ||
sourceStructureExplorer.updateTree(form.buildComponentsTree(), | ||
form.getLastSelectedComponent().getSourceStructureExplorerItem()); | ||
sourceStructureExplorer.setVisible(true); | ||
} | ||
|
||
public SourceStructureExplorer getSourceStructureExplorer() { | ||
return sourceStructureExplorer; | ||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
appinventor/appengine/src/com/google/appinventor/client/boxes/SourceStructureBoxNew.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,114 @@ | ||
// -*- mode: java; c-basic-offset: 2; -*- | ||
// Copyright 2009-2011 Google, All Rights reserved | ||
// Copyright 2011-2023 MIT, All rights reserved | ||
// Released under the Apache License, Version 2.0 | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package com.google.appinventor.client.boxes; | ||
|
||
import com.google.appinventor.client.Ode; | ||
import com.google.appinventor.client.editor.simple.components.MockForm; | ||
import com.google.appinventor.client.editor.youngandroid.YaFormEditor; | ||
import com.google.appinventor.client.explorer.SourceStructureExplorer; | ||
import com.google.appinventor.client.widgets.DropDownButton; | ||
import com.google.appinventor.client.widgets.DropDownItem; | ||
import com.google.gwt.user.client.Command; | ||
import com.google.gwt.user.client.ui.DockPanel; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static com.google.appinventor.client.Ode.MESSAGES; | ||
|
||
/** | ||
* Box implementation for source structure explorer (new style, with filters). | ||
*/ | ||
public final class SourceStructureBoxNew implements ISourceStructureBox { | ||
private Integer view = 1; | ||
|
||
private final DropDownButton dropDownButton; | ||
private final SourceStructureExplorer sourceStructureExplorer = new SourceStructureExplorer(false); | ||
|
||
/** | ||
* Creates new source structure explorer box. | ||
*/ | ||
public SourceStructureBoxNew(SourceStructureBox container) { | ||
super(); | ||
|
||
List<DropDownItem> items = new ArrayList<>(); | ||
items.add(new DropDownItem("AllComponents", MESSAGES.sourceStructureBoxCaptionAll(), new SelectSourceView(1))); | ||
items.add(new DropDownItem("VisibleComponents", MESSAGES.sourceStructureBoxCaptionVisible(), new SelectSourceView(2))); | ||
items.add(new DropDownItem("NonVisibleComponents", MESSAGES.sourceStructureBoxCaptionNonVisible(), new SelectSourceView(3))); | ||
|
||
dropDownButton = new DropDownButton("ComponentsTreeFilter", "", items, false); | ||
dropDownButton.addStyleName("components-tree-filter"); | ||
dropDownButton.setCaption(MESSAGES.sourceStructureBoxCaptionAll()); | ||
|
||
container.getHeaderContainer().clear(); | ||
container.getHeaderContainer().add(dropDownButton, DockPanel.LINE_START); | ||
} | ||
|
||
public void show(MockForm form) { | ||
sourceStructureExplorer.updateTree(form.buildComponentsTree(view), | ||
form.getLastSelectedComponent().getSourceStructureExplorerItem()); | ||
updateSourceDropdownButtonCaption(); | ||
|
||
sourceStructureExplorer.setVisible(true); | ||
} | ||
|
||
public SourceStructureExplorer getSourceStructureExplorer() { | ||
return sourceStructureExplorer; | ||
} | ||
|
||
public void setView(Integer view) { | ||
this.view = view; | ||
} | ||
|
||
public Integer getView() { | ||
return view; | ||
} | ||
|
||
private void updateSourceDropdownButtonCaption() { | ||
String c; | ||
switch (view) { | ||
case 1: | ||
c = MESSAGES.sourceStructureBoxCaptionAll(); | ||
break; | ||
case 2: | ||
c = MESSAGES.sourceStructureBoxCaptionVisible(); | ||
break; | ||
case 3: | ||
c = MESSAGES.sourceStructureBoxCaptionNonVisible(); | ||
break; | ||
default: | ||
c = MESSAGES.sourceStructureBoxCaption(); | ||
break; | ||
} | ||
|
||
dropDownButton.setCaption(c); | ||
} | ||
|
||
private final class SelectSourceView implements Command { | ||
/* 1 - > All components | ||
* 2 - > Visible components | ||
* 3 - > Non-visible components | ||
*/ | ||
private final Integer view; | ||
|
||
SelectSourceView(Integer view) { | ||
super(); | ||
this.view = view; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
MockForm form = ((YaFormEditor) Ode.getInstance().getCurrentFileEditor()).getForm(); | ||
sourceStructureExplorer.updateTree(form.buildComponentsTree(view), | ||
form.getForm().getLastSelectedComponent().getSourceStructureExplorerItem()); | ||
SourceStructureBoxNew.this.setView(view); | ||
|
||
updateSourceDropdownButtonCaption(); | ||
} | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,10 +68,14 @@ public void onBrowserEvent(Event event) { | |
} | ||
} | ||
|
||
public SourceStructureExplorer() { | ||
this(true); | ||
} | ||
|
||
/** | ||
* Creates a new source structure explorer. | ||
*/ | ||
public SourceStructureExplorer() { | ||
public SourceStructureExplorer(boolean includeButtonPanel) { | ||
// Initialize UI elements | ||
tree = new EventCaptureTree(Ode.getImageBundle()); | ||
tree.setAnimationEnabled(true); | ||
|
@@ -174,8 +178,12 @@ public void onClick(ClickEvent event) { | |
|
||
VerticalPanel panel = new VerticalPanel(); | ||
panel.add(scrollPanel); | ||
panel.add(new Label()); | ||
panel.add(buttonPanel); | ||
// TODO([email protected]): With App Inventor's current layout, as of now this is the only place to | ||
// render these buttons... | ||
// if (includeButtonPanel) { | ||
panel.add(new Label()); | ||
panel.add(buttonPanel); | ||
// } | ||
panel.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_CENTER); | ||
initWidget(panel); | ||
} | ||
|
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