Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions org.moreunit.plugin/src/org/moreunit/MoreUnitPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.ui.IPartService;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.moreunit.annotation.AnnotationUpdateListener;
import org.moreunit.annotation.MoreUnitAnnotationModel;
import org.moreunit.decorator.UnitDecorator;
import org.moreunit.core.log.DefaultLogger;
import org.moreunit.core.log.Logger;
import org.moreunit.log.LogHandler;
Expand All @@ -34,6 +36,7 @@ public class MoreUnitPlugin extends AbstractUIPlugin

private Logger logger;
private AnnotationUpdateListener annotationUpdateListener;
private IPropertyChangeListener propertyChangeListener;

/**
* The constructor.
Expand Down Expand Up @@ -66,6 +69,9 @@ public void start(BundleContext context) throws Exception

MoreUnitAnnotationModel.attachForAllOpenEditor();
removeMarkerFromOlderMoreUnitVersions();

propertyChangeListener = event -> UnitDecorator.refreshAll();
getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
}

protected IPartService getPartService()
Expand Down Expand Up @@ -110,6 +116,11 @@ public void stop(BundleContext context) throws Exception
if(partService != null)
partService.removePartListener(annotationUpdateListener);

if(propertyChangeListener != null)
{
getPreferenceStore().removePropertyChangeListener(propertyChangeListener);
}

plugin = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* Handles the decoration of java files. If the class has a testcase a overlay
* icon is added.
*/
// TODO force re-decoration on preferences change (use refreshAll)
public class UnitDecorator extends LabelProvider implements ILightweightLabelDecorator
{
private final Logger logger;
Expand Down Expand Up @@ -150,11 +149,15 @@ public static UnitDecorator getUnitDecorator()
return null;
}

public void refreshAll()
public static void refreshAll()
{
UnitDecorator unitDecorator = getUnitDecorator();
PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
UnitDecorator unitDecorator = getUnitDecorator();

if(unitDecorator != null)
unitDecorator.fireLabelProviderChanged(new LabelProviderChangedEvent(unitDecorator));
if(unitDecorator != null)
{
unitDecorator.fireLabelProviderChanged(new LabelProviderChangedEvent(unitDecorator));
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.moreunit.decorator.UnitDecorator;
import org.moreunit.log.LogHandler;
import org.moreunit.preferences.Preferences;

Expand Down Expand Up @@ -189,6 +190,8 @@ private void saveProperties()
IPreferenceStore store = Preferences.getInstance().getProjectStore(getJavaProject());
if(store instanceof ScopedPreferenceStore preferenceStore)
preferenceStore.save();

UnitDecorator.refreshAll();
}
catch (IOException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class MoreUnitContants
{
public static final String TEST_CASE_MARKER = "org.moreunit.testCase";
public static final String TEST_CASE_DECORATOR = "moreunit.testdecorator";
public static final String TEST_CASE_DECORATOR = "org.moreunit.testdecorator";

public static final String TEST_JUNIT3_METHOD_PRAEFIX = "test";
public static final String SUFFIX_NAME = "Suffix";
Expand Down
Loading