-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bb0b6c
commit d71f93a
Showing
6 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMerge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.jabref.gui.mergeentries.newmergedialog; | ||
|
||
public class ThreeWayMerge { | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/AbstractCell.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/FieldNameCell.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} |
108 changes: 108 additions & 0 deletions
108
src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/FieldValueCell.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |