%s
", errorStr);
try {
doc.insertBeforeEnd(doc.getDefaultRootElement(), error);
} catch (BadLocationException e) {
errorHandler.error("BadLocationException for appender " + name, e, ErrorCode.GENERIC_FAILURE);
return;
} catch (IOException e1) {
errorHandler.error("IOException for appender " + name, e1, ErrorCode.GENERIC_FAILURE);
return;
}
}
jTextPane.update(jTextPane.getGraphics());
jTextPane.setCaretPosition(jTextPane.getDocument().getLength());
}
public boolean requiresLayout() {
return true;
}
public synchronized void close() {
if (this.closed)
return;
this.closed = true;
}
}
MainFrame.java 0000664 0000000 0000000 00000020076 13706574304 0034615 0 ustar 00root root 0000000 0000000 saref-pipeline-5365b2351dd12aaeac2c860ae6f762a5a3c7a121/src/main/java/fr/mines_stetienne/ci/saref/gui /*
* Copyright 2020 ETSI
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package fr.mines_stetienne.ci.saref.gui;
import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.WindowConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.mines_stetienne.ci.saref.SAREF;
import fr.mines_stetienne.ci.saref.SAREFCredentialsProvider;
import fr.mines_stetienne.ci.saref.SAREFPipeline;
import fr.mines_stetienne.ci.saref.SAREFPipeline.Mode;
import fr.mines_stetienne.ci.saref.managers.RepositoryManager;
import fr.mines_stetienne.ci.saref.tests.TestSuites;
public class MainFrame extends JFrame implements SAREFCredentialsProvider {
private static final boolean CAN_OPEN = Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN);
private static final Logger LOG = LoggerFactory.getLogger(MainFrame.class);
private File directory = null;
private SAREFPipeline.Mode mode = Mode.DEVELOP;
private boolean ignoreExamples = false;
private boolean ignoreTerms = false;
private boolean ignoreSite = false;
private final InfoPanel infoPanel = new InfoPanel();
private final FunctionalitiesPanel functionalitiesPanel = new FunctionalitiesPanel(this);
private final ConsolePanel consolePanel = new ConsolePanel();
public MainFrame() {
super("SAREF Pipeline");
setBounds(100, 100, 800, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
URL url = MainFrame.class.getClassLoader().getResource("etsi.png");
ImageIcon img = new ImageIcon(url);
setIconImage(img.getImage());
getContentPane().add(infoPanel, BorderLayout.NORTH);
getContentPane().add(consolePanel, BorderLayout.CENTER);
getContentPane().add(functionalitiesPanel, BorderLayout.SOUTH);
functionalitiesPanel.addFileChooserActionListener(new FileChooserActionListener(this));
functionalitiesPanel.addStartActionListener(new StartActionListener(this));
pack();
setResizable(true);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public void setDirectory(File directory) {
this.directory = directory;
}
public void setMode(SAREFPipeline.Mode mode) {
this.mode = mode;
}
public void setIgnoreSite(boolean ignoreSite) {
this.ignoreSite = ignoreSite;
}
public void setIgnoreExamples(boolean ignoreExamples) {
this.ignoreExamples = ignoreExamples;
}
public void setIgnoreTerms(boolean ignoreTerms) {
this.ignoreTerms = ignoreTerms;
}
private class FileChooserActionListener implements ActionListener {
private final MainFrame mainFrame;
private FileChooserActionListener(MainFrame mainFrame) {
this.mainFrame = mainFrame;
}
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser(directory);
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int option = fileChooser.showOpenDialog(mainFrame);
if (option == JFileChooser.APPROVE_OPTION) {
directory = fileChooser.getSelectedFile();
infoPanel.setDirectory(directory);
functionalitiesPanel.setEnabled();
}
}
}
private class StartActionListener implements ActionListener {
private final MainFrame mainFrame;
private StartActionListener(MainFrame mainFrame) {
this.mainFrame = mainFrame;
}
@Override
public void actionPerformed(ActionEvent e) {
SAREFPipeline pipeline = new SAREFPipeline(mainFrame, directory, mode, ignoreExamples, ignoreTerms,
ignoreSite);
consolePanel.clear();
TestSuites testSuites = pipeline.run();
if(pipeline.mode == Mode.CLEAN) {
consolePanel.reportInfo("Project cleaned", "");
return;
} else {
String title = String.format("The SAREF Pipeline completed with %s errors and %s warnings\n", testSuites.getErrors(), testSuites.getFailures());
File report = new File(pipeline.targetDir, "report_output.xml");
String msg = String.format("Logs and reports: %s
", report.toURI(), report.getPath()); if(!pipeline.ignoreSite) { File reportHTML = new File(pipeline.targetDir, "site/report.html"); msg += String.format("HTML report: %s
", reportHTML.toURI(), reportHTML.getPath()); if(pipeline.getSourcesManager().getTargetRepositoryManager()!=null) { RepositoryManager target = pipeline.getSourcesManager().getTargetRepositoryManager(); File siteDir = new File(pipeline.targetDir, SAREF.NAME_SITE); File ontoDir = new File(siteDir, target.getCurrentVersion().getVersionPath()); File documentationHTML = new File(ontoDir, String.format("%s.html", target.getRepository().getOntologyFileName())); msg += String.format("HTML documentation: %s
", documentationHTML.toURI(), documentationHTML.getPath()); } else { File entryPoint = new File(pipeline.targetDir, "site/extensions.html"); msg += String.format("HTML documentation entrypoint: %s
", entryPoint.toURI(), entryPoint.getPath()); } } consolePanel.reportInfo(title, msg); } } } // public void browseDialog(File file, String messageName) throws IOException { // String link = String.format("%s\n" + "
\n" + "\n"; htmlWriter.write(endTableData); } categoryChanger = data[1]; String entrytoTable2 = "Id | \n" + "Requirement | \n" + "
---|---|
" + data[0] + " | \n" + "" + data[2] + " | \n" + "
" + data[0] + " | \n" + "" + data[2] + " | \n" + "
\n" + "
\n" + "\n"; htmlWriter.write(endTableData2); } categoryChanger = data[2]; String entrytoTable2 = "Id | \n" + "Requirement | \n" + "Test | \n" + "
---|---|---|
" + data[0] + " | \n" + "" + data[1] + " | \n" + "" + data[3] + " | \n" + "
Id | \n" + "Test | \n" + "|
" + data[0] + " | \n" + "" + data[3] + " | \n" + "|
" + data[0] + " | \n" + "" + data[1] + " | \n" + "" + data[3] + " | \n" + "
\n" + "
\n" + "\n"; htmlWriter.write(endTableData); htmlWriter.write(footer); } catch (IOException e) { e.printStackTrace(); } } public static List