use of org.apache.pivot.wtk.ActivityIndicator in project pivot by apache.
the class ActivityIndicatorSkin method install.
@Override
public void install(Component component) {
super.install(component);
ActivityIndicator activityIndicator = (ActivityIndicator) component;
activityIndicator.getActivityIndicatorListeners().add(this);
}
use of org.apache.pivot.wtk.ActivityIndicator 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;
}
}
}));
}
use of org.apache.pivot.wtk.ActivityIndicator in project pivot by apache.
the class TerraActivityIndicatorSkin method paint.
@Override
public void paint(Graphics2D graphics) {
ActivityIndicator activityIndicator = (ActivityIndicator) getComponent();
int width = getWidth();
int height = getHeight();
if (backgroundColor != null) {
graphics.setColor(backgroundColor);
graphics.fillRect(0, 0, width, height);
}
if (activityIndicator.isActive()) {
GraphicsUtilities.setAntialiasingOn(graphics);
// Translate/scale to fit
if (width > height) {
graphics.translate((width - height) / 2, 0);
float scale = height / 128f;
graphics.scale(scale, scale);
} else {
graphics.translate(0, (height - width) / 2);
float scale = width / 128f;
graphics.scale(scale, scale);
}
graphics.translate(64, 64);
graphics.rotate((2 * Math.PI) / 360 * angle);
final double increment = (2 * Math.PI) / 360 * 30;
for (int i = 0; i < 12; i++) {
graphics.setColor(colors[i]);
graphics.fillRoundRect(24, -4, 32, 8, 8, 8);
graphics.rotate(increment);
}
}
}
Aggregations