Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » How to use SnapBox
How to use SnapBox [message #1001763] Thu, 17 January 2013 10:38 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
On my "quest" to get to know as many form fields as possible I've added a SnapBox to one of my forms. However, I have not been able to find out what it would be used for or how it needs to be configured.

Can anyone shed some light on this (either with a link to some documentation that escaped me) or with a brief snippet of code?
Re: How to use SnapBox [message #1002512 is a reply to message #1001763] Fri, 18 January 2013 18:39 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 205
Registered: November 2010
Senior Member
Hi Urs

The ISnapBox is not used very often. I believe its main purpose is to provide a place for the outline selection in SWT. In Swing the Outlines are rendered as tabs in the top part of the window. This representation is dependent from the look and feel (you may have noticed that there is not representation of the top part in the Scout model). In SWT, there is no native possibility to put the outline selection buttons and the window.

What the snap box does, it creates an area where different buttons are shown. In the Scout model you would simple create a field of type SnapBox and then add buttons as inner classes. An Scout application that whishes to use this box as an outline selector has to place a snap box in the outline tree form. The outlines would then be shown as buttons. See the attached screen shot for an example.

index.php/fa/13018/0/

I have never used a SnapBox myself, so I don't know if there are other use cases. But thanks for your interest! Smile

Beat

[Updated on: Tue, 06 January 2015 15:29] by Moderator

Report message to a moderator

Re: How to use SnapBox [message #1003434 is a reply to message #1002512] Mon, 21 January 2013 08:29 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 Beat

Thanks for your answer. I've come one step closer, but there are still a few questions that remain open.

First, part of my confusion was, that apparently the SnapBox is not fully supported by the SDK, as you cannot add buttons to it through the SDK.
index.php/fa/13030/0/

Adding the buttons directly in the code sort of works, but I can't get the same display that your screenshot shows. In Swing there seems to be no implementation of the SnapBox. In SWT I only managed to get iconised buttons that show the name of the outline in the tooltip but have been unable to have the buttons show the name of the outline on them. I've looked at all the properties of the SnapBox but couldn't find anything to chenge this.
index.php/fa/13031/0/

Is there any way to adjust this?

As a followup, since this control seems to aim at changing outlines in an SWT application, I would probably want it shown in the main window, not in one of the sub forms. What would the recommended way to place it above or below the tree view on the main form?
  • Attachment: SnapSDK.png
    (Size: 4.51KB, Downloaded 1193 times)
  • Attachment: SnapOutput.png
    (Size: 2.79KB, Downloaded 1167 times)

[Updated on: Mon, 21 January 2013 08:29]

Report message to a moderator

Re: How to use SnapBox [message #1004212 is a reply to message #1003434] Tue, 22 January 2013 20:14 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 205
Registered: November 2010
Senior Member
Urs Beeli wrote on Mon, 21 January 2013 03:29
First, part of my confusion was, that apparently the SnapBox is not fully supported by the SDK, as you cannot add buttons to it through the SDK.


Yes, that seems to be missing. Please open a bug report if you need it.

Quote:

Adding the buttons directly in the code sort of works, but I can't get the same display that your screenshot shows.


My bad! Apparently there is some extended display functionality in an internal plug-in (non-open-source) that produces a view like in the screenshot, I did not notice that. The default look is indeed the one you posted. Unfortunately, it seems to me that this look cannot be altered easily (but you could write your own UI representation, of course).

Quote:
As a followup, since this control seems to aim at changing outlines in an SWT application, I would probably want it shown in the main window, not in one of the sub forms. What would the recommended way to place it above or below the tree view on the main form?


When Scout SDK generates a project for you, it creates a class called "Desktop". In this Desktop (= main window) two default forms are put:

  @Override
  protected void execOpened() throws ProcessingException {
    // outline tree
    DefaultOutlineTreeForm treeForm = new DefaultOutlineTreeForm();
    treeForm.startView();

    //outline table
    DefaultOutlineTableForm tableForm = new DefaultOutlineTableForm();
    tableForm.startView();

    if (getAvailableOutlines().length > 0) {
      setOutline(getAvailableOutlines()[0]);
    }

  }


To customize the outline tree, simply replace the DefaultOutlineTreeForm with your own implementation. The code of that class is a good start for your own class. If you look at the source code, you can see that it is a fairly normal form, with a MainBox and everything. Just add your desired fields to that MainBox.

B.
Re: How to use SnapBox [message #1004433 is a reply to message #1004212] Wed, 23 January 2013 08:17 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 Beat

Now that I know how to populate the SnapBox, I don't really need the SDK integration any more. Still, I think it would make sense to integrate this fully, so I opened a bug regardless Smile (https://bugs.eclipse.org/bugs/show_bug.cgi?id=398860)

Thanks also for clarifying about the differences in the representation of the UI.

I have - in the mean time - found this post by Andreas Hoegger about integrating the snapbox into the tree view.

As I mentioned in my post on how to switch outlines in SWT that the outline buttons in the snapbox are behaving strangely. Apparently their default display style is DISPLAY_STYLE_TOGGLE. I've added two OutlineButtons to the SnapBox for the two outlines StandardOutline and AdministrationOutlin (from the minicrm tutorial). When I click on the button for AdministrationOutline, the outline is changed. When I then click on the button for the StandardOutline for the first time, nothing happens. When I click on that button the second time, the outline changes. After that, I always have to click the OutlineButton for an outline twice in order to change the outline. I thought this might be related to them having toggle style, but even returning DISPLAY_STYLE_DEFAULT from getConfiguredDisplayStyle() does not change this behaviour.

Is there some obvious mistake I could have made that explains this?

[Updated on: Wed, 23 January 2013 08:24]

Report message to a moderator

Re: How to use SnapBox [message #1004933 is a reply to message #1004433] Thu, 24 January 2013 07:04 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 205
Registered: November 2010
Senior Member
Quote:
Apparently their default display style is DISPLAY_STYLE_TOGGLE.


Yes, but only in the UI, not in the Scout model. I think, this is to give the user a visual hint, which outline currently is selected.

Quote:
When I then click on the button for the StandardOutline for the first time, nothing happens. When I click on that button the second time, the outline changes.


It seems to me, that the currently "selected" button is not "un-selected" when another button is pressed. When you click an already selected button, the "selected" value is FALSE, and as you can see in org.eclipse.scout.rt.client.ui.desktop.outline.AbstractOutlineButton.execToggleAction(boolean), nothing happens in this case. When clicking one of the buttons, the others should be un-selected. Seems to be worth a bug report...

Quote:
I thought this might be related to them having toggle style, but even returning DISPLAY_STYLE_DEFAULT from getConfiguredDisplayStyle() does not change this behaviour.


As previously mentioned, the Scout model's "display style" is not considered for this type of buttons. The Toggle-Style is only applied in the UI (see org.eclipse.scout.rt.ui.swt.form.fields.snapbox.button.SwtScoutMinimizedButton).

Beat
Re: How to use SnapBox [message #1004940 is a reply to message #1004933] Thu, 24 January 2013 07:21 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Beat, thanks for clarifying. I solved the issue by using "normal" AbstractButtons and doing an explicit getDesktop().setOutline() on their execToggleAction().
Re: How to use SnapBox [message #1004942 is a reply to message #1004940] Thu, 24 January 2013 07:27 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
As a followup question: The SnapBox is only implemented for SWT, so ideally, I would like to modify my Desktop.execOpened method as follows:

 @Override
  protected void execOpened() throws ProcessingException {
    // outline tree
    if (SomeMagic.isUsingSWT()) {
      ExtendedOutlineTreeForm treeForm = new ExtendedOutlineTreeForm();
      treeForm.startView();
    } else {
      DefaultOutlineTreeForm treeForm = new DefaultOutlineTreeForm();
      treeForm.startView();
    }

    //outline table
    DefaultOutlineTableForm tableForm = new DefaultOutlineTableForm();
    tableForm.startView();

    if (getAvailableOutlines().length > 0) {
      setOutline(getAvailableOutlines()[0]);
    }

  }


I have not been succesful in finding something to take care of SomeMagic.isUsingSWT() but I am sure there is a way to find out which client UI is used? Can anyone give me a hint on how to do this?
Re: How to use SnapBox [message #1004952 is a reply to message #1004942] Thu, 24 January 2013 07:47 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 205
Registered: November 2010
Senior Member
Quote:
I have not been succesful in finding something to take care of SomeMagic.isUsingSWT() but I am sure there is a way to find out which client UI is used? Can anyone give me a hint on how to do this?


org.eclipse.scout.rt.shared.ui.UserAgentUtility (since Scout 3.8.0) provides various methods to find out information about the current execution environment.

Or you could simply check if the SWT plug-in is present:
Platform.getBundle("my.scout.project.ui.swt.core") != null
Re: How to use SnapBox [message #1004961 is a reply to message #1004952] Thu, 24 January 2013 08:07 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks, this works perfectly.
Previous Topic:Differences between date fields
Next Topic:extension point for custom columns
Goto Forum:
  


Current Time: Fri Apr 19 09:41:02 GMT 2024

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

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

Back to the top