You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2011/12/24 17:07:40 UTC
svn commit: r1222994 [6/11] - in /pivot/trunk:
core/test/org/apache/pivot/beans/test/
demos/src/org/apache/pivot/demos/memorygame/
demos/src/org/apache/pivot/demos/memorygame/img/
demos/src/org/apache/pivot/demos/roweditor/ demos/www/ etc/ examples/src...
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/BXMLExplorerWindow.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/BXMLExplorerWindow.java?rev=1222994&r1=1222993&r2=1222994&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/BXMLExplorerWindow.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/BXMLExplorerWindow.java Sat Dec 24 16:07:37 2011
@@ -1,259 +1,259 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pivot.tutorials.bxmlexplorer;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.pivot.beans.BXML;
-import org.apache.pivot.beans.BXMLSerializer;
-import org.apache.pivot.beans.Bindable;
-import org.apache.pivot.collections.Map;
-import org.apache.pivot.serialization.SerializationException;
-import org.apache.pivot.util.Filter;
-import org.apache.pivot.util.Resources;
-import org.apache.pivot.wtk.Action;
-import org.apache.pivot.wtk.Button;
-import org.apache.pivot.wtk.ButtonPressListener;
-import org.apache.pivot.wtk.Component;
-import org.apache.pivot.wtk.FileBrowserSheet;
-import org.apache.pivot.wtk.Menu;
-import org.apache.pivot.wtk.MenuBar;
-import org.apache.pivot.wtk.MenuHandler;
-import org.apache.pivot.wtk.PushButton;
-import org.apache.pivot.wtk.ScrollPane;
-import org.apache.pivot.wtk.Sheet;
-import org.apache.pivot.wtk.SheetCloseListener;
-import org.apache.pivot.wtk.SplitPane;
-import org.apache.pivot.wtk.TabPane;
-import org.apache.pivot.wtk.TextInput;
-import org.apache.pivot.wtk.TextInputContentListener;
-import org.apache.pivot.wtk.TextInputSelectionListener;
-import org.apache.pivot.wtk.Window;
-import org.xml.sax.SAXException;
-
-public class BXMLExplorerWindow extends Window implements Bindable {
- @BXML
- private FileBrowserSheet fileBrowserSheet;
- @BXML
- private TabPane tabPane = null;
- @BXML
- private PushButton closeButton = null;
- @BXML
- private ScrollPane paletteTreeViewScrollPane;
- @BXML
- private TabPane paletteTabPane;
- @BXML
- private SplitPane splitPane;
- @BXML
- private Menu.Section fileMenuSection;
- @BXML
- private Menu.Item fileNewMenuItem;
-
- private MenuHandler menuHandler = new MenuHandler.Adapter() {
- TextInputContentListener textInputTextListener = new TextInputContentListener.Adapter() {
- @Override
- public void textChanged(TextInput textInput) {
- updateActionState(textInput);
- }
- };
-
- TextInputSelectionListener textInputSelectionListener = new TextInputSelectionListener() {
- @Override
- public void selectionChanged(TextInput textInput, int previousSelectionStart,
- int previousSelectionLength) {
- updateActionState(textInput);
- }
- };
-
- @Override
- public void configureMenuBar(Component component, MenuBar menuBar) {
- if (component instanceof TextInput) {
- TextInput textInput = (TextInput) component;
-
- updateActionState(textInput);
- Action.getNamedActions().get("paste").setEnabled(true);
-
- textInput.getTextInputContentListeners().add(textInputTextListener);
- textInput.getTextInputSelectionListeners().add(textInputSelectionListener);
- } else {
- Action.getNamedActions().get("cut").setEnabled(false);
- Action.getNamedActions().get("copy").setEnabled(false);
- Action.getNamedActions().get("paste").setEnabled(false);
- }
- }
-
- @Override
- public void cleanupMenuBar(Component component, MenuBar menuBar) {
- if (component instanceof TextInput) {
- TextInput textInput = (TextInput) component;
- textInput.getTextInputContentListeners().remove(textInputTextListener);
- textInput.getTextInputSelectionListeners().remove(textInputSelectionListener);
- }
- }
-
- private void updateActionState(TextInput textInput) {
- Action.getNamedActions().get("cut").setEnabled(textInput.getSelectionLength() > 0);
- Action.getNamedActions().get("copy").setEnabled(textInput.getSelectionLength() > 0);
- }
- };
-
- public BXMLExplorerWindow() {
- Action.getNamedActions().put("fileNew", new Action() {
- @Override
- public void perform(Component source) {
- BXMLSerializer bxmlSerializer = new BXMLSerializer();
- bxmlSerializer.getNamespace().put("menuHandler", menuHandler);
-
- Component tab;
- try {
- tab = (BXMLExplorerDocument) bxmlSerializer.readObject(
- BXMLExplorerWindow.class, "bxml_explorer_document.bxml");
- } catch (IOException exception) {
- throw new RuntimeException(exception);
- } catch (SerializationException exception) {
- throw new RuntimeException(exception);
- }
-
- tabPane.getTabs().add(tab);
- TabPane.setTabData(tab, "New File " + tabPane.getTabs().getLength());
- tabPane.setSelectedIndex(tabPane.getTabs().getLength() - 1);
- closeButton.setEnabled(true);
- }
- });
-
- Action.getNamedActions().put("fileOpen", new Action() {
- @Override
- public void perform(Component source) {
- fileBrowserSheet.open(BXMLExplorerWindow.this, new SheetCloseListener() {
- @Override
- public void sheetClosed(Sheet sheet) {
- if (!sheet.getResult()) {
- return;
- }
- File f = fileBrowserSheet.getSelectedFile();
-
- // if we have already loaded the file, select the appropriate tab and return
- int idx = 0;
- for (Component comp : tabPane.getTabs()) {
- if (f.equals(((BXMLExplorerDocument) comp).getLoadedFile())) {
- tabPane.setSelectedIndex(idx);
- return;
- }
- idx++;
- }
-
- BXMLSerializer bxmlSerializer = new BXMLSerializer();
- bxmlSerializer.getNamespace().put("menuHandler", menuHandler);
-
- Component tab;
- try {
- BXMLExplorerDocument explorerDoc = (BXMLExplorerDocument) bxmlSerializer.readObject(
- BXMLExplorerWindow.class, "bxml_explorer_document.bxml");
- explorerDoc.load(f);
- tab = explorerDoc;
- } catch (RuntimeException exception) {
- exception.printStackTrace();
- BXMLExplorer.displayLoadException(exception, BXMLExplorerWindow.this);
- return;
- } catch (IOException exception) {
- exception.printStackTrace();
- BXMLExplorer.displayLoadException(exception, BXMLExplorerWindow.this);
- return;
- } catch (SerializationException exception) {
- exception.printStackTrace();
- BXMLExplorer.displayLoadException(exception, BXMLExplorerWindow.this);
- return;
- } catch (ParserConfigurationException exception) {
- exception.printStackTrace();
- BXMLExplorer.displayLoadException(exception, BXMLExplorerWindow.this);
- return;
- } catch (SAXException exception) {
- exception.printStackTrace();
- BXMLExplorer.displayLoadException(exception, BXMLExplorerWindow.this);
- return;
- }
-
- tabPane.getTabs().add(tab);
- TabPane.setTabData(tab, f.getName());
- tabPane.setSelectedIndex(tabPane.getTabs().getLength() - 1);
- closeButton.setEnabled(true);
- }
- });
-
- }
- });
-
- Action.getNamedActions().put("cut", new Action(false) {
- @Override
- public void perform(Component source) {
- TextInput textInput = (TextInput) BXMLExplorerWindow.this.getFocusDescendant();
- textInput.cut();
- }
- });
-
- Action.getNamedActions().put("copy", new Action(false) {
- @Override
- public void perform(Component source) {
- TextInput textInput = (TextInput) BXMLExplorerWindow.this.getFocusDescendant();
- textInput.copy();
- }
- });
-
- Action.getNamedActions().put("paste", new Action(false) {
- @Override
- public void perform(Component source) {
- TextInput textInput = (TextInput) BXMLExplorerWindow.this.getFocusDescendant();
- textInput.paste();
- }
- });
-
- }
-
- @Override
- public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
- // hide until we support editing and saving BXML files
- if (!BXMLExplorer.ENABLE_EDITING) {
- paletteTabPane.getTabs().remove(paletteTreeViewScrollPane);
- splitPane.setSplitRatio(0);
- fileMenuSection.remove(fileNewMenuItem);
- }
-
- fileBrowserSheet.setDisabledFileFilter(new Filter<File>() {
- @Override
- public boolean include(File item) {
- return !(item.isDirectory() || item.getName().endsWith(".bxml"));
- }
- });
- closeButton.setEnabled(false);
- closeButton.getButtonPressListeners().add(new ButtonPressListener() {
- @Override
- public void buttonPressed(Button button) {
- int x = tabPane.getSelectedIndex();
- tabPane.getTabs().remove(x, 1);
- if (tabPane.getTabs().getLength() > 0) {
- x = Math.max(x - 1, 0);
- tabPane.setSelectedIndex(x);
- }
- closeButton.setEnabled(tabPane.getTabs().getLength() > 0);
- }
- });
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.tutorials.bxmlexplorer;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.pivot.beans.BXML;
+import org.apache.pivot.beans.BXMLSerializer;
+import org.apache.pivot.beans.Bindable;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.serialization.SerializationException;
+import org.apache.pivot.util.Filter;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.Action;
+import org.apache.pivot.wtk.Button;
+import org.apache.pivot.wtk.ButtonPressListener;
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.FileBrowserSheet;
+import org.apache.pivot.wtk.Menu;
+import org.apache.pivot.wtk.MenuBar;
+import org.apache.pivot.wtk.MenuHandler;
+import org.apache.pivot.wtk.PushButton;
+import org.apache.pivot.wtk.ScrollPane;
+import org.apache.pivot.wtk.Sheet;
+import org.apache.pivot.wtk.SheetCloseListener;
+import org.apache.pivot.wtk.SplitPane;
+import org.apache.pivot.wtk.TabPane;
+import org.apache.pivot.wtk.TextInput;
+import org.apache.pivot.wtk.TextInputContentListener;
+import org.apache.pivot.wtk.TextInputSelectionListener;
+import org.apache.pivot.wtk.Window;
+import org.xml.sax.SAXException;
+
+public class BXMLExplorerWindow extends Window implements Bindable {
+ @BXML
+ private FileBrowserSheet fileBrowserSheet;
+ @BXML
+ private TabPane tabPane = null;
+ @BXML
+ private PushButton closeButton = null;
+ @BXML
+ private ScrollPane paletteTreeViewScrollPane;
+ @BXML
+ private TabPane paletteTabPane;
+ @BXML
+ private SplitPane splitPane;
+ @BXML
+ private Menu.Section fileMenuSection;
+ @BXML
+ private Menu.Item fileNewMenuItem;
+
+ private MenuHandler menuHandler = new MenuHandler.Adapter() {
+ TextInputContentListener textInputTextListener = new TextInputContentListener.Adapter() {
+ @Override
+ public void textChanged(TextInput textInput) {
+ updateActionState(textInput);
+ }
+ };
+
+ TextInputSelectionListener textInputSelectionListener = new TextInputSelectionListener() {
+ @Override
+ public void selectionChanged(TextInput textInput, int previousSelectionStart,
+ int previousSelectionLength) {
+ updateActionState(textInput);
+ }
+ };
+
+ @Override
+ public void configureMenuBar(Component component, MenuBar menuBar) {
+ if (component instanceof TextInput) {
+ TextInput textInput = (TextInput) component;
+
+ updateActionState(textInput);
+ Action.getNamedActions().get("paste").setEnabled(true);
+
+ textInput.getTextInputContentListeners().add(textInputTextListener);
+ textInput.getTextInputSelectionListeners().add(textInputSelectionListener);
+ } else {
+ Action.getNamedActions().get("cut").setEnabled(false);
+ Action.getNamedActions().get("copy").setEnabled(false);
+ Action.getNamedActions().get("paste").setEnabled(false);
+ }
+ }
+
+ @Override
+ public void cleanupMenuBar(Component component, MenuBar menuBar) {
+ if (component instanceof TextInput) {
+ TextInput textInput = (TextInput) component;
+ textInput.getTextInputContentListeners().remove(textInputTextListener);
+ textInput.getTextInputSelectionListeners().remove(textInputSelectionListener);
+ }
+ }
+
+ private void updateActionState(TextInput textInput) {
+ Action.getNamedActions().get("cut").setEnabled(textInput.getSelectionLength() > 0);
+ Action.getNamedActions().get("copy").setEnabled(textInput.getSelectionLength() > 0);
+ }
+ };
+
+ public BXMLExplorerWindow() {
+ Action.getNamedActions().put("fileNew", new Action() {
+ @Override
+ public void perform(Component source) {
+ BXMLSerializer bxmlSerializer = new BXMLSerializer();
+ bxmlSerializer.getNamespace().put("menuHandler", menuHandler);
+
+ Component tab;
+ try {
+ tab = (BXMLExplorerDocument) bxmlSerializer.readObject(
+ BXMLExplorerWindow.class, "bxml_explorer_document.bxml");
+ } catch (IOException exception) {
+ throw new RuntimeException(exception);
+ } catch (SerializationException exception) {
+ throw new RuntimeException(exception);
+ }
+
+ tabPane.getTabs().add(tab);
+ TabPane.setTabData(tab, "New File " + tabPane.getTabs().getLength());
+ tabPane.setSelectedIndex(tabPane.getTabs().getLength() - 1);
+ closeButton.setEnabled(true);
+ }
+ });
+
+ Action.getNamedActions().put("fileOpen", new Action() {
+ @Override
+ public void perform(Component source) {
+ fileBrowserSheet.open(BXMLExplorerWindow.this, new SheetCloseListener() {
+ @Override
+ public void sheetClosed(Sheet sheet) {
+ if (!sheet.getResult()) {
+ return;
+ }
+ File f = fileBrowserSheet.getSelectedFile();
+
+ // if we have already loaded the file, select the appropriate tab and return
+ int idx = 0;
+ for (Component comp : tabPane.getTabs()) {
+ if (f.equals(((BXMLExplorerDocument) comp).getLoadedFile())) {
+ tabPane.setSelectedIndex(idx);
+ return;
+ }
+ idx++;
+ }
+
+ BXMLSerializer bxmlSerializer = new BXMLSerializer();
+ bxmlSerializer.getNamespace().put("menuHandler", menuHandler);
+
+ Component tab;
+ try {
+ BXMLExplorerDocument explorerDoc = (BXMLExplorerDocument) bxmlSerializer.readObject(
+ BXMLExplorerWindow.class, "bxml_explorer_document.bxml");
+ explorerDoc.load(f);
+ tab = explorerDoc;
+ } catch (RuntimeException exception) {
+ exception.printStackTrace();
+ BXMLExplorer.displayLoadException(exception, BXMLExplorerWindow.this);
+ return;
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ BXMLExplorer.displayLoadException(exception, BXMLExplorerWindow.this);
+ return;
+ } catch (SerializationException exception) {
+ exception.printStackTrace();
+ BXMLExplorer.displayLoadException(exception, BXMLExplorerWindow.this);
+ return;
+ } catch (ParserConfigurationException exception) {
+ exception.printStackTrace();
+ BXMLExplorer.displayLoadException(exception, BXMLExplorerWindow.this);
+ return;
+ } catch (SAXException exception) {
+ exception.printStackTrace();
+ BXMLExplorer.displayLoadException(exception, BXMLExplorerWindow.this);
+ return;
+ }
+
+ tabPane.getTabs().add(tab);
+ TabPane.setTabData(tab, f.getName());
+ tabPane.setSelectedIndex(tabPane.getTabs().getLength() - 1);
+ closeButton.setEnabled(true);
+ }
+ });
+
+ }
+ });
+
+ Action.getNamedActions().put("cut", new Action(false) {
+ @Override
+ public void perform(Component source) {
+ TextInput textInput = (TextInput) BXMLExplorerWindow.this.getFocusDescendant();
+ textInput.cut();
+ }
+ });
+
+ Action.getNamedActions().put("copy", new Action(false) {
+ @Override
+ public void perform(Component source) {
+ TextInput textInput = (TextInput) BXMLExplorerWindow.this.getFocusDescendant();
+ textInput.copy();
+ }
+ });
+
+ Action.getNamedActions().put("paste", new Action(false) {
+ @Override
+ public void perform(Component source) {
+ TextInput textInput = (TextInput) BXMLExplorerWindow.this.getFocusDescendant();
+ textInput.paste();
+ }
+ });
+
+ }
+
+ @Override
+ public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
+ // hide until we support editing and saving BXML files
+ if (!BXMLExplorer.ENABLE_EDITING) {
+ paletteTabPane.getTabs().remove(paletteTreeViewScrollPane);
+ splitPane.setSplitRatio(0);
+ fileMenuSection.remove(fileNewMenuItem);
+ }
+
+ fileBrowserSheet.setDisabledFileFilter(new Filter<File>() {
+ @Override
+ public boolean include(File item) {
+ return !(item.isDirectory() || item.getName().endsWith(".bxml"));
+ }
+ });
+ closeButton.setEnabled(false);
+ closeButton.getButtonPressListeners().add(new ButtonPressListener() {
+ @Override
+ public void buttonPressed(Button button) {
+ int x = tabPane.getSelectedIndex();
+ tabPane.getTabs().remove(x, 1);
+ if (tabPane.getTabs().getLength() > 0) {
+ x = Math.max(x - 1, 0);
+ tabPane.setSelectedIndex(x);
+ }
+ closeButton.setEnabled(tabPane.getTabs().getLength() > 0);
+ }
+ });
+ }
+}
Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/BXMLExplorerWindow.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/ComponentNode.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/ComponentNode.java?rev=1222994&r1=1222993&r2=1222994&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/ComponentNode.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/ComponentNode.java Sat Dec 24 16:07:37 2011
@@ -1,59 +1,59 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pivot.tutorials.bxmlexplorer;
-
-import java.net.URL;
-
-import org.apache.pivot.wtk.ScrollPane.ScrollBarPolicy;
-import org.apache.pivot.wtk.content.TreeNode;
-
-/**
- * Node in the component explorer's tree view that represents a component type.
- */
-public class ComponentNode extends TreeNode {
- private URL src = null;
- private ScrollBarPolicy horizontalScrollBarPolicy = ScrollBarPolicy.FILL;
- private ScrollBarPolicy verticalScrollBarPolicy = ScrollBarPolicy.FILL;
-
- public ComponentNode() {
- setIcon(ComponentNode.class.getResource("/org/apache/pivot/tutorials/page_white.png"));
- }
-
- public URL getSrc() {
- return src;
- }
-
- public void setSrc(URL src) {
- this.src = src;
- }
-
- public ScrollBarPolicy getHorizontalScrollBarPolicy() {
- return horizontalScrollBarPolicy;
- }
-
- public void setHorizontalScrollBarPolicy(ScrollBarPolicy horizontalScrollBarPolicy) {
- this.horizontalScrollBarPolicy = horizontalScrollBarPolicy;
- }
-
- public ScrollBarPolicy getVerticalScrollBarPolicy() {
- return verticalScrollBarPolicy;
- }
-
- public void setVerticalScrollBarPolicy(ScrollBarPolicy verticalScrollBarPolicy) {
- this.verticalScrollBarPolicy = verticalScrollBarPolicy;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.tutorials.bxmlexplorer;
+
+import java.net.URL;
+
+import org.apache.pivot.wtk.ScrollPane.ScrollBarPolicy;
+import org.apache.pivot.wtk.content.TreeNode;
+
+/**
+ * Node in the component explorer's tree view that represents a component type.
+ */
+public class ComponentNode extends TreeNode {
+ private URL src = null;
+ private ScrollBarPolicy horizontalScrollBarPolicy = ScrollBarPolicy.FILL;
+ private ScrollBarPolicy verticalScrollBarPolicy = ScrollBarPolicy.FILL;
+
+ public ComponentNode() {
+ setIcon(ComponentNode.class.getResource("/org/apache/pivot/tutorials/page_white.png"));
+ }
+
+ public URL getSrc() {
+ return src;
+ }
+
+ public void setSrc(URL src) {
+ this.src = src;
+ }
+
+ public ScrollBarPolicy getHorizontalScrollBarPolicy() {
+ return horizontalScrollBarPolicy;
+ }
+
+ public void setHorizontalScrollBarPolicy(ScrollBarPolicy horizontalScrollBarPolicy) {
+ this.horizontalScrollBarPolicy = horizontalScrollBarPolicy;
+ }
+
+ public ScrollBarPolicy getVerticalScrollBarPolicy() {
+ return verticalScrollBarPolicy;
+ }
+
+ public void setVerticalScrollBarPolicy(ScrollBarPolicy verticalScrollBarPolicy) {
+ this.verticalScrollBarPolicy = verticalScrollBarPolicy;
+ }
+}
Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/ComponentNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.bxml?rev=1222994&r1=1222993&r2=1222994&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.bxml (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.bxml Sat Dec 24 16:07:37 2011
@@ -1,40 +1,40 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to you under the Apache License,
-Version 2.0 (the "License"); you may not use this file except in
-compliance with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-<!-- Used to test the XML highlighting -->
-<Window title="Text Areas" maximized="true"
- xmlns:bxml="http://pivot.apache.org/bxml"
- xmlns="org.apache.pivot.wtk">
- <Border styles="{padding:6}">
- <TablePane>
- <columns>
- <TablePane.Column width="1*"/>
- </columns>
- <TablePane.Row height="1*">
- <Border styles="{color:10}">
- <ScrollPane horizontalScrollBarPolicy="fill"
- verticalScrollBarPolicy="fill_to_capacity"
- preferredHeight="240">
- <TextPane bxml:id="textPane" styles="{margin:10, wrapText:true}">
- </TextPane>
- </ScrollPane>
- </Border>
- </TablePane.Row>
- </TablePane>
- </Border>
-</Window>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<!-- Used to test the XML highlighting -->
+<Window title="Text Areas" maximized="true"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns="org.apache.pivot.wtk">
+ <Border styles="{padding:6}">
+ <TablePane>
+ <columns>
+ <TablePane.Column width="1*"/>
+ </columns>
+ <TablePane.Row height="1*">
+ <Border styles="{color:10}">
+ <ScrollPane horizontalScrollBarPolicy="fill"
+ verticalScrollBarPolicy="fill_to_capacity"
+ preferredHeight="240">
+ <TextPane bxml:id="textPane" styles="{margin:10, wrapText:true}">
+ </TextPane>
+ </ScrollPane>
+ </Border>
+ </TablePane.Row>
+ </TablePane>
+ </Border>
+</Window>
Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.bxml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.bxml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.java?rev=1222994&r1=1222993&r2=1222994&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.java Sat Dec 24 16:07:37 2011
@@ -1,160 +1,160 @@
-package org.apache.pivot.tutorials.bxmlexplorer;
-
-import java.awt.Color;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.pivot.beans.BXMLSerializer;
-import org.apache.pivot.collections.Map;
-import org.apache.pivot.wtk.Application;
-import org.apache.pivot.wtk.DesktopApplicationContext;
-import org.apache.pivot.wtk.Display;
-import org.apache.pivot.wtk.TextPane;
-import org.apache.pivot.wtk.Window;
-import org.apache.pivot.wtk.text.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- * Create a nicely syntax highlighted version of the BXML document.
- */
-public class CreateHighlightedXML {
-
- private static final Color ELEMENT_COLOR = new Color(63, 127, 127);
- private static final Color ATTR_NAME_COLOR = new Color(127, 0, 127);
- private static final Color ATTR_VALUE_COLOR = new Color(42, 0, 255);
- private static final Color ATTR_EQUALS_COLOR = new Color(0, 0, 0);
-
- private final org.apache.pivot.wtk.text.Document textPaneDocument = new org.apache.pivot.wtk.text.Document();
- private org.apache.pivot.wtk.text.Paragraph currentParagraph = new org.apache.pivot.wtk.text.Paragraph();
-
- public org.apache.pivot.wtk.text.Document prettyPrint(InputStream reader)
- throws ParserConfigurationException, SAXException, IOException {
- final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
- org.w3c.dom.Document doc = documentBuilder.parse(reader);
-
- return prettyPrint(doc);
- }
-
- private org.apache.pivot.wtk.text.Document prettyPrint(final org.w3c.dom.Document domDocument) {
- org.w3c.dom.Element domElement = domDocument.getDocumentElement();
- prettyPrint(domElement, 0);
- textPaneDocument.add(currentParagraph);
- return textPaneDocument;
- }
-
- private void prettyPrint(org.w3c.dom.Element domElement, int indent) {
- newLine();
- indent++;
- add(createIndent(indent));
-
- add(ELEMENT_COLOR, "<" + domElement.getNodeName());
-
- final NamedNodeMap attributes = domElement.getAttributes();
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- org.w3c.dom.Attr attr = (org.w3c.dom.Attr) attributes.item(i);
- String attributeName = "";
- String prefix2 = attr.getPrefix();
- if (prefix2 != null && prefix2.length() > 0) {
- attributeName += prefix2 + ":";
- }
- attributeName += attr.getNodeName();
- add(ATTR_NAME_COLOR, " " + attributeName);
- add(ATTR_EQUALS_COLOR, "=");
- add(ATTR_VALUE_COLOR, "\"" + attr.getValue() + "\"");
- }
- }
-
- if (!domElement.hasChildNodes()) {
- add(ELEMENT_COLOR, "/>");
- } else {
- add(ELEMENT_COLOR, ">");
- final NodeList childNodes = domElement.getChildNodes();
- for (int i = 0; i < childNodes.getLength(); i++) {
- org.w3c.dom.Node node = childNodes.item(i);
- if (node instanceof org.w3c.dom.Element) {
- prettyPrint((org.w3c.dom.Element) node, indent);
- }
- }
- newLine();
- add(createIndent(indent));
- add(ELEMENT_COLOR, "</" + domElement.getNodeName() + ">");
- }
- indent--;
- }
-
- private void newLine() {
- textPaneDocument.add(currentParagraph);
- currentParagraph = new org.apache.pivot.wtk.text.Paragraph();
- }
-
- private void add(Color color, String buf) {
- final org.apache.pivot.wtk.text.TextSpan textSpan = new org.apache.pivot.wtk.text.TextSpan();
- textSpan.setForegroundColor(color);
- textSpan.add(buf);
- currentParagraph.add(textSpan);
- }
-
- private void add(String buf) {
- final org.apache.pivot.wtk.text.TextSpan textSpan = new org.apache.pivot.wtk.text.TextSpan();
- textSpan.add(buf);
- currentParagraph.add(textSpan);
- }
-
- private static String createIndent(int indent) {
- StringBuilder buf = new StringBuilder();
- for (int i = 0; i < indent; i++) {
- buf.append(" ");
- }
- return buf.toString();
- }
-
- public static void main(String[] args) throws Exception {
- DesktopApplicationContext.main(TestApplication.class, args);
- }
-
- public static final class TestApplication implements Application {
- private Window window = null;
-
- @Override
- public void startup(Display display, Map<String, String> properties) throws Exception {
-
- CreateHighlightedXML xml = new CreateHighlightedXML();
- Document doc = xml.prettyPrint(CreateHighlightedXML.class.getResourceAsStream("builder-test1.bxml"));
-
- BXMLSerializer bxmlSerializer = new BXMLSerializer();
- window = (Window) bxmlSerializer.readObject(BXMLExplorer.class,
- "CreateHighlightedXml.bxml", true);
-
- TextPane textPane = (TextPane) bxmlSerializer.getNamespace().get("textPane");
- textPane.setDocument(doc);
-
- window.open(display);
- }
-
- @Override
- public boolean shutdown(boolean optional) {
- if (window != null) {
- window.close();
- }
-
- return false;
- }
-
- @Override
- public void resume() throws Exception {
- }
-
- @Override
- public void suspend() throws Exception {
- }
- }
-
-}
+package org.apache.pivot.tutorials.bxmlexplorer;
+
+import java.awt.Color;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.pivot.beans.BXMLSerializer;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.DesktopApplicationContext;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.TextPane;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtk.text.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * Create a nicely syntax highlighted version of the BXML document.
+ */
+public class CreateHighlightedXML {
+
+ private static final Color ELEMENT_COLOR = new Color(63, 127, 127);
+ private static final Color ATTR_NAME_COLOR = new Color(127, 0, 127);
+ private static final Color ATTR_VALUE_COLOR = new Color(42, 0, 255);
+ private static final Color ATTR_EQUALS_COLOR = new Color(0, 0, 0);
+
+ private final org.apache.pivot.wtk.text.Document textPaneDocument = new org.apache.pivot.wtk.text.Document();
+ private org.apache.pivot.wtk.text.Paragraph currentParagraph = new org.apache.pivot.wtk.text.Paragraph();
+
+ public org.apache.pivot.wtk.text.Document prettyPrint(InputStream reader)
+ throws ParserConfigurationException, SAXException, IOException {
+ final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ org.w3c.dom.Document doc = documentBuilder.parse(reader);
+
+ return prettyPrint(doc);
+ }
+
+ private org.apache.pivot.wtk.text.Document prettyPrint(final org.w3c.dom.Document domDocument) {
+ org.w3c.dom.Element domElement = domDocument.getDocumentElement();
+ prettyPrint(domElement, 0);
+ textPaneDocument.add(currentParagraph);
+ return textPaneDocument;
+ }
+
+ private void prettyPrint(org.w3c.dom.Element domElement, int indent) {
+ newLine();
+ indent++;
+ add(createIndent(indent));
+
+ add(ELEMENT_COLOR, "<" + domElement.getNodeName());
+
+ final NamedNodeMap attributes = domElement.getAttributes();
+ if (attributes != null) {
+ for (int i = 0; i < attributes.getLength(); i++) {
+ org.w3c.dom.Attr attr = (org.w3c.dom.Attr) attributes.item(i);
+ String attributeName = "";
+ String prefix2 = attr.getPrefix();
+ if (prefix2 != null && prefix2.length() > 0) {
+ attributeName += prefix2 + ":";
+ }
+ attributeName += attr.getNodeName();
+ add(ATTR_NAME_COLOR, " " + attributeName);
+ add(ATTR_EQUALS_COLOR, "=");
+ add(ATTR_VALUE_COLOR, "\"" + attr.getValue() + "\"");
+ }
+ }
+
+ if (!domElement.hasChildNodes()) {
+ add(ELEMENT_COLOR, "/>");
+ } else {
+ add(ELEMENT_COLOR, ">");
+ final NodeList childNodes = domElement.getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ org.w3c.dom.Node node = childNodes.item(i);
+ if (node instanceof org.w3c.dom.Element) {
+ prettyPrint((org.w3c.dom.Element) node, indent);
+ }
+ }
+ newLine();
+ add(createIndent(indent));
+ add(ELEMENT_COLOR, "</" + domElement.getNodeName() + ">");
+ }
+ indent--;
+ }
+
+ private void newLine() {
+ textPaneDocument.add(currentParagraph);
+ currentParagraph = new org.apache.pivot.wtk.text.Paragraph();
+ }
+
+ private void add(Color color, String buf) {
+ final org.apache.pivot.wtk.text.TextSpan textSpan = new org.apache.pivot.wtk.text.TextSpan();
+ textSpan.setForegroundColor(color);
+ textSpan.add(buf);
+ currentParagraph.add(textSpan);
+ }
+
+ private void add(String buf) {
+ final org.apache.pivot.wtk.text.TextSpan textSpan = new org.apache.pivot.wtk.text.TextSpan();
+ textSpan.add(buf);
+ currentParagraph.add(textSpan);
+ }
+
+ private static String createIndent(int indent) {
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < indent; i++) {
+ buf.append(" ");
+ }
+ return buf.toString();
+ }
+
+ public static void main(String[] args) throws Exception {
+ DesktopApplicationContext.main(TestApplication.class, args);
+ }
+
+ public static final class TestApplication implements Application {
+ private Window window = null;
+
+ @Override
+ public void startup(Display display, Map<String, String> properties) throws Exception {
+
+ CreateHighlightedXML xml = new CreateHighlightedXML();
+ Document doc = xml.prettyPrint(CreateHighlightedXML.class.getResourceAsStream("builder-test1.bxml"));
+
+ BXMLSerializer bxmlSerializer = new BXMLSerializer();
+ window = (Window) bxmlSerializer.readObject(BXMLExplorer.class,
+ "CreateHighlightedXml.bxml", true);
+
+ TextPane textPane = (TextPane) bxmlSerializer.getNamespace().get("textPane");
+ textPane.setDocument(doc);
+
+ window.open(display);
+ }
+
+ @Override
+ public boolean shutdown(boolean optional) {
+ if (window != null) {
+ window.close();
+ }
+
+ return false;
+ }
+
+ @Override
+ public void resume() throws Exception {
+ }
+
+ @Override
+ public void suspend() throws Exception {
+ }
+ }
+
+}
Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/CreateHighlightedXML.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindow.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindow.java?rev=1222994&r1=1222993&r2=1222994&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindow.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindow.java Sat Dec 24 16:07:37 2011
@@ -1,160 +1,160 @@
-package org.apache.pivot.tutorials.bxmlexplorer;
-
-import java.net.URL;
-
-import org.apache.pivot.beans.DefaultProperty;
-import org.apache.pivot.collections.Sequence;
-import org.apache.pivot.util.ListenerList;
-import org.apache.pivot.wtk.Component;
-import org.apache.pivot.wtk.Container;
-import org.apache.pivot.wtk.WTKListenerList;
-import org.apache.pivot.wtk.Window;
-import org.apache.pivot.wtk.Window.IconImageSequence;
-import org.apache.pivot.wtk.WindowListener;
-import org.apache.pivot.wtk.media.Image;
-
-/**
- * Because we can't render a real Window object inside our container, create a fake window
- * that looks mostly like a real window.
- */
-@DefaultProperty("content")
-public class FakeWindow extends Container {
-
- private static class FakeWindowListenerList extends WTKListenerList<FakeWindowListener>
- implements FakeWindowListener {
- @Override
- public void titleChanged(FakeWindow window, String previousTitle) {
- for (FakeWindowListener listener : this) {
- listener.titleChanged(window, previousTitle);
- }
- }
-
- @Override
- public void iconAdded(FakeWindow window, Image addedIcon) {
- for (FakeWindowListener listener : this) {
- listener.iconAdded(window, addedIcon);
- }
- }
-
- @Override
- public void iconInserted(FakeWindow window, Image addedIcon, int index) {
- for (FakeWindowListener listener : this) {
- listener.iconInserted(window, addedIcon, index);
- }
- }
-
- @Override
- public void iconsRemoved(FakeWindow window, int index, Sequence<Image> removed) {
- for (FakeWindowListener listener : this) {
- listener.iconsRemoved(window, index, removed);
- }
- }
-
- @Override
- public void contentChanged(FakeWindow window, Component previousContent) {
- for (FakeWindowListener listener : this) {
- listener.contentChanged(window, previousContent);
- }
- }
-
- }
-
- private FakeWindowListenerList windowListeners = new FakeWindowListenerList();
-
- private Component content = null;
-
- public final Window window;
-
- public FakeWindow(Window _window) {
- Component content = _window.getContent();
- _window.setContent(null);
- this.window = _window;
- window.getWindowListeners().add(new WindowListener() {
-
- @Override
- public void titleChanged(Window window, String previousTitle) {
- windowListeners.titleChanged(FakeWindow.this, previousTitle);
- }
-
- @Override
- public void iconAdded(Window window, Image addedIcon) {
- windowListeners.iconAdded(FakeWindow.this, addedIcon);
- }
-
- @Override
- public void iconInserted(Window window, Image addedIcon, int index) {
- windowListeners.iconInserted(FakeWindow.this, addedIcon, index);
- }
-
- @Override
- public void iconsRemoved(Window window, int index, Sequence<Image> removed) {
- windowListeners.iconsRemoved(FakeWindow.this, index, removed);
- }
-
- @Override
- public void contentChanged(Window window, Component previousContent) {
- windowListeners.contentChanged(FakeWindow.this, previousContent);
- }
-
- @Override
- public void activeChanged(Window window, Window obverseWindow) {
- }
-
- @Override
- public void maximizedChanged(Window window) {
- }
- });
- setContent(content);
- setSkin(new FakeWindowSkin());
- }
-
- public IconImageSequence getIcons() {
- return window.getIcons();
- }
-
- public void setIcon(URL iconURL) {
- window.setIcon(iconURL);
- }
-
- public void setIcon(String iconName) {
- window.setIcon(iconName);
- }
-
- public String getTitle() {
- return window.getTitle();
- }
-
- public void setTitle(String title) {
- window.setTitle(title);
- }
-
- public ListenerList<FakeWindowListener> getWindowListeners() {
- return windowListeners;
- }
-
- public Component getContent() {
- return content;
- }
-
- public void setContent(Component content) {
- Component previousContent = this.content;
-
- if (content != previousContent) {
- this.content = null;
-
- // Remove any previous content component
- if (previousContent != null) {
- remove(previousContent);
- }
-
- // Add the component
- if (content != null) {
- insert(content, 0);
- }
-
- this.content = content;
-
- windowListeners.contentChanged(this, previousContent);
- }
- }
-}
+package org.apache.pivot.tutorials.bxmlexplorer;
+
+import java.net.URL;
+
+import org.apache.pivot.beans.DefaultProperty;
+import org.apache.pivot.collections.Sequence;
+import org.apache.pivot.util.ListenerList;
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.Container;
+import org.apache.pivot.wtk.WTKListenerList;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtk.Window.IconImageSequence;
+import org.apache.pivot.wtk.WindowListener;
+import org.apache.pivot.wtk.media.Image;
+
+/**
+ * Because we can't render a real Window object inside our container, create a fake window
+ * that looks mostly like a real window.
+ */
+@DefaultProperty("content")
+public class FakeWindow extends Container {
+
+ private static class FakeWindowListenerList extends WTKListenerList<FakeWindowListener>
+ implements FakeWindowListener {
+ @Override
+ public void titleChanged(FakeWindow window, String previousTitle) {
+ for (FakeWindowListener listener : this) {
+ listener.titleChanged(window, previousTitle);
+ }
+ }
+
+ @Override
+ public void iconAdded(FakeWindow window, Image addedIcon) {
+ for (FakeWindowListener listener : this) {
+ listener.iconAdded(window, addedIcon);
+ }
+ }
+
+ @Override
+ public void iconInserted(FakeWindow window, Image addedIcon, int index) {
+ for (FakeWindowListener listener : this) {
+ listener.iconInserted(window, addedIcon, index);
+ }
+ }
+
+ @Override
+ public void iconsRemoved(FakeWindow window, int index, Sequence<Image> removed) {
+ for (FakeWindowListener listener : this) {
+ listener.iconsRemoved(window, index, removed);
+ }
+ }
+
+ @Override
+ public void contentChanged(FakeWindow window, Component previousContent) {
+ for (FakeWindowListener listener : this) {
+ listener.contentChanged(window, previousContent);
+ }
+ }
+
+ }
+
+ private FakeWindowListenerList windowListeners = new FakeWindowListenerList();
+
+ private Component content = null;
+
+ public final Window window;
+
+ public FakeWindow(Window _window) {
+ Component content = _window.getContent();
+ _window.setContent(null);
+ this.window = _window;
+ window.getWindowListeners().add(new WindowListener() {
+
+ @Override
+ public void titleChanged(Window window, String previousTitle) {
+ windowListeners.titleChanged(FakeWindow.this, previousTitle);
+ }
+
+ @Override
+ public void iconAdded(Window window, Image addedIcon) {
+ windowListeners.iconAdded(FakeWindow.this, addedIcon);
+ }
+
+ @Override
+ public void iconInserted(Window window, Image addedIcon, int index) {
+ windowListeners.iconInserted(FakeWindow.this, addedIcon, index);
+ }
+
+ @Override
+ public void iconsRemoved(Window window, int index, Sequence<Image> removed) {
+ windowListeners.iconsRemoved(FakeWindow.this, index, removed);
+ }
+
+ @Override
+ public void contentChanged(Window window, Component previousContent) {
+ windowListeners.contentChanged(FakeWindow.this, previousContent);
+ }
+
+ @Override
+ public void activeChanged(Window window, Window obverseWindow) {
+ }
+
+ @Override
+ public void maximizedChanged(Window window) {
+ }
+ });
+ setContent(content);
+ setSkin(new FakeWindowSkin());
+ }
+
+ public IconImageSequence getIcons() {
+ return window.getIcons();
+ }
+
+ public void setIcon(URL iconURL) {
+ window.setIcon(iconURL);
+ }
+
+ public void setIcon(String iconName) {
+ window.setIcon(iconName);
+ }
+
+ public String getTitle() {
+ return window.getTitle();
+ }
+
+ public void setTitle(String title) {
+ window.setTitle(title);
+ }
+
+ public ListenerList<FakeWindowListener> getWindowListeners() {
+ return windowListeners;
+ }
+
+ public Component getContent() {
+ return content;
+ }
+
+ public void setContent(Component content) {
+ Component previousContent = this.content;
+
+ if (content != previousContent) {
+ this.content = null;
+
+ // Remove any previous content component
+ if (previousContent != null) {
+ remove(previousContent);
+ }
+
+ // Add the component
+ if (content != null) {
+ insert(content, 0);
+ }
+
+ this.content = content;
+
+ windowListeners.contentChanged(this, previousContent);
+ }
+ }
+}
Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindow.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowListener.java?rev=1222994&r1=1222993&r2=1222994&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowListener.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowListener.java Sat Dec 24 16:07:37 2011
@@ -1,75 +1,75 @@
-package org.apache.pivot.tutorials.bxmlexplorer;
-
-import org.apache.pivot.collections.Sequence;
-import org.apache.pivot.wtk.Component;
-import org.apache.pivot.wtk.media.Image;
-
-public interface FakeWindowListener {
- /**
- * Window listener adapter.
- */
- public static class Adapter implements FakeWindowListener {
- @Override
- public void titleChanged(FakeWindow window, String previousTitle) {
- }
-
- @Override
- public void iconAdded(FakeWindow window, Image addedIcon) {
- }
-
- @Override
- public void iconInserted(FakeWindow window, Image addedIcon, int index) {
- }
-
- @Override
- public void iconsRemoved(FakeWindow window, int index, Sequence<Image> removed) {
- }
-
- @Override
- public void contentChanged(FakeWindow window, Component previousContent) {
- }
-
- }
-
- /**
- * Called when a window's title has changed.
- *
- * @param window
- * @param previousTitle
- */
- public void titleChanged(FakeWindow window, String previousTitle);
-
- /**
- * Called when a window's icon has changed.
- *
- * @param window
- * @param addedIcon
- */
- public void iconAdded(FakeWindow window, Image addedIcon);
-
- /**
- * Called when a window's icon has changed.
- *
- * @param window
- * @param addedIcon
- */
- public void iconInserted(FakeWindow window, Image addedIcon, int index);
-
- /**
- * Called when a window's icon has changed.
- *
- * @param window
- * @param index
- * @param removed
- */
- public void iconsRemoved(FakeWindow window, int index, Sequence<Image> removed);
-
- /**
- * Called when a window's content component has changed.
- *
- * @param window
- * @param previousContent
- */
- public void contentChanged(FakeWindow window, Component previousContent);
-
-}
+package org.apache.pivot.tutorials.bxmlexplorer;
+
+import org.apache.pivot.collections.Sequence;
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.media.Image;
+
+public interface FakeWindowListener {
+ /**
+ * Window listener adapter.
+ */
+ public static class Adapter implements FakeWindowListener {
+ @Override
+ public void titleChanged(FakeWindow window, String previousTitle) {
+ }
+
+ @Override
+ public void iconAdded(FakeWindow window, Image addedIcon) {
+ }
+
+ @Override
+ public void iconInserted(FakeWindow window, Image addedIcon, int index) {
+ }
+
+ @Override
+ public void iconsRemoved(FakeWindow window, int index, Sequence<Image> removed) {
+ }
+
+ @Override
+ public void contentChanged(FakeWindow window, Component previousContent) {
+ }
+
+ }
+
+ /**
+ * Called when a window's title has changed.
+ *
+ * @param window
+ * @param previousTitle
+ */
+ public void titleChanged(FakeWindow window, String previousTitle);
+
+ /**
+ * Called when a window's icon has changed.
+ *
+ * @param window
+ * @param addedIcon
+ */
+ public void iconAdded(FakeWindow window, Image addedIcon);
+
+ /**
+ * Called when a window's icon has changed.
+ *
+ * @param window
+ * @param addedIcon
+ */
+ public void iconInserted(FakeWindow window, Image addedIcon, int index);
+
+ /**
+ * Called when a window's icon has changed.
+ *
+ * @param window
+ * @param index
+ * @param removed
+ */
+ public void iconsRemoved(FakeWindow window, int index, Sequence<Image> removed);
+
+ /**
+ * Called when a window's content component has changed.
+ *
+ * @param window
+ * @param previousContent
+ */
+ public void contentChanged(FakeWindow window, Component previousContent);
+
+}
Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowListener.java
------------------------------------------------------------------------------
svn:eol-style = native