mirror of
https://github.com/theonedev/onedev.git
synced 2025-12-08 18:26:30 +00:00
Refactor EmphasizeAwareLabel as HighlightableLabel
This commit is contained in:
parent
919c929aba
commit
db17dfff7e
@ -9,7 +9,7 @@ import org.apache.wicket.request.resource.ResourceReference;
|
||||
import com.gitplex.commons.lang.extractors.TokenPosition;
|
||||
import com.gitplex.commons.lang.extractors.java.icons.Icons;
|
||||
import com.gitplex.commons.util.Range;
|
||||
import com.gitplex.commons.wicket.component.EmphasizeAwareLabel;
|
||||
import com.gitplex.commons.wicket.component.HighlightableLabel;
|
||||
|
||||
public class CompilationUnit extends JavaSymbol {
|
||||
|
||||
@ -34,7 +34,7 @@ public class CompilationUnit extends JavaSymbol {
|
||||
|
||||
@Override
|
||||
public Component render(String componentId, Range matchRange) {
|
||||
return new EmphasizeAwareLabel(componentId, packageName, matchRange);
|
||||
return new HighlightableLabel(componentId, packageName, matchRange);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -4,7 +4,7 @@ import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
|
||||
import com.gitplex.commons.util.Range;
|
||||
import com.gitplex.commons.wicket.component.EmphasizeAwareLabel;
|
||||
import com.gitplex.commons.wicket.component.HighlightableLabel;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FieldDefPanel extends Panel {
|
||||
@ -23,7 +23,7 @@ public class FieldDefPanel extends Panel {
|
||||
protected void onInitialize() {
|
||||
super.onInitialize();
|
||||
|
||||
add(new EmphasizeAwareLabel("name", fieldDef.getName(), matchRange));
|
||||
add(new HighlightableLabel("name", fieldDef.getName(), matchRange));
|
||||
|
||||
add(new Label("type", fieldDef.getType()).setVisible(fieldDef.getType()!=null));
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
|
||||
import com.gitplex.commons.util.Range;
|
||||
import com.gitplex.commons.wicket.component.EmphasizeAwareLabel;
|
||||
import com.gitplex.commons.wicket.component.HighlightableLabel;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class MethodDefPanel extends Panel {
|
||||
@ -23,7 +23,7 @@ public class MethodDefPanel extends Panel {
|
||||
protected void onInitialize() {
|
||||
super.onInitialize();
|
||||
|
||||
add(new EmphasizeAwareLabel("name", methodDef.getName(), matchRange));
|
||||
add(new HighlightableLabel("name", methodDef.getName(), matchRange));
|
||||
add(new Label("params", methodDef.getParams()));
|
||||
add(new Label("type", methodDef.getType()).setVisible(methodDef.getType()!=null));
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ import com.gitplex.commons.lang.extractors.Symbol;
|
||||
import com.gitplex.commons.lang.extractors.TokenPosition;
|
||||
import com.gitplex.commons.lang.extractors.java.icons.Icons;
|
||||
import com.gitplex.commons.util.Range;
|
||||
import com.gitplex.commons.wicket.component.EmphasizeAwareLabel;
|
||||
import com.gitplex.commons.wicket.component.HighlightableLabel;
|
||||
|
||||
public class TypeDef extends JavaSymbol {
|
||||
|
||||
@ -45,7 +45,7 @@ public class TypeDef extends JavaSymbol {
|
||||
|
||||
@Override
|
||||
public Component render(String componentId, Range matchRange) {
|
||||
return new EmphasizeAwareLabel(componentId, getName(), matchRange);
|
||||
return new HighlightableLabel(componentId, getName(), matchRange);
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -9,18 +9,18 @@ import com.gitplex.commons.util.Range;
|
||||
import com.gitplex.commons.util.StringUtils;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class EmphasizeAwareLabel extends Label {
|
||||
public class HighlightableLabel extends Label {
|
||||
|
||||
public EmphasizeAwareLabel(String id, @Nullable String label, @Nullable Range emphasize) {
|
||||
public HighlightableLabel(String id, @Nullable String label, @Nullable Range highlight) {
|
||||
super(id, new LoadableDetachableModel<String>() {
|
||||
|
||||
@Override
|
||||
protected String load() {
|
||||
if (label != null) {
|
||||
if (emphasize != null) {
|
||||
String prefix = label.substring(0, emphasize.getFrom());
|
||||
String middle = label.substring(emphasize.getFrom(), emphasize.getTo());
|
||||
String suffix = label.substring(emphasize.getTo());
|
||||
if (highlight != null) {
|
||||
String prefix = label.substring(0, highlight.getFrom());
|
||||
String middle = label.substring(highlight.getFrom(), highlight.getTo());
|
||||
String suffix = label.substring(highlight.getTo());
|
||||
return StringUtils.escapeHtml(prefix)
|
||||
+ "<b>"
|
||||
+ StringUtils.escapeHtml(middle)
|
||||
@ -8,7 +8,7 @@ import org.apache.wicket.request.resource.PackageResourceReference;
|
||||
import org.apache.wicket.request.resource.ResourceReference;
|
||||
|
||||
import com.gitplex.commons.util.Range;
|
||||
import com.gitplex.commons.wicket.component.EmphasizeAwareLabel;
|
||||
import com.gitplex.commons.wicket.component.HighlightableLabel;
|
||||
|
||||
public class FileHit extends QueryHit {
|
||||
|
||||
@ -32,7 +32,7 @@ public class FileHit extends QueryHit {
|
||||
if (fileName.contains("/"))
|
||||
fileName = StringUtils.substringAfterLast(fileName, "/");
|
||||
|
||||
return new EmphasizeAwareLabel(componentId, fileName, matchRange);
|
||||
return new HighlightableLabel(componentId, fileName, matchRange);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -7,7 +7,7 @@ import org.apache.wicket.request.resource.ResourceReference;
|
||||
|
||||
import com.gitplex.commons.lang.extractors.TokenPosition;
|
||||
import com.gitplex.commons.util.Range;
|
||||
import com.gitplex.commons.wicket.component.EmphasizeAwareLabel;
|
||||
import com.gitplex.commons.wicket.component.HighlightableLabel;
|
||||
|
||||
public class TextHit extends QueryHit {
|
||||
|
||||
@ -38,7 +38,7 @@ public class TextHit extends QueryHit {
|
||||
|
||||
@Override
|
||||
public Component render(String componentId) {
|
||||
return new EmphasizeAwareLabel(componentId, lineContent, getTokenPos().getRange());
|
||||
return new HighlightableLabel(componentId, lineContent, getTokenPos().getRange());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -33,7 +33,7 @@ import com.gitplex.server.search.hit.TextHit;
|
||||
import com.gitplex.server.web.component.depotfile.blobview.BlobViewContext;
|
||||
import com.gitplex.server.web.page.depot.file.DepotFilePage;
|
||||
import com.gitplex.commons.git.BlobIdent;
|
||||
import com.gitplex.commons.wicket.component.EmphasizeAwareLabel;
|
||||
import com.gitplex.commons.wicket.component.HighlightableLabel;
|
||||
import com.gitplex.commons.wicket.component.PreventDefaultAjaxLink;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@ -400,7 +400,7 @@ public abstract class SearchResultPanel extends Panel {
|
||||
super.onInitialize();
|
||||
|
||||
String blobPath = blobItem.getModelObject().getBlobPath();
|
||||
add(new EmphasizeAwareLabel("label", blobPath, blobItem.getModelObject().getMatchRange()));
|
||||
add(new HighlightableLabel("label", blobPath, blobItem.getModelObject().getMatchRange()));
|
||||
|
||||
if (activeBlobIndex == blobItem.getIndex() && activeHitIndex == -1)
|
||||
add(AttributeAppender.append("class", " active"));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user