Search in sources :

Example 86 with CardLayout

use of java.awt.CardLayout in project JMRI by JMRI.

the class TabbedPreferences method selection.

void selection(String View) {
    CardLayout cl = (CardLayout) (detailpanel.getLayout());
    cl.show(detailpanel, View);
}
Also used : CardLayout(java.awt.CardLayout)

Example 87 with CardLayout

use of java.awt.CardLayout in project JMRI by JMRI.

the class TabbedPreferences method init.

/**
     * Initialize, including loading classes provided by a
     * {@link java.util.ServiceLoader}.
     * <p>
     * Keeps a current state to prevent doing its work twice.
     *
     * @return The current state, which should be INITIALISED if all is well.
     */
@SuppressWarnings("rawtypes")
public synchronized int init() {
    if (initialisationState == INITIALISED) {
        return INITIALISED;
    }
    if (initialisationState != UNINITIALISED) {
        return initialisationState;
    }
    this.setInitalisationState(INITIALISING);
    list = new JList<>();
    listScroller = new JScrollPane(list);
    listScroller.setPreferredSize(new Dimension(100, 100));
    buttonpanel = new JPanel();
    buttonpanel.setLayout(new BoxLayout(buttonpanel, BoxLayout.Y_AXIS));
    buttonpanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 3));
    detailpanel = new JPanel();
    detailpanel.setLayout(new CardLayout());
    detailpanel.setBorder(BorderFactory.createEmptyBorder(6, 3, 6, 6));
    save = new JButton(ConfigBundle.getMessage("ButtonSave"), new ImageIcon(FileUtil.findURL("program:resources/icons/misc/gui3/SaveIcon.png", FileUtil.Location.INSTALLED)));
    save.addActionListener((ActionEvent e) -> {
        savePressed(invokeSaveOptions());
    });
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    Set<PreferencesPanel> delayed = new HashSet<>();
    for (PreferencesPanel panel : InstanceManager.getList(jmri.swing.PreferencesPanel.class)) {
        if (panel instanceof PreferencesSubPanel) {
            String parent = ((PreferencesSubPanel) panel).getParentClassName();
            if (!this.getPreferencesPanels().containsKey(parent)) {
                delayed.add(panel);
            } else {
                ((PreferencesSubPanel) panel).setParent(this.getPreferencesPanels().get(parent));
            }
        }
        if (!delayed.contains(panel)) {
            this.addPreferencesPanel(panel);
        }
    }
    for (PreferencesPanel panel : ServiceLoader.load(PreferencesPanel.class)) {
        if (panel instanceof PreferencesSubPanel) {
            String parent = ((PreferencesSubPanel) panel).getParentClassName();
            if (!this.getPreferencesPanels().containsKey(parent)) {
                delayed.add(panel);
            } else {
                ((PreferencesSubPanel) panel).setParent(this.getPreferencesPanels().get(parent));
            }
        }
        if (!delayed.contains(panel)) {
            this.addPreferencesPanel(panel);
        }
    }
    while (!delayed.isEmpty()) {
        Set<PreferencesPanel> iterated = new HashSet<>(delayed);
        iterated.stream().filter((panel) -> (panel instanceof PreferencesSubPanel)).forEach((panel) -> {
            String parent = ((PreferencesSubPanel) panel).getParentClassName();
            if (this.getPreferencesPanels().containsKey(parent)) {
                ((PreferencesSubPanel) panel).setParent(this.getPreferencesPanels().get(parent));
                delayed.remove(panel);
                this.addPreferencesPanel(panel);
            }
        });
    }
    preferencesArray.stream().forEach((preferences) -> {
        detailpanel.add(preferences.getPanel(), preferences.getPrefItem());
    });
    updateJList();
    add(buttonpanel);
    add(new JSeparator(JSeparator.VERTICAL));
    add(detailpanel);
    list.setSelectedIndex(0);
    selection(preferencesArray.get(0).getPrefItem());
    this.setInitalisationState(INITIALISED);
    return initialisationState;
}
Also used : JScrollPane(javax.swing.JScrollPane) ListSelectionModel(javax.swing.ListSelectionModel) CardLayout(java.awt.CardLayout) LoggerFactory(org.slf4j.LoggerFactory) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ConfigBundle(apps.ConfigBundle) JTabbedPane(javax.swing.JTabbedPane) ImageIcon(javax.swing.ImageIcon) BorderLayout(java.awt.BorderLayout) ListSelectionEvent(javax.swing.event.ListSelectionEvent) PreferencesSubPanel(jmri.swing.PreferencesSubPanel) BoxLayout(javax.swing.BoxLayout) PreferencesPanel(jmri.swing.PreferencesPanel) AppConfigBase(apps.AppConfigBase) JComponent(javax.swing.JComponent) InstanceManager(jmri.InstanceManager) JButton(javax.swing.JButton) Logger(org.slf4j.Logger) JList(javax.swing.JList) Set(java.util.Set) ServiceLoader(java.util.ServiceLoader) BorderFactory(javax.swing.BorderFactory) ActionEvent(java.awt.event.ActionEvent) JScrollPane(javax.swing.JScrollPane) Dimension(java.awt.Dimension) List(java.util.List) FileUtil(jmri.util.FileUtil) JLabel(javax.swing.JLabel) JSeparator(javax.swing.JSeparator) JPanel(javax.swing.JPanel) Element(org.jdom2.Element) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) ImageIcon(javax.swing.ImageIcon) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) PreferencesPanel(jmri.swing.PreferencesPanel) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) JSeparator(javax.swing.JSeparator) PreferencesSubPanel(jmri.swing.PreferencesSubPanel) HashSet(java.util.HashSet)

