
org.openxma.rwt.launch.PageUtil Maven / Gradle / Ivy
The newest version!
package org.openxma.rwt.launch;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.eclipse.swt.widgets.Shell;
import at.spardat.xma.boot.component.IComponent;
import at.spardat.xma.boot.component.IDialog;
public class PageUtil {
public static IDialog getDialog(IComponent comp) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Method getDialogMethod = null;
for (Method m : comp.getClass().getMethods()) {
if (m.getName().equals("getDialog")) {
getDialogMethod = m;
}
}
IDialog dialog = (IDialog)getDialogMethod.invoke(comp,null);
return dialog;
}
public static void setShell(IDialog d, Shell shell) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Class currentClass = d.getClass();
Class dialogPageClass = null;
while (currentClass != null) {
if (currentClass.getName().equals("at.spardat.xma.page.DialogPage")) {
dialogPageClass = currentClass;
}
currentClass = currentClass.getSuperclass();
}
if (dialogPageClass != null) {
for (Field f : dialogPageClass.getDeclaredFields()) {
if (f.getName().equals("shell")) {
f.setAccessible(true);
f.set(d,shell);
}
}
}
}
public static void setEventsEnabled(IDialog dialog, boolean enabled) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Method setShellMethod = null;
for (Method m : dialog.getClass().getMethods()) {
if (m.getName().equals("setEventsEnabled")) {
setShellMethod = m;
}
}
setShellMethod.invoke(dialog, true);
}
public static void initForEmbedding(IDialog dialog) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Method setShellMethod = null;
for (Method m : dialog.getClass().getMethods()) {
if (m.getName().equals("initForEmbedding")) {
setShellMethod = m;
}
}
if (setShellMethod != null) {
System.out.println("Method initForEmbedding executing...");
setShellMethod.invoke(dialog);
System.out.println("Method initForEmbedding executed.");
} else {
System.out.println("Method initForEmbedding not found.");
}
}
public static boolean isAppShell(IDialog dialog) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Method setShellMethod = null;
for (Method m : dialog.getClass().getMethods()) {
if (m.getName().equals("isAppShell")) {
setShellMethod = m;
}
}
if (setShellMethod != null) {
System.out.println("Method isAppShell executing...");
Object result = setShellMethod.invoke(dialog);
System.out.println("Method isAppShell executed.");
return (Boolean)result;
} else {
System.out.println("Method isAppShell not found.");
}
return false;
}
public static void runRootTask(IDialog dialog) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Method setShellMethod = null;
for (Method m : dialog.getClass().getMethods()) {
if (m.getName().equals("runRootTask")) {
setShellMethod = m;
}
}
if (setShellMethod != null) {
System.out.println("Method runRootTask executing...");
Object result = setShellMethod.invoke(dialog);
System.out.println("Method runRootTask executed.");
} else {
System.out.println("Method runRootTask not found.");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy