From 8c310a44f1d0ac7bce0f70df327d07c920157103 Mon Sep 17 00:00:00 2001 From: Takeshi Morita Date: Mon, 16 Mar 2015 15:22:36 +0900 Subject: [PATCH] Bug Fixes and 1.0 released * Bug Fixes and 1.0 released. --- README.ja.md | 3 +- README.md | 3 +- pom.xml | 19 +- src/main/assembly/descriptor-bin.xml | 2 +- src/main/java/net/sourceforge/mr3/MR3.java | 148 +-- .../mr3/actions/AbstractActionFile.java | 28 +- .../sourceforge/mr3/jgraph/GraphManager.java | 137 +-- .../mr3/resources/version_info.html | 3 +- .../net/sourceforge/mr3/ui/ExportDialog.java | 63 +- .../sourceforge/mr3/ui/HistoryManager.java | 972 ++++++++++-------- .../net/sourceforge/mr3/ui/ImportDialog.java | 62 +- .../net/sourceforge/mr3/ui/OptionDialog.java | 290 +++--- .../mr3/util/NTripleFileFilter.java | 42 +- .../sourceforge/mr3/util/OWLFileFilter.java | 36 +- .../sourceforge/mr3/util/RDFsFileFilter.java | 44 +- .../mr3/util/TurtleFileFilter.java | 36 +- 16 files changed, 931 insertions(+), 957 deletions(-) diff --git a/README.ja.md b/README.ja.md index d2f4fbde..caeaa741 100644 --- a/README.ja.md +++ b/README.ja.md @@ -44,6 +44,7 @@ MR3はフリーソフトウェアです.Free Software Foundation * [JFontChooser](http://jfontchooser.sourceforge.jp/)([License](http://sourceforge.jp/softwaremap/trove_list.php?form_cat=188)) * [Apache ORO](http://attic.apache.org/projects/jakarta-oro.html)([License](http://www.apache.org/licenses/LICENSE-2.0)) * [Silk Icons](http://www.famfamfam.com)([License](http://creativecommons.org/licenses/by/2.5/)) +* [exewrap](http://exewrap.sourceforge.jp/)([License](http://exewrap.sourceforge.jp/#license)) ## プロジェクトメンバー * 森田 武史 (青山学院大学 社会情報学部) @@ -52,5 +53,5 @@ MR3はフリーソフトウェアです.Free Software Foundation * 山口 高平 (慶應義塾大学 理工学部) ## 連絡先 -* 森田 武史 (t_morita@si.aoyama.ac.jp) +* 森田 武史 (t_morita@ae.keio.ac.jp) diff --git a/README.md b/README.md index ad6c99ce..4f9523f9 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ MR3 uses the following libraries. * [JFontChooser](http://jfontchooser.sourceforge.jp/)([License](http://sourceforge.jp/softwaremap/trove_list.php?form_cat=188)) * [Apache ORO](http://attic.apache.org/projects/jakarta-oro.html)([License](http://www.apache.org/licenses/LICENSE-2.0)) * [Silk Icons](http://www.famfamfam.com)([License](http://creativecommons.org/licenses/by/2.5/)) +* [exewrap](http://exewrap.sourceforge.jp/)([License](http://exewrap.sourceforge.jp/#license)) ## Project Member * Takeshi Morita (School of Social Informatics, Aoyama Gakuin University, Japan) @@ -51,5 +52,5 @@ MR3 uses the following libraries. * Takahira Yamaguchi (Faculty of Science and Technology, Keio University, Japan) ## Contact -* Takeshi Morita (t_morita@si.aoyama.ac.jp) +* Takeshi Morita (t_morita@ae.keio.ac.jp) diff --git a/pom.xml b/pom.xml index 01f61e47..4be6cc74 100644 --- a/pom.xml +++ b/pom.xml @@ -181,6 +181,15 @@ JFontChooser Repository http://jfontchooser.sourceforge.jp/repository/ + + net.sourceforge.doddle-owl + http://doddle-owl.sourceforge.net/m2repository + + + repository.apache.org + Apache Jena Repository + https://repository.apache.org/content/repositories/releases/ + @@ -199,11 +208,6 @@ jgraphaddons 1.0.2 - - net.infonode - idw - 1.6.1_gpl - oro oro @@ -215,6 +219,11 @@ 2.12.1 pom + + net.infonode + idw + 1.6.1_gpl + say.swing jfontchooser diff --git a/src/main/assembly/descriptor-bin.xml b/src/main/assembly/descriptor-bin.xml index 7ad7654c..6cd3f785 100644 --- a/src/main/assembly/descriptor-bin.xml +++ b/src/main/assembly/descriptor-bin.xml @@ -26,6 +26,7 @@ *.xml *.jar + License.txt @@ -33,7 +34,6 @@ ./ *.md - License.txt diff --git a/src/main/java/net/sourceforge/mr3/MR3.java b/src/main/java/net/sourceforge/mr3/MR3.java index c86dc750..42a3b739 100644 --- a/src/main/java/net/sourceforge/mr3/MR3.java +++ b/src/main/java/net/sourceforge/mr3/MR3.java @@ -87,8 +87,8 @@ public class MR3 extends JFrame implements ChangeListener { public MR3() { MR3Constants.loadResourceBundle(); initWeakReferences(); - mr3LogConsole = new MR3LogConsole(this, Translator.getString("LogConsole.Title"), Utilities - .getImageIcon("application_xp_terminal.png").getImage()); + mr3LogConsole = new MR3LogConsole(this, Translator.getString("LogConsole.Title"), Utilities.getImageIcon( + "application_xp_terminal.png").getImage()); desktopTabbedPane = new JTabbedPane(); desktopTabbedPane.addChangeListener(this); @@ -109,6 +109,9 @@ public MR3() { initOptions(); HistoryManager.setGraphManager(gmanager); + String logFilePath = userPrefs.get(PrefConstants.logFile, System.getProperty("user.dir") + "/" + + HistoryManager.DEFAULT_LOG_FILE_NAME); + HistoryManager.initLogger(logFilePath); } public JTabbedPane getDesktopTabbedPane() { @@ -150,44 +153,32 @@ private void initWeakReferences() { private AbstractAction showOptionDialogAction; private AbstractAction showVersionInfoAction; - private ImageIcon CPR_ICON = Utilities.getImageIcon(Translator - .getString("Component.Window.DeployCPRWindows.Icon")); - private ImageIcon CR_ICON = Utilities.getImageIcon(Translator - .getString("Component.Window.DeployCRWindows.Icon")); - private ImageIcon PR_ICON = Utilities.getImageIcon(Translator - .getString("Component.Window.DeployPRWindows.Icon")); + private ImageIcon CPR_ICON = Utilities.getImageIcon(Translator.getString("Component.Window.DeployCPRWindows.Icon")); + private ImageIcon CR_ICON = Utilities.getImageIcon(Translator.getString("Component.Window.DeployCRWindows.Icon")); + private ImageIcon PR_ICON = Utilities.getImageIcon(Translator.getString("Component.Window.DeployPRWindows.Icon")); private void initActions() { newProjectAction = new NewProject(this); openProjectAction = new OpenProject(this); - saveProjectAction = new SaveProject(this, SaveProject.SAVE_PROJECT, - SaveProject.SAVE_PROJECT_ICON); - saveProjectAsAction = new SaveProject(this, SaveProject.SAVE_AS_PROJECT, - SaveProject.SAVE_AS_PROJECT_ICON); + saveProjectAction = new SaveProject(this, SaveProject.SAVE_PROJECT, SaveProject.SAVE_PROJECT_ICON); + saveProjectAsAction = new SaveProject(this, SaveProject.SAVE_AS_PROJECT, SaveProject.SAVE_AS_PROJECT_ICON); showPluginManagerAction = new OpenPluginManagerAction(this, Translator.getString("Component.Tools.Plugins.Text")); showValidatorAction = new ShowValidator(this); - toFrontRDFEditorAction = new EditorSelect(this, EditorSelect.RDF_EDITOR, - EditorSelect.RDF_EDITOR_ICON); - toFrontClassEditorAction = new EditorSelect(this, EditorSelect.CLASS_EDITOR, - EditorSelect.CLASS_EDITOR_ICON); + toFrontRDFEditorAction = new EditorSelect(this, EditorSelect.RDF_EDITOR, EditorSelect.RDF_EDITOR_ICON); + toFrontClassEditorAction = new EditorSelect(this, EditorSelect.CLASS_EDITOR, EditorSelect.CLASS_EDITOR_ICON); toFrontPropertyEditorAction = new EditorSelect(this, EditorSelect.PROPERTY_EDITOR, EditorSelect.PROPERTY_EDITOR_ICON); - deployWindowCPRAction = new DeployWindows(this, - Translator.getString("Component.Window.DeployCPRWindows.Text"), CPR_ICON, - DeployType.CPR, "control alt R"); - deployWindowCRAction = new DeployWindows(this, - Translator.getString("Component.Window.DeployCRWindows.Text"), CR_ICON, - DeployType.CR, "control alt C"); - deployWindowPRAction = new DeployWindows(this, - Translator.getString("Component.Window.DeployPRWindows.Text"), PR_ICON, - DeployType.PR, "control alt P"); + deployWindowCPRAction = new DeployWindows(this, Translator.getString("Component.Window.DeployCPRWindows.Text"), + CPR_ICON, DeployType.CPR, "control alt R"); + deployWindowCRAction = new DeployWindows(this, Translator.getString("Component.Window.DeployCRWindows.Text"), + CR_ICON, DeployType.CR, "control alt C"); + deployWindowPRAction = new DeployWindows(this, Translator.getString("Component.Window.DeployPRWindows.Text"), + PR_ICON, DeployType.PR, "control alt P"); showAttrDialogAction = new ShowAttrDialog(this); showNSTableDialogAction = new ShowNSTableDialog(this); - showImportDialogAction = new ShowImportDialog(this, - Translator.getString("Component.Window.ImportDialog.Text")); - showExportDialogAction = new ShowExportDialog(this, - Translator.getString("Component.Window.ExportDialog.Text")); + showImportDialogAction = new ShowImportDialog(this, Translator.getString("Component.Window.ImportDialog.Text")); + showExportDialogAction = new ShowExportDialog(this, Translator.getString("Component.Window.ExportDialog.Text")); findResAction = new FindResAction(null, gmanager); showProjectInfoAction = new ShowProjectInfoDialog(this); showLogConsoleAciton = new ShowLogConsole(this); @@ -236,10 +227,8 @@ private JToolBar createToolBar() { toolbar.add(findField); findResNum = new JLabel("(0/0)"); toolbar.add(findResNum); - ImageIcon PREV_ICON = Utilities.getImageIcon(Translator - .getString("ToolBar.FindField.Icon.prev")); - ImageIcon NEXT_ICON = Utilities.getImageIcon(Translator - .getString("ToolBar.FindField.Icon.next")); + ImageIcon PREV_ICON = Utilities.getImageIcon(Translator.getString("ToolBar.FindField.Icon.prev")); + ImageIcon NEXT_ICON = Utilities.getImageIcon(Translator.getString("ToolBar.FindField.Icon.next")); findPrevButton = new JButton(PREV_ICON); findPrevButton.addActionListener(new PrevResourceAction()); findNextButton = new JButton(NEXT_ICON); @@ -297,8 +286,7 @@ private void setFindList() { if (findField.getText().length() == 0) { findList = NULL; } else { - findList = gmanager.getFindResourceDialog().getFindResources(findField.getText(), - FindActionType.URI); + findList = gmanager.getFindResourceDialog().getFindResources(findField.getText(), FindActionType.URI); } } @@ -477,10 +465,8 @@ private JMenu getEditMenu() { private JMenu getSelectMenu() { JMenu selectMenu = new JMenu(Translator.getString("Component.Select.Text")); - selectMenu.add(new SelectNodes(gmanager, GraphType.RDF, Translator - .getString("Component.Select.RDF.Text"))); - selectMenu.add(new SelectNodes(gmanager, GraphType.CLASS, Translator - .getString("Component.Select.Class.Text"))); + selectMenu.add(new SelectNodes(gmanager, GraphType.RDF, Translator.getString("Component.Select.RDF.Text"))); + selectMenu.add(new SelectNodes(gmanager, GraphType.CLASS, Translator.getString("Component.Select.Class.Text"))); selectMenu.add(new SelectNodes(gmanager, GraphType.PROPERTY, Translator .getString("Component.Select.Property.Text"))); @@ -511,54 +497,43 @@ private JMenu getFileMenu() { } private void initOptions() { - GraphLayoutUtilities.LAYOUT_TYPE = userPrefs.get(PrefConstants.LAYOUT_TYPE, - GraphLayoutUtilities.LAYOUT_TYPE); - GraphLayoutUtilities.RDF_LAYOUT_DIRECTION = userPrefs.get( - PrefConstants.RDF_LAYOUT_DIRECTION, GraphLayoutUtilities.RDF_LAYOUT_DIRECTION); - GraphLayoutUtilities.RDF_LAYOUT_DIRECTION = changeDirectionWithLanguage( - GraphLayoutUtilities.RDF_LAYOUT_DIRECTION, + GraphLayoutUtilities.LAYOUT_TYPE = userPrefs.get(PrefConstants.LAYOUT_TYPE, GraphLayoutUtilities.LAYOUT_TYPE); + GraphLayoutUtilities.RDF_LAYOUT_DIRECTION = userPrefs.get(PrefConstants.RDF_LAYOUT_DIRECTION, GraphLayoutUtilities.RDF_LAYOUT_DIRECTION); - GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION = userPrefs.get( - PrefConstants.CLASS_LAYOUT_DIRECTION, GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION); - GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION = changeDirectionWithLanguage( - GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION, + GraphLayoutUtilities.RDF_LAYOUT_DIRECTION = changeDirectionWithLanguage( + GraphLayoutUtilities.RDF_LAYOUT_DIRECTION, GraphLayoutUtilities.RDF_LAYOUT_DIRECTION); + GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION = userPrefs.get(PrefConstants.CLASS_LAYOUT_DIRECTION, GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION); - GraphLayoutUtilities.PROPERTY_LAYOUT_DIRECTION = userPrefs.get( - PrefConstants.PROPERTY_LAYOUT_DIRECTION, + GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION = changeDirectionWithLanguage( + GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION, GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION); + GraphLayoutUtilities.PROPERTY_LAYOUT_DIRECTION = userPrefs.get(PrefConstants.PROPERTY_LAYOUT_DIRECTION, GraphLayoutUtilities.PROPERTY_LAYOUT_DIRECTION); GraphLayoutUtilities.PROPERTY_LAYOUT_DIRECTION = changeDirectionWithLanguage( - GraphLayoutUtilities.PROPERTY_LAYOUT_DIRECTION, - GraphLayoutUtilities.PROPERTY_LAYOUT_DIRECTION); - GraphLayoutUtilities.RDF_VERTICAL_SPACE = Integer.parseInt(userPrefs.get( - PrefConstants.RDF_VERTICAL_SPACE, + GraphLayoutUtilities.PROPERTY_LAYOUT_DIRECTION, GraphLayoutUtilities.PROPERTY_LAYOUT_DIRECTION); + GraphLayoutUtilities.RDF_VERTICAL_SPACE = Integer.parseInt(userPrefs.get(PrefConstants.RDF_VERTICAL_SPACE, Integer.toString(GraphLayoutUtilities.VERTICAL_SPACE))); - GraphLayoutUtilities.RDF_HORIZONTAL_SPACE = Integer.parseInt(userPrefs.get( - PrefConstants.RDF_HORIZONTAL_SPACE, + GraphLayoutUtilities.RDF_HORIZONTAL_SPACE = Integer.parseInt(userPrefs.get(PrefConstants.RDF_HORIZONTAL_SPACE, Integer.toString(GraphLayoutUtilities.HORIZONTAL_SPACE))); - GraphLayoutUtilities.CLASS_VERTICAL_SPACE = Integer.parseInt(userPrefs.get( - PrefConstants.CLASS_VERTICAL_SPACE, + GraphLayoutUtilities.CLASS_VERTICAL_SPACE = Integer.parseInt(userPrefs.get(PrefConstants.CLASS_VERTICAL_SPACE, Integer.toString(GraphLayoutUtilities.VERTICAL_SPACE))); GraphLayoutUtilities.CLASS_HORIZONTAL_SPACE = Integer.parseInt(userPrefs.get( - PrefConstants.CLASS_HORIZONTAL_SPACE, - Integer.toString(GraphLayoutUtilities.HORIZONTAL_SPACE))); + PrefConstants.CLASS_HORIZONTAL_SPACE, Integer.toString(GraphLayoutUtilities.HORIZONTAL_SPACE))); GraphLayoutUtilities.PROPERTY_VERTICAL_SPACE = Integer.parseInt(userPrefs.get( - PrefConstants.PROPERTY_VERTICAL_SPACE, - Integer.toString(GraphLayoutUtilities.VERTICAL_SPACE))); + PrefConstants.PROPERTY_VERTICAL_SPACE, Integer.toString(GraphLayoutUtilities.VERTICAL_SPACE))); GraphLayoutUtilities.PROPERTY_HORIZONTAL_SPACE = Integer.parseInt(userPrefs.get( - PrefConstants.PROPERTY_HORIZONTAL_SPACE, - Integer.toString(GraphLayoutUtilities.HORIZONTAL_SPACE))); + PrefConstants.PROPERTY_HORIZONTAL_SPACE, Integer.toString(GraphLayoutUtilities.HORIZONTAL_SPACE))); MR3CellMaker.CELL_WIDTH = Integer.parseInt(userPrefs.get(PrefConstants.NODE_WIDTH, Integer.toString(MR3CellMaker.CELL_WIDTH))); MR3CellMaker.CELL_HEIGHT = Integer.parseInt(userPrefs.get(PrefConstants.NODE_HEIGHT, Integer.toString(MR3CellMaker.CELL_HEIGHT))); - RDFResourceCell.rdfResourceColor = new Color(userPrefs.getInt( - PrefConstants.RDFResourceColor, RDFResourceCell.rdfResourceColor.getRGB())); + RDFResourceCell.rdfResourceColor = new Color(userPrefs.getInt(PrefConstants.RDFResourceColor, + RDFResourceCell.rdfResourceColor.getRGB())); RDFLiteralCell.literalColor = new Color(userPrefs.getInt(PrefConstants.LiteralColor, RDFLiteralCell.literalColor.getRGB())); - OntClassCell.classColor = new Color(userPrefs.getInt(PrefConstants.ClassColor, - OntClassCell.classColor.getRGB())); + OntClassCell.classColor = new Color( + userPrefs.getInt(PrefConstants.ClassColor, OntClassCell.classColor.getRGB())); OntPropertyCell.propertyColor = new Color(userPrefs.getInt(PrefConstants.PropertyColor, OntPropertyCell.propertyColor.getRGB())); GraphUtilities.selectedColor = new Color(userPrefs.getInt(PrefConstants.SelectedColor, @@ -570,8 +545,8 @@ private void initOptions() { setLocation(userPrefs.getInt(PrefConstants.WindowPositionX, 50), userPrefs.getInt(PrefConstants.WindowPositionY, 50)); - HistoryManager.resetFileAppender(userPrefs.get(PrefConstants.logFile, - System.getProperty("user.dir") + "\\" + HistoryManager.DEFAULT_LOG_FILE_NAME)); + HistoryManager.resetFileAppender(userPrefs.get(PrefConstants.logFile, System.getProperty("user.dir") + "\\" + + HistoryManager.DEFAULT_LOG_FILE_NAME)); setTitle("MR^3"); setVisible(true); @@ -591,8 +566,7 @@ public static MR3Project getCurrentProject() { } public static void setCurrentProjectName() { - String tabName = getCurrentProject().getCurrentProjectFile().getName() - .replaceAll(".mr3", ""); + String tabName = getCurrentProject().getCurrentProjectFile().getName().replaceAll(".mr3", ""); getCurrentProject().getTabComponent().setTabName(tabName); } @@ -620,21 +594,19 @@ private JMenu getViewMenu() { menu.add(idView); menu.add(labelView); menu.addSeparator(); - showTypeCellBox = new JCheckBoxMenuItem(Translator.getString("Component.View.Type.Text"), - true); + showTypeCellBox = new JCheckBoxMenuItem(Translator.getString("Component.View.Type.Text"), true); gmanager.setIsShowTypeCell(true); showTypeCellBox.addActionListener(new ShowTypeCellAction()); menu.add(showTypeCellBox); // menu.add(new ShowGraphNodeAction("Show Graph Node")); - showRDFPropertyLabelBox = new JCheckBoxMenuItem( - Translator.getString("Component.View.RDFPropertyLabel.Text"), true); + showRDFPropertyLabelBox = new JCheckBoxMenuItem(Translator.getString("Component.View.RDFPropertyLabel.Text"), + true); showRDFPropertyLabelBox.addActionListener(new ShowRDFPropertyLabelAction()); menu.add(showRDFPropertyLabelBox); - showToolTips = new JCheckBoxMenuItem(Translator.getString("Component.View.ToolTips.Text"), - true); + showToolTips = new JCheckBoxMenuItem(Translator.getString("Component.View.ToolTips.Text"), true); showToolTips.addActionListener(new ShowToolTipsAction()); ToolTipManager.sharedInstance().setEnabled(true); menu.add(showToolTips); @@ -646,12 +618,9 @@ private JMenu getViewMenu() { JMenu applyLayout = new JMenu(Translator.getString("Component.View.ApplyLayout.Text")); menu.add(applyLayout); - applyLayout.add(new GraphLayoutAction(gmanager, GraphType.RDF, - GraphLayoutAction.layoutRDFGraphIcon)); - applyLayout.add(new GraphLayoutAction(gmanager, GraphType.CLASS, - GraphLayoutAction.layoutClassGraphIcon)); - applyLayout.add(new GraphLayoutAction(gmanager, GraphType.PROPERTY, - GraphLayoutAction.layoutPropertyGraphIcon)); + applyLayout.add(new GraphLayoutAction(gmanager, GraphType.RDF, GraphLayoutAction.layoutRDFGraphIcon)); + applyLayout.add(new GraphLayoutAction(gmanager, GraphType.CLASS, GraphLayoutAction.layoutClassGraphIcon)); + applyLayout.add(new GraphLayoutAction(gmanager, GraphType.PROPERTY, GraphLayoutAction.layoutPropertyGraphIcon)); return menu; } @@ -777,10 +746,8 @@ public void actionPerformed(ActionEvent e) { public void newProject(String basePath) { gmanager.getAttrDialog().setNullPanel(); gmanager.getNSTableDialog().setDefaultNSPrefix(); - Color backgroundColor = new Color(userPrefs.getInt(PrefConstants.BackgroundColor, - DESKTOP_BACK_COLOR.getRGB())); - TabComponent tabComponent = new TabComponent(this, - Translator.getString("Component.File.NewProject.Text")); + Color backgroundColor = new Color(userPrefs.getInt(PrefConstants.BackgroundColor, DESKTOP_BACK_COLOR.getRGB())); + TabComponent tabComponent = new TabComponent(this, Translator.getString("Component.File.NewProject.Text")); MR3Project project = new MR3Project(gmanager, basePath, backgroundColor, tabComponent); desktopTabbedPane.addTab(null, project); desktopTabbedPane.setTabComponentAt(desktopTabbedPane.getTabCount() - 1, tabComponent); @@ -822,8 +789,7 @@ public static void initialize(Class cls) { System.setProperty("apple.laf.useScreenMenuBar", "true"); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); System.setProperty("swing.plaf.metal.controlFont", Translator.getString("ControlFont")); - System.setProperty("swing.plaf.windows.controlFont", - Translator.getString("ControlFont")); + System.setProperty("swing.plaf.windows.controlFont", Translator.getString("ControlFont")); } catch (Exception ex) { ex.printStackTrace(); } diff --git a/src/main/java/net/sourceforge/mr3/actions/AbstractActionFile.java b/src/main/java/net/sourceforge/mr3/actions/AbstractActionFile.java index 4b865214..ecad2822 100644 --- a/src/main/java/net/sourceforge/mr3/actions/AbstractActionFile.java +++ b/src/main/java/net/sourceforge/mr3/actions/AbstractActionFile.java @@ -126,9 +126,9 @@ protected InputStream getInputStream(String ext) { } private static ProjectFileFilter mr3FileFilter = new ProjectFileFilter(); - private static OWLFileFilter owlFileFilter = new OWLFileFilter(); - private static RDFsFileFilter rdfsFileFilter = new RDFsFileFilter(); - private static NTripleFileFilter n3FileFilter = new NTripleFileFilter(); + private static OWLFileFilter owlFileFilter = new OWLFileFilter(true); + private static RDFsFileFilter rdfsFileFilter = new RDFsFileFilter(true); + private static NTripleFileFilter n3FileFilter = new NTripleFileFilter(true); private static PNGFileFilter pngFileFilter = new PNGFileFilter(); protected File getFile(boolean isOpenFile, String extension) { @@ -173,8 +173,8 @@ private String complementMR3Extension(String tmp, String extension) { private String complementRDFsExtension(String tmp, String extension) { String ext = (extension != null) ? "." + extension.toLowerCase() : ""; - if (extension != null && !tmp.toLowerCase().endsWith(".rdf") - && !tmp.toLowerCase().endsWith(".rdfs") && !tmp.toLowerCase().endsWith(".n3")) { + if (extension != null && !tmp.toLowerCase().endsWith(".rdf") && !tmp.toLowerCase().endsWith(".rdfs") + && !tmp.toLowerCase().endsWith(".n3")) { tmp += ext; } return tmp; @@ -190,8 +190,7 @@ protected void saveProject(File file) { MR3.getCurrentProject().setCurrentProjectFile(file); MR3.setCurrentProjectName(); } catch (FileNotFoundException e2) { - JOptionPane.showMessageDialog(null, "FileNotFound", "Warning", - JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(null, "FileNotFound", "Warning", JOptionPane.ERROR_MESSAGE); } catch (UnsupportedEncodingException e3) { e3.printStackTrace(); } @@ -209,8 +208,8 @@ protected void saveProjectAs() { } protected void exitProgram(Frame frame) { - int messageType = JOptionPane.showConfirmDialog(frame, Translator.getString("SaveChanges"), - "MR^3 - " + Translator.getString("ExitProgram"), JOptionPane.YES_NO_CANCEL_OPTION, + int messageType = JOptionPane.showConfirmDialog(frame, Translator.getString("SaveChanges"), "MR^3 - " + + Translator.getString("ExitProgram"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (messageType == JOptionPane.YES_OPTION) { confirmAllExitProject(frame); @@ -229,12 +228,10 @@ protected void exitProject(MR3Project project) { File currentProjectFile = project.getCurrentProjectFile(); if (isNewProjectFile(project)) { saveProjectAs(); - HistoryManager.saveHistory(HistoryType.SAVE_PROJECT_AS, - currentProjectFile.getAbsolutePath()); + HistoryManager.saveHistory(HistoryType.SAVE_PROJECT_AS, currentProjectFile.getAbsolutePath()); } else { saveProject(currentProjectFile); - HistoryManager.saveHistory(HistoryType.SAVE_PROJECT, - currentProjectFile.getAbsolutePath()); + HistoryManager.saveHistory(HistoryType.SAVE_PROJECT, currentProjectFile.getAbsolutePath()); } } @@ -260,9 +257,8 @@ protected boolean isNewProjectFile(MR3Project currentProject) { protected int confirmExitProject(Frame root, MR3Project project) { String title = project.getTitle(); - int messageType = JOptionPane.showConfirmDialog(root, - title + "\n" + Translator.getString("SaveChanges"), "MR^3 - " + title, - JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); + int messageType = JOptionPane.showConfirmDialog(root, title + "\n" + Translator.getString("SaveChanges"), + "MR^3 - " + title, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); if (messageType == JOptionPane.YES_OPTION) { exitProject(project); } diff --git a/src/main/java/net/sourceforge/mr3/jgraph/GraphManager.java b/src/main/java/net/sourceforge/mr3/jgraph/GraphManager.java index 6c24ba47..d1b4d7cd 100644 --- a/src/main/java/net/sourceforge/mr3/jgraph/GraphManager.java +++ b/src/main/java/net/sourceforge/mr3/jgraph/GraphManager.java @@ -359,28 +359,25 @@ public String[] getResourceContainer() { return userPrefs.get(PrefConstants.ResourceContainer, "").split(","); } - public static final String CLASS_CLASS_LIST = RDFS.Class.toString() + " " - + OWL.Class.toString(); + public static final String CLASS_CLASS_LIST = RDFS.Class.toString() + " " + OWL.Class.toString(); public String getDefaultClassClass() { return userPrefs.get(PrefConstants.DefaultClassClass, RDFS.Class.getURI()); } public Set getClassClassList() { - return getMetaClassList(userPrefs.get(PrefConstants.ClassClassList, CLASS_CLASS_LIST) - .split(" ")); + return getMetaClassList(userPrefs.get(PrefConstants.ClassClassList, CLASS_CLASS_LIST).split(" ")); } - public static final String PROPERTY_CLASS_LIST = RDF.Property.toString() + " " - + OWL.ObjectProperty.toString() + " " + OWL.DatatypeProperty.toString(); + public static final String PROPERTY_CLASS_LIST = RDF.Property.toString() + " " + OWL.ObjectProperty.toString() + + " " + OWL.DatatypeProperty.toString(); public String getDefaultPropertyClass() { return userPrefs.get(PrefConstants.DefaultPropertyClass, RDF.Property.getURI()); } public Set getPropertyClassList() { - return getMetaClassList(userPrefs.get(PrefConstants.PropClassList, PROPERTY_CLASS_LIST) - .split(" ")); + return getMetaClassList(userPrefs.get(PrefConstants.PropClassList, PROPERTY_CLASS_LIST).split(" ")); } public Set getMetaClassList() { @@ -390,8 +387,7 @@ public Set getMetaClassList() { } public void findMetaClass(Model orgModel, Resource supClass, Set set) { - for (ResIterator i = orgModel.listSubjectsWithProperty(RDFS.subClassOf, supClass); i - .hasNext();) { + for (ResIterator i = orgModel.listSubjectsWithProperty(RDFS.subClassOf, supClass); i.hasNext();) { Resource subject = i.nextResource(); set.add(subject); findMetaClass(orgModel, subject, set); @@ -435,8 +431,7 @@ public Set getClassSet() { Set classSet = new HashSet(); for (Object cell : getCurrentClassGraph().getAllCells()) { if (RDFGraph.isRDFSClassCell(cell)) { - RDFSInfo info = (RDFSInfo) GraphConstants.getValue(((GraphCell) cell) - .getAttributes()); + RDFSInfo info = (RDFSInfo) GraphConstants.getValue(((GraphCell) cell).getAttributes()); classSet.add(info.getURIStr()); } } @@ -447,8 +442,7 @@ public Set getPropertySet() { Set propertySet = new HashSet(); for (Object cell : getCurrentPropertyGraph().getAllCells()) { if (RDFGraph.isRDFSPropertyCell(cell)) { - RDFSInfo info = (RDFSInfo) GraphConstants.getValue(((GraphCell) cell) - .getAttributes()); + RDFSInfo info = (RDFSInfo) GraphConstants.getValue(((GraphCell) cell).getAttributes()); propertySet.add(info.getURIStr()); } } @@ -508,8 +502,7 @@ private boolean isRDFResourceDuplicated(String uri, Object cell, GraphType type) for (int i = 0; i < rdfCells.length; i++) { GraphCell rdfCell = (GraphCell) rdfCells[i]; if (rdfCell instanceof RDFResourceCell) { - RDFResourceInfo resInfo = (RDFResourceInfo) GraphConstants.getValue(rdfCell - .getAttributes()); + RDFResourceInfo resInfo = (RDFResourceInfo) GraphConstants.getValue(rdfCell.getAttributes()); if (resInfo == null) { resInfo = (RDFResourceInfo) GraphConstants.getValue(rdfCell.getAttributes()); } @@ -553,8 +546,8 @@ private boolean isRDFResourceDuplicated(String uri, Object cell, GraphType type) public boolean isEmptyURI(String uri) { if (uri.equals("")) { - JOptionPane.showMessageDialog(desktopTabbedPane, - Translator.getString("Warning.Message4"), WARNING, JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(desktopTabbedPane, Translator.getString("Warning.Message4"), WARNING, + JOptionPane.ERROR_MESSAGE); return true; } return false; @@ -562,16 +555,15 @@ public boolean isEmptyURI(String uri) { public boolean isDuplicatedWithDialog(String uri, Object cell, GraphType type) { if (isDuplicated(uri, cell, type)) { - JOptionPane.showMessageDialog(getGraph(type), Translator.getString("Warning.Message1"), - WARNING, JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(getGraph(type), Translator.getString("Warning.Message1"), WARNING, + JOptionPane.ERROR_MESSAGE); return true; } return false; } public boolean isDuplicated(String uri, Object cell, GraphType type) { - return (getCurrentRDFSInfoMap().isDuplicated(uri, cell, type) || isRDFResourceDuplicated( - uri, cell, type)); + return (getCurrentRDFSInfoMap().isDuplicated(uri, cell, type) || isRDFResourceDuplicated(uri, cell, type)); } /** @@ -604,8 +596,7 @@ public Set getRDFNameSpaceSet() { for (int i = 0; i < rdfCells.length; i++) { GraphCell cell = (GraphCell) rdfCells[i]; if (RDFGraph.isRDFResourceCell(cell)) { - RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell - .getAttributes()); + RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell.getAttributes()); Resource uri = info.getURI(); nameSpaces.add(uri.getNameSpace()); } @@ -632,8 +623,7 @@ public Set getPropertyNameSpaceSet() { Set nameSpaces = new HashSet(); for (Object cell : getCurrentPropertyGraph().getAllCells()) { if (RDFGraph.isRDFSPropertyCell(cell)) { - RDFSInfo info = (RDFSInfo) GraphConstants.getValue(((GraphCell) cell) - .getAttributes()); + RDFSInfo info = (RDFSInfo) GraphConstants.getValue(((GraphCell) cell).getAttributes()); Resource uri = info.getURI(); nameSpaces.add(uri.getNameSpace()); } @@ -657,10 +647,8 @@ public void setNodeBounds(Map uriNodeInfoMap) { } else if (rdfsInfoMap.isPropertyCell(uri)) { continue; } else if (uri.getURI().matches(MR3Resource.Literal.getURI() + ".*")) { - MR3Literal literal = new MR3Literal(rec.getString(), rec.getLanguage(), - rec.getDatatype()); - DefaultGraphCell litCell = (DefaultGraphCell) cellMaker.insertRDFLiteral( - rec.getRectangle(), literal); + MR3Literal literal = new MR3Literal(rec.getString(), rec.getLanguage(), rec.getDatatype()); + DefaultGraphCell litCell = (DefaultGraphCell) cellMaker.insertRDFLiteral(rec.getRectangle(), literal); DefaultGraphCell source = (DefaultGraphCell) getRDFResourceCell(rec.getResource()); if (source == null) { // System.out.println("s: " + source); @@ -669,8 +657,8 @@ public void setNodeBounds(Map uriNodeInfoMap) { GraphCell propCell = (GraphCell) rdfsInfoMap.getPropertyCell(rec.getProperty()); if (propCell != null) { RDFSInfo info = (RDFSInfo) GraphConstants.getValue(propCell.getAttributes()); - cellMaker.connect((Port) source.getChildAt(0), (Port) litCell.getChildAt(0), - info, getCurrentRDFGraph()); + cellMaker.connect((Port) source.getChildAt(0), (Port) litCell.getChildAt(0), info, + getCurrentRDFGraph()); } } MR3.STATUS_BAR.addValue(); @@ -693,10 +681,8 @@ public void setCellValue(GraphCell cell, String value) { } else if (RDFGraph.isRDFResourceCell(cell)) { dim = GraphUtilities.getAutoNodeDimension(this, value); if (isShowTypeCell) { - RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell - .getAttributes()); - RDFSInfo typeInfo = (RDFSInfo) GraphConstants.getValue(info.getTypeCell() - .getAttributes()); + RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell.getAttributes()); + RDFSInfo typeInfo = (RDFSInfo) GraphConstants.getValue(info.getTypeCell().getAttributes()); Dimension typeDim = GraphUtilities.getAutoNodeDimension(this, getRDFSNodeValue(info.getType(), typeInfo)); @@ -800,8 +786,7 @@ public Object getRDFResourceCell(Resource uri) { for (int i = 0; i < cells.length; i++) { if (RDFGraph.isRDFResourceCell(cells[i])) { GraphCell cell = (GraphCell) cells[i]; - RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell - .getAttributes()); + RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell.getAttributes()); /* * Resourceクラスのインスタンスをequalsで比べるとisAnon() * によって,true,falseを決められる.文字列を保存しているuri @@ -937,8 +922,7 @@ public Set getClassInstanceSet(Object type) { for (int i = 0; i < cells.length; i++) { if (RDFGraph.isRDFResourceCell(cells[i])) { GraphCell cell = (GraphCell) cells[i]; - RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell - .getAttributes()); + RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell.getAttributes()); if (info.getTypeCell() == type) { instanceSet.add(cell); } @@ -953,8 +937,7 @@ public Set getClassInstanceInfoSet(RDFSInfo clsInfo) { for (int i = 0; i < cells.length; i++) { if (RDFGraph.isRDFResourceCell(cells[i])) { GraphCell cell = (GraphCell) cells[i]; - RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell - .getAttributes()); + RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell.getAttributes()); if (info.getType().getURI().equals(clsInfo.getURIStr())) { instanceInfoSet.add(info); } @@ -1010,8 +993,7 @@ public Set getFindRDFResult(String key) { for (int i = 0; i < cells.length; i++) { GraphCell cell = (GraphCell) cells[i]; if (RDFGraph.isRDFResourceCell(cell)) { - RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell - .getAttributes()); + RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell.getAttributes()); if (isMatches(key, info.getURI())) { result.add(cell); } @@ -1025,8 +1007,7 @@ public Set getFindRDFResult(String key) { return result; } - public Set getFindRDFResult(String key, - FindResourceDialog.FindActionType findActionType) { + public Set getFindRDFResult(String key, FindResourceDialog.FindActionType findActionType) { Set result = new HashSet(); RDFGraph rdfGraph = getCurrentRDFGraph(); Object[] cells = rdfGraph.getAllCells(); @@ -1034,8 +1015,7 @@ public Set getFindRDFResult(String key, GraphCell cell = (GraphCell) cells[i]; List list = null; if (RDFGraph.isRDFResourceCell(cell)) { - RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell - .getAttributes()); + RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell.getAttributes()); if (findActionType == FindResourceDialog.FindActionType.LABEL) { list = info.getLabelList(); } else if (findActionType == FindResourceDialog.FindActionType.COMMENT) { @@ -1079,8 +1059,7 @@ public Set getFindRDFSResult(String key, RDFGraph graph) { return result; } - public Set getFindRDFSResult(String key, RDFGraph graph, - FindActionType findActionType) { + public Set getFindRDFSResult(String key, RDFGraph graph, FindActionType findActionType) { Set result = new HashSet(); Object[] cells = graph.getAllCells(); @@ -1148,8 +1127,7 @@ public void selectPropertyCell(Object cell) { selectCell(cell, getCurrentPropertyGraph()); } - private Map checkUnRemovablePropertyCells(Object[] cells, List notRmCells, Set notRmList, - Object graph) { + private Map checkUnRemovablePropertyCells(Object[] cells, List notRmCells, Set notRmList, Object graph) { Map classPropMap = new HashMap(); if (isPropertyGraph(graph)) { return classPropMap; @@ -1165,8 +1143,7 @@ private Map checkUnRemovablePropertyCells(Object[] cells, List notRmCells, Set n for (int j = 0; j < propCells.length; j++) { GraphCell propCell = (GraphCell) propCells[j]; if (RDFGraph.isRDFSPropertyCell(propCell)) { - PropertyInfo info = (PropertyInfo) GraphConstants.getValue(propCell - .getAttributes()); + PropertyInfo info = (PropertyInfo) GraphConstants.getValue(propCell.getAttributes()); Set domain = info.getDomain(); Set range = info.getRange(); if (domain.contains(cell) || range.contains(cell)) { @@ -1195,8 +1172,7 @@ private Map checkUnRemovableRDFCells(Object[] cells, List notRmCells, Set notRmL for (int j = 0; j < rdfCells.length; j++) { GraphCell rdfCell = (GraphCell) rdfCells[j]; if (RDFGraph.isRDFResourceCell(rdfCell)) { - RDFResourceInfo rdfInfo = (RDFResourceInfo) GraphConstants.getValue(rdfCell - .getAttributes()); + RDFResourceInfo rdfInfo = (RDFResourceInfo) GraphConstants.getValue(rdfCell.getAttributes()); if (rdfInfo.getTypeCell() == cell) { rdfSet.add(rdfCell); } @@ -1297,10 +1273,9 @@ private boolean removeCells() { List unremovableCells = new ArrayList(); Set unremovableResourceCells = new HashSet(); - Map rdfMap = checkUnRemovableRDFCells(removeCells, unremovableCells, - unremovableResourceCells); - Map propMap = checkUnRemovablePropertyCells(removeCells, unremovableCells, - unremovableResourceCells, removeGraph); + Map rdfMap = checkUnRemovableRDFCells(removeCells, unremovableCells, unremovableResourceCells); + Map propMap = checkUnRemovablePropertyCells(removeCells, unremovableCells, unremovableResourceCells, + removeGraph); if (unremovableCells.isEmpty()) { removeGraph.removeCellsWithEdges(removeCells); @@ -1361,8 +1336,7 @@ public void setVisibleAttrDialog(boolean t) { } private boolean isGraphEmpty() { - return getCurrentRDFGraph().getAllCells().length == 0 - && getCurrentClassGraph().getAllCells().length == 0 + return getCurrentRDFGraph().getAllCells().length == 0 && getCurrentClassGraph().getAllCells().length == 0 && getCurrentPropertyGraph().getAllCells().length == 0; } @@ -1371,22 +1345,19 @@ public void applyLayout(GraphType graphType) { if (GraphType.RDF == graphType) { if (GraphLayoutUtilities.LAYOUT_TYPE.equals(GraphLayoutUtilities.VGJ_TREE_LAYOUT)) { applyVGJRDFLayout(graphType); - } else if (GraphLayoutUtilities.LAYOUT_TYPE - .equals(GraphLayoutUtilities.JGRAPH_TREE_LAYOUT)) { + } else if (GraphLayoutUtilities.LAYOUT_TYPE.equals(GraphLayoutUtilities.JGRAPH_TREE_LAYOUT)) { applyJGraphRDFLayout(); } } else if (GraphType.CLASS == graphType) { if (GraphLayoutUtilities.LAYOUT_TYPE.equals(GraphLayoutUtilities.VGJ_TREE_LAYOUT)) { applyVGJClassLayout(extractRDFS); - } else if (GraphLayoutUtilities.LAYOUT_TYPE - .equals(GraphLayoutUtilities.JGRAPH_TREE_LAYOUT)) { + } else if (GraphLayoutUtilities.LAYOUT_TYPE.equals(GraphLayoutUtilities.JGRAPH_TREE_LAYOUT)) { applyJGraphClassLayout(); } } else if (GraphType.PROPERTY == graphType) { if (GraphLayoutUtilities.LAYOUT_TYPE.equals(GraphLayoutUtilities.VGJ_TREE_LAYOUT)) { applyVGJPropertyLayout(extractRDFS); - } else if (GraphLayoutUtilities.LAYOUT_TYPE - .equals(GraphLayoutUtilities.JGRAPH_TREE_LAYOUT)) { + } else if (GraphLayoutUtilities.LAYOUT_TYPE.equals(GraphLayoutUtilities.JGRAPH_TREE_LAYOUT)) { applyJGraphPropertyLayout(); } } @@ -1414,10 +1385,8 @@ private void applyVGJPropertyLayout(RDFSModelExtraction extractRDFS) { private void applyJGraphPropertyLayout() { RDFGraph propGraph = getCurrentPropertyGraph(); GraphLayoutUtilities.reverseArc(cellMaker, propGraph); - treeLayout.performJGraphTreeLayout(propGraph, - GraphLayoutUtilities.getJGraphPropertyLayoutDirection(), - GraphLayoutUtilities.PROPERTY_VERTICAL_SPACE, - GraphLayoutUtilities.PROPERTY_HORIZONTAL_SPACE); + treeLayout.performJGraphTreeLayout(propGraph, GraphLayoutUtilities.getJGraphPropertyLayoutDirection(), + GraphLayoutUtilities.PROPERTY_VERTICAL_SPACE, GraphLayoutUtilities.PROPERTY_HORIZONTAL_SPACE); GraphLayoutUtilities.reverseArc(cellMaker, propGraph); clearSelection(); } @@ -1444,10 +1413,8 @@ private void applyVGJClassLayout(RDFSModelExtraction extractRDFS) { private void applyJGraphClassLayout() { RDFGraph classGraph = getCurrentClassGraph(); GraphLayoutUtilities.reverseArc(cellMaker, classGraph); - treeLayout.performJGraphTreeLayout(classGraph, - GraphLayoutUtilities.getJGraphClassLayoutDirection(), - GraphLayoutUtilities.CLASS_VERTICAL_SPACE, - GraphLayoutUtilities.CLASS_HORIZONTAL_SPACE); + treeLayout.performJGraphTreeLayout(classGraph, GraphLayoutUtilities.getJGraphClassLayoutDirection(), + GraphLayoutUtilities.CLASS_VERTICAL_SPACE, GraphLayoutUtilities.CLASS_HORIZONTAL_SPACE); GraphLayoutUtilities.reverseArc(cellMaker, classGraph); clearSelection(); } @@ -1457,8 +1424,7 @@ private void applyJGraphClassLayout() { */ private void applyVGJRDFLayout(GraphType graphType) { removeTypeCells(); - Map cellLayoutMap = VGJTreeLayout - .getVGJRDFCellLayoutMap(mr3Writer.getRDFModel()); + Map cellLayoutMap = VGJTreeLayout.getVGJRDFCellLayoutMap(mr3Writer.getRDFModel()); RDFGraph rdfGraph = getCurrentRDFGraph(); Object[] cells = rdfGraph.getAllCells(); for (int i = 0; i < cells.length; i++) { @@ -1473,16 +1439,13 @@ private void applyVGJRDFLayout(GraphType graphType) { // } if (RDFGraph.isEdge(cell)) { GraphCell sourceCell = (GraphCell) rdfGraph.getSourceVertex(cell); - RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(sourceCell - .getAttributes()); + RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(sourceCell.getAttributes()); data = cellLayoutMap.get(info.getURI()); moveCell(sourceCell, data, rdfGraph); GraphCell targetCell = (GraphCell) rdfGraph.getTargetVertex(cell); if (RDFGraph.isRDFLiteralCell(targetCell)) { - MR3Literal literal = (MR3Literal) GraphConstants.getValue(targetCell - .getAttributes()); - Resource tmp = ResourceFactory.createResource(info.getURIStr() - + literal.getLiteral().hashCode()); + MR3Literal literal = (MR3Literal) GraphConstants.getValue(targetCell.getAttributes()); + Resource tmp = ResourceFactory.createResource(info.getURIStr() + literal.getLiteral().hashCode()); data = cellLayoutMap.get(tmp); } else { info = (RDFResourceInfo) GraphConstants.getValue(targetCell.getAttributes()); @@ -1498,8 +1461,7 @@ private void applyVGJRDFLayout(GraphType graphType) { private void applyJGraphRDFLayout() { removeTypeCells(); - treeLayout.performJGraphTreeLayout(getCurrentRDFGraph(), - GraphLayoutUtilities.getJGraphRDFLayoutDirection(), + treeLayout.performJGraphTreeLayout(getCurrentRDFGraph(), GraphLayoutUtilities.getJGraphRDFLayoutDirection(), GraphLayoutUtilities.RDF_VERTICAL_SPACE, GraphLayoutUtilities.RDF_HORIZONTAL_SPACE); addTypeCells(); } @@ -1518,8 +1480,7 @@ public void selectChangedRDFCells(RDFSInfo rdfsInfo) { for (Object cell : rdfGraph.getAllCells()) { if (RDFGraph.isRDFResourceCell(cell)) { RDFResourceCell rdfCell = (RDFResourceCell) cell; - RDFResourceInfo rdfInfo = (RDFResourceInfo) GraphConstants.getValue(rdfCell - .getAttributes()); + RDFResourceInfo rdfInfo = (RDFResourceInfo) GraphConstants.getValue(rdfCell.getAttributes()); if (rdfInfo.getType().equals(rdfsInfo.getURI())) { selectedCellSet.add(rdfCell); } diff --git a/src/main/java/net/sourceforge/mr3/resources/version_info.html b/src/main/java/net/sourceforge/mr3/resources/version_info.html index 6945b49b..3036a1e4 100644 --- a/src/main/java/net/sourceforge/mr3/resources/version_info.html +++ b/src/main/java/net/sourceforge/mr3/resources/version_info.html @@ -1,5 +1,5 @@ - +
Name: @@ -47,6 +47,7 @@
  • Jakarta ORO
  • Silk Icons +
  • exewrap diff --git a/src/main/java/net/sourceforge/mr3/ui/ExportDialog.java b/src/main/java/net/sourceforge/mr3/ui/ExportDialog.java index c1422002..ef51f176 100644 --- a/src/main/java/net/sourceforge/mr3/ui/ExportDialog.java +++ b/src/main/java/net/sourceforge/mr3/ui/ExportDialog.java @@ -127,8 +127,7 @@ public class ExportDialog extends JDialog implements ActionListener { private static JTextArea exportTextArea; private static final int FRAME_HEIGHT = 500; private static final int FRAME_WIDTH = 600; - private static ImageIcon EXPORT_ICON = Utilities.getImageIcon(Translator - .getString("Component.File.Export.Icon")); + private static ImageIcon EXPORT_ICON = Utilities.getImageIcon(Translator.getString("Component.File.Export.Icon")); private static ImageIcon FILE_ICON = Utilities.getImageIcon("page_white_text.png"); private static ImageIcon IMAGE_ICON = Utilities.getImageIcon("image.png"); @@ -163,8 +162,7 @@ public ExportDialog(GraphManager gm) { group.add(n3TRIPLERadioButton); JPanel outputCheckPanel = new JPanel(); outputCheckPanel.setLayout(new GridLayout(2, 4)); - outputCheckPanel.setBorder(BorderFactory.createTitledBorder(Translator - .getString("ImportDialog.Syntax"))); + outputCheckPanel.setBorder(BorderFactory.createTitledBorder(Translator.getString("ImportDialog.Syntax"))); outputCheckPanel.add(xmlRadioButton); xmlRadioButton.setSelected(true); outputCheckPanel.add(nTripleRadioButton); @@ -185,8 +183,7 @@ public ExportDialog(GraphManager gm) { propertyConvertBox.addActionListener(this); JPanel dataTypePanel = new JPanel(); dataTypePanel.setLayout(new GridLayout(1, 3)); - dataTypePanel.setBorder(BorderFactory.createTitledBorder(Translator - .getString("ImportDialog.DataType"))); + dataTypePanel.setBorder(BorderFactory.createTitledBorder(Translator.getString("ImportDialog.DataType"))); dataTypePanel.add(rdfConvertBox); dataTypePanel.add(classConvertBox); dataTypePanel.add(propertyConvertBox); @@ -202,8 +199,7 @@ public ExportDialog(GraphManager gm) { xmlbaseCheckBox.setSelected(true); xmlbaseCheckBox.addActionListener(this); JPanel optionCheckPanel = new JPanel(); - optionCheckPanel.setBorder(BorderFactory.createTitledBorder(Translator - .getString("ExportDialog.Option"))); + optionCheckPanel.setBorder(BorderFactory.createTitledBorder(Translator.getString("ExportDialog.Option"))); optionCheckPanel.setLayout(new GridLayout(2, 2)); optionCheckPanel.add(encodeCheckBox); optionCheckPanel.add(selectedCheckBox); @@ -214,8 +210,7 @@ public ExportDialog(GraphManager gm) { exportFileButton.setHorizontalAlignment(JButton.LEFT); exportFileButton.setMnemonic('f'); exportFileButton.addActionListener(new ExportFileEvent()); - exportImgButton = new JButton(Translator.getString("ExportDialog.Image") + "(I)", - IMAGE_ICON); + exportImgButton = new JButton(Translator.getString("ExportDialog.Image") + "(I)", IMAGE_ICON); exportImgButton.setHorizontalAlignment(JButton.LEFT); exportImgButton.setMnemonic('i'); exportImgButton.addActionListener(new ExportImgEvent()); @@ -237,8 +232,8 @@ public void actionPerformed(ActionEvent e) { JPanel exportButtonPanel = new JPanel(); exportButtonPanel.setLayout(new GridLayout(2, 1, 5, 5)); - exportButtonPanel.setBorder(BorderFactory.createTitledBorder(Translator - .getString("Component.File.Export.Text"))); + exportButtonPanel + .setBorder(BorderFactory.createTitledBorder(Translator.getString("Component.File.Export.Text"))); exportButtonPanel.add(exportFileButton); exportButtonPanel.add(exportImgButton); @@ -258,8 +253,8 @@ public void actionPerformed(ActionEvent e) { settingPanel.add(buttonPanel, BorderLayout.EAST); exportTextArea = new JTextArea(); - JSplitPane sourcePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, - Utilities.createWestPanel(settingPanel), new JScrollPane(exportTextArea)); + JSplitPane sourcePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, Utilities.createWestPanel(settingPanel), + new JScrollPane(exportTextArea)); sourcePane.setOneTouchExpandable(true); setContentPane(sourcePane); @@ -269,10 +264,10 @@ public void actionPerformed(ActionEvent e) { setVisible(false); } - private static RDFsFileFilter rdfsFileFilter = new RDFsFileFilter(); - private static NTripleFileFilter n3FileFilter = new NTripleFileFilter(); - private static TurtleFileFilter turtleFileFilter = new TurtleFileFilter(); - private static OWLFileFilter owlFileFilter = new OWLFileFilter(); + private static RDFsFileFilter rdfsFileFilter = new RDFsFileFilter(true); + private static NTripleFileFilter n3FileFilter = new NTripleFileFilter(true); + private static TurtleFileFilter turtleFileFilter = new TurtleFileFilter(true); + private static OWLFileFilter owlFileFilter = new OWLFileFilter(true); private static PNGFileFilter pngFileFilter = new PNGFileFilter(); private File getFile() { @@ -280,8 +275,7 @@ private File getFile() { } private File getFile(String extension) { - JFileChooser jfc = new JFileChooser(gmanager.getUserPrefs().get( - PrefConstants.WorkDirectory, "")); + JFileChooser jfc = new JFileChooser(gmanager.getUserPrefs().get(PrefConstants.WorkDirectory, "")); if (extension.equals("rdf")) { jfc.addChoosableFileFilter(rdfsFileFilter); jfc.addChoosableFileFilter(owlFileFilter); @@ -306,9 +300,9 @@ private File getFile(String extension) { private String complementRDFsExtension(String tmp, String extension) { String ext = (extension != null) ? "." + extension.toLowerCase() : ""; - if (extension != null && !tmp.toLowerCase().endsWith(".rdf") - && !tmp.toLowerCase().endsWith(".rdfs") && !tmp.toLowerCase().endsWith(".n3") - && !tmp.toLowerCase().endsWith(".ttl") && !tmp.toLowerCase().endsWith(".owl")) { + if (extension != null && !tmp.toLowerCase().endsWith(".rdf") && !tmp.toLowerCase().endsWith(".rdfs") + && !tmp.toLowerCase().endsWith(".n3") && !tmp.toLowerCase().endsWith(".ttl") + && !tmp.toLowerCase().endsWith(".owl")) { tmp += ext; } return tmp; @@ -322,8 +316,7 @@ public void actionPerformed(ActionEvent e) { } try { String encoding = gmanager.getUserPrefs().get(PrefConstants.OutputEncoding, "UTF8"); - Writer writer = new OutputStreamWriter(new BufferedOutputStream( - new FileOutputStream(file)), encoding); + Writer writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(file)), encoding); writeModel(getModel(), writer); writer.close(); } catch (Exception ex) { @@ -349,8 +342,8 @@ private int getSelectedCount() { class ExportImgEvent implements ActionListener { public void actionPerformed(ActionEvent e) { if (getSelectedCount() != 1) { - JOptionPane.showMessageDialog(gmanager.getDesktopTabbedPane(), - "Check (RDF or Class or Property)", "", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(gmanager.getDesktopTabbedPane(), "Check (RDF or Class or Property)", "", + JOptionPane.ERROR_MESSAGE); return; } String fileType = "png"; @@ -360,8 +353,7 @@ public void actionPerformed(ActionEvent e) { } try { BufferedImage img = null; - if (rdfConvertBox.isSelected() - && gmanager.getCurrentRDFGraph().getModel().getRootCount() > 0) { + if (rdfConvertBox.isSelected() && gmanager.getCurrentRDFGraph().getModel().getRootCount() > 0) { img = GPConverter.toImage(gmanager.getCurrentRDFGraph()); } else if (classConvertBox.isSelected() && gmanager.getCurrentClassGraph().getModel().getRootCount() > 0) { @@ -387,8 +379,7 @@ private void setRDFTreeRoot() { for (int i = 0; i < cells.length; i++) { GraphCell cell = (GraphCell) cells[i]; if (RDFGraph.isRDFResourceCell(cell)) { - RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell - .getAttributes()); + RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(cell.getAttributes()); Resource resType = info.getType(); if (resType.getURI().length() == 0) { resType = RDFS.Resource; @@ -418,8 +409,8 @@ private void setRDFTreeRoot() { private String getExtension() { if (xmlRadioButton.isSelected()) { return "rdf"; - } else if (n3RadioButton.isSelected() || n3PPRadioButton.isSelected() - || n3PLAINRadioButton.isSelected() || n3TRIPLERadioButton.isSelected()) { + } else if (n3RadioButton.isSelected() || n3PPRadioButton.isSelected() || n3PLAINRadioButton.isSelected() + || n3TRIPLERadioButton.isSelected()) { return "n3"; } else if (nTripleRadioButton.isSelected()) { return "n3"; @@ -537,12 +528,10 @@ private Model getEncodedModel(Model model) { if (!subject.isAnon()) { subject = ResourceFactory.createResource(URIref.encode(stmt.getSubject().getURI())); } - Property predicate = ResourceFactory.createProperty(URIref.encode(stmt.getPredicate() - .getURI())); + Property predicate = ResourceFactory.createProperty(URIref.encode(stmt.getPredicate().getURI())); RDFNode object = stmt.getObject(); if (object.isResource() && !object.isAnon()) { - object = ResourceFactory - .createResource(URIref.encode(((Resource) object).getURI())); + object = ResourceFactory.createResource(URIref.encode(((Resource) object).getURI())); } encodedModel.add(subject, predicate, object); } diff --git a/src/main/java/net/sourceforge/mr3/ui/HistoryManager.java b/src/main/java/net/sourceforge/mr3/ui/HistoryManager.java index 3571acb0..b0fa864f 100644 --- a/src/main/java/net/sourceforge/mr3/ui/HistoryManager.java +++ b/src/main/java/net/sourceforge/mr3/ui/HistoryManager.java @@ -23,457 +23,537 @@ package net.sourceforge.mr3.ui; -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.util.*; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; import java.util.List; - -import javax.swing.*; -import javax.swing.table.*; - -import net.sourceforge.mr3.*; -import net.sourceforge.mr3.data.*; -import net.sourceforge.mr3.data.MR3Constants.*; -import net.sourceforge.mr3.io.*; -import net.sourceforge.mr3.jgraph.*; -import net.sourceforge.mr3.util.*; - -import org.apache.log4j.*; -import org.jgraph.graph.*; - -import com.hp.hpl.jena.rdf.model.*; +import java.util.Map; +import java.util.Set; +import java.util.logging.FileHandler; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; + +import net.sourceforge.mr3.MR3; +import net.sourceforge.mr3.data.ClassInfo; +import net.sourceforge.mr3.data.HistoryData; +import net.sourceforge.mr3.data.MR3Constants; +import net.sourceforge.mr3.data.MR3Constants.HistoryType; +import net.sourceforge.mr3.data.MR3Literal; +import net.sourceforge.mr3.data.PropertyInfo; +import net.sourceforge.mr3.data.RDFResourceInfo; +import net.sourceforge.mr3.data.RDFSInfo; +import net.sourceforge.mr3.io.MR3Reader; +import net.sourceforge.mr3.io.MR3Writer; +import net.sourceforge.mr3.jgraph.GraphManager; +import net.sourceforge.mr3.jgraph.RDFGraph; +import net.sourceforge.mr3.util.Utilities; + +import org.jgraph.graph.GraphCell; +import org.jgraph.graph.GraphConstants; + +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; /** * @author Takeshi Morita */ public class HistoryManager extends JDialog implements ActionListener { - private static MR3 mr3; - private static MR3Reader mr3Reader; - private static MR3Writer mr3Writer; - private static Map dateHistoryDataMap; - private static DefaultTableModel historyTableModel; - private static JTable historyTable; - - private static GraphManager gmanager; - - private JButton applyButton; - private JButton cancelButton; - - private static final int WINDOW_WIDTH = 400; - private static final int WINDOW_HEIGHT = 400; - - public static final String DEFAULT_LOG_FILE_NAME = "mr3_log.txt"; - - private static Logger logger; - - static { - if (GraphManager.isLogAvailable()) { - initLogger(); - } - } - - private static void initLogger() { - try { - logger = Logger.getLogger(HistoryManager.class); - logger.setLevel(Level.INFO); - FileAppender appender = new FileAppender(new PatternLayout("%d{yyyy-MMM-dd HH:mm:ss} %m"), "./" - + DEFAULT_LOG_FILE_NAME); - appender.setName("LOG FILE"); - appender.setAppend(true); - logger.addAppender(appender); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - - public static void resetFileAppender(String path) { - if (!path.equals("")) { - if (GraphManager.isLogAvailable()) { - if (logger == null) { - initLogger(); - } - FileAppender appender = (FileAppender) logger.getAppender("LOG FILE"); - appender.setFile(path); - appender.activateOptions(); - } - } - } - - private static final Object[] columnNames = new Object[] { "Date", "History Type"}; - - public HistoryManager(Frame root, MR3 m) { - super(root, "HistoryManager"); - mr3 = m; - mr3Reader = mr3.getMR3Reader(); - mr3Writer = mr3.getMR3Writer(); - dateHistoryDataMap = new HashMap(); - historyTableModel = new DefaultTableModel(columnNames, 0); - historyTable = new JTable(historyTableModel); - TableColumnModel tcModel = historyTable.getColumnModel(); - tcModel.getColumn(0).setPreferredWidth(50); - tcModel.getColumn(1).setPreferredWidth(100); - historyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - JScrollPane historyTableScroll = new JScrollPane(historyTable); - - applyButton = new JButton(MR3Constants.APPLY); - applyButton.setMnemonic('a'); - applyButton.addActionListener(this); - cancelButton = new JButton(MR3Constants.CANCEL); - cancelButton.setMnemonic('c'); - cancelButton.addActionListener(this); - JPanel buttonPanel = new JPanel(); - buttonPanel.setLayout(new GridLayout(1, 2, 5, 5)); - buttonPanel.add(applyButton); - buttonPanel.add(cancelButton); - - add(historyTableScroll, BorderLayout.CENTER); - add(Utilities.createEastPanel(buttonPanel), BorderLayout.SOUTH); - - setSize(WINDOW_WIDTH, WINDOW_HEIGHT); - setLocationRelativeTo(root); - setVisible(false); - } - - public static void setGraphManager(GraphManager gm) { - gmanager = gm; - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == applyButton) { - loadHistory(); - } else if (e.getSource() == cancelButton) { - setVisible(false); - } - } - - private static final String MODEL = "[Model]"; - private static final String META_MODEL = "[Meta Model]"; - - public synchronized static void saveHistory(HistoryType historyType, RDFSInfo info, GraphCell sourceCell, - GraphCell targetCell) { - if (!GraphManager.isLogAvailable()) { return; } - switch (historyType) { - case INSERT_PROPERTY: - RDFResourceInfo resInfo = (RDFResourceInfo) GraphConstants.getValue(sourceCell.getAttributes()); - String sourceStr = "Source: RDF Resource: " + resInfo.getURIStr() + "\tRDF Resource Type: " - + resInfo.getType() + "\n"; - String targetStr = ""; - if (RDFGraph.isRDFLiteralCell(targetCell)) { - MR3Literal literal = (MR3Literal) GraphConstants.getValue(targetCell.getAttributes()); - targetStr = "Target: Language: " + literal.getLanguage() + "\tDatatype: " + literal.getDatatype() - + "\tString: " + literal.getString() + "\n"; - } else { - resInfo = (RDFResourceInfo) GraphConstants.getValue(targetCell.getAttributes()); - targetStr = "Target: RDF Resource: " + resInfo.getURIStr() + "\tRDF Resource Type: " - + resInfo.getType() + "\n"; - } - logger.info(MODEL + "[" + historyType + "]\n" + "Insert Property: " + info.getURIStr() + "\n" + sourceStr - + targetStr); - break; - case CONNECT_SUP_SUB_CLASS: - RDFSInfo subInfo = (RDFSInfo) GraphConstants.getValue(sourceCell.getAttributes()); - String subStr = "Sub Class: " + subInfo.getURIStr() + "\tMeta Class: " + subInfo.getMetaClass() + "\n"; - RDFSInfo supInfo = (RDFSInfo) GraphConstants.getValue(targetCell.getAttributes()); - String supStr = "Super Class: " + supInfo.getURIStr() + "\tMeta Class: " + supInfo.getMetaClass() + "\n"; - logger.info(META_MODEL + "[" + historyType + "]\n" + subStr + supStr); - break; - case CONNECT_SUP_SUB_PROPERTY: - subInfo = (RDFSInfo) GraphConstants.getValue(sourceCell.getAttributes()); - subStr = "Sub Property: " + subInfo.getURIStr() + "\tMeta Class: " + subInfo.getMetaClass() + "\n"; - supInfo = (RDFSInfo) GraphConstants.getValue(targetCell.getAttributes()); - supStr = "Super Property: " + supInfo.getURIStr() + "\tMeta Class: " + supInfo.getMetaClass() + "\n"; - logger.info(META_MODEL + "[" + historyType + "]\n" + subStr + supStr); - break; - } - } - - public synchronized static void saveHistory(HistoryType historyType, Object[] removeCells) { - if (!GraphManager.isLogAvailable()) { return; } - StringBuffer buf = new StringBuffer("DELETE: \n"); - for (int i = 0; i < removeCells.length; i++) { - GraphCell cell = (GraphCell) removeCells[i]; - if (RDFGraph.isRDFResourceCell(cell)) { - RDFResourceInfo resInfo = (RDFResourceInfo) GraphConstants.getValue(cell.getAttributes()); - buf.append("RDF Resource: " + resInfo.getURIStr() + "\t"); - buf.append("RDF Resource Type: " + resInfo.getType() + "\n"); - } else if (historyType == HistoryType.DELETE_RDF && RDFGraph.isRDFPropertyCell(cell)) { - RDFSInfo rdfsInfo = (RDFSInfo) GraphConstants.getValue(cell.getAttributes()); - buf.append("RDF Property: " + rdfsInfo.getURIStr() + "\n"); - } else if (RDFGraph.isRDFLiteralCell(cell)) { - MR3Literal literal = (MR3Literal) GraphConstants.getValue(cell.getAttributes()); - buf.append("RDF Literal: \n"); - buf.append("Language: " + literal.getLanguage() + "\t"); - buf.append("Datatype: " + literal.getDatatype() + "\t"); - buf.append("String: " + literal.getString() + "\n"); - } else if (RDFGraph.isRDFSClassCell(cell)) { - RDFSInfo rdfsInfo = (RDFSInfo) GraphConstants.getValue(cell.getAttributes()); - buf.append("Ont Class: " + rdfsInfo.getURIStr() + "\t"); - buf.append("Meta Class: " + rdfsInfo.getMetaClass() + "\n"); - } else if (RDFGraph.isRDFSPropertyCell(cell)) { - RDFSInfo rdfsInfo = (RDFSInfo) GraphConstants.getValue(cell.getAttributes()); - buf.append("Ont Property: " + rdfsInfo.getURIStr() + "\t"); - buf.append("Meta Property: " + rdfsInfo.getMetaClass() + "\n"); - } - } - - switch (historyType) { - case DELETE_RDF: - logger.info(MODEL + "[" + historyType + "]\n" + buf.toString()); - break; - case DELETE_CLASS: - case DELETE_ONT_PROPERTY: - logger.info(META_MODEL + "[" + historyType + "]\n" + buf.toString()); - break; - } - } - - public synchronized static void saveHistory(HistoryType historyType, List beforeMR3LiteralList, - List afterMR3LiteralList) { - if (!GraphManager.isLogAvailable()) { return; } - StringBuffer beforeBuf = new StringBuffer(""); - for (MR3Literal lit : beforeMR3LiteralList) { - beforeBuf.append("Language: " + lit.getLanguage() + "\tString: " + lit.getString() + "\n"); - } - StringBuffer afterBuf = new StringBuffer(""); - for (MR3Literal lit : afterMR3LiteralList) { - afterBuf.append("Language: " + lit.getLanguage() + "\tString: " + lit.getString() + "\n"); - } - - switch (historyType) { - case EDIT_RESOURCE_LABEL: - case EDIT_RESOURCE_LABEL_WITH_GRAPH: - case ADD_RESOURCE_LABEL: - case DELETE_RESOURCE_LABEL: - logger.info(MODEL + "[" + historyType + "]\n" + "Before Label: \n" + beforeBuf.toString() - + "After Label: \n" + afterBuf.toString()); - break; - case EDIT_RESOURCE_COMMENT: - case ADD_RESOURCE_COMMENT: - case DELETE_RESOURCE_COMMENT: - logger.info(MODEL + "[" + historyType + "]\n" + "Before Comment: \n" + beforeBuf.toString() - + "After Comment: \n" + afterBuf.toString()); - break; - case EDIT_CLASS_LABEL: - case EDIT_CLASS_LABEL_WITH_GRAPH: - case ADD_CLASS_LABEL: - case DELETE_CLASS_LABEL: - case EDIT_ONT_PROPERTY_LABEL: - case EDIT_ONT_PROPERTY_LABEL_WITH_GRAPH: - case ADD_ONT_PROPERTY_LABEL: - case DELETE_ONT_PROPERTY_LABEL: - logger.info(META_MODEL + "[" + historyType + "]\n" + "Before Label: \n" + beforeBuf.toString() - + "After Label: " + afterBuf.toString()); - break; - case EDIT_CLASS_COMMENT: - case ADD_CLASS_COMMENT: - case DELETE_CLASS_COMMENT: - case EDIT_ONT_PROPERTY_COMMENT: - case ADD_ONT_PROPERTY_COMMENT: - case DELETE_ONT_PROPERTY_COMMENT: - logger.info(META_MODEL + "[" + historyType + "]\n" + "Before Comment: \n" + beforeBuf.toString() - + "After Comment: " + afterBuf.toString()); - break; - - } - } - - public synchronized static void saveHistory(HistoryType historyType, RDFResourceInfo beforeInfo, - RDFResourceInfo afterInfo) { - if (!GraphManager.isLogAvailable()) { return; } - if (beforeInfo.isSameInfo(afterInfo)) { return; } - switch (historyType) { - case EDIT_RESOURCE_WITH_DIALOG: - case EDIT_RESOURCE_WITH_GRAPH: - logger.info(MODEL + "[" + historyType + "]\n" + "Before RDF Resource URI Type: " + beforeInfo.getURIType() - + "\nBefore RDF Resource: " + beforeInfo.getURIStr() + "\nBefore RDF Resource Type: " - + beforeInfo.getType() + "\nAfter RDF Resource URI Type: " + afterInfo.getURIType() - + "\nAfter RDF Resource: " + afterInfo.getURIStr() + "\nAfter RDF Resource Type: " - + afterInfo.getType() + "\n"); - break; - } - } - - public synchronized static void saveHistory(HistoryType historyType, String beforeProperty, String afterProperty) { - if (!GraphManager.isLogAvailable()) { return; } - if (beforeProperty.equals(afterProperty)) { return; } - switch (historyType) { - case EDIT_PROPERTY_WITH_DIAGLOG: - case EDIT_PROPERTY_WITH_GRAPH: - logger.info(MODEL + "[" + historyType + "]\n" + "Before Property: " + beforeProperty + "\nAfter Property: " - + afterProperty + "\n"); - break; - } - } - - public synchronized static void saveHistory(HistoryType historyType, MR3Literal beforeLiteral, - MR3Literal afterLiteral) { - if (!GraphManager.isLogAvailable()) { return; } - if (beforeLiteral.equals(afterLiteral)) { return; } - switch (historyType) { - case EDIT_LITERAL_WITH_DIAGLOG: - case EDIT_LITERAL_WITH_GRAPH: - logger.info(MODEL + "[" + historyType + "]\n" + "Before Language: " + beforeLiteral.getLanguage() - + "\nBefore String: " + beforeLiteral.getString() + "\nBefore Data type: " - + beforeLiteral.getDatatype() + "\nAfter Language: " + afterLiteral.getLanguage() - + "\nAfter String: " + afterLiteral.getString() + "\nAfter Data type: " - + afterLiteral.getDatatype() + "\n"); - break; - } - } - - public synchronized static void saveHistory(HistoryType historyType, Set beforeRegion, Set afterRegion, String uri) { - if (!GraphManager.isLogAvailable()) { return; } - switch (historyType) { - case ADD_ONT_PROPERTY_DOMAIN: - case DELETE_ONT_PROPERTY_DOMAIN: - logger.info(META_MODEL + "[" + historyType + "]\n" + "ONT Property: " + uri - + "\nBefore ONT Property Domain: " + beforeRegion + "\nAfter ONT Property Domain: " + afterRegion - + "\n"); - break; - case ADD_ONT_PROPERTY_RANGE: - case DELETE_ONT_PROPERTY_RANGE: - logger.info(META_MODEL + "[" + historyType + "]\n" + "ONT Property: " + uri - + "\nBefore ONT Property Range: " + beforeRegion + "\nAfter ONT Property Range: " + afterRegion - + "\n"); - break; - } - } - - public synchronized static void saveHistory(HistoryType historyType, RDFSInfo beforeInfo, RDFSInfo afterInfo) { - if (!GraphManager.isLogAvailable()) { return; } - if (beforeInfo.isSameInfo(afterInfo)) { return; } - switch (historyType) { - case EDIT_CLASS_WITH_DIAGLOG: - case EDIT_CLASS_WITH_GRAPH: - logger.info(META_MODEL + "[" + historyType + "]\n" + "Before ONT Class: " + beforeInfo.getURIStr() - + "\nBefore ONT Class Type: " + beforeInfo.getMetaClass() + "\nAfter ONT Class: " - + afterInfo.getURIStr() + "\nAfter ONT Class Type: " + afterInfo.getMetaClass() + "\n"); - if (!MR3.OFF_META_MODEL_MANAGEMENT) { - ClassInfo clsInfo = (ClassInfo) afterInfo; - Set instanceInfoSet = gmanager.getClassInstanceInfoSet(clsInfo); - if (0 < instanceInfoSet.size()) { - StringBuffer instanceInfoStr = new StringBuffer(""); - for (RDFResourceInfo resInfo : instanceInfoSet) { - instanceInfoStr.append("RDF Resource: " + resInfo.getURIStr() + "\n"); - } - logger.info(META_MODEL + "[" + HistoryType.META_MODEL_MANAGEMNET_REPLACE_CLASS + "]\n" - + instanceInfoStr); - } - } - break; - case EDIT_ONT_PROPERTY_WITH_DIAGLOG: - case EDIT_ONT_PROPERTY_WITH_GRAPH: - logger.info(META_MODEL + "[" + historyType + "]\n" + "Before ONT Property: " + beforeInfo.getURIStr() - + "\nBefore ONT Property Type: " + beforeInfo.getMetaClass() + "\nAfter ONT Property: " - + afterInfo.getURIStr() + "\nAfter ONT Property Type: " + afterInfo.getMetaClass() + "\n"); - if (!MR3.OFF_META_MODEL_MANAGEMENT) { - PropertyInfo propInfo = (PropertyInfo) afterInfo; - Set instanceSet = gmanager.getPropertyInstanceInfoSet(propInfo); - if (0 < instanceSet.size()) { - StringBuffer instanceInfoStr = new StringBuffer(""); - for (Object cell : instanceSet) { - RDFResourceInfo resInfo = (RDFResourceInfo) GraphConstants.getValue(((GraphCell) cell) - .getAttributes()); - instanceInfoStr.append("Source RDF Resource: " + resInfo.getURIStr() + "\n"); - } - // 正確にやるなら,RDFプロパティのグラフセルのセットから,sourcevertex, - // targetvertexを得て, - // Source Resource, Target Resourceを表示するようにすべき - logger.info(META_MODEL + "[" + HistoryType.META_MODEL_MANAGEMNET_REPLACE_ONT_PROPERTY + "]\n" - + instanceInfoStr); - } - } - break; - } - } - - public synchronized static void saveHistory(HistoryType historyType, GraphCell insertCell) { - if (!GraphManager.isLogAvailable()) { return; } - switch (historyType) { - case INSERT_RESOURCE: - case INSERT_CONNECTED_RESOURCE: - RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(insertCell.getAttributes()); - logger.info(MODEL + "[" + historyType + "]\n" + "RDF Resource URI Type: " + info.getURIType() - + "\nRDF Resource: " + info.getURIStr() + "\nRDF Resource Type: " + info.getType() + "\n"); - break; - case INSERT_LITERAL: - case INSERT_CONNECTED_LITERAL: - MR3Literal literal = (MR3Literal) GraphConstants.getValue(insertCell.getAttributes()); - logger.info(MODEL + "[" + historyType + "]\n" + "Language: " + literal.getLanguage() + "\nString: " - + literal.getString() + "\nData type: " + literal.getDatatype() + "\n"); - break; - case INSERT_ONT_PROPERTY: - case INSERT_CONNECTED_ONT_PROPERTY: - RDFSInfo rdfsInfo = (RDFSInfo) GraphConstants.getValue(insertCell.getAttributes()); - logger.info(META_MODEL + "[" + historyType + "]\n" + "ONT Property: " + rdfsInfo.getURIStr() - + "\nONT Property Type: " + rdfsInfo.getMetaClass() + "\n"); - break; - case INSERT_CLASS: - rdfsInfo = (RDFSInfo) GraphConstants.getValue(insertCell.getAttributes()); - logger.info(META_MODEL + "[" + historyType + "]\n" + "ONT Class: " + rdfsInfo.getURIStr() - + "\nONT Class Type: " + rdfsInfo.getMetaClass() + "\n"); - break; - } - } - - public synchronized static void saveHistory(HistoryType historyType, String path) { - if (!GraphManager.isLogAvailable()) { return; } - switch (historyType) { - case OPEN_PROJECT: - logger.info("[---][" + historyType + "]\nPath: " + path + "\n"); - break; - case SAVE_PROJECT: - case SAVE_PROJECT_AS: - logger.info("[---][" + historyType + "]\nPath: " + path + "\n"); - break; - } - } - - public synchronized static void saveHistory(HistoryType historyType) { - if (!GraphManager.isLogAvailable()) { return; } - switch (historyType) { - case NEW_PROJECT: - logger.info("[---][" + historyType + "]\n"); - break; - case COPY_CLASS_GRAPH: - case CUT_CLASS_GRAPH: - case PASTE_CLASS_GRAPH: - case COPY_PROPERTY_GRAPH: - case CUT_PROPERTY_GRAPH: - case PASTE_PROPERTY_GRAPH: - logger.info(META_MODEL + "[" + historyType + "]\n"); - break; - case META_MODEL_MANAGEMNET_REPLACE_RESOURCE_TYPE_WITH_CREATE_CLASS: - case META_MODEL_MANAGEMNET_REPLACE_RESOURCE_TYPE_WITH_REPLACE_CLASS: - case META_MODEL_MANAGEMNET_REPLACE_PROPERTY_WITH_CREATE_ONT_PROPERTY: - case META_MODEL_MANAGEMNET_REPLACE_PROPERTY_WITH_REPLACE_ONT_PROPERTY: - case COPY_RDF_GRAPH: - case CUT_RDF_GRAPH: - case PASTE_RDF_GRAPH: - logger.info(MODEL + "[" + historyType + "]\n"); - break; - } - // HistoryData data = new HistoryData(historyType, - // mr3Writer.getProjectModel()); - // dateHistoryDataMap.put(data.getDate(), data); - // historyTableModel.insertRow(0, new Object[] { data.getDate(), - // data.getHistoryType()}); - } - - public void loadHistory() { - if (historyTable.getSelectedRowCount() == 1) { - Date date = (Date) historyTableModel.getValueAt(historyTable.getSelectedRow(), 0); - HistoryData data = dateHistoryDataMap.get(date); - Model projectModel = ModelFactory.createDefaultModel(); - projectModel = projectModel.union(data.getProjectModel()); - mr3Reader.replaceProjectModel(projectModel); - saveHistory(HistoryType.LOAD_HISTORY); - } - } - - public static void main(String[] arg) { - System.out.println(Calendar.getInstance().getTime()); - } + private static MR3 mr3; + private static MR3Reader mr3Reader; + private static MR3Writer mr3Writer; + private static Map dateHistoryDataMap; + private static DefaultTableModel historyTableModel; + private static JTable historyTable; + + private static GraphManager gmanager; + + private JButton applyButton; + private JButton cancelButton; + + private static final int WINDOW_WIDTH = 400; + private static final int WINDOW_HEIGHT = 400; + + public static final String DEFAULT_LOG_FILE_NAME = "mr3_log.txt"; + + private static Logger logger; + + public static class CustomLogFormatter extends SimpleFormatter { + private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + public String format(LogRecord logRecord) { + final StringBuffer stringBuffer = new StringBuffer(); + + stringBuffer.append(this.dateFormat.format(new Date(logRecord.getMillis()))); + stringBuffer.append(" "); + + Level level = logRecord.getLevel(); + if (level == Level.FINEST) { + stringBuffer.append("FINEST"); + } else if (level == Level.FINER) { + stringBuffer.append("FINER "); + } else if (level == Level.FINE) { + stringBuffer.append("FINE "); + } else if (level == Level.CONFIG) { + stringBuffer.append("CONFIG"); + } else if (level == Level.INFO) { + stringBuffer.append("INFO "); + } else if (level == Level.WARNING) { + stringBuffer.append("WARN "); + } else if (level == Level.SEVERE) { + stringBuffer.append("SEVERE"); + } else { + stringBuffer.append(Integer.toString(logRecord.getLevel().intValue())); + stringBuffer.append(" "); + } + stringBuffer.append(" "); + stringBuffer.append(logRecord.getLoggerName()); + stringBuffer.append(" - "); + stringBuffer.append(logRecord.getMessage()); + stringBuffer.append(System.lineSeparator()); + + return stringBuffer.toString(); + } + } + + public static void initLogger(String logFilePath) { + logger = Logger.getGlobal(); + logger.setLevel(Level.INFO); + if (GraphManager.isLogAvailable()) { + try { + FileHandler fileHandler = new FileHandler(logFilePath, true); + fileHandler.setFormatter(new CustomLogFormatter()); + logger.addHandler(fileHandler); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + } + + public static void resetFileAppender(String logFilePath) { + if (!logFilePath.equals("")) { + if (GraphManager.isLogAvailable()) { + initLogger(logFilePath); + } + } + } + + private static final Object[] columnNames = new Object[] { "Date", "History Type" }; + + public HistoryManager(Frame root, MR3 m) { + super(root, "HistoryManager"); + mr3 = m; + mr3Reader = mr3.getMR3Reader(); + mr3Writer = mr3.getMR3Writer(); + dateHistoryDataMap = new HashMap(); + historyTableModel = new DefaultTableModel(columnNames, 0); + historyTable = new JTable(historyTableModel); + TableColumnModel tcModel = historyTable.getColumnModel(); + tcModel.getColumn(0).setPreferredWidth(50); + tcModel.getColumn(1).setPreferredWidth(100); + historyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + JScrollPane historyTableScroll = new JScrollPane(historyTable); + + applyButton = new JButton(MR3Constants.APPLY); + applyButton.setMnemonic('a'); + applyButton.addActionListener(this); + cancelButton = new JButton(MR3Constants.CANCEL); + cancelButton.setMnemonic('c'); + cancelButton.addActionListener(this); + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new GridLayout(1, 2, 5, 5)); + buttonPanel.add(applyButton); + buttonPanel.add(cancelButton); + + add(historyTableScroll, BorderLayout.CENTER); + add(Utilities.createEastPanel(buttonPanel), BorderLayout.SOUTH); + + setSize(WINDOW_WIDTH, WINDOW_HEIGHT); + setLocationRelativeTo(root); + setVisible(false); + } + + public static void setGraphManager(GraphManager gm) { + gmanager = gm; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == applyButton) { + loadHistory(); + } else if (e.getSource() == cancelButton) { + setVisible(false); + } + } + + private static final String MODEL = "[Model]"; + private static final String META_MODEL = "[Meta Model]"; + + public synchronized static void saveHistory(HistoryType historyType, RDFSInfo info, GraphCell sourceCell, + GraphCell targetCell) { + if (!GraphManager.isLogAvailable()) { + return; + } + switch (historyType) { + case INSERT_PROPERTY: + RDFResourceInfo resInfo = (RDFResourceInfo) GraphConstants.getValue(sourceCell.getAttributes()); + String sourceStr = "Source: RDF Resource: " + resInfo.getURIStr() + "\tRDF Resource Type: " + + resInfo.getType() + "\n"; + String targetStr = ""; + if (RDFGraph.isRDFLiteralCell(targetCell)) { + MR3Literal literal = (MR3Literal) GraphConstants.getValue(targetCell.getAttributes()); + targetStr = "Target: Language: " + literal.getLanguage() + "\tDatatype: " + literal.getDatatype() + + "\tString: " + literal.getString() + "\n"; + } else { + resInfo = (RDFResourceInfo) GraphConstants.getValue(targetCell.getAttributes()); + targetStr = "Target: RDF Resource: " + resInfo.getURIStr() + "\tRDF Resource Type: " + + resInfo.getType() + "\n"; + } + logger.info(MODEL + "[" + historyType + "]\n" + "Insert Property: " + info.getURIStr() + "\n" + sourceStr + + targetStr); + break; + case CONNECT_SUP_SUB_CLASS: + RDFSInfo subInfo = (RDFSInfo) GraphConstants.getValue(sourceCell.getAttributes()); + String subStr = "Sub Class: " + subInfo.getURIStr() + "\tMeta Class: " + subInfo.getMetaClass() + "\n"; + RDFSInfo supInfo = (RDFSInfo) GraphConstants.getValue(targetCell.getAttributes()); + String supStr = "Super Class: " + supInfo.getURIStr() + "\tMeta Class: " + supInfo.getMetaClass() + "\n"; + logger.info(META_MODEL + "[" + historyType + "]\n" + subStr + supStr); + break; + case CONNECT_SUP_SUB_PROPERTY: + subInfo = (RDFSInfo) GraphConstants.getValue(sourceCell.getAttributes()); + subStr = "Sub Property: " + subInfo.getURIStr() + "\tMeta Class: " + subInfo.getMetaClass() + "\n"; + supInfo = (RDFSInfo) GraphConstants.getValue(targetCell.getAttributes()); + supStr = "Super Property: " + supInfo.getURIStr() + "\tMeta Class: " + supInfo.getMetaClass() + "\n"; + logger.info(META_MODEL + "[" + historyType + "]\n" + subStr + supStr); + break; + } + } + + public synchronized static void saveHistory(HistoryType historyType, Object[] removeCells) { + if (!GraphManager.isLogAvailable()) { + return; + } + StringBuffer buf = new StringBuffer("DELETE: \n"); + for (int i = 0; i < removeCells.length; i++) { + GraphCell cell = (GraphCell) removeCells[i]; + if (RDFGraph.isRDFResourceCell(cell)) { + RDFResourceInfo resInfo = (RDFResourceInfo) GraphConstants.getValue(cell.getAttributes()); + buf.append("RDF Resource: " + resInfo.getURIStr() + "\t"); + buf.append("RDF Resource Type: " + resInfo.getType() + "\n"); + } else if (historyType == HistoryType.DELETE_RDF && RDFGraph.isRDFPropertyCell(cell)) { + RDFSInfo rdfsInfo = (RDFSInfo) GraphConstants.getValue(cell.getAttributes()); + buf.append("RDF Property: " + rdfsInfo.getURIStr() + "\n"); + } else if (RDFGraph.isRDFLiteralCell(cell)) { + MR3Literal literal = (MR3Literal) GraphConstants.getValue(cell.getAttributes()); + buf.append("RDF Literal: \n"); + buf.append("Language: " + literal.getLanguage() + "\t"); + buf.append("Datatype: " + literal.getDatatype() + "\t"); + buf.append("String: " + literal.getString() + "\n"); + } else if (RDFGraph.isRDFSClassCell(cell)) { + RDFSInfo rdfsInfo = (RDFSInfo) GraphConstants.getValue(cell.getAttributes()); + buf.append("Ont Class: " + rdfsInfo.getURIStr() + "\t"); + buf.append("Meta Class: " + rdfsInfo.getMetaClass() + "\n"); + } else if (RDFGraph.isRDFSPropertyCell(cell)) { + RDFSInfo rdfsInfo = (RDFSInfo) GraphConstants.getValue(cell.getAttributes()); + buf.append("Ont Property: " + rdfsInfo.getURIStr() + "\t"); + buf.append("Meta Property: " + rdfsInfo.getMetaClass() + "\n"); + } + } + + switch (historyType) { + case DELETE_RDF: + logger.info(MODEL + "[" + historyType + "]\n" + buf.toString()); + break; + case DELETE_CLASS: + case DELETE_ONT_PROPERTY: + logger.info(META_MODEL + "[" + historyType + "]\n" + buf.toString()); + break; + } + } + + public synchronized static void saveHistory(HistoryType historyType, List beforeMR3LiteralList, + List afterMR3LiteralList) { + if (!GraphManager.isLogAvailable()) { + return; + } + StringBuffer beforeBuf = new StringBuffer(""); + for (MR3Literal lit : beforeMR3LiteralList) { + beforeBuf.append("Language: " + lit.getLanguage() + "\tString: " + lit.getString() + "\n"); + } + StringBuffer afterBuf = new StringBuffer(""); + for (MR3Literal lit : afterMR3LiteralList) { + afterBuf.append("Language: " + lit.getLanguage() + "\tString: " + lit.getString() + "\n"); + } + + switch (historyType) { + case EDIT_RESOURCE_LABEL: + case EDIT_RESOURCE_LABEL_WITH_GRAPH: + case ADD_RESOURCE_LABEL: + case DELETE_RESOURCE_LABEL: + logger.info(MODEL + "[" + historyType + "]\n" + "Before Label: \n" + beforeBuf.toString() + + "After Label: \n" + afterBuf.toString()); + break; + case EDIT_RESOURCE_COMMENT: + case ADD_RESOURCE_COMMENT: + case DELETE_RESOURCE_COMMENT: + logger.info(MODEL + "[" + historyType + "]\n" + "Before Comment: \n" + beforeBuf.toString() + + "After Comment: \n" + afterBuf.toString()); + break; + case EDIT_CLASS_LABEL: + case EDIT_CLASS_LABEL_WITH_GRAPH: + case ADD_CLASS_LABEL: + case DELETE_CLASS_LABEL: + case EDIT_ONT_PROPERTY_LABEL: + case EDIT_ONT_PROPERTY_LABEL_WITH_GRAPH: + case ADD_ONT_PROPERTY_LABEL: + case DELETE_ONT_PROPERTY_LABEL: + logger.info(META_MODEL + "[" + historyType + "]\n" + "Before Label: \n" + beforeBuf.toString() + + "After Label: " + afterBuf.toString()); + break; + case EDIT_CLASS_COMMENT: + case ADD_CLASS_COMMENT: + case DELETE_CLASS_COMMENT: + case EDIT_ONT_PROPERTY_COMMENT: + case ADD_ONT_PROPERTY_COMMENT: + case DELETE_ONT_PROPERTY_COMMENT: + logger.info(META_MODEL + "[" + historyType + "]\n" + "Before Comment: \n" + beforeBuf.toString() + + "After Comment: " + afterBuf.toString()); + break; + + } + } + + public synchronized static void saveHistory(HistoryType historyType, RDFResourceInfo beforeInfo, + RDFResourceInfo afterInfo) { + if (!GraphManager.isLogAvailable()) { + return; + } + if (beforeInfo.isSameInfo(afterInfo)) { + return; + } + switch (historyType) { + case EDIT_RESOURCE_WITH_DIALOG: + case EDIT_RESOURCE_WITH_GRAPH: + logger.info(MODEL + "[" + historyType + "]\n" + "Before RDF Resource URI Type: " + beforeInfo.getURIType() + + "\nBefore RDF Resource: " + beforeInfo.getURIStr() + "\nBefore RDF Resource Type: " + + beforeInfo.getType() + "\nAfter RDF Resource URI Type: " + afterInfo.getURIType() + + "\nAfter RDF Resource: " + afterInfo.getURIStr() + "\nAfter RDF Resource Type: " + + afterInfo.getType() + "\n"); + break; + } + } + + public synchronized static void saveHistory(HistoryType historyType, String beforeProperty, String afterProperty) { + if (!GraphManager.isLogAvailable()) { + return; + } + if (beforeProperty.equals(afterProperty)) { + return; + } + switch (historyType) { + case EDIT_PROPERTY_WITH_DIAGLOG: + case EDIT_PROPERTY_WITH_GRAPH: + logger.info(MODEL + "[" + historyType + "]\n" + "Before Property: " + beforeProperty + "\nAfter Property: " + + afterProperty + "\n"); + break; + } + } + + public synchronized static void saveHistory(HistoryType historyType, MR3Literal beforeLiteral, + MR3Literal afterLiteral) { + if (!GraphManager.isLogAvailable()) { + return; + } + if (beforeLiteral.equals(afterLiteral)) { + return; + } + switch (historyType) { + case EDIT_LITERAL_WITH_DIAGLOG: + case EDIT_LITERAL_WITH_GRAPH: + logger.info(MODEL + "[" + historyType + "]\n" + "Before Language: " + beforeLiteral.getLanguage() + + "\nBefore String: " + beforeLiteral.getString() + "\nBefore Data type: " + + beforeLiteral.getDatatype() + "\nAfter Language: " + afterLiteral.getLanguage() + + "\nAfter String: " + afterLiteral.getString() + "\nAfter Data type: " + + afterLiteral.getDatatype() + "\n"); + break; + } + } + + public synchronized static void saveHistory(HistoryType historyType, Set beforeRegion, Set afterRegion, String uri) { + if (!GraphManager.isLogAvailable()) { + return; + } + switch (historyType) { + case ADD_ONT_PROPERTY_DOMAIN: + case DELETE_ONT_PROPERTY_DOMAIN: + logger.info(META_MODEL + "[" + historyType + "]\n" + "ONT Property: " + uri + + "\nBefore ONT Property Domain: " + beforeRegion + "\nAfter ONT Property Domain: " + afterRegion + + "\n"); + break; + case ADD_ONT_PROPERTY_RANGE: + case DELETE_ONT_PROPERTY_RANGE: + logger.info(META_MODEL + "[" + historyType + "]\n" + "ONT Property: " + uri + + "\nBefore ONT Property Range: " + beforeRegion + "\nAfter ONT Property Range: " + afterRegion + + "\n"); + break; + } + } + + public synchronized static void saveHistory(HistoryType historyType, RDFSInfo beforeInfo, RDFSInfo afterInfo) { + if (!GraphManager.isLogAvailable()) { + return; + } + if (beforeInfo.isSameInfo(afterInfo)) { + return; + } + switch (historyType) { + case EDIT_CLASS_WITH_DIAGLOG: + case EDIT_CLASS_WITH_GRAPH: + logger.info(META_MODEL + "[" + historyType + "]\n" + "Before ONT Class: " + beforeInfo.getURIStr() + + "\nBefore ONT Class Type: " + beforeInfo.getMetaClass() + "\nAfter ONT Class: " + + afterInfo.getURIStr() + "\nAfter ONT Class Type: " + afterInfo.getMetaClass() + "\n"); + if (!MR3.OFF_META_MODEL_MANAGEMENT) { + ClassInfo clsInfo = (ClassInfo) afterInfo; + Set instanceInfoSet = gmanager.getClassInstanceInfoSet(clsInfo); + if (0 < instanceInfoSet.size()) { + StringBuffer instanceInfoStr = new StringBuffer(""); + for (RDFResourceInfo resInfo : instanceInfoSet) { + instanceInfoStr.append("RDF Resource: " + resInfo.getURIStr() + "\n"); + } + logger.info(META_MODEL + "[" + HistoryType.META_MODEL_MANAGEMNET_REPLACE_CLASS + "]\n" + + instanceInfoStr); + } + } + break; + case EDIT_ONT_PROPERTY_WITH_DIAGLOG: + case EDIT_ONT_PROPERTY_WITH_GRAPH: + logger.info(META_MODEL + "[" + historyType + "]\n" + "Before ONT Property: " + beforeInfo.getURIStr() + + "\nBefore ONT Property Type: " + beforeInfo.getMetaClass() + "\nAfter ONT Property: " + + afterInfo.getURIStr() + "\nAfter ONT Property Type: " + afterInfo.getMetaClass() + "\n"); + if (!MR3.OFF_META_MODEL_MANAGEMENT) { + PropertyInfo propInfo = (PropertyInfo) afterInfo; + Set instanceSet = gmanager.getPropertyInstanceInfoSet(propInfo); + if (0 < instanceSet.size()) { + StringBuffer instanceInfoStr = new StringBuffer(""); + for (Object cell : instanceSet) { + RDFResourceInfo resInfo = (RDFResourceInfo) GraphConstants.getValue(((GraphCell) cell) + .getAttributes()); + instanceInfoStr.append("Source RDF Resource: " + resInfo.getURIStr() + "\n"); + } + // 正確にやるなら,RDFプロパティのグラフセルのセットから,sourcevertex, + // targetvertexを得て, + // Source Resource, Target Resourceを表示するようにすべき + logger.info(META_MODEL + "[" + HistoryType.META_MODEL_MANAGEMNET_REPLACE_ONT_PROPERTY + "]\n" + + instanceInfoStr); + } + } + break; + } + } + + public synchronized static void saveHistory(HistoryType historyType, GraphCell insertCell) { + if (!GraphManager.isLogAvailable()) { + return; + } + switch (historyType) { + case INSERT_RESOURCE: + case INSERT_CONNECTED_RESOURCE: + RDFResourceInfo info = (RDFResourceInfo) GraphConstants.getValue(insertCell.getAttributes()); + logger.info(MODEL + "[" + historyType + "]\n" + "RDF Resource URI Type: " + info.getURIType() + + "\nRDF Resource: " + info.getURIStr() + "\nRDF Resource Type: " + info.getType() + "\n"); + break; + case INSERT_LITERAL: + case INSERT_CONNECTED_LITERAL: + MR3Literal literal = (MR3Literal) GraphConstants.getValue(insertCell.getAttributes()); + logger.info(MODEL + "[" + historyType + "]\n" + "Language: " + literal.getLanguage() + "\nString: " + + literal.getString() + "\nData type: " + literal.getDatatype() + "\n"); + break; + case INSERT_ONT_PROPERTY: + case INSERT_CONNECTED_ONT_PROPERTY: + RDFSInfo rdfsInfo = (RDFSInfo) GraphConstants.getValue(insertCell.getAttributes()); + logger.info(META_MODEL + "[" + historyType + "]\n" + "ONT Property: " + rdfsInfo.getURIStr() + + "\nONT Property Type: " + rdfsInfo.getMetaClass() + "\n"); + break; + case INSERT_CLASS: + rdfsInfo = (RDFSInfo) GraphConstants.getValue(insertCell.getAttributes()); + logger.info(META_MODEL + "[" + historyType + "]\n" + "ONT Class: " + rdfsInfo.getURIStr() + + "\nONT Class Type: " + rdfsInfo.getMetaClass() + "\n"); + break; + } + } + + public synchronized static void saveHistory(HistoryType historyType, String path) { + if (!GraphManager.isLogAvailable()) { + return; + } + switch (historyType) { + case OPEN_PROJECT: + logger.info("[---][" + historyType + "]\nPath: " + path + "\n"); + break; + case SAVE_PROJECT: + case SAVE_PROJECT_AS: + logger.info("[---][" + historyType + "]\nPath: " + path + "\n"); + break; + } + } + + public synchronized static void saveHistory(HistoryType historyType) { + if (!GraphManager.isLogAvailable()) { + return; + } + switch (historyType) { + case NEW_PROJECT: + logger.info("[---][" + historyType + "]\n"); + break; + case COPY_CLASS_GRAPH: + case CUT_CLASS_GRAPH: + case PASTE_CLASS_GRAPH: + case COPY_PROPERTY_GRAPH: + case CUT_PROPERTY_GRAPH: + case PASTE_PROPERTY_GRAPH: + logger.info(META_MODEL + "[" + historyType + "]\n"); + break; + case META_MODEL_MANAGEMNET_REPLACE_RESOURCE_TYPE_WITH_CREATE_CLASS: + case META_MODEL_MANAGEMNET_REPLACE_RESOURCE_TYPE_WITH_REPLACE_CLASS: + case META_MODEL_MANAGEMNET_REPLACE_PROPERTY_WITH_CREATE_ONT_PROPERTY: + case META_MODEL_MANAGEMNET_REPLACE_PROPERTY_WITH_REPLACE_ONT_PROPERTY: + case COPY_RDF_GRAPH: + case CUT_RDF_GRAPH: + case PASTE_RDF_GRAPH: + logger.info(MODEL + "[" + historyType + "]\n"); + break; + } + // HistoryData data = new HistoryData(historyType, + // mr3Writer.getProjectModel()); + // dateHistoryDataMap.put(data.getDate(), data); + // historyTableModel.insertRow(0, new Object[] { data.getDate(), + // data.getHistoryType()}); + } + + public void loadHistory() { + if (historyTable.getSelectedRowCount() == 1) { + Date date = (Date) historyTableModel.getValueAt(historyTable.getSelectedRow(), 0); + HistoryData data = dateHistoryDataMap.get(date); + Model projectModel = ModelFactory.createDefaultModel(); + projectModel = projectModel.union(data.getProjectModel()); + mr3Reader.replaceProjectModel(projectModel); + saveHistory(HistoryType.LOAD_HISTORY); + } + } } diff --git a/src/main/java/net/sourceforge/mr3/ui/ImportDialog.java b/src/main/java/net/sourceforge/mr3/ui/ImportDialog.java index 6aa1c5b0..79494cba 100644 --- a/src/main/java/net/sourceforge/mr3/ui/ImportDialog.java +++ b/src/main/java/net/sourceforge/mr3/ui/ImportDialog.java @@ -83,15 +83,14 @@ public class ImportDialog extends JDialog implements ActionListener { private ChangeContainerAction changeContainerAction; - private static FileFilter owlFileFilter = new OWLFileFilter(); - private static FileFilter rdfsFileFilter = new RDFsFileFilter(); - private static FileFilter n3FileFilter = new NTripleFileFilter(); - private static FileFilter turtleFileFilter = new TurtleFileFilter(); + private static FileFilter owlFileFilter = new OWLFileFilter(false); + private static FileFilter rdfsFileFilter = new RDFsFileFilter(false); + private static FileFilter n3FileFilter = new NTripleFileFilter(false); + private static FileFilter turtleFileFilter = new TurtleFileFilter(false); private static final int FRAME_HEIGHT = 400; private static final int FRAME_WIDTH = 600; - private static ImageIcon IMPORT_ICON = Utilities.getImageIcon(Translator - .getString("ImportDialog.Icon")); + private static ImageIcon IMPORT_ICON = Utilities.getImageIcon(Translator.getString("ImportDialog.Icon")); public ImportDialog(GraphManager gm) { super(gm.getRootFrame(), Translator.getString("ImportDialog.Title"), true); @@ -116,23 +115,20 @@ public ImportDialog(GraphManager gm) { group.add(syntaxTurtleButton); JPanel syntaxPanel = new JPanel(); syntaxPanel.setLayout(new GridLayout(2, 2)); - syntaxPanel.setBorder(BorderFactory.createTitledBorder(Translator - .getString("ImportDialog.Syntax"))); + syntaxPanel.setBorder(BorderFactory.createTitledBorder(Translator.getString("ImportDialog.Syntax"))); syntaxPanel.add(syntaxXMLButton); syntaxPanel.add(syntaxN3Button); syntaxPanel.add(syntaxNTripleButton); syntaxPanel.add(syntaxTurtleButton); - importReplaceButton = new JRadioButton( - Translator.getString("ImportDialog.ImportMethod.Replace")); - importMergeButton = new JRadioButton( - Translator.getString("ImportDialog.ImportMethod.Merge")); + importReplaceButton = new JRadioButton(Translator.getString("ImportDialog.ImportMethod.Replace")); + importMergeButton = new JRadioButton(Translator.getString("ImportDialog.ImportMethod.Merge")); importMergeButton.setSelected(true); group = new ButtonGroup(); group.add(importReplaceButton); group.add(importMergeButton); JPanel importMethodPanel = new JPanel(); - importMethodPanel.setBorder(BorderFactory.createTitledBorder(Translator - .getString("ImportDialog.ImportMethod"))); + importMethodPanel + .setBorder(BorderFactory.createTitledBorder(Translator.getString("ImportDialog.ImportMethod"))); importMethodPanel.add(importMergeButton); importMethodPanel.add(importReplaceButton); ActionListener dataTypeManagementAction = new DataTypeManagementAction(); @@ -149,8 +145,7 @@ public ImportDialog(GraphManager gm) { group.add(dataTypeRDFSButton); group.add(dataTypeOWLButton); JPanel dataTypePanel = new JPanel(); - dataTypePanel.setBorder(BorderFactory.createTitledBorder(Translator - .getString("ImportDialog.DataType"))); + dataTypePanel.setBorder(BorderFactory.createTitledBorder(Translator.getString("ImportDialog.DataType"))); dataTypePanel.add(dataTypeRDFButton); dataTypePanel.add(dataTypeRDFSButton); dataTypePanel.add(dataTypeOWLButton); @@ -210,10 +205,9 @@ public ImportDialog(GraphManager gm) { fileListUI = new JList(); fileListUI.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); JScrollPane fileListScroll = new JScrollPane(fileListUI); - fileListScroll.setBorder(BorderFactory.createTitledBorder(Translator - .getString("ImportDialog.ImportFileList"))); - filterBox = new JComboBox(new Object[] { rdfsFileFilter, n3FileFilter, turtleFileFilter, - owlFileFilter, "All Files" }); + fileListScroll.setBorder(BorderFactory.createTitledBorder(Translator.getString("ImportDialog.ImportFileList"))); + filterBox = new JComboBox(new Object[] { rdfsFileFilter, n3FileFilter, turtleFileFilter, owlFileFilter, + "All Files" }); filterBox.addActionListener(changeContainerAction); filterBox.setSelectedIndex(0); JPanel fileListPanel = new JPanel(); @@ -229,8 +223,7 @@ public ImportDialog(GraphManager gm) { selectFilePanel.add(findPanel, BorderLayout.NORTH); selectFilePanel.add(fileListPanel, BorderLayout.CENTER); selectFilePanel.add(reloadButtonPanel, BorderLayout.SOUTH); - importButton = new JButton(Translator.getString("Component.File.Import.Text") + "(I)", - IMPORT_ICON); + importButton = new JButton(Translator.getString("Component.File.Import.Text") + "(I)", IMPORT_ICON); importButton.setMnemonic('i'); importButton.addActionListener(this); cancelButton = new JButton(MR3Constants.CANCEL); @@ -246,10 +239,8 @@ public void actionPerformed(ActionEvent e) { buttonPanel.add(cancelButton); Container contentPane = getContentPane(); - JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainPanel, - selectFilePanel); - JSplitPane centerSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, containerListPanel, - splitPane); + JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainPanel, selectFilePanel); + JSplitPane centerSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, containerListPanel, splitPane); centerSplitPane.setDividerLocation(0.5); contentPane.add(centerSplitPane, BorderLayout.CENTER); contentPane.add(Utilities.createEastPanel(buttonPanel), BorderLayout.SOUTH); @@ -283,7 +274,7 @@ class AddContainerAction implements ActionListener { private File getDirectory() { Preferences userPrefs = gmanager.getUserPrefs(); JFileChooser jfc = new JFileChooser(userPrefs.get(PrefConstants.WorkDirectory, "")); - jfc.setFileHidingEnabled(false); + jfc.setFileHidingEnabled(true); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (jfc.showOpenDialog(gmanager.getDesktopTabbedPane()) == JFileChooser.APPROVE_OPTION) { return jfc.getSelectedFile(); @@ -324,7 +315,7 @@ public void actionPerformed(ActionEvent e) { } else if (e.getSource() == addURIButton) { try { String uri = JOptionPane - .showInputDialog("Input URI ( exp. http://slashdot.jp/slashdot.rdf )"); + .showInputDialog("Input URI ( exp. https://creativecommons.org/schema.rdf )"); if (uri == null) { return; } @@ -366,8 +357,8 @@ private void changeContainerList() { uriSet.add(selectedContainer.toString()); } else { if (filterBox.getSelectedItem() instanceof java.io.FileFilter) { - fileSet.addAll(Arrays.asList(selectedDirectory - .listFiles((java.io.FileFilter) filterBox.getSelectedItem()))); + fileSet.addAll(Arrays.asList(selectedDirectory.listFiles((java.io.FileFilter) filterBox + .getSelectedItem()))); } else { fileSet.addAll(Arrays.asList(selectedDirectory.listFiles())); } @@ -455,8 +446,7 @@ private File getFile(String file) { // System.out.println(tokens[0].substring(4)); // System.out.println(tokens[1]); String fileName = tokens[1]; - String dirPath = containerListModel.get(Integer.parseInt(tokens[0].substring(4))) - .toString(); + String dirPath = containerListModel.get(Integer.parseInt(tokens[0].substring(4))).toString(); return new File(dirPath, fileName); } @@ -488,13 +478,13 @@ private Set getURIInputStreamSet() { try { inputStreamSet.add(new BufferedInputStream(getURI(uri).openStream())); } catch (UnknownHostException uhe) { - JOptionPane.showMessageDialog(gmanager.getDesktopTabbedPane(), - "Unknown Host(Proxy)", "Warning", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(gmanager.getDesktopTabbedPane(), "Unknown Host(Proxy)", "Warning", + JOptionPane.ERROR_MESSAGE); } catch (MalformedURLException uriex) { uriex.printStackTrace(); } catch (IOException ioe) { - JOptionPane.showMessageDialog(gmanager.getDesktopTabbedPane(), "File Not Found.", - "Warning", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(gmanager.getDesktopTabbedPane(), "File Not Found.", "Warning", + JOptionPane.ERROR_MESSAGE); } } return inputStreamSet; diff --git a/src/main/java/net/sourceforge/mr3/ui/OptionDialog.java b/src/main/java/net/sourceforge/mr3/ui/OptionDialog.java index 44cf084e..aebcfd5e 100644 --- a/src/main/java/net/sourceforge/mr3/ui/OptionDialog.java +++ b/src/main/java/net/sourceforge/mr3/ui/OptionDialog.java @@ -70,6 +70,7 @@ import javax.swing.SpinnerNumberModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.text.JTextComponent; import net.sourceforge.mr3.data.MR3Constants; @@ -143,8 +144,8 @@ public OptionDialog(GraphManager gm, Preferences prefs) { layoutPanel = new LayoutPanel(); renderingPanel = new RenderingPanel(); - menuList = new JList(new Object[] { basePanel, directoryPanel, proxyPanel, metaClassPanel, - layoutPanel, renderingPanel }); + menuList = new JList(new Object[] { basePanel, directoryPanel, proxyPanel, metaClassPanel, layoutPanel, + renderingPanel }); menuList.addListSelectionListener(this); JComponent menuListPanel = Utilities.createTitledPanel(menuList, "", 100, 100); @@ -270,8 +271,7 @@ public void setConfig() { userPrefs.put(PrefConstants.DefaultLang, defaultLangField.getText()); // userPrefs.put(PrefConstants.InputEncoding, (String) // inputEncodingBox.getSelectedItem()); - userPrefs.put(PrefConstants.OutputEncoding, - (String) outputEncodingBox.getSelectedItem()); + userPrefs.put(PrefConstants.OutputEncoding, (String) outputEncodingBox.getSelectedItem()); userPrefs.put(PrefConstants.BaseURI, baseURILabel.getText()); gmanager.setBaseURI(baseURILabel.getText()); if (isLogAvailableCheckBox.isSelected()) { @@ -293,15 +293,14 @@ public void resetConfig() { // InputEncoding, // "SJIS")); outputEncodingBox.setSelectedItem(userPrefs.get(PrefConstants.OutputEncoding, "UTF-8")); - baseURILabel.setText(userPrefs.get(PrefConstants.BaseURI, - MR3Resource.DefaultURI.getURI())); + baseURILabel.setText(userPrefs.get(PrefConstants.BaseURI, MR3Resource.DefaultURI.getURI())); if (userPrefs.get(PrefConstants.isLogAvailable, "false").equals("true")) { isLogAvailableCheckBox.setSelected(true); } else { isLogAvailableCheckBox.setSelected(false); } setText(logFileField, - userPrefs.get(PrefConstants.logFile, System.getProperty("user.dir") + "\\" + userPrefs.get(PrefConstants.logFile, System.getProperty("user.dir") + "/" + HistoryManager.DEFAULT_LOG_FILE_NAME)); HistoryManager.resetFileAppender(logFileField.getText()); } @@ -344,8 +343,8 @@ private Object[] getSystemUILanguages() { } private Object[] getUILanguages() { - File resourceDir = new File(userPrefs.get(PrefConstants.ResourceDirectory, - System.getProperty("user.dir") + "\\resources")); + File resourceDir = new File(userPrefs.get(PrefConstants.ResourceDirectory, System.getProperty("user.dir") + + "\\resources")); Object[] languages = getLanguages(resourceDir); if (0 < languages.length) { return languages; @@ -366,16 +365,14 @@ private JComponent getUILangPanel() { } private JComponent getEncodingPanel() { - Object[] encodingList = new Object[] { "JISAutoDetect", "SJIS", "EUC_JP", "ISO2022JP", - "UTF-8", "UTF-16" }; + Object[] encodingList = new Object[] { "JISAutoDetect", "SJIS", "EUC_JP", "ISO2022JP", "UTF-8", "UTF-16" }; encodingList = new Object[] { "SJIS", "EUC_JP", "ISO2022JP", "UTF-8", "UTF-16" }; outputEncodingBoxModel = new DefaultComboBoxModel(encodingList); outputEncodingBox = new JComboBox(outputEncodingBoxModel); outputEncodingBox.setPreferredSize(new Dimension(PREFIX_BOX_WIDTH, PREFIX_BOX_HEIGHT)); JPanel encodingPanel = new JPanel(); encodingPanel.setLayout(new GridLayout(1, 2, 5, 5)); - encodingPanel.add(new JLabel(Translator - .getString("PreferenceDialog.BaseTab.OutputEncoding") + ": ")); + encodingPanel.add(new JLabel(Translator.getString("PreferenceDialog.BaseTab.OutputEncoding") + ": ")); encodingPanel.add(outputEncodingBox); return Utilities.createWestPanel(encodingPanel); @@ -383,14 +380,12 @@ private JComponent getEncodingPanel() { private JComponent getFontSettingPanel() { fontSettingValueLabel = new JLabel(getFont().getFontName() + "-" + getFont().getSize()); - fontSettingButton = new JButton( - Translator.getString("PreferenceDialog.BaseTab.FontSetting.Button")); - fontSettingButton.addActionListener(new ChooseFontAction(Translator - .getString("Component.View.ChooseFont"))); + fontSettingButton = new JButton(Translator.getString("PreferenceDialog.BaseTab.FontSetting.Button")); + fontSettingButton + .addActionListener(new ChooseFontAction(Translator.getString("Component.View.ChooseFont"))); JPanel fontSettingPanel = new JPanel(); fontSettingPanel.setLayout(new GridLayout(1, 3, 5, 5)); - fontSettingPanel.add(new JLabel(Translator - .getString("PreferenceDialog.BaseTab.FontSetting") + ": ")); + fontSettingPanel.add(new JLabel(Translator.getString("PreferenceDialog.BaseTab.FontSetting") + ": ")); fontSettingPanel.add(fontSettingValueLabel); fontSettingPanel.add(fontSettingButton); return Utilities.createWestPanel(fontSettingPanel); @@ -448,8 +443,7 @@ private void setGraphFont(RDFGraph graph, Font font) { private JComponent getBaseURIPanel() { uriPrefixBox = new JComboBox(); uriPrefixBox.addActionListener(new ChangePrefixAction()); - JComponent uriPrefixBoxP = Utilities.createTitledPanel(uriPrefixBox, - MR3Constants.PREFIX); + JComponent uriPrefixBoxP = Utilities.createTitledPanel(uriPrefixBox, MR3Constants.PREFIX); baseURILabel = new JLabel(""); JComponent baseURILabelP = Utilities.createTitledPanel(baseURILabel, "URI"); initPrefixBox(); @@ -479,7 +473,9 @@ private String getFileName() { JFileChooser jfc = new JFileChooser(currentFile); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); - jfc.setDialogTitle("Select File"); + FileNameExtensionFilter filter = new FileNameExtensionFilter("*.txt", "txt"); + jfc.addChoosableFileFilter(filter); + jfc.setDialogTitle("Select Log File"); int fd = jfc.showOpenDialog(gmanager.getRootFrame()); if (fd == JFileChooser.APPROVE_OPTION) { return jfc.getSelectedFile().toString(); @@ -496,12 +492,11 @@ public void actionPerformed(ActionEvent e) { } private JPanel getLogFilePanel() { - isLogAvailableCheckBox = new JCheckBox( - Translator.getString("PreferenceDialog.BaseTab.LogFile.check"), false); + isLogAvailableCheckBox = new JCheckBox(Translator.getString("PreferenceDialog.BaseTab.LogFile.check"), + false); logFileField = new JTextField(15); logFileField.setEditable(false); - browseLogFileButton = new JButton( - Translator.getString("PreferenceDialog.DirectoryTab.Browse") + "(L)"); + browseLogFileButton = new JButton(Translator.getString("PreferenceDialog.DirectoryTab.Browse") + "(L)"); browseLogFileButton.setMnemonic('l'); browseLogFileButton.addActionListener(new BrowseFile(logFileField)); @@ -569,11 +564,9 @@ public void setConfig() { public void resetConfig() { setText(workDirectoryField, userPrefs.get(PrefConstants.WorkDirectory, "")); setText(pluginsDirectoryField, - userPrefs.get(PrefConstants.PluginsDirectory, System.getProperty("user.dir") - + "\\plugins")); + userPrefs.get(PrefConstants.PluginsDirectory, System.getProperty("user.dir") + "\\plugins")); setText(resourceDirectoryField, - userPrefs.get(PrefConstants.ResourceDirectory, System.getProperty("user.dir") - + "\\resources")); + userPrefs.get(PrefConstants.ResourceDirectory, System.getProperty("user.dir") + "\\resources")); } class BrowseDirectory extends AbstractAction { @@ -614,8 +607,8 @@ public void actionPerformed(ActionEvent e) { private void initWorkDirectoryField() { workDirectoryField = new JTextField(15); workDirectoryField.setEditable(false); - browseWorkDirectoryButton = new JButton( - Translator.getString("PreferenceDialog.DirectoryTab.Browse") + "(W)"); + browseWorkDirectoryButton = new JButton(Translator.getString("PreferenceDialog.DirectoryTab.Browse") + + "(W)"); browseWorkDirectoryButton.setMnemonic('w'); browseWorkDirectoryButton.addActionListener(new BrowseDirectory(workDirectoryField)); } @@ -623,21 +616,19 @@ private void initWorkDirectoryField() { private void initPluginsDirectoryField() { pluginsDirectoryField = new JTextField(15); pluginsDirectoryField.setEditable(false); - browsePluginsDirectoryButton = new JButton( - Translator.getString("PreferenceDialog.DirectoryTab.Browse") + "(P)"); + browsePluginsDirectoryButton = new JButton(Translator.getString("PreferenceDialog.DirectoryTab.Browse") + + "(P)"); browsePluginsDirectoryButton.setMnemonic('p'); - browsePluginsDirectoryButton.addActionListener(new BrowseDirectory( - pluginsDirectoryField)); + browsePluginsDirectoryButton.addActionListener(new BrowseDirectory(pluginsDirectoryField)); } private void initResourceDirectoryField() { resourceDirectoryField = new JTextField(15); resourceDirectoryField.setEditable(false); - browseResourceDirectoryButton = new JButton( - Translator.getString("PreferenceDialog.DirectoryTab.Browse") + "(R)"); + browseResourceDirectoryButton = new JButton(Translator.getString("PreferenceDialog.DirectoryTab.Browse") + + "(R)"); browseResourceDirectoryButton.setMnemonic('r'); - browseResourceDirectoryButton.addActionListener(new BrowseDirectory( - resourceDirectoryField)); + browseResourceDirectoryButton.addActionListener(new BrowseDirectory(resourceDirectoryField)); } private JPanel getWorkDirectoryPanel() { @@ -663,8 +654,7 @@ private JPanel getPluginDirectoryPanel() { private JPanel getResourceDirectoryPanel() { JPanel resourceDirectoryPanel = new JPanel(); - resourceDirectoryPanel - .setLayout(new BoxLayout(resourceDirectoryPanel, BoxLayout.X_AXIS)); + resourceDirectoryPanel.setLayout(new BoxLayout(resourceDirectoryPanel, BoxLayout.X_AXIS)); resourceDirectoryPanel.setBorder(BorderFactory.createTitledBorder(Translator .getString("PreferenceDialog.DirectoryTab.ResourcesDirectory"))); resourceDirectoryPanel.add(resourceDirectoryField); @@ -756,27 +746,28 @@ class MetaClassPanel extends JPanel implements ListSelectionListener { defaultClassClassField = new JTextField(); defaultClassClassField.setEditable(false); - JComponent defaultClassClassFieldP = Utilities.createTitledPanel( - defaultClassClassField, "Default Class Class"); + JComponent defaultClassClassFieldP = Utilities.createTitledPanel(defaultClassClassField, + "Default Class Class"); classClassListModel = new DefaultListModel(); classClassList = new JList(classClassListModel); classClassList.addListSelectionListener(this); JScrollPane classClassListScroll = new JScrollPane(classClassList); - Utilities.initComponent(classClassListScroll, - Translator.getString("PreferenceDialog.MetaClassTab.ClassClass"), - LONG_URI_FIELD_WIDTH, LIST_HEIGHT); + Utilities + .initComponent(classClassListScroll, + Translator.getString("PreferenceDialog.MetaClassTab.ClassClass"), LONG_URI_FIELD_WIDTH, + LIST_HEIGHT); defaultPropertyClassField = new JTextField(); defaultPropertyClassField.setEditable(false); - JComponent defaultPropertyClassFieldP = Utilities.createTitledPanel( - defaultPropertyClassField, "Default Property Class"); + JComponent defaultPropertyClassFieldP = Utilities.createTitledPanel(defaultPropertyClassField, + "Default Property Class"); propClassListModel = new DefaultListModel(); propClassList = new JList(propClassListModel); propClassList.addListSelectionListener(this); JScrollPane propClassListScroll = new JScrollPane(propClassList); Utilities.initComponent(propClassListScroll, - Translator.getString("PreferenceDialog.MetaClassTab.PropertyClass"), - LONG_URI_FIELD_WIDTH, LIST_HEIGHT); + Translator.getString("PreferenceDialog.MetaClassTab.PropertyClass"), LONG_URI_FIELD_WIDTH, + LIST_HEIGHT); JPanel classClassPanel = new JPanel(); classClassPanel.setLayout(new BoxLayout(classClassPanel, BoxLayout.Y_AXIS)); @@ -806,20 +797,16 @@ public String toString() { public void setConfig() { userPrefs.put(PrefConstants.DefaultClassClass, defaultClassClassField.getText()); - userPrefs.put(PrefConstants.ClassClassList, - getMetaClassStr(classClassListModel.toArray())); + userPrefs.put(PrefConstants.ClassClassList, getMetaClassStr(classClassListModel.toArray())); userPrefs.put(PrefConstants.DefaultPropertyClass, defaultPropertyClassField.getText()); - userPrefs.put(PrefConstants.PropClassList, - getMetaClassStr(propClassListModel.toArray())); + userPrefs.put(PrefConstants.PropClassList, getMetaClassStr(propClassListModel.toArray())); } public void resetConfig() { - String defaultClassClass = userPrefs.get(PrefConstants.DefaultClassClass, - RDFS.Class.getURI()); + String defaultClassClass = userPrefs.get(PrefConstants.DefaultClassClass, RDFS.Class.getURI()); defaultClassClassField.setText(defaultClassClass); defaultClassClassField.setToolTipText(defaultClassClass); - String classClassListStr = userPrefs.get(PrefConstants.ClassClassList, - GraphManager.CLASS_CLASS_LIST); + String classClassListStr = userPrefs.get(PrefConstants.ClassClassList, GraphManager.CLASS_CLASS_LIST); String[] list = classClassListStr.split(" "); Arrays.sort(list); classClassListModel.clear(); @@ -827,12 +814,10 @@ public void resetConfig() { classClassListModel.addElement(list[i]); } - String defaultPropertyClass = userPrefs.get(PrefConstants.DefaultPropertyClass, - RDF.Property.getURI()); + String defaultPropertyClass = userPrefs.get(PrefConstants.DefaultPropertyClass, RDF.Property.getURI()); defaultPropertyClassField.setText(defaultPropertyClass); defaultPropertyClassField.setToolTipText(defaultPropertyClass); - String propClassListStr = userPrefs.get(PrefConstants.PropClassList, - GraphManager.PROPERTY_CLASS_LIST); + String propClassListStr = userPrefs.get(PrefConstants.PropClassList, GraphManager.PROPERTY_CLASS_LIST); list = propClassListStr.split(" "); Arrays.sort(list); propClassListModel.clear(); @@ -895,8 +880,7 @@ private JComponent getPropertyClassButtonPanel() { class ClassClassButtonAction extends AbstractAction { private boolean isEditable() { - return !classClassList.isSelectionEmpty() - && classClassList.getSelectedIndices().length == 1 + return !classClassList.isSelectionEmpty() && classClassList.getSelectedIndices().length == 1 && !isDefaultClass(classClassList.getSelectedValue()) && isAddable(); } @@ -907,8 +891,7 @@ private boolean isAddable() { private void edit() { if (isEditable()) { - classClassListModel.setElementAt(metaClassField.getText(), - classClassList.getSelectedIndex()); + classClassListModel.setElementAt(metaClassField.getText(), classClassList.getSelectedIndex()); } } @@ -962,8 +945,7 @@ public void actionPerformed(ActionEvent e) { class PropClassButtonAction extends AbstractAction { private boolean isEditable() { - return !propClassList.isSelectionEmpty() - && propClassList.getSelectedIndices().length == 1 + return !propClassList.isSelectionEmpty() && propClassList.getSelectedIndices().length == 1 && !isDefaultProperty(propClassList.getSelectedValue()) && isAddable(); } @@ -974,8 +956,7 @@ private boolean isAddable() { private void edit() { if (isEditable()) { - propClassListModel.setElementAt(metaClassField.getText(), - propClassList.getSelectedIndex()); + propClassListModel.setElementAt(metaClassField.getText(), propClassList.getSelectedIndex()); } } @@ -986,8 +967,7 @@ private void add() { } private boolean isDefaultProperty(Object item) { - return item.equals(RDF.Property.toString()) - || item.equals(OWL.ObjectProperty.toString()) + return item.equals(RDF.Property.toString()) || item.equals(OWL.ObjectProperty.toString()) || item.equals(OWL.DatatypeProperty.toString()); } @@ -1063,8 +1043,7 @@ class LayoutPanel extends JPanel { LayoutPanel() { ChangeNodeSizeAction nodeSizeAction = new ChangeNodeSizeAction(); - autoSizeButton = new JRadioButton( - Translator.getString("PreferenceDialog.LayoutTab.Auto")); + autoSizeButton = new JRadioButton(Translator.getString("PreferenceDialog.LayoutTab.Auto")); autoSizeButton.addActionListener(nodeSizeAction); autoSizeButton.setSelected(true); fixSizeButton = new JRadioButton(Translator.getString("PreferenceDialog.LayoutTab.Fix")); @@ -1078,12 +1057,10 @@ class LayoutPanel extends JPanel { nodeSizeButtonPanel.setBorder(BorderFactory.createTitledBorder(Translator .getString("PreferenceDialog.LayoutTab.NodeSize"))); - nodeWidthLabel = new JLabel( - Translator.getString("PreferenceDialog.LayoutTab.NodeWidth")); + nodeWidthLabel = new JLabel(Translator.getString("PreferenceDialog.LayoutTab.NodeWidth")); nodeWidthSpinner = new JSpinner(new SpinnerNumberModel(50, 0, 999, 1)); nodeWidthSpinner.setEnabled(false); - nodeHeightLabel = new JLabel( - Translator.getString("PreferenceDialog.LayoutTab.NodeHeight")); + nodeHeightLabel = new JLabel(Translator.getString("PreferenceDialog.LayoutTab.NodeHeight")); nodeHeightSpinner = new JSpinner(new SpinnerNumberModel(50, 0, 999, 1)); nodeHeightSpinner.setEnabled(false); @@ -1095,21 +1072,15 @@ class LayoutPanel extends JPanel { nodeSizePanel.add(nodeHeightSpinner); nodeSizePanel.setBorder(BorderFactory.createEtchedBorder()); - layoutTypeLabel = new JLabel( - Translator.getString("PreferenceDialog.LayoutTab.LayoutType")); - verticalSpaceLabel = new JLabel( - Translator.getString("PreferenceDialog.LayoutTab.VerticalSpace")); + layoutTypeLabel = new JLabel(Translator.getString("PreferenceDialog.LayoutTab.LayoutType")); + verticalSpaceLabel = new JLabel(Translator.getString("PreferenceDialog.LayoutTab.VerticalSpace")); verticalSpaceLabel.setHorizontalAlignment(JLabel.CENTER); - horizontalSpaceLabel = new JLabel( - Translator.getString("PreferenceDialog.LayoutTab.HorizontalSpace")); + horizontalSpaceLabel = new JLabel(Translator.getString("PreferenceDialog.LayoutTab.HorizontalSpace")); horizontalSpaceLabel.setHorizontalAlignment(JLabel.CENTER); - rdfLayoutLabel = new JLabel( - Translator.getString("PreferenceDialog.LayoutTab.RDFLayoutDirection")); - classLayoutLabel = new JLabel( - Translator.getString("PreferenceDialog.LayoutTab.ClassLayoutDirection")); - propertyLayoutLabel = new JLabel( - Translator.getString("PreferenceDialog.LayoutTab.PropertyLayoutDirection")); + rdfLayoutLabel = new JLabel(Translator.getString("PreferenceDialog.LayoutTab.RDFLayoutDirection")); + classLayoutLabel = new JLabel(Translator.getString("PreferenceDialog.LayoutTab.ClassLayoutDirection")); + propertyLayoutLabel = new JLabel(Translator.getString("PreferenceDialog.LayoutTab.PropertyLayoutDirection")); layoutTypeBox = new JComboBox(new Object[] { GraphLayoutUtilities.VGJ_TREE_LAYOUT, GraphLayoutUtilities.JGRAPH_TREE_LAYOUT }); @@ -1119,8 +1090,7 @@ class LayoutPanel extends JPanel { classHorizontalSpaceSpinner = new JSpinner(new SpinnerNumberModel(200, 0, 999, 1)); propertyVerticalSpaceSpinner = new JSpinner(new SpinnerNumberModel(50, 0, 999, 1)); propertyHorizontalSpaceSpinner = new JSpinner(new SpinnerNumberModel(200, 0, 999, 1)); - Object[] directionList = new Object[] { GraphLayoutUtilities.UP_TO_DOWN, - GraphLayoutUtilities.LEFT_TO_RIGHT }; + Object[] directionList = new Object[] { GraphLayoutUtilities.UP_TO_DOWN, GraphLayoutUtilities.LEFT_TO_RIGHT }; rdfLayoutDirectionBox = new JComboBox(directionList); classLayoutDirectionBox = new JComboBox(directionList); propertyLayoutDirectionBox = new JComboBox(directionList); @@ -1144,45 +1114,34 @@ public String toString() { public void setConfig() { userPrefs.put(PrefConstants.LAYOUT_TYPE, (String) layoutTypeBox.getSelectedItem()); GraphLayoutUtilities.LAYOUT_TYPE = (String) layoutTypeBox.getSelectedItem(); - userPrefs.put(PrefConstants.RDF_LAYOUT_DIRECTION, - (String) rdfLayoutDirectionBox.getSelectedItem()); - GraphLayoutUtilities.RDF_LAYOUT_DIRECTION = (String) rdfLayoutDirectionBox - .getSelectedItem(); - userPrefs.put(PrefConstants.CLASS_LAYOUT_DIRECTION, - (String) classLayoutDirectionBox.getSelectedItem()); - GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION = (String) classLayoutDirectionBox - .getSelectedItem(); + userPrefs.put(PrefConstants.RDF_LAYOUT_DIRECTION, (String) rdfLayoutDirectionBox.getSelectedItem()); + GraphLayoutUtilities.RDF_LAYOUT_DIRECTION = (String) rdfLayoutDirectionBox.getSelectedItem(); + userPrefs.put(PrefConstants.CLASS_LAYOUT_DIRECTION, (String) classLayoutDirectionBox.getSelectedItem()); + GraphLayoutUtilities.CLASS_LAYOUT_DIRECTION = (String) classLayoutDirectionBox.getSelectedItem(); userPrefs.put(PrefConstants.PROPERTY_LAYOUT_DIRECTION, (String) propertyLayoutDirectionBox.getSelectedItem()); - GraphLayoutUtilities.PROPERTY_LAYOUT_DIRECTION = (String) propertyLayoutDirectionBox - .getSelectedItem(); + GraphLayoutUtilities.PROPERTY_LAYOUT_DIRECTION = (String) propertyLayoutDirectionBox.getSelectedItem(); - userPrefs.put(PrefConstants.RDF_VERTICAL_SPACE, rdfVerticalSpaceSpinner.getValue() + userPrefs.put(PrefConstants.RDF_VERTICAL_SPACE, rdfVerticalSpaceSpinner.getValue().toString()); + GraphLayoutUtilities.RDF_VERTICAL_SPACE = Integer.parseInt(rdfVerticalSpaceSpinner.getValue().toString()); + userPrefs.put(PrefConstants.RDF_HORIZONTAL_SPACE, rdfHorizontalSpaceSpinner.getValue().toString()); + GraphLayoutUtilities.RDF_HORIZONTAL_SPACE = Integer.parseInt(rdfHorizontalSpaceSpinner.getValue() .toString()); - GraphLayoutUtilities.RDF_VERTICAL_SPACE = Integer.parseInt(rdfVerticalSpaceSpinner - .getValue().toString()); - userPrefs.put(PrefConstants.RDF_HORIZONTAL_SPACE, rdfHorizontalSpaceSpinner.getValue() + + userPrefs.put(PrefConstants.CLASS_VERTICAL_SPACE, classVerticalSpaceSpinner.getValue().toString()); + GraphLayoutUtilities.CLASS_VERTICAL_SPACE = Integer.parseInt(classVerticalSpaceSpinner.getValue() + .toString()); + userPrefs.put(PrefConstants.CLASS_HORIZONTAL_SPACE, classHorizontalSpaceSpinner.getValue().toString()); + GraphLayoutUtilities.CLASS_HORIZONTAL_SPACE = Integer.parseInt(classHorizontalSpaceSpinner.getValue() .toString()); - GraphLayoutUtilities.RDF_HORIZONTAL_SPACE = Integer.parseInt(rdfHorizontalSpaceSpinner - .getValue().toString()); - userPrefs.put(PrefConstants.CLASS_VERTICAL_SPACE, classVerticalSpaceSpinner.getValue() + userPrefs.put(PrefConstants.PROPERTY_VERTICAL_SPACE, propertyVerticalSpaceSpinner.getValue().toString()); + GraphLayoutUtilities.PROPERTY_VERTICAL_SPACE = Integer.parseInt(propertyVerticalSpaceSpinner.getValue() + .toString()); + userPrefs + .put(PrefConstants.PROPERTY_HORIZONTAL_SPACE, propertyHorizontalSpaceSpinner.getValue().toString()); + GraphLayoutUtilities.PROPERTY_HORIZONTAL_SPACE = Integer.parseInt(propertyHorizontalSpaceSpinner.getValue() .toString()); - GraphLayoutUtilities.CLASS_VERTICAL_SPACE = Integer.parseInt(classVerticalSpaceSpinner - .getValue().toString()); - userPrefs.put(PrefConstants.CLASS_HORIZONTAL_SPACE, classHorizontalSpaceSpinner - .getValue().toString()); - GraphLayoutUtilities.CLASS_HORIZONTAL_SPACE = Integer - .parseInt(classHorizontalSpaceSpinner.getValue().toString()); - - userPrefs.put(PrefConstants.PROPERTY_VERTICAL_SPACE, propertyVerticalSpaceSpinner - .getValue().toString()); - GraphLayoutUtilities.PROPERTY_VERTICAL_SPACE = Integer - .parseInt(propertyVerticalSpaceSpinner.getValue().toString()); - userPrefs.put(PrefConstants.PROPERTY_HORIZONTAL_SPACE, propertyHorizontalSpaceSpinner - .getValue().toString()); - GraphLayoutUtilities.PROPERTY_HORIZONTAL_SPACE = Integer - .parseInt(propertyHorizontalSpaceSpinner.getValue().toString()); if (autoSizeButton.isSelected()) { userPrefs.put(PrefConstants.NODE_SIZE, PrefConstants.NODE_SIZE_AUTO); @@ -1198,54 +1157,41 @@ public void setConfig() { } public void resetConfig() { - String layoutType = userPrefs.get(PrefConstants.LAYOUT_TYPE, - GraphLayoutUtilities.VGJ_TREE_LAYOUT); + String layoutType = userPrefs.get(PrefConstants.LAYOUT_TYPE, GraphLayoutUtilities.VGJ_TREE_LAYOUT); layoutTypeBox.setSelectedItem(layoutType); - String direction = userPrefs.get(PrefConstants.RDF_LAYOUT_DIRECTION, - GraphLayoutUtilities.LEFT_TO_RIGHT); + String direction = userPrefs.get(PrefConstants.RDF_LAYOUT_DIRECTION, GraphLayoutUtilities.LEFT_TO_RIGHT); if (isValidLayoutDirection(rdfLayoutDirectionBox, direction)) { rdfLayoutDirectionBox.setSelectedItem(direction); } else { - direction = changeDirectionWithLanguage(direction, - PrefConstants.RDF_LAYOUT_DIRECTION); + direction = changeDirectionWithLanguage(direction, PrefConstants.RDF_LAYOUT_DIRECTION); rdfLayoutDirectionBox.setSelectedItem(direction); } - direction = userPrefs.get(PrefConstants.CLASS_LAYOUT_DIRECTION, - GraphLayoutUtilities.LEFT_TO_RIGHT); + direction = userPrefs.get(PrefConstants.CLASS_LAYOUT_DIRECTION, GraphLayoutUtilities.LEFT_TO_RIGHT); if (isValidLayoutDirection(classLayoutDirectionBox, direction)) { classLayoutDirectionBox.setSelectedItem(direction); } else { - direction = changeDirectionWithLanguage(direction, - PrefConstants.CLASS_LAYOUT_DIRECTION); + direction = changeDirectionWithLanguage(direction, PrefConstants.CLASS_LAYOUT_DIRECTION); classLayoutDirectionBox.setSelectedItem(direction); } - direction = userPrefs.get(PrefConstants.PROPERTY_LAYOUT_DIRECTION, - GraphLayoutUtilities.LEFT_TO_RIGHT); + direction = userPrefs.get(PrefConstants.PROPERTY_LAYOUT_DIRECTION, GraphLayoutUtilities.LEFT_TO_RIGHT); if (isValidLayoutDirection(propertyLayoutDirectionBox, direction)) { propertyLayoutDirectionBox.setSelectedItem(direction); } else { - direction = changeDirectionWithLanguage(direction, - PrefConstants.PROPERTY_LAYOUT_DIRECTION); + direction = changeDirectionWithLanguage(direction, PrefConstants.PROPERTY_LAYOUT_DIRECTION); propertyLayoutDirectionBox.setSelectedItem(direction); } - rdfVerticalSpaceSpinner.setValue(new Integer(userPrefs.get( - PrefConstants.RDF_VERTICAL_SPACE, + rdfVerticalSpaceSpinner.setValue(new Integer(userPrefs.get(PrefConstants.RDF_VERTICAL_SPACE, Integer.toString(GraphLayoutUtilities.VERTICAL_SPACE)))); - rdfHorizontalSpaceSpinner.setValue(new Integer(userPrefs.get( - PrefConstants.RDF_HORIZONTAL_SPACE, + rdfHorizontalSpaceSpinner.setValue(new Integer(userPrefs.get(PrefConstants.RDF_HORIZONTAL_SPACE, Integer.toString(GraphLayoutUtilities.HORIZONTAL_SPACE)))); - classVerticalSpaceSpinner.setValue(new Integer(userPrefs.get( - PrefConstants.CLASS_VERTICAL_SPACE, + classVerticalSpaceSpinner.setValue(new Integer(userPrefs.get(PrefConstants.CLASS_VERTICAL_SPACE, Integer.toString(GraphLayoutUtilities.VERTICAL_SPACE)))); - classHorizontalSpaceSpinner.setValue(new Integer(userPrefs.get( - PrefConstants.CLASS_HORIZONTAL_SPACE, + classHorizontalSpaceSpinner.setValue(new Integer(userPrefs.get(PrefConstants.CLASS_HORIZONTAL_SPACE, Integer.toString(GraphLayoutUtilities.HORIZONTAL_SPACE)))); - propertyVerticalSpaceSpinner.setValue(new Integer(userPrefs.get( - PrefConstants.PROPERTY_VERTICAL_SPACE, + propertyVerticalSpaceSpinner.setValue(new Integer(userPrefs.get(PrefConstants.PROPERTY_VERTICAL_SPACE, Integer.toString(GraphLayoutUtilities.VERTICAL_SPACE)))); - propertyHorizontalSpaceSpinner.setValue(new Integer(userPrefs.get( - PrefConstants.PROPERTY_HORIZONTAL_SPACE, + propertyHorizontalSpaceSpinner.setValue(new Integer(userPrefs.get(PrefConstants.PROPERTY_HORIZONTAL_SPACE, Integer.toString(GraphLayoutUtilities.HORIZONTAL_SPACE)))); String nodeSize = userPrefs.get(PrefConstants.NODE_SIZE, PrefConstants.NODE_SIZE_AUTO); @@ -1351,36 +1297,32 @@ class RenderingPanel extends JPanel { RenderingPanel() { ChangeColorAction action = new ChangeColorAction(); - rdfResourceColorButton = new JButton( - Translator.getString("PreferenceDialog.RenderingTab.RDFResourceColor") + "(R)"); + rdfResourceColorButton = new JButton(Translator.getString("PreferenceDialog.RenderingTab.RDFResourceColor") + + "(R)"); rdfResourceColorButton.setMnemonic('r'); initColorButton(rdfResourceColorButton, "Resource", BUTTON_WIDTH, BUTTON_HEIGHT, action); - literalColorButton = new JButton( - Translator.getString("PreferenceDialog.RenderingTab.RDFLiteralColor") + "(L)"); + literalColorButton = new JButton(Translator.getString("PreferenceDialog.RenderingTab.RDFLiteralColor") + + "(L)"); literalColorButton.setMnemonic('l'); initColorButton(literalColorButton, "Literal", BUTTON_WIDTH, BUTTON_HEIGHT, action); - classColorButton = new JButton( - Translator.getString("PreferenceDialog.RenderingTab.ClassColor") + "(U)"); + classColorButton = new JButton(Translator.getString("PreferenceDialog.RenderingTab.ClassColor") + "(U)"); classColorButton.setMnemonic('u'); initColorButton(classColorButton, "Class", BUTTON_WIDTH, BUTTON_HEIGHT, action); - propertyColorButton = new JButton( - Translator.getString("PreferenceDialog.RenderingTab.PropertyColor") + "(P)"); + propertyColorButton = new JButton(Translator.getString("PreferenceDialog.RenderingTab.PropertyColor") + + "(P)"); propertyColorButton.setMnemonic('p'); initColorButton(propertyColorButton, "Property", BUTTON_WIDTH, BUTTON_HEIGHT, action); - selectedColorButton = new JButton( - Translator.getString("PreferenceDialog.RenderingTab.SelectedColor") + "(S)"); + selectedColorButton = new JButton(Translator.getString("PreferenceDialog.RenderingTab.SelectedColor") + + "(S)"); selectedColorButton.setMnemonic('s'); initColorButton(selectedColorButton, "Selected", BUTTON_WIDTH, BUTTON_HEIGHT, action); - backgroundColorButton = new JButton( - Translator.getString("PreferenceDialog.RenderingTab.BackgroundColor") + "(B)"); + backgroundColorButton = new JButton(Translator.getString("PreferenceDialog.RenderingTab.BackgroundColor") + + "(B)"); backgroundColorButton.setMnemonic('b'); - initColorButton(backgroundColorButton, "Background", BUTTON_WIDTH, BUTTON_HEIGHT, - action); + initColorButton(backgroundColorButton, "Background", BUTTON_WIDTH, BUTTON_HEIGHT, action); - isColorBox = new JCheckBox( - Translator.getString("PreferenceDialog.RenderingTab.Option.Color")); - isAntialiasBox = new JCheckBox( - Translator.getString("PreferenceDialog.RenderingTab.Option.Antialias")); + isColorBox = new JCheckBox(Translator.getString("PreferenceDialog.RenderingTab.Option.Color")); + isAntialiasBox = new JCheckBox(Translator.getString("PreferenceDialog.RenderingTab.Option.Antialias")); JPanel colorPanel = new JPanel(); colorPanel.setBorder(BorderFactory.createTitledBorder(Translator @@ -1447,8 +1389,7 @@ public void resetConfig() { isAntialiasBox.setSelected(userPrefs.getBoolean(PrefConstants.Antialias, true)); } - private void initColorButton(JButton button, String name, int width, int height, - Action action) { + private void initColorButton(JButton button, String name, int width, int height, Action action) { button.setHorizontalAlignment(JButton.LEFT); button.setIcon(new ColorSwatch(name)); button.setPreferredSize(new Dimension(width, height)); @@ -1541,8 +1482,7 @@ private void setText(JTextComponent jtc, String text) { } private boolean isValidLayoutDirection(JComboBox box, String direction) { - return (box.getModel().getElementAt(0).equals(direction) || box.getModel().getElementAt(1) - .equals(direction)); + return (box.getModel().getElementAt(0).equals(direction) || box.getModel().getElementAt(1).equals(direction)); } public void resetConfig() { @@ -1573,8 +1513,8 @@ private void setConfig() { layoutPanel.setConfig(); renderingPanel.setConfig(); } catch (NumberFormatException nfe) { - JOptionPane.showMessageDialog(gmanager.getDesktopTabbedPane(), - "Number Format Exception", "Warning", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(gmanager.getDesktopTabbedPane(), "Number Format Exception", "Warning", + JOptionPane.ERROR_MESSAGE); return; } } diff --git a/src/main/java/net/sourceforge/mr3/util/NTripleFileFilter.java b/src/main/java/net/sourceforge/mr3/util/NTripleFileFilter.java index 9c17ab1f..de7a02a0 100644 --- a/src/main/java/net/sourceforge/mr3/util/NTripleFileFilter.java +++ b/src/main/java/net/sourceforge/mr3/util/NTripleFileFilter.java @@ -23,29 +23,39 @@ package net.sourceforge.mr3.util; -import java.io.*; +import java.io.File; /** * @author Takeshi Morita */ public class NTripleFileFilter extends MR3FileFilter implements java.io.FileFilter { - public String getExtension() { - return "n3"; - } + private boolean isShowDirectories; - public boolean accept(File f) { - if (f.isDirectory()) { return false; } - String extension = getExtension(f); - if (extension != null && extension.equals("n3")) { return true; } - return false; - } + public NTripleFileFilter(boolean isShowDirectories) { + this.isShowDirectories = isShowDirectories; + } - public String getDescription() { - return "N-Triple File (*.n3)"; - } + public String getExtension() { + return "n3"; + } - public String toString() { - return getDescription(); - } + public boolean accept(File f) { + if (f.isDirectory()) { + return isShowDirectories; + } + String extension = getExtension(f); + if (extension != null && extension.equals("n3")) { + return true; + } + return false; + } + + public String getDescription() { + return "N-Triple File (*.n3)"; + } + + public String toString() { + return getDescription(); + } } diff --git a/src/main/java/net/sourceforge/mr3/util/OWLFileFilter.java b/src/main/java/net/sourceforge/mr3/util/OWLFileFilter.java index c6a81890..429788b5 100644 --- a/src/main/java/net/sourceforge/mr3/util/OWLFileFilter.java +++ b/src/main/java/net/sourceforge/mr3/util/OWLFileFilter.java @@ -23,25 +23,35 @@ package net.sourceforge.mr3.util; -import java.io.*; +import java.io.File; /** * @author Takeshi Morita */ public class OWLFileFilter extends MR3FileFilter implements java.io.FileFilter { - public String getExtension() { - return "owl"; - } + private boolean isShowDirectories; - public boolean accept(File f) { - if (f.isDirectory()) { return true; } - String extension = getExtension(f); - if (extension != null && extension.equals("owl")) { return true; } - return false; - } + public OWLFileFilter(boolean isShowDirectories) { + this.isShowDirectories = isShowDirectories; + } - public String getDescription() { - return "OWL File (*.owl)"; - } + public String getExtension() { + return "owl"; + } + + public boolean accept(File f) { + if (f.isDirectory()) { + return isShowDirectories; + } + String extension = getExtension(f); + if (extension != null && extension.equals("owl")) { + return true; + } + return false; + } + + public String getDescription() { + return "OWL File (*.owl)"; + } } diff --git a/src/main/java/net/sourceforge/mr3/util/RDFsFileFilter.java b/src/main/java/net/sourceforge/mr3/util/RDFsFileFilter.java index cd111201..9cb8ee75 100644 --- a/src/main/java/net/sourceforge/mr3/util/RDFsFileFilter.java +++ b/src/main/java/net/sourceforge/mr3/util/RDFsFileFilter.java @@ -23,27 +23,37 @@ package net.sourceforge.mr3.util; -import java.io.*; +import java.io.File; /** * @author Takeshi Morita */ public class RDFsFileFilter extends MR3FileFilter implements java.io.FileFilter { - public String getExtension() { - return "rdf"; - } - - public boolean accept(File f) { - if (f.isDirectory()) { return true; } - String extension = getExtension(f); - if (extension != null) { - if (extension.equals("xml") || extension.equals("rdf") || extension.equals("rdfs")) { return true; } - } - return false; - } - - public String getDescription() { - return "RDF(S) (*.xml, *.rdf, *.rdfs)"; - } + private boolean isShowDirectories; + + public RDFsFileFilter(boolean isShowDirectories) { + this.isShowDirectories = isShowDirectories; + } + + public String getExtension() { + return "rdf"; + } + + public boolean accept(File f) { + if (f.isDirectory()) { + return isShowDirectories; + } + String extension = getExtension(f); + if (extension != null) { + if (extension.equals("xml") || extension.equals("rdf") || extension.equals("rdfs")) { + return true; + } + } + return false; + } + + public String getDescription() { + return "RDF(S) (*.xml, *.rdf, *.rdfs)"; + } } diff --git a/src/main/java/net/sourceforge/mr3/util/TurtleFileFilter.java b/src/main/java/net/sourceforge/mr3/util/TurtleFileFilter.java index aabf247b..ee81296c 100644 --- a/src/main/java/net/sourceforge/mr3/util/TurtleFileFilter.java +++ b/src/main/java/net/sourceforge/mr3/util/TurtleFileFilter.java @@ -23,25 +23,35 @@ package net.sourceforge.mr3.util; -import java.io.*; +import java.io.File; /** * @author Takeshi Morita */ public class TurtleFileFilter extends MR3FileFilter implements java.io.FileFilter { - public String getExtension() { - return "ttl"; - } + private boolean isShowDirectories; - public boolean accept(File f) { - if (f.isDirectory()) { return true; } - String extension = getExtension(f); - if (extension != null && extension.equals("ttl")) { return true; } - return false; - } + public TurtleFileFilter(boolean isShowDirectories) { + this.isShowDirectories = isShowDirectories; + } - public String getDescription() { - return "Turtle (*.ttl)"; - } + public String getExtension() { + return "ttl"; + } + + public boolean accept(File f) { + if (f.isDirectory()) { + return isShowDirectories; + } + String extension = getExtension(f); + if (extension != null && extension.equals("ttl")) { + return true; + } + return false; + } + + public String getDescription() { + return "Turtle (*.ttl)"; + } }