// Custom function for creation of New Tabs. public ScriptingFileWidget createFileTab(File file) { if (openFiles.get(file.getAbsolutePath()) != null && widgets.get(file.getAbsolutePath()) != null) { setSelectedTab(openFiles.get(file.getAbsolutePath())); return widgets.get(file.getAbsolutePath()).getScripting(); } Tab fileTab = new Tab(file.getName()); openFiles.put(file.getAbsolutePath(), fileTab); try { Log.warning("Loading local file from: " + file.getAbsolutePath()); LocalFileScriptTab t = new LocalFileScriptTab(file); fileTab.setContent(t); addTab(fileTab, true); widgets.put(file.getAbsolutePath(), t); fileTab.setOnCloseRequest( event -> { widgets.remove(file.getAbsolutePath()); openFiles.remove(file.getAbsolutePath()); }); return t.getScripting(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
@FXML public void handleInspectionButton() { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(new File("C:\\Users\\Christoph\\OneDrive\\newAnalysis")); fileChooser.setTitle("Choose Invariant File"); fileChooser.getExtensionFilters().addAll(new ExtensionFilter("Invariant Files", "*.txt")); File selectedFile = fileChooser.showOpenDialog(stage); if (selectedFile != null) { try { FXMLLoader loader = new FXMLLoader(); BorderPane root = (BorderPane) loader.load(getClass().getResource("InvariantInspectorTab.fxml").openStream()); InvariantInspectorTabController controller = (InvariantInspectorTabController) loader.getController(); controller.setPrimaryStage(stage); controller.loadData(selectedFile); Tab tab = new Tab(); tab.setContent(root); tabPane.getTabs().add(tab); } catch (Exception e) { e.printStackTrace(); } } }
public void openImageFile(Resource resource) { Tab tab = new Tab(); tab.setClosable(true); if (resource == null) { Dialogs.create() .owner(tabPane) .title("Datei nicht vorhanden") .message( "Die angeforderte Datei ist nicht vorhanden und kann deshalb nicht geöffnet werden.") .showError(); return; } tab.setText(resource.getFileName()); ImageResource imageResource = (ImageResource) resource; ImageViewerPane pane = new ImageViewerPane(); pane.setImageResource(imageResource); ImageView imageView = pane.getImageView(); imageView.setImage(imageResource.asNativeFormat()); imageView.setFitHeight(-1); imageView.setFitWidth(-1); Label imagePropertiesLabel = pane.getImagePropertiesLabel(); imagePropertiesLabel.setText(imageResource.getImageDescription()); tab.setContent(pane); tab.setUserData(resource); tabPane.getTabs().add(tab); tabPane.getSelectionModel().select(tab); }
private void saveUnsavedEditors() { for (Tab tab : tabPane.getTabs()) { EditorPane pane = (EditorPane) tab.getContent(); pane.promptSave(); } }
private void updateTabTitle() { final HBox title = new HBox(); title.setAlignment(Pos.CENTER); if (isAutoRefresh()) { final ProgressIndicator progressIndicator = new ProgressIndicator(); progressIndicator.setMaxSize(15, 15); title.getChildren().add(progressIndicator); title.getChildren().add(new Label(" ")); } // If the search value is too long, show only a substring final String searchValue = searchField.getText().length() > MAX_SEARCH_VALUE_CHARACTERS ? searchField.getText().substring(0, MAX_SEARCH_VALUE_CHARACTERS) + "..." : searchField.getText(); title .getChildren() .add( new Label( "Search: \"" + searchValue + "\"" + " [" + foundMessages.size() + " found / " + seachedCount + " searched]")); tab.setText(null); tab.setGraphic(title); }
public void addNewTab(UserInterfaceVC pane) { myWorkSpaces.add(pane); Tab t = new Tab(); t.setContent(pane.getGroup()); t.setText("Work Space " + String.valueOf(numTabs + 1)); numTabs++; myTabPane.getTabs().add(t); }
public Tab get(Connection connection, Entity entity) { for (Tab t : tabList.getItems()) { if (t.getConnection().equals(connection) && t.getEntity().equals(entity)) { return t; } } return create(connection, entity); }
public AbstractTab(String name, String id, Stage stage, D dto) { tab = new Tab(name); tab.setId(id); this.name = name; this.stage = stage; setDTO(dto); tab.setContent(addTabContent(stage)); }
public void setTabTitles() { for (Tab t : myTabPane.getTabs()) { t.setText("Work Space " + String.valueOf(numTabs + 1)); numTabs++; } }
public Tab findAfterTab(String text, int index) { int tabCount = this.getTabs().size(); for (int i = index + 1; i < tabCount; i++) { Tab tab = this.getTabs().get(i); if (tab.getText().equals(text)) { return tab; } } return null; }
private void enablePanes() { if (lotto.numbers.size() == 5 && lotto.starNumbers.size() == 2 && lotto.getDate().length() > 0) { tab_uploadSingle.setDisable(false); } else { tab_uploadSingle.setDisable(true); } }
private boolean isTabAlreadyOpen(Resource resource) { boolean found = false; List<Tab> tabs = tabPane.getTabs(); for (Tab tab : tabs) { if (tab.getUserData().equals(resource)) { tabPane.getSelectionModel().select(tab); found = true; } } return found; }
public Tab findBeforeTab(String text, int index) { int tabCount = this.getTabs().size(); if (index >= tabCount) { index = tabCount - 1; } for (int i = index - 1; i >= 0; i--) { Tab tab = this.getTabs().get(i); if (tab.getText().equals(text)) { return tab; } } return null; }
public void addUserStatusMessage( User source, Message message, MessageRow.Type type, TabAction action) { for (Tab tab : getItems()) { if (tab.getEntity().equals(source) || (tab.getEntity() instanceof Channel && ((Channel) tab.getEntity()).getUsers().contains(source))) { tab.getContentPane().getMessagePane().addRow(new MessageRow(message, type)); if (action != null) { action.process(tab); } } } }
public void refreshAll() { List<Tab> tabs = tabPane.getTabs(); for (Tab tab : tabs) { Resource resource = (Resource) tab.getUserData(); if (tab.getContent() instanceof CodeEditor) { CodeEditor editor = (CodeEditor) tab.getContent(); try { editor.setCode(new String(resource.getData(), "UTF-8")); } catch (IOException e) { logger.error("", e); } } } }
private void saveEditorPaneConfig() { List<String> editorPanePaths = new ArrayList<>(); for (Tab tab : tabPane.getTabs()) { EditorPane pane = (EditorPane) tab.getContent(); if (pane != null && pane.getSourceFile() != null) { String editorPanePath = pane.getSourceFile().getAbsolutePath(); editorPanePaths.add(editorPanePath); } } config.setLastEditorPaneList(editorPanePaths); config.saveConfig(); }
private void addEditor(File filename) { final EditorPane pane = new EditorPane(this); if (filename != null) { pane.loadSource(filename); } final Tab tab = new Tab(); tab.setContent(pane); tab.setText(pane.getName()); EventHandler<Event> closeHandler = new EventHandler<Event>() { @Override public void handle(Event e) { if (pane.isModified()) { pane.promptSave(); } tabPane.getTabs().remove(tab); } }; // JavaFX 2.2 (from Java 7) has no onCloseRequestProperty if (JITWatchUI.IS_JAVA_FX2) { tab.setOnClosed(closeHandler); } else { // Use reflection to call setOnCloseRequestProperty for Java 8 try { MethodType mt = MethodType.methodType(void.class, EventHandler.class); MethodHandle mh = MethodHandles.lookup().findVirtual(Tab.class, "setOnCloseRequest", mt); // fails with invokeExact due to generic type erasure? mh.invoke(tab, closeHandler); } catch (Throwable t) { logger.error("Exception: {}", t.getMessage(), t); } } tabPane.getTabs().add(tab); pane.requestFocus(); setVMLanguage(pane); saveEditorPaneConfig(); }
@FXML private void lvListenerGetEmployeeInfo(MouseEvent event) { try { tabPayCheck.setDisable(true); clearTextFields(); String[] a = lvEmployees.getSelectionModel().getSelectedItem().split("-"); tfInfoId.setText(a[1].trim()); final int ID = Integer.parseInt(tfInfoId.getText()); tfInfoName.setText(Environment.getEmployeeStrInfo(ID, "name")); tfInfoPos.setText(Environment.getEmployeeStrInfo(ID, "position")); tfInfoStreet.setText(Environment.getEmployeeStrInfo(ID, "street")); tfInfoCSZ.setText(Environment.getCityStateZip(ID)); tfInfoPayRate.setText( String.format("%.2f", Double.parseDouble(Environment.getEmployeeStrInfo(ID, "payRate")))); } catch (Exception e) { Alert alert; alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Error Message"); alert.setHeaderText("Whoops you did not select an Employee."); alert.setContentText("Try again."); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { // ... user chose OK } else { // ... user chose CANCEL or closed the dialog } } }
public void addUntargetedMessage(Connection connection, Message message, MessageRow.Type type) { Tab tab = getSelected(); if (tab == null || !tab.getConnection().equals(connection)) { tab = null; for (Tab _tab : getItems()) { if (_tab.getConnection().equals(connection)) { tab = _tab; break; } } if (tab == null) { tab = create(connection, connection.getServer()); } } tab.getContentPane().getMessagePane().addRow(new MessageRow(message, type)); }
@Override protected void updateItem(final Tab tab, boolean empty) { super.updateItem(tab, empty); if (tab != null) { tab.getUnreadProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observableValue, Boolean oldValue, Boolean newValue) { if (newValue) { getStyleClass().add("unread"); } else { getStyleClass().remove("unread"); } } }); Entity entity = tab.getEntity(); setPrefHeight(32); if (entity instanceof Server) { setPrefHeight(40); Label net = new Label("network"); net.getStyleClass().add("network"); VBox box = new VBox(); Label name = new Label(entity.getName()); name.getStyleClass().add("network-name"); box.getChildren().addAll(net, name); setGraphic(box); } else if (entity instanceof Channel) { final Label label = new Label(entity.getName().substring(1)); label.getStyleClass().add("name"); final HBox box = new HBox(); box.getChildren().addAll(FontAwesome.createIcon(FontAwesome.COMMENTS), label); setGraphic(box); } else if (entity instanceof User) { final Label label = new Label(entity.getName()); label.getStyleClass().add("name"); final HBox box = new HBox(); box.getChildren().addAll(FontAwesome.createIcon(FontAwesome.USER), label); setGraphic(box); } } }
public void refreshImageViewer(Resource resourceToUpdate) { List<Tab> tabs = tabPane.getTabs(); for (Tab tab : tabs) { Resource resource = (Resource) tab.getUserData(); if (resourceToUpdate.equals(resource)) { ImageResource imageResource = (ImageResource) resourceToUpdate; logger.info("refreshing image resource"); ImageViewerPane imageViewerPane = (ImageViewerPane) tab.getContent(); ImageView imageView = imageViewerPane.getImageView(); imageView.setImage(imageResource.asNativeFormat()); imageView.setFitHeight(-1); imageView.setFitWidth(-1); Label imagePropertiesLabel = imageViewerPane.getImagePropertiesLabel(); imagePropertiesLabel.setText(imageResource.getImageDescription()); } } }
private void checkForDefinedGitRepoDirectory() { if (!ApplicationModel.getInstance().isRepoDirectoryDefined()) { publicKeysTab.setDisable(true); reposTab.setDisable(true); Platform.runLater( () -> { Alert alert = new Alert( AlertType.ERROR, "Please select the root directory of the gitolite admin repository."); alert.showAndWait(); }); } else { publicKeysTab.setDisable(false); reposTab.setDisable(false); addTabContent(); } }
public void setSelectedTab(Tab tab) { if (getSelectionModel().getSelectedItem() != tab) { Platform.runLater( () -> { System.out.println("Selecting " + tab.getText()); getSelectionModel().select(tab); }); } }
@FXML public void HandleSaveButtonAction(ActionEvent event) { extract.setMarkdown(SourceText.getText()); extract.save(); tab.setText(extract.getTitle()); this.isSaved = true; SourceText.requestFocus(); }
public ChartsResultsBroker(Tab tabChartsBrokerResults) { this.tabChartsBrokerResults = tabChartsBrokerResults; scpAllPage = new ScrollPane(); scpAllPage.getStyleClass().add("bg-general-container"); vbxAllPage = new VBox(); vbxAllPage.setPadding(new Insets(10, 10, 10, 10)); vbxAllPage.setSpacing(10); scpAllPage.setContent(vbxAllPage); tabChartsBrokerResults.setContent(scpAllPage); }
public void addTargetedMessage(Connection connection, Message message, MessageRow.Type type) { Entity target = message.getTarget(); if (target.equals(connection.getLocalUser())) { target = message.getSource(); } Tab tab = null; for (Tab _tab : getItems()) { if (_tab.getEntity().equals(target)) { tab = _tab; break; } } if (tab == null) { if (type == MessageRow.Type.PART && message.getSource().equals(connection.getLocalUser())) { return; } tab = create(connection, target); } tab.getContentPane().getMessagePane().addRow(new MessageRow(message, type)); }
@Override public void setModified(EditorPane pane, boolean isModified) { for (Tab tab : tabPane.getTabs()) { EditorPane currentPane = (EditorPane) tab.getContent(); if (currentPane == pane) { String tabText = tab.getText(); if (isModified) { if (!tabText.endsWith(S_ASTERISK)) { tab.setText(tabText + S_ASTERISK); } } else { if (tabText.endsWith(S_ASTERISK)) { tab.setText(tabText.substring(0, tabText.length() - 1)); } } } } }
public void changed(ObservableValue<? extends Tab> ov, Tab oldTab, Tab newTab) { try { if (newTab == null) { appPane.setContentPane(null); return; } newTab.setUnread(false); appPane.setContentPane(newTab.getContentPane()); final TextField inputField = appPane.getContentPane().getInputPane().getInputField(); Platform.runLater( new Runnable() { public void run() { inputField.requestFocus(); inputField.positionCaret(inputField.getText().length()); inputField.deselect(); } }); } catch (final NullPointerException npe) { System.err.println("NPE Caught in method: TabPane.TabClickedListener#changed()"); } }
@Override public void initUI() { AnchorPane anchorPane = new AnchorPane(); anchorPane.setPrefHeight(90.0); anchorPane.setPrefWidth(384.0); Label label = new Label(getApplication().getMessageSource().getMessage("name.label")); TextField input = new TextField(); input.setPrefWidth(200.0); Button button = new Button(); button.setPrefWidth(200.0); JavaFXUtils.configure( button, (JavaFXAction) actionFor(controller, "sayHello").getToolkitAction()); Label output = new Label(); label.setPrefWidth(360.0); model.inputProperty().bindBidirectional(input.textProperty()); model.outputProperty().bindBidirectional(output.textProperty()); anchorPane.getChildren().addAll(label, input, button, output); setLeftAnchor(label, 14.0); setTopAnchor(label, 14.0); setLeftAnchor(input, 172.0); setTopAnchor(input, 11.0); setLeftAnchor(button, 172.0); setTopAnchor(button, 45.0); setLeftAnchor(output, 14.0); setTopAnchor(output, 80.0); Tab tab = new Tab("Java"); tab.setGraphic(new FontAwesomeIcon(FontAwesome.FA_COFFEE)); tab.setClosable(false); tab.setContent(anchorPane); parentView.getTabPane().getTabs().add(tab); }
public void addTab(Tab tab, boolean closable) { // new RuntimeException().printStackTrace(); Platform.runLater( () -> { final ObservableList<Tab> tabs = getTabs(); tab.setClosable(closable); int index = tabs.size() - 1; // new RuntimeException().printStackTrace(); tabs.add(index, tab); setSelectedTab(tab); }); }