/** * Load the default data if any is specified in the System.ini file. * * @param sHomeViewID the id of the home view to load the data into. * @return true if completely successful. * @exception IOException if there is an IO or Zip error. */ private boolean loadDefaultData(String sHomeViewID) throws IOException { String defaultDataPath = SystemProperties.projectDefaultDataFile; if (!defaultDataPath.equals("")) { // $NON-NLS-1$ String sXMLFile = defaultDataPath; if (defaultDataPath.endsWith(".zip")) { // $NON-NLS-1$ ZipFile zipFile = new ZipFile(defaultDataPath); Enumeration entries = zipFile.entries(); ZipEntry entry = null; String sTemp = ""; // $NON-NLS-1$ while (entries.hasMoreElements()) { entry = (ZipEntry) entries.nextElement(); sTemp = entry.getName(); if (sTemp.endsWith(".xml") && sTemp.startsWith("Exports")) { // $NON-NLS-1$ //$NON-NLS-2$ sXMLFile = sTemp; } // AVOID Thumbs.db files if (sTemp.endsWith(".db")) { // $NON-NLS-1$ continue; } int len = 0; byte[] buffer = new byte[1024]; InputStream in = zipFile.getInputStream(entry); String sFileName = ""; // $NON-NLS-1$ String sLinkedFiles = "Linked Files/"; // $NON-NLS-1$ if (sTemp.startsWith(sLinkedFiles)) { sFileName = UIUtilities.sGetLinkedFilesLocation() + sTemp.substring(sLinkedFiles.length()); } else { sFileName = entry.getName(); } File file = new File(sFileName); if (file.getParentFile() != null) { file.getParentFile().mkdirs(); } OutputStream out = new BufferedOutputStream(new FileOutputStream(sFileName)); while ((len = in.read(buffer)) >= 0) { out.write(buffer, 0, len); } in.close(); out.close(); } zipFile.close(); } // IMPORT THE XML if (!sXMLFile.equals("") && sXMLFile.endsWith(".xml")) { // $NON-NLS-1$ //$NON-NLS-2$ File oXMLFile = new File(sXMLFile); if (oXMLFile.exists()) { boolean importAuthorAndDate = false; boolean includeOriginalAuthorDate = false; boolean preserveIDs = true; boolean transclude = true; boolean updateTranscludedNodes = false; File oXMLFile2 = new File(sXMLFile); if (oXMLFile2.exists()) { DBNode.setImportAsTranscluded(transclude); DBNode.setPreserveImportedIds(preserveIDs); DBNode.setUpdateTranscludedNodes(updateTranscludedNodes); DBNode.setNodesMarkedSeen(true); UIViewFrame frame = ProjectCompendium.APP.getCurrentFrame(); if (frame instanceof UIMapViewFrame) { UIMapViewFrame mapFrame = (UIMapViewFrame) frame; UIViewPane oViewPane = mapFrame.getViewPane(); ViewPaneUI oViewPaneUI = oViewPane.getUI(); if (oViewPaneUI != null) { oViewPaneUI.setSmartImport(importAuthorAndDate); oViewPaneUI.onImportXMLFile(sXMLFile, includeOriginalAuthorDate); } } else if (frame instanceof UIListViewFrame) { UIListViewFrame listFrame = (UIListViewFrame) frame; UIList uiList = listFrame.getUIList(); if (uiList != null) { uiList.getListUI().setSmartImport(importAuthorAndDate); uiList.getListUI().onImportXMLFile(sXMLFile, includeOriginalAuthorDate); } } return true; } } else { ProjectCompendium.APP.displayError( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UINewDatabaseDialog.missingFileA") + "\n\n" + LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UINewDatabaseDialog.missingFileB") + "\n"); //$NON-NLS-1$ return false; } } else { return true; // there is allowed to be no default data to load. } return false; } return true; }
/** * Handles most menu action event for this application. * * @param evt the generated action event to be handled. */ public void actionPerformed(ActionEvent evt) { ProjectCompendium.APP.setWaitCursor(); Object source = evt.getSource(); if (source.equals(miStencilManagement)) { UIStencilDialog dlg = new UIStencilDialog(ProjectCompendium.APP, ProjectCompendium.APP.oStencilManager); UIUtilities.centerComponent(dlg, ProjectCompendium.APP); dlg.setVisible(true); } else if (source.equals(miLinkGroupManagement)) { UILinkManagementDialog dlg = new UILinkManagementDialog( ProjectCompendium.APP, ProjectCompendium.APP.oLinkGroupManager); UIUtilities.centerComponent(dlg, ProjectCompendium.APP); dlg.setVisible(true); } else if (source.equals(miLinkGroupDefault)) { ProjectCompendium.APP.oLinkGroupManager.createDefaultLinkGroup(); } else if (source.equals(miLinkGroupManagement)) { ProjectCompendium.APP.oLinkGroupManager.createDefaultLinkGroup(); ProjectCompendium.APP.oLinkGroupManager.refreshTree(); } else if (source.equals(miUsers)) ProjectCompendium.APP.onUsers(); else if (source.equals(miLinkedFilesFileBrowser)) ProjectCompendium.APP.onLinkedFilesBrowser(); else if (source.equals(miMeetingRecording)) { ProjectCompendium.APP.displayError( LanguageProperties.getString( LanguageProperties.MENUS_BUNDLE, "UIMenuTools.memeticMessage1")); // $NON-NLS-1$ } else if (source.equals(miMeetingUpload)) { } else if (source.equals(miCodes)) ProjectCompendium.APP.onCodes(); else if (source.equals(miShowCodes)) ProjectCompendium.APP.onShowCodes(); else if (source.equals(miHideCodes)) ProjectCompendium.APP.onHideCodes(); else if (source.equals(miShowScribblePad)) { ProjectCompendium.APP.onShowScribblePad(); miShowScribblePad.setEnabled(false); miHideScribblePad.setEnabled(true); miSaveScribblePad.setEnabled(true); miClearScribblePad.setEnabled(true); } else if (source.equals(miHideScribblePad)) { ProjectCompendium.APP.onHideScribblePad(); miShowScribblePad.setEnabled(true); miHideScribblePad.setEnabled(false); miSaveScribblePad.setEnabled(false); miClearScribblePad.setEnabled(false); } else if (source.equals(miSaveScribblePad)) ProjectCompendium.APP.onSaveScribblePad(); else if (source.equals(miClearScribblePad)) ProjectCompendium.APP.onClearScribblePad(); else if (source.equals(miProjectOptions)) { UIProjectOptionsDialog dialog = new UIProjectOptionsDialog(ProjectCompendium.APP, ProjectCompendium.APP.getModel()); dialog.setVisible(true); } else if (source.equals(miOptions)) { UIOptionsDialog dialog = new UIOptionsDialog(ProjectCompendium.APP); dialog.setVisible(true); } else if (source.equals(miFocusFrames)) { JDesktopPane pane = ProjectCompendium.APP.getDesktop(); JInternalFrame frame = pane.getSelectedFrame(); if (frame instanceof UIMapViewFrame) { UIMapViewFrame mapframe = (UIMapViewFrame) frame; mapframe.getViewPane().requestFocus(); } else if (frame instanceof UIListViewFrame) { UIListViewFrame listframe = (UIListViewFrame) frame; listframe.getUIList().getList().requestFocus(); } } else if (source.equals(miFocusTabs)) { JTabbedPane oTabbedPane = ProjectCompendium.APP.oTabbedPane; if (oTabbedPane.getTabCount() > 0) { oTabbedPane.requestFocus(); } } ProjectCompendium.APP.setDefaultCursor(); }