コード例 #1
0
ファイル: Sheet.java プロジェクト: koson/xmind3
 public int getIndex() {
   IWorkbook w = getParent();
   if (w != null) {
     return w.getSheets().indexOf(this);
   }
   return -1;
 }
コード例 #2
0
ファイル: StyleUtils.java プロジェクト: koson/xmind3
 private static void setThemeStyles(
     IWorkbook workbook,
     IStyleSheet styleSheet,
     ISheet sheet,
     IStyle theme,
     String... sheetStyleNames) {
   IStyle sheetTheme = theme.getDefaultStyle(Styles.FAMILY_MAP);
   if (sheetTheme == null) return;
   IStyle sheetStyle = styleSheet.findStyle(sheet.getStyleId());
   if (sheetStyle != null) {
     sheetStyle =
         Core.getWorkbookBuilder().createWorkbook().getStyleSheet().importStyle(sheetStyle);
   }
   String value = null;
   for (String styleName : sheetStyleNames) {
     value = sheetTheme.getProperty(styleName);
     if (value != null) {
       if (sheetStyle == null)
         sheetStyle =
             Core.getWorkbookBuilder()
                 .createWorkbook()
                 .getStyleSheet()
                 .createStyle(sheet.getStyleType());
       sheetStyle.setProperty(styleName, value);
     } else if (sheetStyle != null) {
       sheetStyle.setProperty(styleName, value);
     }
   }
   if (sheetStyle != null) {
     sheetStyle = workbook.getStyleSheet().importStyle(sheetStyle);
     if (sheetStyle != null) {
       sheet.setStyleId(sheetStyle.getId());
     }
   }
 }
コード例 #3
0
ファイル: StyleUtils.java プロジェクト: koson/xmind3
  public static void setTheme(ISheet sheet, IStyle theme) {
    if (sheet == null) return;

    if (theme == null || theme.isEmpty()) {
      sheet.setThemeId(null);
    } else {
      IWorkbook workbook = sheet.getOwnedWorkbook();
      IStyleSheet styleSheet = workbook.getStyleSheet();
      theme = styleSheet.importStyle(theme);
      if (theme == null || theme.isEmpty()) {
        sheet.setThemeId(null);
      } else {
        sheet.setThemeId(theme.getId());
        setThemeStyles(
            workbook, styleSheet, sheet, theme, Styles.MultiLineColors, Styles.LineTapered);
      }
    }
  }
コード例 #4
0
  @Test
  public void testGetMarkers() {
    ITopic ct = workbook.getPrimarySheet().getRootTopic();
    ITopic mt1 = ct.getChildren(ITopic.ATTACHED).get(0);
    ITopic mt2 = ct.getChildren(ITopic.ATTACHED).get(1);
    ITopic mt3 = ct.getChildren(ITopic.ATTACHED).get(2);

    assertUnorderedResultSet(eval(ct, "marker"), ct.getMarkerRefs().toArray());
    assertUnorderedResultSet(eval(mt1, "marker"), mt1.getMarkerRefs().toArray());
    assertUnorderedResultSet(eval(mt2, "marker"), mt2.getMarkerRefs().toArray());
    assertUnorderedResultSet(eval(mt3, "marker"), mt3.getMarkerRefs().toArray());
  }
コード例 #5
0
  @Test
  public void testGetFolded() {
    ITopic ct = workbook.getPrimarySheet().getRootTopic();
    ITopic mt1 = ct.getChildren(ITopic.ATTACHED).get(0);
    ITopic mt2 = ct.getChildren(ITopic.ATTACHED).get(1);
    ITopic mt3 = ct.getChildren(ITopic.ATTACHED).get(2);

    assertOrderedResultSet(eval(ct, "@folded"), Boolean.FALSE);
    assertOrderedResultSet(eval(mt1, "@folded"), Boolean.FALSE);
    assertOrderedResultSet(eval(mt2, "@folded"), Boolean.FALSE);
    assertOrderedResultSet(eval(mt3, "@folded"), Boolean.TRUE);
  }
コード例 #6
0
  @Test
  public void testGetMarkerIds() {
    ITopic ct = workbook.getPrimarySheet().getRootTopic();
    ITopic mt1 = ct.getChildren(ITopic.ATTACHED).get(0);
    ITopic mt2 = ct.getChildren(ITopic.ATTACHED).get(1);
    ITopic mt3 = ct.getChildren(ITopic.ATTACHED).get(2);

    assertUnorderedResultSet(eval(ct, "marker/@id"));
    assertUnorderedResultSet(eval(mt1, "marker/@id"), "priority-2", "smiley-laugh");
    assertUnorderedResultSet(eval(mt2, "marker/@id"), "task-3oct");
    assertUnorderedResultSet(eval(mt3, "marker/@id"));

    assertOrderedResultSet(eval(mt2, "marker/@id='task-3oct'"), Boolean.TRUE);
  }
