diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml index a46415f06e9ba5bea9ef83657e28d61e9a18dee0..9d5745755f8bbe303e3d406e6f8b4d0a8ea6c951 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml @@ -84,7 +84,14 @@ <HBox fx:id="toolbarHBox" alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" prefHeight="28.0" prefWidth="586.0" spacing="14.0"> <children> <HBox fx:id="pageHBox" alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" spacing="14.0" HBox.hgrow="ALWAYS" /> - <HBox fx:id="iconHbox" alignment="CENTER" spacing="14.0" /> + <HBox fx:id="iconHbox" alignment="CENTER" spacing="14.0"> + <children> + <Label fx:id="liveLabel" text="%main.label.live" textFill="RED"> + <font> + <Font size="26.0" /> + </font> + </Label> + </children></HBox> <HBox alignment="CENTER" spacing="7.0" HBox.hgrow="NEVER"> <children> <Label fx:id="volumeDownLabel"> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml index f9a87997e46bf5594b325dca016e74f3074f3557..97a767c4076cd823fb0e56c64fe24e18c1263580 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml @@ -13,7 +13,14 @@ <HBox fx:id="toolbarHBox" alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" prefHeight="28.0" prefWidth="586.0" spacing="14.0"> <children> <HBox fx:id="pageHBox" alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" spacing="14.0" HBox.hgrow="ALWAYS" /> - <HBox fx:id="iconHbox" alignment="CENTER" spacing="14.0" /> + <HBox fx:id="iconHbox" alignment="CENTER" spacing="14.0"> + <children> + <Label fx:id="liveLabel" text="%main.label.live" textFill="RED"> + <font> + <Font size="26.0" /> + </font> + </Label> + </children></HBox> <HBox alignment="CENTER" spacing="7.0" HBox.hgrow="NEVER"> <children> <Label fx:id="volumeDownLabel"> @@ -29,9 +36,15 @@ </Label> <MenuButton focusTraversable="false" mnemonicParsing="false" text="..."> <items> - <CheckMenuItem fx:id="fullScreenMenuItem" mnemonicParsing="false" onAction="#fullScreenMenuItemHandler" text="%main.menuitem.fullScreen" /> + <CheckMenuItem fx:id="fullScreenMenuItem" mnemonicParsing="false" onAction="#fullScreenMenuItemHandler" text="%main.menuitem.fullScreen"> + <accelerator> + <KeyCodeCombination alt="UP" code="F" control="UP" meta="UP" shift="DOWN" shortcut="DOWN" /> + </accelerator></CheckMenuItem> <CheckMenuItem fx:id="alwaysOnTopItem" mnemonicParsing="false" onAction="#alwaysOnTopItemHandler" text="%main.menuitem.onTop" /> - <MenuItem fx:id="closeMenuItem" mnemonicParsing="false" onAction="#closeMenuItemHandler" text="%main.menuitem.close" /> + <MenuItem fx:id="closeMenuItem" mnemonicParsing="false" onAction="#closeMenuItemHandler" text="%main.menuitem.close"> + <accelerator> + <KeyCodeCombination alt="UP" code="W" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> + </accelerator></MenuItem> </items> </MenuButton> </children> diff --git a/PlayWall/src/de/tobias/playpad/PlayPadMain.java b/PlayWall/src/de/tobias/playpad/PlayPadMain.java index 26fd6ff5df11b207e456dd1eafb9672c8112c95f..0439b37f31d78aa3c532ad960a0130d9afb00012 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadMain.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadMain.java @@ -11,9 +11,7 @@ import java.util.UUID; import org.dom4j.DocumentException; -import de.tobias.playpad.action.mapper.KeyboardMapperConnect; import de.tobias.playpad.action.mapper.MapperRegistry; -import de.tobias.playpad.action.mapper.MidiMapperConnect; import de.tobias.playpad.audio.ClipAudioHandler; import de.tobias.playpad.audio.JavaFXAudioHandler; import de.tobias.playpad.audio.TinyAudioHandler; @@ -198,8 +196,6 @@ public class PlayPadMain extends Application implements LocalizationDelegate, Pr DeviceRegistry.getFactoryInstance().registerDevice(PD12.NAME, PD12.class); // Mapper - MapperRegistry.registerMapperConnect(new MidiMapperConnect()); - MapperRegistry.registerMapperConnect(new KeyboardMapperConnect()); MapperRegistry.setOverviewViewController(new MapperOverviewViewController()); Profile.registerListener(this); diff --git a/PlayWall/src/de/tobias/playpad/components/Design.xml b/PlayWall/src/de/tobias/playpad/components/Design.xml index a47a17cb8ee7a993ed47c8cb33b0b64f5ba4a27e..0e8188e17752e3889f820bc8f0804dd9aebadb6f 100644 --- a/PlayWall/src/de/tobias/playpad/components/Design.xml +++ b/PlayWall/src/de/tobias/playpad/components/Design.xml @@ -1,4 +1,4 @@ <Actions> - <Component id="modern">de.tobias.playpad.design.modern.ModernDesignConnect</Component> + <Component id="modern" default="true">de.tobias.playpad.design.modern.ModernDesignConnect</Component> <Component id="classic">de.tobias.playpad.design.classic.ClassicDesignConnect</Component> </Actions> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java index 60ea0feffc329e9b28ca6717b2f198c573e4b2b5..c8e5b424d2df00e5dd0406b50ec23c8f59bd1973 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java @@ -49,6 +49,7 @@ import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; import javafx.scene.control.CheckMenuItem; +import javafx.scene.control.Label; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; @@ -77,6 +78,8 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML protected Menu extensionMenu; + @FXML protected Label liveLabel; + private IMainViewController mainViewController; private SettingsViewController settingsViewController; @@ -87,6 +90,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro toolbarHBox.prefWidthProperty().bind(toolbar.widthProperty().subtract(25)); toolbarHBox.prefHeightProperty().bind(toolbar.minHeightProperty()); + showLiveLabel(false); initLayoutMenu(); } @@ -152,12 +156,12 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro public void setLocked(boolean looked) { dndModeMenuItem.setDisable(looked); } - + @Override public void setAlwaysOnTopActive(boolean alwaysOnTopActive) { alwaysOnTopItem.setSelected(alwaysOnTopActive); } - + @Override public void setFullScreenActive(boolean fullScreenActive) { fullScreenMenuItem.setSelected(fullScreenActive); @@ -214,6 +218,19 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro public void deinit() { toolbarHBox.prefWidthProperty().unbind(); toolbarHBox.prefHeightProperty().unbind(); + + // Disable Drag Mode wenn aktiv und diese Toolbar deaktiviert wird. + if (dndModeMenuItem.isSelected()) { + PadDragListener.setDndMode(false); + for (IPadViewV2 view : mainViewController.getPadViews()) { + view.enableDragAndDropDesignMode(false); + } + } + } + + @Override + public void showLiveLabel(boolean show) { + liveLabel.setVisible(show); } @Override @@ -221,6 +238,24 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro return volumeSlider; } + private int currentPage = 0; + + @Override + public void hilightPageButton(int index) { + if (index >= 0) { + if (pageHBox.getChildren().size() > currentPage) { + Node removeNode = pageHBox.getChildren().get(currentPage); + removeNode.getStyleClass().remove(CURRENT_PAGE_BUTTON); + } + + if (pageHBox.getChildren().size() > index) { + Node newNode = pageHBox.getChildren().get(index); + newNode.getStyleClass().add(CURRENT_PAGE_BUTTON); + currentPage = index; + } + } + } + // EventHandler // Basic Event Handler @FXML diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java index 1b2b41b2ba29247494457506f853abc2804df48a..c976d00a5a9eaada1355a92d7809787806752d16 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java @@ -3,15 +3,10 @@ package de.tobias.playpad.layout.touch; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; -import de.tobias.playpad.project.Project; -import de.tobias.playpad.project.ProjectNotFoundException; -import de.tobias.playpad.project.ProjectReference; import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileNotFoundException; import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.view.main.MainLayoutConnect; import de.tobias.playpad.view.main.MenuType; -import de.tobias.playpad.viewcontroller.dialog.ImportDialog; import de.tobias.playpad.viewcontroller.main.BasicMenuToolbarViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.utils.util.Localization; @@ -20,6 +15,7 @@ import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.control.Button; import javafx.scene.control.CheckMenuItem; +import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.control.Slider; import javafx.scene.image.Image; @@ -30,6 +26,8 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll @FXML protected CheckMenuItem alwaysOnTopItem; @FXML protected MenuItem closeMenuItem; + @FXML protected Label liveLabel; + private IMainViewController mainViewController; public TouchMenuToolbarViewController(IMainViewController mainViewController) { @@ -38,6 +36,8 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll toolbarHBox.prefWidthProperty().bind(toolbar.widthProperty().subtract(25)); toolbarHBox.prefHeightProperty().bind(toolbar.minHeightProperty()); + + showLiveLabel(false); } @Override @@ -91,10 +91,12 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll } @Override - public void addMenuItem(MenuItem item, MenuType type) {} + public void addMenuItem(MenuItem item, MenuType type) { + } @Override - public void removeMenuItem(MenuItem item) {} + public void removeMenuItem(MenuItem item) { + } @Override public boolean isAlwaysOnTopActive() { @@ -112,6 +114,29 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll toolbarHBox.prefHeightProperty().unbind(); } + @Override + public void showLiveLabel(boolean show) { + liveLabel.setVisible(show); + } + + private int currentPage = 0; + + @Override + public void hilightPageButton(int index) { + if (index >= 0) { + if (pageHBox.getChildren().size() > currentPage) { + Node removeNode = pageHBox.getChildren().get(currentPage); + removeNode.getStyleClass().remove(CURRENT_PAGE_BUTTON); + } + + if (pageHBox.getChildren().size() > index) { + Node newNode = pageHBox.getChildren().get(index); + newNode.getStyleClass().add(CURRENT_PAGE_BUTTON); + currentPage = index; + } + } + } + @Override public Slider getVolumeSlider() { return volumeSlider; @@ -145,33 +170,6 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll Button button = (Button) event.getSource(); int page = (int) button.getUserData(); mainViewController.showPage(page); - } else if (event.getSource() instanceof MenuItem) { - // Zuletzt verwendete Projects - doAction(() -> - { - // TODO Rewrite mit openProject von BasicMenuToolbarViewController - MenuItem item = (MenuItem) event.getSource(); - ProjectReference ref = (ProjectReference) item.getUserData(); - try { - // Speichern das alte Project in mvc.setProject(Project) - Project project = Project.load(ref, true, ImportDialog.getInstance(mainViewController.getStage())); - PlayPadMain.getProgramInstance().openProject(project); - } catch (ProfileNotFoundException e) { - e.printStackTrace(); - mainViewController.showError( - Localization.getString(Strings.Error_Profile_NotFound, ref.getProfileReference(), e.getLocalizedMessage())); - - // Neues Profile wählen - Profile profile = ImportDialog.getInstance(mainViewController.getStage()).getUnkownProfile(); - ref.setProfileReference(profile.getRef()); - } catch (ProjectNotFoundException e) { - e.printStackTrace(); - mainViewController.showError(Localization.getString(Strings.Error_Project_NotFound, ref, e.getLocalizedMessage())); - } catch (Exception e) { - e.printStackTrace(); - mainViewController.showError(Localization.getString(Strings.Error_Project_Open, ref, e.getLocalizedMessage())); - } - }); } } diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java index 347a5e90ba24d4a72907a41c401315bf7ee71cd5..62f0c4279b8ea610af3f70ae2acb2b1799c7fbb3 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java @@ -1,17 +1,8 @@ package de.tobias.playpad.layout.touch; -import java.io.File; -import java.nio.file.Path; -import java.util.Set; - -import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.PadContentRegistry; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.TimeMode; -import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.pad.conntent.PadContentConnect; import de.tobias.playpad.pad.conntent.play.Durationable; import de.tobias.playpad.pad.listener.IPadPositionListener; import de.tobias.playpad.pad.listener.PadContentListener; @@ -21,31 +12,19 @@ import de.tobias.playpad.pad.listener.PadPositionListener; import de.tobias.playpad.pad.listener.PadStatusListener; import de.tobias.playpad.pad.view.IPadViewV2; import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; -import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileSettings; -import de.tobias.playpad.view.FileDragOptionView; -import de.tobias.playpad.viewcontroller.main.IMainViewController; -import de.tobias.playpad.viewcontroller.option.pad.PadSettingsViewController; import de.tobias.playpad.viewcontroller.pad.PadDragListener; -import de.tobias.utils.application.ApplicationUtils; -import de.tobias.utils.util.FileUtils; -import de.tobias.utils.util.Localization; import javafx.beans.value.ChangeListener; import javafx.event.Event; import javafx.event.EventHandler; -import javafx.scene.Node; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; -import javafx.stage.FileChooser; -import javafx.stage.FileChooser.ExtensionFilter; -import javafx.stage.Stage; import javafx.util.Duration; public class TouchPadViewController implements IPadViewControllerV2, EventHandler<Event> { protected static final String CURRENT_PAGE_BUTTON = "current-page-button"; - private static final String OPEN_FOLDER = "openFolder"; private static final String DURATION_FORMAT = "%d:%02d"; private TouchPadView padView; @@ -58,7 +37,6 @@ public class TouchPadViewController implements IPadViewControllerV2, EventHandle private IPadPositionListener padPositionListener; private PadDragListener padDragListener; - private transient PadSettingsViewController padSettingsViewController; public TouchPadViewController(TouchPadView padView) { this.padView = padView; @@ -69,7 +47,8 @@ public class TouchPadViewController implements IPadViewControllerV2, EventHandle padDurationListener = new PadDurationListener(this); padPositionListener = new PadPositionListener(this); - // Listener muss nur einmal hier hinzugefügt werden, weil bei einem neuen Profile, werden neue PadViewController erzeugt + // Listener muss nur einmal hier hinzugefügt werden, weil bei einem neuen Profile, werden neue PadViewController + // erzeugt ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); profileSettings.lockedProperty().addListener(padLockedListener); } @@ -156,41 +135,18 @@ public class TouchPadViewController implements IPadViewControllerV2, EventHandle if (event instanceof MouseEvent) { if (event.getEventType() == MouseEvent.MOUSE_CLICKED) { MouseEvent mouseEvent = (MouseEvent) event; - if (mouseEvent.getButton() == MouseButton.PRIMARY || mouseEvent.getButton() == MouseButton.SECONDARY) { - handleAction(mouseEvent.getButton() == MouseButton.PRIMARY, event); + if (mouseEvent.getButton() == MouseButton.PRIMARY) { + if (pad.getStatus() == PadStatus.PLAY) { + onStop(); + } else { + onPlay(); + } } } } } - /** - * Diese Methode handlet die Eingabe für Touch oder Mouse - * - * @param primaryAction - * <code>true</code> Touch einfacher Click, Mause Primary Button - * @param event - * event - */ - private void handleAction(boolean primaryAction, Event event) { - if (primaryAction) { - if (pad.getStatus() == PadStatus.EMPTY) { - try { - onNew(event); - } catch (NoSuchComponentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } else if (pad.getStatus() == PadStatus.PLAY) { - onStop(); - } else { - onPlay(); - } - } else { - onSettings(); - } - } - private void onPlay() { if (pad.getContent() != null) { pad.setStatus(PadStatus.PLAY); @@ -203,96 +159,6 @@ public class TouchPadViewController implements IPadViewControllerV2, EventHandle } } - private void onNew(Event event) throws NoSuchComponentException { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); - if (pad.getProject() != null) { - if (settings.isLiveMode() && settings.isLiveModeFile() && pad.getProject().getPlayedPlayers() > 0) { - PlayPadPlugin.getImplementation().getMainViewController().showLiveInfo(); - return; - } - } - - FileChooser chooser = new FileChooser(); - PadContentRegistry registry = PlayPadPlugin.getRegistryCollection().getPadContents(); - - // File Extension - ExtensionFilter extensionFilter = new ExtensionFilter(Localization.getString(Strings.File_Filter_Media), - registry.getSupportedFileTypes()); - chooser.getExtensionFilters().add(extensionFilter); - - // Last Folder - Object openFolder = ApplicationUtils.getApplication().getUserDefaults().getData(OPEN_FOLDER); - if (openFolder != null) { - File folder = new File(openFolder.toString()); - chooser.setInitialDirectory(folder); - } - - File file = chooser.showOpenDialog(((Node) event.getTarget()).getScene().getWindow()); - if (file != null) { - Path path = file.toPath(); - - Set<PadContentConnect> connects = registry.getPadContentConnectsForFile(file.toPath()); - if (!connects.isEmpty()) { - if (connects.size() > 1) { - FileDragOptionView hud = new FileDragOptionView(padView.getRootNode()); - hud.showDropOptions(connects, connect -> - { - if (connect != null) { - setNewPadContent(file, path, connect); - hud.hide(); - } - }); - } else { - PadContentConnect connect = connects.iterator().next(); - setNewPadContent(file, path, connect); - } - } - - ApplicationUtils.getApplication().getUserDefaults().setData(OPEN_FOLDER, path.getParent().toString()); - } - } - - private void setNewPadContent(File file, Path path, PadContentConnect connect) { - PadContent content = pad.getContent(); - if (pad.getContent() == null || !pad.getContent().getType().equals(connect.getType())) { - content = connect.newInstance(pad); - this.pad.setContent(content); - } - - try { - content.handlePath(file.toPath()); - } catch (NoSuchComponentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - this.pad.setName(FileUtils.getFilenameWithoutExtention(path.getFileName())); - } - - private void onSettings() { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); - IMainViewController mvc = PlayPadPlugin.getImplementation().getMainViewController(); - - if (mvc != null) { - if (pad.getProject() != null) { - if (settings.isLiveMode() && settings.isLiveModeSettings() && pad.getProject().getPlayedPlayers() > 0) { - mvc.showLiveInfo(); - return; - } - } - - Stage owner = mvc.getStage(); - if (padSettingsViewController == null) { - padSettingsViewController = new PadSettingsViewController(pad, owner); - padSettingsViewController.getStage().setOnHiding(ev -> - { - if (padView != null && pad != null) - padView.setTriggerLabelActive(pad.hasTriggerItems()); - }); - } - padSettingsViewController.getStage().show(); - } - } - @Override public void updateTimeLabel() { if (pad.getContent() != null && pad.getStatus() != PadStatus.EMPTY && pad.getStatus() != PadStatus.ERROR) { diff --git a/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java b/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java index 98522dabed70961ed87ff28c781cffbf6bd55dee..44f42324683bad635c2010489f06e375df27442f 100644 --- a/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java +++ b/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java @@ -5,10 +5,13 @@ import java.util.List; import java.util.Set; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.action.Action; import de.tobias.playpad.action.mapper.Mapper; -import de.tobias.playpad.action.mapper.MapperRegistry; +import de.tobias.playpad.action.mapper.MapperConnect; import de.tobias.playpad.action.mapper.MapperViewController; +import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.registry.Registry; import de.tobias.playpad.viewcontroller.IMapperOverviewViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; @@ -55,26 +58,34 @@ public class MapperOverviewViewController implements IMapperOverviewViewControll headline.setUnderline(true); root.getChildren().addAll(headline, mappingView, addMappingBox); - Set<String> types = MapperRegistry.getTypes(); + Registry<MapperConnect> registry = PlayPadPlugin.getRegistryCollection().getMappers(); + Set<String> types = registry.getTypes(); types.stream().sorted().forEach(item -> { - Button button = new Button(MapperRegistry.getMapperConnect(item).toString(), new FontIcon(FontAwesomeType.PLUS_CIRCLE)); + Button button = new Button(registry.toString(), new FontIcon(FontAwesomeType.PLUS_CIRCLE)); button.setContentDisplay(ContentDisplay.TOP); button.setPrefWidth(150); button.setOnAction(e -> { // Adds a mapper to the action - MapperViewController controller = onAddMapper(item); - controller.showInputMapperUI(); + try { + MapperViewController controller = onAddMapper(item); + controller.showInputMapperUI(); + } catch (NoSuchComponentException ex) { + // TODO Error Handling + ex.printStackTrace(); + } }); addMappingBox.getChildren().add(button); }); } - private MapperViewController onAddMapper(String type) { - Mapper mapper = MapperRegistry.getMapperConnect(type).createNewMapper(); + private MapperViewController onAddMapper(String type) throws NoSuchComponentException { + Registry<MapperConnect> registry = PlayPadPlugin.getRegistryCollection().getMappers(); + + Mapper mapper = registry.getComponent(type).createNewMapper(); action.addMapper(mapper); return addMapperView(type, mapper); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java index 9e8af0b13152ec470c582634ef86779a49f9dc57..266d71242453fc382be829491c89636934443182 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java @@ -58,5 +58,4 @@ public abstract class BasicMenuToolbarViewController extends MenuToolbarViewCont run.run(); } } - } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java index a41373ad735b06bdf11e5d6bc5bc15f00e64f604..7f9db22ccc2a1f674c6fe95d7aca2a1096d22bfa 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java @@ -113,7 +113,8 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon Profile.registerListener(this); reloadSettings(null, Profile.currentProfile()); - // Wenn sich die Toolbar ändert werden die Button neu erstellt. Das ist hier, weil es nur einmal als Listener da sein muss. Die + // Wenn sich die Toolbar ändert werden die Button neu erstellt. Das ist hier, weil es nur einmal als Listener da + // sein muss. Die // Methode wird aber an unterschiedlichen stellen mehrmals aufgerufen performLayoutDependendAction(() -> { @@ -183,7 +184,6 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon public void setMainLayout(MainLayoutConnect mainLayoutConnect) { this.mainLayout = mainLayoutConnect; initMainLayout(); - layoutChangedListener.handle(layoutActions); } private void initMainLayout() { @@ -205,6 +205,7 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon this.menuToolbarViewController = newMenuToolbarViewController; + layoutChangedListener.handle(layoutActions); createPadViews(); showPage(currentPageShowing); @@ -461,6 +462,10 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon // New addPadsToView(); } + + if (menuToolbarViewController != null) { + menuToolbarViewController.hilightPageButton(page); + } } @Override @@ -478,9 +483,29 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon } } + private boolean shown = false; + @Override public void showLiveInfo() { - // TODO Auto-generated method stub + if (!shown) { + if (menuToolbarViewController != null) { + menuToolbarViewController.showLiveLabel(true); + shown = true; + Worker.runLater(() -> + { + try { + Thread.sleep(PlayPadMain.displayTimeMillis * 2); + } catch (Exception e) { + } + Platform.runLater(() -> + { + if (menuToolbarViewController != null) + menuToolbarViewController.showLiveLabel(false); + shown = false; + }); + }); + } + } } diff --git a/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperRegistry.java b/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperRegistry.java index 7d25d2907118eabbf3da5f17fbde05846e119755..ea795f46ebab8df397805d40be37c6a54a737ca2 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperRegistry.java +++ b/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperRegistry.java @@ -1,36 +1,11 @@ package de.tobias.playpad.action.mapper; -import java.util.HashMap; -import java.util.Set; - import de.tobias.playpad.viewcontroller.IMapperOverviewViewController; @Deprecated public class MapperRegistry { - private static HashMap<String, MapperConnect> mappers; - - static { - mappers = new HashMap<>(); - } - - public static void registerMapperConnect(MapperConnect connect) { - mappers.put(connect.getType(), connect); - } - - public static MapperConnect getMapperConnect(String type) { - if (mappers.containsKey(type)) { - return mappers.get(type); - } else { - throw new IllegalArgumentException("Tpye of MapperConnect does not exists: " + type); - } - } - - public static Set<String> getTypes() { - return mappers.keySet(); - } - - //TODO New Implementation + // TODO New Implementation private static IMapperOverviewViewController controllerInstance; public static void setOverviewViewController(IMapperOverviewViewController controller) { diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java index 72863a94a62a86bd8e1f324ad77a6f2bb8f1d859..61a34d54610ff01c55258e832052eb268cf59d86 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java @@ -20,6 +20,8 @@ import javafx.scene.image.Image; */ public abstract class MenuToolbarViewController extends ContentViewController { + protected static final String CURRENT_PAGE_BUTTON = "current-page-button"; + /** * Erstellt einen neuen ViewController ohne Localization * @@ -148,4 +150,8 @@ public abstract class MenuToolbarViewController extends ContentViewController { public abstract void setAlwaysOnTopActive(boolean alwaysOnTopActive); public abstract void setFullScreenActive(boolean fullScreenActive); + + public abstract void showLiveLabel(boolean show); + + public abstract void hilightPageButton(int index); }