Version 5 (modified by deni, 16 years ago) (diff) |
---|
Analysis
(Give as much as possible of the needed information for designing and implementing the task in the following sections.)
Overview
One of Sophie best features is the possibility to create links that open URLs in users' default browser. In order to create competitive application we also should provide this functionality.
Task requirements
- The user must be able to open URLs in his default browser.
- This functionality must be included as a link action in links inside text and in frame links.
- Although it is not very appropriate, it is acceptable that it is available in page links, too.
- Creating such links could be done like this:
- The user selects text -> Link halo appears
- The user clicks on the link halo -> The link HUD appears
- The user chooses trigger from the dropdown menu -> Trigger is created
- The user chooses open url for action -> Field where the user can write the address appears. (It must look like just like when the action is go to page..., but instead of a dropdown menu a writable field should appear)
- The user enters URL in the field -> The creation of the link is complete
- (optional) It would be nice if on mouse hover a tooltip with the URL is displayed as tooltip.
- (optional) Some basic URL validation
Task result
Result of this task must be code.
Implementation idea
- see the implementation of frame showing actions;
- make sure the new actions are persisted appropriately;
- opening a URL in a browser is already implemented in OldAboutDialog ; move it in a util class in org.sophie2.base.commons package and use it
Related
TEXT_LINK_MANIPULATION_R0
GROUP_LINKS_R0
How to demo
- Insert text frame
- Write some text in it
- Create link
- Open in preview mode or in reader and click on the link
Design
- Model and view:
- add a new package org.sophie2.main.func.links.actions.external for classes related to external links
- add a new class OpenUrlAction extending LinkAction in org.sophie2.main.func.links.actions.external
- it should be immutable (as all LinkActions)
- it should have a private final String field for the url address that should be opened
- add a provider for "Open URL..." actions - OpenUrlActionProvider
- add a configuration panel for the "Open URL..." action - OpenUrlConfigurationPanel
- it should extend BaseSwingVisualElement and implement ActionConfigurationPanel
- inner static class UrlField extending BoundTextField
- protected Prop<UrlField> child() - autoproperty that maintains the URL text field
- public Prop<JPanel> swingComponent() - just adds the URL field
- add a persister for "Open URL..." actions - OpenUrlActionPersister
- register all new classes in LinksModule
- Logic:
- add a new class OpenBrowserUtil in org.sophie2.base.commons.util package and move the public static void openURL(String url) method from OldAboutDialog there
- add a new class ExternalActionsLogic that processes external link actions
- add a new operation ON_SET_URL in ConfigurationPanelsLogic that is evoked when the user submits data from the OpenUrlConfigurationPanel.
- Source code: [8000]
Implementation
(Describe and link the implementation results here (from the wiki or the repository).)
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)