List of usage examples for org.eclipse.jface.viewers ViewerCell getElement
public Object getElement()
From source file:net.tourbook.preferences.PrefPageTourTypeFilterList.java
License:Open Source License
private void createUI_20_TourTypeViewer(final Composite parent) { final TableLayoutComposite layouter = new TableLayoutComposite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).hint(200, SWT.DEFAULT).applyTo(layouter); final Table table = new Table(layouter, (SWT.CHECK | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION)); table.setHeaderVisible(false);//from w w w . ja v a2 s .c om table.setLinesVisible(false); _tourTypeViewer = new CheckboxTableViewer(table); TableViewerColumn tvc; // column: name tvc = new TableViewerColumn(_tourTypeViewer, SWT.NONE); tvc.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourType tourType = ((TourType) cell.getElement()); cell.setText(tourType.getName()); cell.setImage(UI.getInstance().getTourTypeImage(tourType.getTypeId())); } }); layouter.addColumnData(new ColumnWeightData(1)); _tourTypeViewer.setContentProvider(new IStructuredContentProvider() { @Override public void dispose() { } @Override public Object[] getElements(final Object inputElement) { return _tourTypes.toArray(); } @Override public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { } }); _tourTypeViewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(final CheckStateChangedEvent event) { _isModified = true; } }); _tourTypeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { onSelectTourType(); } }); _tourTypeViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent event) { /* * invert check state */ final TourType tourType = (TourType) ((StructuredSelection) _tourTypeViewer.getSelection()) .getFirstElement(); final boolean isChecked = _tourTypeViewer.getChecked(tourType); _tourTypeViewer.setChecked(tourType, !isChecked); // getSelectedTourTypes(); } }); }
From source file:net.tourbook.preferences.PrefPageTourTypes.java
License:Open Source License
/** * create columns//from www.jav a 2 s . c o m */ private void defineAllColumns(final TreeColumnLayout treeLayout, final Tree tree) { final int numberOfHorizontalImages = 4; final int trailingOffset = 10; final int itemHeight = tree.getItemHeight(); final int oneColorWidth = itemHeight + GraphColorPainter.GRAPH_COLOR_SPACING; final int colorImageWidth = (oneColorWidth * numberOfHorizontalImages) + trailingOffset; TreeColumn tc; TreeViewerColumn tvc; /* * 1. column: color item/color definition */ { tvc = new TreeViewerColumn(_tourTypeViewer, SWT.TRAIL); tc = tvc.getColumn(); tvc.setLabelProvider(new StyledCellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof ColorDefinition) { cell.setText(((ColorDefinition) (element)).getVisibleName()); } else if (element instanceof GraphColorItem) { cell.setText(((GraphColorItem) (element)).getName()); } else { cell.setText(UI.EMPTY_STRING); } } }); treeLayout.setColumnData(tc, new ColumnWeightData(1, true)); } /* * 2. column: color for definition/item */ { tvc = new TreeViewerColumn(_tourTypeViewer, SWT.TRAIL); tc = tvc.getColumn(); tvc.setLabelProvider(new StyledCellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof ColorDefinition) { final Image image = _graphColorPainter.drawColorDefinitionImage((ColorDefinition) element, numberOfHorizontalImages); cell.setImage(image); } else if (element instanceof GraphColorItem) { final Image image = _graphColorPainter.drawGraphColorImage(// (GraphColorItem) element, numberOfHorizontalImages); cell.setImage(image); } else { cell.setImage(null); } } }); treeLayout.setColumnData(tc, new ColumnPixelData(colorImageWidth, true)); } }
From source file:net.tourbook.srtm.PrefPageSRTMColors.java
License:Open Source License
/** * column: id//from w w w. j a v a2 s .c o m */ private void defineColumn_ProfileId() { final TableColumnDefinition colDef = new TableColumnDefinition(_columnManager, "profileId", SWT.TRAIL); //$NON-NLS-1$ colDef.setColumnLabel(Messages.profileViewer_column_label_id); colDef.setColumnHeaderText(Messages.profileViewer_column_label_id_header); colDef.setColumnHeaderToolTipText(Messages.profileViewer_column_label_id_tooltip); colDef.setDefaultColumnWidth(_pc.convertWidthInCharsToPixels(10)); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final SRTMProfile vertexList = (SRTMProfile) cell.getElement(); cell.setText(Integer.toString(vertexList.getProfileId())); } }); }
From source file:net.tourbook.srtm.PrefPageSRTMColors.java
License:Open Source License
/** * column: profile name//from ww w . jav a 2 s. co m */ private void defineColumn_ProfileName() { final TableColumnDefinition colDef = new TableColumnDefinition(_columnManager, "profileName", SWT.LEAD); //$NON-NLS-1$ colDef.setColumnLabel(Messages.profileViewer_column_label_name); colDef.setColumnHeaderText(Messages.profileViewer_column_label_name_header); colDef.setColumnHeaderToolTipText(Messages.profileViewer_column_label_name_tooltip); colDef.setDefaultColumnWidth(_pc.convertWidthInCharsToPixels(20)); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final SRTMProfile vertexList = (SRTMProfile) cell.getElement(); cell.setText(vertexList.getProfileName()); } }); }
From source file:net.tourbook.srtm.PrefPageSRTMColors.java
License:Open Source License
/** * column: resolution/*from w w w .j a v a 2 s . co m*/ */ private void defineColumn_Resolution() { final TableColumnDefinition colDef = new TableColumnDefinition(_columnManager, "resolution", SWT.LEAD); //$NON-NLS-1$ colDef.setColumnLabel(Messages.profileViewer_column_label_resolution); colDef.setColumnHeaderText(Messages.profileViewer_column_label_resolution_header); colDef.setColumnHeaderToolTipText(Messages.profileViewer_column_label_resolution_tooltip); colDef.setDefaultColumnWidth(_pc.convertWidthInCharsToPixels(20)); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final SRTMProfile profile = (SRTMProfile) cell.getElement(); cell.setText(getResolutionUI(profile)); } }); }
From source file:net.tourbook.srtm.PrefPageSRTMColors.java
License:Open Source License
/** * column: shadow state/* www . j ava 2 s . c o m*/ */ private void defineColumn_ShadowState() { final TableColumnDefinition colDef = new TableColumnDefinition(_columnManager, "shadowState", SWT.LEAD); //$NON-NLS-1$ colDef.setColumnLabel(Messages.profileViewer_column_label_isShadow); colDef.setColumnHeaderText(Messages.profileViewer_column_label_isShadow_header); colDef.setColumnHeaderToolTipText(Messages.profileViewer_column_label_isShadow_tooltip); colDef.setDefaultColumnWidth(_pc.convertWidthInCharsToPixels(5)); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final SRTMProfile profile = (SRTMProfile) cell.getElement(); cell.setText(profile.isShadowState() ? Messages.app_ui_Y : Messages.app_ui_N); } }); }
From source file:net.tourbook.srtm.PrefPageSRTMColors.java
License:Open Source License
/** * column: shadow value/* w w w . j a v a 2 s . c om*/ */ private void defineColumn_ShadowValue() { final TableColumnDefinition colDef = new TableColumnDefinition(_columnManager, "shadowValue", SWT.LEAD); //$NON-NLS-1$ colDef.setColumnLabel(Messages.profileViewer_column_label_shadowValue); colDef.setColumnHeaderText(Messages.profileViewer_column_label_shadowValue_header); colDef.setColumnHeaderToolTipText(Messages.profileViewer_column_label_shadowValue_tooltip); colDef.setDefaultColumnWidth(_pc.convertWidthInCharsToPixels(10)); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final SRTMProfile profile = (SRTMProfile) cell.getElement(); cell.setText(Float.toString(profile.getShadowValue())); } }); }
From source file:net.tourbook.srtm.PrefPageSRTMColors.java
License:Open Source License
/** * column: image path/*from w ww . ja v a2s. co m*/ */ private void defineColumn_TileImagePath() { final TableColumnDefinition colDef = new TableColumnDefinition(_columnManager, "tileImagePath", SWT.LEAD); //$NON-NLS-1$ colDef.setColumnLabel(Messages.profileViewer_column_label_imagePath); colDef.setColumnHeaderText(Messages.profileViewer_column_label_imagePath_header); colDef.setColumnHeaderToolTipText(Messages.profileViewer_column_label_imagePath_tooltip); colDef.setDefaultColumnWidth(_pc.convertWidthInCharsToPixels(20)); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final SRTMProfile vertexList = (SRTMProfile) cell.getElement(); cell.setText(vertexList.getTilePath()); } }); }
From source file:net.tourbook.tour.DialogMarker.java
License:Open Source License
/** * Column: Description// www. j a va 2s . c o m */ private void defineColumn_Description(final TableColumnLayout tableLayout) { final TableViewerColumn tvc = new TableViewerColumn(_markerViewer, SWT.CENTER); final TableColumn tc = tvc.getColumn(); tc.setText(Messages.Tour_Marker_Column_Description_ShortCut); tc.setToolTipText(Messages.Tour_Marker_Column_Description_Tooltip); tvc.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourMarker tourMarker = (TourMarker) cell.getElement(); final String description = tourMarker.getDescription(); cell.setText(description.length() == 0 ? UI.EMPTY_STRING : UI.SYMBOL_STAR); } }); tableLayout.setColumnData(tc, new ColumnPixelData(_pc.convertWidthInCharsToPixels(4), false)); }
From source file:net.tourbook.tour.DialogMarker.java
License:Open Source License
/** * column: distance km/mi/* w w w .j a va 2 s. c o m*/ */ private void defineColumn_Distance(final TableColumnLayout tableLayout) { final TableViewerColumn tvc = new TableViewerColumn(_markerViewer, SWT.TRAIL); final TableColumn tc = tvc.getColumn(); tc.setText(UI.UNIT_LABEL_DISTANCE); tc.setToolTipText(Messages.Tour_Marker_Column_km_tooltip); tvc.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourMarker tourMarker = (TourMarker) cell.getElement(); final float markerDistance = tourMarker.getDistance(); if (markerDistance == -1) { cell.setText(UI.EMPTY_STRING); } else { cell.setText(_nf3.format(markerDistance / (1000 * net.tourbook.ui.UI.UNIT_VALUE_DISTANCE))); } if (tourMarker.getType() == ChartLabel.MARKER_TYPE_DEVICE) { cell.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } } }); tableLayout.setColumnData(tc, new ColumnPixelData(_pc.convertWidthInCharsToPixels(11), false)); }