3030import javafx .scene .Scene ;
3131import javafx .scene .control .*;
3232import javafx .scene .input .KeyCode ;
33- import javafx .scene .input .MouseButton ;
3433import javafx .scene .layout .*;
3534import javafx .stage .Stage ;
3635import org .jackhuang .hmcl .game .GameDumpGenerator ;
3938import org .jackhuang .hmcl .task .Schedulers ;
4039import org .jackhuang .hmcl .theme .Themes ;
4140import org .jackhuang .hmcl .ui .construct .MessageDialogPane ;
42- import org .jackhuang .hmcl .ui .construct .NoneMultipleSelectionModel ;
4341import org .jackhuang .hmcl .ui .construct .SpinnerPane ;
4442import org .jackhuang .hmcl .util .CircularArrayList ;
4543import org .jackhuang .hmcl .util .Lang ;
@@ -261,9 +259,6 @@ private static final class LogWindowSkin extends SkinBase<LogWindowImpl> {
261259 private static final PseudoClass INFO = PseudoClass .getPseudoClass ("info" );
262260 private static final PseudoClass DEBUG = PseudoClass .getPseudoClass ("debug" );
263261 private static final PseudoClass TRACE = PseudoClass .getPseudoClass ("trace" );
264- private static final PseudoClass SELECTED = PseudoClass .getPseudoClass ("selected" );
265-
266- private final Set <ListCell <Log >> selected = new HashSet <>();
267262 private final JFXSnackbar snackbar = new JFXSnackbar ();
268263
269264 LogWindowSkin (LogWindowImpl control ) {
@@ -309,6 +304,7 @@ private static final class LogWindowSkin extends SkinBase<LogWindowImpl> {
309304
310305 {
311306 ListView <Log > listView = control .listView ;
307+ listView .getSelectionModel ().setSelectionMode (SelectionMode .MULTIPLE );
312308 listView .getItems ().addListener ((InvalidationListener ) observable -> {
313309 if (!listView .getItems ().isEmpty () && control .autoScroll .get ())
314310 listView .scrollTo (listView .getItems ().size () - 1 );
@@ -318,7 +314,6 @@ private static final class LogWindowSkin extends SkinBase<LogWindowImpl> {
318314 + "\" ; -fx-font-size: " + config ().getFontSize () + "px;" );
319315 listView .setCellFactory (x -> new ListCell <>() {
320316 {
321- x .setSelectionModel (new NoneMultipleSelectionModel <>());
322317 getStyleClass ().add ("log-window-list-cell" );
323318 Region clippedContainer = (Region ) listView .lookup (".clipped-container" );
324319 if (clippedContainer != null ) {
@@ -328,32 +323,6 @@ private static final class LogWindowSkin extends SkinBase<LogWindowImpl> {
328323 setPadding (new Insets (2 ));
329324 setWrapText (true );
330325 setGraphic (null );
331-
332- setOnMouseClicked (event -> {
333- if (event .getButton () != MouseButton .PRIMARY )
334- return ;
335-
336- if (!event .isControlDown ()) {
337- for (ListCell <Log > logListCell : selected ) {
338- if (logListCell != this ) {
339- logListCell .pseudoClassStateChanged (SELECTED , false );
340- if (logListCell .getItem () != null ) {
341- logListCell .getItem ().setSelected (false );
342- }
343- }
344- }
345-
346- selected .clear ();
347- }
348-
349- selected .add (this );
350- pseudoClassStateChanged (SELECTED , true );
351- if (getItem () != null ) {
352- getItem ().setSelected (true );
353- }
354-
355- event .consume ();
356- });
357326 }
358327
359328 @ Override
@@ -367,7 +336,6 @@ protected void updateItem(Log item, boolean empty) {
367336 pseudoClassStateChanged (INFO , !empty && item .getLevel () == Log4jLevel .INFO );
368337 pseudoClassStateChanged (DEBUG , !empty && item .getLevel () == Log4jLevel .DEBUG );
369338 pseudoClassStateChanged (TRACE , !empty && item .getLevel () == Log4jLevel .TRACE );
370- pseudoClassStateChanged (SELECTED , !empty && item .isSelected ());
371339
372340 if (empty ) {
373341 setText (null );
@@ -379,10 +347,13 @@ protected void updateItem(Log item, boolean empty) {
379347
380348 listView .setOnKeyPressed (event -> {
381349 if (event .isControlDown () && event .getCode () == KeyCode .C ) {
350+ if (listView .getSelectionModel ().isEmpty ())
351+ return ;
352+
382353 StringBuilder stringBuilder = new StringBuilder ();
383354
384- for (Log item : listView .getItems ()) {
385- if (item != null && item . isSelected () ) {
355+ for (Log item : listView .getSelectionModel (). getSelectedItems ()) {
356+ if (item != null ) {
386357 if (item .getLog () != null )
387358 stringBuilder .append (item .getLog ());
388359 stringBuilder .append ('\n' );
0 commit comments