Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.
Open

OWL #100

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@

import javax.swing.JFrame;

import org.coode.owlapi.turtle.TurtleOntologyFormat;
import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import org.semanticweb.owlapi.io.OWLXMLOntologyFormat;
import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
import org.semanticweb.owlapi.model.OWLOntologyFormat;

import RefOntoUML.parser.OntoUMLParser;
import net.menthor.common.settings.owl.OWL2Approach;
Expand Down Expand Up @@ -117,7 +121,15 @@ public static ResultType generateOwl(OntoUMLParser filteredParser, RefOntoUML.Pa
try {
if(trOpt.getApproach()==OWL2Approach.SIMPLE)
{
owlOutput = OntoUML2SimpleOWL.Transformation(model, owlOptions.getIRI());
OWLOntologyFormat format = new RDFXMLOntologyFormat();
if ( trOpt.getPath().endsWith(".owl")) {
format = new OWLXMLOntologyFormat();
} else
if ( trOpt.getPath().endsWith(".ttl")) {
format = new TurtleOntologyFormat();
}

owlOutput = OntoUML2SimpleOWL.Transformation(model, owlOptions.getIRI(), format);
}
if(trOpt.getApproach()==OWL2Approach.OOTOS)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,121 +1,121 @@
package net.menthor.editor.v2.ui.generic;
/**
* ============================================================================================
* Menthor Editor -- Copyright (c) 2015
*
* This file is part of Menthor Editor. Menthor Editor is based on TinyUML and as so it is
* distributed under the same license terms.
*
* Menthor Editor is free software; you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* Menthor Editor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Menthor Editor;
* if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301 USA
* ============================================================================================
*/
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
public abstract class GenericDestinePane extends JPanel {
private static final long serialVersionUID = 5020467392354283714L;
protected JPanel radioPane;
protected JPanel comboPane;
protected JLabel pathLabel;
protected JButton browseButton;
protected JTextField pathText;
protected ButtonGroup group;
protected String fileDescription;
protected String fileExtension;
//====================================================
//Constructor and Initializer Methods
//====================================================
public GenericDestinePane(String fileDescription, String fileExtension)
{
this.fileDescription = fileDescription;
this.fileExtension = fileExtension;
buildUI();
}
private void buildUI(){
setBorder(new TitledBorder(null, "Destine", TitledBorder.LEADING, TitledBorder.TOP, null, null));
setLayout(new BorderLayout(5, 5));
group = new ButtonGroup();
radioPane = new JPanel();
add(radioPane, BorderLayout.SOUTH);
comboPane = new JPanel();
add(comboPane, BorderLayout.NORTH);
comboPane.setLayout(new BorderLayout(10, 10));
pathLabel = new JLabel("File Path:");
pathLabel.setHorizontalAlignment(SwingConstants.RIGHT);
comboPane.add(pathLabel, BorderLayout.WEST);
pathText = new JTextField();
pathText.setBackground(Color.WHITE);
comboPane.add(pathText, BorderLayout.CENTER);
pathText.setColumns(10);
pathText.setEditable(false);
browseButton = new JButton("...");
browseButton.setPreferredSize(new Dimension(35, 23));
comboPane.add(browseButton, BorderLayout.EAST);
browseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
getFilePath();
}
});
}
//====================================================
//Getters & Setters
//====================================================
public String getPath() { return pathText.getText(); }
public void setPath(String text) { pathText.setText(text); }
protected void enableFileChooser(boolean flag){
pathText.setEnabled(flag);
pathText.setEditable(flag);
browseButton.setEnabled(flag);
pathLabel.setEnabled(flag);
}
protected void getFilePath(){
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Destination");
FileNameExtensionFilter filter = new FileNameExtensionFilter(fileDescription, fileExtension);
fileChooser.addChoosableFileFilter(filter);
fileChooser.setFileFilter(filter);
fileChooser.setAcceptAllFileFilterUsed(false);
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){
File selectedFile = fileChooser.getSelectedFile();
String filePath = selectedFile.getAbsolutePath();
if(!filePath.endsWith("."+fileExtension)) filePath += "."+fileExtension;
pathText.setText(filePath);
}
}
}
package net.menthor.editor.v2.ui.generic;

/**
* ============================================================================================
* Menthor Editor -- Copyright (c) 2015
*
* This file is part of Menthor Editor. Menthor Editor is based on TinyUML and as so it is
* distributed under the same license terms.
*
* Menthor Editor is free software; you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* Menthor Editor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Menthor Editor;
* if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301 USA
* ============================================================================================
*/

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;
import javax.swing.filechooser.FileNameExtensionFilter;

public abstract class GenericDestinePane extends JPanel {

private static final long serialVersionUID = 5020467392354283714L;

protected JPanel radioPane;
protected JPanel comboPane;
protected JLabel pathLabel;
protected JButton browseButton;
protected JTextField pathText;
protected ButtonGroup group;
protected String[] extensions;
protected String description;

//====================================================
//Constructor and Initializer Methods
//====================================================

public GenericDestinePane( final String description, final String... extensions )
{
this.description = description;
this.extensions = extensions;
buildUI();
}

private void buildUI(){
setBorder(new TitledBorder(null, "Destine", TitledBorder.LEADING, TitledBorder.TOP, null, null));
setLayout(new BorderLayout(5, 5));
group = new ButtonGroup();
radioPane = new JPanel();
add(radioPane, BorderLayout.SOUTH);
comboPane = new JPanel();
add(comboPane, BorderLayout.NORTH);
comboPane.setLayout(new BorderLayout(10, 10));
pathLabel = new JLabel("File Path:");
pathLabel.setHorizontalAlignment(SwingConstants.RIGHT);
comboPane.add(pathLabel, BorderLayout.WEST);
pathText = new JTextField();
pathText.setBackground(Color.WHITE);
comboPane.add(pathText, BorderLayout.CENTER);
pathText.setColumns(10);
pathText.setEditable(false);
browseButton = new JButton("...");
browseButton.setPreferredSize(new Dimension(35, 23));
comboPane.add(browseButton, BorderLayout.EAST);
browseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
getFilePath();
}
});
}

//====================================================
//Getters & Setters
//====================================================

public String getPath() { return pathText.getText(); }
public void setPath(String text) { pathText.setText(text); }

protected void enableFileChooser(boolean flag){
pathText.setEnabled(flag);
pathText.setEditable(flag);
browseButton.setEnabled(flag);
pathLabel.setEnabled(flag);
}

protected void getFilePath(){
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Destination");
FileNameExtensionFilter filter = new FileNameExtensionFilter(description, extensions);
fileChooser.addChoosableFileFilter(filter);
fileChooser.setFileFilter(filter);
fileChooser.setAcceptAllFileFilterUsed(false);
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){
File selectedFile = fileChooser.getSelectedFile();
String filePath = selectedFile.getAbsolutePath();
// if(!filePath.endsWith("."+extension)) filePath += "."+fileExtension;
pathText.setText(filePath);
}
}
}
Loading