com.pureinfo.srm.srm2rpms.action.ToolbarAction.java Source code

Java tutorial

Introduction

Here is the source code for com.pureinfo.srm.srm2rpms.action.ToolbarAction.java

Source

/**
 * PureInfo Quake
 * @(#)ToolbarAction.java   1.0 Jun 28, 2006
 * 
 * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. 
 * All rights reserved, see the license file.
 * 
 * www.pureinfo.com.cn
 */

package com.pureinfo.srm.srm2rpms.action;

import java.util.Iterator;
import java.util.List;

import org.dom4j.Element;

import com.pureinfo.ark.interaction.toolbar.ToolbarActionBase;
import com.pureinfo.force.exception.PureException;
import com.pureinfo.force.io.ClassResourceUtil;
import com.pureinfo.force.xml.XMLUtil;

public class ToolbarAction extends ToolbarActionBase {

    protected void addToolbarElements() throws PureException {
        addElement("view.do", "RPMS");

        // to add validators
        String sFileName = ClassResourceUtil.mapFullPath("srm2rpms-validator.cfg.xml", false);
        if (sFileName != null) {
            Element element = XMLUtil.fileToElement(sFileName);
            List list = element.elements();
            try {
                Iterator itrList = list.iterator();
                while (itrList.hasNext()) {
                    element = (Element) itrList.next();
                    addElement("validator.do?id=" + element.attributeValue("id") + "&classId="
                            + element.attributeValue("classId"), element.attributeValue("title"));
                }
            } finally {
                list.clear();
            }
        }
    }

    protected String getTitle() throws PureException {
        return "RPMS";
    }

}