Commit b357edb0 authored by Matija Obreza's avatar Matija Obreza

Initial import

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>anno</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.swt</groupId>
<artifactId>swing2swt</artifactId>
<version>1.0</version>
<description>POM was created from install:install-file</description>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.eclipse.swt</groupId>
<artifactId>swing2swt</artifactId>
<version>1.0</version>
<versioning>
<versions>
<version>1.0</version>
</versions>
<lastUpdated>20140514183125</lastUpdated>
</versioning>
</metadata>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.genesys2</groupId>
<artifactId>anno</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Data annotator</name>
<repositories>
<repository>
<id>my-local-repo</id>
<url>file://${basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>swt</artifactId>
<version>3.3.0-v3346</version>
</dependency>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>swing2swt</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>
org.eclipse.swt.org.eclipse.swt.cocoa.macosx.x86_64.4.3.swt
</groupId>
<artifactId>org.eclipse.swt.cocoa.macosx.x86_64</artifactId>
<version>4.3</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>jface</artifactId>
<version>3.3.0-I20070606-0010</version>
</dependency>
<dependency>
<groupId>org.eclipse.jface</groupId>
<artifactId>databinding</artifactId>
<version>1.1.0-I20070606-0010</version>
</dependency>
<dependency>
<groupId>net.sf.supercsv</groupId>
<artifactId>super-csv</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>io.github.appbundler</groupId>
<artifactId>appbundle-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<mainClass>org.genesys2.anno.gui.AppWindow</mainClass>
<bundleName>Genesys Magic</bundleName>
<jvmVersion>1.6</jvmVersion>
<dictionaryFile>Info.plist.template</dictionaryFile>
<vmOptions>-XstartOnFirstThread</vmOptions>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Run it -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-XstartOnFirstThread</argument>
<arguments>-Dapple.laf.useScreenMenuBar=true</arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath />
<argument>org.genesys2.anno.gui.AppWindow</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
package org.genesys2.anno.gui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
import swing2swt.layout.BorderLayout;
public class AppWindow2 {
protected Shell shlGenesysMagic;
private MenuItem mntmQuit;
private Table table;
/**
* Launch the application.
* @param args
*/
public static void main(String[] args) {
try {
AppWindow2 window = new AppWindow2();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window.
*/
public void open() {
Display display = Display.getDefault();
createContents();
shlGenesysMagic.open();
shlGenesysMagic.layout();
while (!shlGenesysMagic.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
public static boolean isMac() {
if ( System.getProperty( "os.name" ).equals( "Mac OS X" ) ) {
return true;
}
return false;
}
/**
* Create contents of the window.
*/
protected void createContents() {
shlGenesysMagic = new Shell();
shlGenesysMagic.setMinimumSize(new Point(100, 22));
shlGenesysMagic.setSize(554, 374);
shlGenesysMagic.setText("Genesys Magic");
shlGenesysMagic.setLayout(new BorderLayout(5, 5));
Menu menu = new Menu(shlGenesysMagic, SWT.BAR);
shlGenesysMagic.setMenuBar(menu);
MenuItem mntmFile = new MenuItem(menu, SWT.CASCADE);
mntmFile.setText("File");
Menu menu_1 = new Menu(mntmFile);
mntmFile.setMenu(menu_1);
MenuItem mntmOpen = new MenuItem(menu_1, SWT.NONE);
mntmOpen.setText("Open");
new MenuItem(menu_1, SWT.SEPARATOR);
mntmQuit = new MenuItem(menu_1, SWT.NONE);
mntmQuit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
System.err.println("Exiting now.");
shlGenesysMagic.dispose();
}
});
mntmQuit.setText("Quit");
MenuItem mntmHelp = new MenuItem(menu, SWT.CASCADE);
mntmHelp.setText("Help");
Menu menu_2 = new Menu(mntmHelp);
mntmHelp.setMenu(menu_2);
MenuItem mntmAbout = new MenuItem(menu_2, SWT.NONE);
mntmAbout.setText("About");
new MenuItem(menu_2, SWT.SEPARATOR);
MenuItem mntmVersion = new MenuItem(menu_2, SWT.NONE);
mntmVersion.setText("Version...");
SashForm sashForm = new SashForm(shlGenesysMagic, SWT.NONE);
sashForm.setLayoutData(BorderLayout.CENTER);
table = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn tblclmnColumn = new TableColumn(table, SWT.NONE);
tblclmnColumn.setWidth(100);
tblclmnColumn.setText("Column");
TableColumn tblclmnRdfTerm = new TableColumn(table, SWT.NONE);
tblclmnRdfTerm.setWidth(200);
tblclmnRdfTerm.setText("Ontology Term");
Tree tree = new Tree(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
TreeColumn trclmnTerms = new TreeColumn(tree, SWT.NONE);
trclmnTerms.setWidth(200);
trclmnTerms.setText("Terms");
TreeColumn trclmnUrl = new TreeColumn(tree, SWT.NONE);
trclmnUrl.setWidth(100);
trclmnUrl.setText("URL");
TreeItem trtmSomeTree = new TreeItem(tree, SWT.NONE);
trtmSomeTree.setChecked(true);
trtmSomeTree.setText("Some tree");
trtmSomeTree.setExpanded(true);
TreeItem trtmNewTreeitem_1 = new TreeItem(tree, SWT.NONE);
trtmNewTreeitem_1.setText("Bugger");
TreeItem trtmNewTreeitem = new TreeItem(tree, SWT.NONE);
trtmNewTreeitem.setText(new String[] {"Alpha", "beta"});
trtmNewTreeitem.setText("Another treee");
sashForm.setWeights(new int[] {310, 239});
}
}
package org.genesys2.anno.gui;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class DataSourceFile {
private File file;
private List<DataSourceSheet> sheets = new ArrayList<DataSourceSheet>();
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public List<DataSourceSheet> getSheets() {
return sheets;
}
public void setSheets(List<DataSourceSheet> sheets) {
this.sheets = sheets;
}
@Override
public String toString() {
return file.getName();
}
}
package org.genesys2.anno.gui;
import java.io.File;
import java.util.List;
public interface DataSourceLoader {
void registerParser(DataSourceParser parser);
DataSourceFile loadDataSource(File file);
List<Object[]> loadRows(DataSourceSheet sheet, int maxRows) throws UnsupportedDataFormatException;
}
package org.genesys2.anno.gui;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class DataSourceLoaderImpl implements DataSourceLoader {
private final List<DataSourceSheet> NO_SHEETS = new ArrayList<DataSourceSheet>();
private Set<DataSourceParser> parsers = new HashSet<DataSourceParser>();
@Override
public void registerParser(DataSourceParser parser) {
System.err.println("Adding parser " + parser.getClass().getName());
this.parsers.add(parser);
}
@Override
public DataSourceFile loadDataSource(File file) {
if (!file.exists() || !file.canRead()) {
System.err.println("Could not find or read "
+ file.getAbsolutePath());
return null;
}
DataSourceFile dataSourceFile = new DataSourceFile();
dataSourceFile.setFile(file);
dataSourceFile.getSheets().addAll(findSheets(dataSourceFile));
return dataSourceFile;
}
private Collection<? extends DataSourceSheet> findSheets(
DataSourceFile dataSourceFile) {
File sourceFile = dataSourceFile.getFile();
// Iterate over parsers and see if something comes out
for (DataSourceParser parser : parsers) {
try {
if (parser.supports(sourceFile)) {
return parser.findSheets(sourceFile);
}
} catch (UnsupportedDataFormatException e) {
System.err.println(e.getMessage());
}
}
return NO_SHEETS;
}
@Override
public List<Object[]> loadRows(DataSourceSheet sheet, int maxRows)
throws UnsupportedDataFormatException {
// Iterate over parsers and see if something comes out
for (DataSourceParser parser : parsers) {
try {
if (parser.supports(sheet.getSourceFile())) {
return parser.loadRows(sheet.getSourceFile(),
sheet.getSheetName(), maxRows);
}
} catch (UnsupportedDataFormatException e) {
System.err.println(e.getMessage());
}
}
throw new UnsupportedDataFormatException("No parser found", null);
}
}
package org.genesys2.anno.gui;
import java.io.File;
import java.util.Collection;
import java.util.List;
public interface DataSourceParser {
boolean supports(File sourceFile);
Collection<? extends DataSourceSheet> findSheets(File sourceFile)
throws UnsupportedDataFormatException;
List<Object[]> loadRows(File sourceFile, String sheetName, int maxRows)
throws UnsupportedDataFormatException;
}
package org.genesys2.anno.gui;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DataSourceSheet {
private File sourceFile;
private String sheetName;
private List<String> columnNames = new ArrayList<String>();
private Map<String, String> columnTerms = new HashMap<String, String>();
public DataSourceSheet(File sourceFile) {
this.sourceFile = new File(sourceFile.getAbsolutePath());
}
public File getSourceFile() {
return sourceFile;
}
public String getSheetName() {
return sheetName;
}
public void setSheetName(String sheetName) {
this.sheetName = sheetName;
}
public List<String> getColumnNames() {
return columnNames;
}
public void setColumnNames(List<String> columnNames) {
this.columnNames = columnNames;
}
public Map<String, String> getColumnTerms() {
return columnTerms;
}
public void setColumnTerms(Map<String, String> columnTerms) {
this.columnTerms = columnTerms;
}
}
package org.genesys2.anno.gui;
import java.util.ArrayList;
import java.util.List;
public class DwcaBuilder {
private List<DataSourceFile> fileRoots = new ArrayList<DataSourceFile>();
public List<DataSourceFile> getFileRoots() {
return fileRoots;
}
public void addDataSource(DataSourceFile dataSource) {
if (dataSource == null)
return;
fileRoots.add(dataSource);
}
}
package org.genesys2.anno.gui;
import java.util.List;
import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import swing2swt.layout.BorderLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
public class SheetDisplay extends Composite {
private static class ContentProvider implements IStructuredContentProvider {
public Object[] getElements(Object inputElement) {
if (inputElement instanceof List) {
return ((List<?>) inputElement).toArray();
}
return new Object[0];
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
}
private class TableLabelProvider extends LabelProvider implements
ITableLabelProvider {
public Image getColumnImage(Object element, int columnIndex) {