Search in sources :

Example 6 with PropertyContext

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);
}
Also used : UIPropertyContext(pcgen.gui2.UIPropertyContext) PropertyContext(pcgen.system.PropertyContext)

Example 7 with PropertyContext

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);
}
Also used : SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) HtmlRendererContext(org.lobobrowser.html.HtmlRendererContext) SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) JPanel(javax.swing.JPanel) JButton(javax.swing.JButton) Sponsor(pcgen.cdom.content.Sponsor) SimpleUserAgentContext(org.lobobrowser.html.test.SimpleUserAgentContext) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) BorderLayout(java.awt.BorderLayout) PropertyContext(pcgen.system.PropertyContext) HtmlPanel(org.lobobrowser.html.gui.HtmlPanel) JDialog(javax.swing.JDialog)

Example 8 with PropertyContext

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());
}
Also used : UIPropertyContext(pcgen.gui2.UIPropertyContext) PropertyContext(pcgen.system.PropertyContext) UIPropertyContext(pcgen.gui2.UIPropertyContext)

Aggregations

PropertyContext (pcgen.system.PropertyContext)8 UIPropertyContext (pcgen.gui2.UIPropertyContext)5 BorderLayout (java.awt.BorderLayout)3 Dimension (java.awt.Dimension)3 JButton (javax.swing.JButton)3 JCheckBox (javax.swing.JCheckBox)3 JDialog (javax.swing.JDialog)3 JPanel (javax.swing.JPanel)3 HtmlRendererContext (org.lobobrowser.html.HtmlRendererContext)3 HtmlPanel (org.lobobrowser.html.gui.HtmlPanel)3 SimpleHtmlRendererContext (org.lobobrowser.html.test.SimpleHtmlRendererContext)3 SimpleUserAgentContext (org.lobobrowser.html.test.SimpleUserAgentContext)3 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 JLabel (javax.swing.JLabel)1 TableColumn (javax.swing.table.TableColumn)1 Sponsor (pcgen.cdom.content.Sponsor)1