Skip to content
Snippets Groups Projects
Commit b09d7e7d authored by srosse's avatar srosse
Browse files

OO-59: ReusableURLHelper method moved in Window

parent 96d4a673
No related branches found
No related tags found
No related merge requests found
......@@ -70,7 +70,6 @@ import org.olat.core.gui.render.ValidationResult;
import org.olat.core.gui.render.intercept.InterceptHandler;
import org.olat.core.gui.render.intercept.InterceptHandlerInstance;
import org.olat.core.gui.themes.Theme;
import org.olat.core.gui.util.ReusableURLHelper;
import org.olat.core.helpers.Settings;
import org.olat.core.id.context.BusinessControl;
import org.olat.core.id.context.BusinessControlFactory;
......@@ -1126,7 +1125,7 @@ public class Window extends Container {
target = cur;
} else {
String childName = res[0]; // Pre: all paths have at least one entry
List<Component> founds = ReusableURLHelper.findComponentsWithChildName(childName, getContentPane());
List<Component> founds = findComponentsWithChildName(childName, getContentPane());
int foundsCnt = founds.size();
if (foundsCnt == 1) {
// unique -> high probability that the recorded link is still the same
......@@ -1226,6 +1225,22 @@ public class Window extends Container {
}
return toDispatch;
}
private List<Component> findComponentsWithChildName(final String childName, Component searchRoot) {
final List<Component> founds = new ArrayList<Component>();
ComponentTraverser ct = new ComponentTraverser(new ComponentVisitor(){
public boolean visit(Component comp, UserRequest ureq) {
if(comp.getParent()==null){
return true;
}
if (comp.getParent().getComponent(childName) == comp) {
founds.add(comp);
}
return true;
}}, searchRoot, true);
ct.visitAll(null);
return founds;
}
/**
......
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <hr>
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* This file has been modified by the OpenOLAT community. Changes are licensed
* under the Apache 2.0 license as the original file.
* <p>
*/
package org.olat.core.gui.util;
import java.util.ArrayList;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.util.component.ComponentTraverser;
import org.olat.core.util.component.ComponentVisitor;
/**
* @author Felix Jost, http://www.goodsolutions.ch
*
*/
public class ReusableURLHelper {
/**
* Used only for load-test-mode identification of the correct component when the full path matching failed.
* @param childName
* @param searchRoot
* @return a List of Components which are added in parent using the name childName, that is, where something like container.put(childName,...) has taken place
*/
public static List<Component> findComponentsWithChildName(final String childName, Component searchRoot) {
final List<Component> founds = new ArrayList<Component>();
ComponentTraverser ct = new ComponentTraverser(new ComponentVisitor(){
public boolean visit(Component comp, UserRequest ureq) {
if(comp.getParent()==null){
return true;
}
if (comp.getParent().getComponent(childName) == comp) {
founds.add(comp);
}
return true;
}}, searchRoot, true);
ct.visitAll(null);
return founds;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment