Exemple #1
0
  private Context() {
    workspaceController = new WorkspaceController();
    resetWorksapce();
    workspace = workspaceController.getWorkspace();
    workspaceChanged = false;
    highlightBlockSet = new HashSet<RenderableBlock>();
    ofls = new HashSet<OpenblocksFrameListener>();
    this.workspace = workspaceController.getWorkspace();

    isInArduino = false;

    osType = determineOsType();
  }
Exemple #2
0
  private Context() {
    /*
     * workspace = new Workspace(); workspace.reset(); workspace.setl
     */

    // Style list
    List<String[]> list = new ArrayList<String[]>();
    String[][] styles = {};

    //		{ "//BlockGenus[@name[starts-with(.,\"Tinker\")]]/@color", "128 0 0" },
    //		{ "//BlockGenus[@name[starts-with(.,\"df_\")]]/@color",	"0 128 0" } };

    for (String[] style : styles) {
      list.add(style);
    }

    workspaceController = new WorkspaceController();
    workspaceController.resetWorkspace();
    workspaceController.resetLanguage();
    workspaceController.setLangResourceBundle(
        ResourceBundle.getBundle("com/ardublock/block/ardublock"));
    workspaceController.setStyleList(list);
    workspaceController.setLangDefDtd(this.getClass().getResourceAsStream(LANG_DTD_PATH));
    workspaceController.setLangDefStream(this.getClass().getResourceAsStream(ARDUBLOCK_LANG_PATH));
    workspaceController.loadFreshWorkspace();
    workspace = workspaceController.getWorkspace();
    workspaceChanged = false;
    highlightBlockSet = new HashSet<RenderableBlock>();
    ofls = new HashSet<OpenblocksFrameListener>();
    this.workspace = workspaceController.getWorkspace();

    isInArduino = false;

    // determine OS
    String osName = System.getProperty("os.name");
    osName = osName.toLowerCase();
    if (osName.contains("win")) {
      osType = Context.OsType.WINDOWS;
    } else {
      if (osName.contains("linux")) {
        osType = Context.OsType.LINUX;
      } else {
        if (osName.contains("mac")) {
          osType = Context.OsType.MAC;
        } else {
          osType = Context.OsType.UNKNOWN;
        }
      }
    }
    //
  }
Exemple #3
0
  private void loadDefaultArdublockProgram() {
    /*
    InputStream defaultArdublockProgram = this.getClass().getResourceAsStream(DEFAULT_ARDUBLOCK_PROGRAM_PATH);

    final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          factory.setNamespaceAware(true);
          final DocumentBuilder builder;
          final Document doc;
    try
    {
    	builder = factory.newDocumentBuilder();
    	doc = builder.parse(defaultArdublockProgram);
    	final Element projectRoot = doc.getDocumentElement();
    	workspaceController.resetWorkspace();
    	workspaceController.loadProjectFromElement(projectRoot);
    }
    catch (ParserConfigurationException e)
    {
    	// TODO Auto-generated catch block
    	e.printStackTrace();
    }
    catch (SAXException e)
    {
    	// TODO Auto-generated catch block
    	e.printStackTrace();
    }
    catch (IllegalArgumentException e)
    {
    	// TODO Auto-generated catch block
    	e.printStackTrace();
    	workspaceController.loadFreshWorkspace();
    }
    catch (IOException e)
    {
    	// TODO Auto-generated catch block
    	e.printStackTrace();
    	workspaceController.loadFreshWorkspace();
    }
          */

    Workspace workspace = workspaceController.getWorkspace();
    Page page = workspace.getPageNamed("Main");

    FactoryManager manager = workspace.getFactoryManager();
    Block newBlock;
    newBlock = new Block(workspace, "loop", false);
    FactoryRenderableBlock factoryRenderableBlock =
        new FactoryRenderableBlock(workspace, manager, newBlock.getBlockID());
    RenderableBlock renderableBlock = factoryRenderableBlock.createNewInstance();
    renderableBlock.setLocation(100, 100);
    page.addBlock(renderableBlock);
  }