本文整理汇总了Java中org.osgi.service.event.Event.getPropertyNames方法的典型用法代码示例。如果您正苦于以下问题:Java Event.getPropertyNames方法的具体用法?Java Event.getPropertyNames怎么用?Java Event.getPropertyNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.service.event.Event
的用法示例。
在下文中一共展示了Event.getPropertyNames方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleEvent
import org.osgi.service.event.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event event) {
String[] propertyNames = event.getPropertyNames();
//System.out.println(event.getProperty(propertyNames[0]));
IStyledTextGazeResponse response = (IStyledTextGazeResponse)event.getProperty(propertyNames[0]);
Rectangle mBounds = ITrace.getDefault().getRootShell().getBounds();
int screenX = (int) (response.getGaze().getX() * mBounds.width);
int screenY = (int) (response.getGaze().getY() * mBounds.height);
//Rectangle monitorBounds = ITrace.getDefault().monitorBounds;
if(styledText.isDisposed()) return;
Rectangle editorBounds = styledText.getBounds();
Point screenPos = styledText.toDisplay(0, 0);
editorBounds.x = screenPos.x - mBounds.x;
editorBounds.y = screenPos.y - mBounds.y;
if(editorBounds.contains(screenX, screenY)){
int relativeX = screenX-editorBounds.x;
int relativeY = screenY-editorBounds.y;
update(response.getLine()-1,response.getCol(), relativeX, relativeY);
}
}
示例2: sendEvent
import org.osgi.service.event.Event; //导入方法依赖的package包/类
private void sendEvent(Event osgiEvent) {
boolean trace = log.isTraceEnabled();
ServiceReference ref = bundleContext.getServiceReference(EVENT_ADMIN);
if (ref != null) {
EventAdmin eventAdmin = (EventAdmin) bundleContext.getService(ref);
if (eventAdmin != null) {
if (trace) {
StringBuilder sb = new StringBuilder();
String[] names = osgiEvent.getPropertyNames();
sb.append("{");
for (int i = 0; i < names.length; i++) {
String name = names[i];
sb.append(name);
sb.append("=");
Object value = osgiEvent.getProperty(name);
sb.append(ObjectUtils.getDisplayString(value));
if (i < names.length - 1)
sb.append(",");
}
sb.append("}");
log.trace("Broadcasting OSGi event " + osgiEvent + " w/ props " + sb.toString());
}
publisher.publish(eventAdmin, osgiEvent);
}
} else {
log.trace("No event admin found for broadcasting event " + osgiEvent);
}
}
示例3: handleEvent
import org.osgi.service.event.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event event) {
if(outFile == null) this.init();
String[] propertyNames = event.getPropertyNames();
IGazeResponse response = (IGazeResponse)event.getProperty(propertyNames[0]);
this.process(response);
}
示例4: handleEvent
import org.osgi.service.event.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event event) {
String[] propertyNames = event.getPropertyNames();
Gaze gaze = (Gaze)event.getProperty(propertyNames[0]);
Point leftEye = new Point((int)(gaze.getLeftX() * (screenSize.width/4)),(int)(gaze.getLeftY() * (screenSize.height/4)));
Point rightEye = new Point((int)(gaze.getRightX() * (screenSize.width/4)),(int)(gaze.getRightY() * (screenSize.height/4)));
drawingPanel.update(leftEye, rightEye, gaze.getLeftValidity(), gaze.getRightValidity());
}
示例5: handleEvent
import org.osgi.service.event.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event event) {
if(event.getTopic() == "iTrace/newgaze"){
String[] propertyNames = event.getPropertyNames();
Gaze g = (Gaze)event.getProperty(propertyNames[0]);
if (g != null) {
if(!rootShell.isDisposed()){
Rectangle monitorBounds = rootShell.getMonitor().getBounds();
int screenX = (int) (g.getX() * monitorBounds.width);
int screenY = (int) (g.getY() * monitorBounds.height);
IGazeResponse response;
response = handleGaze(screenX, screenY, g);
if (response != null) {
if(recording){
statusLineManager
.setMessage(String.valueOf(response.getGaze().getSessionTime()));
registerTime = System.currentTimeMillis();
if(xmlOutput) eventBroker.post("iTrace/xmlOutput", response);
if(jsonOutput) eventBroker.post("iTrace/jsonOutput", response);
}
if(response instanceof IStyledTextGazeResponse && response != null && showTokenHighlights){
IStyledTextGazeResponse styledTextResponse = (IStyledTextGazeResponse)response;
eventBroker.post("iTrace/newstresponse", styledTextResponse);
}
}
}else{
if((System.currentTimeMillis()-registerTime) > 2000){
statusLineManager.setMessage("");
}
}
}
}
}
示例6: toMap
import org.osgi.service.event.Event; //导入方法依赖的package包/类
Map<String, ?> toMap(Event event) {
Map<String, Object> props = new HashMap<>();
props.put("topic", event.getTopic());
for (String key : event.getPropertyNames()) {
props.put(key, event.getProperty(key));
}
return props;
}
示例7: handleEvent
import org.osgi.service.event.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event event) {
// construct server sent event
JsonObject data = new JsonObject();
for(String key : event.getPropertyNames()){
if(!key.equals("event.topics"))
data.add(key, new JsonPrimitive(event.getProperty(key).toString()));
}
if(event.getTopic().contains("progress")){
// progress
data.add("type", new JsonPrimitive("progress"));
} else {
data.add("type", new JsonPrimitive("notification"));
}
StringBuilder builder = new StringBuilder();
builder.append("data: ").append(data.toString()).append("\n\n");
String sse = builder.toString();
// send to all clients
Iterator<Entry<String,AsyncContext>> it = clients.entrySet().iterator();
while(it.hasNext()){
AsyncContext client = it.next().getValue();
try {
PrintWriter writer = client.getResponse().getWriter();
writer.write(sse);
writer.flush();
} catch(Exception e){
it.remove();
}
}
}
示例8: handleEvent
import org.osgi.service.event.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event event) {
String[] propertyNames = event.getPropertyNames();
String message = (String)event.getProperty(propertyNames[0]);
displayError(message);
}