|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.refactoring.ui; import java.lang.reflect.Modifier; import java.text.MessageFormat; import java.util.ResourceBundle; import javax.jmi.reflect.RefObject; import org.netbeans.modules.refactoring.api.RenameRefactoring; import org.netbeans.modules.refactoring.api.WhereUsedQuery; import org.netbeans.modules.refactoring.api.ui.RefactoringUI; import org.netbeans.jmi.javamodel.*; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; /** * * @author Martin Matula */ public class WhereUsedQueryUI implements RefactoringUI { private final WhereUsedQuery query; private final String name; private WhereUsedPanel panel; private final RefObject element; public WhereUsedQueryUI(RefObject jmiObject) { this.query = new WhereUsedQuery(jmiObject); this.element = jmiObject; if (jmiObject instanceof Constructor) { name = ((JavaClass) ((Constructor) jmiObject).getDeclaringClass()).getName(); } else if (jmiObject instanceof NamedElement) { name = ((NamedElement) jmiObject).getName(); } else { name = ""; } } public boolean isQuery() { return true; } public javax.swing.JPanel getPanel(org.netbeans.modules.refactoring.api.ui.ParametersPanel parent) { if (panel == null) { panel = new WhereUsedPanel(name, element, parent); } return panel; } public org.netbeans.modules.refactoring.api.Problem setParameters() { if (element instanceof Method) { return query.setParametersForMethod(panel.isMethodFromBaseClass(), panel.isMethodOverriders(), panel.isMethodFindUsages()); } else if (element instanceof JavaClass) { return query.setParametersForClass(panel.isClassSubTypes(), panel.isClassSubTypesDirectOnly()); } else return null; } public org.netbeans.modules.refactoring.api.Problem checkParameters() { if (element instanceof Method) { return query.checkParametersForMethod(panel.isMethodFromBaseClass(), panel.isMethodOverriders(), panel.isMethodFindUsages()); } else if (element instanceof JavaClass) { return query.checkParametersForClass(panel.isClassSubTypes(), panel.isClassSubTypesDirectOnly()); } else return null; } public org.netbeans.modules.refactoring.api.AbstractRefactoring getRefactoring() { return query; } public String getDescription() { if (element instanceof JavaClass) { if (!panel.isClassFindUsages()) if (!panel.isClassSubTypesDirectOnly()) { return getString("DSC_WhereUsedFindAllSubTypes", name); } else { return getString("DSC_WhereUsedFindDirectSubTypes", name); } } else { if (element instanceof Method) { String description = null; if (panel.isMethodFindUsages()) { description = getString("DSC_FindUsages"); } if (panel.isMethodOverriders()) { if (description != null) { description += " " + getString("DSC_And") + " "; } else { description = ""; } description += getString("DSC_WhereUsedMethodOverriders"); } if (panel.isMethodFromBaseClass()) { description += " " + getString("DSC_And") + " " + getString("DSC_WhereUsedFromBaseClass"); } description += " " + getString("DSC_WhereUsedOf", name); return description; } } return getString("DSC_WhereUsed", name); } private ResourceBundle bundle; private String getString(String key) { if (bundle == null) { bundle = NbBundle.getBundle(WhereUsedQueryUI.class); } return bundle.getString(key); } private String getString(String key, String value) { return new MessageFormat(getString(key)).format (new Object[] {value}); } public String getName() { return new MessageFormat(NbBundle.getMessage(WhereUsedAction.class, "LBL_WhereUsed")).format ( new Object[] {name} ); } public boolean hasParameters() { if (element instanceof JavaClass) return true; if (element instanceof Method) { return !Modifier.isStatic(((Method) element).getModifiers()); } return false; } public HelpCtx getHelpCtx() { return new HelpCtx(WhereUsedQueryUI.class); } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.