Search in sources :

Example 11 with AttributeDataType

use of org.cytoscape.tableimport.internal.util.AttributeDataType in project cytoscape-impl by cytoscape.

the class AttributeEditorPanel method updateDataTypeButtons.

private void updateDataTypeButtons() {
    final SourceColumnSemantic type = getAttributeType();
    for (Entry<AttributeDataType, JToggleButton> entry : dataTypeButtons.entrySet()) {
        final AttributeDataType dataType = entry.getKey();
        final JToggleButton btn = entry.getValue();
        btn.setEnabled(TypeUtil.isValid(type, dataType));
    }
}
Also used : SourceColumnSemantic(org.cytoscape.tableimport.internal.util.SourceColumnSemantic) AttributeDataType(org.cytoscape.tableimport.internal.util.AttributeDataType) JToggleButton(javax.swing.JToggleButton)

Example 12 with AttributeDataType

use of org.cytoscape.tableimport.internal.util.AttributeDataType in project cytoscape-impl by cytoscape.

the class ImportAttributeTableReaderTask method loadAnnotation.

private void loadAnnotation(TaskMonitor tm) {
    tm.setProgress(0.0);
    final TextTableReader reader = this.reader;
    final AttributeMappingParameters readerAMP = (AttributeMappingParameters) reader.getMappingParameter();
    final String primaryKey = readerAMP.getAttributeNames()[readerAMP.getKeyIndex()];
    final AttributeDataType dataType = readerAMP.getDataTypes()[readerAMP.getKeyIndex()];
    final Class<?> keyType;
    switch(dataType) {
        case TYPE_INTEGER:
            keyType = Integer.class;
            break;
        case TYPE_LONG:
            keyType = Long.class;
            break;
        default:
            keyType = String.class;
    }
    tm.setProgress(0.1);
    final CyTable table = serviceRegistrar.getService(CyTableFactory.class).createTable("AttrTable " + inputName.substring(inputName.lastIndexOf('/') + 1) + " " + Integer.toString(numImports++), primaryKey, keyType, true, true);
    cyTables = new CyTable[] { table };
    tm.setProgress(0.3);
    try {
        this.reader.readTable(table);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    tm.setProgress(1.0);
}
Also used : CyTableFactory(org.cytoscape.model.CyTableFactory) CyTable(org.cytoscape.model.CyTable) AttributeDataType(org.cytoscape.tableimport.internal.util.AttributeDataType) IOException(java.io.IOException) TextTableReader(org.cytoscape.tableimport.internal.reader.TextTableReader) AttributeMappingParameters(org.cytoscape.tableimport.internal.reader.AttributeMappingParameters)

Aggregations

AttributeDataType (org.cytoscape.tableimport.internal.util.AttributeDataType)12 SourceColumnSemantic (org.cytoscape.tableimport.internal.util.SourceColumnSemantic)8 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 AttributeMappingParameters (org.cytoscape.tableimport.internal.reader.AttributeMappingParameters)3 JToggleButton (javax.swing.JToggleButton)2 InvalidFormatException (org.apache.poi.openxml4j.exceptions.InvalidFormatException)2 Sheet (org.apache.poi.ss.usermodel.Sheet)2 Workbook (org.apache.poi.ss.usermodel.Workbook)2 CyTable (org.cytoscape.model.CyTable)2 NetworkTableMappingParameters (org.cytoscape.tableimport.internal.reader.NetworkTableMappingParameters)2 Window (java.awt.Window)1 ActionEvent (java.awt.event.ActionEvent)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 WindowFocusListener (java.awt.event.WindowFocusListener)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 FileInputStream (java.io.FileInputStream)1 List (java.util.List)1