Example usage for com.jgoodies.forms.layout FormLayout insertRow

List of usage examples for com.jgoodies.forms.layout FormLayout insertRow

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout FormLayout insertRow.

Prototype

public void insertRow(int rowIndex, RowSpec rowSpec) 

Source Link

Document

Inserts the specified column at the specified position.

Usage

From source file:tvbrowser.extras.favoritesplugin.wizards.ExcludeWizardStep.java

License:Open Source License

@Override
public JPanel createContent(final WizardHandler handler) {
    mTitleCb = new JCheckBox(mTitleQuestion);
    mTitleTf = new JTextField();
    mFilterCb = new JCheckBox(mFilterQuestion);
    mFilterChooser = new JComboBox(FilterManagerImpl.getInstance().getAvailableFilters());

    mDayChooser = new JComboBox(new Object[] { LimitationConfiguration.DAYLIMIT_WEEKDAY,
            LimitationConfiguration.DAYLIMIT_WEEKEND, LimitationConfiguration.DAYLIMIT_MONDAY,
            LimitationConfiguration.DAYLIMIT_TUESDAY, LimitationConfiguration.DAYLIMIT_WEDNESDAY,
            LimitationConfiguration.DAYLIMIT_THURSDAY, LimitationConfiguration.DAYLIMIT_FRIDAY,
            LimitationConfiguration.DAYLIMIT_SATURDAY, LimitationConfiguration.DAYLIMIT_SUNDAY });
    mDayChooser.setRenderer(new DayListCellRenderer());
    CellConstraints cc = new CellConstraints();
    FormLayout layout = new FormLayout("5dlu, pref, default:grow",
            "pref, 5dlu, pref, 5dlu, pref, 5dlu, pref, 5dlu, pref, 5dlu, pref");
    PanelBuilder panelBuilder = new PanelBuilder(layout);

    mChannelCB = new JComboBox(ChannelList.getSubscribedChannels());

    int rowInx = 3;
    panelBuilder.add(new JLabel(mMainQuestion), cc.xyw(1, 1, 3));

    panelBuilder.add(mTitleCb, cc.xy(2, rowInx));
    panelBuilder.add(mTitleTf, cc.xy(3, rowInx));
    rowInx += 2;/*from  w ww. ja va2 s. c  om*/

    panelBuilder.add(mTopicCb = new JCheckBox(mTopicQuestion), cc.xy(2, rowInx));
    panelBuilder.add(mTopicTf = new JTextField(), cc.xy(3, rowInx));

    rowInx += 2;

    int filterIndex = rowInx;

    panelBuilder.add(mChannelCb = new JCheckBox(mChannelQuestion), cc.xy(2, rowInx));
    panelBuilder.add(mChannelCB, cc.xy(3, rowInx));
    rowInx += 2;

    panelBuilder.add(mDayCb = new JCheckBox(mDayQuestion), cc.xy(2, rowInx));
    panelBuilder.add(mDayChooser, cc.xy(3, rowInx));

    rowInx += 2;
    panelBuilder.add(mTimeCb = new JCheckBox(mTimeQuestion), cc.xy(2, rowInx));
    panelBuilder.add(mTimePeriodChooser = new TimePeriodChooser(TimePeriodChooser.ALIGN_LEFT),
            cc.xy(3, rowInx));

    if (mMode == MODE_EDIT_EXCLUSION || mMode == MODE_CREATE_EXCLUSION) {
        layout.insertRow(filterIndex, RowSpec.decode("pref"));
        layout.insertRow(filterIndex + 1, RowSpec.decode("5dlu"));

        panelBuilder.add(mFilterCb, cc.xy(2, filterIndex));
        panelBuilder.add(mFilterChooser, cc.xy(3, filterIndex));
    }

    if (mMode == MODE_CREATE_DERIVED_FROM_PROGRAM && mProgram != null) {
        mTitleCb.setSelected(false);

        mDoneBtnText = mLocalizer.msg("doneButton.toBlacklist", "Remove this program now");

        mTitleTf.setText(mProgram.getTitle());
        mChannelCB.setSelectedItem(mProgram.getChannel());
        int timeFrom = (mProgram.getHours() - 1) * 60;
        int timeTo = (mProgram.getHours() + 1) * 60;
        if (timeFrom < 0) {
            timeFrom = 0;
        }
        if (timeTo > 24 * 60 - 1) {
            timeTo = 24 * 60 - 1;
        }
        mTimePeriodChooser.setFromTime(timeFrom);
        mTimePeriodChooser.setToTime(timeTo);
        mDayChooser.setSelectedItem(mProgram.getDate().getCalendar().get(Calendar.DAY_OF_WEEK));
    } else if (mMode == MODE_EDIT_EXCLUSION) {
        String title = mExclusion.getTitle();
        String topic = mExclusion.getTopic();
        ProgramFilter filter = mExclusion.getFilter();
        Channel channel = mExclusion.getChannel();
        int timeFrom = mExclusion.getTimeLowerBound();
        int timeTo = mExclusion.getTimeUpperBound();
        int dayOfWeek = mExclusion.getDayOfWeek();
        if (title != null) {
            mTitleCb.setSelected(true);
            mTitleTf.setText(title);
        }
        if (topic != null) {
            mTopicCb.setSelected(true);
            mTopicTf.setText(topic);
        }
        if (filter != null) {
            mFilterCb.setSelected(true);
            mFilterChooser.setSelectedItem(filter);
        }
        if (channel != null) {
            mChannelCb.setSelected(true);
            mChannelCB.setSelectedItem(channel);
        }
        if (timeFrom >= 0 && timeTo >= 0) {
            mTimeCb.setSelected(true);
            mTimePeriodChooser.setFromTime(timeFrom);
            mTimePeriodChooser.setToTime(timeTo);
            mDayChooser.setSelectedItem(mExclusion.getDayOfWeek());
        }
        if (dayOfWeek != Exclusion.DAYLIMIT_DAILY) {
            mDayCb.setSelected(true);
            mDayChooser.setSelectedItem(dayOfWeek);
        }
    }

    updateButtons(handler);

    mChannelCb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            updateButtons(handler);
        }
    });

    mTitleCb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            updateButtons(handler);
        }
    });

    mTopicCb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            updateButtons(handler);
        }
    });

    mFilterCb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            updateButtons(handler);
        }
    });

    mTimeCb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            updateButtons(handler);
        }
    });

    mDayCb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            updateButtons(handler);
        }
    });

    mContentPanel = panelBuilder.getPanel();
    return mContentPanel;
}

From source file:tvbrowser.ui.settings.PictureSettingsTab.java

License:Open Source License

public JPanel createSettingsPanel() {
    try {//from w w  w . j a  v a2s . com
        mShowPicturesNever = new JRadioButton(mLocalizer.msg("showNever", "Show never"),
                Settings.propPictureType.getInt() == ProgramPanelSettings.SHOW_PICTURES_NEVER);
        mShowPicturesEver = new JRadioButton(mLocalizer.msg("showEver", "Show always"),
                Settings.propPictureType.getInt() == ProgramPanelSettings.SHOW_PICTURES_EVER);
        mShowPicturesForSelection = new JRadioButton(mLocalizer.msg("showForSelection", "Selection..."),
                Settings.propPictureType.getInt() > 1);

        mShowPicturesInTimeRange = new JCheckBox(mLocalizer.msg("showInTimeRange", "Show in time range:"),
                ProgramPanelSettings.typeContainsType(Settings.propPictureType.getInt(),
                        ProgramPanelSettings.SHOW_PICTURES_IN_TIME_RANGE));
        mShowPicturesForDuration = new JCheckBox(
                mLocalizer.msg("showForDuration", "Show for duration more than or equals to:"),
                ProgramPanelSettings.typeContainsType(Settings.propPictureType.getInt(),
                        ProgramPanelSettings.SHOW_PICTURES_FOR_DURATION));

        ButtonGroup bg = new ButtonGroup();

        bg.add(mShowPicturesEver);
        bg.add(mShowPicturesNever);
        bg.add(mShowPicturesForSelection);

        String timePattern = mLocalizer.msg("timePattern", "hh:mm a");

        mPictureStartTime = new JSpinner(new SpinnerDateModel());
        mPictureStartTime.setEditor(new JSpinner.DateEditor(mPictureStartTime, timePattern));
        CaretPositionCorrector.createCorrector(
                ((JSpinner.DateEditor) mPictureStartTime.getEditor()).getTextField(), new char[] { ':' }, -1);

        mPictureEndTime = new JSpinner(new SpinnerDateModel());
        mPictureEndTime.setEditor(new JSpinner.DateEditor(mPictureEndTime, timePattern));
        CaretPositionCorrector.createCorrector(
                ((JSpinner.DateEditor) mPictureEndTime.getEditor()).getTextField(), new char[] { ':' }, -1);

        mDuration = new JSpinner(new SpinnerNumberModel(Settings.propPictureDuration.getInt(), 10, 240, 1));

        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, Settings.propPictureStartTime.getInt() / 60);
        cal.set(Calendar.MINUTE, Settings.propPictureStartTime.getInt() % 60);
        mPictureStartTime.setValue(cal.getTime());

        cal.set(Calendar.HOUR_OF_DAY, Settings.propPictureEndTime.getInt() / 60);
        cal.set(Calendar.MINUTE, Settings.propPictureEndTime.getInt() % 60);
        mPictureEndTime.setValue(cal.getTime());

        mShowDescription = new JCheckBox(mLocalizer.msg("showDescription", "Show description for pictures"),
                Settings.propIsPictureShowingDescription.getBoolean());

        JEditorPane helpLabel = UiUtilities.createHtmlHelpTextArea(mLocalizer.msg("help",
                "These settings affect only the showing of the pictures. The pictures can only be shown if the download of pictures in enabled. To enable the picture download look at the <a href=\"#link\">settings of the TV dataservices</a>."),
                new HyperlinkListener() {
                    public void hyperlinkUpdate(HyperlinkEvent e) {
                        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                            SettingsDialog.getInstance().showSettingsTab(SettingsItem.PLUGINS);
                        }
                    }
                });

        CellConstraints cc = new CellConstraints();

        FormLayout layout = new FormLayout("5dlu, 12dlu, 15dlu, pref, 5dlu, pref, 5dlu, pref:grow, 5dlu",
                "pref,5dlu,pref,pref,pref,2dlu,pref,pref,2dlu,pref"
                        + ",2dlu,pref,pref,5dlu,pref,pref,10dlu,pref,5dlu,pref,10dlu,pref,5dlu");

        PanelBuilder pb = new PanelBuilder(layout, new ScrollableJPanel());

        pb.setDefaultDialogBorder();

        int y = 1;

        pb.addSeparator(mLocalizer.msg("basics", "Picture settings for the program table"), cc.xyw(1, y, 9));

        pb.add(mShowPicturesNever, cc.xyw(2, y += 2, 8));
        pb.add(mShowPicturesEver, cc.xyw(2, y += 1, 8));
        pb.add(mShowPicturesForSelection, cc.xyw(2, y += 1, 8));

        pb.add(mShowPicturesInTimeRange, cc.xyw(3, y += 2, 7));
        mStartLabel = pb.addLabel(mLocalizer.msg("startTime", "From:"), cc.xy(4, y += 1));
        pb.add(mPictureStartTime, cc.xy(6, y));
        mEndLabel = pb.addLabel(mLocalizer.msg("endTime", "To:"), cc.xy(4, y += 2));
        pb.add(mPictureEndTime, cc.xy(6, y));

        pb.add(mShowPicturesForDuration, cc.xyw(3, y += 2, 7));
        pb.add(mDuration, cc.xy(6, y += 1));
        final JLabel minutesLabel = pb.addLabel(mLocalizer.msg("minutes", "Minutes"), cc.xy(8, y));
        y++;
        if (Settings.propPicturePluginIds.getStringArray() != null) {
            JPanel mSubPanel = new JPanel(new FormLayout("15dlu,pref:grow,5dlu,pref", "pref,2dlu,pref"));

            mShowPicturesForPlugins = new JCheckBox(
                    mLocalizer.msg("showPicturesForPlugins", "Show for programs that are marked by plugins:"),
                    ProgramPanelSettings.typeContainsType(Settings.propPictureType.getInt(),
                            ProgramPanelSettings.SHOW_PICTURES_FOR_PLUGINS));
            mPluginLabel = new JLabel();
            mPluginLabel.setEnabled(ProgramPanelSettings.typeContainsType(Settings.propPictureType.getInt(),
                    ProgramPanelSettings.SHOW_PICTURES_FOR_PLUGINS));

            choose = new JButton(mLocalizer.msg("selectPlugins", "Choose Plugins"));
            choose.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    Window parent = UiUtilities.getLastModalChildOf(MainFrame.getInstance());
                    MarkerChooserDlg chooser = new MarkerChooserDlg(parent, mClientPlugins, null);

                    chooser.setLocationRelativeTo(parent);
                    chooser.setVisible(true);

                    mClientPlugins = chooser.getMarker();

                    handlePluginSelection();
                }
            });
            choose.setEnabled(ProgramPanelSettings.typeContainsType(Settings.propPictureType.getInt(),
                    ProgramPanelSettings.SHOW_PICTURES_FOR_PLUGINS));

            mShowPicturesForPlugins.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    mPluginLabel.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
                    choose.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
                }
            });

            String[] clientPluginIdArr = Settings.propPicturePluginIds.getStringArray();

            ArrayList<Marker> clientPlugins = new ArrayList<Marker>();

            for (String arr : clientPluginIdArr) {
                PluginAccess plugin = Plugin.getPluginManager().getActivatedPluginForId(arr);
                if (plugin != null) {
                    clientPlugins.add(plugin);
                } else if (ReminderPluginProxy.getInstance().getId().compareTo(arr) == 0) {
                    clientPlugins.add(ReminderPluginProxy.getInstance());
                } else if (FavoritesPluginProxy.getInstance().getId().compareTo(arr) == 0) {
                    clientPlugins.add(FavoritesPluginProxy.getInstance());
                }
            }

            mClientPlugins = clientPlugins.toArray(new Marker[clientPlugins.size()]);

            handlePluginSelection();

            mSubPanel.add(mShowPicturesForPlugins, cc.xyw(1, 1, 4));
            mSubPanel.add(mPluginLabel, cc.xy(2, 3));
            mSubPanel.add(choose, cc.xy(4, 3));

            layout.insertRow(y, RowSpec.decode("2dlu"));
            layout.insertRow(y += 1, RowSpec.decode("pref"));
            pb.add(mSubPanel, cc.xyw(3, y, 6));
            layout.insertRow(y += 1, RowSpec.decode("2dlu"));
            y++;
        }

        pb.add(mShowDescription, cc.xyw(2, y += 1, 8));

        mDescriptionLines = new JSpinner(
                new SpinnerNumberModel(Settings.propPictureDescriptionLines.getInt(), 1, 20, 1));
        pb.add(mDescriptionLines, cc.xyw(3, y += 1, 4));
        mDescriptionLabel = new JLabel(mLocalizer.msg("lines", "lines"));
        pb.add(mDescriptionLabel, cc.xy(8, y));
        mDescriptionLabel.setEnabled(mShowDescription.isSelected());
        mShowDescription.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                mDescriptionLines.setEnabled(mShowDescription.isSelected());
                mDescriptionLabel.setEnabled(mShowDescription.isSelected());
            }
        });

        pb.addSeparator(mLocalizer.msg("pluginPictureTitle",
                "Default picture settings for the program lists of the Plugins"), cc.xyw(1, y += 2, 8));
        pb.add(mPluginsPictureSettings = new PluginsPictureSettingsPanel(
                new PluginPictureSettings(Settings.propPluginsPictureSetting.getInt()), true),
                cc.xyw(2, y += 2, 7));
        pb.add(helpLabel, cc.xyw(1, y += 2, 9));

        mShowPicturesInTimeRange.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                mPictureStartTime.setEnabled(mShowPicturesInTimeRange.isSelected());
                mPictureEndTime.setEnabled(mShowPicturesInTimeRange.isSelected());
                mStartLabel.setEnabled(mShowPicturesInTimeRange.isSelected());
                mEndLabel.setEnabled(mShowPicturesInTimeRange.isSelected());
            }
        });

        mShowPicturesForDuration.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                mDuration.setEnabled(mShowPicturesForDuration.isSelected());
                minutesLabel.setEnabled(mShowPicturesForDuration.isSelected());
            }
        });

        mShowPicturesNever.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                mShowDescription.setEnabled(!mShowPicturesNever.isSelected());
            }
        });

        mShowPicturesForSelection.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                mShowPicturesForDuration.setEnabled(mShowPicturesForSelection.isSelected());
                mShowPicturesInTimeRange.setEnabled(mShowPicturesForSelection.isSelected());
                mStartLabel.setEnabled(
                        mShowPicturesForSelection.isSelected() && mShowPicturesInTimeRange.isSelected());
                mEndLabel.setEnabled(
                        mShowPicturesForSelection.isSelected() && mShowPicturesInTimeRange.isSelected());
                minutesLabel.setEnabled(
                        mShowPicturesForSelection.isSelected() && mShowPicturesForDuration.isSelected());
                mPictureStartTime.setEnabled(
                        mShowPicturesForSelection.isSelected() && mShowPicturesInTimeRange.isSelected());
                mPictureEndTime.setEnabled(
                        mShowPicturesForSelection.isSelected() && mShowPicturesInTimeRange.isSelected());
                mDuration.setEnabled(
                        mShowPicturesForSelection.isSelected() && mShowPicturesForDuration.isSelected());

                if (mShowPicturesForPlugins != null) {
                    mShowPicturesForPlugins.setEnabled(mShowPicturesForSelection.isSelected());
                }
                if (mPluginLabel != null) {
                    mPluginLabel.setEnabled(
                            mShowPicturesForSelection.isSelected() && mShowPicturesForPlugins.isSelected());
                }
                if (choose != null) {
                    choose.setEnabled(
                            mShowPicturesForSelection.isSelected() && mShowPicturesForPlugins.isSelected());
                }
            }
        });

        mShowPicturesInTimeRange.getItemListeners()[0].itemStateChanged(null);
        mShowPicturesForDuration.getItemListeners()[0].itemStateChanged(null);
        mShowPicturesForSelection.getItemListeners()[0].itemStateChanged(null);
        mShowPicturesNever.getItemListeners()[0].itemStateChanged(null);

        JScrollPane scrollPane = new JScrollPane(pb.getPanel());
        scrollPane.getViewport().setBackground(pb.getPanel().getBackground());
        scrollPane.setBorder(null);

        JPanel scrollPanel = new JPanel(new BorderLayout());
        scrollPanel.add(scrollPane, BorderLayout.CENTER);

        return scrollPanel;

    } catch (Exception e) {
        e.printStackTrace();
    }

    return null;
}

From source file:tvbrowser.ui.settings.StartupSettingsTab.java

License:Open Source License

/**
 * Creates the settings panel for this tab.
 *//*from   w ww . j  a  v a 2 s .  c  o m*/
public JPanel createSettingsPanel() {
    FormLayout layout = new FormLayout("5dlu, pref, 3dlu, pref, fill:3dlu:grow, 3dlu",
            "pref, 5dlu, pref, 1dlu, pref, 1dlu, pref, 10dlu, pref, 10dlu, pref, 5dlu, pref, pref");
    mSettingsPn = new JPanel(layout);
    mSettingsPn.setBorder(Borders.DIALOG_BORDER);

    CellConstraints cc = new CellConstraints();

    int y = 1;

    mSettingsPn.add(DefaultComponentFactory.getInstance().createSeparator(mLocalizer.msg("title", "Startup")),
            cc.xyw(1, y++, 5));

    mMinimizeAfterStartUpChB = new JCheckBox(
            mLocalizer.msg("minimizeAfterStartup", "Minimize main window after start up"),
            Settings.propMinimizeAfterStartup.getBoolean());
    mSettingsPn.add(mMinimizeAfterStartUpChB, cc.xy(2, ++y));

    y++;

    mStartFullscreen = new JCheckBox(mLocalizer.msg("startFullscreen", "Start in fullscreen mode"),
            Settings.propIsUsingFullscreen.getBoolean());
    mSettingsPn.add(mStartFullscreen, cc.xy(2, ++y));

    mMinimizeAfterStartUpChB.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                mStartFullscreen.setSelected(false);
            }
        }
    });

    mStartFullscreen.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                mMinimizeAfterStartUpChB.setSelected(false);
            }
        }
    });

    y++;

    mShowSplashChB = new JCheckBox(mLocalizer.msg("showSplashScreen", "Show splash screen during start up"),
            Settings.propSplashShow.getBoolean());
    mSettingsPn.add(mShowSplashChB, cc.xy(2, ++y));

    if (System.getProperty("os.name").toLowerCase().startsWith("windows") && !TVBrowser.isTransportable()) {
        layout.insertRow(++y, RowSpec.decode("1dlu"));
        layout.insertRow(++y, RowSpec.decode("pref"));

        try {
            RegistryKey shellFolders = new RegistryKey(RootKey.HKEY_CURRENT_USER,
                    "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders");
            String path = shellFolders.getValue("Startup").getData().toString();

            if (path == null || path.length() < 1 || !(new File(path)).isDirectory()) {
                throw new Exception();
            }

            mLinkFileFile = new File(path, "TV-Browser.url");

            try {
                mLinkFile = new LinkFile(mLinkFileFile);

                if (mLinkFileFile.isFile()) {
                    try {
                        if (!mLinkFile.hasTarget((new File("tvbrowser.exe")).getAbsoluteFile())) {
                            createLink(mLinkFile);
                        }
                    } catch (Exception linkException) {
                        mLinkFileFile.delete();
                    }
                }
            } catch (FileNotFoundException fe) {
            }

            mAutostartWithWindows = new JCheckBox(mLocalizer.msg("autostart", "Start TV-Browser with Windows"),
                    mLinkFileFile.isFile());

            mSettingsPn.add(mAutostartWithWindows, cc.xy(2, y));
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

    y++;

    mSettingsPn.add(createRefreshPanel(), cc.xyw(1, ++y, 5));

    y++;

    String msg = mLocalizer.msg("onlyMinimizeWhenWindowClosing",
            "When closing the main window only minimize TV-Browser, don't quit.");

    mOnlyMinimizeWhenWindowClosingChB = new JCheckBox(msg,
            Settings.propOnlyMinimizeWhenWindowClosing.getBoolean());
    mAskForExitConfirmation = new JCheckBox(
            mLocalizer.msg("askForExitConfirmation", "Ask for confirmation on TV-Browser exit"),
            !Settings.propHiddenMessageBoxes.containsItem("MainFrame.askForExitConfirm"));

    mSettingsPn.add(DefaultComponentFactory.getInstance().createSeparator(mLocalizer.msg("closing", "Closing")),
            cc.xyw(1, ++y, 5));

    y++;

    mSettingsPn.add(mOnlyMinimizeWhenWindowClosingChB, cc.xyw(2, ++y, 4));
    mSettingsPn.add(mAskForExitConfirmation, cc.xyw(2, ++y, 4));

    return mSettingsPn;
}

From source file:util.ui.LocalPluginProgramFormatingSettingsDialog.java

License:Open Source License

private void createGui(Window w, AbstractPluginProgramFormating config,
        AbstractPluginProgramFormating defaultConfig, boolean showTitleSetting, boolean showEncodingSetting) {
    mConfig = config;/*from   w w w  .j  a  va 2s .  c  om*/
    mDefaultConfig = defaultConfig;

    setTitle(mLocalizer.msg("settingsFor", "Settings for ") + config.getName());
    UiUtilities.registerForClosing(this);

    CellConstraints cc = new CellConstraints();
    FormLayout baseLayout = new FormLayout("pref,5dlu,pref:grow", "pref,5dlu,pref,fill:default:grow,5dlu,pref");
    PanelBuilder pb = new PanelBuilder(baseLayout, (JPanel) getContentPane());
    pb.setDefaultDialogBorder();

    mName = new JLabel(config.getName());
    mSetName = new JButton(mLocalizer.msg("changeName", "Change name"));
    mSetName.addActionListener(this);

    JPanel panel = new JPanel(new FormLayout("pref:grow,5dlu,pref", "pref"));
    panel.add(mName, cc.xy(1, 1));
    panel.add(mSetName, cc.xy(3, 1));

    mTitle = new JTextField(config.getTitleValue());
    mContentArea = new JTextArea(config.getContentValue());

    Vector<String> encodings = new Vector<String>();
    Map<String, Charset> availcs = Charset.availableCharsets();
    Set<String> keys = availcs.keySet();
    for (String string : keys) {
        encodings.add(string);
    }

    mEncoding = new JComboBox(encodings);
    mEncoding.setSelectedItem(config.getEncodingValue());
    mEncoding.addActionListener(this);

    mPreview = new JButton(mLocalizer.msg("preview", "Preview"));
    mPreview.addActionListener(this);

    mSetBack = new JButton(Localizer.getLocalization(Localizer.I18N_DEFAULT));
    mSetBack.addActionListener(this);

    mHelp = new JButton(Localizer.getLocalization(Localizer.I18N_HELP));
    mHelp.addActionListener(this);

    mOk = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    mOk.addActionListener(this);

    mCancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
    mCancel.addActionListener(this);

    FormLayout layout = new FormLayout("pref,3dlu,pref,3dlu,pref,0dlu:grow,pref,3dlu,pref", "pref");
    layout.setColumnGroups(new int[][] { { 1, 3, 5, 7, 9 } });

    JPanel buttonPanel = new JPanel(layout);

    buttonPanel.add(mPreview, cc.xy(1, 1));
    buttonPanel.add(mSetBack, cc.xy(3, 1));
    buttonPanel.add(mHelp, cc.xy(5, 1));
    buttonPanel.add(mOk, cc.xy(7, 1));
    buttonPanel.add(mCancel, cc.xy(9, 1));

    int y = 1;

    pb.addLabel(mLocalizer.msg("name", "Name") + ":", cc.xy(1, y));
    pb.add(panel, cc.xy(3, y++));

    if (showTitleSetting) {
        baseLayout.insertRow(y++, RowSpec.decode("2dlu"));
        baseLayout.insertRow(y, RowSpec.decode("pref"));

        pb.addLabel(mLocalizer.msg("title", "Titel") + ":", cc.xy(1, y));
        pb.add(mTitle, cc.xy(3, y++));
    }

    pb.addLabel(mLocalizer.msg("content", "Content") + ":", cc.xyw(1, ++y, 3));
    pb.add(new JScrollPane(mContentArea), cc.xyw(1, ++y, 3));

    y++;

    if (showEncodingSetting) {
        baseLayout.insertRow(y++, RowSpec.decode("5dlu"));
        baseLayout.insertRow(y, RowSpec.decode("pref"));

        pb.addLabel(mLocalizer.msg("encoding", "Encoding") + ":", cc.xy(1, y));
        pb.add(mEncoding, cc.xy(3, y++));
    }

    pb.add(buttonPanel, cc.xyw(1, ++y, 3));

    UiUtilities.setSize(this, 500, 400);
    setLocationRelativeTo(w);
    setVisible(true);
}