com.exadel.aem.toolkit.plugin.handlers.placement.PlacementHelper Maven / Gradle / Ivy
/*
* 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
*
* http://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 com.exadel.aem.toolkit.plugin.handlers.placement;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import com.exadel.aem.toolkit.api.annotations.layouts.Place;
import com.exadel.aem.toolkit.api.handlers.Source;
import com.exadel.aem.toolkit.api.handlers.Target;
import com.exadel.aem.toolkit.plugin.adapters.AdaptationBase;
import com.exadel.aem.toolkit.plugin.adapters.PlaceSetting;
import com.exadel.aem.toolkit.plugin.handlers.Handlers;
import com.exadel.aem.toolkit.plugin.handlers.placement.registries.MembersRegistry;
import com.exadel.aem.toolkit.plugin.handlers.placement.registries.SectionsRegistry;
import com.exadel.aem.toolkit.plugin.handlers.placement.sections.Section;
import com.exadel.aem.toolkit.plugin.utils.DialogConstants;
import com.exadel.aem.toolkit.plugin.utils.NamingUtil;
import com.exadel.aem.toolkit.plugin.utils.ordering.OrderingUtil;
/**
* Helper object for distributing class member-bound widgets into container sections, such as {@code Tab}s
* or {@code AccordionPanel}s, that are defined in the processed Java class or any of its superclasses
*/
public class PlacementHelper {
private Source source;
private Target container;
private SectionsRegistry sections;
private MembersRegistry members;
/**
* Default (instantiation-preventing) constructor
*/
private PlacementHelper() {
}
/* ----------------------
Public placement logic
---------------------- */
/**
* Attempts to place as many as possible available members to the sections of the container provided
*/
public void doPlacement() {
if (sections != null && !sections.getAvailable().isEmpty()) {
doMultiSectionPlacement();
} else {
doSimplePlacement();
}
}
/**
* Called by {@link PlacementHelper#doPlacement()} to process multi-section installations
*/
private void doMultiSectionPlacement() {
Iterator sectionIterator = sections.getAvailable().iterator();
int iterationStep = 0;
while (sectionIterator.hasNext()) {
final boolean isFirstSection = iterationStep++ == 0;
Section currentSection = sectionIterator.next();
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy