Search in sources :

Example 1 with TableColumn

use of javafx.scene.control.TableColumn in project jphp by jphp-compiler.

the class UXTableColumn method __construct.

@Signature
public void __construct() {
    __wrappedObject = new TableColumn();
    setCellValueFactoryForArrays();
}
Also used : TableColumn(javafx.scene.control.TableColumn)

Example 2 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class MergedTableViewExam method start.

/**
	 * @inheritDoc
	 */
@Override
public void start(Stage primaryStage) throws Exception {
    MergedTableView<String> root = new MergedTableView<>();
    TableColumn<String, String> e = new TableColumn<>("sample");
    e.setCellValueFactory(param -> {
        String value = param.getValue();
        return new SimpleStringProperty(value);
    });
    e.setCellFactory(MergedTextFieldTableCell.forTableColumn());
    root.getColumns().add(e);
    Random random = new Random(10);
    for (int i = 0; i < 100; i++) {
        root.getItems().add(String.valueOf(random.nextInt(10)));
    }
    //		
    primaryStage.setScene(new Scene(root));
    primaryStage.show();
}
Also used : Random(java.util.Random) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) MergedTableView(com.kyj.fx.voeditor.visual.component.grid.MergedTableView)

Example 3 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class FxExcelUtil method getDataSource.

/**
	 * UI 및 TableView로부터 Excel데이터생성을 위한 체계화된 데이터 
	 * LinkedHashMap객체를 리턴.
	 * @작성자 : KYJ
	 * @작성일 : 2016. 9. 7. 
	 * @param screen
	 * @param table
	 * @param allColumnsList 
	 *    계층형 테이블컬럼들을 일렬로 찾아낸 리스트
	 * @return
	 */
@SuppressWarnings({ "rawtypes" })
static /**
	 * UI 및 TableView로부터 Excel데이터생성을 위한 체계화된 데이터 
	 * @작성자 : KYJ
	 * @작성일 : 2016. 9. 19. 
	 * @param mapper
	 * @param table
	 * @param allColumnsList
	 * @return
	 */
