public Form getSupportMe() {
    if (frmSupportMe == null) {
      // ---------------------------------------------
      // Form f = ...
      frmSupportMe = new Form("Support Me");
      frmSupportMe.setLayout(new BorderLayout());

      Image bimage = null;
      try {
        bimage = Image.createImage("/images/metaLabSmall.png");
      } catch (IOException ex) {
        ex.printStackTrace();
      }

      Label bottomText = new Label(bimage);
      bottomText.setAlignment(Component.CENTER);
      bottomText.setText("Our Logo");
      bottomText.setTextPosition(Component.BOTTOM);

      Container buttonBar = new Container(new BoxLayout(BoxLayout.X_AXIS));
      buttonBar.addComponent(new Button("Add"));
      buttonBar.addComponent(new Button("Remove"));
      buttonBar.addComponent(new Button("Edit"));
      buttonBar.addComponent(new Button("Send"));
      buttonBar.addComponent(new Button("Exit"));

      frmSupportMe.addComponent(BorderLayout.CENTER, bottomText);
      frmSupportMe.addComponent(BorderLayout.SOUTH, buttonBar);
      frmSupportMe.addCommand(mBackCommand);
      frmSupportMe.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmSupportMe;
  }
  /* goodB2G() - use badsource and goodsink */
  private void goodB2G() throws Throwable {
    int count;

    count = Integer.MIN_VALUE; /* Initialize count */

    /* get environment variable ADD */
    /* POTENTIAL FLAW: Read count from an environment variable */
    {
      String stringNumber = System.getenv("ADD");
      if (stringNumber != null) // avoid NPD incidental warnings
      {
        try {
          count = Integer.parseInt(stringNumber.trim());
        } catch (NumberFormatException exceptNumberFormat) {
          IO.logger.log(
              Level.WARNING,
              "Number format exception parsing count from string",
              exceptNumberFormat);
        }
      }
    }

    Container countContainer = new Container();
    countContainer.containerOne = count;
    (new CWE400_Resource_Exhaustion__sleep_Environment_67b()).goodB2GSink(countContainer);
  }
Ejemplo n.º 3
0
  public void start() {
    mLogger.d("start");

    if (!MapObject.isOfType(MapObject.MY_POSITION, mStartPoint)) {
      Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_START_SUGGEST_REBUILD);
      AlohaHelper.logClick(AlohaHelper.ROUTING_START_SUGGEST_REBUILD);
      suggestRebuildRoute();
      return;
    }

    MapObject my = LocationHelper.INSTANCE.getMyPosition();
    if (my == null) {
      mRoutingListener.onRoutingEvent(ResultCodesHelper.NO_POSITION, null);
      return;
    }

    mStartPoint = my;
    Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_START);
    AlohaHelper.logClick(AlohaHelper.ROUTING_START);
    setState(State.NAVIGATION);

    mContainer.showRoutePlan(false, null);
    mContainer.showNavigation(true);

    ThemeSwitcher.restart();

    Framework.nativeFollowRoute();
    LocationHelper.INSTANCE.restart();
  }
Ejemplo n.º 4
0
 private void completeUberRequest() {
   mUberRequestHandled = true;
   if (mContainer != null) {
     mContainer.updateBuildProgress(100, mLastRouterType);
     mContainer.updateMenu();
   }
 }
Ejemplo n.º 5
0
  public void checkLocation() {
    Container con = new Container();
    MyLocationListener locationListener = new MyLocationListener(con);

    locationListener.onLocationChanged();
    con.publish();
  }
Ejemplo n.º 6
0
  /** 先根据TYPE注解获取FieldContainer,如果null再根据Field获取 都取不到return null */
  static FieldContainer getPrimaryFieldContainer(@NonNull Container container) {

    HashMap<String, FieldContainer> containers = container.getFieldContainers();
    if (containers == null || containers.size() < 1) {
      return null;
    }

    PrimaryKey primaryKey = container.getPrimaryKey();
    if (primaryKey != null) { // 先根据TYPE注解获取FieldContainer
      String name = primaryKey.keyName();
      boolean isAuto = primaryKey.autoIncrement();
      if (!TextUtils.isEmpty(name)) {
        FieldContainer fc = containers.get(name);
        if (fc != null) {
          fc.setIsAuto(isAuto);
          fc.setIsPrimaryKey(true);
          return fc;
        }
      }
    }

    // Field获取
    Set<Map.Entry<String, FieldContainer>> sets = containers.entrySet();
    Iterator<Map.Entry<String, FieldContainer>> iterator = sets.iterator();
    while ((iterator.hasNext())) {
      Map.Entry<String, FieldContainer> entry = iterator.next();
      FieldContainer fieldContainer = entry.getValue();
      if (fieldContainer.isPrimaryKey()) {
        return fieldContainer;
      }
    }
    return null;
  }
Ejemplo n.º 7
0
  /**
   * Determines the minimum size of the container argument using this grid layout.
   *
   * <p>The minimum width of a grid layout is the largest minimum width of all of the components in
   * the container times the number of columns, plus the horizontal padding times the number of
   * columns minus one, plus the left and right insets of the target container.
   *
   * <p>The minimum height of a grid layout is the largest minimum height of all of the components
   * in the container times the number of rows, plus the vertical padding times the number of rows
   * minus one, plus the top and bottom insets of the target container.
   *
   * @param parent the container in which to do the layout
   * @return the minimum dimensions needed to lay out the subcomponents of the specified container
   * @see java.awt.GridLayout#preferredLayoutSize
   * @see java.awt.Container#doLayout
   */
  public Dimension minimumLayoutSize(Container parent) {
    synchronized (parent.getTreeLock()) {
      Insets insets = parent.getInsets();
      int ncomponents = parent.getComponentCount();
      int nrows = rows;
      int ncols = cols;

      if (nrows > 0) {
        ncols = (ncomponents + nrows - 1) / nrows;
      } else {
        nrows = (ncomponents + ncols - 1) / ncols;
      }
      int w = 0;
      int h = 0;
      for (int i = 0; i < ncomponents; i++) {
        Component comp = parent.getComponent(i);
        Dimension d = comp.getMinimumSize();
        if (w < d.width) {
          w = d.width;
        }
        if (h < d.height) {
          h = d.height;
        }
      }
      return new Dimension(
          insets.left + insets.right + ncols * w + (ncols - 1) * hgap,
          insets.top + insets.bottom + nrows * h + (nrows - 1) * vgap);
    }
  }
    public void addCompletions(
        @NotNull CompletionParameters parameters,
        ProcessingContext context,
        @NotNull CompletionResultSet resultSet) {

      PsiElement element = parameters.getPosition().getParent();
      Project project = element.getProject();

      if (!SilexProjectComponent.isEnabled(project)) {
        return;
      }

      if (!(element instanceof StringLiteralExpression)) {
        return;
      }

      Container container =
          Utils.findContainerForFirstParameterOfPimpleMethod((StringLiteralExpression) element);
      if (container == null) {
        return;
      }

      for (Service service : container.getServices().values()) {
        resultSet.addElement(new ServiceLookupElement(service, project));
      }

      for (Parameter parameter : container.getParameters().values()) {
        resultSet.addElement(new ParameterLookupElement(parameter));
      }

      resultSet.stopHere();
    }
