Skip to content

Commit

Permalink
closes #621: error message if user doesn't have javafx and exit gui
Browse files Browse the repository at this point in the history
Conflicts:
	iped-app/resources/localization/iped-desktop-messages.properties
	iped-app/resources/localization/iped-desktop-messages_pt_BR.properties
	iped-app/src/main/java/dpf/sp/gpinf/indexer/desktop/ViewerController.java
  • Loading branch information
lfcnassif committed Jun 23, 2021
1 parent a7e22f2 commit e82d780
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 92 deletions.
7 changes: 7 additions & 0 deletions iped-app/src/main/java/dpf/sp/gpinf/indexer/desktop/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
Expand Down Expand Up @@ -121,6 +122,7 @@
import dpf.sp.gpinf.indexer.ui.hitsViewer.HitsTable;
import dpf.sp.gpinf.indexer.ui.hitsViewer.HitsTableModel;
import dpf.sp.gpinf.indexer.util.IconUtil;
import dpf.sp.gpinf.indexer.util.Util;
import iped3.IIPEDSource;
import iped3.IItem;
import iped3.IItemId;
Expand Down Expand Up @@ -375,6 +377,11 @@ private void destroy() {

public void createGUI() {

if (!Util.isJavaFXPresent()) {
JOptionPane.showMessageDialog(this, Messages.get("NoJavaFX.Error"), "Error", JOptionPane.ERROR_MESSAGE);
System.exit(1);
}

String tab = " "; //$NON-NLS-1$
this.setTitle(Versao.APP_NAME + tab + "[" + Messages.getString("App.Case") + ": " + casesPathFile + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
this.setSize(new Dimension(800, 600));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@
import dpf.sp.gpinf.indexer.ui.fileViewer.frames.LibreOfficeViewer;
import dpf.sp.gpinf.indexer.ui.fileViewer.frames.LibreOfficeViewer.NotSupported32BitPlatformExcepion;
import dpf.sp.gpinf.indexer.ui.fileViewer.frames.MetadataViewer;
import dpf.sp.gpinf.indexer.ui.fileViewer.frames.NoJavaFXViewer;
import dpf.sp.gpinf.indexer.ui.fileViewer.frames.ReferencedFileViewer;
import dpf.sp.gpinf.indexer.ui.fileViewer.frames.TextViewer;
import dpf.sp.gpinf.indexer.ui.fileViewer.frames.TiffViewer;
import dpf.sp.gpinf.indexer.ui.fileViewer.frames.TikaHtmlViewer;
import dpf.sp.gpinf.indexer.ui.fileViewer.frames.Viewer;
import dpf.sp.gpinf.indexer.ui.fileViewer.frames.ViewersRepository;
import dpf.sp.gpinf.indexer.ui.fileViewer.util.AppSearchParams;
import dpf.sp.gpinf.indexer.util.JarLoader;
import dpf.sp.gpinf.indexer.util.LibreOfficeFinder;
import iped3.io.IStreamSource;

Expand Down Expand Up @@ -84,21 +82,14 @@ public boolean isFixed() {
});
viewers.add(viewersRepository = new ViewersRepository());

boolean javaFX = new JarLoader().loadJavaFX();

// These are content-specific viewers (inside a single ViewersRepository)
viewersRepository.addViewer(new ImageViewer());
viewersRepository.addViewer(new CADViewer());
if (javaFX) {
viewersRepository.addViewer(new HtmlViewer());
viewersRepository.addViewer(new EmailViewer());
linkViewer = new HtmlLinkViewer(new AttachmentSearcherImpl());
viewersRepository.addViewer(linkViewer);
viewersRepository.addViewer(new TikaHtmlViewer());
} else {
viewersRepository.addViewer(new NoJavaFXViewer());
linkViewer = null;
}
viewersRepository.addViewer(new HtmlViewer());
viewersRepository.addViewer(new EmailViewer());
linkViewer = new HtmlLinkViewer(new AttachmentSearcherImpl());
viewersRepository.addViewer(linkViewer);
viewersRepository.addViewer(new TikaHtmlViewer());
viewersRepository.addViewer(new IcePDFViewer());
viewersRepository.addViewer(new TiffViewer());
viewersRepository.addViewer(new ReferencedFileViewer(viewersRepository, new AttachmentSearcherImpl()));
Expand All @@ -109,7 +100,6 @@ public void run() {
for (Viewer viewer : viewers) {
viewer.init();
}
tika = new Tika();

// LibreOffice viewer initialization
LibreOfficeFinder loFinder = new LibreOfficeFinder(new File(params.codePath).getParentFile());
Expand All @@ -130,6 +120,7 @@ public void run() {
viewersRepository.removeViewer(officeViewer);
} catch (Throwable e) {
// catches NoClassDefFoundError on Linux if libreoffice-java is not installed
// and if debugging UI: custom class loader is not used to load libreoffice jars
e.printStackTrace();
} finally {
synchronized (lock) {
Expand Down Expand Up @@ -340,6 +331,9 @@ private void updateViewType() {
return;
if (!file.equals(viewFile)) {
try {
if (tika == null) {
tika = new Tika();
}
viewType = tika.detect(viewFile.getFile());
return;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ MetadataPanel.Scale=Scale:
MetadataPanel.Sort=Sort:
MetadataPanel.Update=Update
MetadataPanel.UpdateWarn=[Click on Update]
NoJavaFX.Error=This application needs JavaFX to be installed!
ProcessingNotFinished.title=Processing not finished
ProcessingNotFinished.message=Processing didn't finish successfully. Many case items could be missing, including allocated.\nTry to resume it with --continue option.
ProcessingNotFinished.cases=\ Following cases are affected:\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ MetadataPanel.Scale=Escala:
MetadataPanel.Sort=Ordenação:
MetadataPanel.Update=Atualizar
MetadataPanel.UpdateWarn=[Clique em Atualizar]
NoJavaFX.Error=Esta aplicação precisa que o JavaFX esteja instalado!
ProcessingNotFinished.title=Processamento não finalizado
ProcessingNotFinished.message=Processamento não finalizou com sucesso. Muitos itens podem estar ausentes, incluindo alocados.\nTente retomá-lo com a opção --continue.
ProcessingNotFinished.cases=\ Os seguintes casos são afetados:\n
Expand Down
11 changes: 10 additions & 1 deletion iped-engine/src/main/java/dpf/sp/gpinf/indexer/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.DocumentInputStream;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.tika.io.TemporaryResources;
import org.apache.tika.io.TikaInputStream;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.mime.MediaType;
Expand Down Expand Up @@ -100,6 +99,16 @@ public static String getJavaVersionWarn() {
return null;
}

public static boolean isJavaFXPresent() {
try {
Class.forName("javafx.application.Platform");
return true;

} catch (Throwable t) {
return false;
}
}

public static String getRootName(String path) {
int fromIndex = path.charAt(0) == '/' || path.charAt(0) == '\\' ? 1 : 0;
int slashIdx = path.indexOf('/', fromIndex);
Expand Down
76 changes: 0 additions & 76 deletions iped-utils/src/main/java/dpf/sp/gpinf/indexer/util/JarLoader.java

This file was deleted.

0 comments on commit e82d780

Please sign in to comment.