use of org.parosproxy.paros.model.SessionListener in project zaproxy by zaproxy.
the class MenuFileControl method openSession.
public boolean openSession(String session) {
final Object[] opened = { Boolean.TRUE };
File sessionFile = new File(session);
waitMessageDialog = view.getWaitMessageDialog(Constant.messages.getString("menu.file.loadSession"));
log.info("opening session file " + sessionFile.getAbsolutePath());
control.openSession(sessionFile, new SessionListener() {
@Override
public void sessionSnapshot(Exception e) {
}
@Override
public void sessionSaved(Exception e) {
}
@Override
public void sessionOpened(final File file, final Exception e) {
if (EventQueue.isDispatchThread()) {
if (e != null) {
view.showWarningDialog(Constant.messages.getString("menu.file.openSession.error"));
log.error("error opening session file " + model.getSession().getFileName(), e);
opened[0] = Boolean.FALSE;
}
view.getSiteTreePanel().getTreeSite().setModel(model.getSession().getSiteTree());
if (waitMessageDialog != null) {
waitMessageDialog.setVisible(false);
waitMessageDialog = null;
}
} else {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
sessionOpened(file, e);
}
});
}
}
});
waitMessageDialog.setVisible(true);
return opened[0] == Boolean.TRUE;
}
use of org.parosproxy.paros.model.SessionListener in project zaproxy by zaproxy.
the class MenuFileControl method newSession.
public boolean newSession(String fileName) {
final Object[] created = { Boolean.TRUE };
waitMessageDialog = view.getWaitMessageDialog(Constant.messages.getString("menu.file.newSession.wait.dialogue"));
control.newSession(fileName, new SessionListener() {
@Override
public void sessionSnapshot(Exception e) {
}
@Override
public void sessionSaved(final Exception e) {
if (EventQueue.isDispatchThread()) {
if (e == null) {
view.getSiteTreePanel().getTreeSite().setModel(model.getSession().getSiteTree());
} else {
view.showWarningDialog(Constant.messages.getString("menu.file.newSession.error"));
log.error("Error creating session file " + model.getSession().getFileName(), e);
created[0] = Boolean.FALSE;
}
if (waitMessageDialog != null) {
waitMessageDialog.setVisible(false);
waitMessageDialog = null;
}
} else {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
sessionSaved(e);
}
});
}
}
@Override
public void sessionOpened(File file, Exception e) {
}
});
waitMessageDialog.setVisible(true);
return created[0] == Boolean.TRUE;
}
Aggregations