1
|
package eu.dnetlib.repo.manager.client.datasources.update;
|
2
|
|
3
|
import com.google.gwt.core.client.GWT;
|
4
|
import com.google.gwt.dom.client.Document;
|
5
|
import com.google.gwt.event.dom.client.ClickEvent;
|
6
|
import com.google.gwt.event.dom.client.ClickHandler;
|
7
|
import com.google.gwt.user.client.History;
|
8
|
import com.google.gwt.user.client.Window;
|
9
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
10
|
import com.google.gwt.user.client.ui.FlowPanel;
|
11
|
import com.google.gwt.user.client.ui.HTML;
|
12
|
import com.google.gwt.user.client.ui.Widget;
|
13
|
import eu.dnetlib.domain.data.Repository;
|
14
|
import eu.dnetlib.gwt.client.help.HelpService;
|
15
|
import eu.dnetlib.gwt.client.help.HelpServiceAsync;
|
16
|
import eu.dnetlib.repo.manager.client.AbstractRepositoryManagerWidget;
|
17
|
import eu.dnetlib.repo.manager.client.HelpCallback;
|
18
|
import eu.dnetlib.repo.manager.client.RepositoryManager;
|
19
|
import eu.dnetlib.repo.manager.client.RepositoryManagerWidget;
|
20
|
import eu.dnetlib.repo.manager.client.services.RepositoryService;
|
21
|
import eu.dnetlib.repo.manager.client.services.RepositoryServiceAsync;
|
22
|
import eu.dnetlib.repo.manager.client.widgets.ListOrGridViewOfDatasourcesWidget;
|
23
|
import eu.dnetlib.repo.manager.client.widgets.OpenAIRECompliantLogoDownloadWidget;
|
24
|
import eu.dnetlib.repo.manager.shared.DatasourcesCollection;
|
25
|
import org.gwtbootstrap3.client.ui.Alert;
|
26
|
import org.gwtbootstrap3.client.ui.Anchor;
|
27
|
import org.gwtbootstrap3.client.ui.constants.AlertType;
|
28
|
import org.gwtbootstrap3.client.ui.constants.IconPosition;
|
29
|
import org.gwtbootstrap3.client.ui.constants.IconType;
|
30
|
|
31
|
/**
|
32
|
* Created by stefania on 1/14/16.
|
33
|
*/
|
34
|
public class SelectFromMyRepositoriesWidget extends AbstractRepositoryManagerWidget implements RepositoryManagerWidget {
|
35
|
|
36
|
private String parentToken = "";
|
37
|
private String restToken = "";
|
38
|
|
39
|
private FlowPanel myRepositoriesListBoxContent = new FlowPanel();
|
40
|
|
41
|
private RepositoryServiceAsync repositoryService = GWT.create(RepositoryService.class);
|
42
|
private static HelpServiceAsync helpService = GWT.create(HelpService.class);
|
43
|
|
44
|
public SelectFromMyRepositoriesWidget() {
|
45
|
|
46
|
super();
|
47
|
|
48
|
HTML title = new HTML("<h1 class=\"uk-article-title\">Manage your datasources</h1>");
|
49
|
title.addStyleName("uk-margin-medium-bottom");
|
50
|
contentPanel.add(title);
|
51
|
contentPanel.add(myRepositoriesListBoxContent);
|
52
|
}
|
53
|
|
54
|
@Override
|
55
|
public void clear() {
|
56
|
myRepositoriesListBoxContent.clear();
|
57
|
gridPanel.remove(helpPanel);
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
public void reload() {
|
62
|
|
63
|
Document.get().getElementById("headerNoTransparent").removeClassName("tm-header-transparent");
|
64
|
helpService.getHelpById(parentToken, new HelpCallback(helpPanel, gridPanel));
|
65
|
|
66
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\" style=\"text-align: center; padding-top: 170px; " +
|
67
|
"color: rgb(47, 64, 80); font-weight: bold;\">Retrieving repositories...</div>" +
|
68
|
"<div class=\"whiteFilm\"></div>");
|
69
|
myRepositoriesListBoxContent.addStyleName("loading-big");
|
70
|
myRepositoriesListBoxContent.add(loadingWheel);
|
71
|
|
72
|
repositoryService.getRepositoriesOfUser(RepositoryManager.currentUser.getEmail(), true, false,
|
73
|
new AsyncCallback<DatasourcesCollection>() {
|
74
|
|
75
|
@Override
|
76
|
public void onFailure(Throwable caught) {
|
77
|
|
78
|
myRepositoriesListBoxContent.removeStyleName("loading-big");
|
79
|
myRepositoriesListBoxContent.remove(loadingWheel);
|
80
|
|
81
|
Alert errorAlert = new Alert();
|
82
|
errorAlert.setType(AlertType.DANGER);
|
83
|
errorAlert.setText("System error retrieving repositories.");
|
84
|
errorAlert.setDismissable(false);
|
85
|
myRepositoriesListBoxContent.add(errorAlert);
|
86
|
}
|
87
|
|
88
|
@Override
|
89
|
public void onSuccess(DatasourcesCollection datasourcesCollection) {
|
90
|
|
91
|
myRepositoriesListBoxContent.removeStyleName("loading-big");
|
92
|
myRepositoriesListBoxContent.remove(loadingWheel);
|
93
|
|
94
|
ListOrGridViewOfDatasourcesWidget listOrGridViewOfDatasourcesWidget =
|
95
|
new ListOrGridViewOfDatasourcesWidget(datasourcesCollection, "Choose the Datasource you would like to manage",
|
96
|
parentToken, "<i class=\"fa fa-pencil\" aria-hidden=\"true\"></i>", false);
|
97
|
|
98
|
myRepositoriesListBoxContent.add(listOrGridViewOfDatasourcesWidget.asWidget());
|
99
|
|
100
|
OpenAIRECompliantLogoDownloadWidget openAIRECompliantLogoDownloadWidget = new OpenAIRECompliantLogoDownloadWidget();
|
101
|
myRepositoriesListBoxContent.add(openAIRECompliantLogoDownloadWidget.asWidget());
|
102
|
|
103
|
|
104
|
}
|
105
|
});
|
106
|
}
|
107
|
|
108
|
@Override
|
109
|
public void setToken(String parentToken, String rest) {
|
110
|
this.parentToken = parentToken;
|
111
|
this.restToken = rest;
|
112
|
}
|
113
|
|
114
|
@Override
|
115
|
public void afterAdditionToRootPanel() {
|
116
|
|
117
|
}
|
118
|
}
|