Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Using different view-sets (perspectives)
Using different view-sets (perspectives) [message #1228925] Wed, 08 January 2014 11:03 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I'm familiar with the scout concept of using different outlines depending on context.
I've also managed to add additional views and/or view stacks to the existing views using the org.eclipse.ui.views extension point in an SWT client's plugin.xml file.

However, I'm not quite sure what the best way to tackle the following requirement is:

In our application we want to have to different layouts depending on what type of data we are working with. In "mode 1" we want to use a layout as shown to the left of the red bar (i.e. the classic scout layout with OutlineTree, TablePages and SearchPages). In "mode 2" we want to use a layout as shwon to the right of the red bar (i.e. no OutlineTree and three separate views).

index.php/fa/17169/0/

One approach I've been considering is to define those six views in the one default perspective that is created by the scout SDK. Basically, the three views shown on the right would overlap the three views shown on the left and when switching between the two modes, we would show/hide the corresponding views.

I know that I can show additional views by creating and starting the corresponding Form:
DetailForm detailForm = new DetailForm();
addForm(detailForm);
detailForm.startDisplay();

My question is: How do I hide/end such a form()

The other approach - of which I'm not sure if it is supported by Scout - would be to define two different perspectives in the plugin.xml file (one for mode1 and another for mode2). I could then define the three views for the first perspective and the three views for the second perspective.

Is this feasible/supported with Scout?
If yes, how would I switch between the perspectives? What would I need to take care of with regard to the currently shown forms/views before switching to the other perspective?
  • Attachment: Views.png
    (Size: 6.67KB, Downloaded 609 times)
Re: Using different view-sets (perspectives) [message #1233470 is a reply to message #1228925] Sun, 19 January 2014 18:53 Go to previous messageGo to next message
Claudio Guglielmo is currently offline Claudio GuglielmoFriend
Messages: 256
Registered: March 2010
Senior Member
Hi Urs

Both approaches should work.

Approach 1:
To hide a form just call ClientJob.getCurrentSession().getDesktop().removeForm(form);
The state of the fields won't be touched so you can reshow it any time later.
Btw: To hide the outline table form you may use desktop.setOutlineTableFormVisible, which in fact does nothing more than add / remove.

Approach 2:
Some years ago I worked in a project which used scout/swt with two perspectives. I can't remember all the details but I can tell it worked. I'll give you feedback as soon as I can check the source code.

Cheers
Claudio

[Updated on: Sun, 19 January 2014 19:58]

Report message to a moderator

Re: Using different view-sets (perspectives) [message #1233636 is a reply to message #1233470] Mon, 20 January 2014 06:54 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Hi Claudio

Thanks for your hints to approach 1, I'll have a look at this. And I'm looking forward to hearing more about approach 2 from you, so I can evaluate two alternatives.
Re: Using different view-sets (perspectives) [message #1245115 is a reply to message #1228925] Thu, 13 February 2014 10:09 Go to previous messageGo to next message
Claudio Guglielmo is currently offline Claudio GuglielmoFriend
Messages: 256
Registered: March 2010
Senior Member
Hi Urs

Meanwhile I could check the code. What you (propably) have to do:
1. When openening a form which belongs to the second perspective, open the perspective. We did this directly in the SwtEnvironment, but you could also use a custom service and call it from the model. Example (SwtEnvironment):

@Override
public void showStandaloneForm(IForm form) {
  ensurePerspectiveIsOpen(form);

  super.showStandaloneForm(form);
}

public void ensurePerspectiveIsOpen(IForm form) {
  // If the CalendarForm should be opened or activated then open the calendar-perspective first
  if (form instanceof CalendarForm) {
    IWorkbench wb = PlatformUI.getWorkbench();
    String currentPerspective = wb.getActiveWorkbenchWindow().getActivePage().getPerspective().getId();
    if (!currentPerspective.equals(CalendarPerspective.class.getName())) {
      try {
        wb.showPerspective(CalendarPerspective.class.getName(), wb.getActiveWorkbenchWindow());
      }
      catch (WorkbenchException e) {
        LOG.debug("The perspective could not automatically be switched! " + e);
      }
    }
  }
}


2. Do the same when activating a form (maybe you can ommit the instanceof check, I can't exactly remember the exact reason for this):
@Override
public void ensureStandaloneFormVisible(IForm form) {
  ensurePerspetiveIsOpen(form);
  
  //ensureVisible calls activate on the view
  //We actually would like to have bringToTop which is not supported by scout yet.
  if (!(form instanceof CalendarForm)) {
    super.ensureStandaloneFormVisible(form);
  }
}

3. Start form if the user activates the perspective
@Override
public void init(IViewSite site) throws PartInitException {
  super.init(site);

  //Make sure the form is started when the view is created.
  //This is necessary if the view is opened the first time when the user selects the perspective manually.
  startFormIfNecessary();
}


private void startFormIfNecessary() {
  ISwtEnvironment swtEnvironment = Activator.getDefault().getEnvironment();
  if (getForm() != null || swtEnvironment == null || !swtEnvironment.isInitialized()) {
    return;
  }

  swtEnvironment.invokeScoutLater(new Runnable() {

    @Override
    public void run() {
      CalendarForm form = ClientSession.get().getDesktop().findForm(CalendarForm.class);
      if (form == null) {
        try {
          form = new CalendarForm();
          form.startModifyExclusive();
        }
        catch (ProcessingException e) {
          SERVICES.getService(IExceptionHandlerService.class).handleException(e);
        }
      }

    }

  }, 0);
}


Hope it helps making your decision. Personally, I would favor approach 1 because it's the "official" scout way and will work with any ui.

Regards
Claudio
Re: Using different view-sets (perspectives) [message #1248354 is a reply to message #1245115] Mon, 17 February 2014 06:57 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Claudio, thanks for the code. I, too, think that I'll stick to approach 1.
Re: Using different view-sets (perspectives) [message #1439715 is a reply to message #1248354] Tue, 07 October 2014 12:36 Go to previous message
Beatriz SanchezFriend
Messages: 22
Registered: July 2014
Location: York
Junior Member

[Updated on: Thu, 09 October 2014 12:19]

Report message to a moderator

Previous Topic:The type cannot be resolved. It is indirectly referenced from required .class files
Next Topic:Luna: additional undesired Stop button in SWT UI
Goto Forum:
  


Current Time: Tue Apr 16 19:54:05 GMT 2024

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

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

Back to the top