Search in sources :

Example 1 with IDesignPageSite

use of org.eclipse.wb.core.editor.IDesignPageSite in project windowbuilder by eclipse.

the class InstanceObjectPropertyEditor method openClass.

/**
 * If there is class, open it, else create new anonymous class and open.
 */
private void openClass(Property property) throws Exception {
    GenericProperty genericProperty = (GenericProperty) property;
    Expression expression = genericProperty.getExpression();
    if (expression != null) {
        IDesignPageSite site = IDesignPageSite.Helper.getSite(genericProperty.getJavaInfo());
        if (site != null) {
            site.openSourcePosition(expression.getStartPosition());
        }
    } else {
        // generate new class
        generateNewClass(genericProperty);
        openClass(property);
    }
}
Also used : IDesignPageSite(org.eclipse.wb.core.editor.IDesignPageSite) Expression(org.eclipse.jdt.core.dom.Expression) GenericProperty(org.eclipse.wb.internal.core.model.property.GenericProperty)

Example 2 with IDesignPageSite

use of org.eclipse.wb.core.editor.IDesignPageSite in project windowbuilder by eclipse.

the class JavaPropertiesToolBarContributor method addGotoDefinitionAction.

private void addGotoDefinitionAction(IToolBarManager manager, List<ObjectInfo> objects) {
    if (objects.size() == 1 && objects.get(0) instanceof JavaInfo) {
        final JavaInfo javaInfo = (JavaInfo) objects.get(0);
        IAction gotoDefinitionAction = new Action() {

            @Override
            public void run() {
                int position = javaInfo.getCreationSupport().getNode().getStartPosition();
                IDesignPageSite site = IDesignPageSite.Helper.getSite(javaInfo);
                site.openSourcePosition(position);
            }
        };
        gotoDefinitionAction.setImageDescriptor(DesignerPlugin.getImageDescriptor("structure/goto_definition.gif"));
        gotoDefinitionAction.setToolTipText(Messages.ComponentsPropertiesPage_goDefinition);
        manager.appendToGroup(GROUP_EDIT, gotoDefinitionAction);
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IDesignPageSite(org.eclipse.wb.core.editor.IDesignPageSite) IAction(org.eclipse.jface.action.IAction) JavaInfo(org.eclipse.wb.core.model.JavaInfo)

Example 3 with IDesignPageSite

use of org.eclipse.wb.core.editor.IDesignPageSite in project windowbuilder by eclipse.

the class OpenEditorLayoutEditPolicy method performDoubleClick.

// //////////////////////////////////////////////////////////////////////////
// 
// DoubleClickLayoutEditPolicy
// 
// //////////////////////////////////////////////////////////////////////////
@Override
protected void performDoubleClick() {
    IDesignPageSite site = IDesignPageSite.Helper.getSite(m_javaInfo);
    int position = m_javaInfo.getCreationSupport().getNode().getStartPosition();
    site.openSourcePosition(position);
}
Also used : IDesignPageSite(org.eclipse.wb.core.editor.IDesignPageSite)

Example 4 with IDesignPageSite

use of org.eclipse.wb.core.editor.IDesignPageSite in project windowbuilder by eclipse.

the class DatabindingsProvider method gotoDefinition.

@Override
public void gotoDefinition(IBindingInfo ibinding) {
    BindingInfo binding = (BindingInfo) ibinding;
    int position = binding.getDefinitionOffset();
    if (position != -1) {
        IDesignPageSite site = IDesignPageSite.Helper.getSite(m_xmlObjectRoot);
        site.openSourcePosition(position);
    }
}
Also used : IDesignPageSite(org.eclipse.wb.core.editor.IDesignPageSite) BindingInfo(org.eclipse.wb.internal.rcp.databinding.xwt.model.BindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) AbstractBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo)

Example 5 with IDesignPageSite

use of org.eclipse.wb.core.editor.IDesignPageSite in project windowbuilder by eclipse.

the class EventsPropertyTest method DISABLE_test_openStubListenerMethod_valid.

// //////////////////////////////////////////////////////////////////////////
// 
// openStubMethod - by listener and method names
// 
// //////////////////////////////////////////////////////////////////////////
/**
 * Test for {@link EventsProperty#openStubMethod(String, String)}. It should create and open
 * listener.<br>
 * In this case such listener/method combination exists.
 */
public void DISABLE_test_openStubListenerMethod_valid() throws Exception {
    ContainerInfo panel = parseContainer("// filler filler filler", "public class Test extends JPanel {", "  public Test() {", "  }", "}");
    // set mock for DesignPageSite
    IDesignPageSite pageSite;
    {
        pageSite = EasyMock.createStrictMock(IDesignPageSite.class);
        pageSite.openSourcePosition(org.easymock.EasyMock.anyInt());
        EasyMock.replay(pageSite);
        // do set
        DesignPageSite.Helper.setSite(panel, pageSite);
    }
    // add key pressed listener
    EventsProperty eventsProperty = (EventsProperty) panel.getPropertyByTitle("Events");
    eventsProperty.openStubMethod("key/pressed");
    waitEventLoop(0);
    // test results
    EasyMock.verify(pageSite);
    assertEditor("// filler filler filler", "public class Test extends JPanel {", "  public Test() {", "    addKeyListener(new KeyAdapter() {", "      @Override", "      public void keyPressed(KeyEvent e) {", "      }", "    });", "  }", "}");
}
Also used : IDesignPageSite(org.eclipse.wb.core.editor.IDesignPageSite) ContainerInfo(org.eclipse.wb.internal.swing.model.component.ContainerInfo) EventsProperty(org.eclipse.wb.internal.core.model.property.event.EventsProperty)

Aggregations

IDesignPageSite (org.eclipse.wb.core.editor.IDesignPageSite)21 EventsProperty (org.eclipse.wb.internal.core.model.property.event.EventsProperty)5 ContainerInfo (org.eclipse.wb.internal.swing.model.component.ContainerInfo)5 Capture (org.easymock.Capture)4 GenericProperty (org.eclipse.wb.internal.core.model.property.GenericProperty)3 Property (org.eclipse.wb.internal.core.model.property.Property)3 IMocksControl (org.easymock.IMocksControl)2 Expression (org.eclipse.jdt.core.dom.Expression)2 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)2 Action (org.eclipse.jface.action.Action)2 IAction (org.eclipse.jface.action.IAction)2 JavaInfo (org.eclipse.wb.core.model.JavaInfo)2 IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)2 XmlObjectInfo (org.eclipse.wb.internal.core.xml.model.XmlObjectInfo)2 AbstractBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo)2 ComponentInfo (org.eclipse.wb.internal.swing.model.component.ComponentInfo)2 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)2 ASTNode (org.eclipse.jdt.core.dom.ASTNode)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 StackLayout (org.eclipse.swt.custom.StackLayout)1