1515 */
1616package org .exbin .bined .intellij ;
1717
18- import com .intellij .openapi .fileEditor .impl .FileEditorManagerImpl ;
1918import com .intellij .openapi .project .DumbAware ;
2019import com .intellij .openapi .vfs .LocalFileSystem ;
2120import com .intellij .openapi .vfs .VirtualFile ;
2827import org .exbin .framework .App ;
2928import org .exbin .framework .bined .BinEdEditorComponent ;
3029import org .exbin .framework .bined .BinEdFileHandler ;
30+ import org .exbin .framework .bined .BinEdFileManager ;
3131import org .exbin .framework .bined .BinedModule ;
3232import org .exbin .framework .bined .gui .BinEdComponentPanel ;
33+ import org .exbin .framework .bined .preferences .BinaryEditorPreferences ;
34+ import org .exbin .framework .file .action .FileActions ;
35+ import org .exbin .framework .preferences .api .PreferencesModuleApi ;
3336import org .jetbrains .annotations .Nullable ;
3437
3538import javax .annotation .Nonnull ;
@@ -75,15 +78,27 @@ public BinEdVirtualFile(VirtualFile parentFile) {
7578 this .displayName = "" ;
7679 }
7780
81+ fileHandler .registerUndoHandler ();
7882 BinedModule binedModule = App .getModule (BinedModule .class );
79- binedModule .getFileManager ().initComponentPanel (fileHandler .getComponent ());
80- binedModule .getFileManager ().initFileHandler (fileHandler );
83+ BinEdFileManager fileManager = binedModule .getFileManager ();
84+ fileManager .initFileHandler (fileHandler );
85+ fileManager .initCommandHandler (fileHandler .getComponent ());
86+
8187 filePanel .setFileHandler (fileHandler );
82- fileHandler .registerUndoHandler ();
88+ PreferencesModuleApi preferencesModule = App .getModule (PreferencesModuleApi .class );
89+ BinaryEditorPreferences binaryEditorPreferences = new BinaryEditorPreferences (preferencesModule .getAppPreferences ());
90+ fileHandler .onInitFromPreferences (binaryEditorPreferences );
91+ fileHandler .setNewData (binaryEditorPreferences .getEditorPreferences ().getFileHandlingMode ());
8392
8493 BinEdToolbarPanel toolbarPanel = filePanel .getToolbarPanel ();
8594 toolbarPanel .setUndoHandler (fileHandler .getCodeAreaUndoHandler ().get ());
86- toolbarPanel .setSaveAction (e -> fileHandler .saveFile ());
95+ toolbarPanel .setSaveAction (e -> {
96+ fileHandler .saveFile ();
97+ fileHandler .fileSync ();
98+ ((BinEdIntelliJEditorProvider ) binedModule .getEditorProvider ()).updateStatus ();
99+ });
100+
101+ toolbarPanel .loadFromPreferences (binaryEditorPreferences );
87102 }
88103
89104 @ Nonnull
@@ -265,11 +280,6 @@ public int hashCode() {
265280 return getPath ().hashCode ();
266281 }
267282
268- public boolean isMoved () {
269- Boolean closingToReopen = getUserData (FileEditorManagerImpl .CLOSING_TO_REOPEN );
270- return closingToReopen != null && closingToReopen ;
271- }
272-
273283 public boolean isClosing () {
274284 return closing ;
275285 }
@@ -292,16 +302,20 @@ public JComponent getPreferredFocusedComponent() {
292302 public void openFile (BinEdFileHandler fileHandler ) {
293303 if (!isDirectory () && isValid ()) {
294304 File file = extractFile (this );
305+ fileHandler .clearFile ();
295306 if (file .isFile () && file .exists ()) {
296- fileHandler .clearFile ();
297307 fileHandler .loadFromFile (file .toURI (), null );
308+ fileHandler .fileSync ();
298309 } else {
299310 try (InputStream stream = getInputStream ()) {
300311 fileHandler .loadFromStream (stream );
312+ fileHandler .fileSync ();
301313 } catch (IOException ex ) {
302314 Logger .getLogger (BinEdFileHandler .class .getName ()).log (Level .SEVERE , null , ex );
303315 }
304316 }
305317 }
318+ BinedModule binedModule = App .getModule (BinedModule .class );
319+ ((BinEdIntelliJEditorProvider ) binedModule .getEditorProvider ()).updateStatus ();
306320 }
307321}
0 commit comments