@Test
  public void getResourceClassInfoByResource_nonExistentReferences_shouldFail() {
    authenticateSystemResource();

    final char[] password = generateUniquePassword();
    final Resource accessorResource = generateAuthenticatableResource(password);

    generateResourceClass(false, false);

    // authenticate and verify
    accessControlContext.authenticate(accessorResource, PasswordCredentials.newInstance(password));

    try {
      accessControlContext.getResourceClassInfoByResource(Resources.getInstance(-999L));
      fail("getting resource class info by resource for non-existent resource should have failed");
    } catch (IllegalArgumentException e) {
      assertThat(e.getMessage().toLowerCase(), containsString("not found"));
    }
    try {
      accessControlContext.getResourceClassInfoByResource(Resources.getInstance("invalid"));
      fail(
          "getting resource class info by resource for non-existent external resource reference should have failed");
    } catch (IllegalArgumentException e) {
      assertThat(e.getMessage().toLowerCase(), containsString("not found"));
    }
    try {
      accessControlContext.getResourceClassInfoByResource(Resources.getInstance(-999L, "invalid"));
      fail(
          "getting resource class info by resource for mismatched internal/external resource ids should have failed");
    } catch (IllegalArgumentException e) {
      assertThat(e.getMessage().toLowerCase(), containsString("not resolve"));
    }
  }
Пример #2
0
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    LetItRain.server = sender.getServer();

    World world;
    Player target;
    String outputMsg = LetItRain.dPunishMsg;

    if (args != null && args.length > 0) target = Resources.isPlayer(args[0]);
    else {
      Resources.privateMsg(sender, "Please enter the name of the player you want to strike");
      return true;
    }

    if (target == null) {
      Resources.privateMsg(sender, "Please enter a valid player name");
      return true;
    }

    // Permissions
    if (!sender.hasPermission("LetItRain.strike")) return true;

    Location location = target.getLocation();

    world = target.getWorld();

    world.strikeLightning(location);
    target.setHealth(0);

    outputMsg = outputMsg.replaceAll(Pattern.quote("[player]"), target.getName());

    if (!outputMsg.isEmpty()) Resources.broadcast(outputMsg);

    return true;
  }
 private void setStatusButton(int priority, int state) {
   String tooltip = Resources.get("Standard Priority");
   ImageIcon icon = standardIcon;
   if (state == TrainModel.STATE_STOPPED) {
     icon = stoppedIcon;
     tooltip = Resources.get("Stopped");
   } else {
     switch (priority) {
       case TrainModel.PRIORITY_EXPRESS:
         icon = expressIcon;
         tooltip = Resources.get("Express Priority");
         break;
       case TrainModel.PRIORITY_NORMAL:
         icon = standardIcon;
         tooltip = Resources.get("Standard Priority");
         break;
       case TrainModel.PRIORITY_SLOW:
         icon = slowIcon;
         tooltip = Resources.get("Slow Priority");
         break;
       default:
         throw new IllegalStateException();
     }
   }
   statusJButton.setToolTipText(tooltip);
   statusJButton.setIcon(icon);
 }
  /**
   * The "Add Identifier" button is clicked on the panel.
   *
   * @param identifierTable
   */
  protected void addIdentifierActionPerformed(
      DomainSortableTable identifierTable, Resources model) {
    ArchDescComponentIdentifiers newArchDescComponentIdentifier;
    DomainEditor dialog =
        new DomainEditor(
            ArchDescComponentIdentifiers.class,
            editorField.getParentEditor(),
            "Add Identifier",
            new ArchDescComponentIdentifiersFields());
    dialog.setNavigationButtonListeners((ActionListener) editorField.getParentEditor());
    dialog.setNewRecord(true);

    boolean done = false;
    int returnStatus;
    while (!done) {
      newArchDescComponentIdentifier = new ArchDescComponentIdentifiers(model);
      dialog.setModel(newArchDescComponentIdentifier, null);
      returnStatus = dialog.showDialog();

      if (returnStatus == JOptionPane.OK_OPTION) {
        model.addArchDescComponentIdentifier(newArchDescComponentIdentifier);
        identifierTable.updateCollection(model.getArchDescComponentIdentifiers());
        done = true;
      } else if (returnStatus == StandardEditor.OK_AND_ANOTHER_OPTION) {
        model.addArchDescComponentIdentifier(newArchDescComponentIdentifier);
        identifierTable.updateCollection(model.getArchDescComponentIdentifiers());
      } else {
        done = true;
      }
    }
  }
