Commit 89884aa7 authored by Matija Obreza's avatar Matija Obreza
Browse files

Code formatting

parent 1cb45e4e
......@@ -13,7 +13,6 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.genesys2.anno.gui.ColumnDefs;
import org.genesys2.anno.gui.DataSourceSheet;
import org.genesys2.anno.gui.IDataSourceSheet;
import org.genesys2.anno.model.Column;
import org.genesys2.anno.model.ColumnDef;
......
......@@ -19,7 +19,6 @@ package org.genesys2.anno.gui;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutorService;
......@@ -119,7 +118,7 @@ public class AppWindow {
@Override
public String getText(Object element) {
// _log.debug("getText " + element);
// _log.debug("getText " + element);
if (element instanceof DataSourceFile) {
return ((DataSourceFile) element).getFile().getName();
}
......@@ -164,15 +163,15 @@ public class AppWindow {
if (parentElement instanceof DataSourceFile) {
return ((DataSourceFile) parentElement).getSheets().toArray();
}
if (parentElement instanceof JdbcDataSource) {
return ((JdbcDataSource) parentElement).getSheets().toArray();
}
if (parentElement instanceof JdbcDataSource) {
return ((JdbcDataSource) parentElement).getSheets().toArray();
}
if (parentElement instanceof DataSourceSheet) {
return null;
}
if (parentElement instanceof JdbcDataSourceSheet) {
return null;
}
if (parentElement instanceof JdbcDataSourceSheet) {
return null;
}
return new Object[] { "Item 0", "Item 1", "Item 2" };
}
......@@ -183,7 +182,7 @@ public class AppWindow {
@Override
public boolean hasChildren(Object element) {
// _log.debug("hasChildren " + element + " " + element.getClass());
// _log.debug("hasChildren " + element + " " + element.getClass());
if (element instanceof DwcaBuilder) {
return ((DwcaBuilder) element).getFileRoots().size() > 0;
......@@ -191,15 +190,15 @@ public class AppWindow {
if (element instanceof DataSourceFile) {
return ((DataSourceFile) element).getSheets().size() > 0;
}
if (element instanceof JdbcDataSource) {
return ((JdbcDataSource) element).getSheets().size() > 0;
}
if (element instanceof JdbcDataSource) {
return ((JdbcDataSource) element).getSheets().size() > 0;
}
if (element instanceof DataSourceSheet) {
return false;
}
if (element instanceof JdbcDataSourceSheet) {
return false;
}
if (element instanceof JdbcDataSourceSheet) {
return false;
}
return getChildren(element).length > 0;
}
......@@ -382,32 +381,32 @@ public class AppWindow {
treeViewer.setContentProvider(new TreeContentProvider());
treeViewer.setInput(builder);
final MenuItem mntmAddFile = new MenuItem(filesTreeMenu, SWT.NONE);
mntmAddFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
Object selectedObject = ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
if (selectedObject instanceof JdbcDataSource) {
addJdbcQuery((JdbcDataSource) selectedObject);
}
if (selectedObject instanceof DataSourceFile) {
addSourceFile();
}
}
});
filesTreeMenu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent e) {
Object selectedObject = ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
if (selectedObject instanceof DataSourceFile) {
mntmAddFile.setText("Add file");
}
if (selectedObject instanceof JdbcDataSource) {
mntmAddFile.setText("Add SQL Query");
}
}
});
final MenuItem mntmAddFile = new MenuItem(filesTreeMenu, SWT.NONE);
mntmAddFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
Object selectedObject = ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
if (selectedObject instanceof JdbcDataSource) {
addJdbcQuery((JdbcDataSource) selectedObject);
}
if (selectedObject instanceof DataSourceFile) {
addSourceFile();
}
}
});
filesTreeMenu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent e) {
Object selectedObject = ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
if (selectedObject instanceof DataSourceFile) {
mntmAddFile.setText("Add file");
}
if (selectedObject instanceof JdbcDataSource) {
mntmAddFile.setText("Add SQL Query");
}
}
});
final MenuItem mntmRemoveFile = new MenuItem(filesTreeMenu, SWT.NONE);
mntmRemoveFile.addSelectionListener(new SelectionAdapter() {
......@@ -518,31 +517,31 @@ public class AppWindow {
CTabItem newSheetTab = createTab(tabFolder, currentSheet);
// Load stuff
if (selectedNode instanceof DataSourceSheet) {
threadPool.execute(new Runnable() {
@Override
public void run() {
try {
final List<Object[]> rows = dataSourceLoader.loadRows(currentSheet, 200);
currentSheet.updateData(rows);
} catch (UnsupportedDataFormatException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
tabFolder.setSelection(newSheetTab);
}
}
});
sashForm_1.setWeights(new int[] { 4 });
if (selectedNode instanceof DataSourceSheet) {
threadPool.execute(new Runnable() {
@Override
public void run() {
try {
final List<Object[]> rows = dataSourceLoader.loadRows(currentSheet, 200);
currentSheet.updateData(rows);
} catch (UnsupportedDataFormatException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
tabFolder.setSelection(newSheetTab);
}
}
});
sashForm_1.setWeights(new int[] { 4 });
ToolBar toolBar = new ToolBar(shlGenesysMagic, SWT.FLAT);
toolBar.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
......@@ -608,15 +607,15 @@ public class AppWindow {
tltmPush.setText("Push");
tltmPush.setImage(pushDataIcon);
ToolItem tltmDatabase = new ToolItem(toolBar, SWT.NONE);
tltmDatabase.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doDatabase();
}
});
tltmDatabase.setText("Add database");
m_bindingContext = initDataBindings();
ToolItem tltmDatabase = new ToolItem(toolBar, SWT.NONE);
tltmDatabase.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doDatabase();
}
});
tltmDatabase.setText("Add database");
m_bindingContext = initDataBindings();
}
protected CTabItem createTab(CTabFolder tabFolder, IDataSourceSheet currentSheet) {
......@@ -626,7 +625,7 @@ public class AppWindow {
tbtmOther.setText(currentSheet.getSheetName());
tbtmOther.setImage(spreadsheetIcon16);
final SheetDisplay sheetDisplay = (SheetDisplay) applicationContext.getBean("sheetDisplay", currentSheet, tabFolder,treeViewer, SWT.NONE);
final SheetDisplay sheetDisplay = (SheetDisplay) applicationContext.getBean("sheetDisplay", currentSheet, tabFolder, treeViewer, SWT.NONE);
tbtmOther.setControl(sheetDisplay);
tbtmOther.addDisposeListener(new DisposeListener() {
......@@ -699,10 +698,10 @@ public class AppWindow {
settingsDialog.open();
}
protected void doDatabase() {
DatabaseDialog databaseDialog = (DatabaseDialog) applicationContext.getBean("databaseDialog",shlGenesysMagic,treeViewer, SWT.NONE);
databaseDialog.open();
}
protected void doDatabase() {
DatabaseDialog databaseDialog = (DatabaseDialog) applicationContext.getBean("databaseDialog", shlGenesysMagic, treeViewer, SWT.NONE);
databaseDialog.open();
}
protected void doAutomap() {
final IDataSourceSheet dss = getCurrentDataSourceSheet();
......@@ -730,12 +729,12 @@ public class AppWindow {
return dss;
}
public void addJdbcQuery(JdbcDataSource dataSource) {
JdbcDataSourceSheet dataSourceSheet= new JdbcDataSourceSheet();
dataSourceSheet.setDatabaseSettings(dataSource.getSettings());
dataSource.addSheet(dataSourceSheet);
treeViewer.refresh();
}
public void addJdbcQuery(JdbcDataSource dataSource) {
JdbcDataSourceSheet dataSourceSheet = new JdbcDataSourceSheet();
dataSourceSheet.setDatabaseSettings(dataSource.getSettings());
dataSource.addSheet(dataSourceSheet);
treeViewer.refresh();
}
public void addSourceFile() {
FileDialog fd = new FileDialog(shlGenesysMagic, SWT.MULTI);
......
......@@ -41,6 +41,7 @@ public class AppWindow2 {
/**
* Launch the application.
*
* @param args
*/
public static void main(String[] args) {
......@@ -68,11 +69,11 @@ public class AppWindow2 {
}
public static boolean isMac() {
if ( System.getProperty( "os.name" ).equals( "Mac OS X" ) ) {
return true;
}
return false;
}
if (System.getProperty("os.name").equals("Mac OS X")) {
return true;
}
return false;
}
/**
* Create contents of the window.
......@@ -83,21 +84,21 @@ public class AppWindow2 {
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
......@@ -107,60 +108,60 @@ public class AppWindow2 {
}
});
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(new String[] { "Alpha", "beta" });
trtmNewTreeitem.setText("Another treee");
sashForm.setWeights(new int[] {310, 239});
sashForm.setWeights(new int[] { 310, 239 });
}
}
......@@ -32,12 +32,12 @@ public class ColumnDefs extends AbstractModelObject {
public List<ColumnDef> getColumnDefs() {
return columnDefs;
}
//
// public void addDataSource() {
// firePropertyChange("columnDefs", null, this);
// }
//
// public void removeDataSource() {
// firePropertyChange("columnDefs", null, this);
// }
//
// public void addDataSource() {
// firePropertyChange("columnDefs", null, this);
// }
//
// public void removeDataSource() {
// firePropertyChange("columnDefs", null, this);
// }
}
......@@ -26,7 +26,7 @@ public class DSW extends AbstractModelObject {
public IDataSourceSheet getDataSourceSheet() {
return dataSourceSheet;
}
public CsvDataSourceSheet getCsvDataSourceSheet() {
return (CsvDataSourceSheet) (dataSourceSheet instanceof CsvDataSourceSheet ? dataSourceSheet : null);
}
......
......@@ -24,28 +24,28 @@ public class DataSourceFile extends AbstractModelObject implements IDataSource {
private File file;
private List<IDataSourceSheet> sheets = new ArrayList<IDataSourceSheet>();
@Override
@Override
public File getFile() {
return file;
}
@Override
@Override
public void setFile(File file) {
this.file = file;
firePropertyChange("fileName", null, file);
}
@Override
@Override
public String getFileName() {
return this.file==null ? null : this.file.getName();
return this.file == null ? null : this.file.getName();
}
@Override
@Override
public List<IDataSourceSheet> getSheets() {
return sheets;
}
@Override
@Override
public void setSheets(List<IDataSourceSheet> sheets) {
this.sheets = sheets;
firePropertyChange("sheets", null, sheets);
......
......@@ -41,7 +41,7 @@ public class DataSourceLoaderImpl implements DataSourceLoader {
@Autowired
private JDBCRowReader jdbcRowReader;
@Override
public void registerParser(DataSourceParser parser) {
_log.debug("Adding parser " + parser.getClass().getName());
......@@ -116,17 +116,17 @@ public class DataSourceLoaderImpl implements DataSourceLoader {
@Override
public RowReader createRowReader(IDataSourceSheet sheet) throws IOException, UnsupportedDataFormatException {
// Iterate over parsers and see if something comes out
if (sheet instanceof JdbcDataSourceSheet) {
JdbcDataSourceSheet jdbcSheet = (JdbcDataSourceSheet) sheet;
JdbcDataSourceSheet jdbcSheet = (JdbcDataSourceSheet) sheet;
DatabaseSettings databaseSettings = jdbcSheet.getDatabaseSettings();
String url = databaseSettings.getUrl();
String user = databaseSettings.getUser();
String password = databaseSettings.getPassword();
String user = databaseSettings.getUser();
String password = databaseSettings.getPassword();
return jdbcRowReader.createRowReader(jdbcSheet.getQuery(), url, user, password);
}
for (DataSourceParser parser : parsers) {
try {
if (parser.supports(sheet.getSourceFile())) {
......
......@@ -28,8 +28,7 @@ public interface DataSourceParser {
boolean supports(File sourceFile);
Collection<? extends DataSourceSheet> findSheets(File sourceFile)
throws UnsupportedDataFormatException;
Collection<? extends DataSourceSheet> findSheets(File sourceFile) throws UnsupportedDataFormatException;
List<Object[]> loadRows(IDataSourceSheet sheet, int maxRows, int startAt) throws UnsupportedDataFormatException, FileNotFoundException, IOException;
......
......@@ -44,15 +44,17 @@ public class DataSourceSheet extends AbstractModelObject implements IDataSourceS
this.sourceFile = new File(sourceFile.getAbsolutePath());
}
@Override
public File getSourceFile() {
return sourceFile;
}
@Override
@Override
public String getSheetName() {
return sheetName;
}
@Override
public void setSheetName(String sheetName) {
this.sheetName = sheetName;
firePropertyChange("sheetName", null, sheetName);
......@@ -76,30 +78,31 @@ public class DataSourceSheet extends AbstractModelObject implements IDataSourceS
firePropertyChange("columnTerms", null, columnTerms);
}
@Override
@Override
public void setHeadersIncluded(boolean headersIncluded) {
_log.debug("Set headers included :" + headersIncluded);
this.headersIncluded = headersIncluded;
firePropertyChange("headersIncluded", null, headersIncluded);
}
@Override
@Override
public boolean isHeadersIncluded() {
return headersIncluded;
}
@Override
@Override
public int getHeaderRowIndex() {
return headerRowIndex;
}
@Override
@Override
public void setHeaderRowIndex(int headerRowIndex) {
_log.debug("Set header row index:" + headerRowIndex);
this.headerRowIndex = headerRowIndex;
firePropertyChange("headerRowIndex", null, headerRowIndex);
}
@Override
@Override
public void updateData(List<Object[]> rows) {
int columnCount = 0;
for (Object[] row : rows) {
......@@ -152,17 +155,17 @@ public class DataSourceSheet extends AbstractModelObject implements IDataSourceS
firePropertyChange("columns", null, columns);
}
@Override
@Override
public List<Object[]> getSampleData() {
return sampleData;
}
@Override
@Override
public List<Column> getColumns() {
return this.columns;
}
@Override
@Override
public void setColumns(List<Column> columns) {
this.columns = columns;
firePropertyChange("columns", null, this.columns);
......@@ -172,18 +175,18 @@ public class DataSourceSheet extends AbstractModelObject implements IDataSourceS
return this.columns.get(columnIndex);
}
@Override