Skip to content

Commit

Permalink
Fixed issue #709.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed Aug 18, 2023
1 parent 6e4e103 commit 6b2ba4b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
import org.nschmidt.ldparteditor.data.DatFile;
import org.nschmidt.ldparteditor.dialog.newproject.NewProjectDialog;
import org.nschmidt.ldparteditor.enumtype.MyLanguage;
import org.nschmidt.ldparteditor.enumtype.View;
import org.nschmidt.ldparteditor.i18n.I18n;
import org.nschmidt.ldparteditor.logger.NLogger;
import org.nschmidt.ldparteditor.project.Project;
Expand Down Expand Up @@ -132,7 +133,16 @@ private static boolean askForUnsavedChanges(Editor3DWindow win, boolean createOn
w.closeAllTabs();
}
}

Editor3DWindow.getWindow().closeAllComposite3D();

// Remove all opened files, unless they are unsaved
Project.getOpenedFiles().removeIf(df -> !Project.getUnsavedFiles().contains(df));
Editor3DWindow.getWindow().closeAllTabs();
Project.setFileToEdit(View.DUMMY_DATFILE);

// We may clear all old project informations
Project.clearProjectTree();
} else if (result == SWT.YES) {
// Keep the files open and continue
} else return false;
Expand Down
14 changes: 9 additions & 5 deletions src/org/nschmidt/ldparteditor/project/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ public static void create(boolean withFolders) {
createFileStructure(withFolders);
updateEditor();

clearProjectTree();

Editor3DWindow.getWindow().getShell().update();
Editor3DWindow.getWindow().getProjectParts().getParent().build();
Editor3DWindow.getWindow().getProjectParts().getParent().redraw();
Editor3DWindow.getWindow().getProjectParts().getParent().update();
}

public static void clearProjectTree() {
Editor3DWindow.getWindow().getProjectParts().getItems().clear();
Editor3DWindow.getWindow().getProjectParts().setData(new ArrayList<>());

Expand All @@ -86,11 +95,6 @@ public static void create(boolean withFolders) {

Editor3DWindow.getWindow().getProjectPrimitives8().getItems().clear();
Editor3DWindow.getWindow().getProjectPrimitives8().setData(new ArrayList<>());

Editor3DWindow.getWindow().getShell().update();
Editor3DWindow.getWindow().getProjectParts().getParent().build();
Editor3DWindow.getWindow().getProjectParts().getParent().redraw();
Editor3DWindow.getWindow().getProjectParts().getParent().update();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,6 @@ protected Control createContents(Composite parent) {
treeItemNewPart.setData(Project.getFileToEdit());
Project.addUnsavedFile(Project.getFileToEdit());


if (NLogger.debugging) {
try (UTF8BufferedReader reader = new UTF8BufferedReader("testsource.txt")) { //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3962,6 +3962,13 @@ public void closeTabWithDatFile(DatFile df) {
}
}
}

public void closeAllTabs() {
for (CTabItem ti : tabFolderOpenDatFilesPtr[0].getItems()) {
ti.dispose();
}
}


public static AtomicBoolean getNoSyncDeadlock() {
return no_sync_deadlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ private void addListeners() {
win.getOfficialParts().setData(null);
win.getSearchText().setText(" "); //$NON-NLS-1$
win.getSearchText().setText(""); //$NON-NLS-1$
win.updateTreeUnsavedEntries();
}

Project.setFileToEdit(View.DUMMY_DATFILE);
win.updateTreeUnsavedEntries();
win.regainFocus();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ private static void addListeners() {
if (ProjectActions.createNewProject(Editor3DWindow.getWindow(), false)) {
addRecentFile(Project.getProjectPath());
}

win.updateTreeUnsavedEntries();
win.regainFocus();
});
widgetUtil(btnOpenPtr[0]).addSelectionListener(e -> {
Expand All @@ -108,8 +110,9 @@ private static void addListeners() {
win.getOfficialParts().setData(null);
win.getSearchText().setText(" "); //$NON-NLS-1$
win.getSearchText().setText(""); //$NON-NLS-1$
win.updateTreeUnsavedEntries();
}

win.updateTreeUnsavedEntries();
win.regainFocus();
});
widgetUtil(btnSavePtr[0]).addSelectionListener(new WidgetSelectionListener() {
Expand Down Expand Up @@ -175,6 +178,8 @@ public void widgetSelected(SelectionEvent e) {
Project.setLastVisitedPath(Project.getProjectPath());
}
}

win.updateTreeUnsavedEntries();
win.regainFocus();
}

Expand Down

0 comments on commit 6b2ba4b

Please sign in to comment.