Example 88 with CardLayout

use of java.awt.CardLayout in project vcell by virtualcell.

the class DataProcessingResultsPanel method initialize.

private void initialize() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.rowWeights = new double[] { 0.0 };
    gridBagLayout.columnWeights = new double[] { 0, 0 };
    setLayout(gridBagLayout);
    varJList = new JList();
    varJList.setVisibleRowCount(5);
    varJList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            if (varJList.getSelectedIndex() != -1) {
                ((CardLayout) cardLayoutPanel.getLayout()).show(cardLayoutPanel, "plotPane1");
            }
            onVariablesChange();
        }
    });
    GridBagConstraints gbc_graphScrollPane = new GridBagConstraints();
    gbc_graphScrollPane.weighty = 0.3;
    gbc_graphScrollPane.gridx = 0;
    gbc_graphScrollPane.gridy = 0;
    gbc_graphScrollPane.insets = new Insets(4, 4, 4, 4);
    gbc_graphScrollPane.fill = GridBagConstraints.BOTH;
    graphScrollPane = new JScrollPane(varJList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    graphScrollPane.setMinimumSize(new Dimension(150, 150));
    add(graphScrollPane, gbc_graphScrollPane);
    cardLayoutPanel = new JPanel();
    GridBagConstraints gbc_cardLayoutPanel = new GridBagConstraints();
    gbc_cardLayoutPanel.weightx = 1.0;
    gbc_cardLayoutPanel.weighty = 1.0;
    gbc_cardLayoutPanel.insets = new Insets(4, 4, 4, 4);
    gbc_cardLayoutPanel.fill = GridBagConstraints.BOTH;
    gbc_cardLayoutPanel.gridx = 1;
    gbc_cardLayoutPanel.gridy = 0;
    add(cardLayoutPanel, gbc_cardLayoutPanel);
    cardLayoutPanel.setLayout(new CardLayout(0, 0));
    plotPane = new PlotPane();
    cardLayoutPanel.add(plotPane, "plotPane1");
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ListSelectionEvent(javax.swing.event.ListSelectionEvent) PlotPane(cbit.plot.gui.PlotPane) Dimension(java.awt.Dimension) JList(javax.swing.JList) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 89 with CardLayout

use of java.awt.CardLayout in project knime-core by knime.

the class NameFilterPanel method updateFilterView.

/**
 * Displays a JTable if there is something to display, otherwise displays a TablePlaceholder.
 * @param table the JTable being displayed instead of the TablePlaceholder
 * @param cardsPanel the JPanel holding the cards
 * @param tablePlaceholder the TablePlaceholder being displayed instead of the table
 * @param searchQuery the entered search query
 */
private void updateFilterView(final JTable table, final JPanel cardsPanel, final TablePlaceholder tablePlaceholder, final String searchQuery) {
    CardLayout cl = (CardLayout) cardsPanel.getLayout();
    // if there are no columns in the list
    if (table.getModel().getRowCount() == 0) {
        tablePlaceholder.updateTextEmpty();
        cl.show(cardsPanel, ID_CARDLAYOUT_PLACEHOLDER);
    } else {
        // nothing found
        if (table.getRowCount() == 0) {
            tablePlaceholder.updateTextNothingFound(searchQuery, table.getModel().getRowCount());
            cl.show(cardsPanel, ID_CARDLAYOUT_PLACEHOLDER);
        } else {
            cl.show(cardsPanel, ID_CARDLAYOUT_LIST);
        }
    }
}
Also used : CardLayout(java.awt.CardLayout)

Example 90 with CardLayout

use of java.awt.CardLayout in project cayenne by apache.

the class SQLTemplatePrefetchTab method initView.

protected void initView() {
    messagePanel = new JPanel(new BorderLayout());
    cardLayout = new CardLayout();
    Preferences detail = Application.getInstance().getPreferencesNode(this.getClass(), "");
    int defLocation = Application.getFrame().getHeight() / 2;
    int location = detail != null ? detail.getInt(getDividerLocationProperty(), defLocation) : defLocation;
    // As of CAY-888 #3 main pane is now a JSplitPane. Top component is a bit larger.
    JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mainPanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, this);
    mainPanel.setDividerLocation(location);
    mainPanel.setTopComponent(createEditorPanel());
    mainPanel.setBottomComponent(createSelectorPanel());
    setLayout(cardLayout);
    add(mainPanel, REAL_PANEL);
    add(messagePanel, PLACEHOLDER_PANEL);
}
Also used : JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) BorderLayout(java.awt.BorderLayout) Preferences(java.util.prefs.Preferences) JSplitPane(javax.swing.JSplitPane)

Aggregations

CardLayout (java.awt.CardLayout)92 JPanel (javax.swing.JPanel)37 BorderLayout (java.awt.BorderLayout)16 JLabel (javax.swing.JLabel)14 JScrollPane (javax.swing.JScrollPane)12 Dimension (java.awt.Dimension)9 GridBagLayout (java.awt.GridBagLayout)8 Insets (java.awt.Insets)8 JButton (javax.swing.JButton)7 ImageIcon (javax.swing.ImageIcon)6 ListSelectionEvent (javax.swing.event.ListSelectionEvent)6 JSplitPane (javax.swing.JSplitPane)5 ListSelectionListener (javax.swing.event.ListSelectionListener)5 FlowLayout (java.awt.FlowLayout)4 Font (java.awt.Font)4 Point (java.awt.Point)4 JList (javax.swing.JList)4 EmptyBorder (javax.swing.border.EmptyBorder)4 AWTException (java.awt.AWTException)3 GridBagConstraints (java.awt.GridBagConstraints)3