
it.tidalwave.netbeans.lookandfeel.ui.openide.NoTabsTabDisplayerUI Maven / Gradle / Ivy
The newest version!
/***********************************************************************************************************************
*
* SolidBlue - open source safe data
* Copyright (C) 2011-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************
*
* WWW: http://solidblue.java.net
* SCM: https://bitbucket.org/tidalwave/solidblue-src
*
**********************************************************************************************************************/
package it.tidalwave.netbeans.lookandfeel.ui.openide;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import javax.annotation.Nonnull;
import javax.swing.BorderFactory;
import javax.swing.DefaultSingleSelectionModel;
import javax.swing.JComponent;
import javax.swing.SingleSelectionModel;
import javax.swing.plaf.ComponentUI;
import org.netbeans.swing.tabcontrol.TabDisplayer;
import org.netbeans.swing.tabcontrol.TabDisplayerUI;
/*******************************************************************************
*
* See http://blogs.sun.com/roller/page/geertjan?entry=farewell_to_space_consuming_weird
*
* @author Fabrizio Giudici
* @version $Id$
*
******************************************************************************/
public class NoTabsTabDisplayerUI extends TabDisplayerUI
{
private static final int[] PTS = new int[] { 0, 0, 0 };
@Nonnull
public static ComponentUI createUI (final @Nonnull JComponent jc)
{
assert jc instanceof TabDisplayer;
return new NoTabsTabDisplayerUI((TabDisplayer)jc);
}
public NoTabsTabDisplayerUI (final @Nonnull TabDisplayer displayer)
{
super(displayer);
displayer.setBorder(BorderFactory.createEmptyBorder());
}
@Override @Nonnull
public Polygon getExactTabIndication (final int i)
{
//Should never be called
return new Polygon(PTS, PTS, PTS.length);
}
@Override @Nonnull
public Polygon getInsertTabIndication (final int i)
{
return new Polygon(PTS, PTS, PTS.length);
}
@Override @Nonnull
public int tabForCoordinate (final @Nonnull Point point)
{
return -1;
}
@Override @Nonnull
public Rectangle getTabRect (int i, final @Nonnull Rectangle rectangle)
{
return new Rectangle(0,0,0,0);
}
@Override @Nonnull
protected SingleSelectionModel createSelectionModel()
{
return new DefaultSingleSelectionModel();
}
@Nonnull
public String getCommandAtPoint (final @Nonnull Point point)
{
return null;
}
@Override @Nonnull
public int dropIndexOfPoint (final @Nonnull Point point)
{
return -1;
}
@Override @Nonnull
public void registerShortcuts (final @Nonnull JComponent jComponent)
{
//do nothing
}
@Override @Nonnull
public void unregisterShortcuts (final @Nonnull JComponent jComponent)
{
//do nothing
}
@Override @Nonnull
protected void requestAttention (final int i)
{
//do nothing
}
@Override @Nonnull
protected void cancelRequestAttention (final int i)
{
//do nothing
}
@Override @Nonnull
public Dimension getPreferredSize (final @Nonnull JComponent c)
{
return new Dimension(0, 0);
}
@Override @Nonnull
public Dimension getMinimumSize (final @Nonnull JComponent c)
{
return new Dimension(0, 0);
}
@Override @Nonnull
public Dimension getMaximumSize (final @Nonnull JComponent c)
{
return new Dimension(0, 0);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy