Пример #1
0
  @Override
  public void postInitialize() {
    // beanModule is not yet defined (we must put this after initialize)
    ////// System.out.println("iniciant amb "+this.getBeanModule().getIniParameters());
    cfg = new Cfg(this.getBeanModule().getIniParameters(), coreCfg);
    ////// System.out.println("DONE");

    DefaultComboBoxModel model1 = new DefaultComboBoxModel();
    model1.addElement("Totes les categories");
    int selection = 0;
    int i = 0;
    for (AnuncisDefinition b : AnuncisDefinition.getMapDefined().values()) {
      model1.addElement(b.getAnuncisTypeName());
      if (b.getAnuncisTypeId() == PreferencesBean.getInstance(cfg).getTypeAnuncis()) {
        selection = i;
      }
      i += 1;
    }
    jComboBox1.setModel(model1);
    jComboBox1.setSelectedIndex(selection);
  }
Пример #2
0
    @Override
    protected Void doInBackground() throws Exception {
      isLoading = true;
      int sel = jComboBox1.getSelectedIndex();
      int type = -1;
      if (sel > 0) {
        type = AnuncisDefinition.getMapDefined().get(sel - 1).getAnuncisTypeId();
      }

      int orderType = 1; // 0=post date, 1=first event date
      if (jRadioButtonMenuItem2.isSelected()) {
        orderType = 0;
      }
      ArrayList<AnunciBean> listAnuncis = loadAnuncis(type, orderType);
      ////// System.out.println("anuncis has been loaded");

      MyAnunci first = null;
      int k = 0;
      vigents = 0;
      for (AnunciBean bean : listAnuncis) {
        ////// System.out.println(this.getStray()+"STRAY");
        ////// System.out.println(this.getStray().getFrame()+"FRAME");

        MyAnunci ma =
            new MyAnunci(bean, AnuncisModule.this.getStray().getFrame(), AnuncisModule.this, cfg);

        if (k == 0) {
          first = ma;
        }
        jTaskPane1.add(ma);
        k += 1;
        if (ma.isExpanded()) {
          vigents += 1;
        }
      }

      if (listAnuncis != null && listAnuncis.isEmpty()) {
        JTaskPaneGroup emptyLabel = new JTaskPaneGroup();
        ////////////////            emptyLabel.setCollapsable(false);
        emptyLabel.setExpanded(false);
        emptyLabel.setTitle("No s'han trobat anuncis");

        jTaskPane1.add(emptyLabel);
      }

      listAnuncis.clear();
      listAnuncis = null;
      jTaskPane1.revalidate();
      jTaskPane1.repaint();
      isLoading = false;
      return null;
    }
Пример #3
0
  // This method generates user customization for framework delegation
  @Override
  public ArrayList<UserPreferencesBean> getUserModulePreferences() {
    userModulePreferences = new ArrayList<UserPreferencesBean>();

    JComboBox combo = new JComboBox();
    DefaultComboBoxModel modelCombo = new DefaultComboBoxModel();
    modelCombo.addElement("[-1] Tots");

    HashMap<Integer, AnuncisDefinition> mapDefined = AnuncisDefinition.getMapDefined();
    for (int id : mapDefined.keySet()) {
      modelCombo.addElement("[" + id + "] " + mapDefined.get(id).getAnuncisTypeName());
    }

    combo.setModel(modelCombo);
    // Put selection
    String property = coreCfg.getUserPreferences().getProperty("anuncis.showTypeAnuncis", "-1");
    for (int i = 0; i < modelCombo.getSize(); i++) {
      if (modelCombo.getElementAt(i).toString().startsWith("[" + property)) {
        combo.setSelectedIndex(i);
        break;
      }
    }

    combo.setActionCommand("anuncis.showTypeAnuncis");

    UserPreferencesBean bean = new UserPreferencesBean();
    bean.setName("Mostra tipus anuncis");
    bean.setFileKey("anuncis.showTypeAnuncis");
    bean.setComponent(combo);
    userModulePreferences.add(bean);

    ///////////////////////////////////
    combo = new JComboBox();
    modelCombo = new DefaultComboBoxModel();
    modelCombo.addElement("none");
    modelCombo.addElement("*suro.png");
    File file =
        new File(
            CoreCfg.contextRoot
                + File.separator
                + "applications"
                + File.separator
                + "org-iesapp-apps-anuncis"
                + File.separator
                + "icons");
    File[] listFiles = file.listFiles();
    for (File f : listFiles) {
      modelCombo.addElement(f.getName());
    }

    combo.setModel(modelCombo);
    // Put selection
    property = coreCfg.getUserPreferences().getProperty("anuncis.background", "*suro.png");
    for (int i = 0; i < modelCombo.getSize(); i++) {
      if (modelCombo.getElementAt(i).toString().startsWith(property)) {
        combo.setSelectedIndex(i);
        break;
      }
    }

    combo.setActionCommand("anuncis.background");

    bean = new UserPreferencesBean();
    bean.setName("Fons del tauler");
    bean.setFileKey("anuncis.background");
    bean.setComponent(combo);
    userModulePreferences.add(bean);

    ///////////////////////////////////
    combo = new JComboBox();
    modelCombo = new DefaultComboBoxModel();
    modelCombo.addElement("5");
    modelCombo.addElement("10");
    modelCombo.addElement("15");
    modelCombo.addElement("20");
    modelCombo.addElement("*");
    combo.setModel(modelCombo);
    combo.setActionCommand("anuncis.showNumberAnuncis");

    combo.setSelectedItem(
        coreCfg.getUserPreferences().getProperty("anuncis.showNumberAnuncis", cfg.onStartLoad));

    bean = new UserPreferencesBean();
    bean.setName("Fons del tauler");
    bean.setFileKey("anuncis.showNumberAnuncis");
    bean.setComponent(combo);
    userModulePreferences.add(bean);

    return userModulePreferences;
  }