private void createGui() {
setTitle(mLocalizer.msg("title", "Configure Dreambox"));
UiUtilities.registerForClosing(this);
EnhancedPanelBuilder basicPanel = new EnhancedPanelBuilder("2dlu, pref, 3dlu, fill:min:grow, 3dlu, pref, 3dlu, pref");
basicPanel.setBorder(Borders.DLU4_BORDER);
CellConstraints cc = new CellConstraints();
basicPanel.addParagraph(mLocalizer.msg("misc", "Miscellaneous"));
basicPanel.addRow();
basicPanel.add(new JLabel(mLocalizer.msg("name","Name:")), cc.xy(2, basicPanel.getRow()));
mDeviceName = new JTextField(mDevice.getName());
basicPanel.add(mDeviceName, cc.xy(4, basicPanel.getRow()));
basicPanel.addRow();
basicPanel.add(new JLabel(mLocalizer.msg("webIf","Webif:")), cc.xy(2,basicPanel.getRow()));
String[] values = {"ipkg",
"opkg"};
mSoftwareSelection = new JComboBox(values);
mSoftwareSelection.setSelectedIndex(mConfig.isOpkg() ? 1 : 0);
basicPanel.add(mSoftwareSelection, cc.xy(4, basicPanel.getRow()));
basicPanel.addRow();
basicPanel.add(new JLabel(mLocalizer.msg("ipaddress", "IP address")), cc.xy(2, basicPanel.getRow()));
mDreamboxAddress = new JTextField(mConfig.getDreamboxAddress());
basicPanel.add(mDreamboxAddress, cc.xy(4, basicPanel.getRow()));
JButton help = new JButton(CapturePlugin.getInstance().createImageIcon("apps", "help-browser", 16));
help.setToolTipText(Localizer.getLocalization(Localizer.I18N_HELP));
help.setOpaque(false);
help.setBorder(Borders.EMPTY_BORDER);
basicPanel.add(help, cc.xy(8, basicPanel.getRow()));
ButtonBarBuilder2 refresh = new ButtonBarBuilder2();
refresh.addGlue();
mRefreshButton = new JButton(mLocalizer.msg("refresh", "Refresh channel list"));
mRefreshButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
refreshChannelList();
}
});
mRefreshButton.setIcon(TVBrowserIcons.refresh(TVBrowserIcons.SIZE_SMALL));
mRefreshButton.setEnabled(mConfig.hasValidAddress());
mDreamboxAddress.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
check(e);
}
@Override
public void insertUpdate(DocumentEvent e) {
check(e);
}
@Override
public void changedUpdate(DocumentEvent e) {
check(e);
}
private void check(DocumentEvent e) {
mRefreshButton.setEnabled(!mDreamboxAddress.getText().trim().isEmpty());
}
});
refresh.addButton(new JButton[]{mRefreshButton});
basicPanel.addRow();
basicPanel.add(refresh.getPanel(), cc.xy(4, basicPanel.getRow()));
basicPanel.addRow();
basicPanel.add(new JLabel(mLocalizer.msg("preTime", "Time before in minutes:")), cc.xy(2,basicPanel.getRow()));
mBeforeModel = new SpinnerNumberModel(mConfig.getPreTime(), 0, 60, 1);
JSpinner beforeSpinner = new JSpinner(mBeforeModel);
basicPanel.add(beforeSpinner, cc.xy(4, basicPanel.getRow()));
basicPanel.addRow();
basicPanel.add(new JLabel(mLocalizer.msg("afterTime", "Time after in minutes:")), cc.xy(2, basicPanel.getRow()));
mAfterModel = new SpinnerNumberModel(mConfig.getAfterTime(), 0, 60, 1);
JSpinner afterSpinner = new JSpinner(mAfterModel);
basicPanel.add(afterSpinner, cc.xy(4, basicPanel.getRow()));
basicPanel.addParagraph(mLocalizer.msg("channel", "Channel assignment"));
mTable = new JTable(new ConfigTableModel(mConfig, mLocalizer.msg("dreambox", "Dreambox channel")));
mTable.getTableHeader().setReorderingAllowed(false);
mTable.getColumnModel().getColumn(0).setCellRenderer(new util.ui.ChannelTableCellRenderer());
mTable.getColumnModel().getColumn(1).setCellRenderer(new ExternalChannelTableCellRenderer());
mTable.getColumnModel().getColumn(1).setCellEditor(new ExternalChannelTableCellEditor(mConfig));
basicPanel.addGrowingRow();
basicPanel.add(new JScrollPane(mTable), cc.xyw(2, basicPanel.getRow(), basicPanel.getColumnCount() - 1));
ButtonBarBuilder2 builder = new ButtonBarBuilder2();
builder.addGlue();
JButton attach = new JButton(mLocalizer.msg("attach", "Attach"));
attach.setToolTipText(mLocalizer.msg("attachHelp", "Attach channels"));
attach.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
attachChannels();
}
});
builder.addButton(attach);
basicPanel.addRow();
basicPanel.add(builder.getPanel(), cc.xyw(2,basicPanel.getRow(), basicPanel.getColumnCount() - 1));
final EnhancedPanelBuilder extendedPanel = new EnhancedPanelBuilder("2dlu, pref, 3dlu, fill:pref:grow, 3dlu, pref, 5dlu");
extendedPanel.setBorder(Borders.DLU4_BORDER);
extendedPanel.addParagraph(mLocalizer.msg("misc", "Miscellaneous"));
extendedPanel.addRow();
extendedPanel.add(new JLabel(mLocalizer.msg("Timeout", "Timeout for connections in ms:")), cc.xy(2, extendedPanel.getRow()));
mTimeoutModel = new SpinnerNumberModel(mConfig.getTimeout(), 0, 100000, 10);
JSpinner timeoutSpinner = new JSpinner(mTimeoutModel);
extendedPanel.add(timeoutSpinner, cc.xyw(4, extendedPanel.getRow(), 3));
extendedPanel.addParagraph(mLocalizer.msg("timeZoneSeparator","Time zone"));
extendedPanel.addRow();
extendedPanel.add(new JLabel(mLocalizer.msg("timeZone", "Time zone:")), cc.xy(2, extendedPanel.getRow()));
String[] zoneIds = new String[0];
try {
zoneIds = TimeZone.getAvailableIDs();
} catch (Exception e) {
e.printStackTrace();
}
Arrays.sort(zoneIds);
mTimezone = new JComboBox(zoneIds);
String zone = mConfig.getTimeZoneAsString();
for (int i = 0; i < zoneIds.length; i++) {
if (zoneIds[i].equals(zone)) {
mTimezone.setSelectedIndex(i);
break;
}
}
extendedPanel.add(mTimezone, cc.xyw(4, extendedPanel.getRow(), 3));
extendedPanel.addParagraph(mLocalizer.msg("security", "Security"));
extendedPanel.addRow();
extendedPanel.add(new JLabel(mLocalizer.msg("userName", "User name :")), cc.xy(2, extendedPanel.getRow()));
mUserName = new JTextField(mConfig.getUserName());
extendedPanel.add(mUserName, cc.xyw(4, extendedPanel.getRow(),3));
extendedPanel.addRow();
extendedPanel.add(new JLabel(mLocalizer.msg("password", "Password :")), cc.xy(2, extendedPanel.getRow()));
mPasswordField = new JPasswordField(mConfig.getPassword());
extendedPanel.add(mPasswordField, cc.xyw(4, extendedPanel.getRow(), 3));
extendedPanel.addParagraph(mLocalizer.msg("streaming", "Streaming"));
extendedPanel.addRow();
extendedPanel.add(new JLabel(mLocalizer.msg("mediaplayer", "Mediaplayer :")), cc.xy(2, extendedPanel.getRow()));
mMediaplayer = new JTextField(mConfig.getMediaplayer());
extendedPanel.add(mMediaplayer, cc.xy(4, extendedPanel.getRow()));
JButton select = new JButton(Localizer.getLocalization(Localizer.I18N_SELECT));
select.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser mediaplayerChooser = new JFileChooser();
int returnVal = mediaplayerChooser.showOpenDialog(extendedPanel.getPanel());
if(returnVal == JFileChooser.APPROVE_OPTION) {
mMediaplayer.setText(mediaplayerChooser.getSelectedFile().getAbsolutePath());
}
}
});
extendedPanel.add(select, cc.xy(6, extendedPanel.getRow()));
mProgramReceiveTargetSelection = new ProgramReceiveTargetSelectionPanel(UiUtilities.getLastModalChildOf(CapturePlugin.getInstance().getSuperFrame()),
mConfig.getProgramReceiveTargets(),null,CapturePlugin.getInstance(),true,mLocalizer.msg("sendToTitle","Send scheduled programs to:"));
extendedPanel.addRow();
extendedPanel.addRow();
extendedPanel.add(mProgramReceiveTargetSelection, cc.xyw(1,extendedPanel.getRow(),7));
builder = new ButtonBarBuilder2();
JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okPressed();
}
});
JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
close();
}
});
builder.addGlue();
builder.addButton(new JButton[]{ok, cancel});
getRootPane().setDefaultButton(ok);
JTabbedPane tabs = new JTabbedPane();
tabs.add(mLocalizer.msg("basicTitle", "Basic settings"), basicPanel.getPanel());
tabs.add(mLocalizer.msg("extendedTitle", "Extended settings"), extendedPanel.getPanel());
JPanel content = (JPanel) getContentPane();
content.setBorder(Borders.DLU4_BORDER);
content.setLayout(new FormLayout("fill:pref:grow", "fill:pref:grow, 3dlu, pref"));
content.add(tabs, cc.xy(1,1));