Ejemplo n.º 9
0
  /**
   * Maps a named servlet to a particular path or extension. If the named servlet is unregistered,
   * it will be added and subsequently mapped.
   *
   * <p>Note that the order of resolution to handle a request is:
   *
   * <p>exact mapped servlet (eg /catalog) prefix mapped servlets (eg /foo/bar/*) extension mapped
   * servlets (eg *jsp) default servlet
   */
  public void addServletMapping(String path, String servletName) throws TomcatException {
    if (mappings.get(path) != null) {
      log("Removing duplicate " + path + " -> " + mappings.get(path));
      mappings.remove(path);
      Container ct = (Container) containers.get(path);
      removeContainer(ct);
    }
    ServletWrapper sw = (ServletWrapper) servlets.get(servletName);
    if (sw == null) {
      // Workaround for frequent "bug" in web.xmls
      // Declare a default mapping
      log("Mapping with unregistered servlet " + servletName);
      sw = addServlet(servletName, servletName);
    }
    if ("/".equals(path)) defaultServlet = sw;

    mappings.put(path, sw);

    Container map = new Container();
    map.setContext(this);
    map.setHandler(sw);
    map.setPath(path);
    contextM.addContainer(map);
    containers.put(path, map);
  }
  private static List<AnaphorWithReferent> parseText(InputText text) {
    Annotation annotatedText = new Annotation(text.toString());
    Container.getStanfordCoreNLP().annotate(annotatedText);
    List<CoreMap> coreMapSentences = annotatedText.get(CoreAnnotations.SentencesAnnotation.class);
    List<Tree> trees =
        coreMapSentences
            .stream()
            .map(s -> s.get(TreeCoreAnnotations.TreeAnnotation.class))
            .collect(Collectors.toList());

    List<Sentence> allSentences =
        IntStream.range(0, trees.size())
            .mapToObj(
                id ->
                    new Sentence(
                        id,
                        trees.get(id),
                        Container.getNPsFromParseTreeExtractor().extract(trees.get(id))))
            .collect(Collectors.toList());
    List<AnaphorWithReferent> anaphoraWithReferentFromAllSentences =
        allSentences
            .stream()
            .map(s -> Container.getAllAnaphorWithReferentPerSentenceFinder().find(s, allSentences))
            .flatMap(a -> a.stream())
            .collect(Collectors.toList());

    return anaphoraWithReferentFromAllSentences;
  }
Ejemplo n.º 11
0
  /**
   * Log a message on the Logger associated with our Container (if any).
   *
   * @param message Message to be logged
   */
  protected void log(String message) {

    Logger logger = null;
    if (container != null) logger = container.getLogger();
    if (logger != null) logger.log("StandardPipeline[" + container.getName() + "]: " + message);
    else System.out.println("StandardPipeline[" + container.getName() + "]: " + message);
  }
Ejemplo n.º 12
0
  /**
   * Constructor of a Plate from scratch
   *
   * @param plateName
   * @param numrows
   * @param numcols
   * @param isFixedContainers
   */
  public Plate(String plateName, PlateType type, Person author) {
    super();
    _plateDatum = new PlateDatum();
    _datum = _plateDatum;
    _datum.name = plateName;
    _datum.dateCreated = new Date();
    _datum.lastModified = new Date();
    _datum.uuid = _uuid;

    _plateDatum._authorUUID = author.getUUID();
    _plateDatum._plateTypeUUID = type.getUUID();
    _plateDatum.myWells = new String[type.getNumRows()][type.getNumCols()];

    // If it's a fixed-Container Plate, add containers
    if (type.isContainerFixed()) {
      int numrows = type.getNumRows();
      int numcols = type.getNumCols();
      for (short row = 0; row < numrows; row++) {
        for (short col = 0; col < numcols; col++) {
          Container acon = new Container();
          acon.putContainerToPlate(row, col, this);
        }
      }
    }
  }
 private void shutdownAllContainers() {
   for (Container ct : this.containers.values()) {
     if (ct != null) {
       ct.kill();
     }
   }
 }
Ejemplo n.º 14
0
  /**
   * Create an <code>ObjectName</code> for this <code>Manager</code> object.
   *
   * @param domain Domain in which this name is to be created
   * @param manager The Manager to be named
   * @exception MalformedObjectNameException if a name cannot be created
   */
  static ObjectName createObjectName(String domain, Manager manager)
      throws MalformedObjectNameException {

    ObjectName name = null;
    Container container = manager.getContainer();

    if (container instanceof Engine) {
      name = new ObjectName(domain + ":type=Manager");
    } else if (container instanceof Host) {
      name = new ObjectName(domain + ":type=Manager,host=" + container.getName());
    } else if (container instanceof Context) {
      String path = ((Context) container).getPath();
      if (path.length() < 1) {
        path = "/";
      }
      Host host = (Host) container.getParent();
      name = new ObjectName(domain + ":type=Manager,path=" + path + ",host=" + host.getName());
    } else if (container == null) {
      DefaultContext defaultContext = manager.getDefaultContext();
      if (defaultContext != null) {
        Container parent = defaultContext.getParent();
        if (parent instanceof Engine) {
          name = new ObjectName(domain + ":type=DefaultManager");
        } else if (parent instanceof Host) {
          name = new ObjectName(domain + ":type=DefaultManager,host=" + parent.getName());
        }
      }
    }

    return (name);
  }
