Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javafx.scene.control;
import com.sun.javafx.scene.control.skin.NestedTableColumnHeader;
import com.sun.javafx.scene.control.skin.TableColumnHeader;
import com.sun.javafx.scene.control.skin.TableHeaderRow;
import com.sun.javafx.scene.control.skin.TableViewSkin;
import com.sun.javafx.scene.control.skin.TableViewSkinBase;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.css.CssMetaData;
import javafx.css.Styleable;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.event.EventTarget;
import javafx.event.EventType;
import javafx.scene.Node;
import javafx.util.Callback;
import javafx.collections.WeakListChangeListener;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ObservableValue;
import javafx.beans.value.WritableValue;
/**
* A {@link TableView} is made up of a number of TableColumn instances. Each
* TableColumn in a table is responsible for displaying (and editing) the contents
* of that column. As well as being responsible for displaying and editing data
* for a single column, a TableColumn also contains the necessary properties to:
*
*
Be resized (using {@link #minWidthProperty() minWidth}/{@link #prefWidthProperty() prefWidth}/{@link #maxWidthProperty() maxWidth}
* and {@link #widthProperty() width} properties)
*
Have its {@link #visibleProperty() visibility} toggled
*
Display {@link #textProperty() header text}
*
Display any {@link #getColumns() nested columns} it may contain
*
Have a {@link #contextMenuProperty() context menu} when the user
* right-clicks the column header area
*
Have the contents of the table be sorted (using
* {@link #comparatorProperty() comparator}, {@link #sortable sortable} and
* {@link #sortTypeProperty() sortType})
*
*
*
* When creating a TableColumn instance, perhaps the two most important properties
* to set are the column {@link #textProperty() text} (what to show in the column
* header area), and the column {@link #cellValueFactory cell value factory}
* (which is used to populate individual cells in the column). This can be
* achieved using some variation on the following code:
*
*
* {@code
* ObservableList data = ...
* TableView tableView = new TableView(data);
*
* TableColumn firstNameCol = new TableColumn("First Name");
* firstNameCol.setCellValueFactory(new Callback, ObservableValue>() {
* public ObservableValue call(CellDataFeatures p) {
* // p.getValue() returns the Person instance for a particular TableView row
* return p.getValue().firstNameProperty();
* }
* });
* }
* tableView.getColumns().add(firstNameCol);}
*
* This approach assumes that the object returned from p.getValue()
* has a JavaFX {@link ObservableValue} that can simply be returned. The benefit of this
* is that the TableView will internally create bindings to ensure that,
* should the returned {@link ObservableValue} change, the cell contents will be
* automatically refreshed.
*
*
In situations where a TableColumn must interact with classes created before
* JavaFX, or that generally do not wish to use JavaFX apis for properties, it is
* possible to wrap the returned value in a {@link ReadOnlyObjectWrapper} instance. For
* example:
*
*
*
* It is hoped that over time there will be convenience cell value factories
* developed and made available to developers. As of the JavaFX 2.0 release,
* there is one such convenience class: {@link PropertyValueFactory}. This class
* removes the need to write the code above, instead relying on reflection to
* look up a given property from a String. Refer to the
* PropertyValueFactory class documentation for more information
* on how to use this with a TableColumn.
*
* Finally, for more detail on how to use TableColumn, there is further documentation in
* the {@link TableView} class documentation.
*
* @param The type of the TableView generic type (i.e. S == TableView<S>)
* @param The type of the content in all cells in this TableColumn.
* @see TableView
* @see TableCell
* @see TablePosition
* @since JavaFX 2.0
*/
public class TableColumn extends TableColumnBase implements EventTarget {
/***************************************************************************
* *
* Static properties and methods *
* *
**************************************************************************/
/**
* Parent event for any TableColumn edit event.
*/
@SuppressWarnings("unchecked")
public static EventType> editAnyEvent() {
return (EventType>) EDIT_ANY_EVENT;
}
private static final EventType> EDIT_ANY_EVENT =
new EventType(Event.ANY, "TABLE_COLUMN_EDIT");
/**
* Indicates that the user has performed some interaction to start an edit
* event, or alternatively the {@link TableView#edit(int, javafx.scene.control.TableColumn)}
* method has been called.
*/
@SuppressWarnings("unchecked")
public static EventType> editStartEvent() {
return (EventType>) EDIT_START_EVENT;
}
private static final EventType> EDIT_START_EVENT =
new EventType(editAnyEvent(), "EDIT_START");
/**
* Indicates that the editing has been canceled, meaning that no change should
* be made to the backing data source.
*/
@SuppressWarnings("unchecked")
public static EventType> editCancelEvent() {
return (EventType>) EDIT_CANCEL_EVENT;
}
private static final EventType> EDIT_CANCEL_EVENT =
new EventType(editAnyEvent(), "EDIT_CANCEL");
/**
* Indicates that the editing has been committed by the user, meaning that
* a change should be made to the backing data source to reflect the new
* data.
*/
@SuppressWarnings("unchecked")
public static EventType> editCommitEvent() {
return (EventType>) EDIT_COMMIT_EVENT;
}
private static final EventType> EDIT_COMMIT_EVENT =
new EventType(editAnyEvent(), "EDIT_COMMIT");
/**
* If no cellFactory is specified on a TableColumn instance, then this one
* will be used by default. At present it simply renders the TableCell item
* property within the {@link TableCell#graphicProperty() graphic} property
* if the {@link Cell#item item} is a Node, or it simply calls
* toString() if it is not null, setting the resulting string
* inside the {@link Cell#textProperty() text} property.
*/
public static final Callback, TableCell,?>> DEFAULT_CELL_FACTORY =
new Callback, TableCell,?>>() {
@Override public TableCell,?> call(TableColumn,?> param) {
return new TableCell