Search in sources :

Example 1 with CloseableParent

use of com.kyj.fx.voeditor.visual.main.layout.CloseableParent in project Gargoyle by callakrsos.

the class JavaCodeAreaHelper method doPmd.

/**
	 * PMD 처리
	 * @작성자 : KYJ
	 * @작성일 : 2016. 10. 12.
	 */
private void doPmd() {
    PMDCheckedListComposite pmdCheckedListComposite = new PMDCheckedListComposite(null) {

        @Override
        public void run() {
            simpleFilePmd(null);
        }

        @Override
        protected void simpleFilePmd(File file) {
            try {
                GargoylePMDParameters params = new GargoylePMDParameters();
                String sourceCode = codeArea.getText();
                params.setSourceFileName("Java");
                params.setSourceText(sourceCode);
                //						if (!FileUtil.isJavaFile(file)) {
                //							String fileExtension = FileUtil.getFileExtension(file);
                //							try {
                //								Field declaredField = PMDParameters.class.getDeclaredField("language");
                //								if (declaredField != null) {
                //									declaredField.setAccessible(true);
                //									declaredField.set(params, fileExtension);
                //								}
                //							} catch (Exception e) {
                //								e.printStackTrace();
                //							}
                //						}
                //			transformParametersIntoConfiguration(params);
                long start = System.nanoTime();
                doPMD.doPMD(transformParametersIntoConfiguration(params), reportListenerPropertyProperty().get(), violationCountingListenerProperty().get());
                long end = System.nanoTime();
                Benchmarker.mark(Benchmark.TotalPMD, end - start, 0);
                TextReport report = new TextReport();
                try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
                    report.generate(Benchmarker.values(), new PrintStream(out));
                    out.flush();
                    LOGGER.debug(out.toString("UTF-8"));
                }
                updateStatus(sourceCode);
            } catch (IOException e) {
                LOGGER.error(ValueUtil.toString(e));
            }
        }
    };
    pmdCheckedListComposite.run();
    CloseableParent<BorderPane> closa = pmdCheckedListComposite;
    Consumer<Stage> option = stage -> {
        stage.setTitle("PMD Check.");
        stage.initOwner(SharedMemory.getPrimaryStage());
        stage.setWidth(1200d);
        stage.setHeight(800d);
    };
    FxUtil.createStageAndShow(closa, option);
}
Also used : EventHandler(javafx.event.EventHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LoggerFactory(org.slf4j.LoggerFactory) PMDCheckedListComposite(com.kyj.fx.voeditor.visual.component.pmd.PMDCheckedListComposite) Benchmark(net.sourceforge.pmd.benchmark.Benchmark) PrintStream(java.io.PrintStream) Logger(org.slf4j.Logger) MenuItem(javafx.scene.control.MenuItem) CloseableParent(com.kyj.fx.voeditor.visual.main.layout.CloseableParent) GargoylePMDParameters(com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDParameters) IOException(java.io.IOException) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) CodeArea(org.fxmisc.richtext.CodeArea) File(java.io.File) TextReport(net.sourceforge.pmd.benchmark.TextReport) Menu(javafx.scene.control.Menu) Consumer(java.util.function.Consumer) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) Benchmarker(net.sourceforge.pmd.benchmark.Benchmarker) BorderPane(javafx.scene.layout.BorderPane) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) PrintStream(java.io.PrintStream) BorderPane(javafx.scene.layout.BorderPane) PMDCheckedListComposite(com.kyj.fx.voeditor.visual.component.pmd.PMDCheckedListComposite) TextReport(net.sourceforge.pmd.benchmark.TextReport) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Stage(javafx.stage.Stage) GargoylePMDParameters(com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDParameters) File(java.io.File)

Aggregations

PMDCheckedListComposite (com.kyj.fx.voeditor.visual.component.pmd.PMDCheckedListComposite)1 GargoylePMDParameters (com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDParameters)1 CloseableParent (com.kyj.fx.voeditor.visual.main.layout.CloseableParent)1 SharedMemory (com.kyj.fx.voeditor.visual.momory.SharedMemory)1 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)1 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 ActionEvent (javafx.event.ActionEvent)1 EventHandler (javafx.event.EventHandler)1 Menu (javafx.scene.control.Menu)1 MenuItem (javafx.scene.control.MenuItem)1 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)1 BorderPane (javafx.scene.layout.BorderPane)1 Stage (javafx.stage.Stage)1 Benchmark (net.sourceforge.pmd.benchmark.Benchmark)1