示例#1
0
  private void generateGcodeProgram() {

    LOG.debug("generateGcodeProgram:");

    gcodeProgram.clear();

    gcodeProgram.appendLine("(Macro for " + getTitle() + ")");
    gcodeProgram.appendLine("(generated " + getTimestamp() + ")");
    gcodeProgram.appendLine("G21");
    gcodeProgram.appendLine("G90");

    generateGcodeCore(gcodeProgram);

    if (gcodeGenerationError) {

      clear();

    } else {

      gcodeProgram.appendLine(
          "G0 Z"
              + String.format(
                  IConstant.FORMAT_COORDINATE, getDoublePreference(IPreferenceKey.Z_CLEARANCE)));
      gcodeProgram.appendLine("M5");

      gcodeProgram.parse();

      Text gcodeText = (Text) context.get(IConstant.MACRO_TEXT_ID);
      if (gcodeText != null) toolbox.gcodeToText(gcodeText, gcodeProgram);
    }

    eventBroker.send(IEvent.GCODE_MACRO_GENERATED, null);
    eventBroker.send(IEvent.REDRAW, null);
  }
 @PreDestroy
 void preDestroy() {
   constructed = false;
   eventBroker.unsubscribe(selectedHandler);
   eventBroker.unsubscribe(minimizedPartHandler);
   partActivationHistory.clear();
 }
 @PreDestroy
 public void contextDisposed() {
   eventBroker.unsubscribe(itemUpdater);
   eventBroker.unsubscribe(selectionUpdater);
   eventBroker.unsubscribe(enabledUpdater);
   eventBroker.unsubscribe(toBeRenderedUpdater);
   eventBroker.unsubscribe(childAdditionUpdater);
 }
 @PreDestroy
 void contextDisposed() {
   if (eventBroker == null) return;
   eventBroker.unsubscribe(toBeRenderedHandler);
   eventBroker.unsubscribe(visibilityHandler);
   eventBroker.unsubscribe(childrenHandler);
   eventBroker.unsubscribe(trimHandler);
 }
  @PostConstruct
  void init() {
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, childrenHandler);
    eventBroker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED, toBeRenderedHandler);
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, selectionHandler);
    eventBroker.subscribe(UIEvents.UILabel.TOPIC_ALL, labelHandler);

    setPropertyChangeListener();
  }
 @PostConstruct
 void postConstruct() {
   eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, selectedHandler);
   eventBroker.subscribe(UIEvents.ApplicationElement.TOPIC_TAGS, minimizedPartHandler);
   constructed = true;
   partActivationHistory = new PartActivationHistory(this, modelService);
   if (activePart != null) {
     partActivationHistory.prepend(activePart);
   }
 }
  @PostConstruct
  public void init() {
    eventBroker.subscribe(UIEvents.UILabel.TOPIC_ALL, itemUpdater);
    eventBroker.subscribe(UIEvents.Item.TOPIC_SELECTED, selectionUpdater);
    eventBroker.subscribe(UIEvents.Item.TOPIC_ENABLED, enabledUpdater);
    eventBroker.subscribe(UIEvents.UIElement.TOPIC_ALL, toBeRenderedUpdater);
    eventBroker.subscribe(ElementContainer.TOPIC_CHILDREN, childAdditionUpdater);

    context.set(ToolBarManagerRenderer.class, this);
  }
  /**
   * This is a singleton service. One instance is used throughout the running application
   *
   * @param appContext The applicationContext to get the eventBroker from
   * @throws NullPointerException if the given appContext is <code>null</code>
   */
  public ModelServiceImpl(IEclipseContext appContext) {
    if (appContext == null) {
      throw new NullPointerException("No application context given!"); // $NON-NLS-1$
    }

    this.appContext = appContext;
    IEventBroker eventBroker = appContext.get(IEventBroker.class);
    eventBroker.subscribe(UIEvents.UIElement.TOPIC_WIDGET, hostedElementHandler);

    mApplicationElementFactory =
        new GenericMApplicationElementFactoryImpl(appContext.get(IExtensionRegistry.class));
  }
  @PreDestroy
  void cleanUp() {
    if (perspectiveImage != null) {
      perspectiveImage.dispose();
      perspectiveImage = null;
    }

    eventBroker.unsubscribe(toBeRenderedHandler);
    eventBroker.unsubscribe(childrenHandler);
    eventBroker.unsubscribe(selectionHandler);
    eventBroker.unsubscribe(labelHandler);

    PrefUtil.getAPIPreferenceStore().removePropertyChangeListener(propertyChangeListener);
  }
  @PostConstruct
  public void init() {
    eventBroker.subscribe(UIEvents.UILabel.TOPIC_ALL, itemUpdater);
    eventBroker.subscribe(UIEvents.Item.TOPIC_SELECTED, selectionUpdater);
    eventBroker.subscribe(UIEvents.Item.TOPIC_ENABLED, enabledUpdater);
    eventBroker.subscribe(UIEvents.UIElement.TOPIC_ALL, toBeRenderedUpdater);

    context.set(MenuManagerRenderer.class, this);
    Display display = context.get(Display.class);
    rendererFilter = ContextInjectionFactory.make(MenuManagerRendererFilter.class, context);
    display.addFilter(SWT.Show, rendererFilter);
    display.addFilter(SWT.Hide, rendererFilter);
    display.addFilter(SWT.Dispose, rendererFilter);
    context.set(MenuManagerRendererFilter.class, rendererFilter);
  }
 private void registerModelListeners() {
   additionHandler =
       new EventHandler() {
         public void handleEvent(Event event) {
           Object elementObj = event.getProperty(UIEvents.EventTags.ELEMENT);
           if (elementObj instanceof MBindingContext) {
             if (UIEvents.isADD(event)) {
               for (Object newObj : UIEvents.asIterable(event, UIEvents.EventTags.NEW_VALUE)) {
                 if (newObj instanceof MBindingContext) {
                   MBindingContext newCtx = (MBindingContext) newObj;
                   defineContexts((MBindingContext) elementObj, newCtx);
                 }
               }
             } else if (UIEvents.isREMOVE(event)) {
               for (Object oldObj : UIEvents.asIterable(event, UIEvents.EventTags.OLD_VALUE)) {
                 if (oldObj instanceof MBindingContext) {
                   MBindingContext oldCtx = (MBindingContext) oldObj;
                   undefineContext(oldCtx);
                 }
               }
             }
           }
         }
       };
   broker.subscribe(UIEvents.BindingContext.TOPIC_CHILDREN, additionHandler);
 }
 /** Unconfigure the handler */
 @PreDestroy
 public void dispose() {
   if (shellListener != null) {
     eventBroker.unsubscribe(shellListener);
   }
   if (menuListener != null) {
     eventBroker.unsubscribe(menuListener);
   }
   if (menuContributionListener != null) {
     eventBroker.unsubscribe(menuContributionListener);
   }
   if (commandListener != null) {
     eventBroker.unsubscribe(commandListener);
   }
   if (tagListener != null) {
     eventBroker.unsubscribe(tagListener);
   }
 }
 void fireStyleChange(final StyleSnapshot inStyleSnapshot) {
   if (inStyleSnapshot != null) {
     eventBroker.post(
         isFormStyle
             ? RelationsConstants.TOPIC_STYLE_CHANGED_FORM
             : RelationsConstants.TOPIC_STYLE_CHANGED_INSPECTOR,
         inStyleSnapshot.createStyleParameter());
   }
 }
  /**
   * Initialize a part renderer from the extension point.
   *
   * @param context the context for the part factories
   */
  @PostConstruct
  void initialize(IEclipseContext context) {
    this.appContext = context;

    // initialize the correct key-binding display formatter
    KeyFormatterFactory.setDefault(SWTKeySupport.getKeyFormatterForPlatform());

    // Add the renderer to the context
    context.set(IPresentationEngine.class.getName(), this);

    IRendererFactory factory = null;
    IContributionFactory contribFactory = context.get(IContributionFactory.class);
    try {
      factory = (IRendererFactory) contribFactory.create(factoryUrl, context);
    } catch (Exception e) {
      logger.warn(e, "Could not create rendering factory");
    }

    // Try to load the default one
    if (factory == null) {
      try {
        factory = (IRendererFactory) contribFactory.create(defaultFactoryUrl, context);
      } catch (Exception e) {
        logger.error(e, "Could not create default rendering factory");
      }
    }

    if (factory == null) {
      throw new IllegalStateException("Could not create any rendering factory. Aborting ...");
    }

    curFactory = factory;
    context.set(IRendererFactory.class, curFactory);

    // Hook up the widget life-cycle subscriber
    if (eventBroker != null) {
      eventBroker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED, toBeRenderedHandler);
      eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, visibilityHandler);
      eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, childrenHandler);
      eventBroker.subscribe(UIEvents.Window.TOPIC_WINDOWS, windowsHandler);
      eventBroker.subscribe(UIEvents.Perspective.TOPIC_WINDOWS, windowsHandler);
      eventBroker.subscribe(UIEvents.TrimmedWindow.TOPIC_TRIMBARS, trimHandler);
    }
  }
  @PreDestroy
  public void contextDisposed() {
    eventBroker.unsubscribe(itemUpdater);
    eventBroker.unsubscribe(selectionUpdater);
    eventBroker.unsubscribe(enabledUpdater);
    eventBroker.unsubscribe(toBeRenderedUpdater);

    context.remove(MenuManagerRendererFilter.class);
    Display display = context.get(Display.class);
    if (display != null && !display.isDisposed() && rendererFilter != null) {
      display.removeFilter(SWT.Show, rendererFilter);
      display.removeFilter(SWT.Hide, rendererFilter);
      display.removeFilter(SWT.Dispose, rendererFilter);
    }
    if (rendererFilter != null) {
      ContextInjectionFactory.uninject(rendererFilter, context);
      rendererFilter = null;
    }
    context.remove(MenuManagerRenderer.class);
  }
 private void registerModelListeners() {
   additionHandler =
       new EventHandler() {
         @Override
         public void handleEvent(Event event) {
           if (application == event.getProperty(UIEvents.EventTags.ELEMENT)) {
             if (UIEvents.isADD(event)) {
               for (Object obj : UIEvents.asIterable(event, UIEvents.EventTags.NEW_VALUE)) {
                 if (obj instanceof MCommand) {
                   createCommand((MCommand) obj);
                 } else if (obj instanceof MCategory) {
                   createCategory((MCategory) obj);
                 }
               }
             }
           }
         }
       };
   broker.subscribe(UIEvents.Application.TOPIC_COMMANDS, additionHandler);
   broker.subscribe(UIEvents.Application.TOPIC_CATEGORIES, additionHandler);
 }
