package gov.nasa.jpl.mbee.ems.sync;

import gov.nasa.jpl.mbee.actions.systemsreasoner.SRAction;

import java.awt.event.ActionEvent;

import com.nomagic.magicdraw.core.Application;
import com.nomagic.magicdraw.core.Project;

public class AutosyncStatusAction extends SRAction {	
	private static final long serialVersionUID = 1L;
	
	private boolean current = false;
	public static final String NAME = "MMS Sync";
	
	public AutosyncStatusAction() {
		super(NAME + ": OFF");
	}
	
	public void update(final boolean on) {
		current = on;
		setName(AutosyncStatusAction.NAME + ": " + (current ? "ON" : "OFF"));
	}
	
	@Override
	public void actionPerformed(final ActionEvent event) {
		Project project = Application.getInstance().getProject();
		if (!current)
			AutoSyncProjectListener.initDurable(project);
		else
			AutoSyncProjectListener.close(project, true);
	}
}
@@ -88,16 +88,52 @@
 RAction;
+%0Aimport gov.nasa.jpl.mbee.lib.Utils;
 %0A%0Aimport
@@ -765,16 +765,145 @@
 ject();%0A
+%09%09if (project == null) %7B%0A%09%09%09Utils.guilog(%22%5BERROR%5D Dynamic sync can only be started when a project is open.%22);%0A%09%09%09return;%0A%09%09%7D%0A%09%09%09%0A
 %09%09if (!c

check for open project on sync init