Exemplo n.º 1
0
  public String create() {
    try {
      // Seteo la Tienda
      tienda = getTienda();
      current.setTiendaId(tienda);
      current.setUbicacion(pasillo);

      // Guardo el Boton
      getFacade().create(current);

      // Listado de Turnos
      List<Turno> turnos = getFacadeTurno().findAll();
      // Listado de Asesores
      List<Asesor> asesores = getFacadeAsesor().findAll();

      // Para el Boton creado se hace el insert en la tabla Distribucion
      for (Turno turno : turnos) {
        for (Asesor asesor : asesores) {
          Distribucion dist = new Distribucion();
          dist.setAsesorId(asesor.getId());
          dist.setTurnoId(turno.getId());
          dist.setBotonId(current.getId());
          dist.setStatus(JpaUtilities.HABILITADO);
          ejbFacadeDistribucion.create(dist);
        }
      }

      JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("BotonCreated"));
      return prepareList();
    } catch (Exception e) {
      JsfUtil.addErrorMessage(
          e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
      return null;
    }
  }
 private void persist(PersistAction persistAction, String successMessage) {
   if (selected != null) {
     setEmbeddableKeys();
     try {
       if (persistAction != PersistAction.DELETE) {
         getFacade().edit(selected);
       } else {
         getFacade().remove(selected);
       }
       JsfUtil.addSuccessMessage(successMessage);
     } catch (EJBException ex) {
       String msg = "";
       Throwable cause = ex.getCause();
       if (cause != null) {
         msg = cause.getLocalizedMessage();
       }
       if (msg.length() > 0) {
         JsfUtil.addErrorMessage(msg);
       } else {
         JsfUtil.addErrorMessage(
             ex, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
       }
     } catch (Exception ex) {
       Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
       JsfUtil.addErrorMessage(
           ex, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
     }
   }
 }
Exemplo n.º 3
0
  public String updateStatus() {
    try {
      tienda = getTienda();
      current.setTiendaId(tienda);
      current.setStatus(JpaUtilities.INHABILITADO);
      // Listado de Turnos
      List<Turno> turnos = getFacadeTurno().findAll();
      // Listado de Asesores
      List<Asesor> asesores = getFacadeAsesor().findAll();

      // Inhabilitar la Distribución para este Botón
      for (Turno turno : turnos) {
        for (Asesor asesor : asesores) {
          List<Distribucion> lista =
              ejbFacadeDistribucionExt.findDistribucionList(asesor, turno, current);
          for (Distribucion dist : lista) {
            dist.setStatus(JpaUtilities.INHABILITADO);
            ejbFacadeDistribucion.edit(dist);
          }
        }
      }
      getFacade().edit(current);
      JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("BotonUpdated"));
      return prepareList();
    } catch (Exception e) {
      JsfUtil.addErrorMessage(
          e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
      return null;
    }
  }
  @Override
  public void execute() {
    List<Criterio> criterios = seleccionPanel.getElementosSeleccionados();
    if (criterios.isEmpty()) {
      JOptionPane.showMessageDialog(
          null,
          java.util.ResourceBundle.getBundle("i18n.Bundle")
              .getString("SELECCIONE AL MENOS UN CRITERIO."),
          java.util.ResourceBundle.getBundle("i18n.Bundle").getString("LINCE"),
          JOptionPane.INFORMATION_MESSAGE);
      return;
    }
    if (Registro.getInstance().getRowCount() == 0) {
      JOptionPane.showMessageDialog(
          null,
          java.util.ResourceBundle.getBundle("i18n.Bundle")
              .getString("EL REGISTRO ACTUALMENTE ABIERTO NO TIENE NINGUNA FILA."),
          java.util.ResourceBundle.getBundle("i18n.Bundle").getString("LINCE"),
          JOptionPane.INFORMATION_MESSAGE);
      return;
    }

    File f = PathArchivos.getPathArchivoGuardar(null, null, null, "sds");

    if (f != null) {
      String contenido = Registro.getInstance().exportToSdisGseqMultievento(criterios);
      ControladorArchivos.getInstance().crearArchivoDeTexto(f, contenido);
    }
  }
Exemplo n.º 5
0
  /**
   * Loads the bundle (if not already loaded).
   *
   * @param name The name of the bundle to load.
   */
  private static void loadBundle(String name) {
    if (bundles.containsKey(name)) {
      return;
    }
    String resource = BUNDLES_PATH + "." + name;
    ResourceBundle bundle = null;
    try {
      LOG.debug("Loading " + resource);
      Locale locale = Locale.getDefault();
      bundle = ResourceBundle.getBundle(resource, locale);
    } catch (MissingResourceException e1) {
      LOG.debug("Resource " + resource + " not found in the default class loader.");

      Iterator iter = classLoaders.iterator();
      while (iter.hasNext()) {
        ClassLoader cl = (ClassLoader) iter.next();
        try {
          LOG.debug("Loading " + resource + " from " + cl);
          bundle = ResourceBundle.getBundle(resource, Locale.getDefault(), cl);
          break;
        } catch (MissingResourceException e2) {
          LOG.debug("Resource " + resource + " not found in " + cl);
        }
      }
    }

    bundles.put(name, bundle);
  }
  public static String loadMessage(final String code, final Object[] parameters) {
    // default message
    String errorMessage = "";
    try {
      // get access to the error messages bundle
      final ResourceBundle messagesBundle =
          ResourceBundle.getBundle(ERRORS_BUNDLE, Locale.getDefault());
      // construct the error message
      errorMessage = code + " - " + messagesBundle.getString(MESSAGE_PREFIX + code);

      // get access to the error message parameters bundle
      final ResourceBundle parametersBundle =
          ResourceBundle.getBundle(PARAMETERS_BUNDLE, Locale.getDefault());
      // loop for all parameters
      for (int i = 0; i < parameters.length; i++) {
        // get parameter value
        final String parameterValue =
            parametersBundle.getString(PARAMETER_PREFIX + (String) parameters[i]);
        // replace parameter placeholder in the error message string
        errorMessage = errorMessage.replaceAll("\\{" + (i + 1) + "}", parameterValue);
      }
    } catch (Exception e) {
      // log the exception
      LOGGER.warning(e);
    }

    return errorMessage;
  }
Exemplo n.º 7
0
 /**
  * Lazily initializes the bundles. This is (currently) necessary because this object may be
  * created before the locale to be used is known.
  */
 protected void initBundles() {
   if (commonBundle == null) {
     Locale locale = configuration.getLocale();
     this.commonBundle = ResourceBundle.getBundle(commonBundleName, locale);
     this.docletBundle = ResourceBundle.getBundle(docletBundleName, locale);
   }
 }
Exemplo n.º 8
0
 /**
  * Reads the properties of this action from a resource bundle of given base name.
  *
  * @throws MissingResourceException if no resource bundle could be found from <code>
  *     resourceBaseName</code>.
  */
 private void readActionPropertyValues(
     String resourceBaseName, String actionPrefix, ClassLoader pluginClassLoader) {
   ResourceBundle resource;
   if (pluginClassLoader != null) {
     resource = ResourceBundle.getBundle(resourceBaseName, Locale.getDefault(), pluginClassLoader);
   } else {
     resource = ResourceBundle.getBundle(resourceBaseName, Locale.getDefault());
   }
   String propertyPrefix = actionPrefix + ".";
   putPropertyValue(Property.NAME, getOptionalString(resource, propertyPrefix + Property.NAME));
   putPropertyValue(
       Property.SHORT_DESCRIPTION,
       getOptionalString(resource, propertyPrefix + Property.SHORT_DESCRIPTION));
   String smallIcon = getOptionalString(resource, propertyPrefix + Property.SMALL_ICON);
   if (smallIcon != null) {
     if (smallIcon.startsWith("/")) {
       smallIcon = smallIcon.substring(1);
     }
     putPropertyValue(Property.SMALL_ICON, new ResourceURLContent(pluginClassLoader, smallIcon));
   }
   String mnemonicKey = getOptionalString(resource, propertyPrefix + Property.MNEMONIC);
   if (mnemonicKey != null) {
     putPropertyValue(Property.MNEMONIC, Character.valueOf(mnemonicKey.charAt(0)));
   }
   String toolBar = getOptionalString(resource, propertyPrefix + Property.TOOL_BAR);
   if (toolBar != null) {
     putPropertyValue(Property.TOOL_BAR, Boolean.valueOf(toolBar));
   }
   putPropertyValue(Property.MENU, getOptionalString(resource, propertyPrefix + Property.MENU));
 }
Exemplo n.º 9
0
 private void persistCube(Cube cube, JsfUtil.PersistAction persistAction, String successMessage) {
   if (cube != null) {
     try {
       if (persistAction == JsfUtil.PersistAction.CREATE) {
         cubeEM.create(cube);
       } else if (persistAction == JsfUtil.PersistAction.DELETE) {
         cubeEM.remove(cube);
       } else {
         cubeEM.edit(cube);
       }
       JsfUtil.addSuccessMessage(successMessage);
     } catch (EJBException ex) {
       String msg = "";
       Throwable cause = ex.getCause();
       JsfUtil.setValidationFailed();
       ;
       if (cause != null) {
         msg = cause.getLocalizedMessage();
       }
       if (msg.length() > 0) {
         JsfUtil.addErrorMessage(msg);
       } else {
         JsfUtil.addErrorMessage(
             ex, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
       }
     } catch (Exception ex) {
       Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
       JsfUtil.addErrorMessage(
           ex, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
     }
   }
 }
Exemplo n.º 10
0
  public static String getString(
      String bundle1,
      String bundle2,
      String resourceId,
      Locale locale,
      ClassLoader loader,
      Object[] params) {
    String resource = null;
    ResourceBundle bundle;

    if (bundle1 != null) {
      bundle = ResourceBundle.getBundle(bundle1, locale, loader);
      if (bundle != null)
        try {
          resource = bundle.getString(resourceId);
        } catch (MissingResourceException ex) {
        }
    }

    if (resource == null) {
      bundle = ResourceBundle.getBundle(bundle2, locale, loader);
      if (bundle != null)
        try {
          resource = bundle.getString(resourceId);
        } catch (MissingResourceException ex) {
        }
    }

    if (resource == null) return null; // no match
    if (params == null) return resource;

    MessageFormat formatter = new MessageFormat(resource, locale);
    return formatter.format(params);
  }
Exemplo n.º 11
0
  private static void init() {
    if (resources == null) {

      // initialize resources

      Bundle mainPlugin = SQLExplorerPlugin.getDefault().getBundle();
      Bundle[] fragments = Platform.getFragments(mainPlugin);

      if (fragments == null) {
        fragments = new Bundle[0];
      }

      resources = new ResourceBundle[fragments.length + 1];

      resources[0] = ResourceBundle.getBundle(mainPlugin.getSymbolicName() + BUNDLE_NAME);

      for (int i = 0; i < fragments.length; i++) {
        try {
          resources[i + 1] = ResourceBundle.getBundle(fragments[i].getSymbolicName() + BUNDLE_NAME);
        } catch (Exception ignored) {
          // ignore it
        }
      }
    }
  }
Exemplo n.º 12
0
 public static final boolean checkTutorial(GUIRoot gui_root, int tutorial_number) {
   switch (tutorial_number) {
     case TUTORIAL_TOWER:
       if (!Renderer.isRegistered()) {
         ResourceBundle db = ResourceBundle.getBundle(DemoForm.class.getName());
         Form demo_form =
             new DemoForm(
                 gui_root,
                 Utils.getBundleString(db, "tower_unavailable_header"),
                 new GUIImage(512, 256, 0f, 0f, 1f, 1f, "/textures/gui/demo_towers"),
                 Utils.getBundleString(db, "tower_unavailable"));
         gui_root.addModalForm(demo_form);
         return false;
       }
     case TUTORIAL_CHIEFTAIN:
       if (!Renderer.isRegistered()) {
         ResourceBundle db = ResourceBundle.getBundle(DemoForm.class.getName());
         Form demo_form =
             new DemoForm(
                 gui_root,
                 Utils.getBundleString(db, "chieftain_unavailable_header"),
                 new GUIImage(512, 256, 0f, 0f, 1f, 1f, "/textures/gui/demo_chieftains"),
                 Utils.getBundleString(db, "chieftain_unavailable"));
         gui_root.addModalForm(demo_form);
         return false;
       }
     default:
   }
   return true;
 }
Exemplo n.º 13
0
 /**
  * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
  * call it in your code!
  *
  * @noinspection ALL
  */
 private void $$$setupUI$$$() {
   myRootPanel = new JPanel();
   myRootPanel.setLayout(new BorderLayout(0, 0));
   final JTabbedPane tabbedPane1 = new JTabbedPane();
   myRootPanel.add(tabbedPane1, BorderLayout.CENTER);
   final JPanel panel1 = new JPanel();
   panel1.setLayout(new BorderLayout(0, 0));
   tabbedPane1.addTab(
       ResourceBundle.getBundle("net/groboclown/idea/p4ic/P4Bundle")
           .getString("user.settings.connection"),
       panel1);
   final JScrollPane scrollPane1 = new JScrollPane();
   panel1.add(scrollPane1, BorderLayout.CENTER);
   myP4ConfigPanel = new P4ConfigPanel();
   scrollPane1.setViewportView(myP4ConfigPanel.$$$getRootComponent$$$());
   final JPanel panel2 = new JPanel();
   panel2.setLayout(new BorderLayout(0, 0));
   tabbedPane1.addTab(
       ResourceBundle.getBundle("net/groboclown/idea/p4ic/P4Bundle")
           .getString("user.settings.prefs"),
       panel2);
   final JScrollPane scrollPane2 = new JScrollPane();
   panel2.add(scrollPane2, BorderLayout.CENTER);
   myUserPreferencesPanel = new UserPreferencesPanel();
   scrollPane2.setViewportView(myUserPreferencesPanel.$$$getRootComponent$$$());
 }
Exemplo n.º 14
0
  /** Returns a Map of the known resources for the given locale. */
  private Map<String, Object> getResourceCache(Locale l) {
    Map<String, Object> values = resourceCache.get(l);

    if (values == null) {
      values = new TextAndMnemonicHashMap();
      for (int i = resourceBundles.size() - 1; i >= 0; i--) {
        String bundleName = resourceBundles.get(i);
        try {
          Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
          ResourceBundle b;
          if (c != null) {
            b = ResourceBundle.getBundle(bundleName, l, c);
          } else {
            b = ResourceBundle.getBundle(bundleName, l);
          }
          Enumeration keys = b.getKeys();

          while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();

            if (values.get(key) == null) {
              Object value = b.getObject(key);

              values.put(key, value);
            }
          }
        } catch (MissingResourceException mre) {
          // Keep looking
        }
      }
      resourceCache.put(l, values);
    }
    return values;
  }
Exemplo n.º 15
0
  private void cargarEdicion() {
    try {

      this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      Cliente cliente = ClienteNegocio.Obtener(id);
      if (cliente != null) {

        txtNombre.setText(cliente.getNombre());
        txtCalle.setText(cliente.getDireccion().getCalle());
        txtCelular.setText(cliente.getCelular());
        txtCiudad.setText(cliente.getDireccion().getCiudad());
        txtColonia.setText(cliente.getDireccion().getColonia());
        txtCorreo.setText(cliente.getCorreo());
        txtNumero.setText(cliente.getDireccion().getNumero());
        txtTelefono.setText(cliente.getTelefono());
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          this,
          ResourceBundle.getBundle("gdm/entidades/clases/resource").getString("ErrorMensaje"),
          ResourceBundle.getBundle("gdm/entidades/clases/resource").getString("TituloError"),
          JOptionPane.INFORMATION_MESSAGE);

    } finally {
      this.setCursor(Cursor.getDefaultCursor());
    }
  }
Exemplo n.º 16
0
  /** @see HttpServlet#HttpServlet() */
  public inputData() {
    super();

    ResourceBundle rdb = ResourceBundle.getBundle("properties.database");

    ResourceBundle rlb = ResourceBundle.getBundle("properties.dynamic_linker");

    this.db_name = rdb.getString("DB.NAME");
    this.db_host = rdb.getString("DB.HOST");
    this.db_user = rdb.getString("DB.USER");
    this.db_password = rdb.getString("DB.PASSWORD");
    this.db_metadata = rdb.getString("DB.METADATA.TABLE");

    String[] columnNames = rlb.getString("DYN.COLUMN.NAMES").split(",");
    String[] mapNames = rlb.getString("DYN.MAP.NAMES").split(",");
    String[] layerNames = rlb.getString("DYN.LAYER.NAMES").split(",");
    String[] typeNames = rlb.getString("DYN.MAP.TYPES").split(",");

    for (int i = 0; i < columnNames.length; i++) {
      String s[] = new String[3];

      s[0] = mapNames[i];
      s[1] = layerNames[i];
      s[2] = typeNames[i];

      this.dynamicMap.put(columnNames[i], s);
    }
  }
Exemplo n.º 17
0
  public void testGetLocalName() {
    ResourceBundle rb = ResourceBundle.getBundle("bundles/java/util/logging/res");
    Level l = new MockLevel("level1", 120, "bundles/java/util/logging/res");
    assertEquals(rb.getString("level1"), l.getLocalizedName());

    // regression test for HARMONY-2415
    rb =
        ResourceBundle.getBundle(
            "org.apache.harmony.logging.tests.java.util.logging.LevelTestResource");
    l =
        new MockLevel(
            "Level_error",
            120,
            "org.apache.harmony.logging.tests.java.util.logging.LevelTestResource");
    assertEquals(rb.getString("Level_error"), l.getLocalizedName());

    l = new MockLevel("bad name", 120, "res");
    assertEquals("bad name", l.getLocalizedName());

    l = new MockLevel("level1", 11120, "bad name");
    assertEquals("level1", l.getLocalizedName());

    l = new MockLevel("level1", 1120);
    assertEquals("level1", l.getLocalizedName());
  }
Exemplo n.º 18
0
 private static ResourceBundle getBundle(Locale locale) {
   try {
     return ResourceBundle.getBundle(BASE_NAME, locale);
   } catch (MissingResourceException e) {
     return ResourceBundle.getBundle(BASE_NAME);
   }
 }
Exemplo n.º 19
0
 /**
  * Creates a new StringManager for a given package. This is a private method and all access to it
  * is arbitrated by the static getManager method call so that only one StringManager per package
  * will be created.
  *
  * @param packageName Name of package to create StringManager for.
  */
 private StringManager(String packageName, Locale locale) {
   String bundleName = packageName + ".LocalStrings";
   ResourceBundle bnd = null;
   try {
     bnd = ResourceBundle.getBundle(bundleName, locale);
   } catch (MissingResourceException ex) {
     // Try from the current loader (that's the case for trusted apps)
     // Should only be required if using a TC5 style classloader structure
     // where common != shared != server
     ClassLoader cl = Thread.currentThread().getContextClassLoader();
     if (cl != null) {
       try {
         bnd = ResourceBundle.getBundle(bundleName, locale, cl);
       } catch (MissingResourceException ex2) {
         // Ignore
       }
     }
   }
   bundle = bnd;
   // Get the actual locale, which may be different from the requested one
   if (bundle != null) {
     this.locale = bundle.getLocale();
   } else {
     this.locale = null;
   }
 }
 private static ResourceBundle getBundle(String simpleName, Locale locale) {
   try {
     return ResourceBundle.getBundle(RESOURCES_PREFIX + simpleName + RESOURCES_SUFFIX, locale);
   } catch (MissingResourceException ex) {
     return ResourceBundle.getBundle(RESOURCES_PREFIX + simpleName, locale);
   }
 }
Exemplo n.º 21
0
  /**
   * Return a named ResourceBundle for a particular locale. This method mimics the behavior of
   * ResourceBundle.getBundle().
   *
   * @param className the name of the class that implements the resource bundle.
   * @return the ResourceBundle
   * @throws MissingResourceException
   */
  public static final XMLErrorResources loadResourceBundle(String className)
      throws MissingResourceException {

    Locale locale = Locale.getDefault();
    String suffix = getResourceSuffix(locale);

    try {

      // first try with the given locale
      return (XMLErrorResources) ResourceBundle.getBundle(className + suffix, locale);
    } catch (MissingResourceException e) {
      try // try to fall back to en_US if we can't load
      {

        // Since we can't find the localized property file,
        // fall back to en_US.
        return (XMLErrorResources) ResourceBundle.getBundle(className, new Locale("en", "US"));
      } catch (MissingResourceException e2) {

        // Now we are really in trouble.
        // very bad, definitely very bad...not going to get very far
        throw new MissingResourceException("Could not load any resource bundles.", className, "");
      }
    }
  }
Exemplo n.º 22
0
 private void deleteBorrowerPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_deleteBorrowerPerformed
   if (borrowersTable.getSelectedRowCount() > 0) {
     try {
       Borrower b =
           reader.getBorrower((Integer) model.getValueAt(borrowersTable.getSelectedRow(), 0));
       int result =
           JOptionPane.showConfirmDialog(
               this,
               java.util.ResourceBundle.getBundle("de/web/feitsch/fabian/loft/bundles/bundle")
                       .getString("gui.delete_question")
                   + b.getName()
                   + " "
                   + b.getSurname()
                   + "'?",
               java.util.ResourceBundle.getBundle("de/web/feitsch/fabian/loft/bundles/bundle")
                   .getString("gui.msgtitles.warning"),
               JOptionPane.YES_NO_OPTION);
       if (result == JOptionPane.YES_OPTION) {
         BorrowerBookQuest relationQuest = new BorrowerBookQuest();
         relationQuest.addNumericCondition(
             "borrower_id", b.getID(), DigitOperator.EQUAL, SQLOperator.AND);
         ArrayList<BorrowerBookRelation> relations =
             reader.getBorrowerBookRelations(relationQuest);
         for (BorrowerBookRelation relation : relations) {
           writer.deleteEntry(relation);
         }
         writer.deleteEntry(b);
         repaint();
       }
     } catch (SQLException ex) {
       Logger.getLogger(BorrowerPanel.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
 } // GEN-LAST:event_deleteBorrowerPerformed
  /**
   * Return a named ResourceBundle for a particular locale. This method mimics the behavior of
   * ResourceBundle.getBundle().
   *
   * @param className Name of local-specific subclass.
   * @param locale the locale to prefer when searching for the bundle
   */
  public static final XResourceBundle loadResourceBundle(String className, Locale locale)
      throws MissingResourceException {

    String suffix = getResourceSuffix(locale);

    // System.out.println("resource " + className + suffix);
    try {

      // first try with the given locale
      String resourceName = className + suffix;
      return (XResourceBundle) ResourceBundle.getBundle(resourceName, locale);
    } catch (MissingResourceException e) {
      try // try to fall back to en_US if we can't load
      {

        // Since we can't find the localized property file,
        // fall back to en_US.
        return (XResourceBundle) ResourceBundle.getBundle(XSLT_RESOURCE, new Locale("en", "US"));
      } catch (MissingResourceException e2) {

        // Now we are really in trouble.
        // very bad, definitely very bad...not going to get very far
        throw new MissingResourceException("Could not load any resource bundles.", className, "");
      }
    }
  }
Exemplo n.º 24
0
 /**
  * 方法名: </br> 详述: </br>修改build文件配置文件 开发人员:谭明</br> 创建时间:Apr 1, 2014</br>
  *
  * @param project_path
  * @throws Exception
  */
 public static void update_sysconfig_properties(String project_path) throws Exception {
   File file =
       new File(project_path + File.separator + "src" + File.separator + "sysConfig.properties");
   if (!file.exists()) {
     throw new Exception("项目sysConfig.properties文件不存在!");
   }
   InputStream in;
   try {
     in = new BufferedInputStream(new FileInputStream(file));
     Properties p = new Properties();
     p.load(in);
     in.close();
     p.remove("a");
     OutputStream fos = new FileOutputStream(file);
     p.setProperty("URL_SOCKET", ResourceBundle.getBundle("config").getString("socket_ip"));
     String url = ResourceBundle.getBundle("config").getString("push_url");
     p.setProperty("URL_SERVER", url.replaceAll("\\\\", ""));
     p.setProperty("URL_SOCKETPORT", ResourceBundle.getBundle("config").getString("socket_port"));
     p.store(fos, "Update URL_SOCKET、URL_SERVER、URL_SOCKETPORT value");
     fos.close();
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 25
0
 protected void handleModified() {
   if (Setup.isAutoSaveEnabled()) {
     storeValues();
     return;
   }
   if (OperationsXml.areFilesDirty()) {
     int result =
         javax.swing.JOptionPane.showOptionDialog(
             this,
             Bundle.getMessage("PromptQuitWindowNotWritten"),
             Bundle.getMessage("PromptSaveQuit"),
             javax.swing.JOptionPane.YES_NO_OPTION,
             javax.swing.JOptionPane.WARNING_MESSAGE,
             null, // icon
             new String[] {
               ResourceBundle.getBundle("jmri.util.UtilBundle").getString("WarnYesSave"), // NOI18N
               ResourceBundle.getBundle("jmri.util.UtilBundle").getString("WarnNoClose")
             }, // NOI18N
             ResourceBundle.getBundle("jmri.util.UtilBundle").getString("WarnYesSave"));
     if (result == javax.swing.JOptionPane.NO_OPTION) {
       return;
     }
     // user wants to save
     storeValues();
   }
 }
 public static void setBundle(Locale locale) {
   try {
     rb = ResourceBundle.getBundle(BUNDLE_NAME, locale);
   } catch (Exception e) {
     rb = ResourceBundle.getBundle(BUNDLE_NAME, Locale.ENGLISH);
   }
 }
Exemplo n.º 27
0
  public Lang() {
    // Warning this can be null. - ToDo check it
    final ClassLoader classLoader = ScoreboardStats.getInstance().getClassLoaderBypass();

    defaultMessages = ResourceBundle.getBundle("messages", Locale.getDefault(), classLoader);
    utfCharacters = ResourceBundle.getBundle("characters", Locale.getDefault(), classLoader);
  }
Exemplo n.º 28
0
 public BundleUtils() {
   try {
     _bundle = ResourceBundle.getBundle("com/jdevelopstation/l2ce/strings/Bundle");
   } catch (MissingResourceException e) {
     Locale.setDefault(Locale.ENGLISH);
     _bundle = ResourceBundle.getBundle("com/jdevelopstation/l2ce/strings/Bundle");
   }
 }
 protected ResourceBundle getBundle(final Locale locale) {
   try {
     return ResourceBundle.getBundle(bundleName, locale);
   } catch (final MissingResourceException mre) {
     // ignore the exception, fall back to explicit english locales. Fail, if that fails too.
     return ResourceBundle.getBundle(bundleName, Locale.ENGLISH);
   }
 }
Exemplo n.º 30
0
  private String localize(String key) {
    ResourceBundle rb;

    if (locale == null) rb = ResourceBundle.getBundle(NameGetter.class.getName());
    else rb = ResourceBundle.getBundle(NameGetter.class.getName(), locale);

    return rb.getString(key);
  }