/*
 * Copyright (c) 2000-2009 TeamDev Ltd. All rights reserved.
 * TeamDev PROPRIETARY and CONFIDENTIAL.
 * Use is subject to license terms.
 */
package com.jniwrapper.win32.samples.demo;

import com.jniwrapper.samples.shell.components.HTMLText;
import com.jniwrapper.win32.ui.controls.SelectFolderField;

import javax.swing.*;
import java.awt.*;

/**
 @author Serge Piletsky
 */
public class ChooseFolderSample extends ComfyJSample
{
    private JLabel lblAdvisoryText;
    private JLabel lblSelectedFolderCaption;
    private SelectFolderField _selectFolderField;
    private JLabel lblSelectedPrinterCaption;
    private SelectFolderField _selectPrinterField;
    private JLabel lblSelectedComputerCaption;
    private SelectFolderField _selectComputerField;
    private JLabel lblNotSupported;

    public ChooseFolderSample(Window parent)
    {
        super(parent);
    }

    public void initialize() throws Exception
    {
        boolean comfyjAvailable = isComfyJAvailable();

        if (comfyjAvailable)
        {
            lblNotSupported = new JLabel();
        }
        else
        {
            lblNotSupported = new HTMLText("<b><FONT color = red>NOTE:</FONT> The Choose Folder dialog functionality " +
                    "requires the ComfyJ library and ComfyJ license file.");
        }

        lblAdvisoryText = new HTMLText("This page demonstrates different customizations of Select Folder dialog.");
        lblSelectedFolderCaption = new JLabel("Select Folder:");
        _selectFolderField = new SelectFolderField();
        lblSelectedPrinterCaption = new JLabel("Select Printer:");
        _selectPrinterField = new SelectFolderField(SelectFolderField.MODE_SELECT_PRINTER);
        lblSelectedComputerCaption = new JLabel("Select Computer:");
        _selectComputerField = new SelectFolderField(SelectFolderField.MODE_SELECT_COMPUTER);

        if (!comfyjAvailable)
        {
            _selectFolderField.setEnabled(false);
            _selectPrinterField.setEnabled(false);
            _selectComputerField.setEnabled(false);
        }

        setLayout(new GridBagLayout());

        add(lblAdvisoryText, new GridBagConstraints(00210.00.0
                , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10101010)00));

        add(lblSelectedFolderCaption, new GridBagConstraints(01110.00.0
                , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(101000)00));

        add(_selectFolderField, new GridBagConstraints(11110.00.0
                , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(101000)00));

        add(lblSelectedPrinterCaption, new GridBagConstraints(02110.00.0
                , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(101000)00));

        add(_selectPrinterField, new GridBagConstraints(12110.00.0
                , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(101000)00));

        add(lblSelectedComputerCaption, new GridBagConstraints(03110.00.0
                , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(101000)00));

        add(_selectComputerField, new GridBagConstraints(13110.00.0
                , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(101000)00));

        add(lblNotSupported, new GridBagConstraints(04210.00.0
                , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(20101010)00));

        add(new JPanel()new GridBagConstraints(05211.01.0
                , GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0000)00));

        super.initialize();
    }
}