Search in sources :

Example 6 with NodeProject

use of com.igormaznitsa.sciareto.ui.tree.NodeProject in project netbeans-mmd-plugin by raydac.

the class MainFrame method saveState.

private void saveState() {
    try {
        final List<File> files = new ArrayList<>();
        for (final NodeFileOrFolder p : this.explorerTree.getCurrentGroup()) {
            final File f = ((NodeProject) p).getFolder();
            if (f.isDirectory()) {
                files.add(f);
            }
        }
        FileHistoryManager.getInstance().saveActiveProjects(files.toArray(new File[files.size()]));
        files.clear();
        for (final TabTitle p : this.tabPane) {
            final File f = p.getAssociatedFile();
            if (f != null && f.isFile()) {
                files.add(f);
            }
        }
        FileHistoryManager.getInstance().saveActiveFiles(files.toArray(new File[files.size()]));
    } catch (IOException ex) {
        // NOI18N
        LOGGER.error("Can't save state", ex);
    }
}
Also used : NodeFileOrFolder(com.igormaznitsa.sciareto.ui.tree.NodeFileOrFolder) NodeProject(com.igormaznitsa.sciareto.ui.tree.NodeProject) TabTitle(com.igormaznitsa.sciareto.ui.tabs.TabTitle) IOException(java.io.IOException) File(java.io.File)

Example 7 with NodeProject

use of com.igormaznitsa.sciareto.ui.tree.NodeProject in project netbeans-mmd-plugin by raydac.

the class MMDEditor method getProjectFolder.

@Nullable
private File getProjectFolder() {
    File result = null;
    final File associatedFile = this.title.getAssociatedFile();
    if (associatedFile != null) {
        final NodeProject project = context.findProjectForFile(associatedFile);
        result = project == null ? null : project.getFolder();
    }
    return result;
}
Also used : NodeProject(com.igormaznitsa.sciareto.ui.tree.NodeProject) File(java.io.File) Nullable(javax.annotation.Nullable)

Example 8 with NodeProject

use of com.igormaznitsa.sciareto.ui.tree.NodeProject in project netbeans-mmd-plugin by raydac.

the class TabTitle method saveAs.

public boolean saveAs() throws IOException {
    boolean result = false;
    if (this.parent.saveDocumentAs()) {
        result = true;
        final NodeProject project = this.context.findProjectForFile(this.associatedFile);
        if (project != null) {
            project.getGroup().refreshProjectFolder(project, PrefUtils.isShowHiddenFilesAndFolders());
            this.context.focusInTree(this);
        }
    }
    return result;
}
Also used : NodeProject(com.igormaznitsa.sciareto.ui.tree.NodeProject)

Example 9 with NodeProject

use of com.igormaznitsa.sciareto.ui.tree.NodeProject in project netbeans-mmd-plugin by raydac.

the class NodeListRenderer method getListCellRendererComponent.

@Override
@Nonnull
public Component getListCellRendererComponent(@Nonnull final JList<?> list, @Nonnull final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    final NodeFileOrFolder node = (NodeFileOrFolder) value;
    final String ext = FilenameUtils.getExtension(node.toString()).toLowerCase(Locale.ENGLISH);
    if (!isSelected && COLOR_ROW_EVEN != null && COLOR_ROW_ODD != null) {
        if (index % 2 == 0) {
            this.setBackground(COLOR_ROW_EVEN);
        } else {
            this.setBackground(COLOR_ROW_ODD);
        }
    }
    if (node instanceof NodeProject || !node.isLeaf()) {
        this.setIcon(TreeCellRenderer.DEFAULT_FOLDER_CLOSED);
    } else if (ext.equals("mmd")) {
        // NOI18N
        this.setIcon(Icons.DOCUMENT.getIcon());
    } else if (PictureViewer.SUPPORTED_FORMATS.contains(ext)) {
        this.setIcon(TreeCellRenderer.ICON_IMAGE);
    } else {
        this.setIcon(TreeCellRenderer.DEFAULT_FILE);
    }
    this.setText(makeTextForNode(node));
    return this;
}
Also used : NodeFileOrFolder(com.igormaznitsa.sciareto.ui.tree.NodeFileOrFolder) NodeProject(com.igormaznitsa.sciareto.ui.tree.NodeProject) Nonnull(javax.annotation.Nonnull)

Aggregations

NodeProject (com.igormaznitsa.sciareto.ui.tree.NodeProject)9 File (java.io.File)6 NodeFileOrFolder (com.igormaznitsa.sciareto.ui.tree.NodeFileOrFolder)3 TabTitle (com.igormaznitsa.sciareto.ui.tabs.TabTitle)2 IOException (java.io.IOException)2 MindMap (com.igormaznitsa.mindmap.model.MindMap)1 FileLinkGraphPanel (com.igormaznitsa.sciareto.ui.misc.FileLinkGraphPanel)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 Path (java.nio.file.Path)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 LineIterator (org.apache.commons.io.LineIterator)1