839 lines
24 KiB
Java
839 lines
24 KiB
Java
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.project;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewMainCodeEvent;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.StatAlgoImporterMonitor;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ProjectStatusEventType;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectFolder;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
|
import org.gcube.portlets.widgets.githubconnector.client.GitHubConnectorWizard;
|
|
import org.gcube.portlets.widgets.githubconnector.client.wizard.event.WizardEvent;
|
|
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
|
|
import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectDialog;
|
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
|
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
import com.google.gwt.core.shared.GWT;
|
|
import com.google.gwt.event.shared.EventBus;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
import com.sencha.gxt.core.client.dom.XDOM;
|
|
import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
|
|
import com.sencha.gxt.widget.core.client.event.DialogHideEvent;
|
|
import com.sencha.gxt.widget.core.client.event.DialogHideEvent.DialogHideHandler;
|
|
|
|
/**
|
|
*
|
|
* @author Giancarlo Panichi
|
|
*
|
|
*
|
|
*/
|
|
public class ProjectManager {
|
|
private EventBus eventBus;
|
|
private Project project;
|
|
|
|
public ProjectManager(EventBus eventBus) {
|
|
this.eventBus = eventBus;
|
|
}
|
|
|
|
public void createProject() {
|
|
|
|
WorkspaceExplorerSelectDialog wselectDialog = new WorkspaceExplorerSelectDialog(
|
|
"Select Project Folder", true);
|
|
|
|
WorskpaceExplorerSelectNotificationListener handler = new WorskpaceExplorerSelectNotificationListener() {
|
|
|
|
@Override
|
|
public void onSelectedItem(Item item) {
|
|
|
|
if (item.getType() == ItemType.FOLDER) {
|
|
createProjectOnServer(item);
|
|
|
|
} else {
|
|
UtilsGXT3.info("Attention",
|
|
"Select a valid project folder!");
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailed(Throwable throwable) {
|
|
Log.error("Error in create project: "
|
|
+ throwable.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error", throwable.getLocalizedMessage());
|
|
throwable.printStackTrace();
|
|
}
|
|
|
|
@Override
|
|
public void onAborted() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onNotValidSelection() {
|
|
UtilsGXT3.info("Attention", "Select a valid project folder!");
|
|
}
|
|
};
|
|
|
|
wselectDialog.addWorkspaceExplorerSelectNotificationListener(handler);
|
|
wselectDialog.setZIndex(XDOM.getTopZIndex());
|
|
wselectDialog.show();
|
|
}
|
|
|
|
public void openProject() {
|
|
WorkspaceExplorerSelectDialog wselectDialog = new WorkspaceExplorerSelectDialog(
|
|
"Select Project Folder", true);
|
|
|
|
WorskpaceExplorerSelectNotificationListener handler = new WorskpaceExplorerSelectNotificationListener() {
|
|
|
|
@Override
|
|
public void onSelectedItem(Item item) {
|
|
|
|
if (item.getType() == ItemType.FOLDER) {
|
|
openProjectOnServer(item);
|
|
|
|
} else {
|
|
UtilsGXT3.info("Attention",
|
|
"Select a valid project folder!");
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailed(Throwable throwable) {
|
|
Log.error("Error in create project: "
|
|
+ throwable.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error", throwable.getLocalizedMessage());
|
|
throwable.printStackTrace();
|
|
}
|
|
|
|
@Override
|
|
public void onAborted() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onNotValidSelection() {
|
|
UtilsGXT3.info("Attention", "Select a valid project folder!");
|
|
}
|
|
};
|
|
|
|
wselectDialog.addWorkspaceExplorerSelectNotificationListener(handler);
|
|
wselectDialog.setZIndex(XDOM.getTopZIndex());
|
|
wselectDialog.show();
|
|
|
|
}
|
|
|
|
public void addGitHubProject() {
|
|
if (project != null) {
|
|
if (project.getProjectFolder() != null
|
|
&& project.getProjectFolder().getFolder() != null) {
|
|
WizardEvent.WizardEventHandler handler = new WizardEvent.WizardEventHandler() {
|
|
|
|
@Override
|
|
public void onResponse(WizardEvent event) {
|
|
GWT.log("Wizard Response: "
|
|
+ event.getWizardEventType());
|
|
if (event.getWizardEventType() == null) {
|
|
fireProjectStatusAddResourceEvent();
|
|
return;
|
|
|
|
}
|
|
|
|
switch (event.getWizardEventType()) {
|
|
case Aborted:
|
|
case Background:
|
|
case Completed:
|
|
case Failed:
|
|
default:
|
|
fireProjectStatusAddResourceEvent();
|
|
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
GitHubConnectorWizard wizard = new GitHubConnectorWizard(
|
|
project.getProjectFolder().getFolder().getId());
|
|
wizard.addWizardEventHandler(handler);
|
|
wizard.setZIndex(XDOM.getTopZIndex());
|
|
wizard.show();
|
|
} else {
|
|
Log.error("Invalid ProjectFolder: "
|
|
+ project.getProjectFolder());
|
|
UtilsGXT3.alert("Error", "Error retrieving project folder!");
|
|
}
|
|
|
|
} else {
|
|
Log.error("Invalid Project: " + project);
|
|
UtilsGXT3.alert("Error", "Error retrieving project: " + project);
|
|
}
|
|
|
|
}
|
|
|
|
public void addResource() {
|
|
List<ItemType> selectableTypes = new ArrayList<ItemType>();
|
|
selectableTypes.add(ItemType.EXTERNAL_FILE);
|
|
selectableTypes.add(ItemType.EXTERNAL_IMAGE);
|
|
selectableTypes.add(ItemType.IMAGE_DOCUMENT);
|
|
selectableTypes.add(ItemType.DOCUMENT);
|
|
selectableTypes.add(ItemType.PDF_DOCUMENT);
|
|
|
|
List<ItemType> showableTypes = new ArrayList<ItemType>();
|
|
showableTypes.addAll(Arrays.asList(ItemType.values()));
|
|
|
|
WorkspaceExplorerSelectDialog wselectDialog = new WorkspaceExplorerSelectDialog(
|
|
"Select a Resource", selectableTypes, showableTypes);
|
|
|
|
WorskpaceExplorerSelectNotificationListener handler = new WorskpaceExplorerSelectNotificationListener() {
|
|
|
|
@Override
|
|
public void onSelectedItem(Item item) {
|
|
if (item.getType() == ItemType.EXTERNAL_FILE
|
|
|| item.getType() == ItemType.EXTERNAL_IMAGE
|
|
|| item.getType() == ItemType.IMAGE_DOCUMENT
|
|
|| item.getType() == ItemType.DOCUMENT
|
|
|| item.getType() == ItemType.PDF_DOCUMENT) {
|
|
String filename = item.getName();
|
|
if (filename != null && !filename.isEmpty()) {
|
|
addResourceToProject(item);
|
|
} else {
|
|
UtilsGXT3.info("Attention", "Select a valid resource!");
|
|
}
|
|
|
|
} else {
|
|
UtilsGXT3.info("Attention", "Select a valid resource!");
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailed(Throwable throwable) {
|
|
Log.error("Error in add resource: "
|
|
+ throwable.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error", throwable.getLocalizedMessage());
|
|
throwable.printStackTrace();
|
|
}
|
|
|
|
@Override
|
|
public void onAborted() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onNotValidSelection() {
|
|
UtilsGXT3.info("Attention", "Select a valid resource!");
|
|
}
|
|
};
|
|
|
|
wselectDialog.addWorkspaceExplorerSelectNotificationListener(handler);
|
|
wselectDialog.setZIndex(XDOM.getTopZIndex());
|
|
wselectDialog.show();
|
|
}
|
|
|
|
private void addResourceToProject(Item item) {
|
|
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
|
|
Log.debug("Add Resource To Project Item selected: " + item);
|
|
ItemDescription itemDescription = new ItemDescription(item.getId(),
|
|
item.getName(), item.getOwner(), item.getPath(), item.getType()
|
|
.name());
|
|
StatAlgoImporterServiceAsync.INSTANCE.addResourceToProject(
|
|
itemDescription, new AsyncCallback<Void>() {
|
|
|
|
@Override
|
|
public void onSuccess(Void result) {
|
|
monitor.hide();
|
|
fireProjectStatusAddResourceEvent();
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
monitor.hide();
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
Log.error("Error in add resource to project: "
|
|
+ caught.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
}
|
|
caught.printStackTrace();
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
private void createProjectOnServer(Item item) {
|
|
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
|
|
Log.debug("Create Project Item selected: " + item);
|
|
final ItemDescription newProjectFolder = new ItemDescription(
|
|
item.getId(), item.getName(), item.getOwner(), item.getPath(),
|
|
item.getType().name());
|
|
StatAlgoImporterServiceAsync.INSTANCE.createProjectOnWorkspace(
|
|
newProjectFolder, new AsyncCallback<Void>() {
|
|
|
|
@Override
|
|
public void onSuccess(Void result) {
|
|
monitor.hide();
|
|
project = new Project(new ProjectFolder(
|
|
newProjectFolder));
|
|
fireProjectStatusOpenEvent();
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
monitor.hide();
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
Log.error("Error in create project: "
|
|
+ caught.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
}
|
|
caught.printStackTrace();
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
protected void openProjectOnServer(Item item) {
|
|
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
|
|
|
|
Log.debug("Open Project Item selected: " + item);
|
|
final ItemDescription newProjectFolder = new ItemDescription(
|
|
item.getId(), item.getName(), item.getOwner(), item.getPath(),
|
|
item.getType().name());
|
|
StatAlgoImporterServiceAsync.INSTANCE.openProjectOnWorkspace(
|
|
newProjectFolder, new AsyncCallback<Project>() {
|
|
|
|
@Override
|
|
public void onSuccess(Project projectOpened) {
|
|
Log.debug("Open: " + projectOpened);
|
|
monitor.hide();
|
|
project = projectOpened;
|
|
fireProjectStatusOpenEvent();
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
monitor.hide();
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
Log.error("Error in open project: "
|
|
+ caught.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
}
|
|
caught.printStackTrace();
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
public void saveProject(InputData inputData,
|
|
final StatAlgoImporterMonitor monitor) {
|
|
Log.debug("Save Project: " + inputData);
|
|
|
|
StatAlgoImporterServiceAsync.INSTANCE.saveProject(inputData,
|
|
new AsyncCallback<Void>() {
|
|
|
|
@Override
|
|
public void onSuccess(Void result) {
|
|
monitor.hide();
|
|
UtilsGXT3.info("Save", "Project saved!");
|
|
fireProjectStatusExplorerRefreshEvent();
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
monitor.hide();
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
Log.error("Error on save project: "
|
|
+ caught.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
}
|
|
caught.printStackTrace();
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
public void softwareCreate(final InputData inputData,
|
|
final StatAlgoImporterMonitor monitor) {
|
|
|
|
StatAlgoImporterServiceAsync.INSTANCE.createSoftware(inputData,
|
|
new AsyncCallback<Void>() {
|
|
|
|
@Override
|
|
public void onSuccess(Void result) {
|
|
monitor.hide();
|
|
fireProjectStatusSoftwareCreatedEvent();
|
|
UtilsGXT3.info("Create Software", "Software Created!");
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
monitor.hide();
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
Log.error("Error in create software: "
|
|
+ caught.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
fireProjectStatusExplorerRefreshEvent();
|
|
|
|
}
|
|
caught.printStackTrace();
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
public void setMainCode(final ItemDescription itemDescription) {
|
|
if (project != null) {
|
|
if (project.getMainCode() != null
|
|
&& project.getMainCode().getItemDescription() != null) {
|
|
final ConfirmMessageBox mb = new ConfirmMessageBox("Attention",
|
|
"All previous configurations will be lost. Would you like to change main code?");
|
|
mb.addDialogHideHandler(new DialogHideHandler() {
|
|
|
|
@Override
|
|
public void onDialogHide(DialogHideEvent event) {
|
|
switch (event.getHideButton()) {
|
|
case NO:
|
|
break;
|
|
case YES:
|
|
setMainCodeOnServer(itemDescription);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
});
|
|
mb.setWidth(300);
|
|
mb.show();
|
|
} else {
|
|
setMainCodeOnServer(itemDescription);
|
|
}
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void setMainCodeOnServer(final ItemDescription itemDescription) {
|
|
|
|
Log.debug("Set Main Code: " + itemDescription);
|
|
StatAlgoImporterServiceAsync.INSTANCE.setMainCode(itemDescription,
|
|
new AsyncCallback<Project>() {
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
Log.error("Error setting main code: "
|
|
+ caught.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
}
|
|
caught.printStackTrace();
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onSuccess(Project result) {
|
|
project = result;
|
|
fireProjectStatusMainCodeSetEvent();
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
public void setNewMainCode(NewMainCodeEvent newMainCodeEvent,
|
|
final StatAlgoImporterMonitor monitor) {
|
|
StatAlgoImporterServiceAsync.INSTANCE.setNewMainCode(
|
|
newMainCodeEvent.getFile(), newMainCodeEvent.getCode(),
|
|
new AsyncCallback<Project>() {
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
monitor.hide();
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
Log.error("Error on save new main code: "
|
|
+ caught.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
}
|
|
caught.printStackTrace();
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onSuccess(Project result) {
|
|
project = result;
|
|
fireProjectStatusMainCodeSetEvent();
|
|
monitor.hide();
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
public void deleteItem(final ItemDescription itemDescription) {
|
|
if (project != null
|
|
&& project.getMainCode() != null
|
|
&& project.getMainCode().getItemDescription() != null
|
|
&& itemDescription.getId().compareTo(
|
|
project.getMainCode().getItemDescription().getId()) == 0) {
|
|
final ConfirmMessageBox mb = new ConfirmMessageBox("Delete",
|
|
"All previous configurations will be lost. Would you like to delete main code?");
|
|
mb.addDialogHideHandler(new DialogHideHandler() {
|
|
|
|
@Override
|
|
public void onDialogHide(DialogHideEvent event) {
|
|
switch (event.getHideButton()) {
|
|
case NO:
|
|
break;
|
|
case YES:
|
|
deleteItemOnServer(itemDescription, true);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
});
|
|
mb.setWidth(300);
|
|
mb.show();
|
|
|
|
} else {
|
|
final ConfirmMessageBox mb = new ConfirmMessageBox("Delete",
|
|
"Would you like to delete this resource?");
|
|
mb.addDialogHideHandler(new DialogHideHandler() {
|
|
|
|
@Override
|
|
public void onDialogHide(DialogHideEvent event) {
|
|
switch (event.getHideButton()) {
|
|
case NO:
|
|
break;
|
|
case YES:
|
|
deleteItemOnServer(itemDescription, false);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
});
|
|
mb.setWidth(300);
|
|
mb.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void deleteItemOnServer(ItemDescription itemDescription,
|
|
final boolean mainCode) {
|
|
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
|
|
|
|
StatAlgoImporterServiceAsync.INSTANCE.deleteResourceOnProject(
|
|
itemDescription, new AsyncCallback<Project>() {
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
monitor.hide();
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
Log.error("Error deleting resourse: "
|
|
+ caught.getLocalizedMessage());
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
}
|
|
caught.printStackTrace();
|
|
}
|
|
|
|
@Override
|
|
public void onSuccess(Project result) {
|
|
monitor.hide();
|
|
project = result;
|
|
if (mainCode) {
|
|
fireProjectStatusDeleteMainCodeEvent();
|
|
} else {
|
|
fireProjectStatusDeleteEvent();
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
public void startProjectManager(String value) {
|
|
|
|
StatAlgoImporterServiceAsync.INSTANCE.restoreUISession(value,
|
|
new AsyncCallback<Project>() {
|
|
|
|
public void onFailure(Throwable caught) {
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
|
|
}
|
|
}
|
|
|
|
public void onSuccess(Project p) {
|
|
if (p != null) {
|
|
project = p;
|
|
fireProjectStatusOpenEvent();
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
public void softwareRepackage() {
|
|
if (project != null) {
|
|
final ConfirmMessageBox mb = new ConfirmMessageBox(
|
|
"Attention",
|
|
"This operation repackages the script only without recreating the Java software. The already deployed Java software will use the new script package. Do you want to proceed?");
|
|
mb.addDialogHideHandler(new DialogHideHandler() {
|
|
|
|
@Override
|
|
public void onDialogHide(DialogHideEvent event) {
|
|
switch (event.getHideButton()) {
|
|
case NO:
|
|
break;
|
|
case YES:
|
|
softwareRepackageOnServer();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
});
|
|
mb.setWidth(300);
|
|
mb.show();
|
|
|
|
} else {
|
|
Log.error("Project not open: " + project);
|
|
UtilsGXT3.alert("Error", "Project not open!");
|
|
}
|
|
|
|
}
|
|
|
|
private void softwareRepackageOnServer() {
|
|
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
|
|
StatAlgoImporterServiceAsync.INSTANCE
|
|
.repackageSoftware(new AsyncCallback<Void>() {
|
|
|
|
public void onFailure(Throwable caught) {
|
|
monitor.hide();
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
fireProjectStatusExplorerRefreshEvent();
|
|
}
|
|
}
|
|
|
|
public void onSuccess(Void result) {
|
|
monitor.hide();
|
|
UtilsGXT3.info("Repackage",
|
|
"The script has been repackaged!");
|
|
fireProjectStatusSoftwareRepackageEvent();
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
public void softwarePublish() {
|
|
if (project != null) {
|
|
final ConfirmMessageBox mb = new ConfirmMessageBox(
|
|
"Attention",
|
|
"The compiled software will be notified to the Infrastructure Administrators and will be published in the suggested VREs. The source code will not be shared. Do you confirm the submission?");
|
|
mb.addDialogHideHandler(new DialogHideHandler() {
|
|
|
|
@Override
|
|
public void onDialogHide(DialogHideEvent event) {
|
|
switch (event.getHideButton()) {
|
|
case NO:
|
|
break;
|
|
case YES:
|
|
softwarePublishOnServer();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
});
|
|
mb.setWidth(300);
|
|
mb.show();
|
|
|
|
} else {
|
|
Log.error("Project not open: " + project);
|
|
UtilsGXT3.alert("Error", "Project not open!");
|
|
}
|
|
|
|
}
|
|
|
|
private void softwarePublishOnServer() {
|
|
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
|
|
StatAlgoImporterServiceAsync.INSTANCE
|
|
.publishSoftware(new AsyncCallback<Void>() {
|
|
|
|
public void onFailure(Throwable caught) {
|
|
monitor.hide();
|
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
UtilsGXT3.alert("Error",
|
|
caught.getLocalizedMessage());
|
|
fireProjectStatusExplorerRefreshEvent();
|
|
|
|
}
|
|
}
|
|
|
|
public void onSuccess(Void result) {
|
|
monitor.hide();
|
|
UtilsGXT3.info("Publish",
|
|
"The software has been published!");
|
|
fireProjectStatusSoftwarePublishEvent();
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
public void startProjectManager() {
|
|
fireProjectStatusStartEvent();
|
|
}
|
|
|
|
private void fireProjectStatusOpenEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.OPEN, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
|
|
}
|
|
|
|
@SuppressWarnings("unused")
|
|
private void fireProjectStatusSaveProjectEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.SAVE, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
private void fireProjectStatusAddResourceEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.ADD_RESOURCE, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
private void fireProjectStatusDeleteEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.DELETE_RESOURCE, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
private void fireProjectStatusDeleteMainCodeEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.DELETE_MAIN_CODE, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
@SuppressWarnings("unused")
|
|
private void fireProjectStatusUpdateEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.UPDATE, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
private void fireProjectStatusExplorerRefreshEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.EXPLORER_REFRESH, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
private void fireProjectStatusMainCodeSetEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.MAIN_CODE_SET, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
private void fireProjectStatusSoftwareCreatedEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.SOFTWARE_CREATED, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
private void fireProjectStatusSoftwarePublishEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.SOFTWARE_PUBLISH, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
private void fireProjectStatusSoftwareRepackageEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.SOFTWARE_REPACKAGE, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
private void fireProjectStatusStartEvent() {
|
|
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
|
ProjectStatusEventType.START, project);
|
|
eventBus.fireEvent(projectStatusEvent);
|
|
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
|
}
|
|
|
|
}
|