use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.
the class PostgreSQLProjectCreator method loadProject.
/**
* Loads a project from the database.
*
* @param provider The connection to the database.
* @param projectId The ID of the project to load.
*
* @return The loaded project.
*
* @throws SQLException Thrown if the project could not be loaded.
*/
protected static CProject loadProject(final AbstractSQLProvider provider, final int projectId) throws SQLException {
final String query = "select id, name, description, creation_date, modification_date from " + CTableNames.PROJECTS_TABLE + " where id = " + projectId;
try (ResultSet resultSet = provider.getConnection().executeQuery(query, true)) {
while (resultSet.next()) {
final String name = PostgreSQLHelpers.readString(resultSet, "name");
final String description = PostgreSQLHelpers.readString(resultSet, "description");
final int addressSpaceCount = 0;
final Timestamp creationDate = resultSet.getTimestamp("creation_date");
final Timestamp modificationDate = resultSet.getTimestamp("modification_date");
return new CProject(projectId, name, description, creationDate, modificationDate, addressSpaceCount, new ArrayList<DebuggerTemplate>(), provider);
}
}
return null;
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.
the class PostgreSQLDatabaseFunctions method getAssignedDebuggers.
/**
* Determines the debuggers that are assigned to a project.
*
* @param connection Connection to the SQL database where the information is stored.
* @param projectId ID of the project in question.
* @param debuggerManager Debugger manager object that belongs to the given database.
* @return A list that contains the debugger templates assigned to the given project.
* @throws CouldntLoadDataException Thrown if the debugger templates could not be loaded.
*/
protected static List<DebuggerTemplate> getAssignedDebuggers(final CConnection connection, final int projectId, final DebuggerTemplateManager debuggerManager) throws CouldntLoadDataException {
Preconditions.checkNotNull(connection, "IE02264: Connection argument can not be null");
Preconditions.checkArgument(projectId > 0, "Project id %s must be a positive integer.", projectId);
Preconditions.checkNotNull(debuggerManager, "IE02265: debugger manager argument can not be null");
final List<DebuggerTemplate> debuggerIds = new ArrayList<>();
final String query = String.format("SELECT debugger_id FROM %s WHERE project_id = %d", CTableNames.PROJECT_DEBUGGERS_TABLE, projectId);
try (ResultSet resultSet = connection.executeQuery(query, true)) {
while (resultSet.next()) {
debuggerIds.add(debuggerManager.findDebugger(resultSet.getInt("debugger_id")));
}
} catch (final SQLException exception) {
throw new CouldntLoadDataException(exception);
}
return debuggerIds;
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.
the class CDebuggerComboModel method updateElements.
/**
* Updates the elements of the combobox after relevant changes to the debugger container.
*/
private void updateElements() {
comboboxElements.clear();
comboboxElements.add(new CDebuggerTemplateWrapper(null));
for (final DebuggerTemplate template : debuggerContainer.getDebuggers()) {
comboboxElements.add(new CDebuggerTemplateWrapper(template));
}
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.
the class CProjectNodeComponent method saveDebuggers.
/**
* Saves the configured project debuggers to the database.
*/
private void saveDebuggers() {
try {
final ListModel<DebuggerTemplate> model = m_checkedList.getModel();
final List<DebuggerTemplate> oldDebuggers = m_project.getConfiguration().getDebuggers();
for (int i = 0; i < model.getSize(); ++i) {
final DebuggerTemplate debugger = model.getElementAt(i);
if (m_checkedList.isChecked(i) && !oldDebuggers.contains(debugger)) {
m_project.getConfiguration().addDebugger(debugger);
} else if (!m_checkedList.isChecked(i) && oldDebuggers.contains(debugger)) {
m_project.getConfiguration().removeDebugger(model.getElementAt(i));
}
}
} catch (final CouldntSaveDataException e) {
CUtilityFunctions.logException(e);
final String innerMessage = "E00173: " + "Could not save project debuggers";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The new debuggers of the project '%s' could not be saved.", m_project.getConfiguration().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The project keeps its old debuggers." });
NaviErrorDialog.show(SwingUtilities.getWindowAncestor(CProjectNodeComponent.this), innerMessage, innerDescription, e);
}
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.
the class CProjectNodeComponent method updateCheckedListPanel.
/**
* Because the checked list box can not yet deal with growing or shrinking models, the checked
* list box is recreated by this function if necessary.
*/
private void updateCheckedListPanel() {
m_checkedList.removeListSelectionListener(m_updateListener);
m_checkedListPanel.removeAll();
m_checkedList = new JCheckedListbox<>(getDebuggerVector(), false);
m_checkedList.addListSelectionListener(m_updateListener);
final JScrollPane debuggerScrollPane = new JScrollPane(m_checkedList);
m_checkedListPanel.add(debuggerScrollPane);
final Collection<DebuggerTemplate> debuggers = m_project.getConfiguration().getDebuggers();
final ListModel<DebuggerTemplate> model = m_checkedList.getModel();
for (int i = 0; i < model.getSize(); ++i) {
final DebuggerTemplate debuggerId = model.getElementAt(i);
m_checkedList.setChecked(i, debuggers.contains(debuggerId));
}
m_checkedList.updateUI();
updateUI();
}
Aggregations