コード例 #1
0
ファイル: WorkbookLoader.java プロジェクト: gedaofeng/xmind3
 private void copyEntry(IInputSource source, IOutputTarget target, String entryPath)
     throws CoreException {
   try {
     InputStream in = getInputStream(source, entryPath);
     if (in != null) {
       OutputStream out = getOutputStream(target, entryPath);
       if (out != null) {
         try {
           FileUtils.transfer(in, out, true);
         } finally {
           long time = source.getEntryTime(entryPath);
           if (time >= 0) {
             target.setEntryTime(entryPath, time);
           }
           Exception e2 = checkChecksum(source, entryPath, in, null);
           if (e2 instanceof CoreException) {
             throw (CoreException) e2;
           }
         }
       }
     }
   } catch (IOException e) {
     Core.getLogger().log(e);
   } catch (CoreException e) {
     if (e.getType() == Core.ERROR_WRONG_PASSWORD || e.getType() == Core.ERROR_CANCELLATION)
       throw e;
     Core.getLogger().log(e);
   }
 }
コード例 #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
  @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();
  }
コード例 #4
0
 /*
  * (non-Javadoc)
  *
  * @see org.xmind.core.io.IOutputTarget#close()
  */
 public void close() {
   try {
     zip.flush();
     zip.close();
     return;
   } catch (IOException e) {
     Core.getLogger().log(e);
   }
 }
コード例 #5
0
 /*
  * (non-Javadoc)
  *
  * @see org.xmind.core.io.IOutputTarget#getEntryStream(java.lang.String)
  */
 public OutputStream getEntryStream(String entryName) {
   try {
     this.currentEntry = new ZipEntry(entryName);
     zip.putNextEntry(currentEntry);
     return new ZipEntryOutputStream(zip);
   } catch (IOException e) {
     Core.getLogger().log(e);
     return null;
   }
 }
コード例 #6
0
ファイル: WorkbookLoader.java プロジェクト: gedaofeng/xmind3
 private void loadMarkerSheet() throws IOException, CoreException {
   try {
     IMarkerSheet markerSheet =
         ((MarkerSheetBuilderImpl) Core.getMarkerSheetBuilder())
             .loadFromInputSource(source, this, new WorkbookMarkerResourceProvider(workbook));
     workbook.setMarkerSheet((MarkerSheetImpl) markerSheet);
   } catch (IOException e) {
     throw e;
   } catch (CoreException e) {
     if (e.getType() != Core.ERROR_NO_SUCH_ENTRY) throw e;
   }
 }
コード例 #7
0
ファイル: WorkbookLoader.java プロジェクト: gedaofeng/xmind3
 private void loadStyleSheet() throws IOException, CoreException {
   try {
     IStyleSheet styleSheet =
         ((StyleSheetBuilderImpl) Core.getStyleSheetBuilder()).loadFromInputSource(source, this);
     ((StyleSheetImpl) styleSheet).setManifest(manifest);
     workbook.setStyleSheet((StyleSheetImpl) styleSheet);
   } catch (IOException e) {
     throw e;
   } catch (CoreException e) {
     if (e.getType() != Core.ERROR_NO_SUCH_ENTRY) throw e;
   }
 }
コード例 #8
0
ファイル: WorkbookLoader.java プロジェクト: gedaofeng/xmind3
 private Document forceLoadXML(String entryPath) throws IOException, CoreException {
   try {
     return loadXMLFile(source, entryPath);
   } catch (Throwable e) {
     if (e instanceof CoreException) {
       CoreException coreEx = (CoreException) e;
       if (coreEx.getType() == Core.ERROR_WRONG_PASSWORD
           || coreEx.getType() == Core.ERROR_CANCELLATION) {
         throw coreEx;
       }
     }
     // in case the file is damaged,
     // try continue loading
     Core.getLogger().log(e, "Faild to load " + entryPath); // $NON-NLS-1$
     return createDocument();
   }
 }
コード例 #9
0
ファイル: BranchDummy.java プロジェクト: Bluelich/xmind
 private ITopic createDummyTopic(IBranchPart sourceBranch, boolean newTopic) {
   ITopic topic;
   if (sourceBranch == null && newTopic) {
     ITopic centralTopic = (ITopic) viewer.getAdapter(ITopic.class);
     topic = centralTopic.getOwnedWorkbook().createTopic();
     centralTopic.add(topic, ITopic.DETACHED);
   } else if (sourceBranch != null) {
     ITopic sourceTopic = sourceBranch.getTopic();
     topic = sourceTopic.getOwnedWorkbook().createTopic();
     topic.setTitleText(sourceTopic.getTitleText());
     topic.setStyleId(sourceTopic.getStyleId());
     topic.setTitleWidth(sourceTopic.getTitleWidth());
     ((TopicImpl) topic).setCoreEventSupport(new CoreEventSupport());
   } else {
     topic = Core.getWorkbookBuilder().createWorkbook().createTopic();
   }
   return topic;
 }