Ticket #2252 (closed feature: obsolete)

Opened 10 years ago

Last modified 9 years ago

resource-chooser -- Create a resource chooser to replace file chooser somewhere

Reported by: deyan Owned by: pap
Priority: major Milestone: X3
Component: uncategorized Version: 2.0
Keywords: Cc:
Category: unknown Effort:
Importance: 80 Ticket_group:
Estimated Number of Hours: 0 Add Hours to Ticket: 0
Billable?: yes Total Hours: 0
Analysis_owners: deyan Design_owners: meddle
Imp._owners: meddle, pap Test_owners:
Analysis_reviewers: meddle Changelog:
Design_reviewers: pap Imp._reviewers: meddle, todor
Test_reviewers: Analysis_score: 4
Design_score: 3 Imp._score: 4.5
Test_score: 0

Description (last modified by deyan) (diff)

Create a resource chooser

  • The resource chooser should be a dropdown
  • The resource chooser should list all of the resources of a kind (or some kinds)
  • The resource kinds should be selectable by developers. Resource chooser should allow different kinds of resources to be listed in the dropdown.
  • At the bottom of the list there should be a <Browse...> item preceeded by a separator that should open a file dialog
    • If only one resource kind is chosen, the dialog should be for this resource kind
    • Else the dialog should be for all files.
  • Put the resource chooser in
    • Book Properties dialog - to choose background audio (Audio file dialog)
    • Frame/page image background (Image file dialog)


resource.png (4.8 KB) - added by deyan 10 years ago.

Change History

Changed 10 years ago by deyan

comment:1 Changed 10 years ago by deyan

  • Owner set to deyan
  • Status changed from new to s1a_analysis_started
  • Description modified (diff)

comment:2 Changed 10 years ago by deyan

  • Status changed from s1a_analysis_started to s1b_analysis_finished

comment:3 Changed 10 years ago by deyan

  • Description modified (diff)

comment:4 Changed 10 years ago by meddle

  • Status changed from s1b_analysis_finished to s1c_analysis_ok
  • Analysis_reviewers set to meddle
  • Analysis_score changed from 0 to 4

Taking it

comment:5 Changed 10 years ago by meddle

  • Design_owners set to meddle
  • Owner changed from deyan to meddle
  • Status changed from s1c_analysis_ok to s2a_design_started

comment:6 Changed 10 years ago by meddle

  • Status changed from s2a_design_started to s2b_design_finished

Design part:

  • First there is new extender of BoundComboBox called ResourceChooser in the org.sophie2.main.func.resources, package org.sophie2.main.func.resources.view.
    • It is skinned by default to have no validation icon and is not editable.
    • The control can import resources in a given 'parent resource' so there is an abstract method getParentResource() that provides it.
    • There is another abstract method getSelectedResource, which provides the currently selected resource, for example it can provide the background audio resource selected in the model for the BookPropertiesDialog.
    • The control is customizable has protected List<String> getFilters() method that returns a list of ResourceR4#Kinds or null all the children resources should be provided. Empty list means all the resources too. Default value : null.
    • There is a method protected boolean hasBrowseItem() that determines if there is a 'browse' item in the combo. By default it is true.
    • The 'browse' item and the separator from the analysis are implemented like a constant ResourceH and there is a special implementation of ListCellRenderer that takes them in mind and draws them beautifully. See the code for details, add suggestions for the look :)
    • The protected ComboState<ResourceH> computeModelData() is implemented taking in mind three things:
      • The list of filtered children resources.
      • The selected resource. (see the third point)
      • Special 'updater' property which meaning I'll explain in the sections with the problems that I had.
    • The protected BoundValidation validate(ComboInput<ResourceH> inputData) method by default for this control returns SUCCESS.
    • The protected void submitData(ComboInput<ResourceH> input) meyhod is overriden in the following way:
      • If the slected item is the browser item a special 'BROWSE' event is thrown that is handled from the ResourceChooserLogic
      • If the selected item is the separator don't do anything :)
      • IF the selected item is normal item, call the method from the super class.
      • At the time of the design there is logic that fixes the double submit problem for this control only, but deni's fix will remove the need of it and I'll remove it.
  • The are two EventIds :
    • BROWSE -> two arguments :
      • A list with the resource filters.
      • The parent resource.
    • BROWSE_CANCELED -> no arguments
  • There are a special logic too ResourceChooserLogic in the same module, package org.sophie2.main.func.resources.logic.
    • ON_BROWSE_RESOURCES -> handles pressing the 'Browse' item of the chooser.
      • Uses the ResourceImportLogic.importResource method to raise a file dialog, the import logic now is in this method that is public and is used by the ResourceIMportLogic itself. It returns a list of the resource refs of the imported resources. Multy slection and FileFilter can be provided by this method, in this case single selection is used and a special FileFilter constructed by the filters parameter. If the list is null/empty there are no imported resources (cancel, only bad files choosed). If the list is empty/null the BROWSE_CANCELED event is dispatched (with fireLater, see bellow in the probles list), else the submit event of the bound controls is dispatched with the newly imported resource (fireLater is used again).
      • Uses a special updateFromModel() method of the chooser to change the 'Browse' item from the view to he selected old resource from the model.
  • Demo : ResourceChooserDemo shows pretty much everything... Try it.
  • Problems:
    • The view was not updated when new resource was imported... The problem was that the control was synchronizing, so if we use fireLater to submit the selected newly imported resource, it works.
    • The view was not returned to the old resource form 'browse' when the file dialog was canceled... It's normal, the computeModelData depends of the list of resources and the selected one, and none of these is changed.
    • Added a special 'updater' property to the chooser that the method depends of.
    • It is boolean and it's value is reversed from the updateFromModel() method. So the view is updated :)
    • This method is called form the ON_BROWSE_CANCELED handler as mentioned. The event again is fired later because of the synchronization.
    • The bound combo submits two times, so the file dialog is shown two times... Deni's fix from #2235 fix that. I had ugly fix that is present in the current code and I mentioned it above.

comment:7 Changed 10 years ago by deyan

  • Importance set to 80

comment:8 Changed 10 years ago by pap

  • Status changed from s2b_design_finished to s2c_design_ok
  • Design_score changed from 0 to 3
  • Design_reviewers set to pap
  • I am not sure that the BROWSE event needs these parameters. They may be taken from the ResourceChooser.
  • Also you may use invokeLater by yourself instead of the BROWSE_CANCELED event. :)
  • The setUp and tearDown methods are not correctly written. The call to tge super implementation should be the first in setUp and last in tearDown
  • I cannot import a resource through the browse button and the click Browse.. again. I need to select something different first.
  • Also the Browse... item stays selected when I choose a file in the dialog that is not appropriate.
  • Also there are quite a lot abstract methods that should be overriden :-/
  • Otherwise nice :)
  • Not to forget that the design tells nothing about the uses of the ResourceChooser in sophie.

comment:9 Changed 10 years ago by pap

  • Owner changed from meddle to pap
  • Status changed from s2c_design_ok to s3a_implementation_started
  • Imp._owners set to meddle, pap
  • Taking for integrating the ResourceChooser in the BookPropertiesDialog

comment:10 Changed 10 years ago by pap

  • Status changed from s3a_implementation_started to s3b_implementation_finished
  • Implementation notes :
    • Make the swing dialog of the BookPropertiesDialog extend BaseCustomModalDialog.
    • Replace the existing controls with their bound versions.
    • Add a Logic enum with the appropriate code
    • Make the present chooser for background audio SimpleBgAudioCombo
    • Add a new control in main.func.resources module AdvancedBgAudioChooser - it should be with a sortkey that is less than that of SimpleBgAudioCombo - this way when registered it will replace the simple control
    • Add a role in order to distinguish audio choosers
    • In order to implement the None item in the AdvancedBgAudioChooser add a special empty item to the ResourceChooser.
    • Size, position, titles and tooltips of controls may be made better.
    • Source code in http://sophie2.org/trac/browser/branches/private/meddle/resource_chooser or svn://sophie2.org/sophie2/branches/private/meddle/resource_chooser

comment:11 Changed 10 years ago by meddle

  • Status changed from s3b_implementation_finished to s3c_implementation_ok
  • Imp._score changed from 0 to 4.5
  • Imp._reviewers set to meddle, todor

Merged to the trunk at [8562].

In some places bad spacing, and meddle had to fix his bug with importing :)

About the BookPropertiesDialog -> 4.5p at last it is real dialog.

comment:12 Changed 9 years ago by meddle

  • Status changed from s3c_implementation_ok to closed
  • Resolution set to obsolete

Closing all the tickets before M Y1

Note: See TracTickets for help on using tickets.