001 /*
002 * Copyright 2002-2006 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016 package org.springframework.richclient.application.support;
017
018 import java.beans.PropertyChangeEvent;
019 import java.beans.PropertyChangeListener;
020
021 import javax.swing.JComponent;
022 import javax.swing.JToolBar;
023
024 import org.springframework.richclient.application.PageComponent;
025 import org.springframework.richclient.application.PageComponentPane;
026 import org.springframework.richclient.components.SimpleInternalFrame;
027 import org.springframework.richclient.factory.AbstractControlFactory;
028
029 /**
030 * A <code>DefaultPageComponentPane</code> puts the <code>PageComponent</code> inside
031 * a <code>SimpleInternalFrame</code>.
032 *
033 * @author Peter De Bruycker
034 *
035 */
036 public class DefaultPageComponentPane extends AbstractControlFactory implements PageComponentPane {
037 private PageComponent component;
038
039 private PropertyChangeListener updater = new PropertyChangeListener() {
040 public void propertyChange( PropertyChangeEvent evt ) {
041 handleViewPropertyChange();
042 }
043 };
044
045 public DefaultPageComponentPane( PageComponent component ) {
046 this.component = component;
047 this.component.addPropertyChangeListener( updater );
048 }
049
050 public PageComponent getPageComponent() {
051 return component;
052 }
053
054 protected JComponent createControl() {
055 return new SimpleInternalFrame( component.getIcon(), component.getDisplayName(), createViewToolBar(), component
056 .getControl() );
057 }
058
059 protected JToolBar createViewToolBar() {
060 // todo
061 return null;
062 }
063
064 public void propertyChange( PropertyChangeEvent evt ) {
065 handleViewPropertyChange();
066 }
067
068 protected void handleViewPropertyChange() {
069 SimpleInternalFrame frame = (SimpleInternalFrame) getControl();
070 frame.setTitle( component.getDisplayName() );
071 frame.setFrameIcon( component.getIcon() );
072 frame.setToolTipText( component.getCaption() );
073 }
074 }