public ConfirmationDialog(String caption, String description) {
    setCaption(caption);
    setModal(true);
    setResizable(false);
    setClosable(false);
    setWidth(400, Unit.PIXELS);
    setHeight(200, Unit.PIXELS);
    addCloseListener(this);

    okButton = UIHelper.createButton("ok", null, null, this);
    okButton.setId("confirmationDialog.button.ok");
    cancelButton = UIHelper.createButton("cancel", "cancels the current action.", null, this);
    cancelButton.setId("confirmationDialog.button.cancel");
    label.setDescription(description);

    final HorizontalLayout buttonLayout = new HorizontalLayout(okButton, cancelButton);
    buttonLayout.setSpacing(true);

    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setSizeFull();
    layout.addComponent(label);
    layout.addComponent(buttonLayout);
    layout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    setContent(layout);
    center();
  }
Example #2
0
  private Component iciciCodeMappings() {
    java.util.List<TableDisplayInput> displayInputs = new ArrayList<TableDisplayInput>();

    displayInputs.add(new StringDisplayInput("ICICICode", "getIciciCode"));
    displayInputs.add(new StringDisplayInput("StockCode", "getStockCode"));

    List<ICICICodeMapping> list = Controller.getIciciMappings();
    PMTableModel tableModel =
        new PMTableModel(list, displayInputs, false) {
          @Override
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return columnIndex == 1;
          }

          @Override
          public void setValueAt(Object value, int rowIndex, int columnIndex) {
            ((ICICICodeMapping) dataVOs.get(rowIndex)).setStock((StockVO) value);
          }
        };
    table = UIHelper.createTable(tableModel);
    table
        .getColumnModel()
        .getColumn(1)
        .setCellEditor(new DefaultCellEditor(UIHelper.createStockVOlistJCB()));
    return UIHelper.createScrollPane(table);
  }
  @Override
  public void bindView(View row, Context context, final Cursor cursor) {
    final StatusModel s = StatusModel.from(cursor);
    View root = row;
    final ItemView view = (ItemView) root.findViewById(R.id.list_item);

    setColor(cursor, view);
    UIHelper.setContent(view, s);
    UIHelper.setMetaInfo(view, s);
    UIHelper.setImageClick(view, s.getUserId());

    String headUrl = s.getUserProfileImageUrl();
    mImageLoader.displayImage(headUrl, view.getImageView());
  }
 /** return the index of choice from the category the user wants */
 private int getCategoryChoice(List<OptionCategory> categories) {
   System.out.println("Please choose the type of task you want to order:");
   for (int i = 1; i <= categories.size(); i++) {
     System.out.println(i + ") " + categories.get(i - 1).getName());
   }
   return helper.getIntFromUser(1, categories.size()) - 1;
 }
 /** Add an option to the ordersession. Return true if an option was added, else false. */
 private boolean selectOption(OptionCategory optionCategory) {
   System.out.println("Please choose the option you want to order:");
   for (int i = 0; i < optionCategory.getAmountOfOptions(); i++) {
     System.out.println((i + 1) + ") " + optionCategory.getOption(i).getName());
   }
   System.out.println((optionCategory.getAmountOfOptions() + 1) + ") Cancel this order");
   int choice = helper.getIntFromUser(1, optionCategory.getAmountOfOptions() + 1);
   if (choice == (optionCategory.getAmountOfOptions() + 1)) return false;
   getHandler().selectOption(optionCategory.getOption(choice));
   return true;
 }
Example #6
0
 private void init() {
   UIHelper.buildPanel(this);
   flagShowProgressBar = true;
   flagShowCancel = false;
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.NONE;
   gbc.insets = new Insets(10, 10, 10, 10);
   gbc.gridy = 0;
   gbc.gridx = 0;
   this.add(iciciCodeMappings(), gbc);
   gbc.gridy++;
   this.add(getActionButton("Save"), gbc);
 }
 /** Allows the user to order a single task. */
 public void run() {
   System.out.println(helper.SEPERATOR);
   boolean exitMenu = false;
   while (!exitMenu) {
     System.out.println(
         "What do you want to do?:"
             + helper.CRLF
             + "1) Order a single task"
             + helper.CRLF
             + "2) Exit this menu");
     int choice = helper.getIntFromUser(1, 2);
     if (choice == 2) {
       exitMenu = true;
     } else {
       System.out.println(helper.SEPERATOR);
       this.getHandler().startNewOrderSession();
       List<OptionCategory> categories = getHandler().getPossibleTasks();
       int categoryChoice = getCategoryChoice(categories);
       System.out.println(helper.SEPERATOR);
       boolean continueOrder = selectOption(categories.get(categoryChoice));
       if (continueOrder) {
         System.out.println("Please specify the deadline for this order.");
         System.out.println("On what day should the order be finished?");
         int day = helper.getIntFromUser(0, Integer.MAX_VALUE);
         System.out.println("On what hour should the order be finished?");
         int hours = helper.getIntFromUser(0, 23);
         System.out.println("On how many minutes past that hour should the order be finished?");
         int minutes = helper.getIntFromUser(0, 59);
         getHandler().specifyDeadline(day, hours, minutes);
         OrderView order = getHandler().submitSingleTaskOrder();
         System.out.println("Estimated Completion Time for this order is:");
         System.out.println(getHandler().getEstimatedCompletionTime(order).toString());
         helper.getEnter();
         System.out.println(helper.SEPERATOR);
       }
     }
   }
 }
Example #8
0
 public TextButton getUploadButton() {
   if (uploadButton == null) {
     uploadButton =
         UIHelper.createToolbarBtn(
             "Upload",
             Resources.IMAGES.upload(),
             new SelectEvent.SelectHandler() {
               @Override
               public void onSelect(SelectEvent selectEvent) {
                 editEntity();
               }
             });
   }
   return uploadButton;
 }
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case DOWN_UPDATE:
       mProgress.setProgress(progress);
       mProgressText.setText(tmpFileSize + "/" + apkFileSize);
       break;
     case DOWN_OVER:
       downloadDialog.dismiss();
       installApk();
       break;
     case DOWN_NOSDCARD:
       downloadDialog.dismiss();
       UIHelper.ToastMessage(
           mContext, R.layout.toastmessage_text, "无法下载安装文件,请检查SD卡是否挂载", Toast.LENGTH_SHORT);
       break;
   }
 };
Example #10
0
  static void populateEntryView(
      final View view,
      final Entry entry,
      final EntryManager entryManager,
      final UIHelper uiHelper) {
    final Resources resources = entryManager.getContext().getResources();

    // swipe
    final SwipeRelativeLayout swipeContainer =
        (SwipeRelativeLayout) view.findViewById(R.id.swipe_container);

    final View outterContainer = view.findViewById(R.id.outter_container);
    outterContainer.setPadding(0, 0, 0, 0);

    swipeContainer.setSwipeListener(
        new SwipeRelativeLayout.ISwipeListener() {

          private final int selectionFeedbackColor = resources.getColor(R.color.selection_feedback);

          public boolean swipeTopToBottom(final View v) {
            return false;
          }

          public boolean swipeRightToLeft(final View v) {

            view.setBackgroundColor(selectionFeedbackColor);
            entryManager.increaseUnreadLevel(entry);
            return true;
          }

          public boolean swipeLeftToRight(final View v) {

            view.setBackgroundColor(selectionFeedbackColor);
            entryManager.increaseReadLevel(entry);
            return true;
          }

          public boolean swipeBottomToTop(final View v) {
            return false;
          }

          public boolean onLongClick(final View v, final MotionEvent e) {
            return view.performLongClick();
          }

          public boolean onClick(final View v, final MotionEvent e) {
            return view.performClick();
          }
        });

    swipeContainer.setSwipeEnabeld(entryManager.isSwipeOnArticleDetailViewEnabled());
    swipeContainer.setBackgroundResource(R.drawable.article_header_background_thin);

    final TextView entryTitleView = (TextView) view.findViewById(R.id.entry_title);
    final TextView feedTitleView = (TextView) view.findViewById(R.id.feed_title);

    if (feedTitleView == null || entryTitleView == null) {
      Log.e(TAG, "feedTitleView or entryTitleView were null.");
      return;
    }

    if (entry == null) {
      Log.d(TAG, "entry was null");
      return;
    }

    if (entry.getFeedTitle() == null) {
      Log.e(TAG, "entry.getFeedTitle() was null.");
      return;
    }

    feedTitleView.setText(entry.getFeedTitle());
    entryTitleView.setText(entry.getTitle());

    if (entryManager.shouldTitlesBeEllipsized()) {
      entryTitleView.setEllipsize(TruncateAt.MIDDLE);
      entryTitleView.setLines(2);
    }

    // final int backgroundColor = resources.getColor(entry.isRead() ?
    // R.color.article_read_background
    // : R.color.article_unread_background);
    // final int textColor = resources.getColor(entry.isRead() ?
    // R.color.article_read_text
    // : R.color.article_unread_text);

    final TextView readIndicator = (TextView) view.findViewById(R.id.read_status_indicator);
    final int readIndicatorBackground =
        entryManager.isLightColorSchemeSelected()
            ? R.drawable.read_indicator
            : R.drawable.read_indicator_dark;
    final int pinnedIndicatorBackground =
        entryManager.isLightColorSchemeSelected()
            ? R.drawable.pinned_indicator
            : R.drawable.pinned_indicator_dark;

    int bgReadIndicator = -1;

    switch (entry.getReadState()) {
      case READ:
        bgReadIndicator = R.drawable.read_indicator_invisible;
        break;
      case UNREAD:
        bgReadIndicator = readIndicatorBackground;
        break;
      default:
        bgReadIndicator = pinnedIndicatorBackground;
    }

    readIndicator.setBackgroundResource(bgReadIndicator);

    // view.setBackgroundColor(backgroundColor);
    View container = view.findViewById(R.id.outter_container);
    if (entryManager.isLightColorSchemeSelected())
      container.setBackgroundColor(resources.getColor(R.color.article_read_background));
    else
      container.setBackgroundDrawable(
          resources.getDrawable(R.drawable.article_header_background_dark));

    // entryTitleView.setTextColor(textColor);
    // feedTitleView.setTextColor(textColor);

    //
    feedTitleView.setCompoundDrawablePadding(3);
    feedTitleView.setCompoundDrawablesWithIntrinsicBounds(
        resources.getDrawable(
            uiHelper.getArticleDownloadIndicatorDrawable(
                entry.getDownloaded(), entry.getDownloadPref(), resources)),
        null,
        null,
        null);

    // star check box
    final CheckBox starCheckBox = (CheckBox) view.findViewById(R.id.star_checkbox);
    starCheckBox.setVisibility(View.VISIBLE);
    starCheckBox.setChecked(entry.isStarred());
    starCheckBox.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(final View v) {
            entryManager.updateStarredState(entry, starCheckBox.isChecked());
          }
        });
    starCheckBox.requestFocus();

    if (false) {
      // changed
      final TextView changedView = (TextView) view.findViewById(R.id.article_changed);

      final boolean stateChanged = entry.isReadStatePending() || entry.isStarredStatePending();
      changedView.setText(stateChanged ? "*" : "");
    }
  }
Example #11
0
  private void generateSOS() {
    String plan = (String) jAttackPlan.getSelectedItem();
    int amount = Math.min(UIHelper.parseIntFromField(jAmount, 1), jAttack.getItemCount());
    SOSRequest sos = null;
    Tribe t = null;
    for (int i = 0; i < amount; i++) {
      Attack a = AttackManager.getSingleton().getManagedElement(plan, i);
      if (sos == null) {
        sos = new SOSRequest(a.getTarget().getTribe());
        t = a.getTarget().getTribe();
      }

      if (t != null && a.getTarget().getTribe().getId() == t.getId()) {
        TargetInformation info = sos.addTarget(a.getTarget());
        if (info.getTroops().isEmpty()) {
          Hashtable<UnitHolder, Integer> troops = getDefendingTroops();

          Enumeration<UnitHolder> keys = troops.keys();
          while (keys.hasMoreElements()) {
            UnitHolder key = keys.nextElement();
            info.addTroopInformation(key, troops.get(key));
          }
          info.setWallLevel(20);
        }
        if (jIncludeTypes.isSelected()) {
          info.addAttack(
              a.getSource(),
              a.getArriveTime(),
              a.getUnit(),
              a.getType() == Attack.FAKE_TYPE,
              a.getUnit().getPlainName().equals("snob"));
        } else {
          info.addAttack(a.getSource(), a.getArriveTime());
        }
      } else {
        System.err.println(
            "Tribe "
                + a.getTarget().getTribe()
                + "does not fit request tribe "
                + sos.getDefender());
      }
    }

    /**
     * [b]Dorf:[/b] [coord]112|87[/coord] [b]Wallstufe:[/b] 20 [b]Verteidiger:[/b] 23011 22928 0 266
     * 0 814 0 0 0
     *
     * <p>bäääng! [coord]282|306[/coord] --> Ankunftszeit: 11.10.11 14:37:57
     * [player]MrBlue76[/player]
     *
     * <p>[b]Dorf:[/b] [coord]114|84[/coord] [b]Wallstufe:[/b] 20 [b]Verteidiger:[/b] 9079 9080 0
     * 100 0 300 0 0 0
     *
     * <p>bäääng! [coord]318|272[/coord] --> Ankunftszeit: 11.10.11 14:42:49
     * [player]MrBlue76[/player] bäääng! [coord]211|345[/coord] --> Ankunftszeit: 11.10.11 16:45:37
     * [player]MrBlue76[/player]
     */
    Enumeration<Village> targets = sos.getTargets();
    StringBuilder b = new StringBuilder();
    SimpleDateFormat df;
    if (de.tor.tribes.util.ServerSettings.getSingleton().isMillisArrival()) {
      df = new SimpleDateFormat("dd.MM.yy HH:mm:ss:SSS");
    } else {
      df = new SimpleDateFormat("dd.MM.yy HH:mm:ss");
    }
    while (targets.hasMoreElements()) {
      Village target = targets.nextElement();
      b.append("[b]Dorf:[/b] ").append(target.toBBCode()).append("\n");
      TargetInformation ti = sos.getTargetInformation(target);
      b.append("[b]Wallstufe:[/b] ").append(ti.getWallLevel()).append("\n");
      b.append("[b]Verteidiger:[/b] ");
      for (UnitHolder unit : DataHolder.getSingleton().getUnits()) {
        b.append(ti.getTroops().get(unit)).append(" ");
      }
      b.append("\n\n");
      for (TimedAttack a : ti.getAttacks()) {
        if (jIncludeTypes.isSelected()) {
          if (a.isPossibleFake()) {
            b.append("Fake, ");
          } else {
            if (a.getUnit() != null) {
              if (a.getUnit().getPlainName().equals("axe")) {
                b.append("Axt, ");
              } else if (a.getUnit().getPlainName().equals("light")) {
                b.append("LKAV, ");
              } else if (a.getUnit().getPlainName().equals("snob")) {
                b.append("AG, ");
              } else if (a.getUnit().getPlainName().equals("heavy")) {
                b.append("SKAV, ");
              } else if (a.getUnit().getPlainName().equals("sword")) {
                b.append("Schwert, ");
              } else if (a.getUnit().getPlainName().equals("catapult")) {
                b.append("Kata, ");
              }
            }
          }
        }
        b.append(a.getSource().getName())
            .append(" ")
            .append(a.getSource().toBBCode())
            .append(" --> Ankunftszeit: ")
            .append(df.format(new Date(a.getlArriveTime())))
            .append(" ")
            .append(a.getSource().getTribe().toBBCode())
            .append("\n");
      }
      b.append("\n");
    }
    sendToClipboard(b.toString());
  }
Example #12
0
  /** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */
  public void actionPerformed(ActionEvent e) {
    if ("menu_options_tbs_more".equals(e.getActionCommand())) {
      // goto "more TBS" page
      try {
        WebBrowser.launchBrowser(
            "http://sourceforge.net/project/showfiles.php?group_id="
                + IdConst.PROJECT_ID
                + "&package_id=107882");
      } catch (Exception e1) {
        JOptionPane.showOptionDialog(
            MagicUIComponents.magicForm,
            LanguageManager.getString("error") + " : " + e1.getMessage(),
            LanguageManager.getString("web-pb"),
            JOptionPane.OK_OPTION,
            JOptionPane.INFORMATION_MESSAGE,
            UIHelper.getIcon("wiz_update_error.gif"),
            null,
            null);
      }
      return;
    }
    if ("menu_options_tbs_update".equals(e.getActionCommand())) {
      // update the current TBS
      XmlConfiguration.main(new String[] {"-g", MToolKit.tbsName});
      return;
    }
    if ("menu_options_tbs_rebuild".equals(e.getActionCommand())) {
      /*
       * rebuild completely the current TBS
       */
      XmlConfiguration.main(new String[] {"-f", "-g", MToolKit.tbsName});
      return;
    }

    // We change the TBS

    // Wait for confirmation
    if (JOptionPane.YES_OPTION
        == JOptionPane.showOptionDialog(
            MagicUIComponents.magicForm,
            LanguageManager.getString("warn-disconnect"),
            LanguageManager.getString("disconnect"),
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            UIHelper.getIcon("wiz_update.gif"),
            null,
            null)) {

      // Save the current settings before changing TBS
      Magic.saveSettings();

      // Copy this settings file to the profile directory of this TBS
      final File propertyFile = MToolKit.getFile(IdConst.FILE_SETTINGS);
      try {
        FileUtils.copyFile(propertyFile, MToolKit.getTbsFile(IdConst.FILE_SETTINGS_SAVED, false));

        // Delete the current settings file of old TBS
        propertyFile.delete();

        // Load the one of the new TBS
        abstractMainForm.setMdb(e.getActionCommand());
        Configuration.loadTemplateFile(
            MToolKit.getTbsFile(IdConst.FILE_SETTINGS_SAVED, false).getAbsolutePath());

        // Copy the saved configuration of new TBS
        FileUtils.copyFile(MToolKit.getTbsFile(IdConst.FILE_SETTINGS_SAVED, false), propertyFile);
        Log.info("Successful TBS swith to " + MToolKit.tbsName);

        // Restart the game
        System.exit(IdConst.EXIT_CODE_RESTART);
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    }
  }