Autopsy  4.6.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AbstractFXCellFactory.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2015 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.timeline.ui;
20 
21 import java.util.function.Supplier;
22 import javafx.scene.control.IndexedCell;
23 import javafx.scene.control.ListCell;
24 import javafx.scene.control.TableCell;
25 import javafx.scene.control.TableColumn;
26 import javafx.scene.control.TreeTableCell;
27 import javafx.scene.control.TreeTableColumn;
28 
36 public abstract class AbstractFXCellFactory<X, Y> {
37 
38  public TreeTableCell< X, Y> forTreeTable(TreeTableColumn< X, Y> column) {
39  return new AbstractTreeTableCell();
40  }
41 
42  public TableCell<X, Y> forTable(TableColumn<X, Y> column) {
43  return new AbstractTableCell();
44  }
45 
46  public ListCell< Y> forList() {
47  return new AbstractListCell();
48  }
49 
50  protected abstract void configureCell(IndexedCell<? extends Y> cell, Y item, boolean empty, Supplier<X> supplier);
51 
52  private class AbstractTableCell extends TableCell<X, Y> {
53 
54  @Override
55  @SuppressWarnings({"unchecked"}) //we know it will be X but there is a flaw in getTableRow return type
56  protected void updateItem(Y item, boolean empty) {
57  super.updateItem(item, empty);
58  configureCell(this, item, empty, (() -> (X) this.getTableRow().getItem()));
59  }
60  }
61 
62  private class AbstractTreeTableCell extends TreeTableCell<X, Y> {
63 
64  @Override
65  protected void updateItem(Y item, boolean empty) {
66  super.updateItem(item, empty);
67  configureCell(this, item, empty, (() -> this.getTreeTableRow().getItem()));
68  }
69  }
70 
71  private class AbstractListCell extends ListCell< Y> {
72 
73  @Override
74  @SuppressWarnings("unchecked") //for a list X should always equal Y
75  protected void updateItem(Y item, boolean empty) {
76  super.updateItem(item, empty);
77  configureCell(this, item, empty, () -> (X) this.getItem());
78  }
79  }
80 }
TableCell< X, Y > forTable(TableColumn< X, Y > column)
abstract void configureCell(IndexedCell<?extends Y > cell, Y item, boolean empty, Supplier< X > supplier)
TreeTableCell< X, Y > forTreeTable(TreeTableColumn< X, Y > column)

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.