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;
}
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;
}
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;
}
}
}));
}
Aggregations