Search in sources :

Example 1 with Mode

use of org.gephi.io.importer.plugin.file.spreadsheet.process.SpreadsheetGeneralConfiguration.Mode in project gephi by gephi.

the class WizardVisualPanel2 method loadColumns.

private void loadColumns(JPanel settingsPanel) {
    try {
        columnsCheckBoxes.clear();
        columnsComboBoxes.clear();
        JLabel columnsLabel = new JLabel(getMessage("WizardVisualPanel2.columnsLabel.text"));
        settingsPanel.add(columnsLabel, "wrap");
        final String[] headers = importer.getHeadersMap().keySet().toArray(new String[0]);
        final Mode mode = importer.getMode();
        for (String header : headers) {
            if (header.isEmpty()) {
                // Remove empty column headers:
                continue;
            }
            JCheckBox columnCheckBox = new JCheckBox(header, true);
            if (importer.getMode() == Mode.EDGES_TABLE && (header.equalsIgnoreCase("source") || header.equalsIgnoreCase("target"))) {
                columnCheckBox.setEnabled(false);
            }
            columnsCheckBoxes.add(columnCheckBox);
            JComboBox columnComboBox = new JComboBox();
            if (mode.isSpecialColumn(header)) {
                settingsPanel.add(columnCheckBox, "wrap 15px");
                // Special columns such as id, label, source and target... don't need a type selector
                // The type is not used by the importer anyway
                columnsComboBoxes.add(null);
            } else {
                settingsPanel.add(columnCheckBox, "wrap");
                columnsComboBoxes.add(columnComboBox);
                fillComboBoxWithColumnTypes(header, columnComboBox);
                settingsPanel.add(columnComboBox, "wrap 15px");
            }
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) JComboBox(javax.swing.JComboBox) Mode(org.gephi.io.importer.plugin.file.spreadsheet.process.SpreadsheetGeneralConfiguration.Mode) JLabel(javax.swing.JLabel) IOException(java.io.IOException)

Example 2 with Mode

use of org.gephi.io.importer.plugin.file.spreadsheet.process.SpreadsheetGeneralConfiguration.Mode in project gephi by gephi.

the class AbstractImporterSpreadsheet method autoDetectImportMode.

protected void autoDetectImportMode() {
    try {
        SheetParser parser = createParserWithoutHeaders();
        Mode mode = null;
        Iterator<SheetRow> iterator = parser.iterator();
        if (iterator.hasNext()) {
            SheetRow firstRow = iterator.next();
            if (firstRow.get(0) == null || firstRow.get(0).trim().isEmpty()) {
                mode = Mode.MATRIX;
            } else {
                // Detect very probable edges table:
                for (int i = 0; i < firstRow.size(); i++) {
                    String value = firstRow.get(i);
                    if ("source".equalsIgnoreCase(value) || "target".equalsIgnoreCase(value)) {
                        mode = Mode.EDGES_TABLE;
                        break;
                    }
                }
                // Detect probable nodes table:
                if (mode == null) {
                    for (int i = 0; i < firstRow.size(); i++) {
                        String value = firstRow.get(i);
                        if ("id".equalsIgnoreCase(value) || "label".equalsIgnoreCase(value) || "timeset".equalsIgnoreCase(value)) {
                            mode = Mode.NODES_TABLE;
                        }
                    }
                }
            }
        }
        if (mode == null) {
            // Default adjacency list:
            mode = Mode.ADJACENCY_LIST;
        }
        setMode(mode);
    } catch (IOException ex) {
    // NOOP
    }
}
Also used : SheetRow(org.gephi.io.importer.plugin.file.spreadsheet.sheet.SheetRow) Mode(org.gephi.io.importer.plugin.file.spreadsheet.process.SpreadsheetGeneralConfiguration.Mode) SheetParser(org.gephi.io.importer.plugin.file.spreadsheet.sheet.SheetParser) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 Mode (org.gephi.io.importer.plugin.file.spreadsheet.process.SpreadsheetGeneralConfiguration.Mode)2 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 SheetParser (org.gephi.io.importer.plugin.file.spreadsheet.sheet.SheetParser)1 SheetRow (org.gephi.io.importer.plugin.file.spreadsheet.sheet.SheetRow)1