コード例 #7
0
  @Test
  public void testGetTitle() {
    ITopic ct = workbook.getPrimarySheet().getRootTopic();
    ITopic mt1 = ct.getChildren(ITopic.ATTACHED).get(0);
    ITopic mt2 = ct.getChildren(ITopic.ATTACHED).get(1);
    ITopic mt3 = ct.getChildren(ITopic.ATTACHED).get(2);

    assertOrderedResultSet(eval(ct, "@title"), "Central Topic");
    assertOrderedResultSet(eval(mt1, "@title"), "Main Topic 1");
    assertOrderedResultSet(eval(mt2, "@title"), "Task");
    assertOrderedResultSet(eval(mt3, "@title"), "Platform Expression Framework.txt");

    assertOrderedResultSet(eval(ct, "@title='Central Topic'"), Boolean.TRUE);
    assertOrderedResultSet(eval(mt1, "@title='Main Topic 1'"), Boolean.TRUE);
  }
コード例 #8
0
  @Test
  public void testGetCount() {
    ITopic ct = workbook.getPrimarySheet().getRootTopic();
    ITopic mt1 = ct.getChildren(ITopic.ATTACHED).get(0);
    ITopic mt2 = ct.getChildren(ITopic.ATTACHED).get(1);
    ITopic mt3 = ct.getChildren(ITopic.ATTACHED).get(2);

    assertOrderedResultSet(eval(ct, "count(marker)"), Integer.valueOf(0));
    assertOrderedResultSet(eval(mt1, "count(marker)"), Integer.valueOf(2));
    assertOrderedResultSet(eval(mt2, "count(marker)"), Integer.valueOf(1));
    assertOrderedResultSet(eval(mt3, "count(marker)"), Integer.valueOf(0));

    assertOrderedResultSet(eval(ct, "count(marker)=0"), Boolean.TRUE);
    assertOrderedResultSet(eval(mt1, "count(marker)=2"), Boolean.TRUE);
  }
コード例 #9
0
  @Test
  public void testGetType() {
    ITopic ct = workbook.getPrimarySheet().getRootTopic();
    ITopic mt1 = ct.getChildren(ITopic.ATTACHED).get(0);
    ITopic mt2 = ct.getChildren(ITopic.ATTACHED).get(1);
    ITopic mt3 = ct.getChildren(ITopic.ATTACHED).get(2);
    ITopic ft1 = ct.getChildren(ITopic.DETACHED).get(0);
    ITopic st1 = ct.getChildren(ITopic.SUMMARY).get(0);

    assertOrderedResultSet(eval(ct, "@type"), ITopic.ROOT);
    assertOrderedResultSet(eval(mt1, "@type"), ITopic.ATTACHED);
    assertOrderedResultSet(eval(mt2, "@type"), ITopic.ATTACHED);
    assertOrderedResultSet(eval(mt3, "@type"), ITopic.ATTACHED);
    assertOrderedResultSet(eval(ft1, "@type"), ITopic.DETACHED);
    assertOrderedResultSet(eval(st1, "@type"), ITopic.SUMMARY);
  }
コード例 #10
0
  @Before
  public void setUp() throws Exception {
    IMarkerSheet globalMarkers;
    InputStream markerSheetStream =
        new URL("platform:/plugin/org.xmind.core.runtime.tests/samples/markers.xml").openStream();
    try {
      globalMarkers = Core.getMarkerSheetBuilder().loadFromStream(markerSheetStream, null);
    } finally {
      markerSheetStream.close();
    }
    IInputSource source =
        new BundleResourceInputSource(
            "org.xmind.core.runtime.tests", "/samples/sample1.xmind"); // $NON-NLS-2$
    workbook = Core.getWorkbookBuilder().loadFromInputSource(source, new ByteArrayStorage(), null);
    workbook.getMarkerSheet().setParentSheet(globalMarkers);

    axisProvider = new CoreAxisProvider();
  }
コード例 #11
0
  @Test
  public void testGetChildTopics() {
    ITopic ct = workbook.getPrimarySheet().getRootTopic();

    assertOrderedResultSet(eval(ct, "topic"), ct.getAllChildren().toArray());

    assertOrderedResultSet(eval(ct, "topic[1]"), ct.getAllChildren().get(0));
    assertOrderedResultSet(
        eval(ct, "topic[@type='attached']"), ct.getChildren(ITopic.ATTACHED).toArray());
    assertOrderedResultSet(
        eval(ct, "topic[@type='detached']"), ct.getChildren(ITopic.DETACHED).toArray());
    assertOrderedResultSet(
        eval(ct, "topic[@type='summary']"), ct.getChildren(ITopic.SUMMARY).toArray());

    assertOrderedResultSet(
        eval(ct, "topic[matches(@type,'(at|de)tached')]"),
        concat(ct.getChildren(ITopic.ATTACHED), ct.getChildren(ITopic.DETACHED)).toArray());
  }
コード例 #12
0
  @Test
  public void testCommonTopicTests() {
    ITopic ct = workbook.getPrimarySheet().getRootTopic();
    ITopic mt1 = ct.getChildren(ITopic.ATTACHED).get(0);
    ITopic mt2 = ct.getChildren(ITopic.ATTACHED).get(1);
    ITopic mt3 = ct.getChildren(ITopic.ATTACHED).get(2);
    ITopic ft1 = ct.getChildren(ITopic.DETACHED).get(0);
    ITopic st1 = ct.getChildren(ITopic.SUMMARY).get(0);

    // topic has a specific title
    String test1 = "@title='Task'";
    assertOrderedResultSet(eval(ct, test1), Boolean.FALSE);
    assertOrderedResultSet(eval(mt1, test1), Boolean.FALSE);
    assertOrderedResultSet(eval(mt2, test1), Boolean.TRUE);
    assertOrderedResultSet(eval(mt3, test1), Boolean.FALSE);
    assertOrderedResultSet(eval(ft1, test1), Boolean.FALSE);
    assertOrderedResultSet(eval(st1, test1), Boolean.FALSE);

    // topic is the root topic
    String test2 = "@type='root'";
    assertOrderedResultSet(eval(ct, test2), Boolean.TRUE);
    assertOrderedResultSet(eval(mt1, test2), Boolean.FALSE);
    assertOrderedResultSet(eval(mt2, test2), Boolean.FALSE);
    assertOrderedResultSet(eval(mt3, test2), Boolean.FALSE);
    assertOrderedResultSet(eval(ft1, test2), Boolean.FALSE);
    assertOrderedResultSet(eval(st1, test2), Boolean.FALSE);

    // topic is a summary topic
    String test3 = "@type='summary'";
    assertOrderedResultSet(eval(ct, test3), Boolean.FALSE);
    assertOrderedResultSet(eval(mt1, test3), Boolean.FALSE);
    assertOrderedResultSet(eval(mt2, test3), Boolean.FALSE);
    assertOrderedResultSet(eval(mt3, test3), Boolean.FALSE);
    assertOrderedResultSet(eval(ft1, test3), Boolean.FALSE);
    assertOrderedResultSet(eval(st1, test3), Boolean.TRUE);

    // topic is an attachment
    String test4 = "matches(@hyperlink,'^xap\\:.*')";
    assertOrderedResultSet(eval(ct, test4), Boolean.FALSE);
    assertOrderedResultSet(eval(mt1, test4), Boolean.FALSE);
    assertOrderedResultSet(eval(mt2, test4), Boolean.FALSE);
    assertOrderedResultSet(eval(mt3, test4), Boolean.TRUE);
    assertOrderedResultSet(eval(ft1, test4), Boolean.FALSE);
    assertOrderedResultSet(eval(st1, test4), Boolean.FALSE);

    // topic has markers
    String test5 = "count(marker)>0";
    assertOrderedResultSet(eval(ct, test5), Boolean.FALSE);
    assertOrderedResultSet(eval(mt1, test5), Boolean.TRUE);
    assertOrderedResultSet(eval(mt2, test5), Boolean.TRUE);
    assertOrderedResultSet(eval(mt3, test5), Boolean.FALSE);
    assertOrderedResultSet(eval(ft1, test5), Boolean.FALSE);
    assertOrderedResultSet(eval(st1, test5), Boolean.FALSE);

    // topic has image
    String test6 = "count(image[@source])>0";
    assertOrderedResultSet(eval(ct, test6), Boolean.FALSE);
    assertOrderedResultSet(eval(mt1, test6), Boolean.FALSE);
    assertOrderedResultSet(eval(mt2, test6), Boolean.TRUE);
    assertOrderedResultSet(eval(mt3, test6), Boolean.FALSE);
    assertOrderedResultSet(eval(ft1, test6), Boolean.FALSE);
    assertOrderedResultSet(eval(st1, test6), Boolean.FALSE);

    // topic has markers belonging to a specific group
    String test7 = "count(marker[@groupId='priorityMarkers'])>0";
    assertOrderedResultSet(eval(ct, test7), Boolean.FALSE);
    assertOrderedResultSet(eval(mt1, test7), Boolean.TRUE);
    assertOrderedResultSet(eval(mt2, test7), Boolean.FALSE);
    assertOrderedResultSet(eval(mt3, test7), Boolean.FALSE);
    assertOrderedResultSet(eval(ft1, test7), Boolean.FALSE);
    assertOrderedResultSet(eval(st1, test7), Boolean.FALSE);
  }