Search in sources :

Example 1 with Filter

use of org.jdom2.filter.Filter in project pcgen by PCGen.

the class Initiative method checkDeadTabs.

/**
	 * Check for dead combatants
	 */
private void checkDeadTabs() {
    initList.stream().filter(anInitList -> anInitList.getStatus() == State.Dead).forEach(anInitList -> {
        if (showDead.isSelected() && (anInitList instanceof Combatant) && (tpaneInfo.indexOfTab(anInitList.getName()) == -1)) {
            Combatant cbt = (Combatant) anInitList;
            addTab(cbt);
        } else {
            removeTab(anInitList);
        }
    });
}
Also used : PluginManager(pcgen.pluginmgr.PluginManager) Globals(pcgen.core.Globals) Combatant(gmgen.plugin.Combatant) InfoCharacterDetails(gmgen.plugin.InfoCharacterDetails) HyperlinkEvent(javax.swing.event.HyperlinkEvent) JDialog(javax.swing.JDialog) DiceRollModel(plugin.initiative.DiceRollModel) JTableHeader(javax.swing.table.JTableHeader) TableCellRenderer(javax.swing.table.TableCellRenderer) NumberFormatter(javax.swing.text.NumberFormatter) PcgCombatant(gmgen.plugin.PcgCombatant) Document(org.jdom2.Document) Dice(gmgen.plugin.dice.Dice) Vector(java.util.Vector) SettingsHandler(pcgen.core.SettingsHandler) LogUtilities(gmgen.util.LogUtilities) JFileChooser(javax.swing.JFileChooser) DefaultFormatter(javax.swing.text.DefaultFormatter) JComboBox(javax.swing.JComboBox) ListSelectionEvent(javax.swing.event.ListSelectionEvent) FlippingSplitPane(gmgen.gui.FlippingSplitPane) InitHolder(gmgen.plugin.InitHolder) DefaultTableModel(javax.swing.table.DefaultTableModel) Format(org.jdom2.output.Format) Logging(pcgen.util.Logging) Spell(gmgen.plugin.Spell) PCStat(pcgen.core.PCStat) SpellModel(plugin.initiative.SpellModel) GMGenSystem(gmgen.GMGenSystem) Component(java.awt.Component) Collectors(java.util.stream.Collectors) SystemInitiative(gmgen.plugin.SystemInitiative) List(java.util.List) InitHolderList(gmgen.plugin.InitHolderList) CheckModel(plugin.initiative.CheckModel) JSeparator(javax.swing.JSeparator) Writer(java.io.Writer) JCheckBox(javax.swing.JCheckBox) JTable(javax.swing.JTable) XMLCombatant(plugin.initiative.XMLCombatant) Element(org.jdom2.Element) State(gmgen.plugin.State) PlayerCharacter(pcgen.core.PlayerCharacter) PObjectModel(plugin.initiative.PObjectModel) TableColumnModel(javax.swing.table.TableColumnModel) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) InitiativePlugin(plugin.initiative.InitiativePlugin) ArrayList(java.util.ArrayList) AttackModel(plugin.initiative.AttackModel) PCGenMessageHandler(pcgen.pluginmgr.PCGenMessageHandler) SystemHP(gmgen.plugin.SystemHP) LanguageBundle(pcgen.system.LanguageBundle) PCGenSettings(pcgen.system.PCGenSettings) HyperlinkListener(javax.swing.event.HyperlinkListener) SAXBuilder(org.jdom2.input.SAXBuilder) JButton(javax.swing.JButton) JFormattedTextField(javax.swing.JFormattedTextField) TableColumn(javax.swing.table.TableColumn) FileWriter(java.io.FileWriter) IOException(java.io.IOException) JOptionPane(javax.swing.JOptionPane) FileFilter(javax.swing.filechooser.FileFilter) ActionEvent(java.awt.event.ActionEvent) File(java.io.File) DefaultCellEditor(javax.swing.DefaultCellEditor) XMLOutputter(org.jdom2.output.XMLOutputter) CombatantHasBeenUpdatedMessage(gmgen.pluginmgr.messages.CombatantHasBeenUpdatedMessage) Event(gmgen.plugin.Event) SaveModel(plugin.initiative.SaveModel) Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant)

