Difference: DpHipePreferences (1 vs. 36)

Revision 362014-03-05 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"
<-- ANALYTICS CODE - DO NOT EDIT -->
<-- Google Analytics script BEGIN -->
<-- Google Analytics script END -->
Line: 163 to 163
  Each preference is handled by a PreferenceHandler, which provides the means of updating the GUI with the existing preference value and to get any change that the user introduces, and more.
Changed:
<
<
You may consider to extend AbstractPreferenceHandler instead of implementing the interface directly.
>
>
You may consider to extend AbstractPreferenceHandler or use one of its basic extensions, instead of implementing the interface directly.
 

  • makeContent:
Line: 181 to 181
  private static final long serialVersionUID = 1L;
Changed:
<
<
private JTextField _fieldA; // text field associated to preference keyA private JIntegerField _fieldB; // text field associated to preference keyB
>
>
private JTextField fieldA; // text field associated to preference keyA private IntegerField fieldB; // text field associated to preference keyB
  @Override protected void registerHandlers() {

// Preference keyA with type String and default value "text"

Changed:
<
<
registerHandler("keyA", new AbstractPreferenceHandler<String>("text") { public String getValue() { return _fieldA.getText(); } public void setValue(String value) { _fieldA.setText(value); } });
>
>
registerHandler("keyA", new StringPreferenceHandler("text", fieldA));
  // Preference keyB with type Integer and default value 3
Changed:
<
<
registerHandler("keyB", new AbstractPreferenceHandler<Integer>(3) { public Integer getValue() { return _fieldB.getValue(); } public void setValue(Integer value) { _fieldB.setValue(value); } });
>
>
registerHandler("keyB", new IntegerPreferenceHandler(3, fieldB));
  }

@Override protected void makeContent() { setLayout(new GridLayout(2, 2, 5, 5)); // just for the example; you may consider to use a better layout

Changed:
<
<
_fieldA = new JTextField();
>
>
fieldA = new JTextField();
  add(new JLabel("Key A:"));
Changed:
<
<
add(_fieldA); _fieldB = new JIntegerField();
>
>
add(fieldA); fieldB = new IntegerField();
  add(new JLabel("Key B:"));
Changed:
<
<
add(_fieldB);
>
>
add(fieldB);
  } }
Line: 366 to 360
 
String def = Configuration.getProperty("hcss.some.property", "text"); // default value

Changed:
<
<
registerHandler("keyA", new AbstractPreferenceHandler<String>(def) { public String getValue() { return _fieldA.getText(); } public void setValue(String value) { _fieldA.setText(value); } });
>
>
registerHandler("keyA", new StringPreferenceHandler(def, fieldA));
 
Line: 387 to 378
 

Changed:
<
<
registerHandler("keyA", new AbstractPreferenceHandler<String>("text", "hcss.some.property") { public String getValue() { return _fieldA.getText(); } public void setValue(String value) { _fieldA.setText(value); } });
>
>
registerHandler("keyA", new StringPreferenceHandler("text", fieldA, "hcss.some.property"));
 

Revision 352014-02-19 - AlvarGarcia

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"
<-- ANALYTICS CODE - DO NOT EDIT -->
<-- Google Analytics script BEGIN -->
<-- Google Analytics script END -->
Line: 258 to 258
  The framework creates here an empty panel for you, with a message saying that preferences can be found in children categories.
Deleted:
<
<
Note:

Preferences are just released. The still unused fields in the Extension when registering may be used in the future, although for the time being the only foreseen (probable) change is to provide an icon to each category.

 

Read preferences

Line: 340 to 337
 

Listen to changes in preferences

Changed:
<
<
Suppose the user opens an editor component you have developed, then open the preferences dialog, changes some preference related to the presentation of your editor, and press OK.
>
>
Suppose the user opens an editor component you have developed, then opens the preferences dialog, changes some preference related to the presentation of your editor, and presses OK.
  The user would expect that these changes would be applied to the opened editor, not only to editors opened from that moment on.
Line: 362 to 359
 The more common situation may be that you want to migrate some existing property to the new preferences mechanism.

This means that the preference should take the value of the associated property while the user doesn't override it.

Changed:
<
<
After overriden, the saved preference is used and the property is not taken into account.
>
>
After being overridden, the saved preference is used and the property will not be taken into account.
  If this is the case, the only thing you need to do is to add few code when registering the handler of the associated preference. Something like this:

Revision 342014-02-19 - AlvarGarcia

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"
<-- ANALYTICS CODE - DO NOT EDIT -->
<-- Google Analytics script BEGIN -->
<-- Google Analytics script END -->
Line: 15 to 15
 

Revision 332012-10-19 - DavideRizzo

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"
Added:
>
>
<-- ANALYTICS CODE - DO NOT EDIT -->
<-- Google Analytics script BEGIN -->
<-- Google Analytics script END -->

<-- END OF ANALYTICS CODE -->
 
<-- 
  • Set TOPICTITLE = HIPE preferences
-->
Line: 446 to 449
 
<-- END OF COMMENT BOX CODE -->

Changed:
<
<
META FILEATTACHMENT attachment="PreferencesDialog.png" attr="h" comment="Preferences dialog" date="1341497979" name="PreferencesDialog.png" path="PreferencesDialog.png" size="28795" stream="PreferencesDialog.png" user="Main.DavideRizzo" version="2"
>
>
META FILEATTACHMENT attr="h" autoattached="1" comment="Script for Google Analytics" date="1350657737" name="GoogleAnalytics.txt" path="GoogleAnalytics.txt" size="549" user="Main.DavideRizzo" version="1"
META FILEATTACHMENT attr="h" autoattached="1" comment="Preferences dialog" date="1341497979" name="PreferencesDialog.png" path="PreferencesDialog.png" size="28795" user="Main.DavideRizzo" version="2"
 
META TOPICMOVED by="DavideRizzo" date="1272528106" from="Hcss.DpHipePreferences" to="Public.DpHipePreferences"

Revision 322012-07-11 - DavideRizzo

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"
Line: 128 to 130
  From one side, if you want to introduce a new category, you need to write a preferences panel, and then register it.
Changed:
<
<
Afterwards, client code would want to read those preferences, which is done through the UserPreferences class.
>
>
Afterwards, client code would want to read those preferences, which is done through the UserPreferences class.
 Probably it would also want to listen to modifications, so the user doesn't need to restart HIPE for his changes being applied.

Optionally, you may want to link a preference to an existing property that you just want to migrate to the preferences framework.

Line: 262 to 264
  The next step is to use the preferences in client code.
Changed:
<
<
This is very easy and just implies using UserPreferences where you would use Configuration.
>
>
This is very easy and just implies using UserPreferences where you would use Configuration.
  Example:

Revision 312012-07-05 - DavideRizzo

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

Revision 302012-05-14 - DavideRizzo

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"
Added:
>
>

<-- COMMENT BOX CODE - DO NOT EDIT -->
blog comments powered by Disqus
<-- END OF COMMENT BOX CODE -->

 
META FILEATTACHMENT attachment="PreferencesDialog.png" attr="" comment="Preferences dialog" date="1237814878" name="PreferencesDialog.png" path="PreferencesDialog.png" size="26809" stream="PreferencesDialog.png" user="Main.JaimeSaiz" version="1"
META TOPICMOVED by="DavideRizzo" date="1272528106" from="Hcss.DpHipePreferences" to="Public.DpHipePreferences"

Revision 292012-02-24 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

Revision 282012-01-05 - JeanMichelGlorian

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

Revision 272011-11-08 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

Revision 262011-07-19 - JavierDiaz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

Revision 252011-06-24 - DavideRizzo

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"
Changed:
<
<

HIPE Preferences

>
>
<-- 
  • Set TOPICTITLE = HIPE preferences
-->

PDF Version Portrait Landscape

Help Did you spot something wrong or missing on this page? If you have an account on this TWiki, you can fix it yourself by editing the page. If you don't have an account, you can send a message to the Editorial Board to tell us about it. Thank you in advance!

HIPE preferences

 

Revision 242010-12-07 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Revision 232010-11-19 - RikHuygen

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 21 to 21
 
  • Introduce preferences and develop a GUI panel for them in your module.
  • Make a bridge between preferences and existing properties.
  • Use preferences in client code.
Changed:
<
<
  • Listen to changes in preferences to adapt your functionality dinamically.
>
>
  • Listen to changes in preferences to adapt your functionality dynamically.
 

Revision 222010-08-30 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 98 to 98
 Install & Update To be defined Automatic Update Update server, frequency of update checks, notification Data Access
Changed:
<
<
HSA URL, temporary retrieval directory (possible SCR), delay/retry times
>
>
Storages & Pools Management of existing product storages and pools
  Local Store Absolute path, cache configuration Import FITS Requested metadata for importing images, spectra, cubes and tables Import ASCII Ascii table formats handling with AsciiTableReader, defaults
Added:
>
>
HSA URL, temporary retrieval directory (possible SCR), delay/retry times
 

Revision 212010-08-30 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 331 to 331
  The user would expect that these changes would be applied to the opened editor, not only to editors opened from that moment on.
Changed:
<
<
To solve this situation, your editor should listen to preference changes by implementing PreferenceListener and registering with UserPreferences.addListener.

Warning, important Note: The PreferenceListener is called in a non-GUI thread. If you need to call some GUI code in your listener, put your code into a Runnable and use one of the following methods:

  • SwingUtilities.invokeAndWait(Runnable r)
  • SwingUtilities.invokeLater(Runnable r)
  • SiteUtil.execAndWait(Runnable r)
  • SiteUtil.execLater(Runnable r)
>
>
To solve this situation, your editor should listen to preference changes by implementing PreferenceListener and registering with UserPreferences.addListener.
 

Link to properties

Revision 202010-06-10 - DavideRizzo

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 47 to 47
  Therefore we don't consider system preferences, which are used by developers for introducing some flexibility in the functionality they provide, but users shouldn't be concerned of. The existing properties mechanism may still suffice for them.
