Revize 7e0b699a
Přidáno uživatelem Michal Horký před asi 4 roky(ů)
project/Deserializer/src/Deserializer.java | ||
---|---|---|
1 | 1 |
import java.io.File; |
2 | 2 |
|
3 |
import io.Database.DB_Messenger; |
|
3 | 4 |
import io.FileWorker; |
4 | 5 |
import javafx.application.Application; |
5 | 6 |
import javafx.application.Platform; |
7 |
import javafx.collections.FXCollections; |
|
6 | 8 |
import javafx.geometry.Insets; |
7 | 9 |
import javafx.geometry.Pos; |
8 | 10 |
import javafx.scene.Node; |
... | ... | |
14 | 16 |
import javafx.scene.control.Menu; |
15 | 17 |
import javafx.scene.control.MenuBar; |
16 | 18 |
import javafx.scene.control.MenuItem; |
19 |
import javafx.scene.control.PasswordField; |
|
17 | 20 |
import javafx.scene.control.Separator; |
18 | 21 |
import javafx.scene.control.SeparatorMenuItem; |
19 | 22 |
import javafx.scene.control.Tab; |
20 | 23 |
import javafx.scene.control.TabPane; |
21 | 24 |
import javafx.scene.control.TabPane.TabClosingPolicy; |
25 |
import javafx.scene.control.TextField; |
|
22 | 26 |
import javafx.scene.image.Image; |
23 | 27 |
import javafx.scene.image.ImageView; |
24 | 28 |
import javafx.scene.input.KeyCode; |
... | ... | |
95 | 99 |
TabPane header = new TabPane(); |
96 | 100 |
header.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); |
97 | 101 |
header.getTabs().add(createInputFileTab()); |
102 |
header.getTabs().add(createQueryTab()); |
|
98 | 103 |
|
99 | 104 |
|
100 | 105 |
editor = new Editor(); |
... | ... | |
178 | 183 |
return layout; |
179 | 184 |
} |
180 | 185 |
|
186 |
private Tab createQueryTab() { |
|
187 |
String promptTexts[] = new String[] { "jdbc:mysql://server/nazevDB", "jdbc:oracle:thin:@server:port:nazevDB" }; |
|
188 |
|
|
189 |
Label rdbmsLabel = new Label("Typ DB"); |
|
190 |
Label urlLabel = new Label("URL"); |
|
191 |
ComboBox<String> rdbms = new ComboBox<String>(FXCollections.observableArrayList(new String[] { "MySQL", "ORACLE" })); |
|
192 |
TextField url = new TextField(); |
|
193 |
|
|
194 |
rdbms.setOnAction(event -> { |
|
195 |
url.setPromptText(promptTexts[rdbms.getSelectionModel().getSelectedIndex()]); |
|
196 |
}); |
|
197 |
|
|
198 |
rdbms.getSelectionModel().selectFirst(); |
|
199 |
url.setPromptText(promptTexts[0]); |
|
200 |
|
|
201 |
|
|
202 |
Label userLabel = new Label("Uživatel"); |
|
203 |
Label passwordLabel = new Label("Heslo"); |
|
204 |
TextField user = new TextField(); |
|
205 |
PasswordField password = new PasswordField(); |
|
206 |
|
|
207 |
VBox rdbmsLayout = new VBox(); |
|
208 |
rdbmsLayout.getChildren().addAll(rdbmsLabel, rdbms); |
|
209 |
VBox urlLayout = new VBox(); |
|
210 |
urlLayout.getChildren().addAll(urlLabel, url); |
|
211 |
VBox userLayout = new VBox(); |
|
212 |
userLayout.getChildren().addAll(userLabel, user); |
|
213 |
VBox passwordLayout = new VBox(); |
|
214 |
passwordLayout.getChildren().addAll(passwordLabel, password); |
|
215 |
|
|
216 |
rdbmsLabel.setStyle("-fx-font-weight: bold;"); |
|
217 |
urlLabel.setStyle("-fx-font-weight: bold;"); |
|
218 |
userLabel.setStyle("-fx-font-weight: bold;"); |
|
219 |
passwordLabel.setStyle("-fx-font-weight: bold;"); |
|
220 |
|
|
221 |
url.setMinWidth(400); |
|
222 |
user.setMinWidth(100); |
|
223 |
user.setPrefWidth(200); |
|
224 |
user.setMaxWidth(300); |
|
225 |
password.setMinWidth(100); |
|
226 |
password.setPrefWidth(200); |
|
227 |
password.setMaxWidth(300); |
|
228 |
|
|
229 |
HBox.setHgrow(urlLayout, Priority.ALWAYS); |
|
230 |
|
|
231 |
HBox connLayout = new HBox(); |
|
232 |
connLayout.setSpacing(10); |
|
233 |
connLayout.getChildren().addAll(rdbmsLayout, urlLayout, userLayout, passwordLayout); |
|
234 |
|
|
235 |
|
|
236 |
Label select = new Label("SELECT"), from = new Label("FROM"), where = new Label("WHERE"), queryEnd = new Label(";"); |
|
237 |
TextField column = new TextField(), table = new TextField(), cond = new TextField(); |
|
238 |
|
|
239 |
select.setStyle("-fx-font-weight: bold;"); |
|
240 |
from.setStyle("-fx-font-weight: bold;"); |
|
241 |
where.setStyle("-fx-font-weight: bold;"); |
|
242 |
queryEnd.setStyle("-fx-font-weight: bold;"); |
|
243 |
|
|
244 |
column.setPromptText("sloupec"); |
|
245 |
table.setPromptText("tabulka"); |
|
246 |
cond.setPromptText("podminka"); |
|
247 |
|
|
248 |
HBox.setHgrow(column, Priority.ALWAYS); |
|
249 |
HBox.setHgrow(table, Priority.ALWAYS); |
|
250 |
HBox.setHgrow(cond, Priority.ALWAYS); |
|
251 |
|
|
252 |
HBox queryLayout = new HBox(); |
|
253 |
queryLayout.setAlignment(Pos.CENTER); |
|
254 |
queryLayout.setSpacing(5.0); |
|
255 |
queryLayout.getChildren().addAll(select, column, from, table, where, cond, queryEnd); |
|
256 |
|
|
257 |
Button setQuery = new Button("Spustit"); |
|
258 |
setQuery.setOnAction(event -> { |
|
259 |
String driver = rdbms.getValue().equals("MySQL") ? "com.mysql.cj.jdbc.Driver" : "oracle.jdbc.driver.OracleDriver"; |
|
260 |
converter.setInput(null, new DB_Messenger(driver, url.getText().trim(), user.getText().trim(), password.getText().trim(), |
|
261 |
table.getText().trim(), cond.getText().trim(), column.getText().trim())); |
|
262 |
}); |
|
263 |
|
|
264 |
HBox bIF = new HBox(); |
|
265 |
bIF.setAlignment(Pos.CENTER_RIGHT); |
|
266 |
bIF.getChildren().add(setQuery); |
|
267 |
|
|
268 |
VBox forInput = new VBox(); |
|
269 |
forInput.setPadding(new Insets(10, 10, 0, 10)); |
|
270 |
forInput.setSpacing(5.0); |
|
271 |
forInput.getChildren().addAll(connLayout, queryLayout, bIF); |
|
272 |
|
|
273 |
return new Tab("SQL", forInput); |
|
274 |
} |
|
275 |
|
|
181 | 276 |
private Tab createInputFileTab() { |
182 | 277 |
Label forInputFile = new Label("Soubor k deserializaci:"); |
183 | 278 |
Label inputFile = new Label(" Ještě nebyl vybrán žádný soubor..."); |
... | ... | |
198 | 293 |
inputFile.setText(file.getAbsolutePath()); |
199 | 294 |
inputFile.setStyle("-fx-font-weight: bold;"); |
200 | 295 |
|
201 |
converter.setInput(file); |
|
296 |
converter.setInput(file, null);
|
|
202 | 297 |
} |
203 | 298 |
}); |
204 | 299 |
|
Také k dispozici: Unified diff
re #7894
Přidán layout pro data potřebná k vytvoření spojení s DB. Dále přidány knihovny pro MySQL a ORACLE.