2
2
3
3
import java .nio .file .Path ;
4
4
import java .util .Collections ;
5
- import java .util .HashMap ;
6
5
import java .util .List ;
7
- import java .util .Map ;
8
6
import java .util .Objects ;
9
7
import java .util .Optional ;
10
8
11
- import javax .swing .undo .CannotRedoException ;
12
- import javax .swing .undo .CannotUndoException ;
13
-
14
9
import javafx .application .Platform ;
15
10
import javafx .beans .binding .Bindings ;
16
11
import javafx .geometry .Orientation ;
20
15
21
16
import org .jabref .Globals ;
22
17
import org .jabref .JabRefExecutorService ;
23
- import org .jabref .gui .actions .Actions ;
24
- import org .jabref .gui .actions .BaseAction ;
25
18
import org .jabref .gui .autocompleter .AutoCompletePreferences ;
26
19
import org .jabref .gui .autocompleter .AutoCompleteUpdater ;
27
20
import org .jabref .gui .autocompleter .PersonNameSuggestionProvider ;
28
21
import org .jabref .gui .autocompleter .SuggestionProviders ;
29
- import org .jabref .gui .bibtexkeypattern .GenerateBibtexKeyAction ;
30
- import org .jabref .gui .cleanup .CleanupAction ;
31
22
import org .jabref .gui .collab .DatabaseChangeMonitor ;
32
23
import org .jabref .gui .collab .DatabaseChangePane ;
33
- import org .jabref .gui .edit .ReplaceStringAction ;
34
24
import org .jabref .gui .entryeditor .EntryEditor ;
35
- import org .jabref .gui .exporter .SaveDatabaseAction ;
36
- import org .jabref .gui .externalfiles .DownloadFullTextAction ;
37
25
import org .jabref .gui .externalfiletype .ExternalFileTypes ;
38
- import org .jabref .gui .importer .actions .AppendDatabaseAction ;
39
- import org .jabref .gui .journals .AbbreviateAction ;
40
- import org .jabref .gui .journals .AbbreviationType ;
41
- import org .jabref .gui .journals .UnabbreviateAction ;
42
26
import org .jabref .gui .maintable .MainTable ;
43
27
import org .jabref .gui .maintable .MainTableDataModel ;
44
28
import org .jabref .gui .specialfields .SpecialFieldDatabaseChangeListener ;
62
46
import org .jabref .model .database .event .EntriesAddedEvent ;
63
47
import org .jabref .model .database .event .EntriesRemovedEvent ;
64
48
import org .jabref .model .database .shared .DatabaseLocation ;
65
- import org .jabref .model .database .shared .DatabaseSynchronizer ;
66
49
import org .jabref .model .entry .BibEntry ;
67
50
import org .jabref .model .entry .event .EntriesEventSource ;
68
51
import org .jabref .model .entry .event .EntryChangedEvent ;
@@ -88,11 +71,8 @@ public class BasePanel extends StackPane {
88
71
89
72
private final JabRefFrame frame ;
90
73
// The undo manager.
91
- private final UndoAction undoAction = new UndoAction ();
92
- private final RedoAction redoAction = new RedoAction ();
93
74
private final CountingUndoManager undoManager ;
94
- // Keeps track of the string dialog if it is open.
95
- private final Map <Actions , BaseAction > actions = new HashMap <>();
75
+
96
76
private final SidePaneManager sidePaneManager ;
97
77
private final ExternalFileTypes externalFileTypes ;
98
78
@@ -139,8 +119,6 @@ public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabas
139
119
140
120
setupMainPanel ();
141
121
142
- setupActions ();
143
-
144
122
this .getDatabase ().registerListener (new SearchListener ());
145
123
this .getDatabase ().registerListener (new EntriesRemovedListener ());
146
124
@@ -153,7 +131,7 @@ public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabas
153
131
154
132
this .entryEditor = new EntryEditor (this , externalFileTypes );
155
133
// Open entry editor for first entry on start up.
156
- Platform .runLater (() -> clearAndSelectFirst () );
134
+ Platform .runLater (this :: clearAndSelectFirst );
157
135
}
158
136
159
137
@ Subscribe
@@ -216,48 +194,6 @@ public void output(String s) {
216
194
dialogService .notify (s );
217
195
}
218
196
219
- private void setupActions () {
220
- SaveDatabaseAction saveAction = new SaveDatabaseAction (this , Globals .prefs , Globals .entryTypesManager );
221
- CleanupAction cleanUpAction = new CleanupAction (this , Globals .prefs , Globals .TASK_EXECUTOR );
222
-
223
- actions .put (Actions .UNDO , undoAction );
224
- actions .put (Actions .REDO , redoAction );
225
-
226
- // The action for opening an entry editor.
227
- actions .put (Actions .EDIT , this ::showAndEdit );
228
-
229
- // The action for saving a database.
230
- actions .put (Actions .SAVE , saveAction ::save );
231
-
232
- actions .put (Actions .SAVE_AS , saveAction ::saveAs );
233
-
234
- actions .put (Actions .SAVE_SELECTED_AS_PLAIN , saveAction ::saveSelectedAsPlain );
235
-
236
- actions .put (Actions .SELECT_ALL , mainTable .getSelectionModel ()::selectAll );
237
-
238
- // The action for auto-generating keys.
239
- actions .put (Actions .MAKE_KEY , new GenerateBibtexKeyAction (this , frame .getDialogService ()));
240
-
241
- // The action for cleaning up entry.
242
- actions .put (Actions .CLEANUP , cleanUpAction );
243
-
244
- actions .put (Actions .MERGE_DATABASE , new AppendDatabaseAction (frame , this ));
245
-
246
- actions .put (Actions .PULL_CHANGES_FROM_SHARED_DATABASE , () -> {
247
- DatabaseSynchronizer dbmsSynchronizer = frame .getCurrentBasePanel ().getBibDatabaseContext ().getDBMSSynchronizer ();
248
- dbmsSynchronizer .pullChanges ();
249
- });
250
-
251
- actions .put (Actions .REPLACE_ALL , () -> (new ReplaceStringAction (this )).execute ());
252
-
253
- actions .put (Actions .ABBREVIATE_DEFAULT , new AbbreviateAction (this , AbbreviationType .DEFAULT ));
254
- actions .put (Actions .ABBREVIATE_MEDLINE , new AbbreviateAction (this , AbbreviationType .MEDLINE ));
255
- actions .put (Actions .ABBREVIATE_SHORTEST_UNIQUE , new AbbreviateAction (this , AbbreviationType .SHORTEST_UNIQUE ));
256
- actions .put (Actions .UNABBREVIATE , new UnabbreviateAction (this ));
257
-
258
- actions .put (Actions .DOWNLOAD_FULL_TEXT , new DownloadFullTextAction (this )::execute );
259
- }
260
-
261
197
/**
262
198
* Removes the selected entries from the database
263
199
*
@@ -297,26 +233,6 @@ public void delete(BibEntry entry) {
297
233
delete (false , Collections .singletonList (entry ));
298
234
}
299
235
300
- /**
301
- * This method is called from JabRefFrame if a database specific action is requested by the user. Runs the command
302
- * if it is defined, or prints an error message to the standard error stream.
303
- *
304
- * @param command The name of the command to run.
305
- */
306
- public void runCommand (final Actions command ) {
307
- if (!actions .containsKey (command )) {
308
- LOGGER .info ("No action defined for '" + command + '\'' );
309
- return ;
310
- }
311
-
312
- BaseAction action = actions .get (command );
313
- try {
314
- action .action ();
315
- } catch (Throwable ex ) {
316
- LOGGER .error ("runCommand error: " + ex .getMessage (), ex );
317
- }
318
- }
319
-
320
236
public void registerUndoableChanges (List <FieldChange > changes ) {
321
237
NamedCompound ce = new NamedCompound (Localization .lang ("Save actions" ));
322
238
for (FieldChange change : changes ) {
@@ -567,12 +483,6 @@ private void showBottomPane(BasePanelMode newMode) {
567
483
adjustSplitter ();
568
484
}
569
485
570
- private void showAndEdit () {
571
- if (!mainTable .getSelectedEntries ().isEmpty ()) {
572
- showAndEdit (mainTable .getSelectedEntries ().get (0 ));
573
- }
574
- }
575
-
576
486
/**
577
487
* Removes the bottom component.
578
488
*/
@@ -594,7 +504,7 @@ public void clearAndSelect(final BibEntry bibEntry) {
594
504
*/
595
505
private void clearAndSelectFirst () {
596
506
mainTable .clearAndSelectFirst ();
597
- showAndEdit ();
507
+ showAndEdit (mainTable . getSelectedEntries (). get ( 0 ) );
598
508
}
599
509
600
510
public void selectPreviousEntry () {
@@ -645,7 +555,7 @@ public void markNonUndoableBaseChanged() {
645
555
markBaseChanged ();
646
556
}
647
557
648
- private synchronized void markChangedOrUnChanged () {
558
+ public synchronized void markChangedOrUnChanged () {
649
559
if (getUndoManager ().hasChanged ()) {
650
560
if (!baseChanged ) {
651
561
markBaseChanged ();
@@ -864,37 +774,4 @@ public void listen(EntriesRemovedEvent removedEntriesEvent) {
864
774
DefaultTaskExecutor .runInJavaFXThread (() -> frame .getGlobalSearchBar ().performSearch ());
865
775
}
866
776
}
867
-
868
- private class UndoAction implements BaseAction {
869
-
870
- @ Override
871
- public void action () {
872
- try {
873
- getUndoManager ().undo ();
874
- markBaseChanged ();
875
- output (Localization .lang ("Undo" ));
876
- } catch (CannotUndoException ex ) {
877
- LOGGER .warn ("Nothing to undo" , ex );
878
- output (Localization .lang ("Nothing to undo" ) + '.' );
879
- }
880
-
881
- markChangedOrUnChanged ();
882
- }
883
- }
884
-
885
- private class RedoAction implements BaseAction {
886
-
887
- @ Override
888
- public void action () {
889
- try {
890
- getUndoManager ().redo ();
891
- markBaseChanged ();
892
- output (Localization .lang ("Redo" ));
893
- } catch (CannotRedoException ex ) {
894
- output (Localization .lang ("Nothing to redo" ) + '.' );
895
- }
896
-
897
- markChangedOrUnChanged ();
898
- }
899
- }
900
777
}
0 commit comments