Search in sources :

Example 6 with UIPropertyContext

use of pcgen.gui2.UIPropertyContext in project pcgen by PCGen.

the class ExportDialog method initComponents.

private void initComponents() {
    characterBox.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            CharacterFacade character = (CharacterFacade) value;
            return super.getListCellRendererComponent(list, character.getNameRef().get(), index, isSelected, cellHasFocus);
        }
    });
    fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fileList.addListSelectionListener(this);
    exportButton.setDefaultCapable(true);
    getRootPane().setDefaultButton(exportButton);
    partyBox.setActionCommand(PARTY_COMMAND);
    exportBox.setActionCommand(EXPORT_TO_COMMAND);
    exportButton.setActionCommand(EXPORT_COMMAND);
    closeButton.setActionCommand(CLOSE_COMMAND);
    exportBox.addActionListener(this);
    partyBox.addActionListener(this);
    exportButton.addActionListener(this);
    closeButton.addActionListener(this);
    exportButton.setEnabled(false);
    progressBar.setStringPainted(true);
    progressBar.setString("Loading Templates");
    progressBar.setIndeterminate(true);
    setTitle("Export a PC or Party");
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    UIPropertyContext context = UIPropertyContext.createContext("ExportDialog");
    String defaultOSType = context.getProperty(UIPropertyContext.DEFAULT_OS_TYPE);
    if (defaultOSType != null) {
        for (SheetFilter filter : SheetFilter.values()) {
            if (defaultOSType.equals(filter.toString())) {
                exportBox.setSelectedItem(filter);
            }
        }
    }
}
Also used : DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) Component(java.awt.Component) CharacterFacade(pcgen.facade.core.CharacterFacade) UIPropertyContext(pcgen.gui2.UIPropertyContext) JList(javax.swing.JList)

Example 7 with UIPropertyContext

use of pcgen.gui2.UIPropertyContext 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

UIPropertyContext (pcgen.gui2.UIPropertyContext)7 IOException (java.io.IOException)2 CharacterFacade (pcgen.facade.core.CharacterFacade)2 Component (java.awt.Component)1 File (java.io.File)1 URI (java.net.URI)1 DefaultListCellRenderer (javax.swing.DefaultListCellRenderer)1 JCheckBox (javax.swing.JCheckBox)1 JFileChooser (javax.swing.JFileChooser)1 JList (javax.swing.JList)1 JPanel (javax.swing.JPanel)1 FileFilter (javax.swing.filechooser.FileFilter)1 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)1 IOFileFilter (org.apache.commons.io.filefilter.IOFileFilter)1 SuffixFileFilter (org.apache.commons.io.filefilter.SuffixFileFilter)1 TrueFileFilter (org.apache.commons.io.filefilter.TrueFileFilter)1 PropertyContext (pcgen.system.PropertyContext)1