Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » SWT: Opening multiple instances of a form in a view/editor
SWT: Opening multiple instances of a form in a view/editor [message #1038892] Thu, 11 April 2013 13:35 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I'm using the SWT client. I have managed to add new views to my application by:

  • adding a view definition to the extension point org.eclipse.ui.views
  • adding the view to the extension point org.eclipse.ui.perspectiveExtensions
  • creating a corresponding class which extends AbstractScoutView in org.eclipse.minicrm.ui.swt.views
  • defining a VIEW_ID in ui.swt.Activator based on that class' name
  • calling registerPart() for that view in SwtEnvironment
  • creating a form which extends AbstractForm and returns DISPLAY_HINT_VIEW in getConfiguredDisplayHint() and the VIEW_ID that was used in registerPart() in getConfiguredDisplayViewId()
  • creating an instance of that form and passing it to addForm() in Desktop.execOpened()


This works nicely, I now have a permanent view with this form in my client.

I have also managed to add editor forms to my application by following the steps outlined below

  • ScoutEditorPart already exists as does the call to registerPart() in SwtEnvironment
  • creating a form which extends AbstractForm and returns DISPLAY_HINT_VIEW in getConfiguredDisplayHint() and EDITOR_ID in getConfiguredDisplayViewId()
  • creating multiple instances of that form and passing it to addForm() in Desktop.execOpened (or somewhere else)


With this, I end up with five identical forms, showing different content. However, there are a few questions that remain:

  • when I close the last of those editors, the "editor area" remains and uses up space (unlike the view areas which yield their space when the view is closed)
  • if I create a second instance of the form with data that has been used before, a second form is opened in the editor area (unlike in eclipse, where the existing editor is brought to the top when the same file is double clicked twice). I assume this is something I will need to keep track of myself? Or is there a mechanism in Scout that supports me with this?
  • in the ui.swt\plugin.xml I can define the placement and size of the various views but I can't seem to do the same for the editor part. How do I solve this? It seems that all views are relative to org.eclipse.ui.editorss eventually. Do I just need to use the proper "relationship" and "ratio" values to have my views arranged around the editor part instead?


I'm sure more question will come up, but for the moment I'll be happy to get these answered Smile
Re: SWT: Opening multiple instances of a form in a view/editor [message #1041589 is a reply to message #1038892] Mon, 15 April 2013 09:29 Go to previous messageGo to next message
Eclipse UserFriend
To ensure an editor opens only once per input use something like:
@Override
protected void execRowAction(ITableRow row) throws ProcessingException {
  Long personId = getIdColumn().getValue(row);
  IDesktop desktop = ClientSession.get().getDesktop();
  boolean create = true;
  for (IForm f : desktop.getViewStack()) {
    if (f instanceof PersonForm) {
      if (CompareUtility.equals(((PersonForm) f).getPersonId(), personId)) {
        desktop.ensureVisible(f);
        create = false;
      }
    }
  }
  if (create) {
    PersonForm form = new PersonForm();
    form.setPersonId(personId);
    form.startModify();
  }
}


The layout of the perspective is done in the [yourapp].ui.swt.perspective.Perspective class and can be modified to get where you want. Ensure to check the clear workspace data flag in your launch configuration (launch dialog)!

/andreas
Re: SWT: Opening multiple instances of a form in a view/editor [message #1041714 is a reply to message #1038892] Mon, 15 April 2013 12:56 Go to previous messageGo to next message
Claudio Guglielmo is currently offline Claudio GuglielmoFriend
Messages: 256
Registered: March 2010
Senior Member
Although that's definitely a possibility to handle multiple views/editors, I'd rather suggest to use the exclusive mode of forms as described here: http://wiki.eclipse.org/Scout/HowTo/Open_a_Form_in_a_View

And yes, there is only one editor area and the views are positioned around it.
Re: SWT: Opening multiple instances of a form in a view/editor [message #1042225 is a reply to message #1041714] Tue, 16 April 2013 06:25 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks, I'll have a look at this.
Previous Topic:Coding Guidline: Assert static import or not
Next Topic:Scout 3.9 nightly build
Goto Forum:
  


Current Time: Sat Apr 20 00:42:13 GMT 2024

Powered by FUDForum. Page generated in 0.03057 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top