xworker.swt.xwidgets.ActionStackTraceText Maven / Gradle / Ivy
package xworker.swt.xwidgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Event;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.World;
import xworker.util.XWorkerUtils;
public class ActionStackTraceText {
public static Object create(ActionContext actionContext){
Thing self = (Thing) actionContext.get("self");
ActionContext ac = new ActionContext();
ac.put("parent", actionContext.get("parent"));
Thing thing = World.getInstance().getThing("xworker.swt.xwidgets.prototypes.ActionStackTraceTextShell/@text");
Object obj = thing.doAction("create", ac);
actionContext.peek().put("parent", obj);
for(Thing child : self.getChilds()){
child.doAction("create", actionContext);
}
actionContext.getScope(0).put(self.getMetadata().getName(), ac.get("actions"));
return obj;
}
public static void setStackTrace(ActionContext actionContext){
StyledText text = (StyledText) actionContext.get("text");
text.setText("");
String stackTrace = (String) actionContext.get("stackTrace");
if(stackTrace == null){
return;
}
for(String line : stackTrace.split("[\n]")){
String l = line.trim();
if(l.startsWith("caller:")){
String ls[] = l.split("[,]");
String ls1[] = ls[0].split("[:]");
if(ls1.length == 3){
text.append("\t");
text.append(ls1[0] + ":");
text.append(ls1[1] + ":");
Thing thing = World.getInstance().getThing(ls1[2].trim());
if(thing != null){
int start = text.getText().length();
String link = thing.getMetadata().getPath();
text.append(link);
Color colorBlue = text.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE );
StyleRange range = new StyleRange(start, link.length(), colorBlue, null);
range.underline = true;
range.data = thing;
text.setStyleRange(range);
}else{
text.append(ls1[2]);
}
for(int i=1;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy