Search in sources :

Example 11 with TabTitle

use of com.igormaznitsa.sciareto.ui.tabs.TabTitle in project netbeans-mmd-plugin by raydac.

the class MainFrame method menuFileMenuSelected.

// GEN-LAST:event_menuEditMenuDeselected
private void menuFileMenuSelected(javax.swing.event.MenuEvent evt) {
    // GEN-FIRST:event_menuFileMenuSelected
    final TabTitle title = this.getFocusedTab();
    updateMenuItemsForProvider(title == null ? null : title.getProvider());
}
Also used : TabTitle(com.igormaznitsa.sciareto.ui.tabs.TabTitle)

Example 12 with TabTitle

use of com.igormaznitsa.sciareto.ui.tabs.TabTitle in project netbeans-mmd-plugin by raydac.

the class MainFrame method doClosing.

private boolean doClosing() {
    endFullScreenIfActive();
    boolean hasUnsaved = false;
    for (final TabTitle t : tabPane) {
        hasUnsaved |= t.isChanged();
    }
    if (hasUnsaved) {
        if (!DialogProviderManager.getInstance().getDialogProvider().msgConfirmOkCancel(null, "Detected non-saved documents", "Detected unsaved documents! Close application?")) {
            return false;
        }
    }
    if (!this.stateless) {
        saveState();
    }
    return true;
}
Also used : TabTitle(com.igormaznitsa.sciareto.ui.tabs.TabTitle)

Example 13 with TabTitle

use of com.igormaznitsa.sciareto.ui.tabs.TabTitle in project netbeans-mmd-plugin by raydac.

the class MainFrame method deleteTreeNode.

@Override
public boolean deleteTreeNode(@Nonnull final NodeFileOrFolder node) {
    final File file = node.makeFileForNode();
    if (file != null && file.exists()) {
        final List<TabTitle> tabsToClose = this.tabPane.findListOfRelatedTabs(file);
        boolean hasUnsaved = false;
        for (final TabTitle t : tabsToClose) {
            hasUnsaved |= t.isChanged();
        }
        if (hasUnsaved && !DialogProviderManager.getInstance().getDialogProvider().msgConfirmOkCancel(null, "Confirmation", "Are you sure to delete changed unsaved file?")) {
            return false;
        }
        closeTab(tabsToClose.toArray(new TabTitle[tabsToClose.size()]));
        final NodeProject project = findProjectForFile(file);
        List<File> affectedFiles = project == null ? Collections.EMPTY_LIST : project.findAffectedFiles(file);
        final Iterator<File> iterator = affectedFiles.iterator();
        final Path removingFile = file.toPath();
        while (iterator.hasNext()) {
            if (iterator.next().toPath().startsWith(removingFile)) {
                iterator.remove();
            }
        }
        if (!affectedFiles.isEmpty()) {
            affectedFiles = UiUtils.showSelectAffectedFiles(affectedFiles);
            if (affectedFiles == null) {
                return false;
            }
        }
        boolean ok = false;
        if (file.isDirectory()) {
            if (SystemUtils.deleteFile(file, DELETE_MOVING_FILE_TO_TRASH)) {
                ok = true;
            } else {
                DialogProviderManager.getInstance().getDialogProvider().msgError(null, "Can't delete directory, see the log!");
            }
        } else {
            ok = SystemUtils.deleteFile(file, DELETE_MOVING_FILE_TO_TRASH);
            if (!ok) {
                DialogProviderManager.getInstance().getDialogProvider().msgError(null, "Can't delete file!");
            }
        }
        if (ok) {
            explorerTree.deleteNode(node);
        }
        if (!affectedFiles.isEmpty() && project != null) {
            final List<File> changedFiles = project.deleteAllLinksToFile(affectedFiles, file);
            if (!changedFiles.isEmpty()) {
                for (final TabTitle t : tabPane) {
                    final File associated = t.getAssociatedFile();
                    if (associated != null && changedFiles.contains(associated)) {
                        t.reload(true);
                    }
                }
            }
        }
        return ok;
    }
    return false;
}
Also used : Path(java.nio.file.Path) NodeProject(com.igormaznitsa.sciareto.ui.tree.NodeProject) TabTitle(com.igormaznitsa.sciareto.ui.tabs.TabTitle) File(java.io.File)

Example 14 with TabTitle

use of com.igormaznitsa.sciareto.ui.tabs.TabTitle in project netbeans-mmd-plugin by raydac.

the class MainFrame method editPreferences.

@Override
public void editPreferences() {
    final PreferencesPanel configPanel = new PreferencesPanel(this);
    configPanel.load(PreferencesManager.getInstance().getPreferences());
    if (DialogProviderManager.getInstance().getDialogProvider().msgOkCancel(null, "Preferences", configPanel)) {
        configPanel.save();
        for (final TabTitle t : this.tabPane) {
            t.getProvider().updateConfiguration();
        }
    }
}
Also used : PreferencesPanel(com.igormaznitsa.sciareto.preferences.PreferencesPanel) TabTitle(com.igormaznitsa.sciareto.ui.tabs.TabTitle)

Example 15 with TabTitle

use of com.igormaznitsa.sciareto.ui.tabs.TabTitle 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)

Aggregations

TabTitle (com.igormaznitsa.sciareto.ui.tabs.TabTitle)16 File (java.io.File)3 NodeProject (com.igormaznitsa.sciareto.ui.tree.NodeProject)2 ExtraFile (com.igormaznitsa.mindmap.model.ExtraFile)1 PreferencesPanel (com.igormaznitsa.sciareto.preferences.PreferencesPanel)1 FindFilesForTextPanel (com.igormaznitsa.sciareto.ui.FindFilesForTextPanel)1 FindUsagesPanel (com.igormaznitsa.sciareto.ui.FindUsagesPanel)1 NodeFileOrFolder (com.igormaznitsa.sciareto.ui.tree.NodeFileOrFolder)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 JPopupMenu (javax.swing.JPopupMenu)1 JSeparator (javax.swing.JSeparator)1