Examples of XProject


Examples of net.xoetrope.xui.XProject

   * @param isPng true for a png file, false for a tiff file
   * @return the png file name
   */
  protected String convertSvg( String name, int width, int height, boolean isPng )
  {
    XProject currentProject = XProjectManager.getCurrentProject();

    int pos = name.indexOf( ".svg" );
    try {
      URL sourceUrl = currentProject.getUrl( name );
      if ( BuildProperties.DEBUG ) {
        if ( sourceUrl == null ) {
          DebugLogger.logError( "Missing synth resource:" + name );
          return "synth/blank.png";                   
        }
      }
      String srcUrlStr = sourceUrl.toString();

      if ( imageConverter == null ) {
        // If batik is not available don't try reading the SVG
        Class clazz = null;
        if ( !isPng )
          clazz = Class.forName( "net.xoetrope.optional.laf.synth.batik.TiffTranscoderWrapper" );
        else 
          clazz = Class.forName( transcoderClassName.trim() );
        if ( clazz == null )
          return name;

        imageConverter = (ImageConverter)clazz.newInstance();
      }

      String resName = name.substring( 0, pos ) + imageConverter.getOutputExt();
      int svgDirPos = resName.indexOf( "svg/" );
      if ( svgDirPos >= 0 )
        resName = resName.substring( 0, svgDirPos ) + resName.substring( svgDirPos + 4 );
      String outUrlStr = srcUrlStr.substring( 0, srcUrlStr.indexOf( name )) + resName;
      try {
        File sourceFile = new File( sourceUrl.toURI());
        File targetFile = new File( new URL( outUrlStr ).toURI());
        if ( targetFile.lastModified() > sourceFile.lastModified()) {
          DebugLogger.trace( "File up-to-date, no need to convert: " + name );               
          return resName;
        }
      }
      catch ( MalformedURLException mfue ) {}

      if ( outUrlStr.indexOf( "file:" ) == 0 )
        outUrlStr = outUrlStr.substring( 6 );


      BufferedInputStream bis = currentProject.getBufferedInputStream( srcUrlStr );
      if ( bis != null ) {
        if ( svgPreprocessor == null )
          svgPreprocessor = (SvgPreprocessor)SvgPreprocessor.class.newInstance();

        String str = svgPreprocessor.process( bis );
View Full Code Here

Examples of net.xoetrope.xui.XProject

  public XRemoteClassLoader( XProject project )
  {
    super();

    try {
      XProject currentProject = project;
      int numClassLoadersPaths = new Integer( currentProject.getStartupParam( "NumRemoteClassLoaderPaths" ) ).intValue();
      String paths[] = new String[ numClassLoadersPaths ];
      for ( int i = 0; i < numClassLoadersPaths; i++ )
        paths[ i ] = currentProject.getStartupParam( "RemoteClassLoaderPath" + ( i + 1 ));
      setSources( paths );
    }
    catch ( Exception e ) {
      if ( BuildProperties.DEBUG )
        DebugLogger.logError( "Unable to load class loader: " + e.getMessage() );
View Full Code Here

Examples of net.xoetrope.xui.XProject

   */
  public static void installLaf()
  {
    try {
      SynthLookAndFeel synth = new SynthLookAndFeel();
      XProject currentProject = XProjectManager.getCurrentProject();
      String synthConfigFile = currentProject.getStartupParam( "SynthConfigFile" );
      String synthResourceLoader = currentProject.getStartupParam( "SynthResourceLoader" );
      if (( synthResourceLoader == null ) || ( synthResourceLoader.length() == 0 ))
        synthResourceLoader = "net.xoetrope.optional.laf.synth.SynthStub";
      SynthLafInstaller.class.getClassLoader().getResource( synthResourceLoader );
      Class resourceLoader = null;
      try {
        SynthClassLoader scl = new SynthClassLoader( SynthLafInstaller.class.getClassLoader());
        resourceLoader = scl.findClass( synthResourceLoader );
        String s = currentProject.getStartupParam( "SynthImageConveter" );
        if (( s != null ) && ( s.length() > 0 ))
          scl.setConvertClassName( s );
 
        s = currentProject.getStartupParam( "SynthOverwriteImages" );
        if (( s != null ) && ( s.length() > 0 ))
          scl.setOverwriteImages( Boolean.parseBoolean( s ));
      }
      catch ( Throwable e ) {
        resourceLoader = Class.forName( synthResourceLoader.trim() );
      }
      //loadStubClass( "net.xoetrope.optional.laf.synth.SynthStub" );

      BufferedInputStream bis = null;


      // Does the file need processing?
      int pos;
      if (( pos = synthConfigFile.indexOf( ".xsynth" )) > 0 ) {
        String outputFile = synthConfigFile.substring( 0, pos ) + ".synth";

          // Try to find a preprocessor for the file, at runtime this load should fail as the preprocessor
          // will not be present.
          try {
              FilePreprocessor processor = (FilePreprocessor)Class.forName( "net.xoetrope.optional.laf.synth.SynthPreprocessor" ).newInstance();
              DebugLogger.trace( currentProject.findResourceAsString( synthConfigFile ));
              bis = currentProject.getBufferedInputStream ( synthConfigFile );
              String processedStr = processor.process( bis );
              ByteArrayInputStream bais = new ByteArrayInputStream( processedStr.getBytes() );
              bis = new BufferedInputStream( bais );

              // Save the config file
              outputFile = getOutputPath( currentProject, "resources", synthConfigFile.substring( 0, pos ), ".synth" );
              FileWriter fw = new FileWriter( outputFile  );
              fw.write ( processedStr );
              fw.flush();
              fw.close();
          }
          catch ( Exception e )
          {
              // Assume that the file has previously been processed
              bis = currentProject.getBufferedInputStream ( outputFile );
          }
      }
      else
         bis = currentProject.getBufferedInputStream ( synthConfigFile );

      DebugLogger.log( "Synth config file: " + currentProject.findResourceAsString( synthConfigFile ));
      synth.load( bis, resourceLoader );
      UIManager.setLookAndFeel( synth );
    }
    catch ( Exception ex ) {
      ex.printStackTrace();
View Full Code Here

Examples of net.xoetrope.xui.XProject

   * @return the XResourceManager instance
   * @deprecated since 1.0.3
   */
  public static XResourceManager getInstance()
  {
    XProject currentProject = XProjectManager.getCurrentProject();
    XResourceManager rm = (XResourceManager)currentProject.getObject ( "ResourceManager" );
    if ( rm == null )
      rm = new XResourceManager( currentProject );
    return rm;
  }
View Full Code Here

Examples of net.xoetrope.xui.XProject

   * invoked, or the object being repaired
   * @param t throwable the exception that was trapped, or null
   */
  public boolean fixError( XProject project, Object sourceObj, Throwable t )
  {
    final XProject theProject = project;
   
    SwingUtilities.invokeLater( new Runnable()
    {
      public void run()
      {
        int rc = JOptionPane.showConfirmDialog( null, "The XDataSourceClass entry is missing from the startup file, do you want to add it now?",
                                                      "Correct the startup properties",
                                                      JOptionPane.YES_NO_OPTION );
        if ( rc == JOptionPane.YES_OPTION ) {
          theProject.setStartupParam( "XDataSourceClass", "net.xoetrope.optional.data.XOptionalDataSource" );

          InputStream is = theProject.getBufferedInputStream( theProject.getStartupFile());
          Properties startSettings = new Properties();
          try {
            startSettings.load( is );
            startSettings.put( "XDataSourceClass", "net.xoetrope.optional.data.XOptionalDataSource" );
            is.close();


            URL startupFile = theProject.findResource( theProject.getStartupFile());
            File outputFile = new File( startupFile.getFile());
            BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream( outputFile.toString() ));

            startSettings.store( bos, "XUI startup properties, automatically modified by XUI at " + new java.util.Date().toString());
            bos.flush();
View Full Code Here

Examples of net.xoetrope.xui.XProject

    setupComponents( page, source, pageClass );
  }
 
  private void setupComponents( PageSupport page, Object source, Class pageClass )
  { 
    XProject currentProject = page.getProject();
    XuiBuilder builder = (XuiBuilder)currentProject.getObject( "Builder" );
   
    Field[] fields = pageClass.getDeclaredFields();
    for ( Field field : fields ) {    
      boolean isAccessible = field.isAccessible();
      if ( !isAccessible ) {
View Full Code Here

Examples of net.xoetrope.xui.XProject

    super.setUp();

    xBaseModel = new XBaseModel();

    XApplet so = new XApplet();
    XProject project = XProjectManager.getCurrentProject( so );
    XDataSource ds = new XDataSource( project );
    InputStream is = ds.getClass().getClassLoader().getResourceAsStream( "test/xui/data/people.xml" );

    XmlElement src = XmlSource.read( new BufferedReader( new InputStreamReader( is ) ) );
    src.setName( "people" );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.