diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateListResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateListResponse.java index 7bffcf3a..743c71b4 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateListResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateListResponse.java @@ -12,7 +12,6 @@ import java.util.HashSet; import java.util.Map; -import java.util.Set; public class UpdateListResponse implements JsonResponseInterface { diff --git a/Launcher/runtime/engine/api.js b/Launcher/runtime/engine/api.js index d7cbcae5..a1bb7b7a 100644 --- a/Launcher/runtime/engine/api.js +++ b/Launcher/runtime/engine/api.js @@ -60,20 +60,8 @@ var LauncherSettings = LauncherSettingsClass.static; // Helper JS class API imports var JSApplication = null; -var CheckComboBox = null; -var CheckModel = null; -var IndexedCheckModel = null; -var CheckComboBoxSkin = null; -var RingProgressIndicator = null; -var RingProgressIndicatorSkin = null; if (typeof JSApplicationClass !== 'undefined') { JSApplication = JSApplicationClass.static; - CheckComboBox = CheckComboBoxClass.static; - CheckModel = CheckModelClass.static; - IndexedCheckModel = IndexedCheckModelClass.static; - CheckComboBoxSkin = CheckComboBoxSkinClass.static; - RingProgressIndicator = RingProgressIndicatorClass.static; - RingProgressIndicatorSkin = RingProgressIndicatorSkinClass.static; } // API wrapper diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardInterface.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardInterface.java index 7e793db0..3a994300 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardInterface.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherGuardInterface.java @@ -3,7 +3,6 @@ import ru.gravit.launcher.client.ClientLauncherContext; import java.nio.file.Path; -import java.util.Collection; public interface LauncherGuardInterface { String getName(); diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java index 0e2a0d18..9367f2f1 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherJavaGuard.java @@ -7,7 +7,6 @@ import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Collection; import java.util.Collections; public class LauncherJavaGuard implements LauncherGuardInterface { diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java index 7ff825f2..7a251b3b 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherNoGuard.java @@ -6,7 +6,6 @@ import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Collection; import java.util.Collections; public class LauncherNoGuard implements LauncherGuardInterface { diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java index 5f55acfb..b5c59884 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java @@ -9,8 +9,6 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Base64; -import java.util.Collection; import java.util.Collections; import java.util.Map; diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java b/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java index fc99a3c0..a65c9330 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java +++ b/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java @@ -5,12 +5,6 @@ import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.client.*; -import ru.gravit.launcher.gui.choosebox.CheckComboBox; -import ru.gravit.launcher.gui.choosebox.CheckComboBoxSkin; -import ru.gravit.launcher.gui.choosebox.CheckModel; -import ru.gravit.launcher.gui.choosebox.IndexedCheckModel; -import ru.gravit.launcher.gui.indicator.RingProgressIndicator; -import ru.gravit.launcher.gui.indicator.RingProgressIndicatorSkin; import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.hasher.HashedEntry; @@ -117,12 +111,6 @@ public static void addLauncherClassBindings(Map bindings) { try { Class.forName("javafx.application.Application"); bindings.put("JSApplicationClass", JSApplication.class); - bindings.put("RingProgressIndicatorClass", RingProgressIndicator.class); - bindings.put("RingProgressIndicatorSkinClass", RingProgressIndicatorSkin.class); - bindings.put("CheckComboBoxClass", CheckComboBox.class); - bindings.put("CheckModelClass", CheckModel.class); - bindings.put("IndexedCheckModelClass", IndexedCheckModel.class); - bindings.put("CheckComboBoxSkinClass", CheckComboBoxSkin.class); } catch (ClassNotFoundException ignored) { LogHelper.warning("JavaFX API isn't available"); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckBitSetModelBase.java b/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckBitSetModelBase.java deleted file mode 100644 index 58203cc6..00000000 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckBitSetModelBase.java +++ /dev/null @@ -1,233 +0,0 @@ -package ru.gravit.launcher.gui.choosebox; - -import com.sun.javafx.collections.MappingChange; -import com.sun.javafx.collections.NonIterableChange; -import com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList; -import javafx.beans.property.BooleanProperty; -import javafx.beans.property.SimpleBooleanProperty; -import javafx.collections.ListChangeListener; -import javafx.collections.ObservableList; - -import java.util.BitSet; -import java.util.Map; - -abstract class CheckBitSetModelBase implements IndexedCheckModel { - private final Map itemBooleanMap; - - private final BitSet checkedIndices; - private final ReadOnlyUnbackedObservableList checkedIndicesList; - private final ReadOnlyUnbackedObservableList checkedItemsList; - - CheckBitSetModelBase(final Map itemBooleanMap) { - this.itemBooleanMap = itemBooleanMap; - - this.checkedIndices = new BitSet(); - - this.checkedIndicesList = new ReadOnlyUnbackedObservableList() { - @Override - public boolean contains(Object o) { - if (o instanceof Number) { - Number n = (Number) o; - int index = n.intValue(); - - return index >= 0 && index < checkedIndices.length() && checkedIndices.get(index); - } - - return false; - } - - @Override - public Integer get(int index) { - if (index < 0 || index >= getItemCount()) - return -1; - - for (int pos = 0, val = checkedIndices.nextSetBit(0); val >= 0 - || pos == index; pos++, val = checkedIndices.nextSetBit(val + 1)) - if (pos == index) - return val; - - return -1; - } - - @Override - public int size() { - return checkedIndices.cardinality(); - } - }; - - this.checkedItemsList = new ReadOnlyUnbackedObservableList() { - @Override - public T get(int i) { - int pos = checkedIndicesList.get(i); - if (pos < 0 || pos >= getItemCount()) - return null; - return getItem(pos); - } - - @Override - public int size() { - return checkedIndices.cardinality(); - } - }; - - final MappingChange.Map map = this::getItem; - - checkedIndicesList.addListener((ListChangeListener) c -> { - boolean hasRealChangeOccurred = false; - while (c.next() && !hasRealChangeOccurred) - hasRealChangeOccurred = c.wasAdded() || c.wasRemoved(); - - if (hasRealChangeOccurred) { - c.reset(); - checkedItemsList.callObservers(new MappingChange<>(c, map, checkedItemsList)); - } - c.reset(); - }); - getCheckedItems().addListener((ListChangeListener) c -> { - while (c.next()) { - if (c.wasAdded()) - for (T item : c.getAddedSubList()) { - BooleanProperty p = getItemBooleanProperty(item); - if (p != null) - p.set(true); - } - - if (c.wasRemoved()) - for (T item : c.getRemoved()) { - BooleanProperty p = getItemBooleanProperty(item); - if (p != null) - p.set(false); - } - } - }); - } - - @Override - public void check(int index) { - if (index < 0 || index >= getItemCount()) - return; - checkedIndices.set(index); - final int changeIndex = checkedIndicesList.indexOf(index); - checkedIndicesList.callObservers( - new NonIterableChange.SimpleAddChange<>(changeIndex, changeIndex + 1, checkedIndicesList)); - } - - @Override - public void check(T item) { - int index = getItemIndex(item); - check(index); - } - - @Override - public void checkAll() { - for (int i = 0; i < getItemCount(); i++) - check(i); - } - - @Override - public void checkIndices(int... indices) { - for (int indice : indices) - check(indice); - } - - @Override - public void clearCheck(int index) { - if (index < 0 || index >= getItemCount()) - return; - checkedIndices.clear(index); - - final int changeIndex = checkedIndicesList.indexOf(index); - checkedIndicesList.callObservers( - new NonIterableChange.SimpleRemovedChange<>(changeIndex, changeIndex, index, checkedIndicesList)); - } - - @Override - public void clearCheck(T item) { - int index = getItemIndex(item); - clearCheck(index); - } - - @Override - public void clearChecks() { - for (int index = 0; index < checkedIndices.length(); index++) - clearCheck(index); - } - - @Override - public ObservableList getCheckedIndices() { - return checkedIndicesList; - } - - @Override - public ObservableList getCheckedItems() { - return checkedItemsList; - } - - @Override - public abstract T getItem(int index); - - BooleanProperty getItemBooleanProperty(T item) { - return itemBooleanMap.get(item); - } - - @Override - public abstract int getItemCount(); - - @Override - public abstract int getItemIndex(T item); - - @Override - public boolean isChecked(int index) { - return checkedIndices.get(index); - } - - @Override - public boolean isChecked(T item) { - int index = getItemIndex(item); - return isChecked(index); - } - - @Override - public boolean isEmpty() { - return checkedIndices.isEmpty(); - } - - @Override - public void toggleCheckState(int index) { - if (isChecked(index)) - clearCheck(index); - else - check(index); - } - - @Override - public void toggleCheckState(T item) { - int index = getItemIndex(item); - toggleCheckState(index); - } - - protected void updateMap() { - itemBooleanMap.clear(); - for (int i = 0; i < getItemCount(); i++) { - final int index = i; - final T item = getItem(index); - - final BooleanProperty booleanProperty = new SimpleBooleanProperty(item, "selected", false); //$NON-NLS-1$ - itemBooleanMap.put(item, booleanProperty); - - booleanProperty.addListener(o -> { - if (booleanProperty.get()) { - checkedIndices.set(index); - final int changeIndex1 = checkedIndicesList.indexOf(index); - checkedIndicesList.callObservers(new NonIterableChange.SimpleAddChange<>(changeIndex1, - changeIndex1 + 1, checkedIndicesList)); - } else { - final int changeIndex2 = checkedIndicesList.indexOf(index); - checkedIndices.clear(index); - checkedIndicesList.callObservers(new NonIterableChange.SimpleRemovedChange<>(changeIndex2, - changeIndex2, index, checkedIndicesList)); - } - }); - } - } -} \ No newline at end of file diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckComboBox.java b/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckComboBox.java deleted file mode 100644 index 262d1fde..00000000 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckComboBox.java +++ /dev/null @@ -1,142 +0,0 @@ -package ru.gravit.launcher.gui.choosebox; - -import javafx.beans.property.*; -import javafx.collections.FXCollections; -import javafx.collections.ListChangeListener; -import javafx.collections.ObservableList; -import javafx.scene.control.Skin; -import javafx.util.StringConverter; -import ru.gravit.launcher.LauncherAPI; - -import java.util.HashMap; -import java.util.Map; - -public class CheckComboBox extends ControlsFXControl { - private static class CheckComboBoxBitSetCheckModel extends CheckBitSetModelBase { - private final ObservableList items; - - CheckComboBoxBitSetCheckModel(final ObservableList items, final Map itemBooleanMap) { - super(itemBooleanMap); - - this.items = items; - this.items.addListener((ListChangeListener) c -> updateMap()); - - updateMap(); - } - - @Override - public T getItem(int index) { - return items.get(index); - } - - @Override - public int getItemCount() { - return items.size(); - } - - @Override - public int getItemIndex(T item) { - return items.indexOf(item); - } - } - - private final ObservableList items; - private final Map itemBooleanMap; - private CheckComboBoxSkin checkComboBoxSkin; - private ObjectProperty> checkModel = new SimpleObjectProperty<>(this, "checkModel"); - private ObjectProperty> converter = new SimpleObjectProperty<>(this, - "converter"); - private StringProperty title = new SimpleStringProperty(null); - - public CheckComboBox() { - this(null); - } - - public CheckComboBox(final ObservableList items) { - final int initialSize = items == null ? 32 : items.size(); - - this.itemBooleanMap = new HashMap<>(initialSize); - this.items = items == null ? FXCollections.observableArrayList() : items; - setCheckModel(new CheckComboBoxBitSetCheckModel<>(this.items, itemBooleanMap)); - } - - @LauncherAPI - public final ObjectProperty> checkModelProperty() { - return checkModel; - } - - @LauncherAPI - public final ObjectProperty> converterProperty() { - return converter; - } - - @Override - protected Skin createDefaultSkin() { - checkComboBoxSkin = new CheckComboBoxSkin<>(this); - return checkComboBoxSkin; - } - - @LauncherAPI - public final IndexedCheckModel getCheckModel() { - return checkModel == null ? null : checkModel.get(); - } - - @LauncherAPI - public final StringConverter getConverter() { - return converterProperty().get(); - } - - @LauncherAPI - public BooleanProperty getItemBooleanProperty(int index) { - if (index < 0 || index >= items.size()) - return null; - return getItemBooleanProperty(getItems().get(index)); - } - - @LauncherAPI - public BooleanProperty getItemBooleanProperty(T item) { - return itemBooleanMap.get(item); - } - - @LauncherAPI - public ObservableList getItems() { - return items; - } - - @LauncherAPI - public final String getTitle() { - return title.getValue(); - } - - @LauncherAPI - public void hide() { - if (checkComboBoxSkin != null) - checkComboBoxSkin.hide(); - } - - @LauncherAPI - public final void setCheckModel(IndexedCheckModel value) { - checkModelProperty().set(value); - } - - @LauncherAPI - public final void setConverter(StringConverter value) { - converterProperty().set(value); - } - - @LauncherAPI - public final void setTitle(String value) { - title.setValue(value); - } - - @LauncherAPI - public void show() { - if (checkComboBoxSkin != null) - checkComboBoxSkin.show(); - } - - @LauncherAPI - public final StringProperty titleProperty() { - return title; - } -} diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckComboBoxSkin.java b/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckComboBoxSkin.java deleted file mode 100644 index 3a826a39..00000000 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckComboBoxSkin.java +++ /dev/null @@ -1,172 +0,0 @@ -package ru.gravit.launcher.gui.choosebox; - -import com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList; -import com.sun.javafx.scene.control.behavior.BehaviorBase; -import com.sun.javafx.scene.control.skin.BehaviorSkinBase; -import com.sun.javafx.scene.control.skin.ComboBoxListViewSkin; -import javafx.collections.ListChangeListener; -import javafx.collections.ObservableList; -import javafx.scene.control.ComboBox; -import javafx.scene.control.ListCell; -import javafx.scene.control.ListView; -import javafx.scene.control.Skin; -import javafx.scene.control.cell.CheckBoxListCell; -import javafx.scene.input.KeyCode; -import ru.gravit.launcher.LauncherAPI; - -import java.util.Collections; - -public class CheckComboBoxSkin extends BehaviorSkinBase, BehaviorBase>> { - - private final ComboBox comboBox; - private final ListCell buttonCell; - - private final CheckComboBox control; - private final ReadOnlyUnbackedObservableList selectedItems; - - @SuppressWarnings("unchecked") - public CheckComboBoxSkin(final CheckComboBox control) { - super(control, new BehaviorBase<>(control, Collections.emptyList())); - - this.control = control; - ObservableList items = control.getItems(); - - ReadOnlyUnbackedObservableList selectedIndices = (ReadOnlyUnbackedObservableList) control.getCheckModel().getCheckedIndices(); - selectedItems = (ReadOnlyUnbackedObservableList) control.getCheckModel().getCheckedItems(); - - comboBox = new ComboBox(items) { - @Override - protected javafx.scene.control.Skin createDefaultSkin() { - return createComboBoxListViewSkin(this); - } - }; - comboBox.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); - - comboBox.setCellFactory(listView -> { - CheckBoxListCell result = new CheckBoxListCell<>(control::getItemBooleanProperty); - result.focusedProperty().addListener((o, ov, nv) -> { - if (nv) - result.getParent().requestFocus(); - }); - result.setOnMouseClicked(e -> { - T item = result.getItem(); - if (control.getCheckModel().isChecked(item)) - control.getCheckModel().clearCheck(item); - else - control.getCheckModel().check(item); - }); - result.converterProperty().bind(control.converterProperty()); - return result; - }); - - buttonCell = new ListCell() { - @Override - protected void updateItem(T item, boolean empty) { - setText(getTextString()); - } - }; - comboBox.setButtonCell(buttonCell); - comboBox.setValue((T) getTextString()); - - selectedIndices.addListener((ListChangeListener) c -> buttonCell.updateIndex(0)); - - getChildren().add(comboBox); - } - - private String buildString() { - final StringBuilder sb = new StringBuilder(); - for (int i = 0, max = selectedItems.size(); i < max; i++) { - T item = selectedItems.get(i); - if (control.getConverter() == null) - sb.append(item); - else - sb.append(control.getConverter().toString(item)); - if (i < max - 1) - sb.append(", "); //$NON-NLS-1$ - } - return sb.toString(); - } - - @LauncherAPI - @Override - protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, - double leftInset) { - return getSkinnable().prefHeight(width); - } - - @LauncherAPI - @Override - protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, - double leftInset) { - return getSkinnable().prefWidth(height); - } - - @LauncherAPI - @Override - protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, - double leftInset) { - return comboBox.minHeight(width); - } - - @LauncherAPI - @Override - protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, - double leftInset) { - return comboBox.minWidth(height); - } - - @LauncherAPI - @Override - protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, - double leftInset) { - return comboBox.prefHeight(width); - } - - @LauncherAPI - @Override - protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, - double leftInset) { - return comboBox.prefWidth(height); - } - - private Skin createComboBoxListViewSkin(ComboBox comboBox) { - final ComboBoxListViewSkin comboBoxListViewSkin = new ComboBoxListViewSkin(comboBox) { - @Override - protected boolean isHideOnClickEnabled() { - return false; - } - }; - @SuppressWarnings("unchecked") final ListView listView = (ListView) comboBoxListViewSkin.getPopupContent(); - listView.setOnKeyPressed(e -> { - if (e.getCode() == KeyCode.SPACE) { - T item = listView.getSelectionModel().getSelectedItem(); - if (item != null) { - final IndexedCheckModel checkModel = control.getCheckModel(); - if (checkModel != null) - checkModel.toggleCheckState(item); - } - } else if (e.getCode() == KeyCode.ESCAPE) - hide(); - }); - return comboBoxListViewSkin; - } - - @LauncherAPI - protected String getTextString() { - - if (control.getTitle() != null) - return control.getTitle(); - return buildString(); - - } - - @LauncherAPI - public void hide() { - comboBox.hide(); - } - - @LauncherAPI - public void show() { - comboBox.show(); - } -} diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckModel.java b/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckModel.java deleted file mode 100644 index 33a33e45..00000000 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/CheckModel.java +++ /dev/null @@ -1,33 +0,0 @@ -package ru.gravit.launcher.gui.choosebox; - -import javafx.collections.ObservableList; -import ru.gravit.launcher.LauncherAPI; - -public interface CheckModel { - @LauncherAPI - void check(T item); - - @LauncherAPI - void checkAll(); - - @LauncherAPI - void clearCheck(T item); - - @LauncherAPI - void clearChecks(); - - @LauncherAPI - ObservableList getCheckedItems(); - - @LauncherAPI - int getItemCount(); - - @LauncherAPI - boolean isChecked(T item); - - @LauncherAPI - boolean isEmpty(); - - @LauncherAPI - void toggleCheckState(T item); -} diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/ControlsFXControl.java b/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/ControlsFXControl.java deleted file mode 100644 index 82353bba..00000000 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/ControlsFXControl.java +++ /dev/null @@ -1,20 +0,0 @@ -package ru.gravit.launcher.gui.choosebox; - -import javafx.scene.control.Control; - -abstract class ControlsFXControl extends Control { - - private String stylesheet; - - public ControlsFXControl() { - - } - - protected final String getUserAgentStylesheet(Class clazz, String fileName) { - - if (stylesheet == null) - stylesheet = clazz.getResource(fileName).toExternalForm(); - - return stylesheet; - } -} diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/IndexedCheckModel.java b/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/IndexedCheckModel.java deleted file mode 100644 index 5d661000..00000000 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/choosebox/IndexedCheckModel.java +++ /dev/null @@ -1,31 +0,0 @@ -package ru.gravit.launcher.gui.choosebox; - -import javafx.collections.ObservableList; -import ru.gravit.launcher.LauncherAPI; - -public interface IndexedCheckModel extends CheckModel { - @LauncherAPI - void check(int index); - - @LauncherAPI - void checkIndices(int... indices); - - @LauncherAPI - void clearCheck(int index); - - @LauncherAPI - ObservableList getCheckedIndices(); - - @LauncherAPI - T getItem(int index); - - @LauncherAPI - int getItemIndex(T item); - - @LauncherAPI - boolean isChecked(int index); - - @LauncherAPI - void toggleCheckState(int index); - -} \ No newline at end of file diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/ProgressCircleIndicator.java b/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/ProgressCircleIndicator.java deleted file mode 100644 index bf7d4a2e..00000000 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/ProgressCircleIndicator.java +++ /dev/null @@ -1,86 +0,0 @@ -package ru.gravit.launcher.gui.indicator; - -import com.sun.javafx.css.converters.SizeConverter; -import javafx.beans.property.DoubleProperty; -import javafx.css.CssMetaData; -import javafx.css.Styleable; -import javafx.css.StyleableDoubleProperty; -import javafx.css.StyleableProperty; -import javafx.scene.control.Control; -import javafx.scene.control.ProgressIndicator; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -abstract class ProgressCircleIndicator extends ProgressIndicator { - public ProgressCircleIndicator() { - this.getStylesheets().add(ProgressCircleIndicator.class.getResource("/runtime/launcher/overlay/update/circleprogress.css").toExternalForm()); - } - - public final void setInnerCircleRadius(int value) { - innerCircleRadiusProperty().set(value); - } - - public final DoubleProperty innerCircleRadiusProperty() { - return innerCircleRadius; - } - - public final double getInnerCircleRadius() { - return innerCircleRadiusProperty().get(); - } - - /** - * radius of the inner circle - */ - private DoubleProperty innerCircleRadius = new StyleableDoubleProperty(60) { - @Override - public Object getBean() { - return ProgressCircleIndicator.this; - } - - @Override - public String getName() { - return "innerCircleRadius"; - } - - @Override - public CssMetaData getCssMetaData() { - return StyleableProperties.INNER_CIRCLE_RADIUS; - } - }; - - private static class StyleableProperties { - private static final CssMetaData INNER_CIRCLE_RADIUS = new CssMetaData( - "-fx-inner-radius", SizeConverter.getInstance(), 60) { - - @Override - public boolean isSettable(ProgressCircleIndicator n) { - return n.innerCircleRadiusProperty() == null || !n.innerCircleRadiusProperty().isBound(); - } - - @SuppressWarnings("unchecked") - @Override - public StyleableProperty getStyleableProperty(ProgressCircleIndicator n) { - return (StyleableProperty) n.innerCircleRadiusProperty(); - } - }; - - public static final List> STYLEABLES; - - static { - final List> styleables = new ArrayList<>(Control.getClassCssMetaData()); - styleables.add(INNER_CIRCLE_RADIUS); - STYLEABLES = Collections.unmodifiableList(styleables); - } - } - - public static List> getClassCssMetaData() { - return StyleableProperties.STYLEABLES; - } - - @Override - public List> getControlCssMetaData() { - return StyleableProperties.STYLEABLES; - } -} diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicator.java b/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicator.java deleted file mode 100644 index 11c04589..00000000 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicator.java +++ /dev/null @@ -1,95 +0,0 @@ -package ru.gravit.launcher.gui.indicator; - -import com.sun.javafx.css.converters.SizeConverter; -import javafx.beans.property.DoubleProperty; -import javafx.css.CssMetaData; -import javafx.css.Styleable; -import javafx.css.StyleableDoubleProperty; -import javafx.css.StyleableProperty; -import javafx.scene.control.Control; -import javafx.scene.control.Skin; -import ru.gravit.launcher.LauncherAPI; -import ru.gravit.utils.helper.LogHelper; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class RingProgressIndicator extends ProgressCircleIndicator { - public RingProgressIndicator() { - LogHelper.debug("Setting JVM dir name"); - this.getStylesheets().add(RingProgressIndicator.class.getResource("/runtime/launcher/overlay/update/ringprogress.css").toExternalForm()); - this.getStyleClass().add("ringindicator"); - } - - @Override - protected Skin createDefaultSkin() { - return new RingProgressIndicatorSkin(this); - } - - @LauncherAPI - public final void setRingWidth(int value) { - ringWidthProperty().set(value); - } - - @LauncherAPI - public final DoubleProperty ringWidthProperty() { - return ringWidth; - } - - @LauncherAPI - public final double getRingWidth() { - return ringWidthProperty().get(); - } - - /** - * thickness of the ring indicator. - */ - private DoubleProperty ringWidth = new StyleableDoubleProperty(22) { - @Override - public Object getBean() { - return RingProgressIndicator.this; - } - - @Override - public String getName() { - return "ringWidth"; - } - - @Override - public CssMetaData getCssMetaData() { - return StyleableProperties.RING_WIDTH; - } - }; - - private static class StyleableProperties { - private static final CssMetaData RING_WIDTH = new CssMetaData( - "-fx-ring-width", SizeConverter.getInstance(), 22) { - - @Override - public boolean isSettable(RingProgressIndicator n) { - return n.ringWidth == null || !n.ringWidth.isBound(); - } - - @SuppressWarnings("unchecked") - @Override - public StyleableProperty getStyleableProperty(RingProgressIndicator n) { - return (StyleableProperty) n.ringWidth; - } - }; - - public static final List> STYLEABLES; - - static { - final List> styleables = new ArrayList<>(Control.getClassCssMetaData()); - styleables.addAll(getClassCssMetaData()); - styleables.add(RING_WIDTH); - STYLEABLES = Collections.unmodifiableList(styleables); - } - } - - @Override - public List> getControlCssMetaData() { - return StyleableProperties.STYLEABLES; - } -} diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicatorSkin.java b/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicatorSkin.java deleted file mode 100644 index 3367767e..00000000 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicatorSkin.java +++ /dev/null @@ -1,124 +0,0 @@ -package ru.gravit.launcher.gui.indicator; - -import javafx.animation.Animation; -import javafx.animation.Interpolator; -import javafx.animation.RotateTransition; -import javafx.scene.Node; -import javafx.scene.control.Label; -import javafx.scene.control.Skin; -import javafx.scene.layout.Region; -import javafx.scene.layout.StackPane; -import javafx.scene.shape.Arc; -import javafx.scene.shape.Circle; -import javafx.util.Duration; - -/** - * Skin of the ring progress indicator where an arc grows and by the progress value up to 100% where the arc becomes a ring. - * - * @author Andrea Vacondio - */ -public class RingProgressIndicatorSkin implements Skin { - - private final RingProgressIndicator indicator; - private final Label percentLabel = new Label(); - private final Circle innerCircle = new Circle(); - private final Circle outerCircle = new Circle(); - private final StackPane container = new StackPane(); - private final Arc fillerArc = new Arc(); - private final RotateTransition transition = new RotateTransition(Duration.millis(2000), fillerArc); - - public RingProgressIndicatorSkin(final RingProgressIndicator indicator) { - this.indicator = indicator; - initContainer(indicator); - initFillerArc(); - container.widthProperty().addListener((o, oldVal, newVal) -> fillerArc.setCenterX(newVal.intValue() / 2)); - container.heightProperty().addListener((o, oldVal, newVal) -> fillerArc.setCenterY(newVal.intValue() / 2)); - innerCircle.getStyleClass().add("ringindicator-inner-circle"); - outerCircle.getStyleClass().add("ringindicator-outer-circle-secondary"); - updateRadii(); - - this.indicator.indeterminateProperty().addListener((o, oldVal, newVal) -> initIndeterminate(newVal)); - this.indicator.progressProperty().addListener((o, oldVal, newVal) -> { - if (newVal.intValue() >= 0) { - fillerArc.setLength(newVal.doubleValue() * -360); - } - }); - this.indicator.ringWidthProperty().addListener((o, oldVal, newVal) -> updateRadii()); - innerCircle.strokeWidthProperty().addListener((e) -> updateRadii()); - innerCircle.radiusProperty().addListener((e) -> updateRadii()); - initTransition(); - initIndeterminate(indicator.isIndeterminate()); - indicator.visibleProperty().addListener((o, oldVal, newVal) -> { - if (newVal && this.indicator.isIndeterminate()) { - transition.play(); - } else { - transition.pause(); - } - }); - container.getChildren().addAll(fillerArc, outerCircle, innerCircle, percentLabel); - } - - private void initTransition() { - transition.setAutoReverse(false); - transition.setCycleCount(Animation.INDEFINITE); - transition.setDelay(Duration.ZERO); - transition.setInterpolator(Interpolator.LINEAR); - transition.setByAngle(360); - } - - private void initFillerArc() { - fillerArc.setManaged(false); - fillerArc.getStyleClass().add("ringindicator-filler"); - fillerArc.setStartAngle(90); - fillerArc.setLength(indicator.getProgress() * -360); - } - - private void initContainer(final RingProgressIndicator indicator) { - container.getStylesheets().addAll(indicator.getStylesheets()); - container.getStyleClass().addAll("circleindicator-container"); - container.setMaxHeight(Region.USE_PREF_SIZE); - container.setMaxWidth(Region.USE_PREF_SIZE); - } - - private void updateRadii() { - double ringWidth = indicator.getRingWidth(); - double innerCircleHalfStrokeWidth = innerCircle.getStrokeWidth() / 2; - double innerCircleRadius = indicator.getInnerCircleRadius(); - outerCircle.setRadius(innerCircleRadius + innerCircleHalfStrokeWidth + ringWidth); - fillerArc.setRadiusY(innerCircleRadius + innerCircleHalfStrokeWidth - 1 + (ringWidth / 2)); - fillerArc.setRadiusX(innerCircleRadius + innerCircleHalfStrokeWidth - 1 + (ringWidth / 2)); - fillerArc.setStrokeWidth(ringWidth); - innerCircle.setRadius(innerCircleRadius); - } - - private void initIndeterminate(boolean newVal) { - percentLabel.setVisible(!newVal); - if (newVal) { - fillerArc.setLength(360); - fillerArc.getStyleClass().add("indeterminate"); - if (indicator.isVisible()) { - transition.play(); - } - } else { - fillerArc.getStyleClass().remove("indeterminate"); - fillerArc.setRotate(0); - transition.stop(); - } - } - - @Override - public RingProgressIndicator getSkinnable() { - return indicator; - } - - @Override - public Node getNode() { - return container; - } - - @Override - public void dispose() { - transition.stop(); - } - -} diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java index b6f712c7..11777930 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java @@ -17,7 +17,6 @@ import ru.gravit.utils.helper.SecurityHelper; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.net.URLConnection; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/ProfilesRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/ProfilesRequest.java index 4f58cbe2..c13eb7ec 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/ProfilesRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/ProfilesRequest.java @@ -13,7 +13,6 @@ import ru.gravit.launcher.serialize.HOutput; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public final class ProfilesRequest extends Request implements RequestInterface { diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java index 342c6ed0..dfe9c1c1 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java @@ -12,9 +12,7 @@ import ru.gravit.utils.helper.IOHelper; import java.io.IOException; -import java.util.Collections; import java.util.HashSet; -import java.util.Set; public final class UpdateListRequest extends Request implements RequestInterface { @LauncherAPI diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java index fc2d5f67..6319a855 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java @@ -1,11 +1,9 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; -import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; -import java.util.ArrayList; import java.util.HashSet; import java.util.UUID;