fr.ird.observe.client.form.spi.init.JTabbedPaneInitializer Maven / Gradle / Ivy
package fr.ird.observe.client.form.spi.init;
/*-
* #%L
* ObServe Toolkit :: Common Client
* %%
* Copyright (C) 2008 - 2017 IRD, Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* .
* #L%
*/
import fr.ird.observe.client.ObserveKeyStrokes;
import fr.ird.observe.client.form.FormUI;
import fr.ird.observe.client.form.spi.FormUIComponentInitializerSupport;
import fr.ird.observe.client.form.spi.FormUIInitializerContext;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JTabbedPane;
/**
* Created by tchemit on 20/09/17.
*
* @author Tony Chemit - [email protected]
*/
public class JTabbedPaneInitializer> extends FormUIComponentInitializerSupport {
public static final String MAIN_TABBED_PANE = "mainTabbedPane";
public static final String SUB_TABBED_PANE = "subTabbedPane";
public JTabbedPaneInitializer() {
super(JTabbedPane.class);
}
@Override
public void init(V context, JTabbedPane component) {
boolean mainTabbedPane = MAIN_TABBED_PANE.equals(component.getName());
boolean subTabbedPane = SUB_TABBED_PANE.equals(component.getName());
if (!mainTabbedPane && !subTabbedPane) {
return;
}
int tabCount = component.getTabCount();
InputMap inputMap = context.getUi().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
if (mainTabbedPane) {
ObserveKeyStrokes.addKeyStrokeToMainTabbedPane(component);
if (tabCount > 0) {
inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_1, "fr.ird.observe.client.ui.actions.content.GoToTab1UIAction");
}
if (tabCount > 1) {
inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_2, "fr.ird.observe.client.ui.actions.content.GoToTab1UIAction");
}
if (tabCount > 2) {
inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_3, "fr.ird.observe.client.ui.actions.content.GoToTab3UIAction");
}
if (tabCount > 3) {
inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_4, "fr.ird.observe.client.ui.actions.content.GoToTab4UIAction");
}
if (tabCount > 4) {
inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_5, "fr.ird.observe.client.ui.actions.content.GoToTab5UIAction");
}
if (tabCount > 5) {
inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_6, "fr.ird.observe.client.ui.actions.content.GoToTab6UIAction");
}
}
if (subTabbedPane) {
ObserveKeyStrokes.addKeyStrokeToSubTabbedPane(component);
if (tabCount > 0) {
inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_SUB_TAB_1, "fr.ird.observe.client.ui.actions.content.GoToSubTab1UIAction");
}
if (tabCount > 1) {
inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_SUB_TAB_2, "fr.ird.observe.client.ui.actions.content.GoToSubTab2UIAction");
}
if (tabCount > 2) {
inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_SUB_TAB_3, "fr.ird.observe.client.ui.actions.content.GoToSubTab3UIAction");
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy