All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bidib.wizard.localhost.client.preferences.LocalHostSettingsPanel Maven / Gradle / Ivy

There is a newer version: 2.0.29
Show newest version
package org.bidib.wizard.localhost.client.preferences;

import java.awt.BorderLayout;
import java.util.function.Consumer;

import javax.swing.JCheckBox;
import javax.swing.JPanel;

import org.bidib.wizard.api.locale.Resources;
import org.bidib.wizard.client.common.preferences.view.panel.AbstractSettingsPanel;
import org.bidib.wizard.client.common.preferences.view.panel.SettingsPanelInterface;
import org.bidib.wizard.client.common.text.WizardComponentFactory;
import org.bidib.wizard.common.model.settings.LocalHostSettingsInterface;

import com.jgoodies.binding.value.BufferedValueModel;
import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.debug.FormDebugPanel;
import com.jgoodies.forms.factories.Paddings;

public class LocalHostSettingsPanel extends AbstractSettingsPanel
    implements SettingsPanelInterface {

    private static final String ENCODED_DIALOG_COLUMN_SPECS = "pref, 3dlu, pref, 3dlu, fill:50dlu:grow";

    private static final String ENCODED_DIALOG_ROW_SPECS = "pref, 3dlu, pref, 3dlu, pref";

    private final LocalHostSettingsInterface localHostSettingsInterface;

    private JPanel contentPanel;

    public LocalHostSettingsPanel(final LocalHostSettingsInterface localHostSettingsInterface) {
        super(null);
        this.localHostSettingsInterface = localHostSettingsInterface;
    }

    @Override
    public JPanel createPanel(Consumer bufferingCallback) {

        setBufferingCallback(bufferingCallback);

        FormBuilder dialogBuilder = null;
        boolean debugDialog = false;
        if (debugDialog) {
            JPanel panel = new FormDebugPanel();
            dialogBuilder =
                FormBuilder.create().columns(ENCODED_DIALOG_COLUMN_SPECS).rows(ENCODED_DIALOG_ROW_SPECS).panel(panel);
        }
        else {
            JPanel panel = new JPanel(new BorderLayout());
            dialogBuilder =
                FormBuilder.create().columns(ENCODED_DIALOG_COLUMN_SPECS).rows(ENCODED_DIALOG_ROW_SPECS).panel(panel);
        }
        dialogBuilder.border(Paddings.TABBED_DIALOG);

        // use value model here and only update settings on focus lost
        preparePresentationModel(this.localHostSettingsInterface);

        // prepare the panel

        // localhost client enabled
        final BufferedValueModel localHostClientEnabledModel =
            presentationModel.getBufferedModel(LocalHostSettingsInterface.PROPERTY_LOCALHOST_CLIENT_ENABLED);

        JCheckBox localHostClientEnabled =
            WizardComponentFactory
                .createCheckBox(localHostClientEnabledModel, Resources.getString(getClass(), "localHostClientEnabled"));

        dialogBuilder.add(localHostClientEnabled).xyw(1, 1, 5);


        // localhost enabled
        final BufferedValueModel localhostServiceEnabledModel =
                presentationModel.getBufferedModel(LocalHostSettingsInterface.PROPERTY_LOCALHOST_SERVICE_ENABLED);

        JCheckBox localHostServiceEnabled =
                WizardComponentFactory
                        .createCheckBox(localhostServiceEnabledModel, Resources.getString(getClass(), "localHostServiceEnabled"));
        dialogBuilder.add(localHostServiceEnabled).xyw(1, 3, 5);

        contentPanel = dialogBuilder.build();
        contentPanel.setOpaque(false);
        return contentPanel;
    }

    @Override
    public String getTabTitle() {
        return Resources.getString(getClass(), "tab-localhost.title");
    }

    @Override
    public String getTabTooltip() {
        return Resources.getString(getClass(), "tab-localhost.tooltip");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy