Skip to content

Commit

Permalink
Merge pull request #1535 from lorenzgerber/time_range_label_cycling
Browse files Browse the repository at this point in the history
Implement #1534 TimeRange Label cycling option
  • Loading branch information
eselmeister authored Oct 18, 2023
2 parents 4366093 + cf9aba4 commit ef29f58
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
* Contributors:
* Philip Wenig - initial API and implementation
* Lorenz Gerber - Time Range Label Cycling
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.ranges;

Expand Down Expand Up @@ -46,6 +47,7 @@ public class TimeRangesChart extends ChromatogramPeakChart {
private TimeRange timeRange = null;
private TimeRanges timeRanges = null;
private TimeRangeLabels timeRangeLabels = new TimeRangeLabels();
private String timeRangeLabelCycling = null;
//
private ITimeRangeUpdateListener timeRangeUpdateListener = null;
private ITimeRangePeakListener timeRangePeakListener = null;
Expand Down Expand Up @@ -104,6 +106,11 @@ public void select(TimeRange timeRange) {
fireUpdateTimeRange(timeRange);
}

public void setTimeRangeLabelCycling(String cycling) {

this.timeRangeLabelCycling = cycling;
}

@Override
public void handleKeyDownEvent(Event event) {

Expand Down Expand Up @@ -275,6 +282,16 @@ private void adjustTimeRange(Event event) {
* Add a new TimeRange
*/
if(timeRanges != null && !getBaseChart().getSeriesIds().isEmpty()) {
if(timeRangeLabelCycling != null) {
int testCounter = 0;
boolean exists = true;
while(exists == true) {
testCounter += 1;
String testLabel = new StringBuilder("Range (" + timeRangeLabelCycling + ") " + testCounter).toString();
exists = timeRanges.keySet().stream().anyMatch(x -> x.equals(testLabel));
}
timeRangeLabels = new TimeRangeLabels(timeRangeLabelCycling, new StringBuilder("Range (" + timeRangeLabelCycling + ") " + testCounter).toString());
}
TimeRangeDialog timeRangeDialog = new TimeRangeDialog(event.display.getActiveShell(), timeRangeLabels, new IInputValidator() {

@Override
Expand Down

0 comments on commit ef29f58

Please sign in to comment.