Top Description Inners Fields Constructors Methods
com.calendarfx.view

public Class SearchResultView

extends CalendarFXControl
Class Inheritance
Imports
com.calendarfx.model.Calendar, .CalendarSource, .Entry, impl.com.calendarfx.view.SearchResultViewSkin, javafx.beans.property.ObjectProperty, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.collections.FXCollections, .MapChangeListener, .ObservableList, javafx.concurrent.Service, .Task, javafx.scene.control.Skin, java.time.ZoneId, java.util.ArrayList, .Collections, .List

A view used for searching entries in the calendars and for displaying the results. Search Result View To perform a search the application simply needs to change the value of the text property of this view. The easiest way to do this is to bind the property to the text property of a textfield.
See Also
Calendar#findEntries(String), Entry#matches(String)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final ObservableList<CalendarSource>
private static final String
private final ObservableList<Entry<?>>
private final SearchResultView.SearchService
private final StringProperty
private static final String
private final ReadOnlyObjectWrapper<Entry<?>>
private final ObjectProperty<ZoneId>

Constructor Summary

AccessConstructor and Description
public
SearchResultView()

Constructs a new view.

Method Summary

Modifier and TypeMethod and Description
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final ObservableList<CalendarSource>

Returns:

the calendar sources
getCalendarSources
()

The list of calendar sources where the view will perform the search.

public final ObservableList<Entry<?>>

Returns:

the search results
getSearchResults
()

The list containing the search results.

public final String

Returns:

the search text
getSearchText
()

Returns the value of searchTextProperty().

public final Entry<?>

Returns:

the selected entry / search result
getSelectedEntry
()

Returns the value of selectedEntryProperty().

public final ZoneId

Returns:

the time zone
getZoneId
()

Returns the value of zoneIdProperty().

public final StringProperty

Returns:

the search term
searchTextProperty
()

The text used to perform the search in the calendars.

public final ReadOnlyObjectProperty<Entry<?>>

Returns:

the selected result
selectedEntryProperty
()

Stores the currently selected entry / search result.

public final void
setSearchText(String
the search text
text
)

Sets the value of searchTextProperty().

public final void
setZoneId(ZoneId
the time zone
zoneId
)

Sets the value of zoneIdProperty().

private void
public final ObjectProperty<ZoneId>

Returns:

the time zone
zoneIdProperty
()

Provides the current time zone.

Inherited from com.calendarfx.view.CalendarFXControl:
getPropertySheetItemsgetUserAgentStylesheet

Field Detail

calendarSourcesback to summary
private final ObservableList<CalendarSource> calendarSources
DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS
searchResultsback to summary
private final ObservableList<Entry<?>> searchResults
searchServiceback to summary
private final SearchResultView.SearchService searchService
searchTextback to summary
private final StringProperty searchText
SELECTED_ENTRYback to summary
private static final String SELECTED_ENTRY
selectedEntryback to summary
private final ReadOnlyObjectWrapper<Entry<?>> selectedEntry
zoneIdback to summary
private final ObjectProperty<ZoneId> zoneId

Constructor Detail

SearchResultViewback to summary
public SearchResultView()

Constructs a new view.

Method Detail

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Returns:Skin<?>

new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.

Annotations
@Override
getCalendarSourcesback to summary
public final ObservableList<CalendarSource> getCalendarSources()

The list of calendar sources where the view will perform the search.

Returns:ObservableList<CalendarSource>

the calendar sources

getSearchResultsback to summary
public final ObservableList<Entry<?>> getSearchResults()

The list containing the search results.

Returns:ObservableList<Entry<?>>

the search results

getSearchTextback to summary
public final String getSearchText()

Returns the value of searchTextProperty().

Returns:String

the search text

getSelectedEntryback to summary
public final Entry<?> getSelectedEntry()

Returns the value of selectedEntryProperty().

Returns:Entry<?>

the selected entry / search result

getZoneIdback to summary
public final ZoneId getZoneId()

Returns the value of zoneIdProperty().

Returns:ZoneId

the time zone

searchTextPropertyback to summary
public final StringProperty searchTextProperty()

The text used to perform the search in the calendars.

Returns:StringProperty

the search term

See Also
Calendar#findEntries(String), Entry#matches(String)
selectedEntryPropertyback to summary
public final ReadOnlyObjectProperty<Entry<?>> selectedEntryProperty()

Stores the currently selected entry / search result.

Returns:ReadOnlyObjectProperty<Entry<?>>

the selected result

setSearchTextback to summary
public final void setSearchText(String text)

Sets the value of searchTextProperty().

Parameters
text:String

the search text

setZoneIdback to summary
public final void setZoneId(ZoneId zoneId)

Sets the value of zoneIdProperty().

Parameters
zoneId:ZoneId

the time zone

updateSearchResultsback to summary
private void updateSearchResults()
zoneIdPropertyback to summary
public final ObjectProperty<ZoneId> zoneIdProperty()

Provides the current time zone. The zone is required for searches as the view will invoke Calendar#findEntries(String) where the time zone is a required parameter.

Returns:ObjectProperty<ZoneId>

the time zone

com.calendarfx.view back to summary

private Class SearchResultView.SearchService

extends Service<List<Entry<?>>>
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Task<List<Entry<?>>>
createTask()

Implements abstract javafx.concurrent.Service.createTask.

Invoked after the Service is started on the JavaFX Application Thread.

Inherited from javafx.concurrent.Service:
addEventFilteraddEventHandlerbuildEventDispatchChaincancelcancelledexceptionPropertyexecuteTaskexecutorPropertyfailedfireEventgetExceptiongetExecutorgetMessagegetOnCancelledgetOnFailedgetOnReadygetOnRunninggetOnScheduledgetOnSucceededgetProgressgetStategetTitlegetTotalWorkgetValuegetWorkDoneisRunningmessagePropertyonCancelledPropertyonFailedPropertyonReadyPropertyonRunningPropertyonScheduledPropertyonSucceededPropertyprogressPropertyreadyremoveEventFilterremoveEventHandlerresetrestartrunningrunningPropertyscheduledsetEventHandlersetExecutorsetOnCancelledsetOnFailedsetOnReadysetOnRunningsetOnScheduledsetOnSucceededstartstatePropertysucceededtitlePropertytotalWorkPropertyvaluePropertyworkDoneProperty

Constructor Detail

SearchServiceback to summary
public SearchService()

Method Detail

createTaskback to summary
protected Task<List<Entry<?>>> createTask()

Implements abstract javafx.concurrent.Service.createTask.

Doc from javafx.concurrent.Service.createTask.

Invoked after the Service is started on the JavaFX Application Thread. Implementations should save off any state into final variables prior to creating the Task, since accessing properties defined on the Service within the background thread code of the Task will result in exceptions. For example:


    protected Task createTask() {
        final String url = myService.getUrl();
        return new Task<String>() {
            protected String call() {
                URL u = new URL("http://www.oracle.com");
                BufferedReader in = new BufferedReader(
                        new InputStreamReader(u.openStream()));
                String result = in.readLine();
                in.close();
                return result;
            }
        }
    }

If the Task is a pre-defined class (as opposed to being an anonymous class), and if it followed the recommended best-practice, then there is no need to save off state prior to constructing the Task since its state is completely provided in its constructor.

protected Task createTask() {
        // This is safe because getUrl is called on the FX Application
        // Thread and the FirstLineReaderTasks stores it as an
        // immutable property
        return new FirstLineReaderTask(myService.getUrl());
    }
Returns:Task<List<Entry<?>>>

the Task to execute

Annotations
@Override
com.calendarfx.view back to summary

pack-priv Class SearchResultView.SearchService.SearchTask

extends Task<List<Entry<?>>>
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

Constructor Detail

SearchTaskback to summary
pack-priv SearchTask()

Method Detail

callback to summary
protected List<Entry<?>> call() throws Exception

Implements abstract javafx.concurrent.Task.call.

Doc from javafx.concurrent.Task.call.

Invoked when the Task is executed, the call method must be overridden and implemented by subclasses. The call method actually performs the background thread logic. Only the updateProgress, updateMessage, updateValue and updateTitle methods of Task may be called from code within this method. Any other interaction with the Task from the background thread will result in runtime exceptions.

Returns:List<Entry<?>>

The result of the background work, if any.

Annotations
@Override
Exceptions
Exception:
an unhandled exception which occurred during the background operation