Example 2 with Filter

use of org.jdom2.filter.Filter in project coprhd-controller by CoprHD.

the class ServiceCatalogBuilder method build.

/**
 * Parses xml file to ServiceCatalog with Jdom
 *
 * @param xmlFile
 *            The instance of xml file
 * @return instance of ServiceCatalog
 */
public static ServiceCatalog build(final File xmlFile) {
    String fileName = xmlFile.getName().trim().toLowerCase();
    // remove suffix
    if (fileName.endsWith(Constants.XML_FILE_SUFFIX)) {
        fileName = fileName.substring(0, fileName.length() - Constants.XML_FILE_SUFFIX.length() - 1);
    } else {
        throw new IllegalArgumentException("API file is not xml format: " + fileName);
    }
    // filter name
    int separatorIndex = fileName.indexOf(Constants.NAME_STRING_SEPARATOR);
    if (separatorIndex == -1) {
        throw new IllegalArgumentException("API file name should split with " + Constants.NAME_STRING_SEPARATOR + " actually: " + fileName);
    }
    String serviceName = fileName.substring(0, separatorIndex);
    String version = fileName.substring(separatorIndex + 1, fileName.length());
    Document document;
    try {
        document = new SAXBuilder().build(xmlFile);
    } catch (Exception ex) {
        throw new IllegalArgumentException("Invalid XML file:\n " + xmlFile.getAbsolutePath(), ex);
    }
    if (document == null) {
        return null;
    }
    // Navigates to resource tag, it's a little tricky here, depends on structure of xml file completely.
    List<Element> resourceList = document.getRootElement().getChild(Constants.REST_NODE).getChild(Constants.RESOURCES_NODE).getChildren();
    // Navigates to element tag, it's a little tricky here, depends on structure of xml file completely.
    List<Element> elementList = document.getRootElement().getChild(Constants.DATA_NODE).getChild(Constants.DATA_SCHEMA_NODE).getChild(Constants.ELEMENTS_NODE).getChildren();
    return new ServiceCatalog(parseResource(resourceList), parseElement(elementList), serviceName, version);
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Element(org.jdom2.Element) Document(org.jdom2.Document)

Example 3 with Filter

use of org.jdom2.filter.Filter in project JMRI by JMRI.

the class JmriUserPreferencesManager method saveComboBoxLastSelections.

private void saveComboBoxLastSelections() {
    this.setChangeMade(false);
    if (this.allowSave && !comboBoxLastSelection.isEmpty()) {
        Element element = new Element(COMBOBOX_ELEMENT, COMBOBOX_NAMESPACE);
        // Do not store blank last entered/selected values
        comboBoxLastSelection.entrySet().stream().filter((cbls) -> (cbls.getValue() != null && !cbls.getValue().isEmpty())).map((cbls) -> {
            Element combo = new Element("comboBox");
            combo.setAttribute("name", cbls.getKey());
            combo.setAttribute("lastSelected", cbls.getValue());
            return combo;
        }).forEach((combo) -> {
            element.addContent(combo);
        });
        this.saveElement(element);
        this.resetChangeMade();
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) ProfileManager(jmri.profile.ProfileManager) Point(java.awt.Point) HashMap(java.util.HashMap) JmriJFrame(jmri.util.JmriJFrame) Constructor(java.lang.reflect.Constructor) ArrayList(java.util.ArrayList) JDOMException(org.jdom2.JDOMException) JDOMUtil(jmri.util.jdom.JDOMUtil) ProfileUtils(jmri.profile.ProfileUtils) Map(java.util.Map) Bean(jmri.beans.Bean) Profile(jmri.profile.Profile) Method(java.lang.reflect.Method) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) BoxLayout(javax.swing.BoxLayout) InstanceManager(jmri.InstanceManager) UserPreferencesManager(jmri.UserPreferencesManager) Logger(org.slf4j.Logger) JmriException(jmri.JmriException) TableColumnPreferences(jmri.swing.JmriJTablePersistenceManager.TableColumnPreferences) Set(java.util.Set) JOptionPane(javax.swing.JOptionPane) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SortOrder(javax.swing.SortOrder) Dimension(java.awt.Dimension) List(java.util.List) FileUtil(jmri.util.FileUtil) JLabel(javax.swing.JLabel) ConfigureManager(jmri.ConfigureManager) JmriJTablePersistenceManager(jmri.swing.JmriJTablePersistenceManager) Entry(java.util.Map.Entry) JCheckBox(javax.swing.JCheckBox) DataConversionException(org.jdom2.DataConversionException) NodeIdentity(jmri.util.node.NodeIdentity) JPanel(javax.swing.JPanel) Toolkit(java.awt.Toolkit) Element(org.jdom2.Element) Element(org.jdom2.Element)

Example 4 with Filter

use of org.jdom2.filter.Filter in project JMRI by JMRI.

the class RpsPositionIconXml method store.

/**
     * Default implementation for storing the contents of a RpsPositionIcon
     *
     * @param o Object to store, of type RpsPositionIcon
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    RpsPositionIcon p = (RpsPositionIcon) o;
    if (!p.isActive()) {
        // if flagged as inactive, don't store
        return null;
    }
    Element element = new Element("sensoricon");
    storeCommonAttributes(p, element);
    // include contents
    element.setAttribute("active", p.getActiveIcon().getURL());
    element.setAttribute("error", p.getErrorIcon().getURL());
    element.setAttribute("rotate", String.valueOf(p.getActiveIcon().getRotation()));
    element.setAttribute("momentary", p.getMomentary() ? "true" : "false");
    element.setAttribute("sxscale", "" + p.getXScale());
    element.setAttribute("syscale", "" + p.getYScale());
    element.setAttribute("sxorigin", "" + p.getXOrigin());
    element.setAttribute("syorigin", "" + p.getYOrigin());
    element.setAttribute("showid", p.isShowID() ? "true" : "false");
    if (p.getFilter() != null) {
        element.setAttribute("filter", "" + p.getFilter());
    }
    element.addContent(storeIcon("active", p.getActiveIcon()));
    element.addContent(storeIcon("error", p.getErrorIcon()));
    element.setAttribute("class", "jmri.jmrit.display.configurexml.RpsPositionIconXml");
    return element;
}
Also used : Element(org.jdom2.Element) RpsPositionIcon(jmri.jmrit.display.RpsPositionIcon)

Example 5 with Filter

use of org.jdom2.filter.Filter in project jPOS by jpos.

the class ChannelAdaptor method addFilters.

protected void addFilters(FilteredChannel channel, Element e, QFactory fact) throws ConfigurationException {
    for (Object o : e.getChildren("filter")) {
        Element f = (Element) o;
        String clazz = f.getAttributeValue("class");
        ISOFilter filter = (ISOFilter) fact.newInstance(clazz);
        fact.setLogger(filter, f);
        fact.setConfiguration(filter, f);
        String direction = f.getAttributeValue("direction");
        if (direction == null)
            channel.addFilter(filter);
        else if ("incoming".equalsIgnoreCase(direction))
            channel.addIncomingFilter(filter);
        else if ("outgoing".equalsIgnoreCase(direction))
            channel.addOutgoingFilter(filter);
        else if ("both".equalsIgnoreCase(direction)) {
            channel.addIncomingFilter(filter);
            channel.addOutgoingFilter(filter);
        }
    }
}
Also used : Element(org.jdom2.Element)

Aggregations

Element (org.jdom2.Element)43 Document (org.jdom2.Document)24 List (java.util.List)22 IOException (java.io.IOException)20 ArrayList (java.util.ArrayList)19 LogManager (org.apache.logging.log4j.LogManager)17 Logger (org.apache.logging.log4j.Logger)17 JDOMException (org.jdom2.JDOMException)17 Collectors (java.util.stream.Collectors)16 File (java.io.File)11 MCRException (org.mycore.common.MCRException)11 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)11 Collections (java.util.Collections)10 MCRObject (org.mycore.datamodel.metadata.MCRObject)10 Map (java.util.Map)9 MCRAccessException (org.mycore.access.MCRAccessException)9 MCRConstants (org.mycore.common.MCRConstants)9 MCRDerivate (org.mycore.datamodel.metadata.MCRDerivate)9 MCRMetadataManager (org.mycore.datamodel.metadata.MCRMetadataManager)9 Files (java.nio.file.Files)8