refs:3772: SAI - Create a github project importer
https://support.d4science.org/issues/3772 Added Wizard support and Repository explorer git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/github-connector@129100 82a268e6-3cf1-43bd-a215-b396298e98cfmaster
@ -0,0 +1,51 @@
|
||||
package org.gcube.portlets.widgets.githubconnector.client.resource;
|
||||
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface GCResources extends ClientBundle {
|
||||
|
||||
public static final GCResources INSTANCE=GWT.create(GCResources.class);
|
||||
|
||||
@Source("Wizard.css")
|
||||
WizardCSS wizardCSS();
|
||||
|
||||
@Source("arrow-refresh.png")
|
||||
ImageResource refresh();
|
||||
|
||||
@Source("arrow-refresh_16.png")
|
||||
ImageResource refresh16();
|
||||
|
||||
|
||||
@Source("arrow-refresh_32.png")
|
||||
ImageResource refresh32();
|
||||
|
||||
@Source("wizard-next.png")
|
||||
ImageResource wizardNext();
|
||||
|
||||
@Source("wizard-next_32.png")
|
||||
ImageResource wizardNext32();
|
||||
|
||||
@Source("wizard-previous.png")
|
||||
ImageResource wizardPrevious();
|
||||
|
||||
@Source("wizard-previous_32.png")
|
||||
ImageResource wizardPrevious32();
|
||||
|
||||
@Source("wizard-go.png")
|
||||
ImageResource wizardGo();
|
||||
|
||||
@Source("wizard-go_32.png")
|
||||
ImageResource wizardGo32();
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
@CHARSET "UTF-8";
|
||||
|
||||
|
||||
.wizard-title {
|
||||
padding: 5px;
|
||||
font-weight: bold;
|
||||
font-size: small;
|
||||
background-color: #C3D9FF;
|
||||
}
|
||||
|
||||
.wizard-footer {
|
||||
padding: 5px;
|
||||
font-weight: bold;
|
||||
font-size: x-small;
|
||||
text-align: left;
|
||||
background-color: #CDEB8B
|
||||
}
|
||||
|
||||
.source-selection-hover:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.column-excluded {
|
||||
background-color: #e6e0da !important;
|
||||
color: #bfa698;
|
||||
}
|
||||
|
||||
.importSelection-sources {
|
||||
padding: 30px;
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
|
||||
}
|
||||
|
||||
.importSelection-source {
|
||||
padding-bottom: 20px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.githubconnector.client.resource;
|
||||
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface WizardCSS extends CssResource {
|
||||
|
||||
@ClassName("wizard-title")
|
||||
public String getWizardTitle();
|
||||
|
||||
@ClassName("wizard-footer")
|
||||
public String getWizardFooter();
|
||||
|
||||
@ClassName("source-selection-hover")
|
||||
public String getSourceSelectionHover();
|
||||
|
||||
@ClassName("column-excluded")
|
||||
public String getColumnExcluded();
|
||||
|
||||
@ClassName("importSelection-sources")
|
||||
public String getImportSelectionSources();
|
||||
|
||||
@ClassName("importSelection-source")
|
||||
public String getImportSelectionSource();
|
||||
|
||||
|
||||
|
||||
}
|
After Width: | Height: | Size: 781 B |
After Width: | Height: | Size: 984 B |
After Width: | Height: | Size: 572 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 701 B |
After Width: | Height: | Size: 778 B |
After Width: | Height: | Size: 771 B |
After Width: | Height: | Size: 502 B |
After Width: | Height: | Size: 656 B |
After Width: | Height: | Size: 474 B |
After Width: | Height: | Size: 559 B |
After Width: | Height: | Size: 431 B |
After Width: | Height: | Size: 573 B |
@ -1,17 +1,26 @@
|
||||
package org.gcube.portlets.widgets.githubconnector.client.util;
|
||||
|
||||
import com.google.gwt.core.client.Callback;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class GWTMessages {
|
||||
|
||||
|
||||
public static void alert(String title, String text) {
|
||||
AlertDialog alertDialgo = new AlertDialog(title, text);
|
||||
alertDialgo.show();
|
||||
|
||||
}
|
||||
|
||||
public static void alert(String title, String text,
|
||||
Callback<Void, Void> callback) {
|
||||
AlertDialog alertDialgo = new AlertDialog(title, text, callback);
|
||||
alertDialgo.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,75 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SimpleWizardCard extends WizardCard {
|
||||
|
||||
/**
|
||||
* Create a new simple wizard card.
|
||||
*
|
||||
* @param title
|
||||
* the card title.
|
||||
* @param footer
|
||||
* the card footer.
|
||||
* @param content
|
||||
* the card content.
|
||||
*/
|
||||
public SimpleWizardCard(String title, String footer, String content) {
|
||||
super(title, footer);
|
||||
|
||||
SimplePanel contentPanel = new SimplePanel();
|
||||
HTML htmlContent = new HTML(content);
|
||||
htmlContent.setStyleName("wizard-simple-content");
|
||||
contentPanel.add(htmlContent);
|
||||
|
||||
setContent(contentPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
Command sayNextCard = new Command() {
|
||||
|
||||
public void execute() {
|
||||
try {
|
||||
GWT.log("NextCard");
|
||||
getWizardWindow().nextCard();
|
||||
} catch (Exception e) {
|
||||
GWT.log("sayNextCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Command sayPreviousCard = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
GWT.log("PreviousCard");
|
||||
getWizardWindow().previousCard();
|
||||
} catch (Exception e) {
|
||||
GWT.log("sayPreviousCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||
|
||||
setEnableBackButton(true);
|
||||
setBackButtonVisible(true);
|
||||
setEnableNextButton(true);
|
||||
setNextButtonVisible(true);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.widgets.githubconnector.client.resource.GCResources;
|
||||
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class WizardCard extends SimplePanel {
|
||||
|
||||
private WizardWindow wizardWindow;
|
||||
|
||||
|
||||
|
||||
protected GCResources res=GCResources.INSTANCE;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new wizard card.
|
||||
* The footer is automatically calculated.
|
||||
* @param title the card title.
|
||||
*/
|
||||
public WizardCard(String title) {
|
||||
this(title,"");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new wizard card.
|
||||
* @param title the card title.
|
||||
* @param footer the card footer.
|
||||
*/
|
||||
public WizardCard(String title, String footer) {
|
||||
GWT.log(title);
|
||||
res.wizardCSS().ensureInjected();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the card content.
|
||||
* @param content the card content.
|
||||
*/
|
||||
public void setContent(Widget content)
|
||||
{
|
||||
setWidget(content);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enables the next button.
|
||||
* @param enable <code>true</code> to enable it, <code>false</code> otherwise.
|
||||
*/
|
||||
public void setEnableNextButton(boolean enable)
|
||||
{
|
||||
if (wizardWindow!=null){
|
||||
wizardWindow.setEnableNextButton(enable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the back button.
|
||||
* @param enable <code>true</code> to enable the button, <code>false</code> otherwise.
|
||||
*/
|
||||
public void setEnableBackButton(boolean enable)
|
||||
{
|
||||
if (wizardWindow!=null){
|
||||
wizardWindow.setEnableBackButton(enable);
|
||||
}
|
||||
}
|
||||
|
||||
/**dispose
|
||||
* Sets the next button label.
|
||||
* @param text the button label.
|
||||
*/
|
||||
public void setNextButtonText(String text)
|
||||
{
|
||||
if (wizardWindow!=null){
|
||||
wizardWindow.setNextButtonText(text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the back button label.
|
||||
* @param text the button label.
|
||||
*/
|
||||
|
||||
public void setBackButtonText(String text)
|
||||
{
|
||||
if (wizardWindow!=null){
|
||||
wizardWindow.setBackButtonText(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Visible the next button.
|
||||
* @param visible <code>true</code> to show the button, <code>false</code> otherwise.
|
||||
*/
|
||||
public void setNextButtonVisible(boolean visible)
|
||||
{
|
||||
if (wizardWindow!=null){
|
||||
wizardWindow.setNextButtonVisible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visible the back button.
|
||||
* @param visible <code>true</code> to show the button, <code>false</code> otherwise.
|
||||
*/
|
||||
public void setBackButtonVisible(boolean visible)
|
||||
{
|
||||
if (wizardWindow!=null){
|
||||
wizardWindow.setBackButtonVisible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setNextButtonToFinish()
|
||||
{
|
||||
if (wizardWindow!=null){
|
||||
wizardWindow.setNextButtonToFinish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the WizardWindow for this import card.
|
||||
* @param wizardWindow the WizardWindow.
|
||||
*/
|
||||
protected void setWizardWindow(WizardWindow wizardWindow)
|
||||
{
|
||||
this.wizardWindow = wizardWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current wizard window.
|
||||
* @return the wizard window.
|
||||
*/
|
||||
protected WizardWindow getWizardWindow()
|
||||
{
|
||||
if (wizardWindow==null) throw new IllegalStateException("No Wizard Window setup");
|
||||
return wizardWindow;
|
||||
}
|
||||
|
||||
public void addToWindowTitle(String toAdd)
|
||||
{
|
||||
wizardWindow.setTitle(wizardWindow.getOriginalTitle()+toAdd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before the card is showed.
|
||||
*/
|
||||
public void setup()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the card is disposed.
|
||||
*/
|
||||
public void dispose()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Add a listener to the next button.
|
||||
* @param listener the listener to add.
|
||||
*/
|
||||
public void addNextButtonListener(ClickHandler listener)
|
||||
{
|
||||
if (wizardWindow!=null){
|
||||
wizardWindow.addNextButtonListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of cards in the wizard window.
|
||||
* @return the number of cards.
|
||||
*/
|
||||
public int getNumberOfCards()
|
||||
{
|
||||
return getWizardWindow().getCardStackSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this card position on card list.
|
||||
* @return the card position on the card stack.
|
||||
*/
|
||||
public int getCardPosition()
|
||||
{
|
||||
int indexPosition = getWizardWindow().getCardStack().indexOf(this);
|
||||
return (indexPosition>=0)?indexPosition+1:indexPosition;
|
||||
}
|
||||
|
||||
public void showErrorAndHide(String title, final String message, String details, final Throwable throwable)
|
||||
{
|
||||
wizardWindow.showErrorAndHide(title, message, details, throwable);
|
||||
}
|
||||
|
||||
public void hideWindow()
|
||||
{
|
||||
wizardWindow.hide();
|
||||
}
|
||||
|
||||
public EventBus getEventBus(){
|
||||
return wizardWindow.eventBus;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface WizardListener {
|
||||
|
||||
/**
|
||||
* Called when the wizard is completed without errors
|
||||
*/
|
||||
public void completed(String id);
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation is put in background
|
||||
*/
|
||||
public void putInBackground();
|
||||
|
||||
/**
|
||||
* Called when the wizard has been aborted by the user.
|
||||
*/
|
||||
public void aborted();
|
||||
|
||||
/**
|
||||
* Called when the something in the wizard is failed.
|
||||
* @param title
|
||||
* @param message the failure reason.
|
||||
* @param details the failure details.
|
||||
* @param throwable the exception.
|
||||
*/
|
||||
public void failed(String title, String message, String details, Throwable throwable);
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||
|
||||
import com.google.gwt.i18n.client.Messages;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface WizardMessages extends Messages {
|
||||
|
||||
//
|
||||
@DefaultMessage("Back")
|
||||
String buttonBackLabel();
|
||||
|
||||
@DefaultMessage("Next")
|
||||
String buttonNextLabel();
|
||||
|
||||
@DefaultMessage("Finish")
|
||||
String buttonFinishLabel();
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,489 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.widgets.githubconnector.client.util.GWTMessages;
|
||||
|
||||
import com.google.gwt.core.client.Callback;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.event.shared.SimpleEventBus;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.DeckPanel;
|
||||
import com.google.gwt.user.client.ui.DialogBox;
|
||||
import com.google.gwt.user.client.ui.DockPanel;
|
||||
import com.google.gwt.user.client.ui.MenuBar;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class WizardWindow extends DialogBox {
|
||||
|
||||
protected boolean WIZARD_RESIZABLE = false;
|
||||
protected boolean WIZARD_COLLAPSIBLE = true;
|
||||
protected String title;
|
||||
|
||||
protected ArrayList<WizardCard> cardStack = new ArrayList<WizardCard>();
|
||||
|
||||
protected Button backButton;
|
||||
|
||||
protected Button nextButton;
|
||||
|
||||
protected String originalTitle;
|
||||
|
||||
protected boolean checkBeforeClose = true;
|
||||
|
||||
protected boolean nextCardFinish = false;
|
||||
|
||||
protected Command nextButtonAction = null;
|
||||
|
||||
protected Command previousButtonAction = null;
|
||||
|
||||
protected DockPanel dockPanel;
|
||||
|
||||
protected ArrayList<WizardListener> listeners;
|
||||
|
||||
protected EventBus eventBus;
|
||||
|
||||
protected MenuBar cardMoveToolBar;
|
||||
|
||||
// protected FillToolItem fillSpacingCardMoveToolBar;
|
||||
protected WizardMessages msgs;
|
||||
protected DeckPanel deckPanel;
|
||||
|
||||
/**
|
||||
* Create a new Wizard Window with the specified title.
|
||||
*
|
||||
* @param title
|
||||
* the wizard window title.
|
||||
*/
|
||||
public WizardWindow(String title) {
|
||||
this(title, new SimpleEventBus());
|
||||
|
||||
}
|
||||
|
||||
public WizardWindow(String title, EventBus eventBus) {
|
||||
super();
|
||||
GWT.log("WizardWindow");
|
||||
this.title = title;
|
||||
this.eventBus = eventBus;
|
||||
this.msgs = GWT.create(WizardMessages.class);
|
||||
|
||||
initWindow();
|
||||
|
||||
listeners = new ArrayList<WizardListener>();
|
||||
deckPanel=new DeckPanel();
|
||||
|
||||
|
||||
|
||||
cardMoveToolBar = new MenuBar();
|
||||
|
||||
// Create a command that will execute on menu item selection
|
||||
ScheduledCommand menuCommandBack = new ScheduledCommand() {
|
||||
|
||||
public void execute() {
|
||||
if (previousButtonAction != null)
|
||||
previousButtonAction.execute();
|
||||
else
|
||||
previousCard();
|
||||
}
|
||||
};
|
||||
|
||||
ScheduledCommand menuCommandNext = new ScheduledCommand() {
|
||||
|
||||
public void execute() {
|
||||
if (nextButtonAction != null)
|
||||
nextButtonAction.execute();
|
||||
else
|
||||
nextCard();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// cardMoveToolBar.setSpacing(2);
|
||||
// cardMoveToolBar.addStyleName(ThemeStyles.get().style().borderTop());
|
||||
|
||||
backButton = new Button(msgs.buttonBackLabel());
|
||||
// backButton.setIcon(GCResources.INSTANCE.wizardPrevious());
|
||||
backButton.setEnabled(false);
|
||||
backButton.setTabIndex(1001);
|
||||
|
||||
SafeHtml backItem=new SafeHtmlBuilder().appendEscaped(
|
||||
msgs.buttonBackLabel()).toSafeHtml();
|
||||
|
||||
cardMoveToolBar.addItem(backItem,menuCommandBack);
|
||||
|
||||
nextButton = new Button(msgs.buttonNextLabel());
|
||||
// backButton.setIcon(GCResources.INSTANCE.wizardPrevious());
|
||||
nextButton.setEnabled(false);
|
||||
nextButton.setTabIndex(1002);
|
||||
|
||||
SafeHtml nextItem=new SafeHtmlBuilder().appendEscaped(
|
||||
msgs.buttonNextLabel()).toSafeHtml();
|
||||
|
||||
cardMoveToolBar.addItem(nextItem,menuCommandNext);
|
||||
|
||||
dockPanel = new DockPanel();
|
||||
dockPanel.setSpacing(4);
|
||||
|
||||
dockPanel.add(deckPanel , DockPanel.CENTER);
|
||||
dockPanel.add(cardMoveToolBar, DockPanel.SOUTH);
|
||||
|
||||
|
||||
dockPanel.setWidth("100%");
|
||||
setWidget(dockPanel);
|
||||
|
||||
}
|
||||
|
||||
protected void initWindow() {
|
||||
GWT.log(title);
|
||||
setModal(true);
|
||||
setGlassEnabled(true);
|
||||
setAnimationEnabled(true);
|
||||
setText(title);
|
||||
this.originalTitle = title;
|
||||
}
|
||||
|
||||
|
||||
public void addListener(WizardListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(WizardListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the next available card.
|
||||
*/
|
||||
public void nextCard() {
|
||||
|
||||
int index=deckPanel.getVisibleWidget();
|
||||
Widget activeItem =deckPanel.getWidget(index);
|
||||
|
||||
if (activeItem instanceof WizardCard)
|
||||
((WizardCard) activeItem).dispose();
|
||||
|
||||
int cardPos = cardStack.indexOf(activeItem);
|
||||
|
||||
// NEXT ->
|
||||
|
||||
nextButton.setEnabled(true);
|
||||
backButton.setEnabled(true);
|
||||
|
||||
int newPos = cardPos + 1;
|
||||
|
||||
if (newPos == 0) {
|
||||
// we are moving forward from the first card
|
||||
backButton.setEnabled(false);
|
||||
}
|
||||
|
||||
nextButtonAction = null;
|
||||
previousButtonAction = null;
|
||||
GWT.log("cardStack size:" + cardStack.size());
|
||||
WizardCard card = cardStack.get(newPos);
|
||||
deckPanel.add(card);
|
||||
int showIndex=deckPanel.getWidgetIndex(card);
|
||||
deckPanel.showWidget(showIndex);
|
||||
|
||||
if (card instanceof WizardCard)
|
||||
((WizardCard) card).setup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the previous available card.
|
||||
*/
|
||||
public void previousCard() {
|
||||
int index=deckPanel.getVisibleWidget();
|
||||
Widget activeItem =deckPanel.getWidget(index);
|
||||
|
||||
if (activeItem instanceof WizardCard)
|
||||
((WizardCard) activeItem).dispose();
|
||||
|
||||
int cardPos = cardStack.indexOf(activeItem);
|
||||
|
||||
// BACK <-
|
||||
|
||||
nextButton.setEnabled(true);
|
||||
backButton.setEnabled(true);
|
||||
|
||||
int newPos = cardPos - 1;
|
||||
|
||||
if (newPos == 0) {
|
||||
backButton.setEnabled(false);
|
||||
}
|
||||
|
||||
nextButtonAction = null;
|
||||
previousButtonAction = null;
|
||||
|
||||
WizardCard card = cardStack.get(newPos);
|
||||
deckPanel.add(card);
|
||||
int showIndex=deckPanel.getWidgetIndex(card);
|
||||
deckPanel.showWidget(showIndex);
|
||||
|
||||
if (card instanceof WizardCard)
|
||||
((WizardCard) card).setup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of available cards.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getCardStackSize() {
|
||||
return cardStack.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current active card.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getCurrentCard() {
|
||||
int index=deckPanel.getVisibleWidget();
|
||||
Widget activeItem =deckPanel.getWidget(index);
|
||||
return cardStack.indexOf(activeItem);
|
||||
}
|
||||
|
||||
public boolean checkBeforeClose() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void close(boolean check) {
|
||||
checkBeforeClose = check;
|
||||
hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label of next button to "Finish" value and add a close command
|
||||
* to it.
|
||||
*/
|
||||
public void setNextButtonToFinish() {
|
||||
nextButton.setText(msgs.buttonFinishLabel());
|
||||
//nextButton.setIcon(GCResources.INSTANCE.wizardGo());
|
||||
//nextButton.setIconAlign(IconAlign.RIGHT);
|
||||
nextButtonAction = new Command() {
|
||||
|
||||
public void execute() {
|
||||
close(false);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the command for the next button.
|
||||
*
|
||||
* @param command
|
||||
* the command to execute.
|
||||
*/
|
||||
public void setNextButtonCommand(Command command) {
|
||||
nextButtonAction = command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the command for the previous button.
|
||||
*
|
||||
* @param command
|
||||
* the command to execute.
|
||||
*/
|
||||
public void setPreviousButtonCommand(Command command) {
|
||||
previousButtonAction = command;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
|
||||
int index=deckPanel.getVisibleWidget();
|
||||
GWT.log("Visible widget: "+index);
|
||||
Widget activeItem;
|
||||
if(index==-1){
|
||||
if(deckPanel.getWidgetCount()>0){
|
||||
deckPanel.showWidget(0);
|
||||
activeItem=deckPanel.getWidget(0);
|
||||
if (activeItem instanceof WizardCard)
|
||||
((WizardCard) activeItem).setup();
|
||||
backButton.setEnabled(false);
|
||||
|
||||
} else {
|
||||
backButton.setEnabled(false);
|
||||
nextButton.setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
deckPanel.showWidget(index);
|
||||
activeItem=deckPanel.getWidget(index);
|
||||
if (activeItem instanceof WizardCard)
|
||||
((WizardCard) activeItem).setup();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the card list.
|
||||
*
|
||||
* @param cards
|
||||
*/
|
||||
public void setCards(ArrayList<WizardCard> cards) {
|
||||
for (WizardCard card : cards) {
|
||||
addCard(card);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a card to this wizard.
|
||||
*
|
||||
* @param card
|
||||
* the card to add.
|
||||
*/
|
||||
public void addCard(WizardCard card) {
|
||||
card.setWizardWindow(this);
|
||||
|
||||
if(deckPanel.getVisibleWidget()>-1){
|
||||
int index=deckPanel.getVisibleWidget();
|
||||
deckPanel.remove(index);
|
||||
}
|
||||
deckPanel.add(card);
|
||||
cardStack.add(card);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a card to this wizard.
|
||||
*
|
||||
* @param card
|
||||
* the card to add.
|
||||
*/
|
||||
public void removeCard(WizardCard card) {
|
||||
deckPanel.remove(card);
|
||||
cardStack.remove(card);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the next button on the wizard.
|
||||
*
|
||||
* @param enable
|
||||
* <code>true</code> to enable the next button,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public void setEnableNextButton(boolean enable) {
|
||||
nextButton.setEnabled(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the back button on the wizard.
|
||||
*
|
||||
* @param enable
|
||||
* <code>true</code> to enable the back button,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public void setEnableBackButton(boolean enable) {
|
||||
backButton.setEnabled(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the next button label.
|
||||
*
|
||||
* @param text
|
||||
* the button label.
|
||||
*/
|
||||
protected void setNextButtonText(String text) {
|
||||
nextButton.setText(text);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the back button label.
|
||||
*
|
||||
* @param text
|
||||
* the button label.
|
||||
*/
|
||||
protected void setBackButtonText(String text) {
|
||||
backButton.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets visible next button.
|
||||
*
|
||||
* @param visible
|
||||
*/
|
||||
protected void setNextButtonVisible(boolean visible) {
|
||||
nextButton.setVisible(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets visible back button.
|
||||
*
|
||||
* @param visible
|
||||
*/
|
||||
protected void setBackButtonVisible(boolean visible) {
|
||||
backButton.setVisible(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a listener to the next button.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to add.
|
||||
*/
|
||||
protected void addNextButtonListener(ClickHandler listener) {
|
||||
nextButton.addClickHandler(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the originalTitle
|
||||
*/
|
||||
public String getOriginalTitle() {
|
||||
return originalTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the card list.
|
||||
*
|
||||
* @return teh card list.
|
||||
*/
|
||||
public ArrayList<WizardCard> getCardStack() {
|
||||
return cardStack;
|
||||
}
|
||||
|
||||
public void showErrorAndHide(final String title, final String message,
|
||||
final String details, final Throwable throwable) {
|
||||
GWTMessages.alert(title, message + " " + details,
|
||||
new Callback<Void, Void>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Void reason) {
|
||||
hide();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
hide();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package org.gcube.portlets.widgets.githubconnector.shared.git.credential;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class GitHubCredential implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6198756446799134610L;
|
||||
private GitHubCredentialType type;
|
||||
|
||||
public GitHubCredential() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GitHubCredential(GitHubCredentialType type) {
|
||||
super();
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public GitHubCredentialType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GitHubCredential [type=" + type + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package org.gcube.portlets.widgets.githubconnector.shared.git.credential;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class GitHubCredentialAnonymous extends GitHubCredential {
|
||||
|
||||
private static final long serialVersionUID = 6967297424938062981L;
|
||||
|
||||
public GitHubCredentialAnonymous() {
|
||||
super(GitHubCredentialType.Anonymous);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GitHubCredentialAnonymous []";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.gcube.portlets.widgets.githubconnector.shared.git.credential;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class GitHubCredentialLogin extends GitHubCredential {
|
||||
|
||||
private static final long serialVersionUID = 6967297424938062981L;
|
||||
private String user;
|
||||
private String password;
|
||||
|
||||
public GitHubCredentialLogin() {
|
||||
super(GitHubCredentialType.Login);
|
||||
}
|
||||
|
||||
public GitHubCredentialLogin(String user, String password) {
|
||||
super(GitHubCredentialType.Login);
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GitHubCredentialLogin [user=" + user + ", password=" + password
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package org.gcube.portlets.widgets.githubconnector.shared.git.credential;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class GitHubCredentialOAuth2 extends GitHubCredential {
|
||||
|
||||
private static final long serialVersionUID = 6967297424938062981L;
|
||||
private String token;
|
||||
|
||||
public GitHubCredentialOAuth2() {
|
||||
super(GitHubCredentialType.OAuth2);
|
||||
}
|
||||
|
||||
public GitHubCredentialOAuth2(String token) {
|
||||
super(GitHubCredentialType.OAuth2);
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GitHubCredentialOAuth2 [token=" + token + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package org.gcube.portlets.widgets.githubconnector.shared.git.credential;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum GitHubCredentialType {
|
||||
Anonymous("Anonymous"),
|
||||
OAuth2("OAuth2"),
|
||||
Login("Login");
|
||||
|
||||
|
||||
/**
|
||||
* @param text
|
||||
*/
|
||||
private GitHubCredentialType(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private final String id;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public static GitHubCredentialType getFromId(String id) {
|
||||
for (GitHubCredentialType type : values()) {
|
||||
if (type.id.compareToIgnoreCase(id) == 0) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,14 +1,18 @@
|
||||
<%@page contentType="text/html"%>
|
||||
<%@page pageEncoding="UTF-8"%>
|
||||
|
||||
|
||||
<!-- -->
|
||||
<!-- The module reference below is the link -->
|
||||
<!-- between html and your Web Toolkit module -->
|
||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/githubman/reset.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/GitHubConnector.css" type="text/css">
|
||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/gxt/css/gxt-all.css" type="text/css">
|
||||
<script src='<%=request.getContextPath()%>/githubman/js/jquery-1.10.1.min.js'></script>
|
||||
<script src='<%=request.getContextPath()%>/githubman/githubman.nocache.js'></script>
|
||||
|
||||
<!-- between html and your Web Toolkit module -->
|
||||
<!-- <link rel="stylesheet" href="<%=request.getContextPath()%>/githubman/reset.css" type="text/css"/> -->
|
||||
<link rel="stylesheet"
|
||||
href="<%=request.getContextPath()%>/GitHubConnector.css"
|
||||
type="text/css">
|
||||
|
||||
<script
|
||||
src='<%=request.getContextPath()%>/githubman/js/jquery-1.11.0.min.js'></script>
|
||||
<script
|
||||
src='<%=request.getContextPath()%>/githubman/githubman.nocache.js'></script>
|
||||
|
||||
|
||||
<div class="contentDiv" id="contentDiv"></div>
|
||||
|