Search in sources :

Example 11 with AWorkspaceProject

use of org.freeplane.plugin.workspace.model.project.AWorkspaceProject in project freeplane by freeplane.

the class WorkspaceProjectOpenLocationAction method actionPerformed.

public void actionPerformed(ActionEvent event) {
    AWorkspaceProject project = WorkspaceController.getCurrentProject();
    if (project == null) {
        return;
    }
    openFolder(URIUtils.getAbsoluteFile(project.getProjectHome()));
}
Also used : AWorkspaceProject(org.freeplane.plugin.workspace.model.project.AWorkspaceProject)

Example 12 with AWorkspaceProject

use of org.freeplane.plugin.workspace.model.project.AWorkspaceProject in project freeplane by freeplane.

the class WorkspaceRemoveProjectAction method actionPerformed.

/**
 *********************************************************************************
 * REQUIRED METHODS FOR INTERFACES
 *********************************************************************************
 */
public void actionPerformed(ActionEvent e) {
    AWorkspaceProject project = WorkspaceController.getCurrentProject();
    if (project == null) {
        return;
    }
    // WORKSPACE - todo: dialog that asks for physical deletion as well
    int option = JOptionPane.showConfirmDialog(UITools.getFrame(), TextUtils.format("workspace.action.node.remove.confirm.text", project.getModel().getRoot().getName()), TextUtils.getRawText("workspace.action.node.remove.confirm.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (option == JOptionPane.YES_OPTION) {
        // AWorkspaceTreeNode targetNode = getNodeFromActionEvent(e);
        WorkspaceModel model = WorkspaceController.getCurrentModel();
        // model.removeProject(model.getProject(targetNode.getModel()));
        model.removeProject(project);
        model.getRoot().getModel().requestSave();
    }
}
Also used : AWorkspaceProject(org.freeplane.plugin.workspace.model.project.AWorkspaceProject) WorkspaceModel(org.freeplane.plugin.workspace.model.WorkspaceModel)

Example 13 with AWorkspaceProject

use of org.freeplane.plugin.workspace.model.project.AWorkspaceProject in project freeplane by freeplane.

the class WorkspaceModelExtensionWriterReader method registerAttributeHandlers.

private void registerAttributeHandlers(ReadManager reader) {
    reader.addAttributeHandler(MAP_EXTENSION_XML_TAG, PROJECT_ID_XML_TAG, new IAttributeHandler() {

        public void setAttribute(Object map, String value) {
            final MapModel mapModel = (MapModel) map;
            WorkspaceMapModelExtension wmme = WorkspaceController.getMapModelExtension(mapModel);
            if (wmme.getProject() == null) {
                AWorkspaceProject prj = WorkspaceController.getCurrentModel().getProject(value);
                if (prj == null) {
                    // WORKSPACE - todo: propagate exception
                    LogUtils.warn("project with id=" + value + " was not found");
                    return;
                }
                wmme.setProject(prj);
            }
        }
    });
    reader.addAttributeHandler(MAP_EXTENSION_XML_TAG, PROJECT_HOME_XML_TAG, new IAttributeHandler() {

        public void setAttribute(Object map, String value) {
            final MapModel mapModel = (MapModel) map;
            WorkspaceMapModelExtension wmme = WorkspaceController.getMapModelExtension(mapModel);
            if (wmme.getProject() == null) {
            // WORKSPACE - todo: find project for uri?
            // AWorkspaceProject prj = WorkspaceController.getCurrentModel().getProject(value);
            // if(prj == null) {
            // //WORKSPACE - todo: propagate exception
            // LogUtils.warn("project with id="+value+" was not found");
            // return;
            // }
            // wmme.setProject(prj);
            } else {
            // ignore
            }
        }
    });
}
Also used : AWorkspaceProject(org.freeplane.plugin.workspace.model.project.AWorkspaceProject) IAttributeHandler(org.freeplane.core.io.IAttributeHandler) MapModel(org.freeplane.features.map.MapModel)

Example 14 with AWorkspaceProject

use of org.freeplane.plugin.workspace.model.project.AWorkspaceProject in project freeplane by freeplane.

the class WorkspaceModelExtensionWriterReader method writeAttributes.

public void writeAttributes(ITreeWriter writer, Object userObject, IExtension extension) {
    final WorkspaceMapModelExtension wmme = extension != null ? (WorkspaceMapModelExtension) extension : WorkspaceController.getMapModelExtension(((NodeModel) userObject).getMap());
    AWorkspaceProject prj = wmme.getProject();
    if (prj == null) {
        return;
    }
    writer.addAttribute(PROJECT_ID_XML_TAG, prj.getProjectID());
    writer.addAttribute(PROJECT_HOME_XML_TAG, prj.getProjectHome().toString());
}
Also used : AWorkspaceProject(org.freeplane.plugin.workspace.model.project.AWorkspaceProject) NodeModel(org.freeplane.features.map.NodeModel)

Example 15 with AWorkspaceProject

use of org.freeplane.plugin.workspace.model.project.AWorkspaceProject in project freeplane by freeplane.

the class WorkspaceController method addMapToProject.

public static AWorkspaceProject addMapToProject(MapModel map, AWorkspaceProject project, boolean overwrite) {
    if (map == null || project == null) {
        throw new IllegalArgumentException("NULL");
    }
    WorkspaceMapModelExtension wmme = getMapModelExtension(map);
    AWorkspaceProject oldProject = wmme.getProject();
    if (overwrite || oldProject == null) {
        wmme.setProject(project);
    }
    return oldProject;
}
Also used : AWorkspaceProject(org.freeplane.plugin.workspace.model.project.AWorkspaceProject) WorkspaceMapModelExtension(org.freeplane.plugin.workspace.features.WorkspaceMapModelExtension)

Aggregations

AWorkspaceProject (org.freeplane.plugin.workspace.model.project.AWorkspaceProject)15 IOException (java.io.IOException)6 File (java.io.File)5 AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)3 Component (java.awt.Component)2 URI (java.net.URI)2 JButton (javax.swing.JButton)2 JOptionPane (javax.swing.JOptionPane)2 JPanel (javax.swing.JPanel)2 LOAD_RETURN_TYPE (org.freeplane.plugin.workspace.io.IProjectSettingsIOHandler.LOAD_RETURN_TYPE)2 WorkspaceModelException (org.freeplane.plugin.workspace.model.WorkspaceModelException)2 FolderLinkNode (org.freeplane.plugin.workspace.nodes.FolderLinkNode)2 LinkTypeFileNode (org.freeplane.plugin.workspace.nodes.LinkTypeFileNode)2 Dimension (java.awt.Dimension)1 FileFilter (java.io.FileFilter)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1