Skip to content
Snippets Groups Projects
Commit 9c51fa51 authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Cleanup code

parent d6edf676
Branches
Tags
No related merge requests found
...@@ -9,15 +9,15 @@ public class DisplayableCell<T extends Displayable> extends ListCell<T> { ...@@ -9,15 +9,15 @@ public class DisplayableCell<T extends Displayable> extends ListCell<T> {
private Displayable action; private Displayable action;
@Override @Override
protected void updateItem(T action, boolean empty) { protected void updateItem(T item, boolean empty) {
super.updateItem(action, empty); super.updateItem(item, empty);
if (!empty) { if (!empty) {
if (this.action == null || this.action != action) { if (this.action == null || this.action != item) {
Node graphics = action.getGraphics(); Node graphics = item.getGraphics();
setGraphic(graphics); setGraphic(graphics);
textProperty().bind(action.displayProperty()); textProperty().bind(item.displayProperty());
this.action = action; this.action = item;
} }
} else { } else {
this.action = null; this.action = null;
......
package de.tobias.playpad.viewcontroller.dialog; package de.tobias.playpad.viewcontroller.dialog;
import de.thecodelabs.logger.Logger;
import de.thecodelabs.utils.ui.NVC; import de.thecodelabs.utils.ui.NVC;
import de.thecodelabs.utils.ui.NVCStage; import de.thecodelabs.utils.ui.NVCStage;
import de.thecodelabs.utils.util.Localization; import de.thecodelabs.utils.util.Localization;
...@@ -80,7 +81,8 @@ public class ProfileViewController extends NVC implements ChangeListener<Profile ...@@ -80,7 +81,8 @@ public class ProfileViewController extends NVC implements ChangeListener<Profile
ref.setName(newValue); ref.setName(newValue);
return; return;
} }
} catch (Exception ignored) { } catch (Exception e) {
Logger.error(e);
} }
} }
nameTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); nameTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true);
...@@ -110,7 +112,7 @@ public class ProfileViewController extends NVC implements ChangeListener<Profile ...@@ -110,7 +112,7 @@ public class ProfileViewController extends NVC implements ChangeListener<Profile
try { try {
Profile.load(ref); Profile.load(ref);
} catch (ProfileNotFoundException | DocumentException | IOException e) { } catch (ProfileNotFoundException | DocumentException | IOException e) {
e.printStackTrace(); Logger.error(e);
} }
getStageContainer().ifPresent(NVCStage::close); getStageContainer().ifPresent(NVCStage::close);
} }
...@@ -156,8 +158,8 @@ public class ProfileViewController extends NVC implements ChangeListener<Profile ...@@ -156,8 +158,8 @@ public class ProfileViewController extends NVC implements ChangeListener<Profile
ProfileReferenceManager.removeProfile(ref); ProfileReferenceManager.removeProfile(ref);
profileList.getItems().remove(ref); profileList.getItems().remove(ref);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
showErrorMessage(Localization.getString(Strings.Error_Profile_Delete, e.getMessage())); showErrorMessage(Localization.getString(Strings.Error_Profile_Delete, e.getMessage()));
Logger.error(e);
} }
}); });
} }
......
package de.tobias.playpad.viewcontroller.dialog.profile; package de.tobias.playpad.viewcontroller.dialog.profile;
import de.thecodelabs.logger.Logger;
import de.thecodelabs.utils.ui.NVC; import de.thecodelabs.utils.ui.NVC;
import de.thecodelabs.utils.ui.NVCStage; import de.thecodelabs.utils.ui.NVCStage;
import de.thecodelabs.utils.util.Localization; import de.thecodelabs.utils.util.Localization;
...@@ -75,7 +76,7 @@ public class ProfileChooseDialog extends NVC { ...@@ -75,7 +76,7 @@ public class ProfileChooseDialog extends NVC {
getStageContainer().ifPresent(NVCStage::close); getStageContainer().ifPresent(NVCStage::close);
} catch (IOException | DocumentException | ProfileNotFoundException e) { } catch (IOException | DocumentException | ProfileNotFoundException e) {
showErrorMessage(Localization.getString(Strings.Error_Profile_Save, e.getLocalizedMessage())); showErrorMessage(Localization.getString(Strings.Error_Profile_Save, e.getLocalizedMessage()));
e.printStackTrace(); Logger.error(e);
} }
} }
...@@ -87,9 +88,9 @@ public class ProfileChooseDialog extends NVC { ...@@ -87,9 +88,9 @@ public class ProfileChooseDialog extends NVC {
@FXML @FXML
private void newProfileButtonHandler(ActionEvent event) { private void newProfileButtonHandler(ActionEvent event) {
NewProfileDialog dialog = new NewProfileDialog(getContainingWindow()); NewProfileDialog dialog = new NewProfileDialog(getContainingWindow());
dialog.showAndWait().ifPresent(profile -> { dialog.showAndWait().ifPresent(created -> {
// Add new Profile to combo box and select it // Add new Profile to combo box and select it
profileComboBox.getItems().add(profile.getRef()); profileComboBox.getItems().add(created.getRef());
profileComboBox.getSelectionModel().selectLast(); profileComboBox.getSelectionModel().selectLast();
}); });
} }
......
package de.tobias.playpad.viewcontroller.dialog.project; package de.tobias.playpad.viewcontroller.dialog.project;
import de.thecodelabs.logger.Logger;
import de.thecodelabs.utils.ui.NVC; import de.thecodelabs.utils.ui.NVC;
import de.thecodelabs.utils.ui.NVCStage; import de.thecodelabs.utils.ui.NVCStage;
import de.thecodelabs.utils.util.Localization; import de.thecodelabs.utils.util.Localization;
...@@ -82,13 +83,11 @@ public class ProjectManagerDialog extends NVC { ...@@ -82,13 +83,11 @@ public class ProjectManagerDialog extends NVC {
// Mouse Open Handler // Mouse Open Handler
projectList.setOnMouseClicked(mouseEvent -> { projectList.setOnMouseClicked(mouseEvent -> {
if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY) && mouseEvent.getClickCount() == 2) {
if (mouseEvent.getClickCount() == 2) {
if (!projectList.getSelectionModel().isEmpty()) { if (!projectList.getSelectionModel().isEmpty()) {
openHandler(null); openHandler(null);
} }
} }
}
}); });
// Initial Value // Initial Value
...@@ -146,7 +145,7 @@ public class ProjectManagerDialog extends NVC { ...@@ -146,7 +145,7 @@ public class ProjectManagerDialog extends NVC {
ProjectReferenceManager.setSync(reference, newValue); ProjectReferenceManager.setSync(reference, newValue);
} catch (ProjectNotFoundException | ProfileNotFoundException | DocumentException | IOException e) { } catch (ProjectNotFoundException | ProfileNotFoundException | DocumentException | IOException e) {
showErrorMessage(Localization.getString(Strings.Error_Project_Sync_Change, e.getLocalizedMessage())); showErrorMessage(Localization.getString(Strings.Error_Project_Sync_Change, e.getLocalizedMessage()));
e.printStackTrace(); Logger.error(e);
} catch (ProjectReader.ProjectReaderDelegate.ProfileAbortException ignored) { } catch (ProjectReader.ProjectReaderDelegate.ProfileAbortException ignored) {
} }
} }
...@@ -211,7 +210,7 @@ public class ProjectManagerDialog extends NVC { ...@@ -211,7 +210,7 @@ public class ProjectManagerDialog extends NVC {
Optional<ProjectReference> importedProject = dialog.showAndWait(); Optional<ProjectReference> importedProject = dialog.showAndWait();
importedProject.ifPresent(projectList.getItems()::add); importedProject.ifPresent(projectList.getItems()::add);
} catch (IOException | DocumentException e) { } catch (IOException | DocumentException e) {
e.printStackTrace(); Logger.error(e);
} }
} }
} }
...@@ -248,7 +247,7 @@ public class ProjectManagerDialog extends NVC { ...@@ -248,7 +247,7 @@ public class ProjectManagerDialog extends NVC {
projectList.getItems().remove(reference); projectList.getItems().remove(reference);
} catch (IOException e) { } catch (IOException e) {
showErrorMessage(Localization.getString(Strings.Error_Project_Delete, e.getLocalizedMessage())); showErrorMessage(Localization.getString(Strings.Error_Project_Delete, e.getLocalizedMessage()));
e.printStackTrace(); Logger.error(e);
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment