Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » How to create a read only field
How to create a read only field [message #1194095] Mon, 18 November 2013 10:33 Go to next message
Erich Steiger is currently offline Erich SteigerFriend
Messages: 13
Registered: September 2013
Junior Member

Is it possible to create read only fields with scout? In SWT there is the Property SWT.READ_ONLY which changes for example the Text Fields behavier to show the text and makes it possible to do copy it into another app, but the user is not able to change it.

Example in SWT:
Text textField = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
textField.setText("This is a read only field");
Re: How to create a read only field [message #1194158 is a reply to message #1194095] Mon, 18 November 2013 11:16 Go to previous messageGo to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 309
Registered: August 2011
Senior Member
Yes, a field has an Enabled property. If false, the field is disabled for changes. You can still copy the value.
Re: How to create a read only field [message #1194232 is a reply to message #1194158] Mon, 18 November 2013 12:00 Go to previous messageGo to next message
Erich Steiger is currently offline Erich SteigerFriend
Messages: 13
Registered: September 2013
Junior Member

Ok, this is correct. But the controls do not look like Read Only Controls. SWT Read Only controls do have the text painted black, disabled controls do have painted the text gray, which is realy hard do read.
Re: How to create a read only field [message #1196227 is a reply to message #1194232] Tue, 19 November 2013 10:02 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 790
Registered: October 2011
Senior Member
The Scout Model is also a simplified view of the UI Widget. I assume that the people who designed scout didn't want to have "Editable" and "Enabled" properties in the Scout Field to keep the API simple.

I think the design choice still holds today.

For your use case, it is solved in SWT UI with the UiDecorationExtensionPoint. In the SWT plugin of your application, you can use:

   <extension
         point="org.eclipse.scout.rt.ui.swt.lookAndFeel">
      <properties
            scope="global">
         <property
               name="color.forground.disabled"
               value="FF9900">
         </property>
      </properties>
   </extension>


This will override the SWT default for disabled. With the Scout Version 3.10 there is a similar property for the background color of a disabled field in SWT (see Bug 407261)
Re: How to create a read only field [message #1200283 is a reply to message #1196227] Thu, 21 November 2013 06:55 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 341
Registered: October 2012
Location: Bern, Switzerland
Senior Member
And just to keep you from stumbling across the same rock that I hit when I first tried this: The property contains the word "forground" instead of "foreground". Even though Eclipse flagged the line with a warning when I spellt the property name "correctly" I didn't notice that this was the problem and spent about an hour wondering why setting the colour didn't work Smile
Re: How to create a read only field [message #1211008 is a reply to message #1200283] Tue, 26 November 2013 08:03 Go to previous message
Judith Gull is currently offline Judith GullFriend
Messages: 54
Registered: February 2010
Member
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=422545 for the typo correction.
Previous Topic:Access logging in database
Next Topic:Browser field error in RAP client
Goto Forum:
  


Current Time: Mon Nov 24 08:23:05 GMT 2014

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

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