Package bibliothek.util.xml

Examples of bibliothek.util.xml.XElement


     
      for( Map.Entry<String, MultipleCDockableFactory<?, ?>> item : control.getRegister().getFactories().entrySet() ){
        conversion.getSituation().add( new CommonMultipleDockableFactory( item.getKey(), item.getValue(), control, perspective ) );
      }
     
      XElement xstations = root.getElement( "stations" );
      if( xstations == null ){
        throw new XException( "missing element 'stations'" );
      }
     
      Map<String, DockLayoutComposition> stations = conversion.getSituation().readCompositionsXML( xstations );
      factory.setStations( stations );
     
      for( DockLayoutComposition composition : stations.values() ){
        PerspectiveElement station = conversion.convert( composition );
        if( station instanceof CommonElementPerspective ){
          CStationPerspective stationPerspective = ((CommonElementPerspective)station).getElement().asStation();
          if( stationPerspective != null ){
            perspective.addStation( stationPerspective );
          }
        }
      }
     
      perspective.storeLocations();
     
      // read the last known location of all elements
      XElement xinvisible = root.getElement( "invisible" );
      if( xinvisible != null ){
        PropertyTransformer transformer = frontend.getPropertyTransformer();
        for( XElement xdockable : xinvisible.getElements( "dockable" )){
          String key = xdockable.getString( "key" );
          CDockablePerspective dockable = perspective.getDockable( key );
          if( dockable == null ){
            XElement xcontent = xdockable.getElement( "content" );
            if( xcontent != null ){
              PerspectiveElement element = conversion.convert( conversion.getSituation().readCompositionXML( xcontent ) );
                if( element instanceof CommonElementPerspective ){
                  dockable = ((CommonElementPerspective)element).getElement().asDockable();
                  if( dockable != null ){
                    perspective.putDockable( dockable );
                  }
                }   
            }
          }
          if( dockable != null ){
            XElement xlocation = xdockable.getElement( "location" );
            String locationRoot = xlocation.getString( "root" );
            DockableProperty location = transformer.readXML( xlocation );
            Path mode = new Path( xlocation.getString( "mode" ));
           
            ExtendedMode extendedMode = perspective.getLocationManager().getMode( mode );
            if( extendedMode != null ){
              dockable.getLocationHistory().add( extendedMode, new Location( mode, locationRoot, location ) );
            }
          }
        }
      }
     
     
      XElement xmodes = root.getElement( "modes" );
      if( xmodes == null ){
        throw new XException( "missing element 'modes'" );
      }
     
      ModeSettingsConverter<Location, Location> converter = new LocationSettingConverter( control.getOwner().getController() );
View Full Code Here


     * Writes the current and all known layouts into <code>file</code> in xml format.
     * @param file the file to write into
     * @throws IOException if the file is not writable
     */
    public void writeXML( File file ) throws IOException{
        XElement root = new XElement( "root" );
        getResources().writeXML( root );
        BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream( file ));
        XIO.writeUTF( root, out );
        out.close();
    }
View Full Code Here

     * @throws IOException if the file cannot be read
     * @throws XException if the xml file has the wrong structure
     */
    public void readXML( File file ) throws IOException{
        BufferedInputStream in = new BufferedInputStream( new FileInputStream( file ));
        XElement element = XIO.readUTF( in );
        in.close();
        readXML( element );
    }
View Full Code Here

  @SuppressWarnings("unchecked")
  public void write( CommonDockStationLayout layout, XElement element ){
    String factoryId = layout.getFactoryId();
    DockFactory<DockElement, ?, Object> factory = (DockFactory<DockElement, ?, Object>)control.intern().getDockFactory( factoryId );
    XElement content = layout.getLayoutXML();
    if( content == null ){
      layout.updateLayout( factory, null );
      DockLayout<?> data = layout.getLayout();
      if( data == null ){
        throw new XException( "data are null, but data were just updated" );
      }
      content = new XElement("content");
      factory.write( data.getData(), content );
    }
   
    String id = layout.getId();
    if( id != null ){
      element.addElement( "id" ).setString( id );
    }
    element.addElement( "root" ).setBoolean( layout.isRoot() );
   
    content.addString( "delegate", factoryId );
    element.addElement( content );
  }
