use of com.vaadin.ui.UI in project opennms by OpenNMS.
the class SSHWindowTest method setup.
@SuppressWarnings("serial")
@Before
public void setup() {
app = new UI() {
@Override
public void init(VaadinRequest request) {
}
};
sshWindow = new SSHWindow(null, 200, 200);
client = SshClient.setUpDefaultClient();
client.start();
try {
session = client.connect(testHost, testPort).await().getSession();
} catch (Exception e) {
fail("Could not connect to host");
}
sshWindow2 = new SSHWindow(session, 200, 200);
app.addWindow(sshWindow);
app.addWindow(sshWindow2);
}
use of com.vaadin.ui.UI in project opennms by OpenNMS.
the class SSHTerminalTest method setUp.
@SuppressWarnings("serial")
@Before
public void setUp() throws Exception {
app = new UI() {
@Override
public void init(VaadinRequest request) {
}
};
mainWindow = new VerticalLayout();
app.setContent(mainWindow);
SSHWindow sshWindow = new SSHWindow(null, 200, 200);
app.addWindow(sshWindow);
SshClient client = SshClient.setUpDefaultClient();
client.start();
ClientSession session = null;
try {
session = client.connect(testHost, testPort).await().getSession();
} catch (Exception e) {
fail("Could not connect to host");
}
sshTerm = new SSHTerminal(sshWindow, session, 200, 200);
sshWindow.setContent(sshTerm);
UI.setCurrent(app);
}
use of com.vaadin.ui.UI in project VaadinUtils by rlsutton1.
the class BaseCrudView method initButtons.
private void initButtons() {
actionNewButton.addClickListener(new ClickEventLogged.ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void clicked(ClickEvent event) {
if (isDirty()) {
Notification.show("You must Save or Discard your changes first", Type.ERROR_MESSAGE);
return;
}
newClicked();
}
});
actionApplyButton.addClickListener(new ClickEventLogged.ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void clicked(ClickEvent event) {
final Object entityId = entityTable.getValue();
if (entityId != null) {
@SuppressWarnings("unchecked") CrudAction<E> action = (CrudAction<E>) actionCombo.getValue();
if (action != null) {
if (action.showPreparingDialog()) {
performActionWithWaitDialog(entityId, action);
} else {
performAction(entityId, action);
}
} else {
Notification.show("Please select an Action first.");
}
} else {
Notification.show("Please select record first.");
}
}
private void performAction(final Object entityId, final CrudAction<E> action) {
EntityItem<E> entity = container.getItem(entityId);
if (interceptAction(action, entity)) {
action.exec(BaseCrudView.this, entity);
}
container.commit();
container.refreshItem(entity.getItemId());
// actionCombo.select(actionCombo.getNullSelectionItemId());
}
private void performActionWithWaitDialog(final Object entityId, final CrudAction<E> action) {
final ConfirmDialog pleaseWaitMessage = createPleaseWaitDialog();
if (action != null) {
// we have to delay, because if we try to close the window
// before it's created - that won't work.
final ScheduledExecutorService exec = Executors.newScheduledThreadPool(1);
final EntityManagerRunnable runner = invokeAction(entityId, pleaseWaitMessage, action);
exec.schedule(runner, 1, TimeUnit.SECONDS);
exec.shutdown();
UI.getCurrent().setPollInterval(500);
}
}
private EntityManagerRunnable invokeAction(final Object entityId, final ConfirmDialog pleaseWaitMessage, final CrudAction<E> action) {
final EntityManagerRunnable runner = new EntityManagerRunnable(new RunnableUI(UI.getCurrent()) {
@Override
protected void run(final UI ui) {
ui.access(new Runnable() {
@Override
public void run() {
try {
EntityItem<E> entity = container.getItem(entityId);
if (interceptAction(action, entity)) {
action.exec(BaseCrudView.this, entity);
}
container.commit();
container.refreshItem(entity.getItemId());
// actionCombo.select(actionCombo.getNullSelectionItemId());
} finally {
pleaseWaitMessage.close();
ui.setPollInterval(-1);
}
}
});
}
});
return runner;
}
private ConfirmDialog createPleaseWaitDialog() {
final ConfirmDialog pleaseWaitMessage = ConfirmDialog.show(UI.getCurrent(), "Please wait...", new ConfirmDialog.Listener() {
private static final long serialVersionUID = 1L;
@Override
public void onClose(ConfirmDialog dialog) {
}
});
pleaseWaitMessage.setClosable(false);
pleaseWaitMessage.getCancelButton().setVisible(false);
pleaseWaitMessage.getOkButton().setVisible(false);
pleaseWaitMessage.setModal(true);
pleaseWaitMessage.setCaption("Preparing Action");
return pleaseWaitMessage;
}
});
}
use of com.vaadin.ui.UI in project VaadinUtils by rlsutton1.
the class SendEmailTask method sendMessages.
private void sendMessages(final List<JasperTransmission> targets, final JasperProxy proxy) {
new EntityManagerThread<Void>(new CallableUI<Void>(UI.getCurrent()) {
@Override
protected Void call(UI ui) throws Exception {
int sent = 0;
try {
for (JasperTransmission transmission : targets) {
if (cancel == true)
break;
try {
JasperManager manager = proxy.getManager();
RenderedReport renderedHtml = manager.export(OutputFormat.HTML, null);
RenderedReport renderedPDF = manager.export(OutputFormat.PDF, null);
JasperEmailBuilder builder = new JasperEmailBuilder(proxy.getEmailSettings());
builder.setFrom(proxy.getSenderEmailAddress()).setSubject(proxy.getSubject()).setHtmlBody(renderedHtml).addTo(transmission.getRecipientEmailAddress()).addAttachement(renderedPDF.getBodyAsDataSource("report.pdf", AttachmentType.PDF));
builder.send(false);
} catch (EmailException e) {
logger.error(e, e);
transmission.setException(e);
SendEmailTask.super.taskItemError(transmission);
VUNotification.show(e, Type.ERROR_MESSAGE);
}
}
} catch (Exception e) {
VUNotification.show(e, Type.ERROR_MESSAGE);
throw e;
} finally {
SendEmailTask.super.taskComplete(sent);
}
return null;
}
});
}
use of com.vaadin.ui.UI in project VaadinUtils by rlsutton1.
the class ReportParameterTable method addSelectionListener.
@Override
public void addSelectionListener(final ValueChangeListener listener) {
UI ui = UI.getCurrent();
if (ui != null) {
Runnable runner = new Runnable() {
@Override
public void run() {
grid.addSelectionListener(new SelectionListener() {
/**
*/
private static final long serialVersionUID = 1L;
@Override
public void select(SelectionEvent event) {
listener.valueChange(new ValueChangeEvent() {
/**
*/
private static final long serialVersionUID = 1L;
@Override
public Property<Collection<Long>> getProperty() {
return new Property<Collection<Long>>() {
/**
*/
private static final long serialVersionUID = 1L;
@Override
public Collection<Long> getValue() {
return getSelectedIds();
}
@Override
public void setValue(Collection<Long> newValue) throws com.vaadin.data.Property.ReadOnlyException {
}
@Override
public Class<? extends Collection<Long>> getType() {
return null;
}
@Override
public boolean isReadOnly() {
return false;
}
@Override
public void setReadOnly(boolean newStatus) {
}
};
}
});
}
});
}
};
UI.getCurrent().accessSynchronously(runner);
} else {
logger.warn("No vaadin session available, not setting up UI");
}
}
Aggregations