You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/07/22 19:39:38 UTC
svn commit: r796807 - in
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: Component.java
ComponentListener.java ContextMenuHandler.java skin/ComponentSkin.java
Author: tvolkert
Date: Wed Jul 22 17:39:38 2009
New Revision: 796807
URL: http://svn.apache.org/viewvc?rev=796807&view=rev
Log:
PIVOT-181 :: Add ContextMenuHandler interface and Component.get/setContextMenuHandler()
Added:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ContextMenuHandler.java
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentListener.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java?rev=796807&r1=796806&r2=796807&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java Wed Jul 22 17:39:38 2009
@@ -337,6 +337,12 @@
listener.tooltipTextChanged(component, previousTooltipText);
}
}
+
+ public void contextMenuHandlerChanged(Component component, ContextMenuHandler previousContextMenuHandler) {
+ for (ComponentListener listener : this) {
+ listener.contextMenuHandlerChanged(component, previousContextMenuHandler);
+ }
+ }
}
private static class ComponentLayoutListenerList extends
@@ -596,6 +602,9 @@
// The component's drop target
private DropTarget dropTarget = null;
+ // The component's context menu handler
+ private ContextMenuHandler contextMenuHandler = null;
+
// User data
private HashMap<String, Object> userData = new HashMap<String, Object>();
private UserDataDictionary userDataDictionary = new UserDataDictionary();
@@ -2219,6 +2228,19 @@
}
}
+ public ContextMenuHandler getContextMenuHandler() {
+ return contextMenuHandler;
+ }
+
+ public void setContextMenuHandler(ContextMenuHandler contextMenuHandler) {
+ ContextMenuHandler previousContextMenuHandler = this.contextMenuHandler;
+
+ if (previousContextMenuHandler != contextMenuHandler) {
+ this.contextMenuHandler = contextMenuHandler;
+ componentListeners.contextMenuHandlerChanged(this, previousContextMenuHandler);
+ }
+ }
+
/**
* Returns the user data dictionary.
*/
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentListener.java?rev=796807&r1=796806&r2=796807&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentListener.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentListener.java Wed Jul 22 17:39:38 2009
@@ -28,26 +28,37 @@
* @author tvolkert
*/
public static class Adapter implements ComponentListener {
+ @Override
public void parentChanged(Component component, Container previousParent) {
}
+ @Override
public void sizeChanged(Component component, int previousWidth, int previousHeight) {
}
+ @Override
public void locationChanged(Component component, int previousX, int previousY) {
}
+ @Override
public void visibleChanged(Component component) {
}
+ @Override
public void styleUpdated(Component component, String styleKey, Object previousValue) {
}
+ @Override
public void cursorChanged(Component component, Cursor previousCursor) {
}
+ @Override
public void tooltipTextChanged(Component component, String previousTooltipText) {
}
+
+ @Override
+ public void contextMenuHandlerChanged(Component component, ContextMenuHandler previousContextMenuHandler) {
+ }
}
/**
@@ -108,4 +119,12 @@
* @param previousTooltipText
*/
public void tooltipTextChanged(Component component, String previousTooltipText);
+
+ /**
+ * Called when a component's context menu handler has changed.
+ *
+ * @param component
+ * @param previousContextMenuHandler
+ */
+ public void contextMenuHandlerChanged(Component component, ContextMenuHandler previousContextMenuHandler);
}
Added: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ContextMenuHandler.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ContextMenuHandler.java?rev=796807&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ContextMenuHandler.java (added)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ContextMenuHandler.java Wed Jul 22 17:39:38 2009
@@ -0,0 +1,29 @@
+/*
+ * 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.wtk;
+
+/**
+ *
+ *
+ * @author tvolkert
+ */
+public interface ContextMenuHandler {
+ /**
+ *
+ */
+ public boolean configureMenu(Menu menu);
+}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java?rev=796807&r1=796806&r2=796807&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java Wed Jul 22 17:39:38 2009
@@ -27,6 +27,7 @@
import org.apache.pivot.wtk.ComponentMouseWheelListener;
import org.apache.pivot.wtk.ComponentStateListener;
import org.apache.pivot.wtk.Container;
+import org.apache.pivot.wtk.ContextMenuHandler;
import org.apache.pivot.wtk.Cursor;
import org.apache.pivot.wtk.Dimensions;
import org.apache.pivot.wtk.Direction;
@@ -173,6 +174,10 @@
// TODO Handle change here instead of in ShowTooltipCallback?
}
+ public void contextMenuHandlerChanged(Component component, ContextMenuHandler previousContextMenuHandler) {
+ // No-op
+ }
+
// Component layout events
public void preferredSizeChanged(Component component,
int previousPreferredWidth, int previousPreferredHeight) {