diff --git a/serepo-client-webapp/pom.xml b/serepo-client-webapp/pom.xml index b48881b..b4099b3 100644 --- a/serepo-client-webapp/pom.xml +++ b/serepo-client-webapp/pom.xml @@ -72,6 +72,11 @@ commons-csv 1.3 + + com.github.vaadin4qbanos + jsclipboard + 1.0.3 + javax.servlet javax.servlet-api diff --git a/serepo-client-webapp/src/main/java/ch/hsr/isf/serepo/client/webapp/view/seitems/CommitInfoComponent.java b/serepo-client-webapp/src/main/java/ch/hsr/isf/serepo/client/webapp/view/seitems/CommitInfoComponent.java index 4331d48..66ad803 100644 --- a/serepo-client-webapp/src/main/java/ch/hsr/isf/serepo/client/webapp/view/seitems/CommitInfoComponent.java +++ b/serepo-client-webapp/src/main/java/ch/hsr/isf/serepo/client/webapp/view/seitems/CommitInfoComponent.java @@ -4,6 +4,7 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.jsclipboard.ClipboardButton; import com.vaadin.server.FontAwesome; import com.vaadin.server.Resource; import com.vaadin.shared.ui.MarginInfo; @@ -15,6 +16,8 @@ import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Notification; +import com.vaadin.ui.TextField; import com.vaadin.ui.themes.ValoTheme; import ch.hsr.isf.serepo.client.webapp.AppNavigator; @@ -42,6 +45,7 @@ public void addComponent(Component c) { private ComboBox cmbxRepositories = new ComboBox(); private ComboBox cmbxCommits = new ComboBox(); private boolean cmbxValueChangeListenerEnabled = false; + private TextField tfCommitId = new TextField(null, ""); public CommitInfoComponent() { createLayout(); @@ -98,6 +102,23 @@ public void buttonClick(ClickEvent event) { layout.addComponent(btnCommit); configCommitsCmbx(); layout.addComponent(cmbxCommits); + + tfCommitId.setId("textfield-commitid"); + tfCommitId.setWidth("350px"); + tfCommitId.addStyleName(ValoTheme.TEXTFIELD_SMALL); + layout.addComponent(tfCommitId); + + ClipboardButton clipboardButton = new ClipboardButton("textfield-commitid"); + clipboardButton.addSuccessListener(new ClipboardButton.SuccessListener() { + private static final long serialVersionUID = -71258407509006880L; + + @Override + public void onSuccess() { + Notification.show("CommitId was copied to clipboard"); + } + }); + clipboardButton.setClipboardButtonCaption("Copy"); + layout.addComponent(clipboardButton); } private void configRepositoriesCmbx() { @@ -186,6 +207,7 @@ public void setCommitId(String commitId) { } finally { cmbxValueChangeListenerEnabled = true; } + tfCommitId.setValue(commitId); } }