Changed:
<
<
The preferences framework is decoupled from the old configuration properties, so that it could be developed while not being dependent on the property roadmap.
>
>
<-- The preferences framework is decoupled from the old configuration properties, so that it could be developed while not being dependent on the property roadmap.-->
  Nevertheless, preferences can reuse properties and even be just a wrapper for them if needed, as explained later. This way, the break is not dramatic, although replacing properties by preferences is encouraged.
Line: 71 to 71
  Preferences lie under a particular category. They are identified by a name called key, which must be unique within that category, but can be reused in other categories.
Deleted:
<
<
-- BrunoMerin - 25 Aug 2009
 The following set of HIPE preferences (mostly based on Eclipse/IDLDE's preferences) has been agreed upon as a starter to populate the HIPE preferences window:


Line: 413 to 410
 
Deleted:
<
<
-- JaimeSaiz - 23 Mar 2009
 
<--  
-->

Revision 192010-05-17 - DavideRizzo

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 415 to 415
  -- JaimeSaiz - 23 Mar 2009
Added:
>
>
<--  
-->
 
META FILEATTACHMENT attachment="PreferencesDialog.png" attr="" comment="Preferences dialog" date="1237814878" name="PreferencesDialog.png" path="PreferencesDialog.png" size="26809" stream="PreferencesDialog.png" user="Main.JaimeSaiz" version="1"
META TOPICMOVED by="DavideRizzo" date="1272528106" from="Hcss.DpHipePreferences" to="Public.DpHipePreferences"

Revision 182010-04-29 - DavideRizzo

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Revision 172010-01-26 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 83 to 83
  Fonts Already in 1.1: general font sizes Window Already in 1.1: size window and position at startup Logs & History Size of log, auto-save time
Changed:
<
<
Key shortcuts Possible SCR
>
>
Key Shortcuts Possible SCR
  File Associations File associations for automatic importing of .py, .fits, .txt Perspectives list of perspectives, save/load customized perspectives (possible SCR) Startup & Shutdown Memory @ start-up, save session dir/name, tips&tricks (possible SCR) Editors & Viewers
Changed:
<
<
Text editor 80 columns, line number on/off, rectangle cut&paste option Jython editor 80 columns, line number on/off, colors, tabs, completion mode PlotXY viewer memory default size, default symbol, line, axes, multiplots Image viewer Initial zoom, lookup table, cut values, orientation, task properties Spectrum explorer Initial zoom, linestyle (histogram), zoom-mode, task properties Cube analysis tool Initial zoom, lookup table, cut values, orientation, linestyle, task properties
>
>
Text Editor 80 columns, line number on/off, rectangle cut&paste option Jython Editor 80 columns, line number on/off, colors, tabs, completion mode PlotXY Viewer memory default size, default symbol, line, axes, multiplots Image Viewer Initial zoom, lookup table, cut values, orientation, task properties Spectrum Explorer Initial zoom, linestyle (histogram), zoom-mode, task properties Cube Analysis Tool Initial zoom, lookup table, cut values, orientation, linestyle, task properties
 Help To be provided by Marco Soldati Jython Code Automatic import statements, working and output directories Interpreter Error handling, line by line, error codes Install & Update To be defined
Changed:
<
<
Automatic update Update server, frequency of update checks, notification
>
>
Automatic Update Update server, frequency of update checks, notification
 Data Access HSA URL, temporary retrieval directory (possible SCR), delay/retry times Local Store Absolute path, cache configuration

Revision 162009-12-02 - DavideRizzo

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 26 to 26
 
Added:
>
>
 

Introduction

Preferences in HIPE respond to the request of customizing the tool in a user friendly way, from the User Vision document :

Line: 407 to 409
  The reason is that Configuration provides methods for getting the property as boolean, int, double or String, but doesn't provide methods for the other types.
Added:
>
>
 

-- JaimeSaiz - 23 Mar 2009

Revision 152009-11-12 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 379 to 379
 
In this case, your panel should be written in a module that can depend on ia_gui_kernel; however, herschel.versant.store (in this example) can only use Configuration for reading the preferences values.
Changed:
<
<
The solution is to provide the PreferenceHandler the name of the associated property, so the framework would override the property in user.props in addition to being saved as a preference.
>
>
The solution is to provide the PreferenceHandler the name of the associated property, so the framework would override the property in hipe.props.
  As simple as:

Revision 142009-10-23 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 294 to 294
 

Deleted:
<
<
// The event class class SplitLocationChangeEvent extends SiteEvent { private final int _location;

SplitLocationChangeEvent(Object source, int location) { super(source); _location = location; }

int getLocation() { return _location; } }

 // The notifier class public class SplittedEditor extends AbstractEditorComponent<SomeSelection> {

// Suppose we detect changes in the split pane here

Changed:
<
<
private void splitMoved(int newLocation) { SiteEvent event = new SplitLocationChangeEvent(this, newLocation);
>
>
private void splitMoved(float newLocation) { SiteEvent event = new PreferenceChangeRequestEvent(this, category, key, newLocation);
  getPart().getEventHandler().trigger(event); } }
