Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
HoussemNasri committed Jun 23, 2022
1 parent 2bb0b6c commit d71f93a
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 2 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ group = "org.jabref"
version = project.findProperty('projVersion') ?: '100.0.0'

java {
sourceCompatibility = JavaVersion.VERSION_18
targetCompatibility = JavaVersion.VERSION_18
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

// Workaround needed for Eclipse, probably because of https://github.com/gradle/gradle/issues/16922
// Should be removed as soon as Gradle 7.0.1 is released ( https://github.com/gradle/gradle/issues/16922#issuecomment-828217060 )
Expand Down
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
requires net.harawata.appdirs;

requires org.eclipse.jgit;
requires wellbehavedfx;
uses org.eclipse.jgit.transport.SshSessionFactory;
uses org.eclipse.jgit.lib.GpgSigner;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.jabref.gui.mergeentries.newmergedialog;

public class ThreeWayMerge {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.jabref.gui.mergeentries.newmergedialog.cell;

import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.geometry.Insets;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;

/**
*
*/
public abstract class AbstractCell extends HBox {
private final StringProperty text = new SimpleStringProperty();
private final ObjectProperty<BackgroundTone> backgroundTone = new SimpleObjectProperty<>();

public AbstractCell(String text, BackgroundTone backgroundTone) {
backgroundToneProperty().addListener(invalidated -> setBackground(Background.fill(getBackgroundTone().color())));
setPadding(new Insets(8));

setText(text);
setBackgroundTone(backgroundTone);
}

public AbstractCell(String text) {
this(text, BackgroundTone.DARK);
}

public String getText() {
return textProperty().get();
}

public StringProperty textProperty() {
return text;
}

public void setText(String text) {
textProperty().set(text);
}

public void setBackgroundTone(BackgroundTone backgroundTone) {
backgroundToneProperty().set(backgroundTone);
}

public BackgroundTone getBackgroundTone() {
return backgroundToneProperty().get();
}

public ObjectProperty<BackgroundTone> backgroundToneProperty() {
return backgroundTone;
}

public enum BackgroundTone {
LIGHT(Color.web("#F7F7F7")), DARK(Color.web("#FAFAFA"));
private final Color color;

BackgroundTone(Color color) {
this.color = color;
}

public Color color() {
return color;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jabref.gui.mergeentries.newmergedialog.cell;

/**
* A non-editable cell that contains the name of some field
*/
public class FieldNameCell {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package org.jabref.gui.mergeentries.newmergedialog.cell;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.event.Event;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Background;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.paint.Color;

import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.StyleClassedTextArea;
import org.fxmisc.wellbehaved.event.InputMap;
import org.fxmisc.wellbehaved.event.Nodes;

import static org.fxmisc.wellbehaved.event.EventPattern.anyOf;
import static org.fxmisc.wellbehaved.event.EventPattern.eventType;
import static org.fxmisc.wellbehaved.event.EventPattern.mousePressed;

/**
* A non-editable and selectable field cell that contains the value of some field
*/
public class FieldValueCell extends AbstractCell implements Toggle {
private final ObjectProperty<ToggleGroup> toggleGroup = new SimpleObjectProperty<>();
private final BooleanProperty selected = new SimpleBooleanProperty();

private final StyleClassedTextArea label = new StyleClassedTextArea();

private final VirtualizedScrollPane<StyleClassedTextArea> scrollPane = new VirtualizedScrollPane<>(label);

public FieldValueCell(String text, BackgroundTone backgroundTone) {
super(text, backgroundTone);
}

public FieldValueCell(String text) {
super(text);
}

private void initialize() {
initializeLabel();
initializeSelectionBox();
}

private void initializeLabel() {
label.setEditable(false);
label.setBackground(Background.fill(Color.TRANSPARENT));
label.appendText(textProperty().get());
label.setAutoHeight(true);
label.setWrapText(true);

preventTextSelectionViaMouseEvents();
}

private void initializeSelectionBox() {
}

private void initializeScrollPane() {
HBox.setHgrow(scrollPane, Priority.ALWAYS);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
}

private void preventTextSelectionViaMouseEvents() {
InputMap<Event> preventSelection = InputMap.consume(
anyOf(eventType(MouseEvent.MOUSE_DRAGGED),
eventType(MouseEvent.DRAG_DETECTED),
eventType(MouseEvent.MOUSE_ENTERED),
mousePressed().unless(e -> e.getClickCount() == 1)
)
);
Nodes.addInputMap(label, preventSelection);
}

@Override
public ToggleGroup getToggleGroup() {
return toggleGroupProperty().get();
}

@Override
public void setToggleGroup(ToggleGroup toggleGroup) {
toggleGroupProperty().set(toggleGroup);
}

@Override
public ObjectProperty<ToggleGroup> toggleGroupProperty() {
return toggleGroup;
}

@Override
public boolean isSelected() {
return selectedProperty().get();
}

@Override
public void setSelected(boolean selected) {
selectedProperty().set(selected);
}

@Override
public BooleanProperty selectedProperty() {
return selected;
}
}

0 comments on commit d71f93a

Please sign in to comment.