+ Added classes:
+ org.netbeans.spi.viewmodel.AsynchronousModel
,
+ org.netbeans.spi.viewmodel.AsynchronousModelFilter
,
+
true
when the current thread is to be used for
+ * models method calls.
+ */
+ public boolean isCurrentThread() {
+ return rp == null;
+ }
+
+ /**
+ * Get the {@link RequestProcessor} that is used by this {@link ThreadProvider},
+ * if any.
+ * @return the {@link RequestProcessor} or null
.
+ */
+ public RequestProcessor getRequestProcessor() {
+ return rp;
+ }
+ }
+}
diff -r f950fdcb90e1 spi.viewmodel/src/org/netbeans/spi/viewmodel/AsynchronousModelFilter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/spi.viewmodel/src/org/netbeans/spi/viewmodel/AsynchronousModelFilter.java Mon Sep 21 16:39:44 2009 +0200
@@ -0,0 +1,73 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2009 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.spi.viewmodel;
+
+import org.netbeans.spi.viewmodel.AsynchronousModel.CALL;
+import org.netbeans.spi.viewmodel.AsynchronousModel.ThreadProvider;
+
+/**
+ * Change threading information about implemented models.
+ * Methods implemented in {@link TreeModel}, {@link NodeModel} ({@link ExtendedNodeModel})
+ * and {@link TableModel} can be called synchronously in AWT thread as a direct
+ * response to user action, or asynchronously in a Request Processor thread.
+ * Implementation of this interface can change the threading of method
+ * calls provided by an original {@link AsynchronousModel}.
+ * Register an implementation of this along with other models,
+ * if you need to change the original threading.
+ *
+ * @author Martin Entlicher
+ * @since 1.20
+ */
+public interface AsynchronousModelFilter extends Model {
+
+ /**
+ * Change the threading information for view models method calls.
+ * The returned ThreadProvider gives information about the threading
+ * of method calls identified by {@link CALL} enum.
+ *
+ * @param original The original {@link AsynchronousModel}
+ * @param asynchCall Identification of the method call
+ * @param node Object node
+ * @return an instance of ThreadProvider
+ */
+ ThreadProvider asynchronous(AsynchronousModel original,
+ CALL asynchCall, Object node) throws UnknownTypeException;
+
+}
diff -r f950fdcb90e1 spi.viewmodel/src/org/netbeans/spi/viewmodel/Models.java
--- a/spi.viewmodel/src/org/netbeans/spi/viewmodel/Models.java Mon Sep 21 15:17:38 2009 +0200
+++ b/spi.viewmodel/src/org/netbeans/spi/viewmodel/Models.java Mon Sep 21 16:39:44 2009 +0200
@@ -231,23 +231,19 @@
}
}
List extends Model> otherModels;
- RequestProcessor rp = null;
// Either the list contains 10 lists of individual models + one list of mixed models
- // + optional TreeExpansionModelFilter(s) + optional RequestProcessor
+ // + optional TreeExpansionModelFilter(s) + optional AsynchronousModel(s) + optional AsynchronousModelFilter(s)
// ; or the models directly
boolean hasLists = false;
- if (models.size() == 11 || models.size() == 12 || models.size() == 13) {
+ int modelsSize = models.size();
+ if (11 <= modelsSize && modelsSize <= 14) {
Iterator it = models.iterator ();
boolean failure = false;
while (it.hasNext ()) {
Object model = it.next();
if (!(model instanceof List)) {
- if (model instanceof RequestProcessor && !it.hasNext()) {
- failure = false;
- } else {
- failure = true;
- }
+ failure = true;
break;
}
}
@@ -271,20 +267,18 @@
revertOrder(ml.nodeActionsProviderFilters);
ml.columnModels = (List