diff --git a/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/AbstractView.java b/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/AbstractView.java index 262f7bd4..ed77f5c6 100644 --- a/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/AbstractView.java +++ b/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/AbstractView.java @@ -54,6 +54,7 @@ public abstract class AbstractView extends AbstractControl implements View { private boolean hasFocus; private int layer; private EventLoop eventLoop; + private ViewService viewService; private Map keyBindings = new HashMap<>(); private Map hotKeyBindings = new HashMap<>(); private Map mouseBindings = new HashMap<>(); @@ -238,6 +239,24 @@ public abstract class AbstractView extends AbstractControl implements View { return eventLoop; } + /** + * Set a {@link ViewService} + * + * @param viewService the view service + */ + public void setViewService(ViewService viewService) { + this.viewService = viewService; + } + + /** + * Get a {@link ViewService} + * + * @return view service + */ + protected ViewService getViewService() { + return viewService; + } + protected void registerKeyBinding(Integer keyType, String keyCommand) { registerKeyBinding(keyType, keyCommand, null, null); } diff --git a/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/ViewService.java b/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/ViewService.java new file mode 100644 index 00000000..406bb963 --- /dev/null +++ b/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/ViewService.java @@ -0,0 +1,29 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.shell.component.view.control; + +/** + * Provides services for a {@link View} like handling modals. + * + * @author Janne Valkealahti + */ +public interface ViewService { + + View getModal(); + + void setModal(View view); + +}