Revision: 1348
Author:   peterdb
Date:     2006-08-30 03:01:59 -0700 (Wed, 30 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1348&view=rev

Log Message:
-----------
- refactored/restructured AbstractApplicationPage
- introduced PageComponentPane interface
- introduced new ApplicationPage implementations:
        - TabbedApplicationPage
        - FlexDockApplicationPage
- updated DesktopApplicationPage

Modified Paths:
--------------
    trunk/spring-richclient/sandbox/pom.xml
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopApplicationPage.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopApplicationPageFactory.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopPageDescriptor.java

Added Paths:
-----------
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockApplicationPage.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockApplicationPageFactory.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockViewDescriptor.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopViewDescriptor.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/tabbed/
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/tabbed/TabbedApplicationPage.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/tabbed/TabbedApplicationPageFactory.java

Removed Paths:
-------------
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopPageComponentPane.java
Modified: trunk/spring-richclient/sandbox/pom.xml
===================================================================
--- trunk/spring-richclient/sandbox/pom.xml     2006-08-30 10:01:33 UTC (rev 
1347)
+++ trunk/spring-richclient/sandbox/pom.xml     2006-08-30 10:01:59 UTC (rev 
1348)
@@ -61,7 +61,14 @@
             <groupId>hsqldb</groupId>
             <artifactId>hsqldb</artifactId>
             <scope>test</scope>
-        </dependency>
+        </dependency>
+        
+        <!-- Docking -->
+        <dependency>
+            <groupId>net.java.dev.flexdock</groupId>
+            <artifactId>flexdock</artifactId>
+            <optional>true</optional>
+        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file

Added: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockApplicationPage.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockApplicationPage.java
                              (rev 0)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockApplicationPage.java
      2006-08-30 10:01:59 UTC (rev 1348)
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ * 
+ * Licensed 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.springframework.richclient.application.flexdock;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.swing.AbstractButton;
+import javax.swing.JComponent;
+
+import org.flexdock.docking.Dockable;
+import org.flexdock.docking.DockableFactory;
+import org.flexdock.docking.DockingManager;
+import org.flexdock.docking.state.PersistenceException;
+import org.flexdock.view.View;
+import org.flexdock.view.ViewProps;
+import org.flexdock.view.Viewport;
+import org.springframework.richclient.application.PageComponent;
+import org.springframework.richclient.application.ViewDescriptor;
+import 
org.springframework.richclient.application.support.AbstractApplicationPage;
+
+/**
+ * <code>ApplicationPage</code> that uses FlexDock.
+ * 
+ * @author Peter De Bruycker
+ */
+public class FlexDockApplicationPage extends AbstractApplicationPage 
implements DockableFactory {
+    private Viewport port;
+    private Map dockables = new HashMap();
+    private boolean isLoadingLayout;
+    private boolean creatingDockable;
+
+    private PropertyChangeListener activeHandler = new 
PropertyChangeListener() {
+        public void propertyChange( PropertyChangeEvent evt ) {
+            if( ViewProps.ACTIVE.equals( evt.getPropertyName() ) && 
Boolean.TRUE.equals( evt.getNewValue() ) ) {
+                View view = (View) evt.getSource();
+                PageComponent component = findPageComponent( 
view.getPersistentId() );
+                setActiveComponent( component );
+            }
+        }
+    };
+
+    protected View createView( final PageComponent component ) {
+        View view = new View( component.getId() );
+        view.setTitle( component.getDisplayName() );
+        view.setTabText( component.getDisplayName() );
+        view.setTabIcon( component.getIcon() );
+        view.setIcon( component.getIcon() );
+        view.setContentPane( component.getControl() );
+
+        view.getViewProperties().addPropertyChangeListener( activeHandler );
+
+        configureView( component, view, getViewDescriptor( component.getId() ) 
);
+
+        dockables.put( component.getId(), view );
+
+        return view;
+    }
+
+    protected void configureView( final PageComponent component, View view, 
ViewDescriptor descriptor ) {
+        boolean closable = true;
+        boolean pinnable = true;
+        boolean dockable = true;
+
+        if( descriptor instanceof FlexDockViewDescriptor ) {
+            FlexDockViewDescriptor desc = (FlexDockViewDescriptor) descriptor;
+            closable = desc.isClosable();
+            pinnable = desc.isPinnable();
+            dockable = desc.isDockable();
+        }
+
+        if( closable ) {
+            view.addAction( View.CLOSE_ACTION );
+            // TODO fix this: this is the only way I found to find out if a 
dockable has
+            // been closed by the user.
+            AbstractButton btn = view.getActionButton( View.CLOSE_ACTION );
+            btn.addActionListener( new ActionListener() {
+                public void actionPerformed( ActionEvent e ) {
+                    close( component );
+                }
+            } );
+        }
+
+        if( pinnable ) {
+            view.addAction( View.PIN_ACTION );
+        }
+
+        view.getViewProperties().setDockingEnabled( dockable );
+    }
+
+    protected JComponent createControl() {
+        port = new Viewport();
+
+        return port;
+    }
+
+    public View getView( String id ) {
+        return (View) dockables.get( id );
+    }
+
+    protected void doAddPageComponent( PageComponent pageComponent ) {
+        View view = createView( pageComponent );
+        dockables.put( pageComponent.getId(), view );
+
+        if( !isLoadingLayout ) {
+            DockingManager.display( view );
+        }
+    }
+
+    protected void doRemovePageComponent( PageComponent pageComponent ) {
+        View view = getView( pageComponent.getId() );
+        if( view != null ) {
+            DockingManager.close( (Dockable) view );
+
+            // HACK: if we don't repaint here, when closing the last dockable 
the ui is
+            // not updated
+            port.revalidate();
+            port.repaint();
+
+            dockables.remove( view );
+        }
+    }
+
+    protected boolean giveFocusTo( final PageComponent pageComponent ) {
+        if( creatingDockable ) {
+            return false;
+        }
+
+        View view = getView( pageComponent.getId() );
+
+        view.setActive( true );
+
+        // HACK: otherwise the first dockable that was active will still be 
active
+        for( Iterator iter = DockingManager.getDockableIds().iterator(); 
iter.hasNext(); ) {
+            String id = (String) iter.next();
+            if( !id.equals( pageComponent.getId() ) ) {
+                getView( id ).setActive( false );
+            }
+        }
+
+        return true;
+    }
+
+    public void loadLayout() {
+        isLoadingLayout = true;
+
+        // the view port must be created before we attempt to load the layout 
model or try
+        // to restore the layout
+        getControl();
+
+        try {
+            DockingManager.loadLayoutModel( true );
+        } catch( IOException e ) {
+            e.printStackTrace();
+        } catch( PersistenceException e ) {
+            e.printStackTrace();
+        }
+
+        port.revalidate();
+        port.repaint();
+
+        isLoadingLayout = false;
+
+        // mark the view associated with the active component as active
+        View view = getView( getActiveComponent().getId() );
+        if( view != null ) {
+            view.setActive( true );
+        }
+    }
+
+    public Component getDockableComponent( String id ) {
+        // not used, we work with dockables
+        return null;
+    }
+
+    public Dockable getDockable( String id ) {
+        if( dockables.containsKey( id ) ) {
+            return (Dockable) dockables.get( id );
+        }
+
+        creatingDockable = true;
+        showView( id );
+        creatingDockable = false;
+        return (Dockable) dockables.get( id );
+    }
+}

Added: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockApplicationPageFactory.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockApplicationPageFactory.java
                               (rev 0)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockApplicationPageFactory.java
       2006-08-30 10:01:59 UTC (rev 1348)
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ * 
+ * Licensed 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.springframework.richclient.application.flexdock;
+
+import org.flexdock.docking.DockingManager;
+import org.flexdock.docking.drag.effects.DragPreview;
+import org.flexdock.docking.drag.effects.EffectsManager;
+import org.flexdock.perspective.PerspectiveFactory;
+import org.flexdock.perspective.PerspectiveManager;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.richclient.application.ApplicationPage;
+import org.springframework.richclient.application.ApplicationPageFactory;
+import org.springframework.richclient.application.ApplicationWindow;
+import org.springframework.richclient.application.PageDescriptor;
+
+/**
+ * Factory for <code>FlexDockApplicationPage</code> instances
+ * 
+ * @author Peter De Bruycker
+ */
+public class FlexDockApplicationPageFactory implements ApplicationPageFactory, 
InitializingBean {
+
+    private PerspectiveFactory perspectiveFactory;
+    private String defaultPerspective;
+    private DragPreview dragPreview;
+    private boolean floatingEnabled;
+    private boolean singleTabsAllowed;
+
+    public String getDefaultPerspective() {
+        return defaultPerspective;
+    }
+
+    public void setDefaultPerspective( String defaultPerspective ) {
+        this.defaultPerspective = defaultPerspective;
+    }
+
+    public ApplicationPage createApplicationPage( ApplicationWindow window, 
PageDescriptor descriptor ) {
+        final FlexDockApplicationPage page = new FlexDockApplicationPage();
+        page.setApplicationWindow( window );
+        page.setDescriptor( descriptor );
+
+        DockingManager.setDockableFactory( page );
+        // TODO uncomment for persistence
+        // DockingManager.setAutoPersist(true);
+
+        PerspectiveManager.setFactory( perspectiveFactory );
+        PerspectiveManager.getInstance().setCurrentPerspective( 
defaultPerspective, true );
+        // TODO define how the file name or persister will be passed in the 
app context
+        // PersistenceHandler persister = FilePersistenceHandler.createDefault(
+        // "test-flexdock.xml" );
+        // PerspectiveManager.setPersistenceHandler( persister );
+
+        page.loadLayout();
+
+        return page;
+    }
+
+    public void setPerspectiveFactory( PerspectiveFactory perspectiveFactory ) 
{
+        this.perspectiveFactory = perspectiveFactory;
+    }
+
+    public PerspectiveFactory getPerspectiveFactory() {
+        return perspectiveFactory;
+    }
+
+    public void afterPropertiesSet() throws Exception {
+        if( dragPreview != null ) {
+            EffectsManager.setPreview( dragPreview );
+        }
+
+        DockingManager.setFloatingEnabled( floatingEnabled );
+        DockingManager.setSingleTabsAllowed( singleTabsAllowed );
+    }
+
+    public DragPreview getDragPreview() {
+        return dragPreview;
+    }
+
+    public void setDragPreview( DragPreview dragPreview ) {
+        this.dragPreview = dragPreview;
+    }
+
+    public boolean isFloatingEnabled() {
+        return floatingEnabled;
+    }
+
+    public void setFloatingEnabled( boolean floatingEnabled ) {
+        this.floatingEnabled = floatingEnabled;
+    }
+}

Added: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockViewDescriptor.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockViewDescriptor.java
                               (rev 0)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/flexdock/FlexDockViewDescriptor.java
       2006-08-30 10:01:59 UTC (rev 1348)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ * 
+ * Licensed 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.springframework.richclient.application.flexdock;
+
+import 
org.springframework.richclient.application.support.DefaultViewDescriptor;
+
+/**
+ * @author Peter De Bruycker
+ */
+public class FlexDockViewDescriptor extends DefaultViewDescriptor {
+    private boolean closable;
+    private boolean pinnable;
+    private boolean dockable;
+
+    public boolean isDockable() {
+        return dockable;
+    }
+
+    public void setDockable( boolean dockable ) {
+        this.dockable = dockable;
+    }
+
+    public boolean isClosable() {
+        return closable;
+    }
+
+    public void setClosable( boolean closable ) {
+        this.closable = closable;
+    }
+
+    public boolean isPinnable() {
+        return pinnable;
+    }
+
+    public void setPinnable( boolean pinnable ) {
+        this.pinnable = pinnable;
+    }
+}

Modified: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopApplicationPage.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopApplicationPage.java
    2006-08-30 10:01:33 UTC (rev 1347)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopApplicationPage.java
    2006-08-30 10:01:59 UTC (rev 1348)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 the original author or authors.
+ * Copyright 2002-2006 the original author or authors.
  *
  * Licensed 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
@@ -16,88 +16,137 @@
 package org.springframework.richclient.application.mdi;
 
 import java.beans.PropertyVetoException;
-import java.util.Iterator;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.swing.JComponent;
 import javax.swing.JInternalFrame;
 import javax.swing.JScrollPane;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
 
 import org.springframework.richclient.application.ApplicationWindow;
 import org.springframework.richclient.application.PageComponent;
-import org.springframework.richclient.application.PageComponentDescriptor;
-import org.springframework.richclient.application.PageComponentPane;
 import org.springframework.richclient.application.PageDescriptor;
 import org.springframework.richclient.application.PageLayoutBuilder;
+import org.springframework.richclient.application.ViewDescriptor;
 import 
org.springframework.richclient.application.support.AbstractApplicationPage;
-import org.springframework.richclient.application.support.DefaultViewContext;
 
 /**
  * @author Peter De Bruycker
  */
-public class DesktopApplicationPage extends AbstractApplicationPage implements 
PageLayoutBuilder{
+public class DesktopApplicationPage extends AbstractApplicationPage implements 
PageLayoutBuilder {
 
     private ScrollingDesktopPane control;
 
     private JScrollPane scrollPane;
 
-    public DesktopApplicationPage(ApplicationWindow window, PageDescriptor 
pageDescriptor) {
-        super(window, pageDescriptor);
+    private Map frames = new HashMap();
+
+    public DesktopApplicationPage( ApplicationWindow window, PageDescriptor 
pageDescriptor ) {
+        super( window, pageDescriptor );
     }
 
-    protected boolean giveFocusTo(PageComponent pageComponent) {
-        if(getActiveComponent() == pageComponent) {
+    protected boolean giveFocusTo( PageComponent pageComponent ) {
+        if( getActiveComponent() == pageComponent ) {
             return true;
         }
-        
-        PageComponentPane pane = pageComponent.getContext().getPane();
-        JInternalFrame internalFrame = (JInternalFrame) pane.getControl();
 
+        JInternalFrame frame = (JInternalFrame) frames.get( pageComponent );
+        if( frame == null ) {
+            return false;
+        }
+
         try {
-            internalFrame.setSelected(true);
-        }
-        catch (PropertyVetoException e) {
+            if( frame.isIcon() ) {
+                frame.setIcon( false );
+            }
+
+            frame.setSelected( true );
+        } catch( PropertyVetoException e ) {
             // ignore
         }
 
-        pane.requestFocusInWindow();
-        return true;
+        return pageComponent.getControl().requestFocusInWindow();
     }
 
-    protected PageComponent createPageComponent(PageComponentDescriptor 
descriptor) {
-        final PageComponent pageComponent = descriptor.createPageComponent();
-        pageComponent.setContext(new DefaultViewContext(this, new 
DesktopPageComponentPane(this, pageComponent)));
+    public void addView( String viewDescriptorId ) {
+        showView( viewDescriptorId );
+    }
 
-        JInternalFrame internalFrame = (JInternalFrame) 
pageComponent.getContext().getPane().getControl();
-        internalFrame.setVisible(true);
-        control.add(internalFrame);
+    protected void doAddPageComponent( PageComponent pageComponent ) {
+        JInternalFrame frame = createInternalFrame( pageComponent );
+        frames.put( pageComponent, frame );
 
-        return pageComponent;
+        frame.setVisible( true );
+        control.add( frame );
     }
 
-    protected void setActiveComponent() {
-        for (Iterator iter = getPageComponents().iterator(); iter.hasNext();) {
-            PageComponent pageComponent = (PageComponent) iter.next();
-            if (!((JInternalFrame) 
pageComponent.getContext().getPane().getControl()).isIcon()) {
-                setActiveComponent(pageComponent);
-                return;
+    protected JInternalFrame createInternalFrame( final PageComponent 
pageComponent ) {
+        JInternalFrame internalFrame = new JInternalFrame( 
pageComponent.getDisplayName() );
+
+        configureFrame( pageComponent, internalFrame );
+        
+        internalFrame.addInternalFrameListener( new InternalFrameAdapter() {
+            public void internalFrameClosing( InternalFrameEvent e ) {
+                close( pageComponent );
             }
+
+            public void internalFrameActivated( InternalFrameEvent e ) {
+                setActiveComponent( pageComponent );
+            }
+        } );
+
+        internalFrame.getContentPane().add( pageComponent.getControl() );
+        internalFrame.pack();
+        return internalFrame;
+    }
+    
+    protected void configureFrame(PageComponent component, JInternalFrame 
frame) {
+        if( component.getIcon() != null ) {
+            frame.setFrameIcon( component.getIcon() );
         }
-        //no page component found that is not iconified
 
+        ViewDescriptor descriptor = getViewDescriptor( component.getId() );
+        if(descriptor instanceof DesktopViewDescriptor) {
+            DesktopViewDescriptor desktopViewDescriptor = 
(DesktopViewDescriptor) descriptor;
+            frame.setResizable( desktopViewDescriptor.isResizable() );
+            frame.setMaximizable( desktopViewDescriptor.isMaximizable() );
+            frame.setIconifiable( desktopViewDescriptor.isIconifiable() );
+            frame.setClosable( desktopViewDescriptor.isClosable() );
+        }
+        else {
+            frame.setResizable( true );
+            frame.setMaximizable( true );
+            frame.setIconifiable( true );
+            frame.setClosable( true );
+        }
     }
 
-    public JComponent getControl() {
-        if (control == null) {
-            control = new ScrollingDesktopPane();
-            scrollPane = new JScrollPane(control);
+    protected void doRemovePageComponent( PageComponent pageComponent ) {
+        // not used
+        JInternalFrame frame = (JInternalFrame) frames.get( pageComponent );
+        if( frame != null ) {
+            frame.dispose();
+        }
+    }
 
-            this.getPageDescriptor().buildInitialLayout(this);
-            setActiveComponent();
-        }
+    protected JComponent createControl() {
+        control = new ScrollingDesktopPane();
+        scrollPane = new JScrollPane( control );
+
+        getPageDescriptor().buildInitialLayout( this );
+
         return scrollPane;
     }
 
-    public void addView(String viewDescriptorId) {
-        showView(viewDescriptorId);
+    protected void updatePageComponentProperties( PageComponent pageComponent 
) {
+        JInternalFrame frame = (JInternalFrame) frames.get( pageComponent );
+
+        if( pageComponent.getIcon() != null ) {
+            frame.setFrameIcon( pageComponent.getIcon() );
+        }
+        frame.setTitle( pageComponent.getDisplayName() );
+        frame.setToolTipText( pageComponent.getCaption() );
     }
 }

Modified: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopApplicationPageFactory.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopApplicationPageFactory.java
     2006-08-30 10:01:33 UTC (rev 1347)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopApplicationPageFactory.java
     2006-08-30 10:01:59 UTC (rev 1348)
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed 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.springframework.richclient.application.mdi;
 
 import org.springframework.richclient.application.ApplicationPage;
@@ -5,10 +20,13 @@
 import org.springframework.richclient.application.ApplicationWindow;
 import org.springframework.richclient.application.PageDescriptor;
 
-public class DesktopApplicationPageFactory implements ApplicationPageFactory{
+/**
+ * @author Peter De Bruycker
+ */
+public class DesktopApplicationPageFactory implements ApplicationPageFactory {
 
     public ApplicationPage createApplicationPage( ApplicationWindow window, 
PageDescriptor descriptor ) {
-        return new DesktopApplicationPage(window, descriptor);
+        return new DesktopApplicationPage( window, descriptor );
     }
 
 }

Deleted: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopPageComponentPane.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopPageComponentPane.java
  2006-08-30 10:01:33 UTC (rev 1347)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopPageComponentPane.java
  2006-08-30 10:01:59 UTC (rev 1348)
@@ -1,66 +0,0 @@
-/*
- * Copyright 2002-2004 the original author or authors.
- *
- * Licensed 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.springframework.richclient.application.mdi;
-
-import javax.swing.JComponent;
-import javax.swing.JInternalFrame;
-import javax.swing.event.InternalFrameAdapter;
-import javax.swing.event.InternalFrameEvent;
-
-import org.springframework.richclient.application.PageComponent;
-import org.springframework.richclient.application.PageComponentPane;
-
-/**
- * @author Peter De Bruycker
- */
-public class DesktopPageComponentPane extends PageComponentPane {
-
-    private PageComponent pageComponent;
-
-    private DesktopApplicationPage applicationPage;
-
-    private JInternalFrame internalFrame;
-
-    public DesktopPageComponentPane(DesktopApplicationPage applicationPage, 
PageComponent component) {
-        super(component);
-        this.applicationPage = applicationPage;
-        pageComponent = component;
-    }
-
-    protected JComponent createControl() {
-        internalFrame = new JInternalFrame(pageComponent.getDisplayName());
-        if (pageComponent.getIcon() != null) {
-            internalFrame.setFrameIcon(pageComponent.getIcon());
-        }
-        internalFrame.setResizable(true);
-        internalFrame.setMaximizable(true);
-        internalFrame.setIconifiable(true);
-        internalFrame.setClosable(true);
-        internalFrame.addInternalFrameListener(new InternalFrameAdapter() {
-            public void internalFrameClosed(InternalFrameEvent e) {
-                applicationPage.close(pageComponent);
-            }
-
-            public void internalFrameActivated(InternalFrameEvent e) {
-                applicationPage.setActiveComponent(pageComponent);
-            }
-        });
-
-        internalFrame.getContentPane().add(pageComponent.getControl());
-        internalFrame.pack();
-        return internalFrame;
-    }
-}

Modified: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopPageDescriptor.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopPageDescriptor.java
     2006-08-30 10:01:33 UTC (rev 1347)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopPageDescriptor.java
     2006-08-30 10:01:59 UTC (rev 1348)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 the original author or authors.
+ * Copyright 2002-2006 the original author or authors.
  *
  * Licensed 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

Added: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopViewDescriptor.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopViewDescriptor.java
                             (rev 0)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/mdi/DesktopViewDescriptor.java
     2006-08-30 10:01:59 UTC (rev 1348)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed 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.springframework.richclient.application.mdi;
+
+import 
org.springframework.richclient.application.support.DefaultViewDescriptor;
+
+/**
+ * @author Peter De Bruycker
+ */
+public class DesktopViewDescriptor extends DefaultViewDescriptor {
+    private boolean resizable = true;
+    private boolean maximizable = true;
+    private boolean iconifiable = true;
+    private boolean closable = true;
+
+    public boolean isClosable() {
+        return closable;
+    }
+
+    public void setClosable( boolean closable ) {
+        this.closable = closable;
+    }
+
+    public boolean isIconifiable() {
+        return iconifiable;
+    }
+
+    public void setIconifiable( boolean iconifiable ) {
+        this.iconifiable = iconifiable;
+    }
+
+    public boolean isMaximizable() {
+        return maximizable;
+    }
+
+    public void setMaximizable( boolean maximizable ) {
+        this.maximizable = maximizable;
+    }
+
+    public boolean isResizable() {
+        return resizable;
+    }
+
+    public void setResizable( boolean resizable ) {
+        this.resizable = resizable;
+    }
+}

Added: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/tabbed/TabbedApplicationPage.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/tabbed/TabbedApplicationPage.java
                          (rev 0)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/tabbed/TabbedApplicationPage.java
  2006-08-30 10:01:59 UTC (rev 1348)
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ * 
+ * Licensed 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.springframework.richclient.application.tabbed;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JComponent;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.JTabbedPane;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.springframework.richclient.application.PageComponent;
+import org.springframework.richclient.application.PageLayoutBuilder;
+import 
org.springframework.richclient.application.support.AbstractApplicationPage;
+import org.springframework.richclient.util.PopupMenuMouseListener;
+
+/**
+ * <code>ApplicationPage</code> implementation that puts the 
<code>PageComponent</code>s
+ * in a <code>JTabbedPane</code>.
+ * 
+ * @author Peter De Bruycker
+ */
+public class TabbedApplicationPage extends AbstractApplicationPage implements 
PageLayoutBuilder {
+
+    private JTabbedPane tabbedPane;
+    private List components = new ArrayList();
+    private int tabPlacement = -1;
+    private int tabLayoutPolicy= -1;
+
+    protected JComponent createControl() {
+        tabbedPane = new JTabbedPane();
+        if( tabPlacement != -1 ) {
+            tabbedPane.setTabPlacement( tabPlacement );
+        }
+        if( tabLayoutPolicy != -1 ) {
+            tabbedPane.setTabLayoutPolicy( tabLayoutPolicy );
+        }
+
+        tabbedPane.addChangeListener( new ChangeListener() {
+            public void stateChanged( ChangeEvent e ) {
+                if( tabbedPane.getSelectedIndex() >= 0 ) {
+                    setActiveComponent( getComponent( 
tabbedPane.getSelectedIndex() ) );
+                }
+            }
+        } );
+        JPopupMenu popup = new JPopupMenu();
+        JMenuItem close = new JMenuItem( "Close" );
+        close.addActionListener( new ActionListener() {
+            public void actionPerformed( ActionEvent e ) {
+                close( getComponent( tabbedPane.getSelectedIndex() ) );
+            }
+        } );
+        popup.add( close );
+        tabbedPane.addMouseListener( new PopupMenuMouseListener( popup ) );
+
+        this.getPageDescriptor().buildInitialLayout( this );
+
+        return tabbedPane;
+    }
+
+    protected void updatePageComponentProperties( PageComponent pageComponent 
) {
+        int index = indexOf( pageComponent );
+
+        tabbedPane.setIconAt( index, pageComponent.getIcon() );
+        tabbedPane.setTitleAt( index, pageComponent.getDisplayName() );
+        tabbedPane.setToolTipTextAt( index, pageComponent.getCaption() );
+    }
+
+    public void addView( String viewDescriptorId ) {
+        showView( viewDescriptorId );
+    }
+
+    protected void doAddPageComponent( PageComponent pageComponent ) {
+        components.add( pageComponent );
+        tabbedPane.addTab( pageComponent.getDisplayName(), 
pageComponent.getIcon(), pageComponent.getContext()
+                .getPane().getControl(), pageComponent.getCaption() );
+    }
+
+    protected void doRemovePageComponent( PageComponent pageComponent ) {
+        tabbedPane.removeTabAt( indexOf( pageComponent ) );
+        components.remove( pageComponent );
+    }
+
+    protected boolean giveFocusTo( PageComponent pageComponent ) {
+        if( !components.contains( pageComponent ) ) {
+            return false;
+        }
+
+        tabbedPane.setSelectedIndex( indexOf( pageComponent ) );
+        return true;
+    }
+
+    private int indexOf( PageComponent component ) {
+        return components.indexOf( component );
+    }
+
+    private PageComponent getComponent( int index ) {
+        return (PageComponent) components.get( index );
+    }
+
+    public void setTabPlacement( int tabPlacement ) {
+        this.tabPlacement = tabPlacement;
+    }
+
+    public void setTabLayoutPolicy( int tabLayoutPolicy ) {
+        this.tabLayoutPolicy = tabLayoutPolicy;
+    }
+}

Added: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/tabbed/TabbedApplicationPageFactory.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/tabbed/TabbedApplicationPageFactory.java
                           (rev 0)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/application/tabbed/TabbedApplicationPageFactory.java
   2006-08-30 10:01:59 UTC (rev 1348)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ * 
+ * Licensed 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.springframework.richclient.application.tabbed;
+
+import org.springframework.richclient.application.ApplicationPage;
+import org.springframework.richclient.application.ApplicationPageFactory;
+import org.springframework.richclient.application.ApplicationWindow;
+import org.springframework.richclient.application.PageDescriptor;
+
+/**
+ * Factory for <code>TabbedApplicationPage</code> instances.
+ * 
+ * @author Peter De Bruycker
+ */
+public class TabbedApplicationPageFactory implements ApplicationPageFactory {
+
+    private int tabPlacement = -1;
+    private int tabLayoutPolicy = -1;
+
+    public ApplicationPage createApplicationPage( ApplicationWindow window, 
PageDescriptor descriptor ) {
+        TabbedApplicationPage page = new TabbedApplicationPage();
+        page.setApplicationWindow( window );
+        page.setDescriptor( descriptor );
+        if( tabPlacement != -1 ) {
+            page.setTabPlacement( tabPlacement );
+        }
+        if( tabLayoutPolicy != -1 ) {
+            page.setTabLayoutPolicy( tabLayoutPolicy );
+        }
+
+        return page;
+    }
+
+    public void setTabPlacement( int tabPlacement ) {
+        this.tabPlacement = tabPlacement;
+    }
+
+    public int getTabPlacement() {
+        return tabPlacement;
+    }
+
+    public int getTabLayoutPolicy() {
+        return tabLayoutPolicy;
+    }
+
+    public void setTabLayoutPolicy( int tabLayoutPolicy ) {
+        this.tabLayoutPolicy = tabLayoutPolicy;
+    }
+}


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to