Skip to content

Commit

Permalink
Add commitId textfield and copy to clipboard button.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas committed Jun 25, 2017
1 parent 73ad5fa commit 3b0bf3c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions serepo-client-webapp/pom.xml
Expand Up @@ -72,6 +72,11 @@
<artifactId>commons-csv</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.github.vaadin4qbanos</groupId>
<artifactId>jsclipboard</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -186,6 +207,7 @@ public void setCommitId(String commitId) {
} finally {
cmbxValueChangeListenerEnabled = true;
}
tfCommitId.setValue(commitId);
}

}

0 comments on commit 3b0bf3c

Please sign in to comment.