/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.geoforge.guillc.tabbedpane;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.JTabbedPane;
import org.geoforge.io.handler.IGfrHandlerUnserializedObject;
import org.geoforge.lang.handler.IGfrHandlerLifeCycleObject;
/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
public class GfrTab extends JTabbedPane implements
IGfrHandlerLifeCycleObject,
IGfrHandlerUnserializedObject
{
public GfrTab()
{
super(JTabbedPane.TOP);
}
@Override
public boolean init()
{
return true;
}
@Override
public void destroy()
{
for (int i = 0; i < super.getComponentCount(); i++)
{
Component cmpCur = super.getComponent(i);
if (cmpCur instanceof IGfrHandlerLifeCycleObject)
{
IGfrHandlerLifeCycleObject obj = (IGfrHandlerLifeCycleObject) cmpCur;
obj.destroy();
}
}
}
@Override
public void loadUnserializedObject() throws Exception
{
for (int i = 0; i < super.getComponentCount(); i++)
{
Component cmpCur = super.getComponent(i);
if (cmpCur instanceof IGfrHandlerUnserializedObject)
{
IGfrHandlerUnserializedObject serCur = (IGfrHandlerUnserializedObject) cmpCur;
serCur.loadUnserializedObject();
}
}
}
@Override
public void releaseUnserializedObject() throws Exception
{
for (int i = 0; i < super.getComponentCount(); i++)
{
Component cmpCur = super.getComponent(i);
if (cmpCur instanceof IGfrHandlerUnserializedObject)
{
IGfrHandlerUnserializedObject serCur = (IGfrHandlerUnserializedObject) cmpCur;
serCur.releaseUnserializedObject();
}
}
}
// may be use a static method in the scope
@Override
public void setPreferredSize(Dimension dim)
{
/*if (GfrSystem.s_isLinux())
{
String strNameFont = System.getProperty("_geoforge.appli.name.font");
if (strNameFont!=null && strNameFont.toLowerCase().compareTo("garuda") == 0)
{
Dimension dimNew = new Dimension(dim.width, dim.height + 20);
super.setPreferredSize(dimNew);
return;
}
} */
super.setPreferredSize(dim);
}
// may be use a static method in the scope
@Override
public void setMaximumSize(Dimension dim)
{
/*if (GfrSystem.s_isLinux())
{
String strNameFont = System.getProperty("_geoforge.appli.name.font");
if (strNameFont!=null && strNameFont.toLowerCase().compareTo("garuda") == 0)
{
Dimension dimNew = new Dimension(dim.width, dim.height + 20);
super.setMaximumSize(dimNew);
return;
}
} */
super.setMaximumSize(dim);
}
// may be use a static method in the scope
@Override
public void setMinimumSize(Dimension dim)
{
/*if (GfrSystem.s_isLinux())
{
String strNameFont = System.getProperty("_geoforge.appli.name.font");
if (strNameFont!=null && strNameFont.toLowerCase().compareTo("garuda") == 0)
{
Dimension dimNew = new Dimension(dim.width, dim.height + 20);
super.setMinimumSize(dimNew);
return;
}
} */
super.setMinimumSize(dim);
}
}