Пример #5
0
  /** Builds the Network panel. */
  protected JPanel buildNetworkPanel() {
    JGridBagPanel p = new JGridBagPanel();
    p.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));

    JLabel proxyLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_HTTP_PROXY));
    JLabel hostLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_HOST));
    JLabel portLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_PORT));
    JLabel colonLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_COLON));
    Font f = hostLabel.getFont();
    float size = f.getSize2D() * 0.85f;
    f = f.deriveFont(size);
    hostLabel.setFont(f);
    portLabel.setFont(f);
    host = new JTextField();
    host.setPreferredSize(new Dimension(200, 20));
    port = new JTextField();
    port.setPreferredSize(new Dimension(40, 20));

    p.add(proxyLabel, 0, 0, 1, 1, EAST, NONE, 0, 0);
    p.add(host, 1, 0, 1, 1, WEST, HORIZONTAL, 0, 0);
    p.add(colonLabel, 2, 0, 1, 1, WEST, NONE, 0, 0);
    p.add(port, 3, 0, 1, 1, WEST, HORIZONTAL, 0, 0);
    p.add(hostLabel, 1, 1, 1, 1, WEST, NONE, 0, 0);
    p.add(portLabel, 3, 1, 1, 1, WEST, NONE, 0, 0);

    return p;
  }
Пример #6
0
  private void setContextOptions(GameOptions gameType) {
    JPopupMenu contextOptions = new JPopupMenu();

    JMenu addPieces = new JMenu(Resources.getString(Resources.ADD_PIECE));

    String[] pieces = gameType.getPieceList();
    for (int i = 0; i < pieces.length; i++) {
      JMenuItem newPieceName = new JMenuItem(pieces[i]);

      newPieceName.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.out.println(((JMenuItem) e.getSource()).getText());
            }
          });

      addPieces.add(newPieceName);
    }

    contextOptions.add(addPieces);

    contextOptions.add(new JMenuItem(Resources.getString(Resources.DELETE_PIECE)));

    this.setComponentPopupMenu(contextOptions);
  }
Пример #7
0
  private static void setScreenMode(
      String title, Resources resources, int width, int height, boolean resizable) {
    Video.setWindowTitle(title);

    // According to the SDL1.2 docs, windows MUST be given a 32x32 image. How very quaint (windows
    // is s***e).
    // For good looking OSes, we should try to use a bigger icon if there is one.
    // Note that these must be bmp (yuck!), and not png, because it uses SDL_LoadBMP. Annoying!
    String filename32 = resources.resolveFilename("icon32.bmp");
    String filename = resources.resolveFilename("icon.bmp");

    if (System.getProperty("os.name").startsWith("Windows")) {
      filename = filename32;
    }

    try {
      if (new File(filename).exists()) {
        Video.setWindowIcon(filename);
      } else if (new File(filename32).exists()) {
        Video.setWindowIcon(filename32);
      }
    } catch (Exception e) {
      // Do nothing
    }

    try {
      int flags = Video.SWSURFACE | Video.DOUBLEBUF;
      if (resizable) {
        flags = flags | Video.RESIZABLE;
      }
      Video.setMode(width, height, 32, flags);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #8
0
 protected Vector loadRecipes() {
   String filename = parametersFile();
   Vector recipes = (Vector) Resources.getResource("PARSED: " + filename);
   if (recipes == null) {
     StringBuffer str =
         new CMFile(Resources.buildResourcePath("skills") + filename, null, true).text();
     recipes = loadList(str);
     if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!");
     else {
       Vector pleaseAdd1 = new Vector();
       Vector pleaseAdd2 = new Vector();
       for (int r = 0; r < recipes.size(); r++) {
         Vector V = (Vector) recipes.elementAt(r);
         if (V.size() > 0) {
           Vector V1 = (Vector) V.clone();
           Vector V2 = (Vector) V.clone();
           String name = (String) V.elementAt(RCP_FINALNAME);
           V1.setElementAt("Hard " + name, RCP_FINALNAME);
           V1.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 5), RCP_LEVEL);
           V2.setElementAt("Studded " + name, RCP_FINALNAME);
           V2.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 11), RCP_LEVEL);
           pleaseAdd1.addElement(V1);
           pleaseAdd2.addElement(V2);
         }
       }
       for (int i = 0; i < pleaseAdd1.size(); i++) recipes.addElement(pleaseAdd1.elementAt(i));
       for (int i = 0; i < pleaseAdd2.size(); i++) recipes.addElement(pleaseAdd2.elementAt(i));
     }
     Resources.submitResource("PARSED: " + filename, recipes);
   }
   return recipes;
 }
Пример #9
0
  public static Bitmap[] load(String src, int width, int height) {
    Bitmap[] texture = null;
    InputStream is = null;
    AssetManager am = resources.getAssets();
    String[] nameOfBoxs = null;

    try {
      nameOfBoxs = am.list(src);
    } catch (IOException e) {
      Log.d("GraphicMaster", "Culd not find folder " + src);
    }

    Log.d("GraphicMaster", "NameOfBoxs.length = " + nameOfBoxs.length);
    texture = new Bitmap[nameOfBoxs.length];

    for (int i = 0; i < nameOfBoxs.length; i++) {
      try {
        is = resources.getAssets().open(src + "/" + nameOfBoxs[i]);

        texture[i] = BitmapFactory.decodeStream(is);

        /*	if(width > 0 && height > 0)
        texture[i] = Bitmap.createScaledBitmap(texture[i], width, height, false);*/

        Log.d(
            "GraphicMaster",
            "Scaled from "
                + new Integer((int) (texture[i].getWidth())).toString()
                + " "
                + new Integer((int) (texture[i].getHeight())).toString()
                + " to "
                + new Integer((int) (texture[i].getWidth() * GameSettings.widthM)).toString()
                + " "
                + new Integer((int) (GameSettings.heightM * texture[i].getWidth())).toString());

        Log.d(
            "GraphicMaster",
            "Scale"
                + new Double(GameSettings.widthM).toString()
                + " "
                + new Double(GameSettings.heightM).toString());

        if (GameSettings.widthM != 1 && GameSettings.heightM != 1)
          texture[i] =
              Bitmap.createScaledBitmap(
                  texture[i],
                  (int) (texture[i].getWidth() * GameSettings.widthM),
                  (int) (texture[i].getHeight() * GameSettings.heightM),
                  false);

      } catch (IOException e) {
        Log.d("GraphicMaster", "Culd not read: " + src + nameOfBoxs[i]);
      }
    }

    return texture;
  }
Пример #10
0
 private String getCellStyleName() {
   String style;
   if (isMultilineStyle()) {
     style = RESOURCES.style().bDescriptionCell__html();
   } else {
     style = RESOURCES.style().bDescriptionCell__text();
   }
   return style;
 }
  public void testEnsureInjected() {
    Resources r = GWT.create(Resources.class);
    assertTrue(r.empty().ensureInjected());

    r = GWT.create(Resources.class);
    assertFalse(r.empty().ensureInjected());

    r = GWT.create(ChildResources.class);
    assertTrue(r.empty().ensureInjected());
  }
Пример #12
0
  public JobConfig toJobConfig(CRJob crJob) {
    JobConfig jobConfig = new JobConfig(crJob.getName());
    if (crJob.getEnvironmentVariables() != null)
      for (CREnvironmentVariable crEnvironmentVariable : crJob.getEnvironmentVariables()) {
        jobConfig.getVariables().add(toEnvironmentVariableConfig(crEnvironmentVariable));
      }

    List<CRTask> crTasks = crJob.getTasks();
    Tasks tasks = jobConfig.getTasks();
    if (crTasks != null)
      for (CRTask crTask : crTasks) {
        tasks.add(toAbstractTask(crTask));
      }

    Tabs tabs = jobConfig.getTabs();
    if (crJob.getTabs() != null)
      for (CRTab crTab : crJob.getTabs()) {
        tabs.add(toTab(crTab));
      }

    Resources resources = jobConfig.resources();
    if (crJob.getResources() != null)
      for (String crResource : crJob.getResources()) {
        resources.add(new Resource(crResource));
      }

    ArtifactPlans artifactPlans = jobConfig.artifactPlans();
    if (crJob.getArtifacts() != null)
      for (CRArtifact crArtifact : crJob.getArtifacts()) {
        artifactPlans.add(toArtifactPlan(crArtifact));
      }

    ArtifactPropertiesGenerators artifactPropertiesGenerators = jobConfig.getProperties();
    if (crJob.getArtifactPropertiesGenerators() != null)
      for (CRPropertyGenerator crPropertyGenerator : crJob.getArtifactPropertiesGenerators()) {
        artifactPropertiesGenerators.add(
            new ArtifactPropertiesGenerator(
                crPropertyGenerator.getName(),
                crPropertyGenerator.getSrc(),
                crPropertyGenerator.getXpath()));
      }

    if (crJob.isRunOnAllAgents()) jobConfig.setRunOnAllAgents(true);
    else {
      Integer count = crJob.getRunInstanceCount();
      if (count != null) jobConfig.setRunInstanceCount(count);
      // else null - meaning simple job
    }

    if (crJob.getTimeout() != null) jobConfig.setTimeout(Integer.toString(crJob.getTimeout()));
    // else null - means default server-wide timeout

    return jobConfig;
  }
Пример #13
0
  /**
   * Creates an instance of <tt>StatusSubMenu</tt>.
   *
   * @param tray a reference of the parent <tt>Systray</tt>
   */
  public StatusSubMenu(SystrayServiceJdicImpl tray) {

    parentSystray = tray;

    this.setText(Resources.getString("setStatus"));
    this.setIcon(Resources.getImage("statusMenuIcon"));

    /* makes the menu look better */
    this.setPreferredSize(new java.awt.Dimension(28, 24));

    this.init();
  }
Пример #14
0
  protected List<List<String>> loadRecipes() {
    String filename = parametersFile();
    List<List<String>> recipes =
        (List<List<String>>) Resources.getResource("PARSED_RECIPE: " + filename);
    if (recipes == null) {
      StringBuffer str =
          new CMFile(Resources.buildResourcePath("skills") + filename, null, true).text();
      recipes = loadList(str);
      if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!");
      else {
        List<List<String>> pleaseAdd = new Vector();
        for (int r = 0; r < recipes.size(); r++) {
          List<String> V = recipes.get(r);
          if (V.size() > 0) {
            String name = (String) V.get(RCP_FINALNAME);
            int baseLevel = CMath.s_int((String) V.get(RCP_LEVEL)) + 2;

            List<String> V1 = new XVector<String>(V);
            V1.set(RCP_FINALNAME, "Cuirbouli " + name);
            V1.set(RCP_LEVEL, "" + (baseLevel + 37));
            pleaseAdd.add(V1);

            V1 = new XVector<String>(V);
            V1.set(RCP_FINALNAME, "Reinforced " + name);
            V1.set(RCP_LEVEL, "" + (baseLevel + 45));
            pleaseAdd.add(V1);

            V1 = new XVector<String>(V);
            V1.set(RCP_FINALNAME, "Masterwork " + name);
            V1.set(RCP_LEVEL, "" + (baseLevel + 54));
            pleaseAdd.add(V1);

            V1 = new XVector<String>(V);
            V1.set(RCP_FINALNAME, "Laminar " + name);
            V1.set(RCP_LEVEL, "" + (baseLevel + 63));
            pleaseAdd.add(V1);

            V1 = new XVector<String>(V);
            V1.set(RCP_FINALNAME, "Battlemoulded " + name);
            V1.set(RCP_LEVEL, "" + (baseLevel + 72));
            pleaseAdd.add(V1);

            V.set(RCP_FINALNAME, "Designer " + name);
            V.set(RCP_LEVEL, "" + (baseLevel + 30));
          }
        }
        for (int i = 0; i < pleaseAdd.size(); i++) recipes.add(pleaseAdd.get(i));
      }
      Resources.submitResource("PARSED_RECIPE: " + filename, recipes);
    }
    return recipes;
  }