示例#17
0
 public void revealElement(final RobotElement element) {
   if (dataProvider.isFilterSet() && !dataProvider.isProvided(element)) {
     final String topic =
         RobotSuiteEditorEvents.FORM_FILTER_SWITCH_REQUEST_TOPIC
             + "/"
             + RobotCasesSection.SECTION_NAME.replaceAll(" ", "_");
     eventBroker.send(
         topic, new FilterSwitchRequest(RobotCasesSection.SECTION_NAME.replaceAll(" ", "_"), ""));
   }
   CellEditorCloser.closeForcibly(table);
   selectionProvider.setSelection(new StructuredSelection(new Object[] {element}));
   setFocus();
 }
 @Execute
 public void onExecute() {
   eventBroker.subscribe(
       IThemeEngine.Events.THEME_CHANGED,
       new EventHandler() {
         public void handleEvent(Event event) {
           ITheme currentTheme = (ITheme) event.getProperty(IThemeEngine.Events.THEME);
           //						if (!prefDarker.getBoolean(
           //								THEME_DARKER_PREF_THEMEENABLED, false))
           if (currentTheme.getId().equals(THEME_DARKER_ID)) {
             setupPreferences();
             isLastThemeDarker = true;
           } else if (isLastThemeDarker) {
             setToDefaultPreferences();
           }
         }
       });
 }
  @Override
  public void processPacket(Stanza packet) throws NotConnectedException {
    try {
      if (packet instanceof Message) {

        Message msg = (Message) packet;
        logger.info("Task message received from => {}, body => {}", msg.getFrom(), msg.getBody());

        ObjectMapper mapper = new ObjectMapper();
        mapper.getDeserializationConfig().setDateFormat(new SimpleDateFormat("dd-MM-yyyy HH:mm"));

        final TaskNotification task = mapper.readValue(msg.getBody(), TaskNotification.class);

        // Notify related plug-in
        eventBroker.post(LiderConstants.EVENT_TOPICS.TASK_NOTIFICATION_RECEIVED, task);
      }
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
    }
  }
  @Override
  public void hookControllerLogic(final MUIElement element) {
    if (element instanceof MWindow) {
      final MWindow mWindow = (MWindow) element;
      final Shell shell = (Shell) mWindow.getWidget();

      EventHandler sizeHandler =
          new EventHandler() {
            @Override
            public void handleEvent(Event event) {

              // Ensure that this event is for a MMenuItem
              Object objElement = event.getProperty(UIEvents.EventTags.ELEMENT);
              if (!(objElement instanceof MWindow)) {
                return;
              }

              // Is this listener interested ?
              final MWindow window = (MWindow) objElement;
              if (window.getRenderer() != WorkbenchWindowRenderer.this) {
                return;
              }

              // No widget == nothing to update
              if (shell == null) {
                return;
              }

              String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME);

              if (UIEvents.Window.X.equals(attName)
                  || UIEvents.Window.Y.equals(attName)
                  || UIEvents.Window.WIDTH.equals(attName)
                  || UIEvents.Window.HEIGHT.equals(attName)) {
                shell
                    .getDisplay()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            shell.setBounds(
                                window.getX(),
                                window.getY(),
                                window.getWidth(),
                                window.getHeight());
                          }
                        });
              }
            }
          };

      eventBroker.subscribe(UIEvents.Window.TOPIC_ALL, sizeHandler);

      shell.addControlListener(
          new ControlListener() {
            @Override
            public void controlResized(ControlEvent e) {
              // Don't store the maximized size in the model
              if (shell.getMaximized()) {
                return;
              }

              mWindow.setWidth(shell.getSize().x);
              mWindow.setHeight(shell.getSize().y);
            }

            @Override
            public void controlMoved(ControlEvent e) {
              // Don't store the maximized size in the model
              if (shell.getMaximized()) {
                return;
              }

              mWindow.setX(shell.getLocation().x);
              mWindow.setY(shell.getLocation().y);
            }
          });
    }
  }
 @PostConstruct
 public void postConstruct() {
   eventBroker.subscribe(
       UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, selectPerspectiveHandler);
   eventBroker.subscribe(UIEvents.ApplicationElement.TOPIC_TAGS, tagListener);
 }
  private void redrawGcode() {

    eventBroker.send(IEvent.REDRAW, null);
  }
  @PostConstruct
  void init(IEventBroker eventBroker) {
    eventBroker.subscribe(
        UIEvents.ElementContainer.TOPIC_CHILDREN,
        new EventHandler() {

          @Override
          public void handleEvent(Event event) {
            Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
            if (changedObj instanceof MPerspectiveStack) {
              MPerspectiveStack parent = (MPerspectiveStack) changedObj;
              if (BasePerspectiveStackRenderer.this == parent.getRenderer()) {
                String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);

                if (UIEvents.EventTypes.ADD.equals(eventType)) {
                  MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
                  handleChildAddition(parent, (MPerspective) element);
                } else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
                  MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
                  handleChildRemove(parent, (MPerspective) element);
                }
              }
            }
          }
        });
    eventBroker.subscribe(
        UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT,
        new EventHandler() {

          @Override
          public void handleEvent(Event event) {
            Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
            if (changedObj instanceof MPerspectiveStack) {
              MPerspectiveStack parent = (MPerspectiveStack) changedObj;
              if (BasePerspectiveStackRenderer.this == parent.getRenderer()) {
                String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
                if (UIEvents.EventTypes.SET.equals(eventType)) {
                  MUIElement newValue =
                      (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
                  MUIElement oldValue =
                      (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
                  handleSelectedElement(parent, (MPerspective) oldValue, (MPerspective) newValue);
                }
              }
            }
          }
        });
    eventBroker.subscribe(
        UIEvents.UIElement.TOPIC_VISIBLE,
        new EventHandler() {

          @Override
          public void handleEvent(Event event) {
            MUIElement changedObj = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
            if (changedObj.isToBeRendered()) {
              MUIElement parent = changedObj.getParent();
              // Can be null for e.g. detached windows!!!
              if (parent != null) {
                if (BasePerspectiveStackRenderer.this == parent.getRenderer()) {
                  MPerspectiveStack stack = (MPerspectiveStack) parent;
                  String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
                  if (UIEvents.EventTypes.SET.equals(eventType)) {
                    Boolean newValue = (Boolean) event.getProperty(UIEvents.EventTags.NEW_VALUE);
                    if (newValue.booleanValue()) {
                      // TODO Is childRendered not dangerous to call
                      // here??
                      childRendered(stack, changedObj);
                    } else {
                      hideChild(stack, changedObj);
                    }
                  }
                }
              }
            }
          }
        });
  }
 @PreDestroy
 public void preDestroy() {
   eventBroker.unsubscribe(selectPerspectiveHandler);
   eventBroker.unsubscribe(tagListener);
 }
  /** Hooks a listener that tweaks newly opened workbench window shells with the proper OS flags. */
  protected void hookWorkbenchListeners() {
    // watch for a window's "widget" attribute being flipped to a shell
    shellListener =
        new EventHandler() {
          public void handleEvent(org.osgi.service.event.Event event) {
            if (event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MWindow
                && event.getProperty(UIEvents.EventTags.NEW_VALUE) != null) {
              MWindow window = (MWindow) event.getProperty(UIEvents.EventTags.ELEMENT);
              modifyWindowShell(window);
              updateFullScreenStatus(window);
            }
          }
        };
    eventBroker.subscribe(UIEvents.UIElement.TOPIC_WIDGET, shellListener);

    // this listener is handling the Eclipse 4.0 compatibility case,
    // where the window is created without a main menu or trim first,
    // and then later when the main menu is being set it is time
    // for us to do our work. It also handles dynamically created
    // windows too.
    menuListener =
        new EventHandler() {
          public void handleEvent(org.osgi.service.event.Event event) {
            Object newValue = event.getProperty(UIEvents.EventTags.NEW_VALUE);
            Object oldValue = event.getProperty(UIEvents.EventTags.OLD_VALUE);
            Object element = event.getProperty(UIEvents.EventTags.ELEMENT);
            if (element instanceof MWindow && oldValue == null && newValue instanceof MMenu) {
              modifyWindowShell((MWindow) element);
            }
          }
        };
    eventBroker.subscribe(UIEvents.Window.TOPIC_MAINMENU, menuListener);

    // watch for new menu contributions
    menuContributionListener =
        new EventHandler() {
          public void handleEvent(org.osgi.service.event.Event event) {
            if (event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MMenuContribution
                && event.getProperty(UIEvents.EventTags.NEW_VALUE) != null) {
              MMenuContribution contribution =
                  (MMenuContribution) event.getProperty(UIEvents.EventTags.ELEMENT);
              processMenuContribution(contribution);
            }
          }
        };
    eventBroker.subscribe(
        UIEvents.MenuContributions.TOPIC_MENUCONTRIBUTIONS, menuContributionListener);

    // watch for command changes
    commandListener =
        new EventHandler() {
          public void handleEvent(org.osgi.service.event.Event event) {
            if (event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MCommand) {
              MCommand cmd = (MCommand) event.getProperty(UIEvents.EventTags.ELEMENT);
              String id = cmd.getElementId();
              if (COMMAND_ID_ABOUT.equals(id)
                  || COMMAND_ID_PREFERENCES.equals(id)
                  || COMMAND_ID_QUIT.equals(id)) {
                hookApplicationMenu();
              }
            }
          }
        };
    eventBroker.subscribe(UIEvents.Application.TOPIC_COMMANDS, commandListener);

    // watch for a window's full-screen tag being flipped
    tagListener =
        new EventHandler() {
          public void handleEvent(org.osgi.service.event.Event event) {
            if (event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MWindow) {
              MWindow window = (MWindow) event.getProperty(UIEvents.EventTags.ELEMENT);
              updateFullScreenStatus(window);
            }
          }
        };
    eventBroker.subscribe(UIEvents.ApplicationElement.TOPIC_TAGS, tagListener);
  }
 private void unregsiterModelListeners() {
   broker.unsubscribe(additionHandler);
 }
 @PostConstruct
 public void pc(IEventBroker broker) {
   broker.subscribe(MediaConstants.mediaEntrySelected, meidaSelectedHandler);
   broker.subscribe(MediaConstants.mediaEntryChanged, mediaChangedHandler);
 }
  @Execute
  public void execute(final IEventBroker eventBroker) {
    LOGGER.info(this.getClass().getSimpleName() + " called. Active Order is: " + activeOrder);

    eventBroker.post(OrderServiceEvents.TOPIC_ORDER_TREE_REMOVE, activeOrder);
  }
 @PreDestroy
 public void pd(IEventBroker broker) {
   broker.unsubscribe(meidaSelectedHandler);
   broker.unsubscribe(mediaChangedHandler);
 }