use of com.revolsys.swing.component.TabClosableTitle in project com.revolsys.open by revolsys.
the class ProjectFrame method addBottomTab.
public void addBottomTab(final ProjectFramePanel panel, final Map<String, Object> config) {
Invoke.later(() -> {
final TabbedPane tabs = getBottomTabs();
final Object tableView = panel.getProperty(BOTTOM_TAB);
Component component = null;
if (tableView instanceof Component) {
component = (Component) tableView;
if (component.getParent() != tabs) {
component = null;
}
}
if (component == null) {
component = panel.newPanelComponent(config);
if (component != null) {
final Component panelComponent = component;
panel.activatePanelComponent(panelComponent, config);
final int tabIndex = tabs.getTabCount();
panel.setPropertyWeak(BOTTOM_TAB, panelComponent);
final String layerPath = panel.getPath();
final Runnable closeAction = () -> removeBottomTab(panel);
synchronized (this.bottomTabLayerPaths) {
this.bottomTabLayerPaths.add(layerPath);
}
final String name = panel.getName();
final Icon icon = panel.getIcon();
final TabClosableTitle tab = tabs.addClosableTab(name, icon, panelComponent, closeAction);
tab.setMenu(panel);
tabs.setSelectedIndex(tabIndex);
panel.setPropertyWeak(BOTTOM_TAB_LISTENER, //
Arrays.asList(EventQueue.addPropertyChange(panel, "name", () -> {
final int index = tabs.indexOfComponent(panelComponent);
if (index != -1) {
final String newName = panel.getName();
tabs.setTitleAt(index, newName);
}
}), //
EventQueue.addPropertyChange(panel, "icon", () -> {
final int index = tabs.indexOfComponent(panelComponent);
if (index != -1) {
final Icon newName = panel.getIcon();
tabs.setIconAt(index, newName);
}
})));
}
} else {
panel.activatePanelComponent(component, config);
tabs.setSelectedComponent(component);
}
});
}
use of com.revolsys.swing.component.TabClosableTitle in project com.revolsys.open by revolsys.
the class TabbedPane method addClosableTab.
public TabClosableTitle addClosableTab(final String title, final Icon icon, final Component component, final Runnable closeAction) {
final int tabIndex = getTabCount();
addTab(title, icon, component);
final TabClosableTitle tabTitle = new TabClosableTitle(this, closeAction);
setTabComponentAt(tabIndex, tabTitle);
return tabTitle;
}
Aggregations