JaroslavTulach commented on a change in pull request #1135: [NETBEANS-1979] 
Create Mode from client code
URL: 
https://github.com/apache/incubator-netbeans/pull/1135#discussion_r258989422
 
 

 ##########
 File path: platform/openide.windows/src/org/openide/windows/ModeUtility.java
 ##########
 @@ -0,0 +1,104 @@
+/*
+ * 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.openide.windows;
+
+/**
+ * Utility class to help clients manage {@link Mode}s in order to layout 
TopComponents
+ * in predefined "work-spaces".
+ * <br>
+ * <br>
+ * In a NetBeans Platform application, a user may create various TopComponents 
and
+ * drag them around, into and out of the existing defined Modes (e.g. editor, 
explorer) or 
+ * new "anonymous" Modes which get created by the system as needed.
+ * <br>
+ * <br>
+ * The configuration of each Mode can be expressed in XML. This class gives 
access
+ * to that XML with a mechanism to reproduce a Mode from XML so you can 
construct 
+ * ways to save Mode and TopComponent combinations, which can subsequently be
+ * chosen and reloaded at a later time.
+ * <br>
+ * <br>
+ * Note that this is a different approach to how the Platform tends to save 
the layout
+ * of TopComponents at shut-down time in the Windows2Local file system. Note 
also that 
+ * this is not connected with the deprecated notion of {@link Workspace}.
+ * 
+ * @see http://wiki.apidesign.org/wiki/ExtendingInterfaces
+ * 
+ * @author Mark Phipps
+ */
+public final class ModeUtility {
+
+    private ModeUtility() {
+    }
+
+    /**
+     * Expose the Mode's configuration as XML.
+     * 
+     * @param mode the {@link Mode} whose XML configuration is required.
+     * @return the XML of the Mode's configuration or {@code null} if not 
supported.
+     */
+    public final static String toXml(Mode mode) {
+        return mode instanceof Mode.Xml
+                ? ((Mode.Xml) mode).toXml()
+                : null;
+    }
+    
+    /**
+     * Given some XML, attempts to ask the WindowManager to create a Mode that 
can
+     * subsequently be used to dock a TopComponent into. Usually this will be 
an 
+     * anonymous Mode.
+     * 
+     * @param windowManager typically WindowManager.getDefault()
+     * @param xml the XML that was originally produced by {@link #toXml}
+     */
+    public final static void createModeFromXml(WindowManager windowManager, 
String xml) {
 
 Review comment:
   Strange parameters. I'd expect the method to call 
`WindowManager.getDefault()` itself.
   
   Shouldn't the method return `Mode` or `null`? How can one distinguish 
between success and failure?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to