Ejemplo n.º 15
0
 private static void assertContainer(Container container, Component... components) {
   Assert.assertEquals(components.length, container.getComponents().size());
   int index = 0;
   for (Component component : container.getComponents()) {
     Assert.assertSame(components[index++], component);
   }
 }
  public void testRegisterTemplateEmptyTemplateBody() throws Throwable {
    try {

      final Container container = new Container();

      Context context = getInstrumentation().getTargetContext();

      MobileServiceClient client = new MobileServiceClient(appUrl, appKey, context);

      try {
        client
            .getPush()
            .registerTemplate(UUID.randomUUID().toString(), "template1", "", new String[] {"tag1"})
            .get();
      } catch (Exception exception) {
        if (exception instanceof ExecutionException) {
          container.exception = (Exception) exception.getCause();
        } else {
          container.exception = exception;
        }
      }

      // Asserts
      Exception exception = container.exception;

      if (!(exception instanceof IllegalArgumentException)) {
        fail("Expected Exception IllegalArgumentException");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * Sets the actions that will be turned into ActionButtons at the bottom of the panel. Any action
   * that is clicked will also call the OptionPanel.close() method which by default removes the
   * panel from its parent node.
   */
  public void setOptions(Action... options) {

    if (this.options == options) {
      return;
    }
    if (this.options != null) {
      // Need to clear out any old button listeners
      for (Node n : buttons.getLayout().getChildren()) {
        if (!(n instanceof Button)) {
          continue;
        }
        ((Button) n).removeClickCommands(listener);
      }
    }
    this.options = options;
    buttons.clearChildren();
    if (options.length == 0) {
      options = new Action[] {new EmptyAction("Ok")};
    }

    for (Action a : options) {
      ActionButton button = new ActionButton(a, getElementId().child("button"), getStyle());
      button.addClickCommands(listener);
      buttons.addChild(button);
    }
  }
  public void testReRegisterFailNative() throws Throwable {
    try {

      Context context = getInstrumentation().getTargetContext();
      final SharedPreferences sharedPreferences =
          PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());

      final Container container = new Container();
      final String handle = "handle";

      String registrationId1 = "registrationId1";
      String registrationId2 = "registrationId2";

      MobileServiceClient client = new MobileServiceClient(appUrl, appKey, context);

      MobileServiceClient registrationclient =
          client.withFilter(getUpsertTestFilter(registrationId1));
      MobileServiceClient reRegistrationclient =
          client.withFilter(getUpsertFailTestFilter(registrationId2));

      final MobileServicePush registrationPush = registrationclient.getPush();
      final MobileServicePush reRegistrationPush = reRegistrationclient.getPush();

      forceRefreshSync(registrationPush, handle);
      forceRefreshSync(reRegistrationPush, handle);

      try {
        registrationPush.register(handle, new String[] {"tag1"}).get();
      } catch (Exception exception) {
        fail(exception.getMessage());
      }

      try {
        reRegistrationPush.register(handle, new String[] {"tag1"}).get();

      } catch (Exception exception) {
        if (exception instanceof ExecutionException) {
          container.exception = (Exception) exception.getCause();
        } else {
          container.exception = exception;
        }

        container.storedRegistrationId =
            sharedPreferences.getString(
                STORAGE_PREFIX + REGISTRATION_NAME_STORAGE_KEY + DEFAULT_REGISTRATION_NAME, null);
      }

      // Asserts
      Exception exception = container.exception;

      if (!(exception instanceof RegistrationGoneException)) {
        fail("Expected Exception RegistrationGoneException");
      }

      Assert.assertNull(container.storedRegistrationId);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 19
0
 @Override
 public InjectManager<?, ?> create() throws Exception {
   Container container = new WeldContainer(classLoader, ScopeController.INSTANCE, scopes);
   for (ReadFileSystem<?> fs : fileSystems) {
     container.addFileSystem(fs);
   }
   return new CDIManager(container, boundBeans, declaredBeans);
 }
Ejemplo n.º 20
0
 /** Here the read should float after the loop. */
 public static int testLoop9Snippet(int a, int b) {
   container.a = b;
   for (int i = 0; i < a; i++) {
     container.a = i;
   }
   GraalDirectives.controlFlowAnchor();
   return container.a;
 }
Ejemplo n.º 21
0
 public static void main(String[] args) {
   Container<Integer> cont = new Container<Integer>();
   cont.next = new Container<Integer>();
   cont.next.setVal(new Integer(0));
   badMethod(cont.next);
   Object someVal = cont.next.val; // no cast
   System.out.println(cont.next.val); // no cast
 }
Ejemplo n.º 22
0
 /** Here the read should float to the end, right before the write. */
 public static int testIfRead3Snippet(int a) {
   if (a < 0) {
     container.a = 10;
   }
   int res = container.a;
   container.a = 20;
   return res;
 }
Ejemplo n.º 23
0
 void searchPoi(int slotId) {
   mLogger.d("searchPoi: " + slotId);
   Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_SEARCH_POINT);
   AlohaHelper.logClick(AlohaHelper.ROUTING_SEARCH_POINT);
   mWaitingPoiPickSlot = slotId;
   mContainer.showSearch();
   mContainer.updateMenu();
 }
 @Override
 public void run() throws Exception {
   CounterService service = getService();
   System.out.println(
       "Executing backup " + objectId + ".inc() on: " + getNodeEngine().getThisAddress());
   Container container = service.containers[getPartitionId()];
   container.inc(objectId, amount);
 }
Ejemplo n.º 25
0
  @Override
  public boolean compareStorageContainerDimensions(final Container<?> container) {
    if (container.getNumDimensions() != this.getNumDimensions()) return false;

    for (int i = 0; i < numDimensions; i++)
      if (this.dim[i] != container.getDimensions()[i]) return false;

    return true;
  }
Ejemplo n.º 26
0
  public Container getContainerWithName(String name) {
    for (Container container : getContainers()) {
      if (container.getName().equals(name)) {
        return container;
      }
    }

    return null;
  }
Ejemplo n.º 27
0
  public Container getContainerWithId(int id) {
    for (Container container : getContainers()) {
      if (container.getId() == id) {
        return container;
      }
    }

    return null;
  }
 public void sendMessageToClient(AbstractMessage message) {
   try {
     Container.logger().debug(">>> " + message);
     Buffer b1 = encoder.enc(message);
     sendMessageToClient(b1);
   } catch (Throwable e) {
     Container.logger().error(e.getMessage(), e);
   }
 }
Ejemplo n.º 29
0
  @Test
  public void verifyLength() {
    cont.storeFile(
        file, new BufferedInputStream(new ByteArrayInputStream(data)), FileInContainer.NO_TAIL_ID);

    long length = Container.HEADER_SIZE + File.OVERHEAD_SIZE + data.length;

    assertEquals(length, cont.getCurrentSize());
  }
Ejemplo n.º 30
0
  public void cleanup() {
    final IWindowManager windowManager = Container.getComponent(IWindowManager.class);

    if (windowManager != null) {
      windowManager.cleanup();
    }
    Container.getComponent(IBattleManager.class).cleanup();
    Container.getComponent(IHostManager.class).cleanup();
  }