Line: 324 to 312
  // Fill the panel ... // and register to split changes SiteEventHandler eventHandler = SiteUtil.getSite().getEventHandler();
Changed:
<
<
eventHandler.addEventListener(SplitLocationChangeEvent.class, this);
>
>
eventHandler.addEventListener(PreferenceChangeRequestEvent.class, this);
  }

@Override public void selectionChanged(SiteEvent event) {

Changed:
<
<
int location = ((SplitLocationChangeEvent)event).getLocation();
>
>
Float location = (Float)((PreferenceChangeRequestEvent)event).getNewValue();
  setValue("splitLocation", location); // update the value in the panel saveChanges(); // and save it }

Revision 132009-10-01 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 346 to 346
  To solve this situation, your editor should listen to preference changes by implementing PreferenceListener and registering with UserPreferences.addListener.
Added:
>
>
Warning, important Note: The PreferenceListener is called in a non-GUI thread. If you need to call some GUI code in your listener, put your code into a Runnable and use one of the following methods:

  • SwingUtilities.invokeAndWait(Runnable r)
  • SwingUtilities.invokeLater(Runnable r)
  • SiteUtil.execAndWait(Runnable r)
  • SiteUtil.execLater(Runnable r)
 

Link to properties

Now, what happens with plain old properties?

Revision 122009-09-03 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Revision 112009-08-29 - BrunoMerin

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 81 to 81
  Fonts Already in 1.1: general font sizes Window Already in 1.1: size window and position at startup Logs & History Size of log, auto-save time
Added:
>
>
Key shortcuts Possible SCR File Associations File associations for automatic importing of .py, .fits, .txt Perspectives list of perspectives, save/load customized perspectives (possible SCR) Startup & Shutdown Memory @ start-up, save session dir/name, tips&tricks (possible SCR)
  Editors & Viewers Text editor 80 columns, line number on/off, rectangle cut&paste option Jython editor 80 columns, line number on/off, colors, tabs, completion mode
Line: 88 to 92
  Image viewer Initial zoom, lookup table, cut values, orientation, task properties Spectrum explorer Initial zoom, linestyle (histogram), zoom-mode, task properties Cube analysis tool Initial zoom, lookup table, cut values, orientation, linestyle, task properties
Deleted:
<
<
File Associations File associations for automatic importing of .py, .fits, .txt Key shortcuts Possible SCR Perspectives list of perspectives, save/load customized perspectives (possible SCR) Startup & Shutdown Memory @ start-up, save session dir/name, tips&tricks (possible SCR)
 Help To be provided by Marco Soldati Jython Code Automatic import statements, working and output directories

Revision 102009-08-29 - BrunoMerin

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 84 to 84
  Editors & Viewers Text editor 80 columns, line number on/off, rectangle cut&paste option Jython editor 80 columns, line number on/off, colors, tabs, completion mode
Added:
>
>
PlotXY viewer memory default size, default symbol, line, axes, multiplots
  Image viewer Initial zoom, lookup table, cut values, orientation, task properties Spectrum explorer Initial zoom, linestyle (histogram), zoom-mode, task properties Cube analysis tool Initial zoom, lookup table, cut values, orientation, linestyle, task properties

Revision 92009-08-27 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 76 to 76
 
General                      

Changed:
<
<
General/Appearance General/Appearance/Console Already in 1.1: buffer size and prompt extras: redline and buffer for history recovery (i.e. 0 brings up command 0 on history) General/Appearance/Fonts Already in 1.1: general font sizes General/Appearance/Window Already in 1.1: size window and position at startup General/Appearance/Logs & History size of log, auto-save time General/Editors & Viewers/ General/Editors & Viewers/File Associations File associations for automatic importing of .py, .fits, .txt General/Editors & Viewers/Text editor 80 columns, line number on/off, rectangle cut&paste option General/Editors & Viewers/Jython editor 80 columns, line number on/off, colors, tabs, completion mode General/Editors & Viewers/File Associations File associations for automatic importing of .py, .fits, .txt General/Editors & Viewers/Key shortcuts Possible SCR General/Editors & Viewers/Image viewer Initial zoom, lookup table, cut values, orientation, task properties General/Editors & Viewers/Spectrum explorer Initial zoom, linestyle (histogram), zoom-mode, task properties General/Editors & Viewers/Cube analysis tool Initial zoom, lookup table, cut values, orientation, linestyle, task properties General/Perspectives list of perspectives, save/load customized perspectives (possible SCR) General/Startup & Shutdown Memory @ start-up, save session dir/name, tips&tricks (possible SCR) Help/ To be provided by Marco Soldati
>
>
Appearance Console Already in 1.1: buffer size and prompt. Extras: readline and buffer for history recovery (i.e. 0 brings up command 0 on history) Fonts Already in 1.1: general font sizes Window Already in 1.1: size window and position at startup Logs & History Size of log, auto-save time Editors & Viewers Text editor 80 columns, line number on/off, rectangle cut&paste option Jython editor 80 columns, line number on/off, colors, tabs, completion mode Image viewer Initial zoom, lookup table, cut values, orientation, task properties Spectrum explorer Initial zoom, linestyle (histogram), zoom-mode, task properties Cube analysis tool Initial zoom, lookup table, cut values, orientation, linestyle, task properties File Associations File associations for automatic importing of .py, .fits, .txt Key shortcuts Possible SCR Perspectives list of perspectives, save/load customized perspectives (possible SCR) Startup & Shutdown Memory @ start-up, save session dir/name, tips&tricks (possible SCR) Help To be provided by Marco Soldati
 Jython
Changed:
<
<
Jython/Code automatic import statements, working and output directories Jython/Interpreter Error handling, line by line, error codes
>
>
Code Automatic import statements, working and output directories Interpreter Error handling, line by line, error codes
 Install & Update To be defined
Changed:
<
<
Install & Update/Automatic update Update server, frequency of update checks, notification
>
>
Automatic update Update server, frequency of update checks, notification
 Data Access
Changed:
<
<
Data Access/HSA URL, temporary retrieval directory (possible SCR), delay/retry times Data Access/Local Store absolute path, cache configuration Data Access/Import FITS requested metadata for importing images, spectra, cubes and tables Data Access/Import ASCII ascii table formats handling with AsciiTableReader, defaults
>
>
HSA URL, temporary retrieval directory (possible SCR), delay/retry times Local Store Absolute path, cache configuration Import FITS Requested metadata for importing images, spectra, cubes and tables Import ASCII Ascii table formats handling with AsciiTableReader, defaults
 

Revision 82009-08-25 - BrunoMerin

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 82 to 82
 General/Appearance/Fonts Already in 1.1: general font sizes General/Appearance/Window Already in 1.1: size window and position at startup General/Appearance/Logs & History size of log, auto-save time
Deleted:
<
<
General/Content Types File associations for automatic importing of .py, .fits, .txt
 General/Editors & Viewers/ General/Editors & Viewers/File Associations File associations for automatic importing of .py, .fits, .txt General/Editors & Viewers/Text editor 80 columns, line number on/off, rectangle cut&paste option

Revision 72009-08-25 - BrunoMerin

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 69 to 69
  Preferences lie under a particular category. They are identified by a name called key, which must be unique within that category, but can be reused in other categories.
Added:
>
>
-- BrunoMerin - 25 Aug 2009

The following set of HIPE preferences (mostly based on Eclipse/IDLDE's preferences) has been agreed upon as a starter to populate the HIPE preferences window:

General                      
General/Appearance           
General/Appearance/Console   Already in 1.1: buffer size and prompt
  extras: redline and buffer for history recovery (i.e. !0 brings up command 0 on history)
General/Appearance/Fonts    Already in 1.1: general font sizes
General/Appearance/Window   Already in 1.1: size window and position at startup
General/Appearance/Logs & History   size of log, auto-save time
General/Content Types  File associations for automatic importing of .py, .fits, .txt
General/Editors & Viewers/
General/Editors & Viewers/File Associations File associations for automatic importing of .py, .fits, .txt
General/Editors & Viewers/Text editor 80 columns, line number on/off, rectangle cut&paste option
General/Editors & Viewers/Jython editor 80 columns, line number on/off, colors, tabs, completion mode
General/Editors & Viewers/File Associations File associations for automatic importing of .py, .fits, .txt
General/Editors & Viewers/Key shortcuts Possible SCR
General/Editors & Viewers/Image viewer Initial zoom, lookup table, cut values, orientation, task properties
General/Editors & Viewers/Spectrum explorer Initial zoom, linestyle (histogram), zoom-mode, task properties
General/Editors & Viewers/Cube analysis tool Initial zoom, lookup table, cut values, orientation, linestyle, task properties
General/Perspectives   list of perspectives, save/load customized perspectives (possible SCR)
General/Startup & Shutdown Memory @ start-up, save session dir/name, tips&tricks (possible SCR)
Help/ To be provided by Marco Soldati
Jython
Jython/Code automatic import statements, working and output directories
Jython/Interpreter Error handling, line by line, error codes
Install & Update To be defined
Install & Update/Automatic update Update server, frequency of update checks, notification
Data Access
Data Access/HSA URL, temporary retrieval directory (possible SCR), delay/retry times 
Data Access/Local Store absolute path, cache configuration
Data Access/Import FITS requested metadata for importing images, spectra, cubes and tables
Data Access/Import ASCII  ascii table formats handling with AsciiTableReader, defaults 
 

Preferences dialog

The explained approach leads to a preferences dialog in which the user may navigate between categories, select one of them, see and change any of its associated preferences, and accept or cancel the changes.

Revision 62009-06-24 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 294 to 294
  @Override public void selectionChanged(SiteEvent event) { int location = ((SplitLocationChangeEvent)event).getLocation();
Changed:
<
<
setValue("splitLocation", location); saveChanges();
>
>
setValue("splitLocation", location); // update the value in the panel saveChanges(); // and save it
  } }

Revision 52009-06-24 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 240 to 240
  would also be valid.
Added:
>
>

Change preferences

Preferences are supposed to be changed only by users, within the preferences dialog.
This is the reason why UserPreferences just provides methods for reading preferences, but not for changing them.

Now, it may be the case that you need to update preferences from some user action.
For instance, user presses Ctrl-+, so all font sizes must be increased.

This communication can be performed through events: the requester code triggers an event, which is listened and handled by the corresponding preferences panel.

Example:

We have an editor with a split panel, and want to detect any drag in the split separator by the user, so its new position is saved as a preference.


// The event class
class SplitLocationChangeEvent extends SiteEvent {
    private final int _location;

    SplitLocationChangeEvent(Object source, int location) {
        super(source);
        _location = location;
    }

    int getLocation() { return _location; }
}

// The notifier class
public class SplittedEditor extends AbstractEditorComponent<SomeSelection> {

    // Suppose we detect changes in the split pane here
    private void splitMoved(int newLocation) {
        SiteEvent event = new SplitLocationChangeEvent(this, newLocation);
        getPart().getEventHandler().trigger(event);
    }
}

// The preferences panel
public class SomePreferencesPanel extends PreferencesPanel implements SiteEventListener {

    @Override
    protected void makeContent() {
        // Fill the panel ...
        // and register to split changes
        SiteEventHandler eventHandler = SiteUtil.getSite().getEventHandler();
        eventHandler.addEventListener(SplitLocationChangeEvent.class, this);
    }


    @Override
    public void selectionChanged(SiteEvent event) {
	int location = ((SplitLocationChangeEvent)event).getLocation();
        setValue("splitLocation", location);
        saveChanges();
    }
}
 

Listen to changes in preferences

Suppose the user opens an editor component you have developed, then open the preferences dialog, changes some preference related to the presentation of your editor, and press OK.

Revision 42009-06-24 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 254 to 254
  There may be three different situations:
Changed:
<
<

Brand new preferences

>
>

1. Brand new preferences

  If you create new preferences that have no correspondence to existing properties, all we have seen till now should be enough for you; you don't need to worry about properties.
Changed:
<
<

Take a property as default value

>
>

2. Take a property as default value

  The more common situation may be that you want to migrate some existing property to the new preferences mechanism.
Line: 277 to 278
 
Changed:
<
<

Maintain the old property mechanism

>
>

3. Maintain the old property mechanism

  Although the previous two approaches are recommended, it may be the case that you cannot use UserPreferences in your client code, for example because your module cannot depend on ia_gui_kernel, but still want to provide a panel for the user in the preferences window.
Line: 299 to 300
 

In this case, the property would also be used as default value, if existing.

Added:
>
>
 

Allowed types for preferences

Revision 32009-03-31 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 146 to 146
  // Preference keyB with type Integer and default value 3 registerHandler("keyB", new AbstractPreferenceHandler<Integer>(3) {
Changed:
<
<
public Integer getValue() { return _fieldB.getvalue(); }
>
>
public Integer getValue() { return _fieldB.getValue(); }
  public void setValue(Integer value) { _fieldB.setValue(value); } }); }
