use of org.eclipse.wb.internal.swing.model.component.JPanelInfo in project windowbuilder by eclipse.
the class WrapperInfoTest method DISABLE_test_clipboard.
public void DISABLE_test_clipboard() throws Exception {
configureWrapperContents();
ContainerInfo container = parseContainer("public class Test extends JPanel {", " public Test() {", " {", " JPanel panel_1 = new JPanel();", " add(panel_1);", " TestWrapper wrapper = new TestWrapper(panel_1);", " JButton button = wrapper.getControl();", " }", " {", " JPanel panel_2 = new JPanel();", " add(panel_2);", " }", " }", "}");
container.refresh();
// panels
JPanelInfo panel_1 = container.getChildren(JPanelInfo.class).get(0);
ContainerInfo wrappedComponent = panel_1.getChildren(ContainerInfo.class).get(0);
JPanelInfo panel_2 = container.getChildren(JPanelInfo.class).get(1);
// create memento
JavaInfoMemento memento = JavaInfoMemento.createMemento(wrappedComponent);
// restore from memento
ComponentInfo newComponent = (ComponentInfo) memento.create(container);
JavaInfoUtils.add(newComponent, null, panel_2, null);
memento.apply();
// check source
assertEditor("public class Test extends JPanel {", " public Test() {", " {", " JPanel panel_1 = new JPanel();", " add(panel_1);", " TestWrapper wrapper = new TestWrapper(panel_1);", " JButton button = wrapper.getControl();", " }", " {", " JPanel panel_2 = new JPanel();", " add(panel_2);", " {", " TestWrapper testWrapper = new TestWrapper(panel_2);", " JButton button = testWrapper.getControl();", " }", " }", " }", "}");
}
use of org.eclipse.wb.internal.swing.model.component.JPanelInfo in project windowbuilder by eclipse.
the class LazyTest method test_convert_children.
public void test_convert_children() throws Exception {
ContainerInfo testPanel = parseContainer("class Test extends JPanel {", " public Test() {", " setLayout(null);", " JPanel panel = new JPanel();", " panel.setBounds(42, 40, 270, 160);", " add(panel);", " JTextField textField = new JTextField();", " panel.add(textField);", " textField.setColumns(10);", " JButton button = new JButton('New button');", " panel.add(button);", " }", "}");
JPanelInfo panel = testPanel.getChildren(JPanelInfo.class).get(0);
assertThat(panel.getChildren(ComponentInfo.class).size()).isEqualTo(2);
//
assertThat(LazyVariableSupportUtils.canConvert(panel)).isTrue();
LazyVariableSupportUtils.convert(panel);
// check
assertEditor("class Test extends JPanel {", " private JPanel panel;", " public Test() {", " setLayout(null);", " add(getPanel());", " }", " private JPanel getPanel() {", " if (panel == null) {", " panel = new JPanel();", " panel.setBounds(42, 40, 270, 160);", " JTextField textField = new JTextField();", " panel.add(textField);", " textField.setColumns(10);", " JButton button = new JButton('New button');", " panel.add(button);", " }", " return panel;", " }", "}");
}
use of org.eclipse.wb.internal.swing.model.component.JPanelInfo in project windowbuilder by eclipse.
the class LoadResourcesTest method test_CREATE.
/**
* Tests that <code>ResourceMap.injectComponents(Component)</code> is terminate statement for
* children.
*/
public void test_CREATE() throws Exception {
m_waitForAutoBuild = true;
JPanelInfo panel = parseJavaInfo("import org.jdesktop.application.*;", "public class Test extends JPanel {", " public Test() {", " {", " JLabel label = new JLabel();", " add(label);", " }", " Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);", " }", "}");
refresh();
//
{
ComponentInfo newButton = createComponent("javax.swing.JButton");
FlowLayoutInfo layout = (FlowLayoutInfo) panel.getLayout();
layout.add(newButton, null);
}
assertEditor("import org.jdesktop.application.*;", "public class Test extends JPanel {", " public Test() {", " {", " JLabel label = new JLabel();", " add(label);", " }", " {", " JButton button = new JButton('New button');", " add(button);", " }", " Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);", " }", "}");
}
use of org.eclipse.wb.internal.swing.model.component.JPanelInfo in project windowbuilder by eclipse.
the class WrapperInfoTest method test_MOVE_noControl.
public void test_MOVE_noControl() throws Exception {
configureWrapperContents();
ContainerInfo container = parseContainer("public class Test extends JPanel {", " public Test() {", " TestWrapper wrapper = new TestWrapper(this);", " {", " JPanel panel = new JPanel();", " add(panel);", " }", " }", "}");
// wrapper
ContainerInfo wrappedComponent = container.getChildren(ContainerInfo.class).get(0);
WrapperMethodInfo wrapper = wrappedComponent.getChildren(WrapperMethodInfo.class).get(0);
// another panel
JPanelInfo panel = container.getChildren(JPanelInfo.class).get(0);
// move
JavaInfoUtils.move(wrapper, null, panel, null);
// check editor
assertEditor("public class Test extends JPanel {", " public Test() {", " {", " JPanel panel = new JPanel();", " add(panel);", " TestWrapper wrapper = new TestWrapper(panel);", " }", " }", "}");
}
use of org.eclipse.wb.internal.swing.model.component.JPanelInfo in project windowbuilder by eclipse.
the class WrapperInfoTest method test_MOVE_withControl.
public void test_MOVE_withControl() throws Exception {
configureWrapperContents();
ContainerInfo container = parseContainer("public class Test extends JPanel {", " public Test() {", " TestWrapper wrapper = new TestWrapper(this);", " JButton button = wrapper.getControl();", " {", " JPanel panel = new JPanel();", " add(panel);", " }", " }", "}");
// wrapper
ContainerInfo wrappedComponent = container.getChildren(ContainerInfo.class).get(0);
WrapperMethodInfo wrapper = wrappedComponent.getChildren(WrapperMethodInfo.class).get(0);
// another panel
JPanelInfo panel = container.getChildren(JPanelInfo.class).get(0);
// move
JavaInfoUtils.move(wrapper, null, panel, null);
// check editor
assertEditor("public class Test extends JPanel {", " public Test() {", " {", " JPanel panel = new JPanel();", " add(panel);", " TestWrapper wrapper = new TestWrapper(panel);", " JButton button = wrapper.getControl();", " }", " }", "}");
}
Aggregations