use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.
the class CNameListGenerators method getNameList.
/**
* Generates a name list from the names of the given projects.
*
* @param projects The projects that provide the names.
*
* @return The generated name list.
*/
public static String getNameList(final INaviProject[] projects) {
int count = 0;
final StringBuilder list = new StringBuilder();
for (final INaviProject project : projects) {
list.append("- ");
list.append(project.getConfiguration().getName());
list.append('\n');
count++;
if ((count == MAX_LIST_LENGTH) && (projects.length != MAX_LIST_LENGTH)) {
list.append("\n... ");
list.append(String.format("%d others ...", projects.length - count));
break;
}
}
return list.toString();
}
use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.
the class CProjectFunctions method createProject.
/**
* Creates a new project.
*
* @param parent Parent window used for dialogs.
* @param database Database where the project is created.
* @param updater Responsible for updating the project tree after the project was created.
*/
public static void createProject(final JFrame parent, final IDatabase database, final INodeSelectionUpdater updater) {
new Thread() {
@Override
public void run() {
try {
final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
operation.getProgressPanel().setMaximum(3);
operation.getProgressPanel().setText("Creating new project");
final INaviProject newProject = database.getContent().addProject("New Project");
operation.getProgressPanel().next();
try {
newProject.load();
} catch (final LoadCancelledException e) {
// Do nothing
}
operation.getProgressPanel().next();
createDefaultAddressSpace(parent, newProject);
updater.setObject(newProject);
updater.update();
operation.getProgressPanel().next();
operation.stop();
} catch (final CouldntSaveDataException exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00140: " + "New project could not be created";
final String innerDescription = CUtilityFunctions.createDescription("It was not possible to create a new project in the selected database.", new String[] { "There was a problem with the database connection." }, new String[] { "No new project was created in the selected database." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
} catch (final CouldntLoadDataException exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00141: " + "New project could not be loaded";
final String innerDescription = CUtilityFunctions.createDescription("The new project could not be loaded.", new String[] { "There was a problem with the database connection." }, new String[] { "The new project was created but it could not be loaded." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
}
}
}.start();
}
use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.
the class CProjectsModel method setValueAt.
@Override
public void setValueAt(final Object value, final int row, final int col) {
if ((col != NAME_COLUMN) && (col != DESCRIPTION_COLUMN)) {
throw new IllegalStateException("IE01172: Column can not be edited");
}
final INaviProject project = getProjects().get(row);
if (col == NAME_COLUMN) {
try {
project.getConfiguration().setName((String) value);
} catch (final CouldntSaveDataException e) {
CUtilityFunctions.logException(e);
final String innerMessage = "E00174: " + "Could not save project name";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The new name of the project '%s' could not be saved.", project.getConfiguration().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The project keeps its old name." });
NaviErrorDialog.show(null, innerMessage, innerDescription, e);
}
} else if (col == DESCRIPTION_COLUMN) {
try {
project.getConfiguration().setDescription((String) value);
} catch (final CouldntSaveDataException e) {
CUtilityFunctions.logException(e);
final String innerMessage = "E00175: " + "Could not save project description";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The new description of the project '%s' could not be saved.", project.getConfiguration().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The project keeps its old description." });
NaviErrorDialog.show(null, innerMessage, innerDescription, e);
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.
the class CProjectNodeMenuBuilder method getPluginProjects.
/**
* Returns the API project objects for the projects for which the menu was built.
*
* @return The API project objects.
*/
private List<Project> getPluginProjects() {
final DatabaseManager manager = PluginInterface.instance().getDatabaseManager();
for (final Database database : manager) {
if (database.getNative() == m_database) {
final List<Project> allProjects = database.getProjects();
final List<Project> menuProjects = new ArrayList<Project>();
for (final INaviProject project : m_projects) {
menuProjects.add(ObjectFinders.getObject(project, allProjects));
}
return menuProjects;
}
}
throw new IllegalStateException("IE01168: Unknown database");
}
use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.
the class CProjectNodeMenuBuilder method createMenu.
@Override
protected void createMenu(final JComponent menu) {
if ((m_projects.length == 1) && (m_addAddressSpaceAction == null)) {
// We delay the creation of the m_addAddressSpaceAction object because we need to have
// getSelectionUpdater working.
final INaviProject singleProject = m_projects[0];
m_addAddressSpaceAction = CActionProxy.proxy(new CAddAddressSpaceAction(getProjectTree(), singleProject, getSelectionUpdater()));
updateActions(singleProject);
}
final boolean isSingleSelection = m_projects.length == 1;
if (canOpen()) {
menu.add(new JMenuItem(m_loadProjectAction));
menu.add(new JSeparator());
}
if (isSingleSelection) {
// We can not search in more than one project at a time, and only if the project
// is already loaded.
menu.add(new JMenuItem(m_searchViewAction));
menu.add(new JSeparator());
// We do not allow the user to add address spaces to more than one
// project at a time. And the project must be loaded too.
menu.add(new JMenuItem(m_addAddressSpaceAction));
menu.add(new JSeparator());
menu.add(new JMenuItem(m_forwardAction));
menu.add(new JSeparator());
}
menu.add(new JMenuItem(CActionProxy.proxy(new CDeleteProjectAction(getParent(), m_database, m_projects, getParentUpdater()))));
if (m_table != null) {
menu.add(new JSeparator());
menu.add(new JMenuItem(CActionProxy.proxy(new CSearchTableAction(getParent(), m_table))));
menu.add(new JMenuItem(CActionProxy.proxy(new CopySelectionAction(m_table))));
}
addPluginMenus(menu);
}
Aggregations