Skip to content

Commit

Permalink
Merge pull request #3319 from debrief/hotfix/3315_NPE_for_lightweight
Browse files Browse the repository at this point in the history
Hotfix/3315 npe for lightweight
  • Loading branch information
IanMayo committed Oct 19, 2018
2 parents d279d79 + ca325a8 commit 7ee34fc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
Expand Up @@ -367,7 +367,7 @@ public Object getRawValue()
}
catch (final Exception e)
{
MWC.Utilities.Errors.Trace.trace(e);
MWC.Utilities.Errors.Trace.trace(e, "Exception while getting value for:" + _thisProp.getDisplayName());
}

return res;
Expand Down
Expand Up @@ -66,6 +66,7 @@ public void generate(final IMenuManager parent, final Layers theLayers,
{
Collection<Editable> points = null;
String tmpTitle = null;
TrackWrapper track = null;

// check something was selected
if(subjects.length == 0)
Expand All @@ -81,6 +82,11 @@ public void generate(final IMenuManager parent, final Layers theLayers,
TrackSegment ts = (TrackSegment) thisE;
points = ts.getData();
tmpTitle = "Remove jumps for selected track";

if (ts.getWrapper() instanceof TrackWrapper)
{
track = ts.getWrapper();
}
}
}
else
Expand All @@ -96,24 +102,35 @@ public void generate(final IMenuManager parent, final Layers theLayers,
for (int i = 0; i < subjects.length; i++)
{
Editable editable = subjects[i];

if(track == null)
{
FixWrapper fix = (FixWrapper) editable;
if (fix.getTrackWrapper() instanceof TrackWrapper)
{
track = (TrackWrapper) fix.getTrackWrapper();
}
}

points.add(editable);
}

tmpTitle = "Remove jumps in selected positions";

}
}

// ok, is it worth going for?
if (points != null)
if (points != null && track != null)
{
final String title = tmpTitle;
final Collection<Editable> permPoints = points;

final TrackWrapper lTrack = track;

// right,stick in a separator
parent.add(new Separator());

final TrackWrapper track = (TrackWrapper) parentLayers[0];

// and the new drop-down list of interpolation frequencies

// yes, create the action
Expand All @@ -124,7 +141,7 @@ public void run()
// ok, go for it.
// sort it out as an operation
final IUndoableOperation removeJumps = new RemoveJumps(title,
theLayers, track, permPoints);
theLayers, lTrack, permPoints);

// ok, stick it on the buffer
CorePlugin.run(removeJumps);
Expand Down Expand Up @@ -285,12 +302,12 @@ class RemoveJumps extends CMAPOperation

private HashMap<FixWrapper, WorldLocation> _newFixes;

public RemoveJumps(String title, Layers theLayers, TrackWrapper track,
public RemoveJumps(String title, Layers theLayers, TrackWrapper lTrack,
Collection<Editable> points)
{
super(title);
_layers = theLayers;
_track = track;
_track = lTrack;
_points = points;
}

Expand Down
Expand Up @@ -154,15 +154,30 @@ private static interface IsValid
{
boolean isValid(FixWrapper fix);
}


private FixWrapper create(final long date, final double lat,
public final void testMyParams1()
{
Editable ed = new LightweightTrackWrapper("name", true, true, Color.red, 1);
editableTesterSupport.testParams(ed, this);
ed = null;
}

public final void testMyParams2()
{
Editable ed = new LightweightTrackWrapper();
editableTesterSupport.testParams(ed, this);
ed = null;
}

private static FixWrapper create(final long date, final double lat,
final double lon)
{
return new FixWrapper(new Fix(new HiResDate(date), new WorldLocation(lat,
lon, 0), 0d, 0d));
}

private int doCount(final LightweightTrackWrapper track,
private static int doCount(final LightweightTrackWrapper track,
final IsValid aTest)
{
int ctr = 0;
Expand All @@ -178,7 +193,7 @@ private int doCount(final LightweightTrackWrapper track,
return ctr;
}

private LightweightTrackWrapper getTrack()
private static LightweightTrackWrapper getTrack()
{
final LightweightTrackWrapper track = new LightweightTrackWrapper();
track.setName("light");
Expand Down Expand Up @@ -362,7 +377,11 @@ public LightweightTrackWrapper()

// set default line-style
setLineStyle(LineStylePropertyEditor.SOLID);
}

// initialise the symbol to use for plotting this track in snail mode
_theSnailShape = MWC.GUI.Shapes.Symbols.SymbolFactory.createSymbol(
"Submarine");
}

public LightweightTrackWrapper(final String name, final boolean visible,
final boolean nameVisible, final Color color, final int lineStyle)
Expand All @@ -374,10 +393,6 @@ public LightweightTrackWrapper(final String name, final boolean visible,
setNameVisible(nameVisible);
setColor(color);
setLineStyle(lineStyle);

// initialise the symbol to use for plotting this track in snail mode
_theSnailShape = MWC.GUI.Shapes.Symbols.SymbolFactory.createSymbol(
"Submarine");
}

/**
Expand Down

0 comments on commit 7ee34fc

Please sign in to comment.