|
Re: Using different view-sets (perspectives) [message #1233470 is a reply to message #1228925] |
Sun, 19 January 2014 18:53 |
|
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 #1245115 is a reply to message #1228925] |
Thu, 13 February 2014 10:09 |
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03462 seconds