Package com.google.collide.client.workspace

Examples of com.google.collide.client.workspace.FileTreeNode


        continue;
      }

      // Now check if the value is a workspace file path.
      if (inAttribute) {
        FileTreeNode fileNode = findFileNode(valueWithoutQuotes);
        if (fileNode != null) {
          int filePathEndColumn = valueEndColumn - 1// Incl.
          return NavigableReference.createToFile(lineNumber, valueStartColumn, filePathEndColumn,
              fileNode.getNodePath().getPathString());
        }
      }

      // Now check if the value is an URL.
      REGEXP_URL.setLastIndex(0);
View Full Code Here


 
  /**
   * Creates a file tree model given a directory structure
   */
  private FileTreeModel getFileTree(DirInfo dir) {
    FileTreeNode root = FileTreeNode.transform(dir);

    FileTreeModel model = new FileTreeModel(new MockOutgoingController());
    model.replaceNode(PathUtil.WORKSPACE_ROOT, root, "1");
    return model;
  }
View Full Code Here

  }

  public void getDocument(PathUtil path, GetDocumentCallback callback) {
    if (fileTreeModel.getWorkspaceRoot() != null) {
      // FileTreeModel is populated so get the file edit session key for this path
      FileTreeNode node = fileTreeModel.getWorkspaceRoot().findChildNode(path);
      if (node != null && node.getFileEditSessionKey() != null) {
        String fileEditSessionKey = node.getFileEditSessionKey();
        Document document = documentsByFileEditSessionKey.get(fileEditSessionKey);
        if (document != null) {
          callback.onDocumentReceived(document);
          return;
        }
View Full Code Here

      });
    }

    // Save the fileEditSessionKey into the tree node.
    if (fileTreeModel.getWorkspaceRoot() != null) {
      FileTreeNode node = fileTreeModel.getWorkspaceRoot().findChildNode(path);
      if (node != null) {
        node.setFileEditSessionKey(fileEditSessionKey);
      }
    }

    return document;
  }
View Full Code Here

    JsonArray<PathUtil> results = JsonCollections.createArray();
    if (treeModel == null || maxResults < 0) {
      return results;
    }
   
    FileTreeNode root = treeModel.getWorkspaceRoot();
    if (root == null) {
      return results;
    }

    recurseTree(searchPath, root, query, maxResults, results);
View Full Code Here

  private DynamicReferenceProvider createDynamicReferenceProvider(String path, String source) {
    PathUtil filePath = new PathUtil(path);
    document = Document.createFromString(source);
    parser = DocumentParser.create(
        document, CodeMirror2.getParser(filePath), new StubIncrementalScheduler(50, 50));
    FileTreeNode root = FileTreeNode.transform(buildSimpleTree());
    FileTreeModel model = new FileTreeModel(new MockOutgoingController());
    model.replaceNode(PathUtil.WORKSPACE_ROOT, root, "1");
    return new DynamicReferenceProvider(path, new DeferringLineParser(parser), model, null);
  }
View Full Code Here

    tryFindFileNode(provider, "src/world.js", null);
  }

  private void tryFindFileNode(DynamicReferenceProvider provider, String displayPath,
      @Nullable String expectedFileNodePath) {
    FileTreeNode fileNode = provider.findFileNode(displayPath);
    if (expectedFileNodePath == null) {
      assertNull(fileNode);
    } else {
      assertEquals(expectedFileNodePath, fileNode.getNodePath().getPathString());
    }
  }