Line: 194 to 194
 


Changed:
<
<
If you want to organize your categories under a common parent category, and don't have any preference associated to that parent category, it may even be easier. Just skip the creation of the panel and write:
>
>
You may want to organize your categories under a common parent category, but don't have any preference associated to that parent category. In this case, you don't need to create a panel for the parent category:
 
REGISTRY.register(CATEGORY, Extension(

Changed:
<
<
"Some/Category",
>
>
"Parent/Category",
  None, # empty panel None, # unused None)) # unused
Changed:
<
<
In this case, the framework creates an empty panel for you, with a message saying that preferences can be found in children categories.
>
>
The framework creates here an empty panel for you, with a message saying that preferences can be found in children categories.
  Note:
Changed:
<
<
Preferences are just released. The still unused fields in the extension may be used in the future, although for the time being the only foreseen (probable) change is to provide an icon to each category.
>
>
Preferences are just released. The still unused fields in the Extension when registering may be used in the future, although for the time being the only foreseen (probable) change is to provide an icon to each category.
 

Read preferences

Revision 22009-03-25 - JaimeSaiz

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

HIPE Preferences

Line: 255 to 255
 

Brand new preferences

Changed:
<
<
If you create new preferences that have no correspondence to existing properties, all we have seen till now should be enough for you; you don't need to worry about properties. Lucky you!
>
>
If you create new preferences that have no correspondence to existing properties, all we have seen till now should be enough for you; you don't need to worry about properties.
 

Take a property as default value

Line: 269 to 269
 
String def = Configuration.getProperty("hcss.some.property", "text"); // default value

Changed:
<
<
registerHandler("keyA", new AbstractPreferenceHandler(def) {
>
>
registerHandler("keyA", new AbstractPreferenceHandler<String>(def) {
  public String getValue() { return _fieldA.getText(); } public void setValue(String value) { _fieldA.setText(value); } });
Line: 284 to 284
 
In this case, your panel should be written in a module that can depend on ia_gui_kernel; however, herschel.versant.store (in this example) can only use Configuration for reading the preferences values.
Changed:
<
<
The solution is to provide the PreferenceHandler the name of the associated property, so the preference would override the property in user.props in addition to being saved as a preference.
>
>
The solution is to provide the PreferenceHandler the name of the associated property, so the framework would override the property in user.props in addition to being saved as a preference.
  As simple as:


Changed:
<
<
registerHandler("keyA", new AbstractPreferenceHandler("text", "hcss.some.property") {
>
>
registerHandler("keyA", new AbstractPreferenceHandler<String>("text", "hcss.some.property") {
  public String getValue() { return _fieldA.getText(); } public void setValue(String value) { _fieldA.setText(value); } });

Revision 12009-03-23 - JaimeSaiz

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="DpHipe"

HIPE Preferences

<--
   Some short-cuts  
-->

This section explains the relationship between preferences and properties in HIPE, and how you can contribute to:

  • Introduce preferences and develop a GUI panel for them in your module.
  • Make a bridge between preferences and existing properties.
  • Use preferences in client code.
  • Listen to changes in preferences to adapt your functionality dinamically.

Introduction

Preferences in HIPE respond to the request of customizing the tool in a user friendly way, from the User Vision document :

«The Main Interface (...) should provide a new pull-down menu accessible from the top bar with label “Properties” to allow user to change the configuration during the session. This should not be done with Propgen.»

That menu option is called "Preferences" instead of "Properties", since it is a more common label in GUI applications, and a standard in Mac OS X.

The preferences dialog can be accessed in three different ways:

  1. By clicking on the preferences icon in the Welcome view
  2. By pressing the menu option Edit > Preferences
  3. By pressing Alt+Enter at any moment

We talk here about user preferences, meaning those preferences affecting the session that the user may want to change in a user friendly way.

Therefore we don't consider system preferences, which are used by developers for introducing some flexibility in the functionality they provide, but users shouldn't be concerned of. The existing properties mechanism may still suffice for them.

The preferences framework is decoupled from the old configuration properties, so that it could be developed while not being dependent on the property roadmap.

Nevertheless, preferences can reuse properties and even be just a wrapper for them if needed, as explained later. This way, the break is not dramatic, although replacing properties by preferences is encouraged.

Categories

Preferences are organized in categories, which have a hierarchical structure.
Each category may have a parent category (at most one). A category with no parent is called a root category.
It is like a tree, where more than one root is allowed.

Every category is identified by a string that contains its whole path, including its ancestors. This full path must be unique.

The path of a category is similar to an absolute path in Unix, with the difference that the leading '/' is omitted. For example:

General                      A root category
General/Appearance           A child category under General
General/Appearance/Window    A child category under General/Appearance
General/Appearance/Console   Another child category under General/Appearance
Graphics                     Another root category

Preferences lie under a particular category. They are identified by a name called key, which must be unique within that category, but can be reused in other categories.

Preferences dialog

The explained approach leads to a preferences dialog in which the user may navigate between categories, select one of them, see and change any of its associated preferences, and accept or cancel the changes.

The preferences dialog then looks like this:

PreferencesDialog.png

How to contribute

Adding and using preferences has few simple steps.

From one side, if you want to introduce a new category, you need to write a preferences panel, and then register it.

Afterwards, client code would want to read those preferences, which is done through UserPreferences class.
Probably it would also want to listen to modifications, so the user doesn't need to restart HIPE for his changes being applied.

Optionally, you may want to link a preference to an existing property that you just want to migrate to the preferences framework.

Step by step:

Develop a preferences panel

When the user clicks on a category within the tree, the corresponding panel is shown at the right side of the dialog.

Creating a panel requires to extend PreferencesPanel -basically reproduced here- by implementing a couple of methods:

public abstract class PreferencesPanel extends JPanel {
    protected PreferencesPanel() {}
    protected abstract void makeContent();
    protected abstract void registerHandlers();
    protected final void registerHandler(String key, PreferenceHandler<?> handler) { ... }
}

  • registerHandlers:

In this method you call registerHandler once per preference. This is how you specify the keys belonging to the associated category.

Each preference is handled by a PreferenceHandler, which provides the means of updating the GUI with the existing preference value and to get any change that the user introduces, and more.

You may consider to extend AbstractPreferenceHandler instead of implementing the interface directly.

  • makeContent:

Here you create and add to the panel the graphical components for showing and changing the preferences associated to this category.

Example:

public class SimplePreferencesPanel extends PreferencesPanel {

    private static final long serialVersionUID = 1L;

    private JTextField    _fieldA;  // text field associated to preference keyA
    private JIntegerField _fieldB;  // text field associated to preference keyB

    @Override
    protected void registerHandlers() {

        // Preference keyA with type String and default value "text"
        registerHandler("keyA", new AbstractPreferenceHandler<String>("text") {
            public String getValue() { return _fieldA.getText(); }
            public void setValue(String value) { _fieldA.setText(value); }
        });

        // Preference keyB with type Integer and default value 3
        registerHandler("keyB", new AbstractPreferenceHandler<Integer>(3) {
            public Integer getValue() { return _fieldB.getvalue(); }
            public void setValue(Integer value) { _fieldB.setValue(value); }
        });
    }

    @Override
    protected void makeContent() {
        setLayout(new GridLayout(2, 2, 5, 5));  // just for the example; you may consider to use a better layout
        _fieldA = new JTextField();
        add(new JLabel("Key A:"));
        add(_fieldA);
        _fieldB = new JIntegerField();
        add(new JLabel("Key B:"));
        add(_fieldB);
    }
}

Register the category and the panel

If you have developed the preferences panel, you have done the hard work.

Registering the category and its associated panel is straightforward. As usual, it is done in the Extension Registry within a __init__.py file.

Example:

from herschel.ia.gui.kernel import ExtensionRegistry, Extension
from herschel.ia.gui.kernel.prefs import UserPreferences

CATEGORY = UserPreferences.CATEGORY
REGISTRY = ExtensionRegistry.getInstance()

# Preferences categories
REGISTRY.register(CATEGORY, Extension(
                  "Some/Category",
                  "herschel.some.package.SimplePreferencesPanel",
                  None,   # unused
                  None))  # unused

# Cleanup
del(ExtensionRegistry, Extension, UserPreferences, CATEGORY, REGISTRY)


If you want to organize your categories under a common parent category, and don't have any preference associated to that parent category, it may even be easier. Just skip the creation of the panel and write:

REGISTRY.register(CATEGORY, Extension(
                  "Some/Category",
                  None,   # empty panel
                  None,   # unused
                  None))  # unused

In this case, the framework creates an empty panel for you, with a message saying that preferences can be found in children categories.

Note:

Preferences are just released. The still unused fields in the extension may be used in the future, although for the time being the only foreseen (probable) change is to provide an icon to each category.

Read preferences

The next step is to use the preferences in client code.

This is very easy and just implies using UserPreferences where you would use Configuration.

Example:

The preferences defined in the previous example could be accessed like this:

String preferenceA = UserPreferences.get("Some/Category", "keyA");
int preferenceB = UserPreferences.getInt("Some/Category", "keyB");

Any preference can be read as a string, so:

String preferenceB = UserPreferences.get("Some/Category", "keyB");

would also be valid.

Listen to changes in preferences

Suppose the user opens an editor component you have developed, then open the preferences dialog, changes some preference related to the presentation of your editor, and press OK.

The user would expect that these changes would be applied to the opened editor, not only to editors opened from that moment on.

To solve this situation, your editor should listen to preference changes by implementing PreferenceListener and registering with UserPreferences.addListener.

Link to properties

Now, what happens with plain old properties?

There may be three different situations:

Brand new preferences

If you create new preferences that have no correspondence to existing properties, all we have seen till now should be enough for you; you don't need to worry about properties. Lucky you!

Take a property as default value

The more common situation may be that you want to migrate some existing property to the new preferences mechanism.

This means that the preference should take the value of the associated property while the user doesn't override it.
After overriden, the saved preference is used and the property is not taken into account.

If this is the case, the only thing you need to do is to add few code when registering the handler of the associated preference. Something like this:

String def = Configuration.getProperty("hcss.some.property", "text"); // default value
registerHandler("keyA", new AbstractPreferenceHandler(def) {
    public String getValue() { return _fieldA.getText(); }
    public void setValue(String value) { _fieldA.setText(value); }
    });

Maintain the old property mechanism

Although the previous two approaches are recommended, it may be the case that you cannot use UserPreferences in your client code, for example because your module cannot depend on ia_gui_kernel, but still want to provide a panel for the user in the preferences window.

For instance, you want to add a panel for letting the user to set the Versant server and a database name.
In this case, your panel should be written in a module that can depend on ia_gui_kernel; however, herschel.versant.store (in this example) can only use Configuration for reading the preferences values.

The solution is to provide the PreferenceHandler the name of the associated property, so the preference would override the property in user.props in addition to being saved as a preference.

As simple as:

registerHandler("keyA", new AbstractPreferenceHandler("text", "hcss.some.property") {
    public String getValue() { return _fieldA.getText(); }
    public void setValue(String value) { _fieldA.setText(value); }
    });

In this case, the property would also be used as default value, if existing.

Allowed types for preferences

As seen above, you can specify the type you want for each preference. The PreferenceHandler enforces you to provide the correct types when writing their implementations.

The valid types for preferences depend on whether their associated handler uses a property (PreferenceHandler.getProperty() returns not null) or not, that is, if you provide a property when constructing AbstractPreferenceHandler or not (see examples above).

  • If you don't provide a property to the handler, the valid types are Boolean, Integer, Long, Float, Double, String and byte[].

  • If you provide a property to the handler, the valid types are reduced to Boolean, Integer, Double and String.

The reason is that Configuration provides methods for getting the property as boolean, int, double or String, but doesn't provide methods for the other types.


-- JaimeSaiz - 23 Mar 2009

META FILEATTACHMENT attachment="PreferencesDialog.png" attr="" comment="Preferences dialog" date="1237814878" name="PreferencesDialog.png" path="PreferencesDialog.png" size="26809" stream="PreferencesDialog.png" user="Main.JaimeSaiz" version="1"
 
This site is powered by the TWiki collaboration platform Powered by Perl