Commit 3a464396 authored by Constantin Jucovschi's avatar Constantin Jucovschi
Browse files

updates

parent c8af7d06
package info.kwarc.sally4.framing.factory;
import info.kwarc.sally4.components.TemplatingComponent;
import info.kwarc.sally4.docmanager.CallbackManager;
import info.kwarc.sally4.framing.impl.SallyFrameMenuImpl;
import info.kwarc.sally4.framing.impl.SallyFrameMenuImpl.MenuListWindow;
import info.kwarc.sally4.registration.SallyClient;
import info.kwarc.sally4.servlet.SallyServlet;
import info.kwarc.sally4.servlet.impl.ServletController;
import info.kwarc.sally4.util.InstanceCreator;
import java.util.HashMap;
......@@ -39,6 +39,8 @@ public class SallyFrameMenuFactory extends RouteBuilder {
@Requires
CallbackManager callbacks;
ServletController sc;
@Requires(filter="(factory.name="+SallyFrameMenuImpl.factoryid+")")
Factory sallyFrameMenuFactory;
......@@ -52,8 +54,8 @@ public class SallyFrameMenuFactory extends RouteBuilder {
void start() throws Exception {
CamelContext context = new DefaultCamelContext();
context.addComponent("sallyservlet", servlet.getCamelComponent());
context.addComponent("freemarker", new TemplatingComponent("templates/", getClass().getClassLoader()));
// context.addComponent("freemarker", new FreemarkerComponent());
sc = servlet.init(context, getClass().getClassLoader())
.initTemplating("templates");
context.addRoutes(this);
context.start();
}
......@@ -96,8 +98,7 @@ public class SallyFrameMenuFactory extends RouteBuilder {
public void configure() throws Exception {
from("sallyservlet://"+menuPath)
.bean(method(this, "processRequest"))
.to("freemarker:frames_menu.html");
// .to("freemarker:file:///home/cjucovschi/sally4/office-base/src/main/resources/templates/frames_menu.html");
.to(sc.tpl("frames_menu.html"));
}
......
......@@ -7,7 +7,26 @@ import java.util.ArrayList;
public class MenuItemAcceptor {
ArrayList<SallyMenuItem> items = new ArrayList<SallyMenuItem>();
void addItem(SallyMenuItem item) {
Integer posX;
Integer posY;
public MenuItemAcceptor() {
}
public Integer getPosX() {
return posX;
}
public Integer getPosY() {
return posY;
}
public void setPosX(Integer posX) {
this.posX = posX;
}
public void setPosY(Integer posY) {
this.posY = posY;
}
public void addItem(SallyMenuItem item) {
items.add(item);
}
......
package info.kwarc.sally4.framing.impl;
import info.kwarc.sally.comm.frames.ExecDocLevelService;
import info.kwarc.sally.comm.frames.ExecuteFrameRequest;
import info.kwarc.sally.comm.frames.GetSallyFramesRequest;
import info.kwarc.sally.comm.frames.GetSallyFramesResponse;
import info.kwarc.sally.comm.frames.GetSallyFramesResponse.SallyFrameMenuItem;
import info.kwarc.sally.comm.frames.RemoveDocLevelService;
import info.kwarc.sally.comm.frames.ShowSallyFrameMenu;
import info.kwarc.sally4.docmanager.CallbackManager;
......@@ -17,6 +21,7 @@ import info.kwarc.sally4.theo.Theo;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.camel.impl.DefaultExchange;
import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Invalidate;
import org.apache.felix.ipojo.annotations.Provides;
......@@ -88,10 +93,38 @@ public class SallyFrameMenuImpl implements SallyFrameMenu {
return;
}
}
@Subscribe public void onShowSallyFrame (GetSallyFramesRequest request, DefaultExchange e) {
MenuItemAcceptor acceptor = new MenuItemAcceptor();
acceptor.setPosX(request.getPosx());
acceptor.setPosY(request.getPosy());
log.info("Getting frames at "+request.getPosx()+ " "+request.getPosy());
context.post(acceptor, request);
GetSallyFramesResponse response = new GetSallyFramesResponse();
for (SallyMenuItem item : acceptor.getItems()) {
SallyFrameMenuItem it = new SallyFrameMenuItem ();
it.setFrame(item.getFrame());
it.setName(item.getName());
it.setItemid(callbackManager.registerCallback(item));
response.getSallyFrameMenuItem().add(it);
}
log.info("Sending Get frames with "+response.getSallyFrameMenuItem().size()+ " items");
e.getIn().setBody(response);
}
@Subscribe public void onExecuteSallyFrame(ExecuteFrameRequest request) {
SallyMenuItem menuItem = callbackManager.get(request.getFrameid(), SallyMenuItem.class);
if (menuItem != null)
menuItem.run();
}
@Subscribe public void onShowSallyFrame (ShowSallyFrameMenu request) {
MenuItemAcceptor acceptor = new MenuItemAcceptor();
acceptor.setPosX(request.getPosx());
acceptor.setPosY(request.getPosy());
log.info("Showing frames ");
context.post(acceptor, request);
MenuListWindow menuInfo = new MenuListWindow();
menuInfo.items = acceptor.getItems();
......
......@@ -153,11 +153,13 @@ public class SallyClientImpl extends RouteBuilder implements SallyClient {
/**
*
*/
from(fromAlex+"?disableReplyTo=true")
from(fromAlex)
.to("log:SallyDocImpl?showHeaders=true")
.convertBodyTo(String.class)
.process(unMarshalMessage)
.process(triggerOnMessageHandlers);
.process(triggerOnMessageHandlers)
.process(marshalMessage)
.to("log:SallyDocImplBack?showHeaders=true");
from("direct:sendAlexInOut")
.process(marshalMessage)
......
<HTML>
<head>
<script type="text/javascript" src="/sally/jobad/libs/js/libs.js"></script>
<script type="text/javascript" src="/sally/static/jquery.js"></script>
<script type="text/javascript" src="/sally/static/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="/sally/static/bootstrap/css/bootstrap.min.css">
<script src="http://listjs.com/no-cdn/list.js"></script>
<link rel="stylesheet" type="text/css"
href="/sally/jobad/libs/css/libs.css">
<style type="text/css">
li {
list-style:none;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment