Skip to content

Commit

Permalink
Fixed #182 - Peak Identifier [Template] - upgrade to new editor style
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Jan 5, 2022
1 parent f059078 commit 22d502f
Show file tree
Hide file tree
Showing 10 changed files with 249 additions and 184 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Lablicate GmbH.
* Copyright (c) 2018, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -71,4 +71,4 @@ protected void adjustForNumColumns(int numColumns) {
gridData.grabExcessHorizontalSpace = true;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Lablicate GmbH.
* Copyright (c) 2018, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -22,6 +22,7 @@ public class PeakIdentifierFieldEditor extends AbstractFieldEditor {
private TemplatePeakIdentifierEditor editor;

public PeakIdentifierFieldEditor(String name, String labelText, Composite parent) {

init(name, labelText);
createControl(parent);
}
Expand Down Expand Up @@ -70,4 +71,4 @@ protected void adjustForNumColumns(int numColumns) {
gridData.grabExcessHorizontalSpace = true;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 Lablicate GmbH.
* Copyright (c) 2020, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -71,4 +71,4 @@ protected void adjustForNumColumns(int numColumns) {
gridData.grabExcessHorizontalSpace = true;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2021 Lablicate GmbH.
* Copyright (c) 2018, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -110,13 +110,12 @@ protected void setValue(Object element, Object value) {
setting.setReferenceIdentifier(referenceIdentifier);
break;
case PeakDetectorLabelProvider.NAME:
String name = ((String)value).trim();
setting.setName(name);
setting.setName(((String)value).trim());
break;
}
//
tableViewer.refresh();
tableViewer.updateContent();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2019 Lablicate GmbH.
* Copyright (c) 2018, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -11,21 +11,23 @@
*******************************************************************************/
package net.openchrom.xxd.process.supplier.templates.ui.internal.provider;

import org.eclipse.chemclipse.support.ui.swt.ExtendedTableViewer;
import org.eclipse.chemclipse.model.cas.CasSupport;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TextCellEditor;

import net.openchrom.xxd.process.supplier.templates.model.IdentifierSetting;
import net.openchrom.xxd.process.supplier.templates.ui.swt.PeakIdentifierListUI;
import net.openchrom.xxd.process.supplier.templates.util.PeakIdentifierValidator;

public class PeakIdentifierEditingSupport extends EditingSupport {

private CellEditor cellEditor;
private ExtendedTableViewer tableViewer;
private PeakIdentifierListUI tableViewer;
private String column;

public PeakIdentifierEditingSupport(ExtendedTableViewer tableViewer, String column) {
public PeakIdentifierEditingSupport(PeakIdentifierListUI tableViewer, String column) {

super(tableViewer);
this.column = column;
this.cellEditor = new TextCellEditor(tableViewer.getTable());
Expand Down Expand Up @@ -80,7 +82,6 @@ protected void setValue(Object element, Object value) {
if(element instanceof IdentifierSetting) {
IdentifierSetting setting = (IdentifierSetting)element;
double result;
String text;
switch(column) {
/*
* Do not edit the name
Expand All @@ -102,28 +103,16 @@ protected void setValue(Object element, Object value) {
}
break;
case PeakIdentifierLabelProvider.CAS_NUMBER:
text = ((String)value).trim();
if(!"".equals(text)) {
setting.setCasNumber(text);
}
setting.setCasNumber(CasSupport.format(((String)value).trim()));
break;
case PeakIdentifierLabelProvider.COMMENTS:
text = ((String)value).trim();
if(!"".equals(text)) {
setting.setComments(text);
}
setting.setComments(((String)value).trim());
break;
case PeakIdentifierLabelProvider.CONTRIBUTOR:
text = ((String)value).trim();
if(!"".equals(text)) {
setting.setContributor(text);
}
setting.setContributor(((String)value).trim());
break;
case PeakIdentifierLabelProvider.REFERENCE:
text = ((String)value).trim();
if(!"".equals(text)) {
setting.setReference(text);
}
setting.setReference(((String)value).trim());
break;
case PeakIdentifierLabelProvider.TRACES:
String traces = ((String)value).trim();
Expand All @@ -134,13 +123,12 @@ protected void setValue(Object element, Object value) {
}
break;
case PeakIdentifierLabelProvider.REFERENCE_IDENTIFIER:
text = ((String)value).trim();
if(!"".equals(text)) {
setting.setReferenceIdentifier(text);
}
setting.setReferenceIdentifier(((String)value).trim());
break;
}
//
tableViewer.refresh();
tableViewer.updateContent();
}
}

Expand All @@ -154,4 +142,4 @@ private double convertValue(Object value) {
}
return result;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 Lablicate GmbH.
* Copyright (c) 2020, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -11,6 +11,7 @@
*******************************************************************************/
package net.openchrom.xxd.process.supplier.templates.ui.internal.provider;

import org.eclipse.chemclipse.model.cas.CasSupport;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ComboBoxViewerCellEditor;
Expand Down Expand Up @@ -96,10 +97,7 @@ protected void setValue(Object element, Object value) {
setting.setStopRetentionTimeMinutes(convertDouble(value));
break;
case PeakIdentifierLabelProvider.CAS_NUMBER:
String casNumber = ((String)value).trim();
if(!"".equals(casNumber)) {
setting.setCasNumber(casNumber);
}
setting.setCasNumber(CasSupport.format(((String)value).trim()));
break;
case ReportLabelProvider.REPORT_STRATEGY:
if(value instanceof ReportStrategy) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Lablicate GmbH.
* Copyright (c) 2018, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -13,6 +13,7 @@

import java.util.List;

import org.eclipse.chemclipse.model.updates.IUpdateListener;
import org.eclipse.chemclipse.support.ui.provider.ListContentProvider;
import org.eclipse.chemclipse.support.ui.swt.ExtendedTableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
Expand All @@ -32,8 +33,11 @@ public class PeakIdentifierListUI extends ExtendedTableViewer {
private PeakIdentifierLabelProvider labelProvider = new PeakIdentifierLabelProvider();
private PeakIdentifierComparator tableComparator = new PeakIdentifierComparator();
private PeakIdentifierFilter listFilter = new PeakIdentifierFilter();
//
private IUpdateListener updateListener;

public PeakIdentifierListUI(Composite parent, int style) {

super(parent, style);
createColumns();
}
Expand All @@ -44,6 +48,18 @@ public void setSearchText(String searchText, boolean caseSensitive) {
refresh();
}

public void setUpdateListener(IUpdateListener updateListener) {

this.updateListener = updateListener;
}

public void updateContent() {

if(updateListener != null) {
updateListener.update();
}
}

public void clear() {

setInput(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,16 @@ private void applyShift() {
for(AbstractSetting setting : settings) {
switch(positionMarker) {
case RT_MIN_START:
setting.setStartRetentionTime(setting.getStartRetentionTime() + (int)(positionAdjustment * IChromatogram.MINUTE_CORRELATION_FACTOR));
setting.setStartRetentionTime(validateRetentionTime(setting.getStartRetentionTime() + (int)(positionAdjustment * IChromatogram.MINUTE_CORRELATION_FACTOR)));
break;
case RT_MIN_STOP:
setting.setStopRetentionTime(setting.getStopRetentionTime() + (int)(positionAdjustment * IChromatogram.MINUTE_CORRELATION_FACTOR));
setting.setStopRetentionTime(validateRetentionTime(setting.getStopRetentionTime() + (int)(positionAdjustment * IChromatogram.MINUTE_CORRELATION_FACTOR)));
break;
case RT_MS_START:
setting.setStartRetentionTime(setting.getStartRetentionTime() + (int)positionAdjustment);
setting.setStartRetentionTime(validateRetentionTime(setting.getStartRetentionTime() + (int)positionAdjustment));
break;
case RT_MS_STOP:
setting.setStopRetentionTime(setting.getStopRetentionTime() + (int)positionAdjustment);
setting.setStopRetentionTime(validateRetentionTime(setting.getStopRetentionTime() + (int)positionAdjustment));
break;
default:
break;
Expand All @@ -220,6 +220,11 @@ private void applyShift() {
}
}

private int validateRetentionTime(int retentionTime) {

return retentionTime < 0 ? 0 : retentionTime;
}

private void fireUpdate() {

if(updateListener != null) {
Expand Down
Loading

0 comments on commit 22d502f

Please sign in to comment.