Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg
grondeau wrote:Shell inheritance works well at runtime but in Eclipe editor I can't see the widgets in the subclass. For example, class A extends Shell and defines Button X, class B extends class A and defines button Y. In Eclipse, when I look at class A I can see the button but when I look at class B, I see nothing. If you execute the application (which instantiates class B), both buttons are visible. Is this supported?
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Shell1 extends Shell {
private Button checkBox;
private Button helloButton;
public static void main(String args[]) {
try {
Display display = Display.getDefault();
Shell1 shell = new Shell1(display, SWT.SHELL_TRIM);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public Shell1(Display display, int style) {
super(display, style);
setText("SWT Application");
setSize(500, 375);
helloButton = new Button(this, SWT.NONE);
helloButton.setText("Hello");
helloButton.setBounds(14, 13, 131, 62);
checkBox = new Button(this, SWT.CHECK);
checkBox.setText("Check Button");
checkBox.setBounds(151, 27, 186, 35);
}
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
public Button getHelloButton() {
return helloButton;
}
public String getCheckBoxText() {
return checkBox.getText();
}
public void setCheckBoxText(String text) {
checkBox.setText(text);
}
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
public class Shell2 extends Shell1 {
public static void main(String args[]) {
try {
Display display = Display.getDefault();
Shell2 shell = new Shell2(display, SWT.SHELL_TRIM);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public Shell2(Display display, int style) {
super(display, style);
setText("SWT Application");
setSize(500, 375);
final Button button = new Button(this, SWT.NONE);
button.setText("button");
button.setBounds(147, 90, 107, 47);
setCheckBoxText("My Label");
getHelloButton().setText("World");
getHelloButton().setLocation(10, 82);
}
}
on top of the tool bar. Is there a configuration parameter somewhere to enable this feature?Unknown Window Type
!ENTRY com.swtdesigner 4 4 2007-02-08 11:32:54.876
!MESSAGE Designer internal error [6.1.0.20070208071007]: Shell1
!STACK 0
java.lang.ClassNotFoundException: Shell1
at com.swtdesigner.model.util.ast.ASTEditor.loadClass(ASTEditor.java:334)
at com.swtdesigner.model.parser.factory.JavaInfoFactory.loadComponentClass(JavaInfoFactory.java:622)
at com.swtdesigner.model.parser.factory.JavaInfoFactory.loadComponentClass(JavaInfoFactory.java:618)
at com.swtdesigner.model.parser.JavaInfoParser$ParserVisitor.visit(JavaInfoParser.java:2677)
at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:466)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2466)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2536)
at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:212)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2466)
at com.swtdesigner.model.parser.JavaInfoParser.parse(JavaInfoParser.java:202)
at com.swtdesigner.gef.DesignerEditor.parseCompilationUnit(DesignerEditor.java:1064)
at com.swtdesigner.gef.DesignerEditor$17.execute(DesignerEditor.java:1001)
at com.swtdesigner.model.swing.properties.custom.DesignTimeHelper.execute(DesignTimeHelper.java:54)
at com.swtdesigner.gef.DesignerEditor.handleActivate(DesignerEditor.java:995)
at com.swtdesigner.gef.DesignerEditor.handleActivate(DesignerEditor.java:991)
at com.swtdesigner.editors.MultiPageEditor.showDesignEditor(MultiPageEditor.java:413)
at com.swtdesigner.editors.MultiPageEditor$2.widgetSelected(MultiPageEditor.java:183)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:709)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3171)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1953)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:288)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
grondeau wrote:The inherited Shell1 can't be found. This happens when opening the design tab for Shell2. There are no java errors (no red) and if the application is executed it performs as expected, showing the merged widgets from shell1 and 2. I can't figure out how to solve this.
Users browsing this forum: No registered users and 2 guests