mHighlightButton.setEnabled(mHighlight.isSelected());
}
});
CellConstraints cc = new CellConstraints();
EnhancedPanelBuilder formatPanel = new EnhancedPanelBuilder(new FormLayout("5dlu,10dlu,pref,pref,5dlu,default:grow,pref,5dlu"));
formatPanel.setDefaultDialogBorder();
formatPanel.addParagraph(ProgramInfo.mLocalizer.msg("font","Font settings"));
formatPanel.addRow();
formatPanel.add(mAntiAliasing, cc.xyw(2,formatPanel.getRowCount(), formatPanel.getColumnCount() - 2));
formatPanel.addRow();
formatPanel.add(mUserFont, cc.xyw(2,formatPanel.getRowCount(),formatPanel.getColumnCount() - 2));
formatPanel.addRow();
final JLabel titleLabel = new JLabel(ProgramInfo.mLocalizer.msg("title", "Title font"));
formatPanel.add(titleLabel, cc.xy(3, formatPanel.getRowCount()));
formatPanel.add(mTitleFont, cc.xyw(6,formatPanel.getRowCount(),2));
formatPanel.addRow();
final JLabel bodyLabel = new JLabel(ProgramInfo.mLocalizer.msg("body", "Description font"));
formatPanel.add(bodyLabel, cc.xy(3,formatPanel.getRowCount()));
formatPanel.add(mBodyFont, cc.xyw(6,formatPanel.getRowCount(),2));
mUserFont.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
mTitleFont.setEnabled(mUserFont.isSelected());
mBodyFont.setEnabled(mUserFont.isSelected());
titleLabel.setEnabled(mUserFont.isSelected());
bodyLabel.setEnabled(mUserFont.isSelected());
}
});
mTitleFont.setEnabled(mUserFont.isSelected());
mBodyFont.setEnabled(mUserFont.isSelected());
titleLabel.setEnabled(mUserFont.isSelected());
bodyLabel.setEnabled(mUserFont.isSelected());
formatPanel.addParagraph(ProgramInfo.mLocalizer.msg("design","Design"));
formatPanel.addRow();
formatPanel.add(mLook, cc.xyw(2,formatPanel.getRowCount(),2));
formatPanel.addParagraph(ProgramInfoDialog.mLocalizer.msg("functions","Functions"));
formatPanel.addRow();
formatPanel.add(mShowFunctions, cc.xyw(2,formatPanel.getRowCount(),formatPanel.getColumnCount() - 2));
formatPanel.addRow();
formatPanel.add(mShowTextSearchButton, cc.xyw(3,formatPanel.getRowCount(),formatPanel.getColumnCount() - 3));
formatPanel.addParagraph(ProgramInfo.mLocalizer.msg("favorites","Favorites"));
formatPanel.addRow();
formatPanel.add(mHighlight, cc.xyw(2,formatPanel.getRowCount(),5));
JPanel panel = new JPanel(new FlowLayout());
mHighlightColorLb = new ColorLabel(settings.getHighlightColor());
panel.add(mHighlightColorLb);
mHighlightColorLb.setStandardColor(settings.getHighlightColor());
mHighlightButton = new ColorButton(mHighlightColorLb);
panel.add(mHighlightButton);
mHighlight.getActionListeners()[0].actionPerformed(null);
formatPanel.add(panel, cc.xy(7,formatPanel.getRowCount()));
mOldOrder = settings.getFieldOrder();
mOldSetupState = ProgramInfo.getInstance().getSettings().getSetupwasdone();
mList = new OrderChooser(mOldOrder, ProgramTextCreator.getDefaultOrder(),
true);
JButton previewBtn = new JButton(ProgramInfo.mLocalizer.msg("preview", "Preview"));
previewBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
saveSettings();
ProgramInfo.getInstance().showProgramInformation(
Plugin.getPluginManager().getExampleProgram(), false);
restoreSettings();
}
});
JButton defaultBtn = new JButton(ProgramInfo.mLocalizer.msg("default", "Default"));
defaultBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
resetSettings();
}
});
EnhancedPanelBuilder orderPanel = new EnhancedPanelBuilder("default:grow");
orderPanel.setDefaultDialogBorder();
orderPanel.addRow("fill:default:grow");
orderPanel.add(mList, cc.xy(1, orderPanel.getRowCount()));
EnhancedPanelBuilder picturePanel = new EnhancedPanelBuilder("default:grow");
picturePanel.setDefaultDialogBorder();
picturePanel.addRow("default");
picturePanel.add(mPictureSettings = new PluginsPictureSettingsPanel(ProgramInfo.getInstance().getPictureSettings(),false), cc.xy(1, picturePanel.getRowCount()));
PanelBuilder pb = new PanelBuilder(new FormLayout("default,2dlu,default,5dlu,default","default"));
pb.add(mZoomEnabled = new JCheckBox(ProgramInfo.mLocalizer.msg(
"scaleImage", "Scale picture:"), ProgramInfo.getInstance()
.getSettings().getZoomEnabled()), cc.xy(1, 1));
pb.add(mZoomValue = new JSpinner(new SpinnerNumberModel(ProgramInfo
.getInstance().getSettings().getZoomValue(), 50, 300, 1)), cc.xy(3, 1));
final JLabel label = pb.addLabel("%",cc.xy(5,1));
mZoomEnabled.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
mZoomValue.setEnabled(mZoomEnabled.isSelected());
label.setEnabled(mZoomEnabled.isSelected());
}
});
mZoomValue.setEnabled(mZoomEnabled.isSelected());
label.setEnabled(mZoomEnabled.isSelected());
picturePanel.addRow("5dlu");
picturePanel.addRow("default");
picturePanel.add(pb.getPanel(), cc.xy(1, picturePanel.getRowCount()));
PluginAccess webPlugin = PluginManagerImpl.getInstance().getActivatedPluginForId("java.webplugin.WebPlugin");
mAvailableTargetGroup = new ButtonGroup();
final ArrayList<InternalRadioButton<?>> availableDefaultTargets = new ArrayList<InternalRadioButton<?>>();
availableDefaultTargets.add(new InternalRadioButton<String>(ProgramInfoDialog.mLocalizer.msg("searchTvBrowser","Search in TV-Browser")));
mAvailableTargetGroup.add(availableDefaultTargets.get(0));
availableDefaultTargets.add(new InternalRadioButton<String>(ProgramInfoDialog.mLocalizer.msg("searchWikipedia","Search in Wikipedia")));
mAvailableTargetGroup.add(availableDefaultTargets.get(1));
final String currentValue = settings.getActorSearch();
int selectedIndex = -1;
if(webPlugin != null && webPlugin.canReceiveProgramsWithTarget()) {
ProgramReceiveTarget[] targets = webPlugin.getProgramReceiveTargets();
if(targets != null) {
for(ProgramReceiveTarget target : targets) {
availableDefaultTargets.add(new InternalRadioButton<ProgramReceiveTarget>(target));
mAvailableTargetGroup.add(availableDefaultTargets.get(availableDefaultTargets.size()-1));
if(currentValue.equals(target.getReceiveIfId() + "#_#_#" + target.getTargetId())) {
selectedIndex = availableDefaultTargets.size()-1;
}
}
}
}
if(selectedIndex == -1) {
if(currentValue.equals("internalSearch")) {
selectedIndex = 0;
}
else {
selectedIndex = 1;
}
}
availableDefaultTargets.get(selectedIndex).setSelected(true);
ScrollableJPanel buttonPanel = new ScrollableJPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.Y_AXIS));
buttonPanel.setOpaque(false);
for(InternalRadioButton<?> button : availableDefaultTargets) {
buttonPanel.add(button);
}
final JScrollPane scrollPane = new JScrollPane(buttonPanel);
scrollPane.setBackground(UIManager.getDefaults().getColor("List.background"));
scrollPane.getViewport().setBackground(UIManager.getDefaults().getColor("List.background"));
PanelBuilder actorPanel = new PanelBuilder(
new FormLayout(
"default:grow", "pref,3dlu,default,1dlu,fill:default:grow"));
actorPanel.setDefaultDialogBorder();
mPersonSearchCB = new JCheckBox(ProgramInfo.mLocalizer.msg("enableSearch",
"Show person names as links to person search"));
actorPanel.add(mPersonSearchCB, cc.xy(1, 1));
final JLabel searchLabel = new JLabel(ProgramInfo.mLocalizer.msg(
"defaultActorSearchMethod", "Default search method:"));
actorPanel.add(searchLabel, cc.xy(1, 3));
actorPanel.add(scrollPane, cc.xy(1, 5));
mPersonSearchCB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scrollPane.setEnabled(mPersonSearchCB.isSelected());
searchLabel.setEnabled(mPersonSearchCB.isSelected());
for (InternalRadioButton<?> button : availableDefaultTargets) {
button.setEnabled(mPersonSearchCB.isSelected());
}
}
});
mPersonSearchCB.setSelected(settings.getEnableSearch());
mPersonSearchCB.getActionListeners()[0].actionPerformed(null);
final JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.add(ProgramInfo.mLocalizer.msg("look","Look"), formatPanel.getPanel());
tabbedPane.add(ProgramInfo.mLocalizer.msg("fields","Fields"), orderPanel.getPanel());
tabbedPane.add(Localizer.getLocalization(Localizer.I18N_PICTURES), picturePanel.getPanel());
tabbedPane.add(ProgramInfo.mLocalizer.msg("actorSearch","Actor search"), actorPanel.getPanel());
tabbedPane.setSelectedIndex(0);
FormLayout layout = new FormLayout("default,default:grow,default","pref");
layout.setColumnGroups(new int[][] {{1,3}});
JPanel buttonPn = new JPanel(layout);
buttonPn.add(previewBtn, cc.xy(3,1));
buttonPn.add(defaultBtn, cc.xy(1,1));
JPanel base = new JPanel(new FormLayout("default:grow","fill:default:grow,10dlu,default"));
base.setBorder(Borders.DIALOG_BORDER);
base.add(tabbedPane, cc.xy(1,1));
base.add(buttonPn, cc.xy(1,3));
return base;