Exemplo n.º 1
0
 public boolean canProvideCapability(ViewCapability viewCapability) {
   for (ViewFactory viewFactory : viewFactories) {
     if (!viewFactory.canProvideCapability(viewCapability)) {
       return false;
     }
   }
   return viewCapability instanceof RemoveStreamViewCapability;
 }
Exemplo n.º 2
0
 public View makeView(StatementContext statementContext) {
   boolean hasAsymetric = false;
   List<View> views = new ArrayList<View>();
   for (ViewFactory viewFactory : viewFactories) {
     views.add(viewFactory.makeView(statementContext));
     hasAsymetric |= viewFactory instanceof AsymetricDataWindowViewFactory;
   }
   if (hasAsymetric) {
     return new UnionAsymetricView(this, parentEventType, views);
   }
   return new UnionView(this, parentEventType, views);
 }
Exemplo n.º 3
0
  public void setProvideCapability(
      ViewCapability viewCapability, ViewResourceCallback resourceCallback) {
    if (!canProvideCapability(viewCapability)) {
      throw new UnsupportedOperationException(
          "View capability " + viewCapability.getClass().getSimpleName() + " not supported");
    }

    if (viewCapability instanceof RemoveStreamViewCapability) {
      for (ViewFactory viewFactory : viewFactories) {
        viewFactory.setProvideCapability(viewCapability, resourceCallback);
      }
    }
  }
Exemplo n.º 4
0
  /**
   * Render a particular subset of data from a {@link TupleTable} to a particular {@link Renderer}.
   *
   * @param request The request encoding the particulars of the rendering to be done.
   * @param postData The selected page (only relevant for {@link JQGridRenderer} rendering)
   * @param totalPages The total number of pages (only relevant for {@link JQGridRenderer}
   *     rendering)
   * @param tupleTable The table from which to render the data.
   */
  private void renderData(
      MolgenisRequest request, JQGridPostData postData, int totalPages, final TupleTable tupleTable)
      throws TableException {
    tupleTable.setDb(request.getDatabase());

    String strViewType = request.getString("viewType");
    if (StringUtils.isEmpty(strViewType)) {
      strViewType = "JQ_GRID";
    }

    try {
      final ViewFactory viewFactory = new ViewFactoryImpl();
      final Renderers.Renderer view = viewFactory.createView(strViewType);
      view.export(request, request.getString("caption"), tupleTable, totalPages, postData.page);
    } catch (final Exception e) {
      throw new TableException(e);
    }
  }
  public static PriorEventViewFactory getPriorEventViewFactory(
      StatementContext statementContext, int streamNum, int viewFactoryNum, boolean unboundStream) {
    try {
      String namespace = ViewEnum.PRIOR_EVENT_VIEW.getNamespace();
      String name = ViewEnum.PRIOR_EVENT_VIEW.getName();
      ViewFactory factory = statementContext.getViewResolutionService().create(namespace, name);

      ViewFactoryContext context =
          new ViewFactoryContext(statementContext, streamNum, viewFactoryNum, namespace, name);
      factory.setViewParameters(
          context, Arrays.asList((ExprNode) new ExprConstantNodeImpl(unboundStream)));

      return (PriorEventViewFactory) factory;
    } catch (ViewProcessingException ex) {
      String text = "Exception creating prior event view factory";
      throw new EPException(text, ex);
    } catch (ViewParameterException ex) {
      String text = "Exception creating prior event view factory";
      throw new EPException(text, ex);
    }
  }
Exemplo n.º 6
0
  private static void addNewViewMenuItems(
      JPopupMenu menu, final DockingWindow window, ViewFactoryManager viewManager) {
    ViewFactory[] viewFactories = viewManager.getViewFactories();

    if (viewFactories.length == 0) return;

    JMenu viewsPopup = new JMenu("Show View");

    for (int i = 0; i < viewFactories.length; i++) {
      final ViewFactory vf = viewFactories[i];

      viewsPopup
          .add(new JMenuItem(vf.getTitle(), vf.getIcon()))
          .addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  View view = vf.createView();

                  if (view.getRootWindow() == window.getRootWindow()) return;

                  view.restore();

                  if (view.getRootWindow() == window.getRootWindow()) return;

                  if (window instanceof RootWindow) ((RootWindow) window).setWindow(view);
                  else {
                    AbstractTabWindow tabWindow = getTabWindowFor(window);

                    if (tabWindow != null) tabWindow.addTab(view);
                  }
                }
              });
    }

    menu.add(viewsPopup);
  }
 /**
  * Loads all of the children to initialize the view. This is called by the {@link #setParent}
  * method. Subclasses can reimplement this to initialize their child views in a different manner.
  * The default implementation creates a child view for each child element.
  *
  * @param f the view factory
  * @see #setParent
  */
 protected void loadChildren(ViewFactory f) {
   if (f == null) {
     // No factory. This most likely indicates the parent view
     // has changed out from under us, bail!
     return;
   }
   Element e = getElement();
   int n = e.getElementCount();
   if (n > 0) {
     View[] added = new View[n];
     for (int i = 0; i < n; i++) {
       added[i] = f.create(e.getElement(i));
     }
     replace(0, 0, added);
   }
 }
Exemplo n.º 8
0
 /**
  * Updates the child views in response to receiving notification that the model changed, and there
  * is change record for the element this view is responsible for. This is implemented to assume
  * the child views are directly responsible for the child elements of the element this view
  * represents. The <code>ViewFactory</code> is used to create child views for each element
  * specified as added in the <code>ElementChange</code>, starting at the index specified in the
  * given <code>ElementChange</code>. The number of child views representing the removed elements
  * specified are removed.
  *
  * @param ec the change information for the element this view is responsible for. This should not
  *     be <code>null</code> if this method gets called
  * @param e the change information from the associated document
  * @param f the factory to use to build child views
  * @return whether or not the child views represent the child elements of the element this view is
  *     responsible for. Some views create children that represent a portion of the element they
  *     are responsible for, and should return false. This information is used to determine if
  *     views in the range of the added elements should be forwarded to or not
  * @see #insertUpdate
  * @see #removeUpdate
  * @see #changedUpdate
  * @since 1.3
  */
 protected boolean updateChildren(DocumentEvent.ElementChange ec, DocumentEvent e, ViewFactory f) {
   Element[] removedElems = ec.getChildrenRemoved();
   Element[] addedElems = ec.getChildrenAdded();
   View[] added = null;
   if (addedElems != null) {
     added = new View[addedElems.length];
     for (int i = 0; i < addedElems.length; i++) {
       added[i] = f.create(addedElems[i]);
     }
   }
   int nremoved = 0;
   int index = ec.getIndex();
   if (removedElems != null) {
     nremoved = removedElems.length;
   }
   replace(index, nremoved, added);
   return true;
 }
 public GeneralController(Manager manager) {
   this.manager = manager;
   ViewFactory factory = new ViewFactory();
   mainFrame = factory.buildFrame(this);
 }