本文整理匯總了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);
}