Commit 58b20e98 authored by Matija Obreza's avatar Matija Obreza
Browse files

Fixed jump-bug on column selection

parent 20f91089
......@@ -29,16 +29,17 @@ import org.apache.log4j.Logger;
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.PojoProperties;
import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StyledCellLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
......@@ -72,6 +73,7 @@ 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 org.eclipse.wb.swt.SWTResourceManager;
import org.genesys2.anno.converter.RowConverter;
import org.genesys2.anno.model.Column;
import org.genesys2.anno.model.ColumnDef;
......@@ -81,12 +83,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import swing2swt.layout.BorderLayout;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.eclipse.core.databinding.beans.PojoProperties;
import org.eclipse.wb.swt.SWTResourceManager;
import swing2swt.layout.BorderLayout;
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class SheetDisplay extends Composite {
......@@ -105,6 +105,11 @@ public class SheetDisplay extends Composite {
@Autowired
private ObjectMapper mapper;
final Color pinkColor = SWTResourceManager.getColor(255, 192, 203);
final Color blueColor = SWTResourceManager.getColor(173, 216, 230);
final Color yellowColor = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
final Color listBackgroundColor = SWTResourceManager.getColor(SWT.COLOR_LIST_BACKGROUND);
private static class ContentProvider implements IStructuredContentProvider {
@Override
public Object[] getElements(Object inputElement) {
......@@ -123,10 +128,11 @@ public class SheetDisplay extends Composite {
}
}
private class TableLabelProvider extends CellLabelProvider {
private class TableLabelProvider extends StyledCellLabelProvider {
@Override
public void update(final ViewerCell cell) {
final int columnIndex = cell.getColumnIndex();
System.err.println("Update col " + columnIndex);
final Object element = cell.getElement();
if (element instanceof Object[]) {
Object[] elArr = (Object[]) element;
......@@ -135,27 +141,21 @@ public class SheetDisplay extends Composite {
cell.setText(el == null ? "" : el.toString());
}
}
final Color pinkColor = SWTResourceManager.getColor(255,192,203);
final Color blueColor = SWTResourceManager.getColor(173,216,230);
final Color yellowColor = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
final Column selectedColumn = dsw.getSelectedColumn();
final Column currentColumn = dsw.getDataSourceSheet().getColumns().get(columnIndex);
if (currentColumn.getRdfTerm() != null && !currentColumn.getRdfTerm().isEmpty()) {
if (selectedColumn != null) {
if (selectedColumn.getPreferredName().equals(currentColumn.getPreferredName())) {
if (currentColumn == selectedColumn) {
cell.setBackground(pinkColor); // pink
} else {
cell.setBackground(blueColor); // light blue
}
} else {
cell.setBackground(blueColor); // light blue
}
if (currentColumn == selectedColumn) {
cell.setBackground(yellowColor); // yellow
} else {
if (selectedColumn != null) {
if (selectedColumn.getPreferredName().equals(currentColumn.getPreferredName())) {
cell.setBackground(yellowColor);
}
cell.setBackground(listBackgroundColor); // default
}
}
}
......@@ -638,7 +638,7 @@ public class SheetDisplay extends Composite {
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
updateTable();
tableViewer.refresh();
}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment