diff --git a/MGX-KeggViewer/src/main/java/de/cebitec/mgx/gui/keggviewer/Installer.java b/MGX-KeggViewer/src/main/java/de/cebitec/mgx/gui/keggviewer/Installer.java deleted file mode 100644 index c71675bee..000000000 --- a/MGX-KeggViewer/src/main/java/de/cebitec/mgx/gui/keggviewer/Installer.java +++ /dev/null @@ -1,68 +0,0 @@ -package de.cebitec.mgx.gui.keggviewer; - -import de.cebitec.mgx.gui.pool.MGXPool; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.Serial; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.netbeans.api.progress.ProgressHandle; -import org.openide.modules.ModuleInstall; -import org.openide.modules.Places; - -public class Installer extends ModuleInstall { - - @Serial - private static final long serialVersionUID = 1L; - - public static boolean keggLoaded = false; - - @Override - public void restored() { - final Runnable runnable = new Runnable() { - @Override - public void run() { - final ProgressHandle ph = ProgressHandle.createHandle("Fetching/Validating KEGG data"); - ph.start(); - String cacheDir = Places.getUserDirectory().getAbsolutePath() + File.separator + "kegg" + File.separator; - keggLoaded = copyDB(cacheDir); - ph.finish(); - } - }; - - MGXPool.getInstance().execute(runnable); - } - - private boolean copyDB(String targetDir) { - String target = targetDir + File.separator + "kegg.db"; - if (new File(target).exists()) { - new File(target).delete(); - } - - if (!new File(targetDir).exists()) { - new File(targetDir).mkdirs(); - } - - try ( InputStream is = getClass().getClassLoader().getResourceAsStream("de/cebitec/mgx/gui/keggviewer/kegg.db")) { - try ( FileOutputStream rOut = new FileOutputStream(target)) { - - byte[] buffer = new byte[4096]; - - int bytesRead = is.read(buffer); - while (bytesRead >= 0) { - rOut.write(buffer, 0, bytesRead); - bytesRead = is.read(buffer); - } - - rOut.flush(); - } - } catch (IOException ex) { - Logger.getLogger(Installer.class.getPackage().getName()).log(Level.SEVERE, null, ex); - return false; - } - Logger.getLogger(Installer.class.getPackage().getName()).log(Level.INFO, "KEGG database successfully installed."); - return true; - } -} diff --git a/MGX-KeggViewer/src/main/java/de/cebitec/mgx/gui/keggviewer/KeggViewer.java b/MGX-KeggViewer/src/main/java/de/cebitec/mgx/gui/keggviewer/KeggViewer.java index 318e7f771..96baaebbd 100644 --- a/MGX-KeggViewer/src/main/java/de/cebitec/mgx/gui/keggviewer/KeggViewer.java +++ b/MGX-KeggViewer/src/main/java/de/cebitec/mgx/gui/keggviewer/KeggViewer.java @@ -55,6 +55,7 @@ public class KeggViewer extends CategoricalViewerI implements Customizable private KeggCustomizer customizer; private List>> data; private VGroupManagerI vmgr = null; + private boolean initOk = true; // private static boolean messageShown = false; @@ -67,6 +68,7 @@ public KeggViewer() { customizer = new KeggCustomizer(); } catch (KEGGException ex) { Exceptions.printStackTrace(ex); + initOk = false; } } @@ -242,7 +244,7 @@ protected void done() { @Override public boolean canHandle(AttributeTypeI valueType) { - return Installer.keggLoaded && super.canHandle(valueType) && valueType.getName().equals("EC_number"); + return initOk && super.canHandle(valueType) && valueType.getName().equals("EC_number"); } @Override diff --git a/MGX-KeggViewer/src/main/nbm/manifest.mf b/MGX-KeggViewer/src/main/nbm/manifest.mf index 2ef8f45d3..7e962d1c3 100644 --- a/MGX-KeggViewer/src/main/nbm/manifest.mf +++ b/MGX-KeggViewer/src/main/nbm/manifest.mf @@ -1,3 +1,2 @@ Manifest-Version: 1.0 -OpenIDE-Module-Install: de/cebitec/mgx/gui/keggviewer/Installer.class OpenIDE-Module-Localizing-Bundle: de/cebitec/mgx/gui/keggviewer/Bundle.properties diff --git a/MGX-KeggViewer/src/main/resources/de/cebitec/mgx/gui/keggviewer/kegg.db b/MGX-KeggViewer/src/main/resources/de/cebitec/mgx/gui/keggviewer/kegg.db deleted file mode 100644 index 730bf12aa..000000000 Binary files a/MGX-KeggViewer/src/main/resources/de/cebitec/mgx/gui/keggviewer/kegg.db and /dev/null differ