在eclipse galileo中从另一个包中识别另一个类的类调用

时间:2011-04-15 03:48:32

标签: eclipse

这里我有一组资源包(一个.properties java类),它被eclipse项目文件中的许多类调用。我只是想知道eclipse是否有任何快捷键或函数来自动识别来自另一个包中的类(资源包),这些包已经从不同包中的另一个类调用。

调用另一个包资源包的行是

private ResourceBundle useCaseResourceBundle;

完整的代码是

package my.com.infopro.icba10.accounting.ui.maintainproductgl;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

import my.com.infopro.icba10.accounting.delegate.AccountingDelegate;
import my.com.infopro.icba10.accounting.domain.GLField;
import my.com.infopro.icba10.accounting.domain.GLProduct;
import my.com.infopro.icba10.accounting.domain.GLProductDetail;
import my.com.infopro.icba10.admin.vlh.lov.CurrencyLov;
import my.com.infopro.icba10.kernel.uiframework.annotation.ValidationConfigFile;
import my.com.infopro.icba10.kernel.uiframework.binding.PresentationModelFactory;
import my.com.infopro.icba10.kernel.uiframework.component.CustomizedCombobox;
import my.com.infopro.icba10.kernel.uiframework.form.IconFactory;
import my.com.infopro.icba10.kernel.uiframework.form.IconType;
import my.com.infopro.icba10.kernel.uiframework.form.builders.CustomizedPanelBuilder;
import my.com.infopro.icba10.kernel.uiframework.form.builders.PanelBuilderFactory;
import my.com.infopro.icba10.kernel.uiframework.session.UserSessionProfileStore;
import my.com.infopro.icba10.kernel.uiframework.util.LayoutType;
import my.com.infopro.icba10.kernel.uiframework.validation.controls.CustomizedForm;
import my.com.infopro.icba10.kernel.util.configuration.CustomConfig;
import my.com.infopro.icba10.kernel.util.db.DataAccessMode;
import my.com.infopro.icba10.kernel.valuelisthandler.lov.Lov;

import org.apache.commons.beanutils.BeanComparator;
import org.apache.log4j.Logger;

import com.jgoodies.binding.beans.Model;
import com.jgoodies.binding.list.SelectionInList;

/* =================================================================================================
 * HISTORY
 * -------------------------------------------------------------------------------------------------
 * Date         Author      Remarks
 * -------------------------------------------------------------------------------------------------
 * 2010/08/22   hmho        class created 
 * =================================================================================================
 */
@ValidationConfigFile("my.com.infopro.icba10.cbs.core.ui.vconfig.maintainproductglset-vconfig")
public class MaintainProductGLCopyPopUp extends CustomizedForm implements ActionListener {

    private Logger logger= Logger.getLogger(MaintainProductGLCopyPopUp.class);
    private CustomConfig config = CustomConfig.getInstance();
    private ResourceBundle useCaseResourceBundle;
    private UserSessionProfileStore userSessionProfileStore= UserSessionProfileStore.getInstance();

    private CustomizedCombobox currencyComboBox;
    private CustomizedCombobox glSetCodeComboBox;
    private JButton okButton = new JButton();

    private GLProduct fromGLProduct;
    private GLProduct toGLProduct;
    private MaintainProductGLMaintForm form;
    private String glSetCode;
    private String glSetDescription;
    private Map<String,List<GLProductDetail>> glDetailMap = new HashMap<String,List<GLProductDetail>>();

    private AccountingDelegate accountingDelegate;

    public MaintainProductGLCopyPopUp(MaintainProductGLMaintForm form,ResourceBundle useCaseResourceBundle,
            GLProduct glProduct,Map<String,List<GLProductDetail>> glDetailMap) {
        super();
        this.form = form;
        this.useCaseResourceBundle = useCaseResourceBundle;
        this.toGLProduct = glProduct;
        this.glDetailMap = glDetailMap;
    }

    @Override
    public boolean isFormValidatable() {
        return true;
    }

    public void init() {
        initPanels();
        initBindingAndValidation();
        initCode();
        initEventHandling();
    }

    private void initPanels() {
        setLayout(new BorderLayout());
        add(buildCopyPanel(), BorderLayout.CENTER);
    }

    private void initBindingAndValidation() {
        fromGLProduct = new GLProduct();
        presentationModelDelegate = PresentationModelFactory.getPresentationModel(this, 
                getFormBeans(), new String[]{GLProduct.class.getSimpleName()}); 
        fromGLProduct.setBankingConcept(toGLProduct.getBankingConcept());
        fromGLProduct.setModuleCode(toGLProduct.getModuleCode());
        glSetCode = toGLProduct.getGlSetCode();
        glSetDescription = toGLProduct.getGlSetDescription();
        logger.debug("init in copy " );
        logger.debug("toGLProduct " + toGLProduct.getGlSetCode());
        logger.debug("toGLProduct " + toGLProduct.getGlSetDescription());
    }

    private void initCode() {
        accountingDelegate = new AccountingDelegate();
        Lov currencyLov = new CurrencyLov();

        presentationModelDelegate.bindComboBoxWithValues(currencyComboBox, currencyLov);

    }

    private void initEventHandling() {
        currencyComboBox.addActionListener(this);
        okButton.addActionListener(this);
    }

