use of pcgen.system.PropertyContext in project pcgen by PCGen.
the class JTreeViewTable method setTreeViewModel.
public void setTreeViewModel(TreeViewModel<T> viewModel) {
ListFacade<? extends TreeView<T>> views = viewModel.getTreeViews();
PropertyContext context = baseContext.createChildContext(viewModel.getDataView().getPrefsKey());
int viewIndex = context.initInt(VIEW_INDEX_PREFS_KEY, viewModel.getDefaultTreeViewIndex());
TreeView<? super T> startingView = views.getElementAt(viewIndex);
DataView<T> dataView = viewModel.getDataView();
final TreeViewTableModel<T> model = createDefaultTreeViewTableModel(dataView);
this.treetableModel = model;
if (this.viewModel != null) {
this.viewModel.getTreeViews().removeListListener(cornerPopupMenu);
}
this.viewModel = viewModel;
model.setDataModel(viewModel.getDataModel());
model.setSelectedTreeView(startingView);
setTreeTableModel(model);
setColumnModel(createTableColumnModel(startingView, dataView));
cornerPopupMenu.resetComponents();
this.viewModel.getTreeViews().addListListener(cornerPopupMenu);
}
use of pcgen.system.PropertyContext in project pcgen by PCGen.
the class PCGenFrame method showSponsorsDialog.
public void showSponsorsDialog() {
Collection<Sponsor> sponsors = Globals.getGlobalContext().getReferenceContext().getConstructedCDOMObjects(Sponsor.class);
if (sponsors.size() <= 1) {
return;
}
//$NON-NLS-1$
String title = LanguageBundle.getString("in_sponsorTitle");
final JDialog aFrame = new JDialog(this, title, true);
//$NON-NLS-1$
final JButton jClose = new JButton(LanguageBundle.getString("in_close"));
//$NON-NLS-1$
jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
final JPanel jPanel = new JPanel();
//$NON-NLS-1$
final JCheckBox jCheckBox = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad"));
jPanel.add(jCheckBox);
final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT;
jCheckBox.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_SPONSORS_ON_LOAD));
jCheckBox.addItemListener(evt -> context.setBoolean(PCGenSettings.OPTION_SHOW_SPONSORS_ON_LOAD, jCheckBox.isSelected()));
jPanel.add(jClose);
jClose.addActionListener(evt -> aFrame.dispose());
StringBuilder sb = new StringBuilder(500);
sb.append("<html>");
for (Sponsor sponsor : sponsors) {
if (!"PCGEN".equals(sponsor.getKeyName())) {
continue;
}
sb.append("<img src='").append(sponsor.getBannerImage()).append("'><br>");
}
String s = "";
if (sponsors.size() > 2) {
s = "s";
}
sb.append("<H2><CENTER>").append(LanguageBundle.getString("in_sponsorThanks")).append(//$NON-NLS-1$
s).append(":</CENTER></h2>");
int size = 172;
for (Sponsor sponsor : sponsors) {
if ("PCGEN".equals(sponsor.getKeyName())) {
continue;
}
size += 70;
sb.append("<img src='").append(sponsor.getBannerImage()).append("'><br>");
}
sb.append("</html>");
HtmlPanel htmlPanel = new HtmlPanel();
HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext());
htmlPanel.setHtml(sb.toString(), "", theRendererContext);
aFrame.getContentPane().setLayout(new BorderLayout());
aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER);
aFrame.getContentPane().add(jPanel, BorderLayout.SOUTH);
aFrame.setSize(new Dimension(505, size));
Utility.setComponentRelativeLocation(this, aFrame);
aFrame.setVisible(true);
}
use of pcgen.system.PropertyContext in project pcgen by PCGen.
the class ChooserDialog method overridePrefs.
/**
* We don't want some things recalled in preferences (e.g. tree sorting) as they
* aren't the same for all choose data. Ensure we put out desired values in first.
*/
private void overridePrefs() {
UIPropertyContext baseContext = UIPropertyContext.createContext("tablePrefs");
PropertyContext context = baseContext.createChildContext(treeViewModel.getDataView().getPrefsKey());
final String VIEW_INDEX_PREFS_KEY = "viewIdx";
context.setInt(VIEW_INDEX_PREFS_KEY, treeViewModel.getDefaultTreeViewIndex());
}
Aggregations