Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Find/Replace #37

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Expand Up @@ -88,7 +88,8 @@ dependencies {
'org.slf4j:slf4j-api:1.7.12',
'org.slf4j:slf4j-log4j12:1.7.12',
'de.jensd:fontawesomefx:8.9',
'org.zeroturnaround:zt-zip:1.9'
'org.zeroturnaround:zt-zip:1.9',
'org.fxmisc.richtext:richtextfx:0.6.10'
}

task wrapper(type: Wrapper) {
Expand Down
11 changes: 6 additions & 5 deletions src/com/zestedesavoir/zestwriter/view/Editor.fxml
Expand Up @@ -11,8 +11,9 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.web.WebView?>
<?import de.jensd.fx.glyphs.fontawesome.*?>
<?import org.fxmisc.richtext.CodeArea >

<SplitPane dividerPositions="0.5" prefHeight="633.0" prefWidth="773.0" stylesheets="@dark.css" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.zestedesavoir.zestwriter.view.MdConvertController">
<SplitPane dividerPositions="0.5" prefHeight="633.0" prefWidth="773.0" stylesheets="@dark.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.zestedesavoir.zestwriter.view.MdConvertController">
<items>
<BorderPane>
<top>
Expand Down Expand Up @@ -141,11 +142,11 @@
</ToolBar>
</top>
<center>
<TextArea fx:id="SourceText" wrapText="true" BorderPane.alignment="CENTER">
<font>
<CodeArea fx:id="SourceText" wrapText="true" BorderPane.alignment="CENTER">
<!-- <font>
<Font name="Fira Mono" size="13.0" />
</font>
</TextArea>
</font>-->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je ne comprend pas bien pourquoi avoir commenté ça ? (Et s'il doit l'être, pourquoi n'est t'il pas supprimé ?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas supprimé car WIP, mais commenté car théoriquement la CodeArea
possède déjà une font spéciale.

Le 30/03/2016 22:25, WinXaito a écrit :

In src/com/zestedesavoir/zestwriter/view/Editor.fxml
#37 (comment):

               <Font name="Fira Mono" size="13.0" />
  •           </font>
    
  •        </TextArea>
    
  •           </font>-->
    

Je ne comprend pas bien pourquoi avoir commenté ça ? (Et s'il doit
l'être, pourquoi n'est t'il pas supprimé ?)


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/firm1/zest-writer/pull/37/files/b0773f6a395e826a2c3547bb7b41deb379356cf6..be027d8366fad0200843cf3dd670461e5a1ad3d9#r57957412

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je vois, merci de la précision.

</CodeArea>
</center>
</BorderPane>
<BorderPane fx:id="BoxRender" prefHeight="200.0" prefWidth="200.0">
Expand Down
45 changes: 45 additions & 0 deletions src/com/zestedesavoir/zestwriter/view/MenuController.java
Expand Up @@ -31,6 +31,10 @@
import com.zestedesavoir.zestwriter.utils.Corrector;
import com.zestedesavoir.zestwriter.utils.ZdsHttp;
import com.zestedesavoir.zestwriter.utils.readability.Readability;
import com.zestedesavoir.zestwriter.view.dialogs.FindDialog;
import java.util.logging.Level;

import org.fxmisc.richtext.CodeArea;

import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
Expand All @@ -43,8 +47,10 @@
import javafx.concurrent.Worker.State;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
Expand All @@ -58,17 +64,21 @@
import javafx.scene.control.PasswordField;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.SplitPane;
import javafx.scene.control.Tab;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.text.Text;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.DirectoryChooser;
import javafx.stage.Stage;
import javafx.util.Pair;

public class MenuController {
Expand Down Expand Up @@ -840,6 +850,41 @@ private void HandleSwitchWorkspaceAction(ActionEvent event) throws IOException {
alert.showAndWait();
}

@FXML
private void HandleSimpleFind(ActionEvent event){
// TODO: create a method somewhere more apropriate
String currentFileText = "";
Tab currentTab = null;
for(Entry<ExtractFile, Tab> entry: mainApp.getExtracts().entrySet()){
if(entry.getValue().isSelected()){
currentFileText = entry.getKey().getMdText().get();
currentTab = entry.getValue();
}
}
if(currentTab == null){
return;
}
FindDialog dialog = new FindDialog(currentFileText);
dialog.show();
SplitPane editorPane = (SplitPane)currentTab.getContent();
BorderPane editorNode = (BorderPane) editorPane.getItems().get(0);
CodeArea editorAera = (CodeArea) editorNode.getCenter();
for(Integer coords : dialog.getResult()){

}
}
@FXML
private void HandleGlobalFind(ActionEvent event){

}
@FXML
private void HandleSimpleReplace(ActionEvent event){

}
@FXML
private void HandleGlobalReplace(ActionEvent event){

}
private void HandleGoogleAction(Dialog parent) {
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Authentification via Google");
Expand Down
24 changes: 24 additions & 0 deletions src/com/zestedesavoir/zestwriter/view/Root.fxml
Expand Up @@ -64,6 +64,30 @@
<MaterialDesignIconView fill="#084561" glyphName="READ" size="1.8em" />
</graphic>
</Menu>
<Menu text="Recherche" mnemonicParsing="false" >
<items>
<MenuItem fx:id="menuFind" disable="false" mnemonicParsing="true" onAction="#HandleSimpleFind" text="Chercher">
<accelerator>
<KeyCodeCombination alt="UP" code="F" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
<MenuItem fx:id="menuFindAll" disable="false" mnemonicParsing="true" onAction="#HandleGlobalFind" text="Chercher dans tous le contenu">
<accelerator>
<KeyCodeCombination alt="DOWN" code="F" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
<MenuItem fx:id="menuReplace" disable="false" mnemonicParsing="true" onAction="#HandleSimpleReplace" text="Remplacer">
<accelerator>
<KeyCodeCombination alt="UP" code="H" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
<MenuItem fx:id="menuReplaceAll" disable="false" mnemonicParsing="true" onAction="#HandleGlobalReplace" text="Remplacer dans tous le contenu">
<accelerator>
<KeyCodeCombination alt="DOWN" code="H" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
</items>
</Menu>
</items>
</Menu>
<Menu mnemonicParsing="false" text="Synchronisation">
Expand Down
99 changes: 99 additions & 0 deletions src/com/zestedesavoir/zestwriter/view/dialogs/FindDialog.java
@@ -0,0 +1,99 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.zestedesavoir.zestwriter.view.dialogs;

import com.sun.javafx.scene.control.skin.resources.ControlResources;
import java.util.LinkedList;
import java.util.List;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.DialogPane;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;


/**
*
* Get a Line of line/colon entry
*/
public class FindDialog extends Dialog<List<Integer>>{
private final GridPane grid;
private final Label label;
private final TextField textField;
private String searchedText;

public FindDialog(String currentText){
super();
searchedText = currentText;
final DialogPane dialogPane = getDialogPane();
this.setTitle("Terme à rechercher");
this.setHeaderText(null);
this.setContentText("Recherchez");
// -- textfield
this.textField = new TextField("");
this.textField.setMaxWidth(Double.MAX_VALUE);
GridPane.setHgrow(textField, Priority.ALWAYS);
GridPane.setFillWidth(textField, true);

// -- label
label = new Label(dialogPane.getContentText());
label.setPrefWidth(Region.USE_COMPUTED_SIZE);
label.textProperty().bind(dialogPane.contentTextProperty());


this.grid = new GridPane();
this.grid.setHgap(10);
this.grid.setMaxWidth(Double.MAX_VALUE);
this.grid.setAlignment(Pos.CENTER_LEFT);

dialogPane.contentTextProperty().addListener(o -> updateGrid());

setTitle(ControlResources.getString("Dialog.confirm.title"));
dialogPane.setHeaderText(ControlResources.getString("Dialog.confirm.header"));
dialogPane.getStyleClass().add("text-input-dialog");
dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

updateGrid();

setResultConverter((dialogButton) -> {
ButtonBar.ButtonData data = dialogButton == null ? null : dialogButton.getButtonData();
return data == ButtonBar.ButtonData.OK_DONE ? findWordsInFile() : null;
});

}
public String getPatern(){
return textField.getText();
}
private List<Integer> findWordsInFile(){
int lineNumber = 1;
List<Integer> results = new LinkedList<>();
String pattern = textField.getText().toLowerCase();

int col = searchedText.indexOf(pattern);
while(col != -1){
results.add(col);
col = searchedText.indexOf(pattern, col + 1);
}

return results;
}
private void updateGrid() {
grid.getChildren().clear();

grid.add(label, 0, 0);
grid.add(textField, 1, 0);
getDialogPane().setContent(grid);

Platform.runLater(() -> textField.requestFocus());
}

}