コード例 #1
0
  /**
   * Method fired when "add" button is clicked.
   *
   * @param v add button's <tt>View</tt>
   */
  public void onAddClicked(View v) {
    Spinner accountsSpiner = (Spinner) findViewById(R.id.selectAccountSpinner);

    Account selectedAcc = (Account) accountsSpiner.getSelectedItem();
    if (selectedAcc == null) {
      logger.error("No account selected");
      return;
    }

    ProtocolProviderService pps = selectedAcc.getProtocolProvider();
    if (pps == null) {
      logger.error("No provider registered for account " + selectedAcc.getAccountName());
      return;
    }

    View content = findViewById(android.R.id.content);
    String contactAddress = ViewUtil.getTextViewValue(content, R.id.editContactName);

    String displayName = ViewUtil.getTextViewValue(content, R.id.editDisplayName);
    if (displayName != null && displayName.length() > 0) {
      addRenameListener(pps, null, contactAddress, displayName);
    }

    Spinner groupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);
    ContactListUtils.addContact(
        pps, (MetaContactGroup) groupSpinner.getSelectedItem(), contactAddress);
    finish();
  }
コード例 #2
0
  /** {@inheritDoc} */
  @Override
  protected void onDestroy() {
    super.onDestroy();

    if (!cancelled) {
      View content = findViewById(android.R.id.content);
      authWindow.setUsername(ViewUtil.getTextViewValue(content, R.id.username));
      authWindow.setPassword(ViewUtil.getTextViewValue(content, R.id.password));
      authWindow.setRememberPassword(ViewUtil.isCompoundChecked(content, R.id.store_password));
    }

    if (!paused) {
      authWindow.setCanceled(cancelled);

      authWindow.windowClosed();
    }
  }
コード例 #3
0
  /** {@inheritDoc} */
  @Override
  protected void onResume() {
    super.onResume();

    // Update add to contacts status
    updateAddToContactsStatus(ViewUtil.isCompoundChecked(getContentView(), R.id.addToContacts));

    flagPaused = false;
  }
コード例 #4
0
  private void displayLoadedProblems(ProblemAndSubmissionReceipt[] problemList) {
    GWT.log("Displaying " + problemList.length + " problems/submission receipts");

    // Sort by due date
    ProblemAndSubmissionReceipt[] list = new ProblemAndSubmissionReceipt[problemList.length];
    System.arraycopy(problemList, 0, list, 0, problemList.length);
    ViewUtil.sortProblemsByDueDate(list);

    cellTable.setRowData(Arrays.asList(list));
  }
コード例 #5
0
ファイル: ClassCoverageView.java プロジェクト: fukaiyas/hippo
  public ClassCoverageView(ClassCoverage cov) {

    super(new BorderLayout(), true);
    classCoverage = cov;
    lineInfo = new LineInfo(classCoverage);
    conditionInfo = new ConditionInfo(classCoverage);

    CoverageTable table = new CoverageTable(new CoverageTableModel(classCoverage));
    JScrollPane scroll = new JScrollPane(table);
    add(scroll, BorderLayout.CENTER);

    Box graphPanel = new Box(BoxLayout.Y_AXIS);
    graphPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(1, 0, 1, 2)));
    graphPanel.add(ViewUtil.createPanel("C0 :", lineInfo));
    graphPanel.add(ViewUtil.createPanel("C1 :", conditionInfo));
    add(graphPanel, BorderLayout.SOUTH);
  }
コード例 #6
0
  /** {@inheritDoc} */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.authorization_requested);

    long requestId = getIntent().getLongExtra(EXTRA_REQUEST_ID, -1);

    if (requestId == -1) throw new IllegalArgumentException();

    this.request = AuthorizationHandlerImpl.getRequest(requestId);

    View content = findViewById(android.R.id.content);

    ViewUtil.setTextViewValue(
        content,
        R.id.requestInfo,
        getString(
            R.string.service_gui_AUTHORIZATION_REQUESTED_INFO, request.contact.getDisplayName()));

    ViewUtil.setTextViewValue(
        content,
        R.id.addToContacts,
        getString(R.string.service_gui_ADD_AUTHORIZED_CONTACT, request.contact.getDisplayName()));

    Spinner contactGroupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);

    contactGroupSpinner.setAdapter(new MetaContactGroupAdapter(this));

    CompoundButton addToContactsCb = (CompoundButton) findViewById(R.id.addToContacts);

    addToContactsCb.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateAddToContactsStatus(isChecked);
          }
        });
  }