View Full Code Here

  /**
   * Tests select responses to ctrl clicks across tiers in the tree.
   */
  public void testCtrlSelectAcrossTiers() {
    FileTreeNode root = mockTree.getModel().getRoot();

    // Render the tree.
    mockTree.renderTree(-1);

    SignalEvent ctrlSignalEvent = new MockSignalEvent(true, false);

    // Select a bunch of nodes at the same tier.
    FileTreeNode AD1 = getNodeByPath(0);
    assertNotNull("Node did not get rendered!", AD1.getRenderedTreeNode());
    assertFalse(AD1.getRenderedTreeNode().isSelected(resources.treeCss()));

    JsoArray<FileTreeNode> expectedSelects = JsoArray.create();

    // Select the first top level dir.
    mockSelectionModel.selectNode(AD1, ctrlSignalEvent);
    expectedSelects.add(AD1);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(AD1.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Select the second top level dir
    FileTreeNode BD1 = getNodeByPath(1);
    mockSelectionModel.selectNode(BD1, ctrlSignalEvent);
    expectedSelects.add(BD1);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(BD1.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Select deeper. We should not allow cross depth selecting and should
    // replace it with just the new select.
    FileTreeNode AF2 = getNodeByPath(0, 0);
    assertNotNull("Node did not get rendered!", AF2.getRenderedTreeNode());
    assertFalse(AF2.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Change the select.
    mockSelectionModel.selectNode(AF2, ctrlSignalEvent);
    expectedSelects.clear();
    expectedSelects.add(AF2);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(AF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(AD1.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Select another peer node.
    FileTreeNode CF2 = getNodeByPath(0, 2);
    assertNotNull("Node did not get rendered!", CF2.getRenderedTreeNode());
    assertFalse(CF2.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Change the select.
    mockSelectionModel.selectNode(CF2, ctrlSignalEvent);
    expectedSelects.add(CF2);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(AF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertTrue(CF2.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Select another peer node.
    FileTreeNode BF2 = getNodeByPath(0, 1);
    assertNotNull("Node did not get rendered!", BF2.getRenderedTreeNode());
    assertFalse(BF2.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Change the select.
    mockSelectionModel.selectNode(BF2, ctrlSignalEvent);
    // We need to enforce sort order. AF2, BF2, CF2.
    expectedSelects.splice(1, 0, BF2);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(AF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertTrue(BF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertTrue(CF2.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Ensure that if we ctrl click back higher in the stack that we clear the
    // selected list.
    FileTreeNode AF1 = getNodeByPath(3);
    assertNotNull("Node did not get rendered!", AF1.getRenderedTreeNode());
    assertFalse(AF1.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Change the select.
    mockSelectionModel.selectNode(AF1, ctrlSignalEvent);
    expectedSelects.clear();
    expectedSelects.add(AF1);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(AF1.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(AF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(BF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(CF2.getRenderedTreeNode().isSelected(resources.treeCss()));
  }
View Full Code Here

  /**
   * Tests select responses to ctrl clicks that should result in select toggling
   */
  public void testCtrlSelectToggle() {
    FileTreeNode root = mockTree.getModel().getRoot();

    // Render the tree.
    mockTree.renderTree(-1);

    SignalEvent ctrlSignalEvent = new MockSignalEvent(true, false);

    // Select a bunch of nodes at the same tier.
    FileTreeNode AD1 = getNodeByPath(0);
    assertNotNull("Node did not get rendered!", AD1.getRenderedTreeNode());
    assertFalse(AD1.getRenderedTreeNode().isSelected(resources.treeCss()));

    JsoArray<FileTreeNode> expectedSelects = JsoArray.create();

    // Select the first top level dir.
    mockSelectionModel.selectNode(AD1, ctrlSignalEvent);
    expectedSelects.add(AD1);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(AD1.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Select the second top level dir
    FileTreeNode BD1 = getNodeByPath(1);
    mockSelectionModel.selectNode(BD1, ctrlSignalEvent);
    expectedSelects.add(BD1);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(BD1.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Select the first file.
    FileTreeNode AF1 = getNodeByPath(3);
    assertNotNull("Node did not get rendered!", AF1.getRenderedTreeNode());
    assertFalse(AF1.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Change the select.
    mockSelectionModel.selectNode(AF1, ctrlSignalEvent);
    expectedSelects.add(AF1);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(AF1.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Now toggle the second dir.
    mockSelectionModel.selectNode(BD1, ctrlSignalEvent);
    expectedSelects.remove(BD1);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
View Full Code Here

  /**
   * Tests select responses to shift clicks that should do range selects.
   */
  public void testShiftSelect() {
    FileTreeNode root = mockTree.getModel().getRoot();

    // Render the tree.
    mockTree.renderTree(-1);

    SignalEvent shiftSignalEvent = new MockSignalEvent(false, true);

    FileTreeNode AD1 = getNodeByPath(0);
    assertNotNull("Node did not get rendered!", AD1.getRenderedTreeNode());
    assertFalse(AD1.getRenderedTreeNode().isSelected(resources.treeCss()));

    JsoArray<FileTreeNode> expectedSelects = JsoArray.create();

    // Select the first top level dir.
    mockSelectionModel.selectNode(AD1, shiftSignalEvent);
    expectedSelects.add(AD1);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(AD1.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Shift select the last top level file.
    FileTreeNode BF1 = getNodeByPath(4);
    mockSelectionModel.selectNode(BF1, shiftSignalEvent);
    expectedSelects.add(getNodeByPath(1));
    expectedSelects.add(getNodeByPath(2));
    expectedSelects.add(getNodeByPath(3));
    expectedSelects.add(getNodeByPath(4));
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(BF1.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertTrue(getNodeByPath(2).getRenderedTreeNode().isSelected(resources.treeCss()));
    assertTrue(getNodeByPath(3).getRenderedTreeNode().isSelected(resources.treeCss()));

    // Select the last file. It should zero the shift selection.
    mockSelectionModel.selectNode(BF1, shiftSignalEvent);
    expectedSelects.clear();
    expectedSelects.add(BF1);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(BF1.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(getNodeByPath(0).getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(getNodeByPath(1).getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(getNodeByPath(2).getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(getNodeByPath(3).getRenderedTreeNode().isSelected(resources.treeCss()));

    // Select deeper. We should not allow cross depth selecting and
    // should replace it with just the new select.
    FileTreeNode AF2 = getNodeByPath(0, 0);
    assertNotNull("Node did not get rendered!", AF2.getRenderedTreeNode());
    assertFalse(AF2.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Change the select.
    mockSelectionModel.selectNode(AF2, shiftSignalEvent);
    expectedSelects.clear();
    expectedSelects.add(AF2);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(AF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(BF1.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Select the adjacent peer node.
    FileTreeNode BF2 = getNodeByPath(0, 1);
    assertNotNull("Node did not get rendered!", BF2.getRenderedTreeNode());
    assertFalse(BF2.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Change the select.
    mockSelectionModel.selectNode(BF2, shiftSignalEvent);
    expectedSelects.add(BF2);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(AF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertTrue(BF2.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Select the last peer node.
    FileTreeNode DF2 = getNodeByPath(0, 3);
    assertNotNull("Node did not get rendered!", DF2.getRenderedTreeNode());
    assertFalse(DF2.getRenderedTreeNode().isSelected(resources.treeCss()));

    // Change the select.
    mockSelectionModel.selectNode(DF2, shiftSignalEvent);
    expectedSelects.add(getNodeByPath(0, 2));
    expectedSelects.add(getNodeByPath(0, 3));
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(DF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertTrue(getNodeByPath(0, 2).getRenderedTreeNode().isSelected(resources.treeCss()));

    // Ensure that if we shift click the last one we clear the selected list.
    mockSelectionModel.selectNode(DF2, shiftSignalEvent);
    expectedSelects.clear();
    expectedSelects.add(DF2);
    checkNodeArray(expectedSelects, mockSelectionModel.getSelectedNodes());
    assertTrue(DF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(AF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(BF2.getRenderedTreeNode().isSelected(resources.treeCss()));
    assertFalse(getNodeByPath(0, 2).getRenderedTreeNode().isSelected(resources.treeCss()));
  }
View Full Code Here

TOP

Related Classes of com.google.collide.client.workspace.FileTreeNode

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.