use of org.freeplane.plugin.workspace.model.project.AWorkspaceProject in project freeplane by freeplane.
the class ImportProjectDialogPanel method readVersions.
private void readVersions(File home) {
for (File folder : home.listFiles(new FileFilter() {
public boolean accept(File pathname) {
if (pathname.isDirectory()) {
return true;
}
return false;
}
})) {
File settings = new File(folder, "settings.xml");
if (settings.exists()) {
AWorkspaceProject project = AWorkspaceProject.create(folder.getName(), home.getParentFile().toURI());
String item = new TempProjectLoader().getMetaInfo(project);
if (item == null) {
continue;
}
getComboBoxModel().addItem(new VersionItem(project, item, new Date(settings.lastModified())));
}
}
}
use of org.freeplane.plugin.workspace.model.project.AWorkspaceProject in project freeplane by freeplane.
the class NodeNewLinkAction method actionPerformed.
/**
*********************************************************************************
* METHODS
*********************************************************************************
*/
/**
*********************************************************************************
* REQUIRED METHODS FOR INTERFACES
*********************************************************************************
*/
public void actionPerformed(ActionEvent e) {
AWorkspaceTreeNode targetNode = null;
if (e == null || getRootPopupMenu((Component) e.getSource()) == null) {
targetNode = WorkspaceController.getCurrentProject().getModel().getRoot();
} else {
targetNode = getNodeFromActionEvent(e);
}
if (targetNode == null) {
return;
}
AWorkspaceProject project = WorkspaceController.getProject(targetNode);
if (targetNode instanceof AFolderNode) {
JFileChooser chooser = new JFileChooser(URIUtils.getAbsoluteFile(((AFolderNode) targetNode).getPath() == null ? WorkspaceController.getCurrentProject().getProjectHome() : ((AFolderNode) targetNode).getPath()));
chooser.setMultiSelectionEnabled(false);
int response = chooser.showOpenDialog(UITools.getFrame());
if (response == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
if (file != null) {
LinkTypeFileNode node = new LinkTypeFileNode();
node.setName(file.getName());
URI path = chooser.getSelectedFile().toURI();
if (path == null) {
return;
}
URI uri = project.getRelativeURI(path);
if (uri == null) {
node.setLinkURI(path);
} else {
node.setLinkURI(uri);
}
targetNode.getModel().addNodeTo(node, targetNode);
targetNode.refresh();
targetNode.getModel().requestSave();
}
}
}
}
use of org.freeplane.plugin.workspace.model.project.AWorkspaceProject in project freeplane by freeplane.
the class ProjectURLHandler method openConnection.
public URLConnection openConnection(URL url) throws IOException {
// WORKSPACE - todo: extend with meaningful exception messages
AWorkspaceProject project = WorkspaceController.getCurrentModel().getProject(url.getAuthority());
URL absolutePath = resolve(project, url);
return absolutePath.openConnection();
}
use of org.freeplane.plugin.workspace.model.project.AWorkspaceProject in project freeplane by freeplane.
the class MModeWorkspaceController method saveSettings.
private void saveSettings(String settingsPath) {
final File userPropertiesFolder = new File(settingsPath);
final File settingsFile = new File(userPropertiesFolder, USER_SETTINGS_FILENAME);
// clear old settings
String[] projectsIds = settings.getProperty(WORKSPACE_MODEL_PROJECTS, "").split(WORKSPACE_MODEL_PROJECTS_SEPARATOR);
for (String projectID : projectsIds) {
settings.remove(projectID);
}
// build new project stack
List<String> projectIDs = new ArrayList<String>();
synchronized (getModel().getProjects()) {
for (AWorkspaceProject project : getModel().getProjects()) {
saveProject(project);
if (projectIDs.contains(project.getProjectID())) {
continue;
}
projectIDs.add(project.getProjectID());
settings.setProperty(project.getProjectID(), project.getProjectHome().toString());
}
}
StringBuilder sb = new StringBuilder();
for (String prjId : projectIDs) {
if (sb.length() > 0) {
sb.append(WORKSPACE_MODEL_PROJECTS_SEPARATOR);
}
sb.append(prjId);
}
settings.setProperty(WORKSPACE_MODEL_PROJECTS, sb.toString());
OutputStream os = null;
try {
if (!settingsFile.exists()) {
settingsFile.getParentFile().mkdirs();
settingsFile.createNewFile();
}
os = new FileOutputStream(settingsFile);
settings.store(os, "user settings for the workspace");
} catch (final Exception ex) {
LogUtils.severe("could not store workspace settings.", ex);
} finally {
FileUtils.silentlyClose(os);
}
}
use of org.freeplane.plugin.workspace.model.project.AWorkspaceProject in project freeplane by freeplane.
the class MModeWorkspaceController method setupModel.
private void setupModel(ModeController modeController) {
String[] projectsIds = settings.getProperty(WORKSPACE_MODEL_PROJECTS, "").split(WORKSPACE_MODEL_PROJECTS_SEPARATOR);
for (String projectID : projectsIds) {
String projectHome = settings.getProperty(projectID);
if (projectHome == null) {
continue;
}
AWorkspaceProject project = null;
try {
project = AWorkspaceProject.create(projectID, URIUtils.createURI(projectHome));
getModel().addProject(project);
getProjectLoader().loadProject(project);
} catch (Exception e) {
LogUtils.severe(e);
if (project != null) {
getModel().removeProject(project);
}
}
}
}
Aggregations