Пример #15
0
  private void setupHomeDir(String homeString) {
    if (homeString == null) {
      homeString = sysProps.getProperty("swingri.home");
    }

    if (homeString != null) {
      dataDir = new File(homeString);
    } else {
      userHome = new File(sysProps.getProperty("user.home"));
      String dataDirStr = props.getString("application.datadir", DEFAULT_HOME_DIR);
      dataDir = new File(userHome, dataDirStr);
    }

    if (!dataDir.isDirectory()) {
      String path = dataDir.getAbsolutePath();
      boolean create;
      if (props.hasUserRejectedCreatingLocalDataDir()) {
        create = false;
      } else if (getBoolean("application.showLocalStorageDialogs", true)) {
        create =
            Resources.showConfirmDialog(
                null,
                messageBundle,
                "fontManager.properties.title",
                "manager.properties.createNewDirectory",
                path);
        if (!create) props.setUserRejectedCreatingLocalDataDir();
      } else {
        // Always create local-storage directory if show user prompt dialog setting is false.
        create = true;
      }

      if (!create) {
        dataDir = null;
      } else {
        dataDir.mkdirs();
        if (!dataDir.isDirectory()) {
          // check to make sure that dialog should be shown on the error.
          if (getBoolean("application.showLocalStorageDialogs", true)) {
            Resources.showMessageDialog(
                null,
                JOptionPane.ERROR_MESSAGE,
                messageBundle,
                "fontManager.properties.title",
                "manager.properties.failedCreation",
                dataDir.getAbsolutePath());
          }
          dataDir = null;
        }
      }
    }
  }
Пример #16
0
  /**
   * Build an abstract tree from an unmarshalled WADL file
   *
   * @param a the application element of the root WADL file
   * @param rootFile the URI of the root WADL file. Other WADL files might be included by reference.
   * @return the resource element that corresponds to the root of the resource tree
   */
  protected ResourceNode buildAst(Application a, URI rootFile) {
    for (String ifaceId : ifaceMap.keySet()) {
      buildResourceTypes(ifaceId, a);
    }

    Resources r = a.getResources();
    ResourceNode n = new ResourceNode(a, r);
    if (r != null) {
      for (Resource child : r.getResource()) {
        buildResourceTree(n, child, rootFile);
      }
    }

    return n;
  }
Пример #17
0
 @Provides
 @Singleton
 public EventStyle getEventStyle(Resources resources) {
   EventStyle eventStyle = resources.eventStyle();
   eventStyle.ensureInjected();
   return eventStyle;
 }
Пример #18
0
  @Test
  public void ordered() {
    Set<String> list = Resources.list();
    Set<String> ordered = new TreeSet<>(list);

    assertThat(list).isEqualTo(ordered);
  }
Пример #19
0
 public List<Book> parse(InputStream is) throws Exception {
   /*
    * Validate against schema before it triggers implementation.
    */
   StringBuffer xmlFile = new StringBuffer();
   BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
   String line = null;
   while ((line = bufferedReader.readLine()) != null) {
     xmlFile.append(line);
   }
   String xml = xmlFile.toString();
   // validate against schema.
   try {
     URL schema = Resources.getResource("/catalog.xsd");
     Validator validator =
         SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema")
             .newSchema(schema)
             .newValidator();
     Source source = new StreamSource(new CharArrayReader(xml.toCharArray()));
     validator.validate(source);
   } catch (Exception e) {
     this.errorHolder.addErrorMessage("Validation Error", e);
     return null;
   }
   // parse file into catalog
   ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
   // ask extending class to parse
   return parseInternal(bais);
 }