    private JPanel buildCopyPanel() {
        CustomizedPanelBuilder builder = PanelBuilderFactory.createPanelBuilder(LayoutType.SINGLE_CENTERED);
        JPanel popupPanel = new JPanel();
        popupPanel.setLayout(new BorderLayout());
        popupPanel.setBorder(new TitledBorder (useCaseResourceBundle.getString("copyPanel")));

        JPanel copyPanel = new JPanel();
        currencyComboBox= new CustomizedCombobox();
        glSetCodeComboBox= new CustomizedCombobox();
        builder.addComponentGroup(useCaseResourceBundle.getString("currency"), "GLProduct.currencyCode", currencyComboBox);
        builder.addComponentGroup(useCaseResourceBundle.getString("glSetCode"), "GLProduct.glSetCode", glSetCodeComboBox);

        copyPanel = builder.getStandardPanel();
        popupPanel.add(copyPanel, BorderLayout.CENTER);
        popupPanel.add(buildButtonPanel(), BorderLayout.SOUTH);

        return popupPanel;
    }

    private JPanel buildButtonPanel() {

        JPanel innerButtonPanel = new JPanel();
        okButton = new JButton();
        okButton.setText(useCaseResourceBundle.getString("okButton"));
        okButton.setIcon(IconFactory.createIcon(IconType.OK));
        innerButtonPanel.add(okButton);

        JPanel buttonPanel = new JPanel();
        buttonPanel.setLayout(new BorderLayout());
        buttonPanel.add(innerButtonPanel,BorderLayout.EAST);

        return buttonPanel;
    }


    public void registerComponentNames() {
    }

    @Override
    protected void createFormBeans() {
        fromGLProduct = new GLProduct();
    }

    @Override
    public Model[] getFormBeans() {
        return new Model[]{fromGLProduct};   
    }

    @Override
    protected void setFormBeans(final Model[] updatedBean) {
        fromGLProduct = (GLProduct) updatedBean[0];
    }

    public void actionPerformed(ActionEvent event) {
        // TODO Auto-generated method stub
       final Object sourceObject = event.getSource(); 
       if (sourceObject.equals(okButton)) {
           if(null!=fromGLProduct.getCurrencyCode() && null!=fromGLProduct.getGlSetCode()){
               setCopyData();
               searchFrame.dispose();
           }
       } 
       if (sourceObject.equals(currencyComboBox)) {
           List<GLProduct> glSetCodeList = accountingDelegate.findAvailableGlProduct(fromGLProduct);
           if(glSetCodeList.size()<=0) {
               glSetCodeList.add(new GLProduct());
           }
           presentationModelDelegate.bindComboBoxWithValues(glSetCodeComboBox, glSetCodeList, "glSetCode",true);
           glSetCodeComboBox.createListCellRendererHandler();
       }
    }

    private void setCopyData() {
         userSessionProfileStore.setApplicationQueryCall();
         logger.debug("copying " );
         logger.debug("toGLProduct1 " + toGLProduct.getGlSetCode());
         logger.debug("toGLProduct1 " + toGLProduct.getGlSetDescription());
         GLProduct copyProduct = accountingDelegate.copyGLProducts(fromGLProduct, toGLProduct);
         logger.debug("fromGLProduct " + fromGLProduct.getGlSetCode());
         logger.debug("fromGLProduct " + fromGLProduct.getGlSetDescription());
         logger.debug("copyProduct " + copyProduct.getGlSetCode());
         logger.debug("copyProduct " + copyProduct.getGlSetDescription());
         GLField glField = new GLField();

         if(null!=copyProduct){
//           copyProduct.setGlSetCode(glSetCode);
//           copyProduct.setGlSetDescription(glSetDescription);
//           Model[] models = new Model[] {copyProduct, glField};
//           form.getPresentationModelDelegate().reinitBean(copyProduct);
             if(copyProduct.getGLProductDetailList().size()>0){
                 form.getGlSetTableManagerModel().clearItems();
                 BeanComparator comparator = new BeanComparator("glField");
                 Collections.sort(copyProduct.getGLProductDetailList(), comparator);
                 form.setGlSetTableManagerModel(copyProduct.getGLProductDetailList());
                 logger.debug("Copy List Size 2 " + copyProduct.getGLProductDetailList().size());
             }

             SelectionInList selectionInList = form.getGlSetTableManagerModel()
             .getItemSelectionsList();
             List<GLProductDetail> glProductDetails = new ArrayList<GLProductDetail>();
                glProductDetails.clear();
             for(int i=0;i<selectionInList.getSize();i++){
                 GLProductDetail glProductDetail = (GLProductDetail) selectionInList
                    .getElementAt(i);
                 glProductDetail.setAction(DataAccessMode.INSERT);
                 glProductDetails.add(glProductDetail);
             }
             glDetailMap.clear();
             glDetailMap.put(useCaseResourceBundle.getString("defaultCategoryCode"),glProductDetails);
             form.setGlProductDetailMap(glDetailMap);
             for(String key :form.getGlProductDetailMap().keySet()){
                 List<GLProductDetail>gls = form.getGlProductDetailMap().get(key);
                 for(GLProductDetail gl:gls){
                     logger.debug("Map " +gls.size());
                     if(null!=gl.getGlCode()){
                         logger.debug("Map " + gl.getGlField());
                         logger.debug("Map " + gl.getGlCode());
                     }
                 }
             }
        }
    }
}

有没有什么方法可以让我在eclipse中使用任何键或函数来打开java文件引用来自此类的useCaseResourceBundle。在某些情况下,它更容易,因为班级已经明确宣布它。

实施例

private ResourceBundle resourceBundle = config.getPropResourceBundle("KERN_BUNDLE_UIFRAMEWORK");

1 个答案:

答案 0 :(得分:0)

<强>按Ctrl + Shift + G

菜单 - &gt;搜索 - &gt;参考文献 - &gt; ...

  

搜索对所选内容的引用   工作区/项目/层次结构/工作集中的元素......