Search in sources :

Example 11 with GridPane

use of org.apache.pivot.wtk.GridPane in project pivot by apache.

the class GridPaneSkin method getColumnAt.

@Override
public int getColumnAt(int x) {
    GridPane gridPane = (GridPane) getComponent();
    int columnCount = gridPane.getColumnCount();
    int columnIndex = -1;
    for (int j = 0, columnX = padding.left; columnX <= x && j < columnCount; j++) {
        if (x < columnX + cellWidth) {
            columnIndex = j;
            break;
        }
        columnX += cellWidth + horizontalSpacing;
    }
    return columnIndex;
}
Also used : GridPane(org.apache.pivot.wtk.GridPane)

Example 12 with GridPane

use of org.apache.pivot.wtk.GridPane in project pivot by apache.

the class GridPaneSkin method getPreferredWidth.

@Override
public int getPreferredWidth(int height) {
    GridPane gridPane = (GridPane) getComponent();
    GridPane.RowSequence rows = gridPane.getRows();
    int columnCount = gridPane.getColumnCount();
    int rowCount = rows.getLength();
    Metadata metadata = new Metadata();
    int cellHeightLocal = getCellHeight(height, metadata);
    int preferredCellWidth = 0;
    for (int i = 0; i < rowCount; i++) {
        GridPane.Row row = rows.get(i);
        for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) {
            Component component = row.get(j);
            if (component != null && component.isVisible()) {
                preferredCellWidth = Math.max(preferredCellWidth, component.getPreferredWidth(cellHeightLocal));
            }
        }
    }
    // The preferred width of the grid pane is the sum of the column
    // widths, plus padding and spacing
    int preferredWidth = (metadata.visibleColumnCount * preferredCellWidth) + padding.getWidth();
    if (metadata.visibleColumnCount > 1) {
        preferredWidth += (metadata.visibleColumnCount - 1) * horizontalSpacing;
    }
    return preferredWidth;
}
Also used : GridPane(org.apache.pivot.wtk.GridPane) Component(org.apache.pivot.wtk.Component)

Example 13 with GridPane

use of org.apache.pivot.wtk.GridPane in project pivot by apache.

the class TerraVFSBrowserSkin method refreshFileList.

private void refreshFileList() {
    // Cancel any outstanding task
    if (refreshFileListTask != null) {
        refreshFileListTask.abort();
        if (indicator != null) {
            indicator.setActive(false);
            fileStackPane.remove(fileStackPane.getLength() - 1, 1);
        }
    }
    if (indicator == null) {
        indicator = new ActivityIndicator();
        activityGrid = new GridPane(5);
        GridPane.Row row1 = new GridPane.Row(activityGrid);
        GridPane.Row row2 = new GridPane.Row(activityGrid);
        GridPane.Row row3 = new GridPane.Row(activityGrid);
        for (int i = 0; i < 5; i++) {
            row1.add(new GridPane.Filler());
            if (i == 2) {
                row2.add(indicator);
            } else {
                row2.add(new GridPane.Filler());
            }
            row3.add(new GridPane.Filler());
        }
    }
    fileStackPane.add(activityGrid);
    indicator.setActive(true);
    fileTableView.setTableData(new ArrayList<FileObject>());
    String text = searchTextInput.getText().trim();
    Filter<FileObject> disabledFileFilter = hideDisabledFiles ? ((VFSBrowser) getComponent()).getDisabledFileFilter() : null;
    Filter<FileObject> includeFileFilter = text.length() != 0 ? new IncludeFileFilter(text) : null;
    TableView.SortDictionary sort = fileTableView.getSort();
    final FileComparator fileComparator;
    if (sort.isEmpty()) {
        fileComparator = null;
    } else {
        Dictionary.Pair<String, SortDirection> pair = fileTableView.getSort().get(0);
        fileComparator = getFileComparator(pair.key, pair.value);
    }
    refreshFileListTask = new RefreshFileListTask(includeFileFilter, disabledFileFilter, fileComparator);
    refreshFileListTask.execute(new TaskAdapter<>(new TaskListener<ArrayList<FileObject>>() {

        @Override
        public void taskExecuted(Task<ArrayList<FileObject>> task) {
            if (task == refreshFileListTask) {
                indicator.setActive(false);
                fileStackPane.remove(fileStackPane.getLength() - 1, 1);
                ArrayList<FileObject> fileList = task.getResult();
                fileTableView.setTableData(fileList);
                updateSelectedFiles((VFSBrowser) getComponent());
                refreshFileListTask = null;
            }
        }

        @Override
        public void executeFailed(Task<ArrayList<FileObject>> task) {
            if (task == refreshFileListTask) {
                indicator.setActive(false);
                fileStackPane.remove(fileStackPane.getLength() - 1, 1);
                refreshFileListTask = null;
            }
        }
    }));
}
Also used : Dictionary(org.apache.pivot.collections.Dictionary) Task(org.apache.pivot.util.concurrent.Task) GridPane(org.apache.pivot.wtk.GridPane) ActivityIndicator(org.apache.pivot.wtk.ActivityIndicator) Point(org.apache.pivot.wtk.Point) SortDirection(org.apache.pivot.wtk.SortDirection) TaskListener(org.apache.pivot.util.concurrent.TaskListener) FileObject(org.apache.commons.vfs2.FileObject) TableView(org.apache.pivot.wtk.TableView)

Aggregations

GridPane (org.apache.pivot.wtk.GridPane)13 Component (org.apache.pivot.wtk.Component)6 Bounds (org.apache.pivot.wtk.Bounds)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 FileObject (org.apache.commons.vfs2.FileObject)1 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)1 Dictionary (org.apache.pivot.collections.Dictionary)1 Task (org.apache.pivot.util.concurrent.Task)1 TaskExecutionException (org.apache.pivot.util.concurrent.TaskExecutionException)1 TaskListener (org.apache.pivot.util.concurrent.TaskListener)1 ActivityIndicator (org.apache.pivot.wtk.ActivityIndicator)1 CardPane (org.apache.pivot.wtk.CardPane)1 Dimensions (org.apache.pivot.wtk.Dimensions)1 Row (org.apache.pivot.wtk.GridPane.Row)1 Point (org.apache.pivot.wtk.Point)1 PushButton (org.apache.pivot.wtk.PushButton)1 SortDirection (org.apache.pivot.wtk.SortDirection)1 TableView (org.apache.pivot.wtk.TableView)1