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());
}
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;
}
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;
}
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();
}
}
}
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);
}
}
Aggregations