MasterDetailsBlock and DetailsPage in a ViewPart

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

MasterDetailsBlock and DetailsPage in a ViewPart

Postby Paul.Helster » Fri Apr 15, 2005 6:17 am

I am trying out SWT Designer and I want to build a ViewPart that contains a form with a Master/Details control.

I have looked at the docs, and the Form document (http://dev.eclipse.org/viewcvs/index.cg ... Forms.html) but I am still unable to figure out how to do that.

Outside SWTDesigner's environment, I was able to manually create a form in an Editor part but this is not where I want my form to be loaded ultimately.

Has anyone succeded in using forms, and more specifically a MasterDetailsBlock in a ViewPart (or in any non-editor context as a matter of fact).

Being new to SWT Designer, I tried the following:

- Created a Forms->ViewPart
- Created a Forms-> MasterDetailsBlock
- Created a Forms-> DetailsPage

but then, I am stucked attempting to glue it all together. I may be missing the big pigture of SWT Designer, but am I supposed to be able to add the MasterDetailsBlock to the ViewPart from the designer?

:?

Paul
Paul.Helster
 
Posts: 31
Joined: Fri Apr 15, 2005 6:03 am

Got it

Postby Paul.Helster » Fri Apr 15, 2005 12:11 pm

I succeded running a MasterDetailsBlock in a Shell application. I used the code from the example http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/pde-ui-home/working/EclipseForms/EclipseForms.html

I had to tweak the code a little bit to remove dependancies on the IFormPage but I eventually succeded. And also, SWT Designer does not display the view correctly. But here is the code if anyone needs to do this.

Code: Select all
package example.forms;

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.ManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.part.ViewPart;

public class TestView extends ViewPart {

  private FormToolkit toolkit;
 
  public void createPartControl(Composite parent) {
   
    toolkit = new FormToolkit(parent.getDisplay());
    Composite container = toolkit.createComposite(parent, SWT.NONE);
    container.setLayout(new FillLayout());
    toolkit.paintBordersFor(container);

    ScrolledForm form = toolkit.createScrolledForm(container);
    form.getBody().setLayout(new FillLayout());
    form.setText("MasterDetailsBlock example form");
   
    ManagedForm mform = new ManagedForm(toolkit, form) ;   
   
    ScrolledPropertiesBlock block = new ScrolledPropertiesBlock();
    block.createContent(mform);
   
    //
    createActions();
    initializeToolBar();
    initializeMenu();
  }

  private void createActions() {
  }

  private void initializeToolBar() {
    if (getViewSite() == null)
      return;
    IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
  }

  private void initializeMenu() {
    if (getViewSite() == null)
      return;
    IMenuManager manager = getViewSite().getActionBars().getMenuManager();
  }

  public void setFocus() {
  }

  public static void main(String[] args) {

    final Display display = new Display();
    final Shell shell = new Shell(display);

    shell.setSize(800, 600);

    shell.setLayout(new FillLayout());
    TestView testView = new TestView();
    testView.createPartControl(shell);

    // Some settings must be set manually when using HyperLink in
    // a non-workbench app.
    testView.toolkit.getHyperlinkGroup().setForeground(display.getSystemColor(SWT.COLOR_BLUE));
   
    shell.open();
    while (!shell.isDisposed())
      if (!display.readAndDispatch())
        display.sleep();
    display.dispose();
  } 
}
Paul.Helster
 
Posts: 31
Joined: Fri Apr 15, 2005 6:03 am

Re: MasterDetailsBlock and DetailsPage in a ViewPart

Postby Eric Clayberg » Sun Apr 17, 2005 12:54 pm

Paul.Helster wrote:I am trying out SWT Designer and I want to build a ViewPart that contains a form with a Master/Details control.

Both of those are top-level components from Designer's point of view, so you won't be able to mix them. It might help if you provided more detail on exactly what you are trying to do. Any code examples illustrating how you want the pieces to fit together would also be helpful (there aren't very many examples avaiable on the Eclipse.org site).

Paul.Helster wrote:I am stucked attempting to glue it all together. I may be missing the big pigture of SWT Designer, but am I supposed to be able to add the MasterDetailsBlock to the ViewPart from the designer?

No. We don't support doing that and I have never seen an example of that. If we had a example to work from, we might be able to support that in the future.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest