本文整理汇总了Java中com.intellij.util.ReflectionUtil.getField方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionUtil.getField方法的具体用法?Java ReflectionUtil.getField怎么用?Java ReflectionUtil.getField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.ReflectionUtil
的用法示例。
在下文中一共展示了ReflectionUtil.getField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPropertyValue
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Nullable
private static Object getPropertyValue(Object componentInstance, String propertyName) {
final Class<? extends Object> componentInstanceClass = componentInstance.getClass();
Object propertyValue = ReflectionUtil.getField(componentInstanceClass, componentInstance, null, propertyName);
if (propertyValue == null) {
Method method = ReflectionUtil.getMethod(componentInstanceClass, "get" + StringUtil.capitalize(propertyName));
if (method == null) {
method = ReflectionUtil.getMethod(componentInstanceClass, "is" + StringUtil.capitalize(propertyName));
}
if (method != null) {
try {
propertyValue = method.invoke(componentInstance);
}
catch (Exception ignored) {
}
}
}
return propertyValue;
}
示例2: getProcessPid
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
/**
* Returns {@code pid} for Windows process
* @param process Windows process
* @return pid of the {@code process}
*/
public static int getProcessPid(Process process) {
if (process.getClass().getName().equals("java.lang.Win32Process") ||
process.getClass().getName().equals("java.lang.ProcessImpl")) {
try {
long handle = ReflectionUtil.getField(process.getClass(), process, long.class, "handle");
Kernel32 kernel = Kernel32.INSTANCE;
WinNT.HANDLE winHandle = new WinNT.HANDLE();
winHandle.setPointer(Pointer.createConstant(handle));
return kernel.GetProcessId(winHandle);
} catch (Throwable e) {
throw new IllegalStateException(e);
}
} else {
throw new IllegalStateException("Unknown Process implementation");
}
}
示例3: clearAntStaticCache
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
private static void clearAntStaticCache(final Class helperClass) {
//if (++ourClearAttemptCount > 1000) { // allow not more than 1000 helpers cached inside ant
// ourClearAttemptCount = 0;
//}
//else {
// return;
//}
// for ant 1.7, there is a dedicated method for cache clearing
try {
final Method method = helperClass.getDeclaredMethod("clearCache");
method.invoke(null);
}
catch (Throwable e) {
try {
// assume it is older version of ant
Map helpersCollection = ReflectionUtil.getField(helperClass, null, null, "helpers");
helpersCollection.clear();
}
catch (Throwable _e) {
// ignore.
}
}
}
示例4: getComboboxPopup
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Nullable
private static ComboPopup getComboboxPopup(final JComboBox comboBox) {
final ComboBoxUI ui = comboBox.getUI();
ComboPopup popup = null;
if (ui instanceof BasicComboBoxUI) {
popup = ReflectionUtil.getField(BasicComboBoxUI.class, ui, ComboPopup.class, "popup");
}
return popup;
}
示例5: prepareNumberEditor
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
protected JFormattedTextField prepareNumberEditor(@NonNls final String fieldName) {
final NumberFormat formatter = NumberFormat.getIntegerInstance();
formatter.setParseIntegerOnly(true);
final JFormattedTextField valueField = new JFormattedTextField(formatter);
Object value = ReflectionUtil.getField(getClass(), this, null, fieldName);
valueField.setValue(value);
valueField.setColumns(2);
// hack to work around text field becoming unusably small sometimes when using GridBagLayout
valueField.setMinimumSize(valueField.getPreferredSize());
UIUtil.fixFormattedField(valueField);
final Document document = valueField.getDocument();
document.addDocumentListener(new DocumentAdapter() {
@Override
public void textChanged(DocumentEvent evt) {
try {
valueField.commitEdit();
final Number number = (Number)valueField.getValue();
ReflectionUtil.setField(BaseInspection.this.getClass(), BaseInspection.this, int.class, fieldName, number.intValue());
}
catch (ParseException e) {
// No luck this time. Will update the field when correct value is entered.
}
}
});
return valueField;
}
示例6: checkProjectLeak
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@TestOnly
public static void checkProjectLeak() throws Exception {
Processor<Project> isReallyLeak = new Processor<Project>() {
@Override
public boolean process(Project project) {
return !project.isDefault() && !((ProjectImpl)project).isLight();
}
};
Collection<Object> roots = new ArrayList<Object>(Arrays.asList(ApplicationManager.getApplication(), Extensions.getRootArea()));
ClassLoader classLoader = LeakHunter.class.getClassLoader();
Vector<Class> allLoadedClasses = ReflectionUtil.getField(classLoader.getClass(), classLoader, Vector.class, "classes");
roots.addAll(allLoadedClasses); // inspect static fields of all loaded classes
checkLeak(roots, ProjectImpl.class, isReallyLeak);
}
示例7: AwtPopupWrapper
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
public AwtPopupWrapper(Popup popup, JBPopup jbPopup) {
myPopup = popup;
myJBPopup = jbPopup;
if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) {
final Component c = ReflectionUtil.getField(Popup.class, myPopup, Component.class, "component");
c.setBackground(UIUtil.getPanelBackground());
}
}
示例8: getProcessPid
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
public static int getProcessPid(Process process) {
try {
return ReflectionUtil.getField(process.getClass(), process, int.class, "pid");
}
catch (Exception e) {
throw new IllegalStateException("system is not unix", e);
}
}
示例9: cleanupSwingDataStructures
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
private static void cleanupSwingDataStructures() throws Exception {
Object manager =
ReflectionUtil.getDeclaredMethod(
Class.forName("javax.swing.KeyboardManager"), "getCurrentManager")
.invoke(null);
Map<?, ?> componentKeyStrokeMap =
ReflectionUtil.getField(
manager.getClass(), manager, Hashtable.class, "componentKeyStrokeMap");
componentKeyStrokeMap.clear();
Map<?, ?> containerMap =
ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "containerMap");
containerMap.clear();
}
示例10: getField
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
public FIELD_TYPE getField() {
if (myWagonManagerCache == null) {
Object value = ReflectionUtil.getField(myHostClass, myHost, null, myFieldName);
//noinspection unchecked
myWagonManagerCache = (FIELD_TYPE)value;
}
return myWagonManagerCache;
}
示例11: getPropertyValue
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
private static boolean getPropertyValue(InspectionProfileEntry owner,
String property) {
return ReflectionUtil.getField(owner.getClass(), owner, boolean.class, property);
}
示例12: getOption
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Override
public boolean getOption(final String optionName) {
return ReflectionUtil.getField(myInspection.getClass(), myInspection, boolean.class, optionName);
}
示例13: isComboPopupKeyEvent
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
public static boolean isComboPopupKeyEvent(@NotNull ComponentEvent event, @NotNull JComboBox comboBox) {
final Component component = event.getComponent();
if(!comboBox.isPopupVisible() || component == null) return false;
ComboPopup popup = ReflectionUtil.getField(comboBox.getUI().getClass(), comboBox.getUI(), ComboPopup.class, "popup");
return popup != null && SwingUtilities.isDescendingFrom(popup.getList(), component);
}
示例14: getPropertyValue
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
private static Object getPropertyValue(InspectionProfileEntry owner, String property) {
return ReflectionUtil.getField(owner.getClass(), owner, null, property);
}
示例15: getFocusTraversalPolicyAwtImpl
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
private static FocusTraversalPolicy getFocusTraversalPolicyAwtImpl(final JComponent component) {
return ReflectionUtil.getField(Container.class, component, FocusTraversalPolicy.class, "focusTraversalPolicy");
}