LinkedHashMap<ExcelColumnExpression, List<Object>> getDataSource(IExcelScreenHandler mapper, TableView table, ArrayList<ExcelColumnExpression> allColumnsList) {
    LinkedHashMap<ExcelColumnExpression, List<Object>> dataSet = new LinkedHashMap<>();
    //ExcelColumnExpression :: 계층형 테이블컬럼들을 일렬로 찾아낸 리스트
    //		List<ExcelColumnExpression> allColumnsList = new ArrayList<ExcelColumnExpression>();
    @SuppressWarnings("unchecked") ObservableList<TableColumn> items = table.getItems();
    int size = items.size();
    //특화 헤더를 매핑.
    for (ExcelColumnExpression c : allColumnsList) {
        //			if (!c.isVisible())
        //				continue;
        String columnHeaderMapper = mapper.columnHeaderMapper(table, c.getTableColumn());
        c.setDisplayText(columnHeaderMapper);
        List<Object> values = new ArrayList<Object>();
        int columnIndex = c.getIndex();
        for (int rowIndex = 0; rowIndex < size; rowIndex++) {
            Object userValue = mapper.valueMapper(table, c.getTableColumn(), columnIndex, rowIndex);
            values.add(userValue);
        }
        dataSet.put(c, values);
    }
    return dataSet;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList) TableColumn(javafx.scene.control.TableColumn) ExcelColumnExpression(com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class FxExcelUtil method createExcel.

/**
	 * @작성자 : KYJ
	 * @작성일 : 2016. 9. 7. 
	 * @param screen
	 * @param exportExcelFile
	 * @param tableViewList
	 * @param overrite
	 * @throws Exception
	 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void createExcel(IExcelScreenHandler screen, File exportExcelFile, List<TableView> tableViewList, boolean overrite) throws Exception {
    IExcelScreenHandler screenHandler = screen;
    /*
		 * Key : Sheet
		 * Value - Key :  ExcelColumnExpression
		 * Value - Value :  Object
		 */
    LinkedHashMap<String, LinkedHashMap<ExcelColumnExpression, List<Object>>> dataSet = new LinkedHashMap<>();
    Map<String, Map<String, String>> metadata = new HashMap<>();
    int sheetIndex = 0;
    for (TableView table : tableViewList) {
        Predicate<TableView<?>> useTableViewForExcel = screenHandler.useTableViewForExcel();
        if (useTableViewForExcel != null) {
            if (!useTableViewForExcel.test(table)) {
                continue;
            }
        }
        //Sheet.
        String sheetName = screenHandler.toSheetName(table);
        if (sheetName == null) {
            sheetName = String.format(DEFAULT_SHEET_NAME_FORMAT, sheetIndex++);
        }
        ObservableList<TableColumn> columns = table.getColumns();
        //계층형 테이블컬럼의 모든 값을 찾아냄.
        ArrayList<ExcelColumnExpression> allColumnsList = new ArrayList<ExcelColumnExpression>();
        int maxLevel = getMaxLevel(columns, /*ExcelColumnExpression :: 계층형 테이블컬럼들을 일렬로 찾아낸 리스트 */
        allColumnsList, screenHandler.useTableColumnForExcel());
        dataSet.put(sheetName, getDataSource(screen, table, allColumnsList));
        HashMap<String, String> meta = new HashMap<String, String>();
        meta.put($$META_COLUMN_MAX_HEIGHT$$, String.valueOf(maxLevel));
        metadata.put(sheetName, meta);
    }
    if (dataSet.isEmpty())
        dataSet.put("empty", new LinkedHashMap<>());
    createExcel(screenHandler, exportExcelFile, dataSet, metadata, overrite);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IExcelScreenHandler(com.kyj.fx.voeditor.visual.framework.excel.IExcelScreenHandler) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) ExcelColumnExpression(com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TableView(javafx.scene.control.TableView)

Example 5 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class FxTableViewUtil method installPasteClipboard.

public static <K> void installPasteClipboard(TableView<K> tb, Class<K> clazz, Field targetField) {
    tb.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
        if (e.isControlDown() && e.getCode() == KeyCode.V) {
            Clipboard clip = Clipboard.getSystemClipboard();
            ObservableList<TableColumn<K, ?>> columns = tb.getColumns();
            if (columns.isEmpty())
                return;
            Object value = null;
            if (clip.hasFiles()) {
                value = clip.getFiles();
            } else if (clip.hasHtml()) {
                value = clip.getHtml();
            } else if (clip.hasImage()) {
                value = clip.getImage();
            } else if (clip.hasRtf()) {
                value = clip.getRtf();
            } else if (clip.hasString()) {
                value = clip.getString();
            } else if (clip.hasUrl()) {
                value = clip.getUrl();
            }
            if (value == null)
                return;
            try {
                K newInstance = clazz.newInstance();
                Field field = clazz.getField(targetField.getName());
                if (field != null) {
                    if (!field.isAccessible())
                        field.setAccessible(true);
                    field.set(newInstance, value);
                }
                tb.getItems().add(newInstance);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
}
Also used : Field(java.lang.reflect.Field) Clipboard(javafx.scene.input.Clipboard) TableColumn(javafx.scene.control.TableColumn)

Aggregations

TableColumn (javafx.scene.control.TableColumn)132 TableView (javafx.scene.control.TableView)68 TableCell (javafx.scene.control.TableCell)66 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)46 Button (javafx.scene.control.Button)44 VBox (javafx.scene.layout.VBox)41 Tooltip (javafx.scene.control.Tooltip)40 Callback (javafx.util.Callback)40 ObservableList (javafx.collections.ObservableList)39 Insets (javafx.geometry.Insets)37 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)36 Label (javafx.scene.control.Label)35 ArrayList (java.util.ArrayList)33 List (java.util.List)33 Scene (javafx.scene.Scene)32 Res (bisq.core.locale.Res)31 FxmlView (bisq.desktop.common.view.FxmlView)31 Inject (javax.inject.Inject)31 HyperlinkWithIcon (bisq.desktop.components.HyperlinkWithIcon)30 SortedList (javafx.collections.transformation.SortedList)27