2
2
3
3
import io .xpipe .app .core .AppI18n ;
4
4
import io .xpipe .app .ext .ActionProvider ;
5
- import io .xpipe .app .storage .DataStorage ;
6
- import io .xpipe .app .storage .DataStoreEntry ;
7
5
import io .xpipe .app .storage .DataStoreEntryRef ;
8
- import io .xpipe .app .util .TerminalLauncher ;
9
6
import io .xpipe .core .store .DataStore ;
10
- import io .xpipe .core .store .LaunchableStore ;
11
- import io .xpipe .core .store .ShellStore ;
12
- import io .xpipe .ext .base .script .ScriptStore ;
13
-
14
7
import javafx .beans .value .ObservableValue ;
15
8
16
- import lombok .Value ;
17
-
18
9
public class LaunchStoreAction implements ActionProvider {
19
10
20
11
@ Override
@@ -33,7 +24,7 @@ public boolean canLinkTo() {
33
24
34
25
@ Override
35
26
public ActionProvider .Action createAction (DataStoreEntryRef <DataStore > store ) {
36
- return new Action (store .get ());
27
+ return store . get (). getProvider (). launchAction (store .get ());
37
28
}
38
29
39
30
@ Override
@@ -44,8 +35,7 @@ public Class<DataStore> getApplicableClass() {
44
35
@ Override
45
36
public boolean isApplicable (DataStoreEntryRef <DataStore > o ) {
46
37
return o .get ().getValidity ().isUsable ()
47
- && (o .getStore () instanceof LaunchableStore
48
- || o .get ().getProvider ().launchAction (o .get ()) != null );
38
+ && (o .get ().getProvider ().launchAction (o .get ()) != null );
49
39
}
50
40
51
41
@ Override
@@ -66,7 +56,7 @@ public DefaultDataStoreCallSite<?> getDefaultDataStoreCallSite() {
66
56
67
57
@ Override
68
58
public ActionProvider .Action createAction (DataStoreEntryRef <DataStore > store ) {
69
- return new Action (store .get ());
59
+ return store . get (). getProvider (). launchAction (store .get ());
70
60
}
71
61
72
62
@ Override
@@ -77,33 +67,8 @@ public Class<DataStore> getApplicableClass() {
77
67
@ Override
78
68
public boolean isApplicable (DataStoreEntryRef <DataStore > o ) {
79
69
return o .get ().getValidity ().isUsable ()
80
- && (o .getStore () instanceof LaunchableStore
81
- || o .get ().getProvider ().launchAction (o .get ()) != null );
70
+ && (o .get ().getProvider ().launchAction (o .get ()) != null );
82
71
}
83
72
};
84
73
}
85
-
86
- @ Value
87
- static class Action implements ActionProvider .Action {
88
-
89
- DataStoreEntry entry ;
90
-
91
- @ Override
92
- public void execute () throws Exception {
93
- var storeName = DataStorage .get ().getStoreEntryDisplayName (entry );
94
- if (entry .getStore () instanceof ShellStore s ) {
95
- TerminalLauncher .open (entry , storeName , null , ScriptStore .controlWithDefaultScripts (s .control ()));
96
- return ;
97
- }
98
-
99
- if (entry .getStore () instanceof LaunchableStore s ) {
100
- s .launch ();
101
- return ;
102
- }
103
-
104
- if (entry .getProvider ().launchAction (entry ) != null ) {
105
- entry .getProvider ().launchAction (entry ).execute ();
106
- }
107
- }
108
- }
109
74
}
0 commit comments