コード例 #7
0
  /** {@inheritDoc} */
  @Override
  protected void onDestroy() {
    super.onDestroy();

    if (flagPaused) {
      return;
    }

    if (ViewUtil.isCompoundChecked(getContentView(), R.id.addToContacts)
        && responseCode.equals(AuthorizationResponse.ACCEPT)) {
      // Add to contacts
      Spinner groupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);

      ContactListUtils.addContact(
          request.contact.getProtocolProvider(),
          (MetaContactGroup) groupSpinner.getSelectedItem(),
          request.contact.getAddress());
    }

    request.notifyResponseReceived(responseCode);
  }
コード例 #8
0
  /** {@inheritDoc} */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    long requestId = getIntent().getLongExtra(REQUEST_ID_EXTRA, -1);
    if (requestId == -1) throw new IllegalArgumentException();

    this.authWindow = AuthWindowServiceImpl.getAuthWindow(requestId);

    // Content view
    setContentView(R.layout.auth_window);
    View content = findViewById(android.R.id.content);

    // Server name
    String server = authWindow.getServer();

    // Title
    String title = authWindow.getWindowTitle();
    if (title == null) {
      title = getString(R.string.service_gui_AUTHENTICATION_WINDOW_TITLE, server);
    }
    setTitle(title);

    // Message
    String text = authWindow.getWindowText();
    if (text == null) {
      text = getString(R.string.service_gui_AUTHENTICATION_REQUESTED_SERVER, server);
    }
    ViewUtil.setTextViewValue(content, R.id.text, text);

    // Username filed and label
    if (authWindow.getUsernameLabel() != null)
      ViewUtil.setTextViewValue(content, R.id.username_label, authWindow.getUsernameLabel());

    ViewUtil.ensureEnabled(content, R.id.username, authWindow.isUserNameEditable());

    // Password filed and label
    if (authWindow.getPasswordLabel() != null)
      ViewUtil.setTextViewValue(content, R.id.password_label, authWindow.getPasswordLabel());

    ViewUtil.setCompoundChecked(content, R.id.store_password, authWindow.isRememberPassword());
    ViewUtil.ensureVisible(content, R.id.store_password, authWindow.isAllowSavePassword());
  }
コード例 #9
0
  @Test
  public void escapeViewParameters_should_escape_ampersand() {
    String view = ViewUtil.escapeViewParameters("test=%s&count=%d", "Bassie & Adriaan", 5);

    assertThat(view, is("test=Bassie+%26+Adriaan&count=5"));
  }
コード例 #10
0
 @Override
 public String getValue(ProblemAndSubmissionReceipt object) {
   return ViewUtil.formatDate(object.getProblem().getWhenDueAsDate());
 }
コード例 #11
0
 public BattaSprite(Context context) {
   Resources res = context.getResources();
   int currentBird = random.nextInt(DRAWABLE_BIRD.length);
   birds[0] = birds[2] = res.getDrawable(DRAWABLE_BIRD[currentBird][0]);
   birds[1] = res.getDrawable(DRAWABLE_BIRD[currentBird][1]);
   birds[3] = res.getDrawable(DRAWABLE_BIRD[currentBird][2]);
   birdHeight = ViewUtil.dipResourceToPx(context, R.dimen.bird_height);
   birdWidth = birdHeight * birds[0].getIntrinsicWidth() / birds[0].getIntrinsicHeight();
   width = ViewUtil.getScreenWidth(context);
   height = ViewUtil.getScreenHeight(context);
   int xPosition = ViewUtil.dipResourceToPx(context, R.dimen.bird_position_x);
   X = width / 2 - birdWidth / 2 - xPosition;
   currentHeight = height / 2 - birdHeight / 2;
   acceleration = ViewUtil.dipResourceToFloat(context, R.dimen.bird_acceleration);
   tapSpeed = ViewUtil.dipResourceToFloat(context, R.dimen.bird_tap_speed);
   maxHeight = height - ViewUtil.dipResourceToPx(context, R.dimen.ground_height);
   hitPaddingBottom = ViewUtil.dipResourceToPx(context, R.dimen.bird_hit_padding_bottom);
   hitPaddingTop = ViewUtil.dipResourceToPx(context, R.dimen.bird_hit_padding_top);
   hitPaddingLeft = ViewUtil.dipResourceToPx(context, R.dimen.bird_hit_padding_left);
   hitPaddingRight = ViewUtil.dipResourceToPx(context, R.dimen.bird_hit_padding_right);
   currentSpeed = 0;
 }
コード例 #12
0
ファイル: JqgUtility.java プロジェクト: miniants/miniarch
  public static synchronized List<JqgColModel> createColModel(
      final String beanName, final String beanClassName) {
    List<JqgColModel> colModels = new ArrayList<JqgColModel>();

    Class<?> clazz = RDBManager.getLocalSpaceConfig().getOrmBeanClass(beanName);
    // 分两类custom custom_element: $.remex.jgq.jRemexRefEle,
    // custom_value:$.remex.jgq.jRemexRefVal,custom_type:'jqgEditType'
    // 如果是JqgColModel本书,则在程序中定义配置
    if (clazz == JqgColModel.class) {
      for (int i = 0; i < JSonJqgColModels.length; i++) {
        //				JSONObject jcm = JSONObject.fromObject(JSonJqgColModels[i]);
        //				JqgColModel colModel = (JqgColModel) JSONObject.toBean(jcm, JqgColModel.class);
        JqgColModel colModel = JsonHelper.toJavaObject(JSonJqgColModels[i], JqgColModel.class);
        colModel.setBeanName(beanName);
        colModel.setFieldName(colModel.getName());
        colModel.setBeanClassName(clazz.getName());
        colModel.setIdx(colModel.getName());
        colModel.setColModelIndex(i);

        colModels.add(colModel);
      }

    } else {
      // 否则根据class的数据属性创建模型
      Map<String, Type> baseFields = SqlType.getFields(clazz, FieldType.TBase);

      for (String fieldName : baseFields.keySet()) {
        JqgColModel colModel = new JqgColModel();
        colModel.setBeanName(beanName);

        ViewUtil.buildCommConfig(clazz, fieldName, colModel);
        ViewUtil.buildEditConfig(clazz, fieldName, baseFields.get(fieldName), colModel);

        colModels.add(colModel);
      }
      Map<String, Type> objectFields = SqlType.getFields(clazz, FieldType.TObject);
      for (String fieldName : objectFields.keySet()) {
        JqgColModel colModel = new JqgColModel();
        colModel.setBeanName(beanName);

        ViewUtil.buildCommConfig(clazz, fieldName, colModel);
        ViewUtil.buildEditConfig(clazz, fieldName, objectFields.get(fieldName), colModel);
        colModels.add(colModel);
        colModel.setHidden(true); // 参照列隐藏起来。

        // 创建显示列
        if (!ViewUtil.NoRefColumn.contains(fieldName)) {
          JqgColModel colModel_ref = new JqgColModel();
          colModel_ref.setColModelIndex(colModel.getColModelIndex());
          colModel_ref.setWidth(colModel.getWidth());
          colModel_ref.setBeanName(beanName);
          ViewUtil.buildRefDisplayColumn(fieldName, objectFields.get(fieldName), colModel_ref);
          colModels.add(colModel_ref);
        }
      }
    }

    // 排序
    Collections.sort(colModels);

    return colModels;
  }
コード例 #13
0
 /**
  * Updates select group spinner status based on add to contact list checkbox state.
  *
  * @param isChecked <tt>true</tt> if "add to contacts" checkbox is checked.
  */
 private void updateAddToContactsStatus(boolean isChecked) {
   ViewUtil.ensureEnabled(getContentView(), R.id.selectGroupSpinner, isChecked);
 }