Java Code Examples for de.lessvoid.nifty.Nifty#scheduleEndOfFrameElementAction()

The following examples show how to use de.lessvoid.nifty.Nifty#scheduleEndOfFrameElementAction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GUIEditor.java    From niftyeditor with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new gui from a file and current assetFolder as assets
 * @param nifty a valid Nifty instace @see Nifty
 * @throws ParserConfigurationException if controller failed to create
 * a valid document instance
 * @throws IOException
 * @throws  SAXException
 * @throws Exception if nifty can't create the gui
 * @return A string with the elements that weren't loaded
 * 
 */
public String createNewGui(Nifty nifty ,File filename) throws ParserConfigurationException, IOException, SAXException, NoProductException, Exception{
   String assets= ".";
   if(this.gui != null){
      assets = this.gui.getAssetFolder().getPath(); 
   }
   GUIReader reader = new GUIReader(nifty);
   String res = "";
   this.gui = reader.readGUI(filename);
   this.gui.setAssetFolder(new File(assets));
   res = reader.getTagNotLoaded();
   final GScreen screen =this.getGui().gettopScreen();
   for(String sel : nifty.getAllScreensName()){
                nifty.removeScreen(sel);
   }
   writer = new GUIWriter(gui);
  nifty.scheduleEndOfFrameElementAction(new Reload(nifty, screen.getID()), new EndNotify() {

        @Override
        public void perform() {
           setChanged();
           notifyObservers(new ReloadGuiEvent(gui));
           clearChanged();
        }
    });
   currentL=gui.getTopLayer();
   currentS=gui.gettopScreen();
   currentlayers.addAll(gui.getLayers());
   dragDropManager = new NiftyDDManager(nifty);
   this.model.setCurentGUI(gui);
   return res;
        
}
 
Example 2
Source File: GUIEditor.java    From niftyeditor with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new gui from a file with given assetsFolder
 * @param nifty a valid Nifty instace @see Nifty
 * @throws ParserConfigurationException if controller failed to create
 * a valid document instance
 * @throws IOException
 * @throws  SAXException
 * @throws Exception if nifty can't create the gui
 * @return A string with the elements that weren't loaded
  */
 public String createNewGui(Nifty nifty ,File filename,File assetsFolder) throws ParserConfigurationException, IOException, SAXException, NoProductException, Exception{
   GUIReader reader = new GUIReader(nifty);
   String res = "";
   this.gui = reader.readGUI(filename);
   this.gui.setAssetFolder(assetsFolder);
   res = reader.getTagNotLoaded();
   final GScreen screen =this.getGui().gettopScreen();
   for(String sel : nifty.getAllScreensName()){
                nifty.removeScreen(sel);
   }
   writer = new GUIWriter(gui);
  nifty.scheduleEndOfFrameElementAction(new Reload(nifty, screen.getID()), new EndNotify() {

        @Override
        public void perform() {
           setChanged();
           notifyObservers(new ReloadGuiEvent(gui));
           clearChanged();
        }
    });
   currentL=gui.getTopLayer();
   currentS=gui.gettopScreen();
   currentlayers.addAll(gui.getLayers());
   dragDropManager = new NiftyDDManager(nifty);
   this.model.setCurentGUI(gui);
   return res;
        
}
 
Example 3
Source File: GUIEditor.java    From niftyeditor with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new gui from a file with given assetsFolder
 * @param nifty a valid Nifty instace @see Nifty
 * @throws ParserConfigurationException if controller failed to create
 * a valid document instance
 * @throws IOException
 * @throws  SAXException
 * @throws Exception if nifty can't create the gui
 * @return A string with the elements that weren't loaded
  */
 public String createNewGui(Nifty nifty , InputStream stream,File assetsFolder) throws ParserConfigurationException, IOException, SAXException, NoProductException, Exception{
   GUIReader reader = new GUIReader(nifty);
   String res = "";
   this.gui = reader.readGUI(stream);
   this.gui.setAssetFolder(assetsFolder);
   res = reader.getTagNotLoaded();
   final GScreen screen =this.getGui().gettopScreen();
   for(String sel : nifty.getAllScreensName()){
                nifty.removeScreen(sel);
   }
   writer = new GUIWriter(gui);
  nifty.scheduleEndOfFrameElementAction(new Reload(nifty, screen.getID()), new EndNotify() {

        @Override
        public void perform() {
           setChanged();
           notifyObservers(new ReloadGuiEvent(gui));
           clearChanged();
        }
    });
   currentL=gui.getTopLayer();
   currentS=gui.gettopScreen();
   currentlayers.addAll(gui.getLayers());
   dragDropManager = new NiftyDDManager(nifty);
   this.model.setCurentGUI(gui);
   return res;
        
}
 
Example 4
Source File: GUIEditor.java    From niftyeditor with Apache License 2.0 5 votes vote down vote up
/**
 * Refresh the current gui . It causes a call to nifty.fromXml method. 
 * @param nifty
 * @throws Exception if nifty can't load the old gui
 */
public void refresh(Nifty nifty) throws Exception{
    if(getGui() != null){
        String screenID =this.currentS.getID();
            nifty.scheduleEndOfFrameElementAction(new Reload(nifty, screenID), null);
            
            
    }
}