@Override protected Composite createViewerToolTipContentArea(Event event, ViewerCell cell, Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); composite.setBackground(rowColorBack); Plugin plugin = (Plugin) cell.getElement(); Hyperlink button = new Hyperlink(composite, SWT.FLAT); button.setText("\uf05A"); button.setFont(fontAwesome); button.setBackground(composite.getBackground()); button.setForeground(rowColorTitle); button.setUnderlined(false); button.addListener (SWT.MouseDown, e -> Program.launch(GLUON_PLUGIN_URL + plugin.getUrl())); button.setToolTipText("Click to access the service's JavaDoc"); Label text = new Label(composite, SWT.LEFT); final String description = plugin.getDescription(); text.setText(description.contains(".") ? description.substring(0, description.indexOf(".")) : description); text.setBackground(composite.getBackground()); text.setForeground(rowColorTitle); composite.pack(); return composite; }
@Override public void update ( final ViewerCell cell ) { final Object ele = cell.getElement (); if ( ele instanceof KeyProviderFactory ) { cell.setText ( ele.toString () ); } else if ( ele instanceof KeyProvider ) { final KeyProvider keyProvider = (KeyProvider)ele; cell.setText ( keyProvider.toString () ); cell.setImage ( keyProvider.isLocked () ? this.locked : null ); } else if ( ele instanceof org.eclipse.scada.sec.ui.providers.Key ) { final org.eclipse.scada.sec.ui.providers.Key key = (org.eclipse.scada.sec.ui.providers.Key)ele; cell.setText ( key.toString () ); cell.setImage ( key.isLocked () ? this.locked : null ); } }
@Override public void update ( final ViewerCell cell ) { final DecoratedEvent event = (DecoratedEvent)cell.getElement (); if ( this.decoration != null ) { switch ( this.decoration ) { case ACTOR: this.labelProviderSupport.decorateWithActorType ( event, cell ); break; case MONITOR: this.labelProviderSupport.decorateWithMonitorState ( event, cell ); break; } } if ( this.key != null && !this.key.isEmpty () ) { cell.setText ( this.labelProviderSupport.toLabel ( event, this.key ) ); } }
public void decorateWithActorType ( final DecoratedEvent event, final ViewerCell cell ) { final String value = Variant.valueOf ( event.getEvent ().getField ( Fields.ACTOR_TYPE ) ).asString ( "" ); if ( "USER".equalsIgnoreCase ( value ) ) //$NON-NLS-1$ { cell.setImage ( this.userImage ); } else if ( "SYSTEM".equalsIgnoreCase ( value ) ) //$NON-NLS-1$ { cell.setImage ( this.systemImage ); } else { cell.setImage ( null ); } }
@Override public void update ( final ViewerCell cell ) { final Object ele = cell.getElement (); if ( ele instanceof GroupEntry ) { cell.setText ( String.format ( Messages.FlagsDetailsPart_GroupSumFormat, ( (GroupEntry)ele ).getActiveCount (), ( (GroupEntry)ele ).getCount () ) ); } else if ( ele instanceof AttributeEntry ) { final StyledString str = new StyledString (); if ( ( (AttributeEntry)ele ).isActive () ) { str.append ( Messages.FlagsDetailsPart_ActiveMarker, this.activeStyler ); } else { str.append ( Messages.FlagsDetailsPart_InactiveMarker, this.inactiveStyler ); } cell.setText ( str.getString () ); cell.setStyleRanges ( str.getStyleRanges () ); } }
@Override public void update ( final ViewerCell cell ) { final ConfigurationDescriptor cfg = (ConfigurationDescriptor)cell.getElement (); switch ( cell.getColumnIndex () ) { case 0: cell.setText ( cfg.getConfigurationInformation ().getId () ); break; case 1: cell.setText ( "" + cfg.getConfigurationInformation ().getState () ); break; } if ( cfg.getConfigurationInformation ().getErrorInformation () != null ) { cell.setBackground ( Display.getCurrent ().getSystemColor ( SWT.COLOR_RED ) ); } else { cell.setBackground ( null ); } super.update ( cell ); }
@Override public void update ( final ViewerCell cell ) { final Entry entry = (Entry)cell.getElement (); switch ( cell.getColumnIndex () ) { case 0: cell.setText ( entry.getHandlerName () ); break; case 1: cell.setText ( entry.getState ().toString () ); break; case 2: final String errorText = makeError ( entry.getError () ); // only update when we have an error to prevent // the error from disapearing if ( errorText != null ) { cell.setText ( errorText ); } break; } }
private void updateAttributePair ( final AttributePair attributePair, final ViewerCell cell ) { switch ( cell.getColumnIndex () ) { case 0: cell.setText ( attributePair.key ); break; case 2: if ( attributePair.value != null ) { cell.setText ( attributePair.value.getType ().name () ); } break; case 3: if ( attributePair.value != null ) { cell.setText ( attributePair.value.asString ( "<null>" ) ); //$NON-NLS-1$ } break; default: break; } }
@Override public void update ( final ViewerCell cell ) { final Object element = cell.getElement (); if ( element instanceof TreeNode ) { final TreeNode node = (TreeNode)element; cell.setText ( node.getName () ); final CurrentStyle style = node.getStyle (); cell.setImage ( style.image ); cell.setFont ( style.font ); cell.setForeground ( style.foreground ); cell.setBackground ( style.background ); } }
protected void update ( final ViewerCell cell, final ServerEndpoint element ) { final StyledString str = new StyledString (); final boolean running = element.isRunning (); str.append ( element.getLabel () ); cell.setText ( str.getString () ); cell.setStyleRanges ( str.getStyleRanges () ); if ( element.getError () != null ) { cell.setImage ( this.errorImage ); } else { cell.setImage ( running ? this.runningImage : this.stoppedImage ); } }
@SuppressWarnings("unchecked") private RankedItem<T> applyCellDefaultStyles(final ColumnOptions<T> options, ViewerCell cell) { final RankedItem<T> rankedItem = (RankedItem<T>) cell.getElement(); cell.setForeground(fromRegistry(options.getFontColor())); int rowState = rowStateResolver.apply(rankedItem); if ((rowState & RowState.SELECTED.value) != 0 && options.isEnableBackgroundSelection()) { cell.setBackground(fromRegistry(new RGB(225,226,206))); } else { cell.setBackground(fromRegistry(options.getBackgroundColor())); } if ((rowState & RowState.CURSOR.value) != 0 && options.isEnableBackgroundSelection()) { cell.setBackground(fromRegistry(ColorUtil.blend(cell.getBackground().getRGB(), new RGB(200,200,200)))); } Font font = createColumnFont(options, cell); cell.setFont(font); return rankedItem; }
@Override public void update(ViewerCell cell) { TableItem item = (TableItem) cell.getItem(); Pattern pattern = Pattern.compile("^[a-zA-Z0-9 _]*$"); if (!pattern.matcher(((InputField)cell.getElement()).getFieldName()).matches()) { item.setBackground(cell.getControl().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); item.setForeground(cell.getControl().getDisplay().getSystemColor(SWT.COLOR_RED)); ((InputField)cell.getElement()).getErrorObject().setErrorMessage("Input field should match regular expression- \"^[a-zA-Z0-9_]*$\" "); ((InputField)cell.getElement()).getErrorObject().setHasError(true); }else{ if(((InputField)cell.getElement()).getFieldName().trim().equalsIgnoreCase("")){ item.setBackground(cell.getControl().getDisplay().getSystemColor(SWT.COLOR_RED)); ((InputField)cell.getElement()).getErrorObject().setErrorMessage("Input field should not be empty"); ((InputField)cell.getElement()).getErrorObject().setHasError(true); }else{ ((InputField)cell.getElement()).getErrorObject().setHasError(false); } } super.update(cell); }
private void setStyledText(ViewerCell cell, TreeObject obj) { /* Calcul du texte. */ String mainText = obj.getMainText(); if (mainText == null) { return; } String subText = obj.getSubText(); String subTextFinal = subText == null ? "" : (" : " + subText); String fullText = mainText + subTextFinal; cell.setText(fullText); /* Calcul du style. */ List<StyleRange> styles = new ArrayList<>(); StyleRange styleMainText = new StyleRange(0, mainText.length(), null, null); styles.add(styleMainText); if (!subTextFinal.isEmpty()) { Display display = Display.getCurrent(); Color blue = display.getSystemColor(SWT.COLOR_DARK_YELLOW); StyleRange styleSubText = new StyleRange(mainText.length(), subTextFinal.length(), blue, null); styles.add(styleSubText); } cell.setStyleRanges(styles.toArray(new StyleRange[0])); }
@Override public void update(ViewerCell cell) { AvroNode node = nodeConverter.convertToAvroNode(cell.getElement()); String text = labelProvider.getText(node); Image image = labelProvider.getImage(node); StyleRange[] styleRanges = labelProvider.getStyleRanges(node); cell.setText(text); cell.setImage(image); cell.setStyleRanges(styleRanges); Color backgroundColor = labelProvider.getBackgroundColor(node); if (backgroundColor != null) { cell.setBackground(backgroundColor); } super.update(cell); }
@Override protected void focusCellChanged(final ViewerCell newCell, final ViewerCell oldCell) { super.focusCellChanged(newCell, oldCell); /* * When the focus is changed, we merely tell the table to redraw the * affected row(s). */ if (newCell != null) { newCell.getViewerRow().getControl().redraw(); } if (oldCell != null) { oldCell.getViewerRow().getControl().redraw(); } }
public static final Point getFocusCellIndex(final TableViewer viewer) { try { if (viewer.getColumnViewerEditor() != null) { final ViewerCell focusCell = viewer.getColumnViewerEditor().getFocusCell(); if (focusCell != null) { final int x = focusCell.getColumnIndex(); final int y = viewer.getTable().indexOf((TableItem) focusCell.getItem()); return new Point(x, y); } } } catch (final Exception e) { log.warn("Could not determine cell index", e); //$NON-NLS-1$ } return new Point(-1, -1); }
@Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof ImportEclipseProject) { final ImportEclipseProject project = (ImportEclipseProject) element; if (project.isDamaged()) { cell.setText(Messages.getString("GitImportWizardSelectProjectsPage.ProjectDamaged")); //$NON-NLS-1$ setCellFontStyle(cell, SWT.ITALIC); } else { cell.setText(project.getProjectName()); } if (!canImport(project)) { setCellForeground(cell, SWT.COLOR_GRAY); } } }
public void update(ViewerCell cell) { Object element = cell.getElement(); if (!(element instanceof ItemsListSeparator) && provider instanceof IStyledLabelProvider) { IStyledLabelProvider styledLabelProvider = (IStyledLabelProvider) provider; StyledString styledString = getStyledText(element, styledLabelProvider); cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(styledLabelProvider.getImage(element)); } else { cell.setText(getText(element)); cell.setImage(getImage(element)); } cell.setFont(getFont(element)); cell.setForeground(getForeground(element)); cell.setBackground(getBackground(element)); super.update(cell); }
private void hookListener(final ColumnViewer viewer) { Listener listener = new Listener() { @Override public void handleEvent(Event event) { if ((event.detail & SWT.SELECTED) > 0) { ViewerCell focusCell = getFocusCell(); ViewerRow row = focusCell.getViewerRow(); Assert.isNotNull(row, "Internal structure invalid. Item without associated row is not possible."); //$NON-NLS-1$ ViewerCell cell = row.getCell(event.index); if (focusCell == null || !cell.equals(focusCell)) { removeSelectionInformation(event, cell); } else { markFocusedCell(event, cell); } } } }; viewer.getControl().addListener(SWT.EraseItem, listener); }
/** * Column: Device name */ private void defineColumn_Device_Name() { final TreeColumnDefinition colDef = TreeColumnFactory.DEVICE_NAME.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); final String dbValue = ((TVITourBookItem) element).col_DeviceName; if (dbValue == null) { cell.setText(UI.EMPTY_STRING); } else { cell.setText(dbValue); } setCellColor(cell, element); } }); }
/** * column: image direction degree */ 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)); } } }); }
/** * Column: Gear ratio */ private void defineColumn_Powertrain_GearRatio() { final ColumnDefinition colDef = TableColumnFactory.POWERTRAIN_GEAR_RATIO.createColumn(_sliceColumnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { if (_serieGears == null) { cell.setText(UI.EMPTY_STRING); } else { final int serieIndex = ((TimeSlice) cell.getElement()).serieIndex; final float gearRatio = _serieGears[0][serieIndex]; cell.setText(_nf2.format(gearRatio)); } } }); }
/** * column: import file path */ private void defineColumn_Data_ImportFilePath() { final ColumnDefinition colDef = TableColumnFactory.DATA_IMPORT_FILE_PATH.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourData tourData = (TourData) cell.getElement(); final String importFilePath = tourData.getImportFilePath(); if (importFilePath != null) { cell.setText(importFilePath); } } }); }
/** * column: avg pulse */ private void defineColumn_Body_AvgPulse() { final TreeColumnDefinition colDef = TreeColumnFactory.BODY_PULSE_AVG.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); final double value = ((TVITourBookItem) element).colAvgPulse; colDef.printDoubleValue(cell, value, element instanceof TVITourBookTour); setCellColor(cell, element); } }); }
/** * column: number of photos */ private void defineColumn_Tour_Photos() { final TreeColumnDefinition colDef = TreeColumnFactory.TOUR_NUM_PHOTOS.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); final int value = ((TVICollatedTour) element).colNumberOfPhotos; colDef.printValue_0(cell, value); setCellColor(cell, element); } }); }
/** * Column: Altitude segment up */ private void defineColumn_Altitude_Segment_Up(final SelectionAdapter defaultColumnSelectionListener) { final ColumnDefinition colDef; colDef = TableColumnFactory.ALTITUDE_ELEVATION_SEGMENT_UP.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setColumnSelectionListener(defaultColumnSelectionListener); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourSegment segment = (TourSegment) cell.getElement(); final double value = segment.altitude_Segment_Up; colDef.printValue_0(cell, value); if (segment.isTotal) { setTotalStyle(cell); } } }); }
/** * Column: Description */ private void defineColumn_Waypoint_Description() { final ColumnDefinition colDef = TableColumnFactory.WAYPOINT_DESCRIPTION.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourMarker marker = (TourMarker) cell.getElement(); cell.setText(marker.getDescription()); } }); }
/** * column: import file name */ private void defineColumn_Data_ImportFileName() { final ColumnDefinition colDef = TableColumnFactory.DATA_IMPORT_FILE_NAME.createColumn(_columnManager, _pc); colDef.setColumnSelectionListener(_columnSortListener); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourData tourData = (TourData) cell.getElement(); final String importFileName = tourData.getImportFileName(); if (importFileName != null) { cell.setText(importFileName); } } }); _columnId_ImportFileName = colDef.getColumnId(); }
/** * column: altitude up (m) */ private void defineColumn_Altitude_Up() { final TreeColumnDefinition colDef = TreeColumnFactory.ALTITUDE_UP.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof TVITagViewTagCategory) { return; } final long dbAltitudeUp = ((TVITagViewItem) element).colAltitudeUp; final double value = dbAltitudeUp / UI.UNIT_VALUE_ALTITUDE; colDef.printValue_0(cell, value); setCellColor(cell, element); } }); }
public void editElement(Object element, int column) { if (element instanceof TreePath) { setSelection(new TreeSelection((TreePath) element)); GalleryItem[] items = gallery.getSelection(); if (items.length == 1) { ViewerRow row = getViewerRowFromItem(items[0]); if (row != null) { ViewerCell cell = row.getCell(column); if (cell != null) { getControl().setRedraw(false); triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell)); getControl().setRedraw(true); } } } } else { super.editElement(element, column); } }
/** * column: number of photos */ private void defineColumn_Tour_Photos() { final TreeColumnDefinition colDef = TreeColumnFactory.TOUR_NUM_PHOTOS.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); final int value = ((TVITourBookItem) element).colNumberOfPhotos; colDef.printValue_0(cell, value); setCellColor(cell, element); } }); }
/** * column: altitude down (m) */ private void defineColumn_Altitude_Down() { final TreeColumnDefinition colDef = TreeColumnFactory.ALTITUDE_DOWN.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof TVITagViewTagCategory) { return; } final double dbAltitudeDown = ((TVITagViewItem) element).colAltitudeDown; final double value = -dbAltitudeDown / UI.UNIT_VALUE_ALTITUDE; colDef.printValue_0(cell, value); setCellColor(cell, element); } }); }
/** * column: avg temperature */ private void defineColumn_Weather_AvgTemperature() { final TreeColumnDefinition colDef = TreeColumnFactory.WEATHER_AVG_TEMPERATURE.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); float value = ((TVICollatedTour) element).colAvgTemperature; if (net.tourbook.ui.UI.UNIT_VALUE_TEMPERATURE != 1) { value = value // * net.tourbook.ui.UI.UNIT_FAHRENHEIT_MULTI + net.tourbook.ui.UI.UNIT_FAHRENHEIT_ADD; } colDef.printDoubleValue(cell, value, element instanceof TVITourBookTour); setCellColor(cell, element); } }); }
/** * column: time interval */ private void defineColumn_Data_TimeInterval() { final TreeColumnDefinition colDef = TreeColumnFactory.DATA_TIME_INTERVAL.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof TVICompareResultComparedTour) { cell.setText(Integer.toString(((TVICompareResultComparedTour) element).timeIntervall)); setCellColor(cell, element); } } }); }
/** * column: avg cadence */ private void defineColumn_Powertrain_AvgCadence() { final TreeColumnDefinition colDef = TreeColumnFactory.POWERTRAIN_AVG_CADENCE.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); final float value = ((TVICollatedTour) element).colAvgCadence; colDef.printDoubleValue(cell, value, element instanceof TVICollatedTour_Tour); setCellColor(cell, element); } }); }
/** * @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell) */ @Override public void update(final ViewerCell cell) { final CSVRow element = (CSVRow) cell.getElement(); final int index = cell.getColumnIndex(); final String columnText = getColumnText(element, index); cell.setText(columnText); cell.setImage(null); if (searchText != null && searchText.length() > 0) { final int intRangesCorrectSize[] = SearchResultStyle.getSearchTermOccurrences(searchText, columnText); final List<StyleRange> styleRange = new ArrayList<StyleRange>(); for (int i = 0; i < intRangesCorrectSize.length / 2; i++) { final StyleRange myStyleRange = new StyleRange(0, 0, null, searchColor); myStyleRange.start = intRangesCorrectSize[i]; myStyleRange.length = intRangesCorrectSize[++i]; styleRange.add(myStyleRange); } cell.setStyleRanges(styleRange.toArray(new StyleRange[styleRange.size()])); } else { cell.setStyleRanges(null); } super.update(cell); }
/** * column: week year */ private void defineColumn_Time_WeekYear() { final TreeColumnDefinition colDef = TreeColumnFactory.TIME_WEEKYEAR.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); final int week = ((TVITourBookItem) element).colWeekYear; if (week == 0) { cell.setText(UI.EMPTY_STRING); } else { cell.setText(Integer.toString(week)); } setCellColor(cell, element); } }); }
/** * column: max pulse */ private void defineColumn_Body_MaxPulse() { final TreeColumnDefinition colDef = TreeColumnFactory.BODY_PULSE_MAX.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); if (element instanceof TVITagViewTagCategory) { return; } final long value = ((TVITagViewItem) element).colMaxPulse; colDef.printValue_0(cell, value); setCellColor(cell, element); } }); }
/** * column: pace difference */ private void defineColumn_Motion_AvgPace_Difference() { final ColumnDefinition colDef; colDef = TableColumnFactory.MOTION_AVG_PACE_DIFFERENCE.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourSegment segment = (TourSegment) cell.getElement(); final float paceDiff = segment.pace_Diff; if (paceDiff == 0) { cell.setText(UI.EMPTY_STRING); } else { cell.setText(net.tourbook.common.UI.format_mm_ss((long) paceDiff)); } } }); }
/** * Column: Altitude segment down */ private void defineColumn_Altitude_Segment_Down(final SelectionAdapter defaultColumnSelectionListener) { final ColumnDefinition colDef; colDef = TableColumnFactory.ALTITUDE_ELEVATION_SEGMENT_DOWN.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setColumnSelectionListener(defaultColumnSelectionListener); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourSegment segment = (TourSegment) cell.getElement(); final double value = segment.altitude_Segment_Down; colDef.printValue_0(cell, value); if (segment.isTotal) { setTotalStyle(cell); } } }); }