View Full Code Here

  }
 
  @SuppressWarnings("unchecked")
  public CommonDockStationLayout read( XElement element, PlaceholderStrategy placeholders ){
    String id = null;
    XElement xid = element.getElement( "id" );
    if( xid != null ){
      id = xid.getString();
    }
   
    boolean root = element.getElement( "root" ).getBoolean();
   
    XElement xcontent = element.getElement( "content" );
    if( xcontent == null ){
      throw new XException( "missing content element" );
    }
   
    String factoryId = xcontent.getString( "delegate" );
    DockFactory<DockElement, ?, Object> factory = (DockFactory<DockElement, ?, Object>)control.intern().getDockFactory( factoryId );
    if( factory == null ){
      return new CommonDockStationLayout( id, root, factoryId, xcontent );
    }
    else{
View Full Code Here

        element.addElement( "root" ).setString( b.getRoot() );
        transformer.writeXML( b.getLocation(), element.addElement( "location" ) );
    }

    public Location readPropertyXML( XElement element ) {
      XElement xmode = element.getElement( "mode" );
      Path mode = null;
      if( xmode != null ){
        mode = new Path( xmode.getString() );
      }
      String root = element.getElement( "root" ).getString();
      DockableProperty location = transformer.readXML( element.getElement( "location" ) );
      if( mode == null ){
        mode = guessMode( location );
View Full Code Here

        }
  }
 
  @Override
  protected void rescueSettings( XElement element ){
        XElement states = element.getElement( "states" );
        if( states != null ){
            lastMaximizedLocation = new HashMap<String, B>();
            lastMaximizedMode = new HashMap<String, String>();

            XElement xmaximized = element.getElement( "maximized" );

            if( xmaximized != null ){
                for( XElement xitem : xmaximized.getElements( "item" )){
                    String key = xitem.getString( "id" );

                    XElement xmode = xitem.getElement( "mode" );
                    if( xmode != null ){
                        lastMaximizedMode.put( key, xmode.getString() );
                    }

                    XElement xlocation = xitem.getElement( "location" );
                    if( xlocation != null ){
                      XElement xcopy = xlocation.copy();
                      xcopy.addElement( "mode" ).setString( MaximizedMode.IDENTIFIER.toString() );
                      lastMaximizedLocation.put( key, getConverter().readPropertyXML( xcopy ) );
                    }
                }
            }
        }
View Full Code Here

        if( lastMaximizedMode != null ){
            keys.addAll( lastMaximizedMode.keySet() );
        }

        if( !keys.isEmpty() ){
            XElement xmaximized = element.addElement( "maximized" );

            for( String key : keys ){
                Path mode = lastMaximizedMode.get( key );
                Location location = lastMaximizedLocation.get( key );

                if( mode != null || location != null ){
                    XElement xitem = xmaximized.addElement( "item" );
                    xitem.addString( "id", key );
                    if( mode != null ){
                        xitem.addElement( "mode" ).setString( mode.toString() );
                    }
                    if( location != null ){
                      converter.writePropertyXML( converter.convertToSetting( location ), xitem.addElement( "location" ) );
                    }
                }
            }
        }
    }
View Full Code Here

    public <B> void read( XElement element, ModeSettingsConverter<Location, B> converter ) {
      lastMaximizedLocation = new HashMap<String, Location>();
      lastMaximizedMode = new HashMap<String, Path>();

      XElement xmaximized = element.getElement( "maximized" );

      if( xmaximized != null ){
        for( XElement xitem : xmaximized.getElements( "item" )){
          String key = xitem.getString( "id" );

          XElement xmode = xitem.getElement( "mode" );
          if( xmode != null ){
            lastMaximizedMode.put( key, new Path( xmode.getString() ));
          }

          XElement xlocation = xitem.getElement( "location" );
          if( xlocation != null ){
            lastMaximizedLocation.put( key, converter.convertToWorld( converter.readPropertyXML( xlocation ) ) );
          }
        }
      }
View Full Code Here

TOP

Related Classes of bibliothek.util.xml.XElement

Copyright © 2018 www.massapicom. 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.