Revision c5a4b091
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java | ||
---|---|---|
25 | 25 |
import org.eclipse.core.runtime.jobs.Job; |
26 | 26 |
import org.eclipse.jface.layout.GridDataFactory; |
27 | 27 |
import org.eclipse.jface.viewers.ComboViewer; |
28 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
29 | 28 |
import org.eclipse.nebula.widgets.nattable.NatTable; |
30 | 29 |
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry; |
31 | 30 |
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration; |
... | ... | |
53 | 52 |
import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer; |
54 | 53 |
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; |
55 | 54 |
import org.eclipse.nebula.widgets.nattable.layer.ILayer; |
56 |
import org.eclipse.nebula.widgets.nattable.layer.ILayerListener; |
|
57 | 55 |
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator; |
58 |
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; |
|
59 |
import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent; |
|
60 | 56 |
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack; |
61 | 57 |
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; |
62 |
import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent; |
|
63 | 58 |
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer; |
64 | 59 |
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration; |
65 | 60 |
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum; |
... | ... | |
179 | 174 |
private void applyStyles(){ |
180 | 175 |
ModernNatTableThemeConfiguration configuration = new ModernNatTableThemeConfiguration(); |
181 | 176 |
configuration.summaryRowHAlign = HorizontalAlignmentEnum.CENTER; |
177 |
// NOTE: Getting the colors and fonts from the GUIHelper ensures that |
|
178 |
// they are disposed properly (required by SWT) |
|
182 | 179 |
configuration.summaryRowBgColor = GUIHelper.getColor(255, 255, 153); |
183 | 180 |
configuration.cHeaderBgColor = GUIHelper.getColor(211, 211, 211); |
184 | 181 |
configuration.rHeaderBgColor = GUIHelper.getColor(211, 211, 211); |
185 | 182 |
natTable.addConfiguration(configuration); |
186 |
// // NOTE: Getting the colors and fonts from the GUIHelper ensures that |
|
187 |
// // they are disposed properly (required by SWT) |
|
188 |
// DefaultNatTableStyleConfiguration natTableConfiguration = new DefaultNatTableStyleConfiguration(); |
|
189 |
// natTableConfiguration.bgColor = GUIHelper.getColor(249, 172, 7); |
|
190 |
// natTableConfiguration.fgColor = GUIHelper.getColor(30, 76, 19); |
|
191 |
// natTableConfiguration.hAlign = HorizontalAlignmentEnum.LEFT; |
|
192 |
// natTableConfiguration.vAlign = VerticalAlignmentEnum.TOP; |
|
193 |
//// natTableConfiguration.borderStyle = new BorderStyle(1, GUIHelper.getColor(249, 172, 7), LineStyleEnum.SOLID); |
|
194 |
// |
|
195 |
// // Setup even odd row colors - row colors override the NatTable default |
|
196 |
// // colors |
|
197 |
// DefaultRowStyleConfiguration rowStyleConfiguration = new DefaultRowStyleConfiguration(); |
|
198 |
// rowStyleConfiguration.oddRowBgColor = ColorResources.getColor(Resources.COLOR_LIST_ODD); |
|
199 |
// rowStyleConfiguration.evenRowBgColor = ColorResources.getColor(Resources.COLOR_LIST_EVEN); |
|
200 |
// |
|
201 |
// // Setup selection styling |
|
202 |
// DefaultSelectionStyleConfiguration selectionStyle = new DefaultSelectionStyleConfiguration(); |
|
203 |
//// selectionStyle.selectionFont = GUIHelper.getFont(new FontData("Verdana", 8, SWT.NORMAL)); |
|
204 |
//// selectionStyle.selectionBgColor = GUIHelper.getColor(217, 232, 251); |
|
205 |
//// selectionStyle.selectionFgColor = GUIHelper.COLOR_BLACK; |
|
206 |
//// selectionStyle.anchorBorderStyle = new BorderStyle(1, GUIHelper.COLOR_DARK_GRAY, LineStyleEnum.SOLID); |
|
207 |
//// selectionStyle.anchorBgColor = GUIHelper.getColor(65, 113, 43); |
|
208 |
// selectionStyle.selectedHeaderBgColor = GUIHelper.getColor(156, 209, 103); |
|
209 |
// |
|
210 |
// // Add all style configurations to NatTable |
|
211 |
// natTable.addConfiguration(natTableConfiguration); |
|
212 |
// natTable.addConfiguration(rowStyleConfiguration); |
|
213 |
// natTable.addConfiguration(selectionStyle); |
|
214 |
// |
|
215 |
// // Column/Row header style and custom painters |
|
216 |
// DefaultRowHeaderStyleConfiguration rowHeaderConfig = new DefaultRowHeaderStyleConfiguration(); |
|
217 |
// Color rowColumnColor = GUIHelper.getColor(230, 255, 255); |
|
218 |
// rowHeaderConfig.bgColor = rowColumnColor; |
|
219 |
// natTable.addConfiguration(rowHeaderConfig); |
|
220 |
// DefaultColumnHeaderStyleConfiguration columnHeaderStyle = new DefaultColumnHeaderStyleConfiguration(); |
|
221 |
// columnHeaderStyle.bgColor = rowColumnColor; |
|
222 |
// columnHeaderStyle.font = GUIHelper.getFont(new FontData("Verdana", 9, SWT.BOLD)); //$NON-NLS-1$ |
|
223 |
// natTable.addConfiguration(columnHeaderStyle); |
|
224 | 183 |
|
225 | 184 |
} |
226 | 185 |
|
... | ... | |
253 | 212 |
*/ |
254 | 213 |
registerHandlersAndListeners(topMostLayer); |
255 | 214 |
|
215 |
//grab all space |
|
256 | 216 |
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable); |
257 | 217 |
|
218 |
//update label to current data set |
|
258 | 219 |
toolbar.getWsLabel().setText(descriptiveDataSet.getLabel()); |
259 | 220 |
toolbar.getWsLabel().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
260 | 221 |
toolbar.getWsLabel().getParent().layout(); |
261 | 222 |
|
223 |
//initial freeze of supplemental columns |
|
262 | 224 |
freezeSupplementalColumns(true); |
263 | 225 |
|
264 | 226 |
this.layout(); |
... | ... | |
451 | 413 |
topMostLayer.registerCommandHandler(new ExportCommandHandler(topMostLayer)); |
452 | 414 |
|
453 | 415 |
//propagate single cell selection |
454 |
natTable.addLayerListener(new ILayerListener() { |
|
455 |
@Override |
|
456 |
public void handleLayerEvent(ILayerEvent event) { |
|
457 |
if(event instanceof CellSelectionEvent){ |
|
458 |
CellSelectionEvent cellSelectionEvent = (CellSelectionEvent)event; |
|
459 |
int columnPosition = cellSelectionEvent.getColumnPosition(); |
|
460 |
if(columnPosition>LEADING_COLUMN_COUNT){ |
|
461 |
Collection<ILayerCell> selectedCells = cellSelectionEvent.getSelectionLayer().getSelectedCells(); |
|
462 |
StructuredSelection selection = new StructuredSelection(); |
|
463 |
if(selectedCells.size()==1){ |
|
464 |
ILayerCell cell = selectedCells.iterator().next(); |
|
465 |
Object dataValue = cell.getDataValue(); |
|
466 |
if(dataValue!=null){ |
|
467 |
selection = new StructuredSelection(dataValue); |
|
468 |
} |
|
469 |
} |
|
470 |
part.getSelectionService().setSelection(selection); |
|
471 |
} |
|
472 |
} |
|
473 |
} |
|
474 |
}); |
|
416 |
natTable.addLayerListener(new CellSelectionListener(part)); |
|
475 | 417 |
|
476 | 418 |
//register handler for view configuration menu |
477 | 419 |
natTable.registerCommandHandler(toolbar.getDisplayPersistenceDialogCommandHandler()); |
Also available in: Unified diff
Refactor character matrix