Add ViewService interface

- Service interface with holds access to modal
  methods. To get used by views which i.e.
  want to show modal dialogs.
- Relates #825
This commit is contained in:
Janne Valkealahti
2023-08-21 09:01:37 +03:00
parent 55096a5d77
commit 50806589bc
2 changed files with 48 additions and 0 deletions

View File

@@ -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<Integer, KeyBindingValue> keyBindings = new HashMap<>();
private Map<Integer, KeyBindingValue> hotKeyBindings = new HashMap<>();
private Map<Integer, MouseBindingValue> 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);
}

View File

@@ -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);
}