List of usage examples for org.eclipse.jface.viewers ViewerCell getElement
public Object getElement()
From source file:net.tourbook.map3.ui.Map3LayerUI.java
License:Open Source License
/** * column: marker/*from w w w. j a va2 s .com*/ */ private void defineColumn_Opacity(final TreeColumnLayout treeLayout) { final TreeViewerColumn tvc = new TreeViewerColumn(_layerViewer, SWT.CENTER); final TreeColumn tc = tvc.getColumn(); tc.setText(Messages.Map3Layer_Viewer_Column_Opacity); tc.setToolTipText(Messages.Map3Layer_Viewer_Column_Opacity_Tooltip); _opacityEditingSupport = new OpacityEditingSupport(_layerViewer); tvc.setEditingSupport(_opacityEditingSupport); tvc.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof TVIMap3Layer) { final TVIMap3Layer layerItem = (TVIMap3Layer) element; final float opacity = layerItem.getOpacity(); final String opacityText; if (layerItem.canSetOpacity()) { if (layerItem.isLayerVisible) { if (opacity == 1.0) { opacityText = UI.SYMBOL_FULL_BLOCK; } else { opacityText = _nf2.format(opacity); } } else { // layer is hidden opacityText = UI.EMPTY_STRING; } } else { // opacity cannot be set opacityText = OPACITY_CAN_NOT_BE_SET; } cell.setText(opacityText); } } }); treeLayout.setColumnData(tc, new ColumnPixelData(_pc.convertWidthInCharsToPixels(8), false)); }
From source file:net.tourbook.photo.ImageGallery.java
License:Open Source License
/** * column: width x height/*from w w w . j a va 2s. c o m*/ */ private void defineColumn_Dimension() { final ColumnDefinition colDef = TableColumnFactory.PHOTO_FILE_DIMENSION.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Photo photo = (Photo) cell.getElement(); cell.setText(photo.getDimensionText()); } }); }
From source file:net.tourbook.photo.ImageGallery.java
License:Open Source License
/** * column: tour start time//from w w w . j av a 2 s . c o m */ private void defineColumn_ExifTime() { final ColumnDefinition colDef = TableColumnFactory.PHOTO_FILE_TIME.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Photo photo = (Photo) cell.getElement(); cell.setText(TimeTools.getZonedDateTime(photo.imageExifTime).format(TimeTools.Formatter_Time_M)); } }); }
From source file:net.tourbook.photo.ImageGallery.java
License:Open Source License
/** * column: image direction degree/*w ww.j a v a 2s . c o m*/ */ private void defineColumn_ImageDirectionDegree() { final ColumnDefinition colDef = TableColumnFactory.PHOTO_FILE_IMAGE_DIRECTION_DEGREE// .createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Photo photo = (Photo) cell.getElement(); final double imageDirection = photo.getImageDirection(); if (imageDirection == Double.MIN_VALUE) { cell.setText(UI.EMPTY_STRING); } else { cell.setText(Integer.toString((int) imageDirection)); } } }); }
From source file:net.tourbook.photo.ImageGallery.java
License:Open Source License
/** * column: image direction degree/*from w w w. j av a 2 s . co m*/ */ private void defineColumn_ImageDirectionText() { final ColumnDefinition colDef = TableColumnFactory.PHOTO_FILE_IMAGE_DIRECTION_TEXT// .createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Photo photo = (Photo) cell.getElement(); final double imageDirection = photo.getImageDirection(); if (imageDirection == Double.MIN_VALUE) { cell.setText(UI.EMPTY_STRING); } else { final int imageDirectionInt = (int) imageDirection; cell.setText(getDirectionText(imageDirectionInt)); } } }); }
From source file:net.tourbook.photo.ImageGallery.java
License:Open Source License
/** * column: name/*from w ww .jav a2 s. co m*/ */ private void defineColumn_ImageFileName() { final ColumnDefinition colDef = TableColumnFactory.PHOTO_FILE_NAME.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Photo photo = (Photo) cell.getElement(); cell.setText(photo.imageFileName); } }); }
From source file:net.tourbook.photo.ImageGallery.java
License:Open Source License
/** * column: location/*from www.j a va 2 s .com*/ */ private void defineColumn_Location() { final ColumnDefinition colDef = TableColumnFactory.PHOTO_FILE_LOCATION.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Photo photo = (Photo) cell.getElement(); cell.setText(photo.getGpsAreaInfo()); } }); }
From source file:net.tourbook.photo.ImageGallery.java
License:Open Source License
/** * column: orientation// www . ja v a 2s . co m */ private void defineColumn_Orientation() { final ColumnDefinition colDef = TableColumnFactory.PHOTO_FILE_ORIENTATION.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Photo photo = (Photo) cell.getElement(); cell.setText(Integer.toString(photo.getOrientation())); } }); }
From source file:net.tourbook.photo.internal.PicDirFolder.java
License:Open Source License
private void createUI_10_TreeView(final Composite parent) { /*/*from www.j ava 2 s.c om*/ * create tree layout */ final Composite layoutContainer = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults()// .grab(true, true).hint(200, 100).applyTo(layoutContainer); final TreeColumnLayout treeLayout = new TreeColumnLayout(); layoutContainer.setLayout(treeLayout); /* * create viewer */ final Tree tree = new Tree(layoutContainer, SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION); tree.setHeaderVisible(false); tree.addMouseListener(new MouseAdapter() { @Override public void mouseDown(final MouseEvent e) { _doAutoCollapseExpand = true; _isMouseContextMenu = e.button == 3; } }); _folderViewer = new TreeViewer(tree); _folderViewer.setContentProvider(new FolderContentProvider()); _folderViewer.setComparer(new FolderComparer()); _folderViewer.setUseHashlookup(true); _folderViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(final DoubleClickEvent event) { // expand/collapse current item final Object selection = ((IStructuredSelection) _folderViewer.getSelection()).getFirstElement(); final TVIFolderFolder treeItem = (TVIFolderFolder) selection; expandCollapseFolder(treeItem); } }); _folderViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { onSelectFolder((ITreeSelection) event.getSelection()); } }); /* * create columns */ TreeViewerColumn tvc; TreeColumn tvcColumn; // column: os folder tvc = new TreeViewerColumn(_folderViewer, SWT.TRAIL); tvcColumn = tvc.getColumn(); tvc.setLabelProvider(new StyledCellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof TVIFolderFolder) { final TVIFolderFolder folderItem = (TVIFolderFolder) element; final StyledString styledString = new StyledString(); styledString.append(folderItem._folderName); if (_isStateShowFileFolderInFolderItem) { if (folderItem.isFolderLoaded()) { final int folderCounter = folderItem.getFolderCounter(); if (folderCounter > 0) { styledString.append(UI.SPACE2); styledString.append(Integer.toString(folderCounter), PhotoUI.PHOTO_FOLDER_STYLER); } final int fileCounter = folderItem.getFileCounter(); if (fileCounter > 0) { styledString.append(net.tourbook.common.UI.SPACE2); styledString.append(Integer.toString(fileCounter), PhotoUI.PHOTO_FILE_STYLER); } } else { // force that file list is loaded and number of files is available putFolderInWaitingQueue(folderItem, false); styledString.append(UI.SPACE2 + Messages.Pic_Dir_StatusLable_LoadingFolder_InFolderTree, PhotoUI.PHOTO_FOLDER_STYLER); } } cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); } } }); treeLayout.setColumnData(tvcColumn, new ColumnWeightData(100, true)); }
From source file:net.tourbook.preferences.PrefPageAppearanceColors.java
License:Open Source License
/** * create columns/*from w ww. j a va2 s . c o m*/ */ private void defineAllColumns(final TreeColumnLayout treeLayout, final Tree tree) { final int numberOfHorizontalImages = 5; final int trailingOffset = 10; final int itemHeight = tree.getItemHeight(); final int colorWidth = (itemHeight + GraphColorPainter.GRAPH_COLOR_SPACING) * numberOfHorizontalImages + trailingOffset; TreeColumn tc; TreeViewerColumn tvc; // 1. column: color item/color definition tvc = new TreeViewerColumn(_colorViewer, 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(_colorViewer, 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.setImage(_graphColorPainter.drawColorDefinitionImage((ColorDefinition) element, numberOfHorizontalImages)); } else if (element instanceof GraphColorItem) { cell.setImage(_graphColorPainter.drawGraphColorImage(// (GraphColorItem) element, numberOfHorizontalImages)); } else { cell.setImage(null); } } }); treeLayout.setColumnData(tc, new ColumnPixelData(colorWidth, true)); }