Пример #20
0
  static {
    assertTrue(Resources.loadAllResources());

    switch (OSFamily.getSystemOSFamily()) {
      case Windows:
        STDIN_1 = windows_builder_stdin_1;
        STDERR_1 = windows_builder_stderr_1;
        STDOUT_1 = windows_builder_stdout_1;

        ENV_VAR_ECHO = windows_builder_env_var_echo;

        STDERR_ECHO_REPEAT = windows_builder_stderr_echo_repeat;
        STDOUT_ECHO_REPEAT = windows_builder_stdout_echo_repeat;
        STDOUT_STDERR_ECHO_REPEAT = windows_builder_stdout_stderr_echo_repeat;
        break;
      case Unix:
        STDIN_1 = unix_builder_stdin_1;
        STDERR_1 = unix_builder_stderr_1;
        STDOUT_1 = unix_builder_stdout_1;

        ENV_VAR_ECHO = unix_builder_env_var_echo;

        STDERR_ECHO_REPEAT = unix_builder_stderr_echo_repeat;
        STDOUT_ECHO_REPEAT = unix_builder_stdout_echo_repeat;
        STDOUT_STDERR_ECHO_REPEAT = unix_builder_stdout_stderr_echo_repeat;
        break;
      default:
        throw new UnsupportedOperationException(
            "This operating system (" + OSFamily.getSystemOSFamily() + ") is unsupported");
    }
  }
Пример #21
0
 @Test
 public void testTomato() {
   Image expectedIcon = mock(Image.class);
   when(resources.image(resourceName(TRAY_ICON_SIZE))).thenReturn(expectedIcon);
   Image icon = trayIcons.tomato();
   assertThat(icon, equalTo(expectedIcon));
 }
Пример #22
0
 /**
  * Retrieve the ColorStateList for the attribute at <var>index</var>. The value may be either a
  * single solid color or a reference to a color or complex {@link
  * android.content.res.ColorStateList} description.
  *
  * @param index Index of attribute to retrieve.
  * @return ColorStateList for the attribute, or null if not defined.
  */
 public ColorStateList getColorStateList(int index) {
   final TypedValue value = mValue;
   if (getValueAt(index * AssetManager.STYLE_NUM_ENTRIES, value)) {
     return mResources.loadColorStateList(value, value.resourceId);
   }
   return null;
 }
Пример #23
0
 public Template parseTemplate(String template) throws URISyntaxException {
   this.template = template;
   builder = new Builder(template);
   builder.setHasScheme(false);
   builder.setHasAuthority(
       false); // Assume no until found otherwise.  If true, will cause // in output URL.
   builder.setIsAuthorityOnly(false);
   builder.setIsAbsolute(
       false); // Assume relative until found otherwise.  If true, will cause leading / in output
   // URL.
   builder.setIsDirectory(
       false); // Assume a file path until found otherwise.  If true, will cause trailing / in
   // output URL.
   builder.setHasQuery(
       false); // Assume no ? until found otherwise.  If true, will cause ? in output URL.
   builder.setHasFragment(
       false); // Assume no # until found otherwise.  If true, will cause # in output URL.
   Matcher match = PATTERN.matcher(template);
   if (match.matches()) {
     consumeSchemeMatch(match);
     consumeAuthorityMatch(match);
     consumePathMatch(match);
     consumeQueryMatch(match);
     consumeFragmentMatch(match);
     fixNakedAuthority();
   } else {
     throw new URISyntaxException(template, RES.parseTemplateFailureReason(template));
   }
   return builder.build();
 }
Пример #24
0
 @Test
 public void testDefaultTomatoIcon() {
   Image defaultIcon = mock(Image.class);
   when(resources.image(resourceName(TrayIcons.DEFAULT_ICON_SIZE))).thenReturn(defaultIcon);
   Image icon = trayIcons.tomato();
   assertThat(icon, equalTo(defaultIcon));
 }
Пример #25
0
  @Test
  public void testContinuousToString() {
    ResourceId resource = Resources.continuous(D1, P1, Bandwidth.class).id();

    assertThat(
        resource.toString(), is(Arrays.asList(D1, P1, Bandwidth.class.getSimpleName()).toString()));
  }
Пример #26
0
  private boolean setupDefaultProperties() {
    fontProps = new Properties();

    // create program properties with default
    try {
      // If you application needs to look at other font directories
      // they can be added via the readSystemFonts method.
      fontManager.readSystemFonts(null);
      fontProps = fontManager.getFontProperties();

    } catch (Exception ex) {
      if (getBoolean("application.showLocalStorageDialogs", true)) {
        Resources.showMessageDialog(
            null,
            JOptionPane.ERROR_MESSAGE,
            messageBundle,
            "fontManager.properties.title",
            "manager.properties.session.readError",
            ex);
      } // log the error
      if (logger.isLoggable(Level.WARNING)) {
        logger.log(Level.WARNING, "Error loading default properties", ex);
      }
      return false;
    }
    return true;
  }
Пример #27
0
 public synchronized void saveProperties() {
   if (ownLock()) {
     try {
       FileOutputStream out = new FileOutputStream(propertyFile);
       try {
         fontProps.store(out, "-- ICEpf Font properties --");
       } finally {
         out.close();
       }
       recordMofifTime();
     } catch (IOException ex) {
       // check to make sure the storage relate dialogs can be shown
       if (getBoolean("application.showLocalStorageDialogs", true)) {
         Resources.showMessageDialog(
             null,
             JOptionPane.ERROR_MESSAGE,
             messageBundle,
             "fontManager.properties.title",
             "manager.properties.saveError",
             ex);
       }
       // log the error
       if (logger.isLoggable(Level.WARNING)) {
         logger.log(Level.WARNING, "Error saving font properties cache", ex);
       }
     }
   }
 }
Пример #28
0
  public void start() {
    System.out.println("SplitMan starting...");
    try {
      Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
      Display.setResizable(false);
      Display.setVSyncEnabled(true);
      Display.setTitle("SplitMan");
      Display.create();
    } catch (Exception e) {
      e.printStackTrace();
      Display.destroy();
      System.exit(1);
    }
    WIDTH = Display.getWidth();
    HEIGHT = Display.getHeight();
    System.out.println("Display: " + WIDTH + " x " + HEIGHT);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    Resources.load();

    setScreen(new GuiGame());
    System.out.println("SplitMan started");
  }
Пример #29
0
 public Template(String uri) {
   Path existing = Resources.findExistingPath(uri);
   if (existing == null) {
     throw new IllegalArgumentException("Template not found " + uri);
   }
   this.path = existing;
 }
  @Test
  public void getResourceClassInfoByResource_nulls() {
    final char[] password = generateUniquePassword();
    final Resource accessorResource = generateAuthenticatableResource(password);

    generateResourceClass(false, false);

    // authenticate and verify
    accessControlContext.authenticate(accessorResource, PasswordCredentials.newInstance(password));

    try {
      accessControlContext.getResourceClassInfoByResource(null);
      fail("getting resource class info by resource for null resource should have failed");
    } catch (NullPointerException e) {
      assertThat(e.getMessage().toLowerCase(), containsString("resource required"));
    }
    try {
      accessControlContext.getResourceClassInfoByResource(Resources.getInstance(null));
      fail(
          "getting resource class info by resource for null internal/external resource ids should have failed");
    } catch (IllegalArgumentException e) {
      assertThat(
          e.getMessage().toLowerCase(),
          containsString("resource id and/or external id is required"));
    }
  }