# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: D:\hg\core-copy # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: core.windows/manifest.mf --- core.windows/manifest.mf Base (BASE) +++ core.windows/manifest.mf Locally Modified (Based On LOCAL) @@ -6,5 +6,5 @@ OpenIDE-Module-Recommends: org.netbeans.core.windows.nativeaccess.NativeWindowSystem AutoUpdate-Show-In-Client: false AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 2.42 +OpenIDE-Module-Specification-Version: 2.43 Index: core.windows/nbproject/project.xml --- core.windows/nbproject/project.xml Base (BASE) +++ core.windows/nbproject/project.xml Locally Modified (Based On LOCAL) @@ -85,7 +85,7 @@ - 1.27 + 1.33 Index: core.windows/src/org/netbeans/core/windows/view/dnd/DragAndDropFeedbackVisualizer.java --- core.windows/src/org/netbeans/core/windows/view/dnd/DragAndDropFeedbackVisualizer.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/dnd/DragAndDropFeedbackVisualizer.java Locally Modified (Based On LOCAL) @@ -59,7 +59,7 @@ import javax.swing.SwingUtilities; import org.netbeans.core.windows.nativeaccess.NativeWindowSystem; import org.netbeans.core.windows.options.WinSysPrefs; -import org.netbeans.core.windows.view.ui.Tabbed; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; /** * Index: core.windows/src/org/netbeans/core/windows/view/dnd/DragWindow.java --- core.windows/src/org/netbeans/core/windows/view/dnd/DragWindow.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/dnd/DragWindow.java Locally Modified (Based On LOCAL) @@ -62,7 +62,7 @@ import javax.swing.SwingUtilities; import javax.swing.Timer; import org.netbeans.core.windows.options.WinSysPrefs; -import org.netbeans.core.windows.view.ui.Tabbed; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; /** * Index: core.windows/src/org/netbeans/core/windows/view/dnd/TopComponentDragSupport.java --- core.windows/src/org/netbeans/core/windows/view/dnd/TopComponentDragSupport.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/dnd/TopComponentDragSupport.java Locally Modified (Based On LOCAL) @@ -47,6 +47,7 @@ +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; import java.awt.AWTEvent; import java.awt.Color; import java.awt.Component; @@ -273,19 +274,12 @@ TopComponent tc = null; Tabbed tabbed; - if(srcComp instanceof Tabbed) { - tabbed = (Tabbed)srcComp; - } else { - tabbed = (Tabbed)SwingUtilities.getAncestorOfClass(Tabbed.class, srcComp); - } - if (tabbed == null) { if(srcComp instanceof Tabbed.Accessor) { tabbed = ((Tabbed.Accessor)srcComp).getTabbed(); } else { Tabbed.Accessor acc = (Tabbed.Accessor)SwingUtilities.getAncestorOfClass(Tabbed.Accessor.class, srcComp); tabbed = acc != null ? acc.getTabbed() : null; } - } if(tabbed == null) { return; } @@ -396,13 +390,10 @@ addListening(); hackESC = false; - Tabbed tabbed = (Tabbed) SwingUtilities.getAncestorOfClass (Tabbed.class, - startingComp); - if (tabbed == null) { + Tabbed tabbed = null; Tabbed.Accessor acc = (Tabbed.Accessor) SwingUtilities.getAncestorOfClass (Tabbed.Accessor.class, startingComp); tabbed = acc != null ? acc.getTabbed() : null; - } int tabIndex = -1; Image img = createDragImage(); Index: core.windows/src/org/netbeans/core/windows/view/ui/AbstractModeContainer.java --- core.windows/src/org/netbeans/core/windows/view/ui/AbstractModeContainer.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/AbstractModeContainer.java Locally Modified (Based On LOCAL) @@ -46,6 +46,7 @@ package org.netbeans.core.windows.view.ui; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; import org.netbeans.core.windows.Constants; import org.netbeans.core.windows.WindowManagerImpl; import org.netbeans.core.windows.view.ModeContainer; @@ -206,7 +207,7 @@ // Support for TopComponentDroppable protected Shape getIndicationForLocation(Point location) { return tabbedHandler.getIndicationForLocation(location, - windowDnDManager.getStartingTransfer(), + windowDnDManager.getStartingTransfer().getTopComponent(), windowDnDManager.getStartingPoint(), isAttachingPossible()); } Index: core.windows/src/org/netbeans/core/windows/view/ui/DefaultSeparateContainer.java --- core.windows/src/org/netbeans/core/windows/view/ui/DefaultSeparateContainer.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/DefaultSeparateContainer.java Locally Modified (Based On LOCAL) @@ -46,6 +46,7 @@ package org.netbeans.core.windows.view.ui; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; import java.text.MessageFormat; import javax.swing.plaf.basic.BasicHTML; import org.netbeans.core.windows.Constants; @@ -68,6 +69,9 @@ import java.util.logging.Logger; import org.netbeans.core.windows.options.WinSysPrefs; import org.netbeans.core.windows.view.dnd.TopComponentDraggable; +import org.netbeans.swing.tabcontrol.customtabs.TabbedComponentFactory; +import org.netbeans.swing.tabcontrol.customtabs.TabbedType; +import org.openide.util.Lookup; import org.openide.windows.WindowManager; @@ -118,14 +122,10 @@ @Override protected Tabbed createTabbed() { - Tabbed tabbed; - if(getKind() == Constants.MODE_KIND_EDITOR) { - tabbed = new TabbedAdapter(Constants.MODE_KIND_EDITOR); - } else { - tabbed = new TabbedAdapter(Constants.MODE_KIND_VIEW); + TabbedComponentFactory factory = Lookup.getDefault().lookup(TabbedComponentFactory.class); + TabbedType type = getKind() == Constants.MODE_KIND_EDITOR ? TabbedType.Editor : TabbedType.View; + return factory.createTabbedComponent( type, new TabbedAdapter.WinsysInfo(getKind())).getTabbed(); } - return tabbed; - } @Override protected void updateTitle (String title) { Index: core.windows/src/org/netbeans/core/windows/view/ui/DefaultSplitContainer.java --- core.windows/src/org/netbeans/core/windows/view/ui/DefaultSplitContainer.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/DefaultSplitContainer.java Locally Modified (Based On LOCAL) @@ -46,6 +46,7 @@ package org.netbeans.core.windows.view.ui; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; import org.netbeans.core.windows.Constants; import org.netbeans.core.windows.WindowManagerImpl; import org.netbeans.core.windows.view.ModeView; @@ -59,6 +60,9 @@ import java.awt.*; import org.netbeans.core.windows.ModeImpl; import org.netbeans.core.windows.view.dnd.TopComponentDraggable; +import org.netbeans.swing.tabcontrol.customtabs.TabbedComponentFactory; +import org.netbeans.swing.tabcontrol.customtabs.TabbedType; +import org.openide.util.Lookup; import org.openide.windows.Mode; @@ -96,15 +100,12 @@ return panel; } + @Override protected Tabbed createTabbed() { - Tabbed tabbed; - if(getKind() == Constants.MODE_KIND_EDITOR) { - tabbed = new TabbedAdapter(Constants.MODE_KIND_EDITOR); - } else { - tabbed = new TabbedAdapter(Constants.MODE_KIND_VIEW); + TabbedComponentFactory factory = Lookup.getDefault().lookup(TabbedComponentFactory.class); + TabbedType type = getKind() == Constants.MODE_KIND_EDITOR ? TabbedType.Editor : TabbedType.View; + return factory.createTabbedComponent( type, new TabbedAdapter.WinsysInfo(getKind())).getTabbed(); } - return tabbed; - } protected void updateTitle(String title) { // no op Index: core.windows/src/org/netbeans/core/windows/view/ui/DefaultTabbedComponentFactory.java --- core.windows/src/org/netbeans/core/windows/view/ui/DefaultTabbedComponentFactory.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/DefaultTabbedComponentFactory.java Locally New @@ -0,0 +1,65 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 2012 Sun Microsystems, Inc. + */ +package org.netbeans.core.windows.view.ui; + +import org.netbeans.core.windows.view.ui.tabcontrol.TabbedAdapter; +import org.netbeans.swing.tabcontrol.WinsysInfoForTabbedContainer; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed.Accessor; +import org.netbeans.swing.tabcontrol.customtabs.TabbedComponentFactory; +import org.netbeans.swing.tabcontrol.customtabs.TabbedType; +import org.openide.util.lookup.ServiceProvider; + +/** + * Factory to create default tab containers. + * + * @since 2.43 + * + * @author S. Aubrecht + */ +@ServiceProvider(service=TabbedComponentFactory.class) +public class DefaultTabbedComponentFactory implements TabbedComponentFactory { + + @Override + public Accessor createTabbedComponent( TabbedType type, WinsysInfoForTabbedContainer info ) { + return new TabbedAdapter( type.toInt(), info ); + } +} Index: core.windows/src/org/netbeans/core/windows/view/ui/slides/CommandManager.java --- core.windows/src/org/netbeans/core/windows/view/ui/slides/CommandManager.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/slides/CommandManager.java Locally Modified (Based On LOCAL) @@ -459,7 +459,7 @@ * winsys through Tabbed instance */ private void postEvent(ActionEvent evt) { - ((TabbedSlideAdapter)slideBar.getTabbed()).postActionEvent(evt); + slideBar.getTabbedAdapter().postActionEvent(evt); } private final Action escapeAction = new EscapeAction(); Index: core.windows/src/org/netbeans/core/windows/view/ui/slides/SlideBar.java --- core.windows/src/org/netbeans/core/windows/view/ui/slides/SlideBar.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/slides/SlideBar.java Locally Modified (Based On LOCAL) @@ -79,7 +79,7 @@ import org.netbeans.core.windows.ModeImpl; import org.netbeans.core.windows.Switches; import org.netbeans.core.windows.WindowManagerImpl; -import org.netbeans.core.windows.view.ui.Tabbed; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; import org.netbeans.core.windows.view.ui.tabcontrol.TabbedAdapter; import org.netbeans.swing.tabcontrol.SlideBarDataModel; import org.netbeans.swing.tabcontrol.SlidingButton; @@ -405,6 +405,10 @@ @Override public Tabbed getTabbed () { + return tabbed.getTabbed(); + } + + TabbedSlideAdapter getTabbedAdapter() { return tabbed; } Index: core.windows/src/org/netbeans/core/windows/view/ui/slides/SlideBarContainer.java --- core.windows/src/org/netbeans/core/windows/view/ui/slides/SlideBarContainer.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/slides/SlideBarContainer.java Locally Modified (Based On LOCAL) @@ -69,7 +69,7 @@ import org.netbeans.core.windows.view.ui.AbstractModeContainer; import org.netbeans.core.windows.view.ui.ModeComponent; import org.netbeans.core.windows.view.dnd.TopComponentDroppable; -import org.netbeans.core.windows.view.ui.Tabbed; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; import org.openide.windows.TopComponent; @@ -123,7 +123,7 @@ @Override protected Tabbed createTabbed() { - return new TabbedSlideAdapter(((SlidingView)modeView).getSide()); + return new TabbedSlideAdapter(((SlidingView)modeView).getSide()).getTabbed(); } @Override Index: core.windows/src/org/netbeans/core/windows/view/ui/slides/TabbedSlideAdapter.java --- core.windows/src/org/netbeans/core/windows/view/ui/slides/TabbedSlideAdapter.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/slides/TabbedSlideAdapter.java Locally Modified (Based On LOCAL) @@ -65,10 +65,9 @@ import org.netbeans.core.windows.ModeImpl; import org.netbeans.core.windows.WindowManagerImpl; import org.netbeans.core.windows.actions.ActionUtils; -import org.netbeans.core.windows.view.ui.Tabbed; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; import org.netbeans.swing.tabcontrol.DefaultTabDataModel; import org.netbeans.core.windows.view.dnd.DragAndDropFeedbackVisualizer; -import org.netbeans.core.windows.view.dnd.TopComponentDraggable; import org.netbeans.swing.tabcontrol.SlideBarDataModel; import org.netbeans.swing.tabcontrol.TabData; import org.netbeans.swing.tabcontrol.TabDataModel; @@ -83,7 +82,7 @@ * * @author Dafe Simonek */ -public final class TabbedSlideAdapter implements Tabbed { +public final class TabbedSlideAdapter implements Tabbed.Accessor { /** data model of informations about top components in container */ private TabDataModel dataModel; @@ -106,112 +105,70 @@ slidingMode = findSlidingMode(); } + private final Tabbed tabbedImpl = new Tabbed() { + @Override - public void requestAttention (TopComponent tc) { + public void requestAttention( TopComponent tc ) { slideBar.setBlinking(tc, true); } @Override - public void cancelRequestAttention (TopComponent tc) { + public void cancelRequestAttention( TopComponent tc ) { slideBar.setBlinking(tc, false); } - - private void setSide (String side) { - int orientation = SlideBarDataModel.WEST; - if (Constants.LEFT.equals(side)) { - orientation = SlideBarDataModel.WEST; - } else if (Constants.RIGHT.equals(side)) { - orientation = SlideBarDataModel.EAST; - } else if (Constants.BOTTOM.equals(side)) { - orientation = SlideBarDataModel.SOUTH; - } else if (Constants.TOP.equals(side)) { - orientation = SlideBarDataModel.NORTH; + @Override + public void addTopComponent( String name, Icon icon, TopComponent tc, String toolTip ) { + dataModel.addTab(dataModel.size(), new TabData(tc, icon, name, toolTip)); } - ((SlideBarDataModel)dataModel).setOrientation(orientation); - } @Override - public final synchronized void addActionListener(ActionListener listener) { - if (actionListeners == null) { - actionListeners = new ArrayList(); + public TopComponent getTopComponentAt(int index) { + return (TopComponent)dataModel.getTab(index).getComponent(); } - actionListeners.add(listener); - } - /** - * Remove an action listener. - * - * @param listener The listener to remove. - */ @Override - public final synchronized void removeActionListener(ActionListener listener) { - if (actionListeners != null) { - actionListeners.remove(listener); - if (actionListeners.isEmpty()) { - actionListeners = null; + public TopComponent[] getTopComponents() { + int size = dataModel.size(); + TopComponent[] result = new TopComponent[size]; + for (int i=0; i < size; i++) { + result[i] = (TopComponent) dataModel.getTab(i).getComponent(); } + return result; } - } - final void postActionEvent(ActionEvent event) { - List list; - synchronized (this) { - if (actionListeners == null) - return; - list = Collections.unmodifiableList(actionListeners); + @Override + public TopComponent getSelectedTopComponent() { + int index = selModel.getSelectedIndex(); + return index < 0 ? null : (TopComponent)dataModel.getTab(index).getComponent(); } - for (int i = 0; i < list.size(); i++) { - list.get(i).actionPerformed(event); - } - } @Override - public void addChangeListener(ChangeListener listener) { + public void addChangeListener( ChangeListener listener ) { cs.addChangeListener(listener); } @Override - public void removeChangeListener(ChangeListener listener) { + public void removeChangeListener( ChangeListener listener ) { cs.removeChangeListener(listener); } - final void postSelectionEvent() { - cs.fireChange(); - } - - public void addPropertyChangeListener(String name, PropertyChangeListener listener) { - slideBar.addPropertyChangeListener(name, listener); - } - - public void removePropertyChangeListener(String name, PropertyChangeListener listener) { - slideBar.removePropertyChangeListener(name, listener); - } - @Override - public void addTopComponent(String name, Icon icon, TopComponent tc, String toolTip) { - dataModel.addTab(dataModel.size(), new TabData(tc, icon, name, toolTip)); + public void addActionListener( ActionListener al ) { + if (actionListeners == null) { + actionListeners = new ArrayList(); } - - @Override - public TopComponent getSelectedTopComponent() { - int index = selModel.getSelectedIndex(); - return index < 0 ? null : (TopComponent)dataModel.getTab(index).getComponent(); + actionListeners.add(al); } @Override - public TopComponent getTopComponentAt(int index) { - return (TopComponent)dataModel.getTab(index).getComponent(); + public void removeActionListener( ActionListener al ) { + if (actionListeners != null) { + actionListeners.remove(al); + if (actionListeners.isEmpty()) { + actionListeners = null; } - - @Override - public TopComponent[] getTopComponents() { - int size = dataModel.size(); - TopComponent[] result = new TopComponent[size]; - for (int i=0; i < size; i++) { - result[i] = (TopComponent) dataModel.getTab(i).getComponent(); } - return result; } @Override @@ -304,8 +261,6 @@ return slideBar; } -/*************** No DnD support yet **************/ - @Override public Object getConstraintForLocation(Point location, boolean attachingPossible) { int tab = slideBar.nextTabForCoordinate(location.x, location.y); @@ -313,7 +268,7 @@ } @Override - public Shape getIndicationForLocation(Point location, TopComponentDraggable startingTransfer, + public Shape getIndicationForLocation(Point location, TopComponent startingTransfer, Point startingPoint, boolean attachingPossible) { // int tab = tabForCoordinate(location); @@ -376,34 +331,28 @@ return null; } - public DragAndDropFeedbackVisualizer getDragAndDropFeedbackVisualizer( int tabIndex ) { - slideBar.getSelectionModel().setSelectedIndex(tabIndex); - return new DragAndDropFeedbackVisualizer( this, tabIndex ); -// TabData dt = slideBar.getModel().getTab(tabIndex); -// if (dt.getComponent() instanceof TopComponent) { -// DefaultTabDataModel tempModel = new DefaultTabDataModel( new TabData[] { dt } ); -// TabbedContainer temp = new TabbedContainer( tempModel, TabbedContainer.TYPE_VIEW ); -//JWindow w = new JWindow(); -//w.setBounds(-2000, -2000, 300, 300); -//w.getContentPane().add( temp ); -//w.setVisible(true); -////temp.setSize( 300,300 ); -////temp.setLocation( -10000,-10000); -////temp.setVisible(true); -////temp.invalidate(); -////temp.revalidate(); -////temp.repaint(); -//// temp.updateUI(); -////temp.getSelectionModel().setSelectedIndex(0); -// -// Window drag = temp.createDragWindow(0); -//// w.dispose(); -//return drag; -// } -// -// return null; + @Override + public Rectangle getTabBounds(int tabIndex) { + return slideBar.getTabBounds(tabIndex); } + @Override + public boolean isTransparent() { + return false; + } + + @Override + public void setTransparent(boolean transparent) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Rectangle getTabsArea() { + Rectangle res = slideBar.getBounds(); + res.setLocation( 0, 0 ); + return res; + } + /** Add action for disabling slide */ @Override public Action[] getPopupActions(Action[] defaultActions, int tabIndex) { @@ -419,29 +368,54 @@ } return result; } + }; - @Override - public Rectangle getTabBounds(int tabIndex) { - return slideBar.getTabBounds(tabIndex); + private void setSide (String side) { + int orientation = SlideBarDataModel.WEST; + if (Constants.LEFT.equals(side)) { + orientation = SlideBarDataModel.WEST; + } else if (Constants.RIGHT.equals(side)) { + orientation = SlideBarDataModel.EAST; + } else if (Constants.BOTTOM.equals(side)) { + orientation = SlideBarDataModel.SOUTH; + } else if (Constants.TOP.equals(side)) { + orientation = SlideBarDataModel.NORTH; } + ((SlideBarDataModel)dataModel).setOrientation(orientation); + } - @Override - public boolean isTransparent() { - return false; + final void postActionEvent(ActionEvent event) { + List list; + synchronized (this) { + if (actionListeners == null) + return; + list = Collections.unmodifiableList(actionListeners); } + for (int i = 0; i < list.size(); i++) { + list.get(i).actionPerformed(event); + } + } - @Override - public void setTransparent(boolean transparent) { - throw new UnsupportedOperationException("Not supported yet."); + final void postSelectionEvent() { + cs.fireChange(); } - @Override - public Rectangle getTabsArea() { - Rectangle res = slideBar.getBounds(); - res.setLocation( 0, 0 ); - return res; + public void addPropertyChangeListener(String name, PropertyChangeListener listener) { + slideBar.addPropertyChangeListener(name, listener); } + public void removePropertyChangeListener(String name, PropertyChangeListener listener) { + slideBar.removePropertyChangeListener(name, listener); + } + + + + public DragAndDropFeedbackVisualizer getDragAndDropFeedbackVisualizer( int tabIndex ) { + slideBar.getSelectionModel().setSelectedIndex(tabIndex); + return new DragAndDropFeedbackVisualizer( tabbedImpl, tabIndex ); + } + + final ModeImpl getSlidingMode() { return slidingMode; } @@ -470,5 +444,10 @@ return ((SlideBarDataModel)dataModel).getOrientation() == SlideBarDataModel.SOUTH || ((SlideBarDataModel)dataModel).getOrientation() == SlideBarDataModel.NORTH; } + + @Override + public Tabbed getTabbed() { + return tabbedImpl; } +} Index: core.windows/src/org/netbeans/core/windows/view/ui/Tabbed.java --- core.windows/src/org/netbeans/core/windows/view/ui/Tabbed.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/Tabbed.java Locally Deleted @@ -1,144 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - - -package org.netbeans.core.windows.view.ui; - - -import org.openide.windows.TopComponent; - -import javax.swing.*; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ActionListener; -import org.netbeans.core.windows.view.dnd.TopComponentDraggable; - - -/** - * Interface describing component which is used inside SimpleContainer. - * There will be at two implementations one for view and second one for editor type. - * - * @author Peter Zavadsky - */ -public interface Tabbed { - - public void requestAttention(TopComponent tc); - - public void cancelRequestAttention(TopComponent tc); - - public void addTopComponent(String name, Icon icon, TopComponent tc, String toolTip); - - public void insertComponent(String name, Icon icon, Component comp, String toolTip, int position); - - public void setTopComponents(TopComponent[] tcs, TopComponent selected); - - public int getTabCount(); - - public TopComponent[] getTopComponents(); - - public TopComponent getTopComponentAt(int index); - - public int indexOf(Component tc); - - public void removeComponent(Component comp); - - public void setTitleAt(int index, String title); - - public void setIconAt(int index, Icon icon); - - public void setToolTipTextAt(int index, String toolTip); - - public void setSelectedComponent(Component comp); - - public TopComponent getSelectedTopComponent(); - - public void addChangeListener(ChangeListener listener); - - public void removeChangeListener(ChangeListener listener); - - public void addActionListener (ActionListener al); - - public void removeActionListener (ActionListener al); - - public void setActive(boolean active); - - public int tabForCoordinate(Point p); - - public Shape getIndicationForLocation(Point location, TopComponentDraggable startingTransfer, - Point startingPoint, boolean attachingPossible); - - public Object getConstraintForLocation(Point location, boolean attachingPossible); - - public Image createImageOfTab (int tabIndex); - - /** Accessor for visual component holding components */ - public Component getComponent(); - - /** Allows tabbed implementors to speficy content of popup menu on tab - * with given index. Incoming actions are default set by winsys - */ - public Action[] getPopupActions(Action[] defaultActions, int tabIndex); - - /** Returns bounds of tab with given index */ - public Rectangle getTabBounds(int tabIndex); - - /** - * @return Bounds of the area which displays the tab headers. - * @since 2.32 - */ - public Rectangle getTabsArea(); - - public boolean isTransparent(); - - public void setTransparent( boolean transparent ); - - /** Interface for simple accessing of Tabbed instance */ - public interface Accessor { - - public Tabbed getTabbed (); - - } // end of Accessor - -} - Index: core.windows/src/org/netbeans/core/windows/view/ui/TabbedHandler.java --- core.windows/src/org/netbeans/core/windows/view/ui/TabbedHandler.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/TabbedHandler.java Locally Modified (Based On LOCAL) @@ -46,6 +46,7 @@ package org.netbeans.core.windows.view.ui; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; import org.netbeans.core.windows.Constants; import org.netbeans.core.windows.actions.ActionUtils; import org.netbeans.core.windows.actions.MaximizeWindowAction; @@ -69,7 +70,6 @@ import java.util.logging.Logger; import org.netbeans.core.windows.ModeImpl; import org.netbeans.core.windows.Switches; -import org.netbeans.core.windows.view.dnd.TopComponentDraggable; import org.netbeans.core.windows.view.ui.slides.SlideBar; import org.netbeans.core.windows.view.ui.slides.SlideBarActionEvent; import org.netbeans.core.windows.view.ui.slides.SlideOperationFactory; @@ -299,7 +299,7 @@ } // DnD>> - public Shape getIndicationForLocation(Point location, TopComponentDraggable startingTransfer, + public Shape getIndicationForLocation(Point location, TopComponent startingTransfer, Point startingPoint, boolean attachingPossible) { return tabbed.getIndicationForLocation(location, startingTransfer, startingPoint, attachingPossible); @@ -463,13 +463,13 @@ /** Possibly invokes the (un)maximization. */ public static void handleMaximization(TabActionEvent tae) { Component c = (Component) tae.getSource(); - while (c != null && !(c instanceof Tabbed)) + while (c != null && !(c instanceof Tabbed.Accessor)) c = c.getParent(); if (c == null) { return; } - final Tabbed tab = (Tabbed) c; + final Tabbed tab = ((Tabbed.Accessor) c).getTabbed(); TopComponent tc = tab.getTopComponentAt(tae.getTabIndex()); // perform action MaximizeWindowAction mwa = new MaximizeWindowAction(tc); Index: core.windows/src/org/netbeans/core/windows/view/ui/tabcontrol/TabbedAdapter.java --- core.windows/src/org/netbeans/core/windows/view/ui/tabcontrol/TabbedAdapter.java Base (BASE) +++ core.windows/src/org/netbeans/core/windows/view/ui/tabcontrol/TabbedAdapter.java Locally Modified (Based On LOCAL) @@ -52,7 +52,7 @@ import org.netbeans.core.windows.Constants; import org.netbeans.core.windows.Debug; import org.netbeans.core.windows.WindowManagerImpl; -import org.netbeans.core.windows.view.ui.Tabbed; +import org.netbeans.swing.tabcontrol.customtabs.Tabbed; import org.netbeans.swing.tabcontrol.ComponentConverter; import org.netbeans.swing.tabcontrol.TabData; import org.netbeans.swing.tabcontrol.TabbedContainer; @@ -64,12 +64,11 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.*; -import java.util.ArrayList; +import java.awt.event.ActionListener; import java.util.Arrays; import org.netbeans.core.windows.ModeImpl; import org.netbeans.core.windows.Switches; import org.netbeans.core.windows.actions.ActionUtils; -import org.netbeans.core.windows.view.dnd.TopComponentDraggable; import org.netbeans.swing.tabcontrol.TabDisplayer; import org.netbeans.swing.tabcontrol.WinsysInfoForTabbedContainer; import org.netbeans.swing.tabcontrol.event.TabActionEvent; @@ -81,7 +80,7 @@ * * @author Tim Boudreau */ -public class TabbedAdapter extends TabbedContainer implements Tabbed, Tabbed.Accessor, SlideController { +public class TabbedAdapter extends TabbedContainer implements Tabbed.Accessor, SlideController { public static final int DOCUMENT = 1; @@ -93,8 +92,8 @@ private PropertyChangeListener tooltipListener, weakTooltipListener; /** Creates a new instance of TabbedAdapter */ - public TabbedAdapter (int type) { - super (null, type, new WinsysInfo(type)); + public TabbedAdapter (int type, WinsysInfoForTabbedContainer winsysInfo) { + super (null, type, winsysInfo); getSelectionModel().addChangeListener(new ChangeListener() { @Override public void stateChanged (ChangeEvent ce) { @@ -104,11 +103,261 @@ } } }); -// Color fillC = (Color)UIManager.get("nb_workplace_fill"); //NOI18N -// if (fillC != null) setBackground (fillC); } + + public void addComponents(Component[] comps, String[] names, javax.swing.Icon[] icons, String[] tips) { + TabData[] data = new TabData[comps.length]; + for (int i=0; i < comps.length; i++) { + TabData td = new TabData (comps[i], icons[i], names[i], tips[i]); + data[i] = td; + comps[i].addPropertyChangeListener(JComponent.TOOL_TIP_TEXT_KEY, getTooltipListener(comps[i])); + } + getModel().addTabs (0, data); + } + + + /** Removes tooltip listeners from given tabs */ + private void detachTooltipListeners(List tabs) { + JComponent curComp; + for (Iterator iter = tabs.iterator(); iter.hasNext(); ) { + curComp = (JComponent)((TabData)iter.next()).getComponent(); + curComp.removePropertyChangeListener(JComponent.TOOL_TIP_TEXT_KEY, + getTooltipListener(curComp)); + } + } + + + private String getSideForLocation(Point location) { + Rectangle bounds = getBounds(); + bounds.setLocation(0, 0); + + final int TOP_HEIGHT = 10; + final int BOTTOM_HEIGHT = (int)(0.25 * bounds.height); + + final int LEFT_WIDTH = Math.max (getWidth() / 8, 40); + final int RIGHT_WIDTH = LEFT_WIDTH; + + if(DEBUG) { + debugLog(""); // NOI18N + debugLog("TOP_HEIGHT =" + TOP_HEIGHT); // NOI18N + debugLog("BOTTOM_HEIGHT =" + BOTTOM_HEIGHT); // NOI18N + debugLog("LEFT_WIDTH =" + LEFT_WIDTH); // NOI18N + debugLog("RIGHT_WIDTH =" + RIGHT_WIDTH); // NOI18N + } + + // Size of area which indicates creation of new split. +// int delta = Constants.DROP_AREA_SIZE; + Rectangle top = new Rectangle(0, 0, bounds.width, BOTTOM_HEIGHT); + if(top.contains(location)) { + return Constants.TOP; + } + + Polygon left = new EqualPolygon( + new int[] {0, LEFT_WIDTH, LEFT_WIDTH, 0}, + new int[] {TOP_HEIGHT, TOP_HEIGHT, bounds.height - BOTTOM_HEIGHT, bounds.height}, + 4 + ); + if(left.contains(location)) { + return Constants.LEFT; + } + + Polygon right = new EqualPolygon( + new int[] {bounds.width - RIGHT_WIDTH, bounds.width, bounds.width, bounds.width - RIGHT_WIDTH}, + new int[] {TOP_HEIGHT, TOP_HEIGHT, bounds.height, bounds.height - BOTTOM_HEIGHT}, + 4 + ); + if(right.contains(location)) { + return Constants.RIGHT; + } + + Polygon bottom = new EqualPolygon( + new int[] {LEFT_WIDTH, bounds.width - RIGHT_WIDTH, bounds.width, 0}, + new int[] {bounds.height - BOTTOM_HEIGHT, bounds.height - BOTTOM_HEIGHT, bounds.height, bounds.height}, + 4 + ); + if(bottom.contains(location)) { + return Constants.BOTTOM; + } + + return null; + } + + private Shape getStartingIndication(Point startingPoint, Point location) { + Rectangle rect = getBounds(); + rect.setLocation(location.x - startingPoint.x, location.y - startingPoint.y); + return rect; + } + // DnD<< + + + /** Notifies all registered listeners about the event. */ + private void fireStateChanged() { + if (!SwingUtilities.isEventDispatchThread()) { + Logger.getAnonymousLogger().warning( + "All state changes to the tab component must happen on the event thread!"); //NOI18N + Exception e = new Exception(); + e.fillInStackTrace(); + Logger.getAnonymousLogger().warning(e.getStackTrace()[1].toString()); + } + + //Note: Firing the events while holding the tree lock avoids many + //gratuitous repaints that slow down switching tabs. To demonstrate this, + //comment this code out and run the IDE with -J-Dawt.nativeDoubleBuffering=true + //so you'll really see every repaint. When switching between a form + //tab and an editor tab, you will see the property sheet get repainted + //8 times due to changes in the component hierarchy, before the + //selected node is even changed to the appropriate one for the new tab. + //Synchronizing here ensures that never happens. + + // [dafe]: Firing under tree lock is bad practice and causes deadlocking, + // see http://www.netbeans.org/issues/show_bug.cgi?id=120874 + // Comments above seems not to be valid anymore in JDK 1.5 and + // newer. Even if running with -J-Dawt.nativeDoubleBuffering=true, there + // is no difference in number of repaints no matter if holding the tree + // lock or not. Repeated redrawing seems to be coalesced well, so removing + // AWT tree lock + + cs.fireChange(); + } + + private static void debugLog(String message) { + Debug.log(TabbedAdapter.class, message); + } + + private ModeImpl getModeImpl() { + TopComponent[] topComponents = tabbedImpl.getTopComponents(); + if( topComponents.length < 1 ) + return null; + return ( ModeImpl ) WindowManagerImpl.getInstance().findMode( topComponents[0] ); + } + + /** Finds out in what state is window system mode containing given component. + * + * @return true if given component is inside mode which is in maximized state, + * false otherwise + */ + public static boolean isInMaximizedMode (Component comp) { + ModeImpl maxMode = WindowManagerImpl.getInstance().getCurrentMaximizedMode(); + if (maxMode == null) { + return false; + } + return maxMode.containsTopComponent((TopComponent)comp); + } + + /********** implementation of SlideController *****************/ + @Override + public void userToggledAutoHide(int tabIndex, boolean enabled) { + postActionEvent(new TabActionEvent(this, TabbedContainer.COMMAND_ENABLE_AUTO_HIDE, tabIndex)); + } + + @Override + public void userToggledTransparency(int tabIndex) { + postActionEvent(new TabActionEvent(this, TabbedContainer.COMMAND_TOGGLE_TRANSPARENCY, tabIndex)); + } + + /********* implementation of Tabbed.Accessor **************/ + + @Override + public Tabbed getTabbed() { + return tabbedImpl; + } + + /********* implementation of WinsysInfoForTabbed ********/ + + public static class WinsysInfo extends WinsysInfoForTabbedContainer { + private int containerType; + public WinsysInfo( int containerType ) { + this.containerType = containerType; + } + + @Override + public Object getOrientation (Component comp) { + WindowManagerImpl wmi = WindowManagerImpl.getInstance(); + // don't show pin button in separate views + if (!wmi.isDocked((TopComponent)comp)) { + return TabDisplayer.ORIENTATION_INVISIBLE; + } + + String side = wmi.guessSlideSide((TopComponent)comp); + Object result = null; + if (side.equals(Constants.LEFT)) { + result = TabDisplayer.ORIENTATION_WEST; + } else if (side.equals(Constants.RIGHT)) { + result = TabDisplayer.ORIENTATION_EAST; + } else if (side.equals(Constants.BOTTOM)) { + result = TabDisplayer.ORIENTATION_SOUTH; + } else if (side.equals(Constants.TOP)) { + result = TabDisplayer.ORIENTATION_NORTH; + } else { + result = TabDisplayer.ORIENTATION_CENTER; + } + return result; + } + + @Override + public boolean inMaximizedMode (Component comp) { + return isInMaximizedMode(comp); + } + + @Override + public boolean isTopComponentSlidingEnabled() { + return Switches.isTopComponentSlidingEnabled(); + } + + @Override + public boolean isTopComponentClosingEnabled() { + if( containerType == Constants.MODE_KIND_EDITOR ) + return Switches.isEditorTopComponentClosingEnabled(); + else + return Switches.isViewTopComponentClosingEnabled(); + } + + @Override + public boolean isTopComponentMaximizationEnabled() { + return Switches.isTopComponentMaximizationEnabled(); + } + + @Override + public boolean isTopComponentClosingEnabled(TopComponent tc) { + return !Boolean.TRUE.equals(tc.getClientProperty(TopComponent.PROP_CLOSING_DISABLED)) + && isTopComponentClosingEnabled(); + } + + @Override + public boolean isTopComponentMaximizationEnabled(TopComponent tc) { + return !Boolean.TRUE.equals(tc.getClientProperty(TopComponent.PROP_MAXIMIZATION_DISABLED)) + && isTopComponentMaximizationEnabled(); + } + + @Override + public boolean isTopComponentSlidingEnabled(TopComponent tc) { + return !Boolean.TRUE.equals(tc.getClientProperty(TopComponent.PROP_SLIDING_DISABLED)) + && isTopComponentSlidingEnabled(); + } + + @Override + public boolean isModeSlidingEnabled() { + return Switches.isModeSlidingEnabled(); + } + } // end of LocInfo + + /** Returns instance of weak property change listener used to listen to + * tooltip changes. Weak listener is needed, in some situations (close of + * whole mode), our class is not notified from winsys. + */ + private PropertyChangeListener getTooltipListener(Component comp) { + if (tooltipListener == null) { + tooltipListener = new ToolTipListener(); + weakTooltipListener = WeakListeners.propertyChange(tooltipListener, comp); + } + return weakTooltipListener; + } + + private final Tabbed tabbedImpl = new Tabbed() { + + @Override public void addTopComponent(String name, javax.swing.Icon icon, TopComponent tc, String toolTip) { insertComponent (name, icon, tc, toolTip, getTabCount()); } @@ -131,7 +380,7 @@ public void requestAttention (TopComponent tc) { int idx = indexOf(tc); if (idx >= 0) { - requestAttention(idx); + TabbedAdapter.this.requestAttention(idx); } else { Logger.getAnonymousLogger().fine( "RequestAttention on component unknown to container: " + tc); //NOI18N @@ -142,7 +391,7 @@ public void cancelRequestAttention (TopComponent tc) { int idx = indexOf(tc); if (idx >= 0) { - cancelRequestAttention(idx); + TabbedAdapter.this.cancelRequestAttention(idx); } else { throw new IllegalArgumentException ("TopComponent " + tc + " is not a child of this container"); //NOI18N @@ -194,15 +443,14 @@ } } - public void addComponents(Component[] comps, String[] names, javax.swing.Icon[] icons, String[] tips) { - ArrayList al = new ArrayList (comps.length); - TabData[] data = new TabData[comps.length]; - for (int i=0; i < comps.length; i++) { - TabData td = new TabData (comps[i], icons[i], names[i], tips[i]); - data[i] = td; - comps[i].addPropertyChangeListener(JComponent.TOOL_TIP_TEXT_KEY, getTooltipListener(comps[i])); + @Override + public Rectangle getTabBounds(int tabIndex) { + return getTabRect(tabIndex, new Rectangle()); } - getModel().addTabs (0, data); + + @Override + public Rectangle getTabsArea() { + return getUI().getTabsArea(); } @Override @@ -264,17 +512,6 @@ repaint(); } } - - /** Removes tooltip listeners from given tabs */ - private void detachTooltipListeners(List tabs) { - JComponent curComp; - for (Iterator iter = tabs.iterator(); iter.hasNext(); ) { - curComp = (JComponent)((TabData)iter.next()).getComponent(); - curComp.removePropertyChangeListener(JComponent.TOOL_TIP_TEXT_KEY, - getTooltipListener(curComp)); - } - } - // DnD>> /** Finds tab which contains x coordinate of given location point. * @param location The point for which a constraint is required @@ -308,12 +545,12 @@ */ @Override public Shape getIndicationForLocation(Point location, - TopComponentDraggable startingTransfer, Point startingPoint, boolean attachingPossible) { + TopComponent startingTransfer, Point startingPoint, boolean attachingPossible) { Rectangle rect = getBounds(); rect.setLocation(0, 0); - TopComponent draggedTC = startingTransfer.getTopComponent(); + TopComponent draggedTC = startingTransfer; //#47909 int tab = tabForCoordinate(location); // first process the tabs when mouse is inside the tabs area.. @@ -349,77 +586,31 @@ return s; } - if( startingTransfer.isTopComponentTransfer() && startingPoint != null - && indexOf(startingTransfer.getTopComponent()) != -1) { + if( null != startingTransfer && startingPoint != null + && indexOf(startingTransfer) != -1) { return getStartingIndication(startingPoint, location); } return rect; } - private String getSideForLocation(Point location) { - Rectangle bounds = getBounds(); - bounds.setLocation(0, 0); - - final int TOP_HEIGHT = 10; - final int BOTTOM_HEIGHT = (int)(0.25 * bounds.height); - - final int LEFT_WIDTH = Math.max (getWidth() / 8, 40); - final int RIGHT_WIDTH = LEFT_WIDTH; - - if(DEBUG) { - debugLog(""); // NOI18N - debugLog("TOP_HEIGHT =" + TOP_HEIGHT); // NOI18N - debugLog("BOTTOM_HEIGHT =" + BOTTOM_HEIGHT); // NOI18N - debugLog("LEFT_WIDTH =" + LEFT_WIDTH); // NOI18N - debugLog("RIGHT_WIDTH =" + RIGHT_WIDTH); // NOI18N + @Override + public Component getComponent() { + return TabbedAdapter.this; } - // Size of area which indicates creation of new split. -// int delta = Constants.DROP_AREA_SIZE; - Rectangle top = new Rectangle(0, 0, bounds.width, BOTTOM_HEIGHT); - if(top.contains(location)) { - return Constants.TOP; - } - - Polygon left = new EqualPolygon( - new int[] {0, LEFT_WIDTH, LEFT_WIDTH, 0}, - new int[] {TOP_HEIGHT, TOP_HEIGHT, bounds.height - BOTTOM_HEIGHT, bounds.height}, - 4 - ); - if(left.contains(location)) { - return Constants.LEFT; - } - - Polygon right = new EqualPolygon( - new int[] {bounds.width - RIGHT_WIDTH, bounds.width, bounds.width, bounds.width - RIGHT_WIDTH}, - new int[] {TOP_HEIGHT, TOP_HEIGHT, bounds.height, bounds.height - BOTTOM_HEIGHT}, - 4 - ); - if(right.contains(location)) { - return Constants.RIGHT; - } - - Polygon bottom = new EqualPolygon( - new int[] {LEFT_WIDTH, bounds.width - RIGHT_WIDTH, bounds.width, 0}, - new int[] {bounds.height - BOTTOM_HEIGHT, bounds.height - BOTTOM_HEIGHT, bounds.height, bounds.height}, - 4 - ); - if(bottom.contains(location)) { - return Constants.BOTTOM; - } - + /** Add action for enabling auto hide of views */ + @Override + public Action[] getPopupActions(Action[] defaultActions, int tabIndex) { + if( tabIndex < 0 ) { + ModeImpl mode = getModeImpl(); + if( null != mode ) + return ActionUtils.createDefaultPopupActions( mode ); return null; } - - private Shape getStartingIndication(Point startingPoint, Point location) { - Rectangle rect = getBounds(); - rect.setLocation(location.x - startingPoint.x, location.y - startingPoint.y); - return rect; + return defaultActions; } - // DnD<< - /** Registers ChangeListener to receive events. * @param listener The listener to register. * @@ -438,197 +629,68 @@ cs.removeChangeListener(listener); } - /** Notifies all registered listeners about the event. */ - private void fireStateChanged() { - if (!SwingUtilities.isEventDispatchThread()) { - Logger.getAnonymousLogger().warning( - "All state changes to the tab component must happen on the event thread!"); //NOI18N - Exception e = new Exception(); - e.fillInStackTrace(); - Logger.getAnonymousLogger().warning(e.getStackTrace()[1].toString()); - } - - //Note: Firing the events while holding the tree lock avoids many - //gratuitous repaints that slow down switching tabs. To demonstrate this, - //comment this code out and run the IDE with -J-Dawt.nativeDoubleBuffering=true - //so you'll really see every repaint. When switching between a form - //tab and an editor tab, you will see the property sheet get repainted - //8 times due to changes in the component hierarchy, before the - //selected node is even changed to the appropriate one for the new tab. - //Synchronizing here ensures that never happens. - - // [dafe]: Firing under tree lock is bad practice and causes deadlocking, - // see http://www.netbeans.org/issues/show_bug.cgi?id=120874 - // Comments above seems not to be valid anymore in JDK 1.5 and - // newer. Even if running with -J-Dawt.nativeDoubleBuffering=true, there - // is no difference in number of repaints no matter if holding the tree - // lock or not. Repeated redrawing seems to be coalesced well, so removing - // AWT tree lock - - cs.fireChange(); - } - - private static void debugLog(String message) { - Debug.log(TabbedAdapter.class, message); - } - @Override - public Component getComponent() { - return this; + public int getTabCount() { + return TabbedAdapter.this.getTabCount(); } - /** Add action for enabling auto hide of views */ @Override - public Action[] getPopupActions(Action[] defaultActions, int tabIndex) { - if( tabIndex < 0 ) { - ModeImpl mode = getModeImpl(); - if( null != mode ) - return ActionUtils.createDefaultPopupActions( mode ); - return null; + public int indexOf( Component tc ) { + return TabbedAdapter.this.indexOf( tc ); } - return defaultActions; - } - private ModeImpl getModeImpl() { - TopComponent[] topComponents = getTopComponents(); - if( topComponents.length < 1 ) - return null; - return ( ModeImpl ) WindowManagerImpl.getInstance().findMode( topComponents[0] ); - } - - /** Finds out in what state is window system mode containing given component. - * - * @return true if given component is inside mode which is in maximized state, - * false otherwise - */ - public static boolean isInMaximizedMode (Component comp) { - ModeImpl maxMode = WindowManagerImpl.getInstance().getCurrentMaximizedMode(); - if (maxMode == null) { - return false; - } - return maxMode.containsTopComponent((TopComponent)comp); - } - - /********** implementation of SlideController *****************/ - @Override - public void userToggledAutoHide(int tabIndex, boolean enabled) { - postActionEvent(new TabActionEvent(this, TabbedContainer.COMMAND_ENABLE_AUTO_HIDE, tabIndex)); + public void setTitleAt( int index, String title ) { + TabbedAdapter.this.setTitleAt( index, title ); } @Override - public void userToggledTransparency(int tabIndex) { - postActionEvent(new TabActionEvent(this, TabbedContainer.COMMAND_TOGGLE_TRANSPARENCY, tabIndex)); + public void setIconAt( int index, Icon icon ) { + TabbedAdapter.this.setIconAt( index, icon ); } - /********* implementation of Tabbed.Accessor **************/ - @Override - public Tabbed getTabbed() { - return this; + public void setToolTipTextAt( int index, String toolTip ) { + TabbedAdapter.this.setToolTipTextAt( index, toolTip ); } @Override - public Rectangle getTabBounds(int tabIndex) { - return getTabRect(tabIndex, new Rectangle()); + public void addActionListener( ActionListener al ) { + TabbedAdapter.this.addActionListener( al ); } @Override - public Rectangle getTabsArea() { - return getUI().getTabsArea(); + public void removeActionListener( ActionListener al ) { + TabbedAdapter.this.removeActionListener( al ); } - /********* implementation of WinsysInfoForTabbed ********/ - - static class WinsysInfo extends WinsysInfoForTabbedContainer { - private int containerType; - public WinsysInfo( int containerType ) { - this.containerType = containerType; - } - @Override - public Object getOrientation (Component comp) { - WindowManagerImpl wmi = WindowManagerImpl.getInstance(); - // don't show pin button in separate views - if (!wmi.isDocked((TopComponent)comp)) { - return TabDisplayer.ORIENTATION_INVISIBLE; + public void setActive( boolean active ) { + TabbedAdapter.this.setActive( active ); } - String side = wmi.guessSlideSide((TopComponent)comp); - Object result = null; - if (side.equals(Constants.LEFT)) { - result = TabDisplayer.ORIENTATION_WEST; - } else if (side.equals(Constants.RIGHT)) { - result = TabDisplayer.ORIENTATION_EAST; - } else if (side.equals(Constants.BOTTOM)) { - result = TabDisplayer.ORIENTATION_SOUTH; - } else if (side.equals(Constants.TOP)) { - result = TabDisplayer.ORIENTATION_NORTH; - } else { - result = TabDisplayer.ORIENTATION_CENTER; - } - return result; - } - @Override - public boolean inMaximizedMode (Component comp) { - return isInMaximizedMode(comp); + public int tabForCoordinate( Point p ) { + return TabbedAdapter.this.tabForCoordinate( p ); } @Override - public boolean isTopComponentSlidingEnabled() { - return Switches.isTopComponentSlidingEnabled(); + public Image createImageOfTab( int tabIndex ) { + return TabbedAdapter.this.createImageOfTab( tabIndex ); } @Override - public boolean isTopComponentClosingEnabled() { - if( containerType == Constants.MODE_KIND_EDITOR ) - return Switches.isEditorTopComponentClosingEnabled(); - else - return Switches.isViewTopComponentClosingEnabled(); + public boolean isTransparent() { + return TabbedAdapter.this.isTransparent(); } @Override - public boolean isTopComponentMaximizationEnabled() { - return Switches.isTopComponentMaximizationEnabled(); + public void setTransparent( boolean transparent ) { + TabbedAdapter.this.setTransparent( transparent ); } - @Override - public boolean isTopComponentClosingEnabled(TopComponent tc) { - return !Boolean.TRUE.equals(tc.getClientProperty(TopComponent.PROP_CLOSING_DISABLED)) - && isTopComponentClosingEnabled(); - } + }; - @Override - public boolean isTopComponentMaximizationEnabled(TopComponent tc) { - return !Boolean.TRUE.equals(tc.getClientProperty(TopComponent.PROP_MAXIMIZATION_DISABLED)) - && isTopComponentMaximizationEnabled(); - } - - @Override - public boolean isTopComponentSlidingEnabled(TopComponent tc) { - return !Boolean.TRUE.equals(tc.getClientProperty(TopComponent.PROP_SLIDING_DISABLED)) - && isTopComponentSlidingEnabled(); - } - - @Override - public boolean isModeSlidingEnabled() { - return Switches.isModeSlidingEnabled(); - } - } // end of LocInfo - - /** Returns instance of weak property change listener used to listen to - * tooltip changes. Weak listener is needed, in some situations (close of - * whole mode), our class is not notified from winsys. - */ - private PropertyChangeListener getTooltipListener(Component comp) { - if (tooltipListener == null) { - tooltipListener = new ToolTipListener(); - weakTooltipListener = WeakListeners.propertyChange(tooltipListener, comp); - } - return weakTooltipListener; - } - /** Listening to changes of tooltips of currently asociated top components */ private class ToolTipListener implements PropertyChangeListener {