You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/09/10 23:48:20 UTC
svn commit: r813600 - in /incubator/pivot/trunk:
tutorials/src/org/apache/pivot/tutorials/menus/
wtk/src/org/apache/pivot/wtk/skin/terra/
Author: gbrown
Date: Thu Sep 10 21:48:19 2009
New Revision: 813600
URL: http://svn.apache.org/viewvc?rev=813600&view=rev
Log:
Finish menu bar tutorial; add placeholder context menu tutorial; fix minor repaint bug in TerraMenuButtonSkin.
Added:
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/ContextMenus.java
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java
- copied, changed from r813552, incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/Menus.java
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/context_menus.wtkx
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.wtkx
- copied, changed from r813552, incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menus.wtkx
Removed:
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/Menus.java
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menus.wtkx
Modified:
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/document.wtkx
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/ContextMenus.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/ContextMenus.java?rev=813600&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/ContextMenus.java (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/ContextMenus.java Thu Sep 10 21:48:19 2009
@@ -0,0 +1,54 @@
+/*
+ * 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.menus;
+
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtkx.WTKXSerializer;
+
+public class ContextMenus implements Application {
+ private Window window = null;
+
+ @Override
+ public void startup(Display display, Map<String, String> properties) throws Exception {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ window = (Window)wtkxSerializer.readObject(this, "context_menus.wtkx");
+
+ // TODO
+
+ window.open(display);
+ }
+
+ @Override
+ public boolean shutdown(boolean optional) {
+ if (window != null) {
+ window.close();
+ }
+
+ return false;
+ }
+
+ @Override
+ public void suspend() {
+ }
+
+ @Override
+ public void resume() {
+ }
+}
Copied: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java (from r813552, incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/Menus.java)
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java?p2=incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java&p1=incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/Menus.java&r1=813552&r2=813600&rev=813600&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/Menus.java (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java Thu Sep 10 21:48:19 2009
@@ -16,31 +16,65 @@
*/
package org.apache.pivot.tutorials.menus;
+import java.io.IOException;
+
import org.apache.pivot.collections.Map;
+import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.wtk.Action;
import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.Border;
+import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.FileBrowserSheet;
-import org.apache.pivot.wtk.Panel;
+import org.apache.pivot.wtk.MenuBar;
+import org.apache.pivot.wtk.MenuHandler;
+import org.apache.pivot.wtk.PushButton;
import org.apache.pivot.wtk.TabPane;
import org.apache.pivot.wtk.TextInput;
import org.apache.pivot.wtk.Window;
import org.apache.pivot.wtkx.WTKXSerializer;
-public class Menus implements Application {
+public class MenuBars implements Application {
private Window window = null;
private TabPane tabPane = null;
- public Menus() {
+ private MenuHandler menuHandler = new MenuHandler.Adapter() {
+ @Override
+ public void configureMenuBar(Component component, MenuBar menuBar) {
+ boolean enabled = (component instanceof TextInput);
+
+ Action.getNamedActions().get("cut").setEnabled(enabled);
+ Action.getNamedActions().get("copy").setEnabled(enabled);
+ Action.getNamedActions().get("paste").setEnabled(enabled);
+ }
+ };
+
+ public MenuBars() {
Action.getNamedActions().put("fileNew", new Action() {
@Override
public void perform() {
- // TODO Read document.wtkx
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ Component tab;
+ try {
+ tab = new Border((Component)wtkxSerializer.readObject(this, "document.wtkx"));
+
+ TextInput textInput1 = (TextInput)wtkxSerializer.get("textInput1");
+ textInput1.setMenuHandler(menuHandler);
+
+ TextInput textInput2 = (TextInput)wtkxSerializer.get("textInput2");
+ textInput2.setMenuHandler(menuHandler);
+
+ PushButton pushButton = (PushButton)wtkxSerializer.get("pushButton");
+ pushButton.setMenuHandler(menuHandler);
+ } catch (IOException exception) {
+ throw new RuntimeException(exception);
+ } catch (SerializationException exception) {
+ throw new RuntimeException(exception);
+ }
- Panel panel = new Panel();
- tabPane.getTabs().add(panel);
- TabPane.setLabel(panel, "Document " + tabPane.getTabs().getLength());
+ tabPane.getTabs().add(tab);
+ TabPane.setLabel(tab, "Document " + tabPane.getTabs().getLength());
}
});
@@ -81,7 +115,7 @@
public void startup(Display display, Map<String, String> properties)
throws Exception {
WTKXSerializer wtkxSerializer = new WTKXSerializer();
- window = (Window)wtkxSerializer.readObject(this, "menus.wtkx");
+ window = (Window)wtkxSerializer.readObject(this, "menu_bars.wtkx");
tabPane = (TabPane)wtkxSerializer.get("tabPane");
@@ -106,6 +140,6 @@
}
public static void main(String[] args) {
- DesktopApplicationContext.main(Menus.class, args);
+ DesktopApplicationContext.main(MenuBars.class, args);
}
}
Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/context_menus.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/context_menus.wtkx?rev=813600&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/context_menus.wtkx (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/context_menus.wtkx Thu Sep 10 21:48:19 2009
@@ -0,0 +1,25 @@
+<?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.
+-->
+
+<Window title="Context Menus" maximized="true"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk">
+ <content>
+ <!-- TODO -->
+ </content>
+</Window>
Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/document.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/document.wtkx?rev=813600&r1=813599&r2=813600&view=diff
==============================================================================
Binary files - no diff available.
Copied: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.wtkx (from r813552, incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menus.wtkx)
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.wtkx?p2=incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.wtkx&p1=incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menus.wtkx&r1=813552&r2=813600&rev=813600&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java?rev=813600&r1=813599&r2=813600&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java Thu Sep 10 21:48:19 2009
@@ -65,9 +65,7 @@
private WindowStateListener menuPopupWindowStateListener = new WindowStateListener.Adapter() {
@Override
public void windowClosed(Window window, Display display) {
- if (toolbar) {
- repaintComponent();
- }
+ repaintComponent();
}
};