Commit b3576ec5 authored by Matija Obreza's avatar Matija Obreza
Browse files

Logging

parent 1ca24a1b
...@@ -131,6 +131,11 @@ ...@@ -131,6 +131,11 @@
<artifactId>org.eclipse.osgi</artifactId> <artifactId>org.eclipse.osgi</artifactId>
<version>3.8.0</version> <version>3.8.0</version>
</dependency> </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
...@@ -19,26 +19,29 @@ package org.genesys2.anno.gui; ...@@ -19,26 +19,29 @@ package org.genesys2.anno.gui;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeSupport;
import org.apache.log4j.Logger;
public abstract class AbstractModelObject { public abstract class AbstractModelObject {
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
private static final Logger _log = Logger.getLogger(AbstractModelObject.class);
public void addPropertyChangeListener(PropertyChangeListener listener) { public void addPropertyChangeListener(PropertyChangeListener listener) {
// System.out.println("Adding listener to " + this.getClass() + " of " + listener); _log.debug("Adding listener to " + this.getClass() + " of " + listener);
propertyChangeSupport.addPropertyChangeListener(listener); propertyChangeSupport.addPropertyChangeListener(listener);
} }
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
// System.out.println("Adding property listener '" + propertyName + "' to " + this.getClass() + " of " + listener); _log.debug("Adding property listener '" + propertyName + "' to " + this.getClass() + " of " + listener);
propertyChangeSupport.addPropertyChangeListener(propertyName, listener); propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
} }
public void removePropertyChangeListener(PropertyChangeListener listener) { public void removePropertyChangeListener(PropertyChangeListener listener) {
// System.out.println("Removing property listener from " + this.getClass() + " of " + listener); _log.debug("Removing property listener from " + this.getClass() + " of " + listener);
propertyChangeSupport.removePropertyChangeListener(listener); propertyChangeSupport.removePropertyChangeListener(listener);
} }
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
// System.out.println("Removing property listener '" + propertyName + "' from " + this.getClass() + " of " + listener); _log.debug("Removing property listener '" + propertyName + "' from " + this.getClass() + " of " + listener);
propertyChangeSupport.removePropertyChangeListener(propertyName, listener); propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
} }
......
...@@ -24,6 +24,7 @@ import java.util.List; ...@@ -24,6 +24,7 @@ import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import org.apache.log4j.Logger;
import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeansObservables; import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.Realm; import org.eclipse.core.databinding.observable.Realm;
...@@ -77,13 +78,14 @@ import org.genesys2.anno.parser.XlsxDataSourceParser; ...@@ -77,13 +78,14 @@ import org.genesys2.anno.parser.XlsxDataSourceParser;
import swing2swt.layout.BorderLayout; import swing2swt.layout.BorderLayout;
public class AppWindow { public class AppWindow {
private static final Logger _log = Logger.getLogger(AppWindow.class);
private DataBindingContext m_bindingContext; private DataBindingContext m_bindingContext;
private DwcaBuilder builder = new DwcaBuilder(); private DwcaBuilder builder = new DwcaBuilder();
private ExecutorService threadPool = Executors.newFixedThreadPool(4); private ExecutorService threadPool = Executors.newFixedThreadPool(4);
private static class ViewerLabelProvider extends LabelProvider { private static class ViewerLabelProvider extends LabelProvider {
public Image getImage(Object element) { public Image getImage(Object element) {
System.err.println("getImage " + element); _log.debug("getImage " + element);
if (element instanceof DataSourceFile) { if (element instanceof DataSourceFile) {
return archiveIcon; return archiveIcon;
} }
...@@ -94,7 +96,7 @@ public class AppWindow { ...@@ -94,7 +96,7 @@ public class AppWindow {
} }
public String getText(Object element) { public String getText(Object element) {
System.err.println("getText " + element); _log.debug("getText " + element);
if (element instanceof DataSourceFile) { if (element instanceof DataSourceFile) {
return ((DataSourceFile) element).getFile().getName(); return ((DataSourceFile) element).getFile().getName();
} }
...@@ -113,7 +115,7 @@ public class AppWindow { ...@@ -113,7 +115,7 @@ public class AppWindow {
} }
public Object[] getElements(Object inputElement) { public Object[] getElements(Object inputElement) {
System.err.println("getElements " + inputElement + " " _log.debug("getElements " + inputElement + " "
+ inputElement.getClass()); + inputElement.getClass());
if (inputElement instanceof DwcaBuilder) { if (inputElement instanceof DwcaBuilder) {
return ((DwcaBuilder) inputElement).getFileRoots().toArray(); return ((DwcaBuilder) inputElement).getFileRoots().toArray();
...@@ -129,7 +131,7 @@ public class AppWindow { ...@@ -129,7 +131,7 @@ public class AppWindow {
} }
public Object[] getChildren(Object parentElement) { public Object[] getChildren(Object parentElement) {
System.err.println("getChildren " + parentElement + " " _log.debug("getChildren " + parentElement + " "
+ parentElement.getClass()); + parentElement.getClass());
if (parentElement instanceof DwcaBuilder) { if (parentElement instanceof DwcaBuilder) {
...@@ -149,7 +151,7 @@ public class AppWindow { ...@@ -149,7 +151,7 @@ public class AppWindow {
} }
public boolean hasChildren(Object element) { public boolean hasChildren(Object element) {
System.err.println("hasChildren " + element + " " _log.debug("hasChildren " + element + " "
+ element.getClass()); + element.getClass());
if (element instanceof DwcaBuilder) { if (element instanceof DwcaBuilder) {
...@@ -272,7 +274,7 @@ public class AppWindow { ...@@ -272,7 +274,7 @@ public class AppWindow {
mntmQuit.addSelectionListener(new SelectionAdapter() { mntmQuit.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent arg0) { public void widgetSelected(SelectionEvent arg0) {
System.err.println("Exiting now."); _log.debug("Exiting now.");
shlGenesysMagic.dispose(); shlGenesysMagic.dispose();
} }
}); });
...@@ -327,7 +329,7 @@ public class AppWindow { ...@@ -327,7 +329,7 @@ public class AppWindow {
.getSelection()).iterator(); iterator.hasNext();) { .getSelection()).iterator(); iterator.hasNext();) {
Object selectedObject = iterator.next(); Object selectedObject = iterator.next();
System.err.println("Remove Sel " + selectedObject); _log.debug("Remove Sel " + selectedObject);
if (selectedObject instanceof DataSourceFile) { if (selectedObject instanceof DataSourceFile) {
builder.removeDataSource((DataSourceFile) selectedObject); builder.removeDataSource((DataSourceFile) selectedObject);
tableViewer.refresh(); tableViewer.refresh();
...@@ -348,7 +350,7 @@ public class AppWindow { ...@@ -348,7 +350,7 @@ public class AppWindow {
&& iterator.hasNext();) { && iterator.hasNext();) {
Object selectedObject = iterator.next(); Object selectedObject = iterator.next();
System.err.println("Sel " + selectedObject); _log.debug("Sel " + selectedObject);
if (selectedObject instanceof DataSourceFile) if (selectedObject instanceof DataSourceFile)
enabled = true; enabled = true;
...@@ -386,7 +388,7 @@ public class AppWindow { ...@@ -386,7 +388,7 @@ public class AppWindow {
dragSource.addDragListener(new DragSourceAdapter() { dragSource.addDragListener(new DragSourceAdapter() {
@Override @Override
public void dragStart(DragSourceEvent event) { public void dragStart(DragSourceEvent event) {
System.err.println("Starting drag"); _log.debug("Starting drag");
event.doit = true; event.doit = true;
LocalSelectionTransfer.getTransfer().setSelection(tableViewer.getSelection()); LocalSelectionTransfer.getTransfer().setSelection(tableViewer.getSelection());
} }
...@@ -401,10 +403,10 @@ public class AppWindow { ...@@ -401,10 +403,10 @@ public class AppWindow {
if (selectedNode instanceof DataSourceSheet) { if (selectedNode instanceof DataSourceSheet) {
final DataSourceSheet currentSheet = (DataSourceSheet) selectedNode; final DataSourceSheet currentSheet = (DataSourceSheet) selectedNode;
System.err.println("Doubleclick " + currentSheet); _log.debug("Doubleclick " + currentSheet);
int i = 0; int i = 0;
for (Control c : tabFolder.getTabList()) { for (Control c : tabFolder.getTabList()) {
System.err.println("Looking at " + c); _log.debug("Looking at " + c);
if (c instanceof SheetDisplay) { if (c instanceof SheetDisplay) {
if (selectedNode == ((SheetDisplay) c) if (selectedNode == ((SheetDisplay) c)
.getDataSourceSheet()) { .getDataSourceSheet()) {
...@@ -472,12 +474,12 @@ public class AppWindow { ...@@ -472,12 +474,12 @@ public class AppWindow {
if (response != null) { if (response != null) {
for (String file : fd.getFileNames()) { for (String file : fd.getFileNames()) {
System.err.println(fd.getFilterPath() + " " + file); _log.debug(fd.getFilterPath() + " " + file);
builder.addDataSource(dataSourceLoader.loadDataSource(new File( builder.addDataSource(dataSourceLoader.loadDataSource(new File(
fd.getFilterPath(), file))); fd.getFilterPath(), file)));
// Update binding! // Update binding!
System.err.println("Updating models!"); _log.debug("Updating models!");
m_bindingContext.updateModels(); m_bindingContext.updateModels();
} }
} }
......
...@@ -25,21 +25,24 @@ import java.util.HashSet; ...@@ -25,21 +25,24 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.log4j.Logger;
public class DataSourceLoaderImpl implements DataSourceLoader { public class DataSourceLoaderImpl implements DataSourceLoader {
private static final Logger _log = Logger.getLogger(DataSourceLoaderImpl.class);
private final List<DataSourceSheet> NO_SHEETS = new ArrayList<DataSourceSheet>(); private final List<DataSourceSheet> NO_SHEETS = new ArrayList<DataSourceSheet>();
private Set<DataSourceParser> parsers = new HashSet<DataSourceParser>(); private Set<DataSourceParser> parsers = new HashSet<DataSourceParser>();
@Override @Override
public void registerParser(DataSourceParser parser) { public void registerParser(DataSourceParser parser) {
System.err.println("Adding parser " + parser.getClass().getName()); _log.debug("Adding parser " + parser.getClass().getName());
this.parsers.add(parser); this.parsers.add(parser);
} }
@Override @Override
public DataSourceFile loadDataSource(File file) { public DataSourceFile loadDataSource(File file) {
if (!file.exists() || !file.canRead()) { if (!file.exists() || !file.canRead()) {
System.err.println("Could not find or read " _log.debug("Could not find or read "
+ file.getAbsolutePath()); + file.getAbsolutePath());
return null; return null;
} }
...@@ -63,7 +66,7 @@ public class DataSourceLoaderImpl implements DataSourceLoader { ...@@ -63,7 +66,7 @@ public class DataSourceLoaderImpl implements DataSourceLoader {
return parser.findSheets(sourceFile); return parser.findSheets(sourceFile);
} }
} catch (UnsupportedDataFormatException e) { } catch (UnsupportedDataFormatException e) {
System.err.println(e.getMessage()); _log.debug(e.getMessage());
} }
} }
...@@ -82,7 +85,7 @@ public class DataSourceLoaderImpl implements DataSourceLoader { ...@@ -82,7 +85,7 @@ public class DataSourceLoaderImpl implements DataSourceLoader {
sheet.getSheetName(), maxRows); sheet.getSheetName(), maxRows);
} }
} catch (UnsupportedDataFormatException e) { } catch (UnsupportedDataFormatException e) {
System.err.println(e.getMessage()); _log.debug(e.getMessage(), e);
} }
} }
......
...@@ -22,9 +22,12 @@ import java.util.HashMap; ...@@ -22,9 +22,12 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger;
import org.genesys2.anno.model.Column; import org.genesys2.anno.model.Column;
public class DataSourceSheet extends AbstractModelObject { public class DataSourceSheet extends AbstractModelObject {
private static final Logger _log = Logger.getLogger(DataSourceSheet.class);
private File sourceFile; private File sourceFile;
private String sheetName; private String sheetName;
private List<String> columnNames = new ArrayList<String>(); private List<String> columnNames = new ArrayList<String>();
...@@ -70,7 +73,7 @@ public class DataSourceSheet extends AbstractModelObject { ...@@ -70,7 +73,7 @@ public class DataSourceSheet extends AbstractModelObject {
} }
public void setHeadersIncluded(boolean headersIncluded) { public void setHeadersIncluded(boolean headersIncluded) {
System.err.println("Set headers included :" + headersIncluded); _log.debug("Set headers included :" + headersIncluded);
this.headersIncluded = headersIncluded; this.headersIncluded = headersIncluded;
firePropertyChange("headersIncluded", null, headersIncluded); firePropertyChange("headersIncluded", null, headersIncluded);
} }
...@@ -84,7 +87,7 @@ public class DataSourceSheet extends AbstractModelObject { ...@@ -84,7 +87,7 @@ public class DataSourceSheet extends AbstractModelObject {
} }
public void setHeaderRowIndex(int headerRowIndex) { public void setHeaderRowIndex(int headerRowIndex) {
System.err.println("Set header row index:" + headerRowIndex); _log.debug("Set header row index:" + headerRowIndex);
this.headerRowIndex = headerRowIndex; this.headerRowIndex = headerRowIndex;
firePropertyChange("headerRowIndex", null, headerRowIndex); firePropertyChange("headerRowIndex", null, headerRowIndex);
} }
...@@ -113,19 +116,19 @@ public class DataSourceSheet extends AbstractModelObject { ...@@ -113,19 +116,19 @@ public class DataSourceSheet extends AbstractModelObject {
// Make sure we have the Columns in the list // Make sure we have the Columns in the list
ensureColumns(columnCount, headers); ensureColumns(columnCount, headers);
System.err.println("Firing sampleData change"); _log.debug("Firing sampleData change");
firePropertyChange("sampleData", null, this.sampleData); firePropertyChange("sampleData", null, this.sampleData);
} }
private void ensureColumns(int columnCount, Object[] headerRow) { private void ensureColumns(int columnCount, Object[] headerRow) {
boolean changed = false; boolean changed = false;
for (int i = columns.size() - 1; i >= 0 && i > columnCount; i--) { for (int i = columns.size() - 1; i >= 0 && i > columnCount; i--) {
System.err.println("Removing extra columns"); _log.debug("Removing extra columns");
columns.remove(i); columns.remove(i);
changed = true; changed = true;
} }
for (int i = columns.size(); i < columnCount; i++) { for (int i = columns.size(); i < columnCount; i++) {
System.err.println("Adding column " + i); _log.debug("Adding column " + i);
columns.add(new Column()); columns.add(new Column());
changed = true; changed = true;
} }
......
...@@ -19,13 +19,12 @@ package org.genesys2.anno.gui; ...@@ -19,13 +19,12 @@ package org.genesys2.anno.gui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
import org.eclipse.core.databinding.Binding; import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties; import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.observable.ChangeEvent; import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener; import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.util.LocalSelectionTransfer;
...@@ -69,6 +68,7 @@ import org.genesys2.anno.model.Column; ...@@ -69,6 +68,7 @@ import org.genesys2.anno.model.Column;
import swing2swt.layout.BorderLayout; import swing2swt.layout.BorderLayout;
public class SheetDisplay extends Composite { public class SheetDisplay extends Composite {
private static final Logger _log = Logger.getLogger(SheetDisplay.class);
private DataBindingContext m_bindingContext; private DataBindingContext m_bindingContext;
private static class ContentProvider implements IStructuredContentProvider { private static class ContentProvider implements IStructuredContentProvider {
...@@ -107,7 +107,6 @@ public class SheetDisplay extends Composite { ...@@ -107,7 +107,6 @@ public class SheetDisplay extends Composite {
private Table table; private Table table;
private Text txtColumnName; private Text txtColumnName;
private Text txtRdfTerm; private Text txtRdfTerm;
private Text txtColumnIndex;
private DSW dsw = new DSW(); private DSW dsw = new DSW();
private TableViewer tableViewer; private TableViewer tableViewer;
private Text txtHeaderRowIndex; private Text txtHeaderRowIndex;
...@@ -123,10 +122,10 @@ public class SheetDisplay extends Composite { ...@@ -123,10 +122,10 @@ public class SheetDisplay extends Composite {
public void setDataSourceSheet(DataSourceSheet dataSourceSheet) { public void setDataSourceSheet(DataSourceSheet dataSourceSheet) {
this.dsw.setDataSourceSheet(dataSourceSheet); this.dsw.setDataSourceSheet(dataSourceSheet);
// System.err.println("Updating targets"); // _log.debug("Updating targets");
// m_bindingContext.updateTargets(); // m_bindingContext.updateTargets();
} }
/** /**
* Create the composite. * Create the composite.
* *
...@@ -140,9 +139,11 @@ public class SheetDisplay extends Composite { ...@@ -140,9 +139,11 @@ public class SheetDisplay extends Composite {
// UNBIND ALL STUFF // UNBIND ALL STUFF
sampleDataDswObserveValue.dispose(); sampleDataDswObserveValue.dispose();
@SuppressWarnings("unchecked")
ArrayList<Object> bindings = new ArrayList<Object>(m_bindingContext.getBindings()); ArrayList<Object> bindings = new ArrayList<Object>(m_bindingContext.getBindings());
for (Object b : bindings) { for (Object b : bindings) {
System.out.println("Remove binfing " +b); _log.trace("Remove binding " + b);
if (b instanceof Binding) { if (b instanceof Binding) {
((Binding) b).getModel().dispose(); ((Binding) b).getModel().dispose();
} }
...@@ -177,16 +178,6 @@ public class SheetDisplay extends Composite { ...@@ -177,16 +178,6 @@ public class SheetDisplay extends Composite {
scrolledComposite.setMinSize(new Point(10, 200)); scrolledComposite.setMinSize(new Point(10, 200));
new Label(composite, SWT.NONE); new Label(composite, SWT.NONE);
Label lblColumn = new Label(composite, SWT.NONE);
lblColumn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblColumn.setText("Column");
txtColumnIndex = new Text(composite, SWT.BORDER);
txtColumnIndex.setEnabled(false);
txtColumnIndex.setEditable(false);
txtColumnIndex.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
new Label(composite, SWT.NONE);
Label lblThisIsA = new Label(composite, SWT.NONE); Label lblThisIsA = new Label(composite, SWT.NONE);
lblThisIsA.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblThisIsA.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblThisIsA.setText("Column name"); lblThisIsA.setText("Column name");
...@@ -233,7 +224,7 @@ public class SheetDisplay extends Composite { ...@@ -233,7 +224,7 @@ public class SheetDisplay extends Composite {
btnAnalyzeColumnData.addSelectionListener(new SelectionAdapter() { btnAnalyzeColumnData.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
System.err.println("Do column analysis"); _log.debug("Do column analysis");
} }
}); });
btnAnalyzeColumnData.setText("Analyze column data"); btnAnalyzeColumnData.setText("Analyze column data");
...@@ -246,14 +237,14 @@ public class SheetDisplay extends Composite { ...@@ -246,14 +237,14 @@ public class SheetDisplay extends Composite {
public void drop(DropTargetEvent event) { public void drop(DropTargetEvent event) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) { if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) {
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection(); ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
System.err.println("Dropped " + sel); _log.debug("Dropped " + sel);
System.err.println("Dropped class " + sel.getClass()); _log.debug("Dropped class " + sel.getClass());
} }
} }
@Override @Override
public void dragEnter(DropTargetEvent event) { public void dragEnter(DropTargetEvent event) {
System.err.println("dragenter " + event.detail); _log.debug("dragenter " + event.detail);
event.detail = DND.DROP_LINK; event.detail = DND.DROP_LINK;
} }
}); });
...@@ -281,13 +272,13 @@ public class SheetDisplay extends Composite { ...@@ -281,13 +272,13 @@ public class SheetDisplay extends Composite {
// int idx = Integer.parseInt(txtHeaderRowIndex.getText()); // int idx = Integer.parseInt(txtHeaderRowIndex.getText());
// if (dataSourceSheet.getHeaderRowIndex() != idx) { // if (dataSourceSheet.getHeaderRowIndex() != idx) {
// dataSourceSheet.setHeaderRowIndex(idx); // dataSourceSheet.setHeaderRowIndex(idx);
// System.err.println("Modify headerRowIndex: " + idx); // _log.debug("Modify headerRowIndex: " + idx);
// } // }
// } catch (NumberFormatException e1) { // } catch (NumberFormatException e1) {
// txtHeaderRowIndex.setText(String.valueOf(dataSourceSheet // txtHeaderRowIndex.setText(String.valueOf(dataSourceSheet
// .getHeaderRowIndex())); // .getHeaderRowIndex()));
// } // }
System.err.println("Updating model..."); _log.debug("Updating model...");
m_bindingContext.updateModels(); m_bindingContext.updateModels();
} }
}); });
...@@ -378,7 +369,7 @@ public class SheetDisplay extends Composite { ...@@ -378,7 +369,7 @@ public class SheetDisplay extends Composite {
} }
private void updateTable() { private void updateTable() {
System.err.println("Rebuilding table..."); _log.debug("Rebuilding table...");
table.clearAll(); table.clearAll();