summaryrefslogtreecommitdiff
path: root/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer
diff options
context:
space:
mode:
Diffstat (limited to 'mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer')
-rw-r--r--mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProvider.java40
-rw-r--r--mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProviderException.java29
-rw-r--r--mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeFilter.java65
-rw-r--r--mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeTypes.java53
-rw-r--r--mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/SecureViewerSaveDialog.java121
5 files changed, 0 insertions, 308 deletions
diff --git a/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProvider.java b/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProvider.java
deleted file mode 100644
index 8fb815b0..00000000
--- a/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProvider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2008 Federal Chancellery Austria and
- * Graz University of Technology
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package at.gv.egiz.bku.gui.viewer;
-
-import java.awt.Font;
-
-/**
- *
- * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
- */
-public interface FontProvider {
-
- /** will be replaced by more sophisticated font selection mechanism
- * (see java.awt.Font int/String constants) */
- String SANSMONO_FONT_RESOURCE = "DejaVuLGCSansMono.ttf";
-
- /**
- *
- * @return
- * @throws InterruptedException
- * @throws FileNotFoundException if remote font file cannot be retrieved
- */
- Font getFont() throws FontProviderException;
-
-}
diff --git a/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProviderException.java b/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProviderException.java
deleted file mode 100644
index 5a6a277e..00000000
--- a/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProviderException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2008 Federal Chancellery Austria and
- * Graz University of Technology
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package at.gv.egiz.bku.gui.viewer;
-
-/**
- * Encapsulates the reason why a font could not be loaded.
- * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
- */
-public class FontProviderException extends Exception {
-
- public FontProviderException(String msg, Throwable cause) {
- super(msg, cause);
- }
-}
diff --git a/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeFilter.java b/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeFilter.java
deleted file mode 100644
index 5d64eb4f..00000000
--- a/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeFilter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-* Copyright 2008 Federal Chancellery Austria and
-* Graz University of Technology
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package at.gv.egiz.bku.gui.viewer;
-
-import java.io.File;
-import java.util.ResourceBundle;
-import javax.swing.filechooser.FileFilter;
-
-/**
- *
- * @author clemens
- */
-class MimeFilter extends FileFilter {
-
- protected String mimeType;
- protected ResourceBundle messages;
-
- public MimeFilter(String mimeType, ResourceBundle messages) {
- this.mimeType = mimeType;
- this.messages = messages;
- }
-
- @Override
- public boolean accept(File f) {
-
- if (f.isDirectory()) {
- return true;
- }
- return MimeTypes.getExtension(mimeType).equalsIgnoreCase(getExtension(f));
- }
-
- private String getExtension(File f) {
- String ext = null;
- String s = f.getName();
- int i = s.lastIndexOf('.');
-
- if (i > 0 && i < s.length() - 1) {
- ext = s.substring(i + 1).toLowerCase();
- }
- return ext;
- }
-
- @Override
- public String getDescription() {
- return messages.getString(MimeTypes.getDescriptionKey(mimeType));
- }
-
- public static String getExtension(String mimeType) {
- return MimeTypes.getExtension(mimeType);
- }
-} \ No newline at end of file
diff --git a/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeTypes.java b/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeTypes.java
deleted file mode 100644
index 4500fa71..00000000
--- a/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/MimeTypes.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package at.gv.egiz.bku.gui.viewer;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * @author clemens
- */
-public class MimeTypes {
-
- private static final Map<String , String> FILE_EXTENSIONS = new HashMap<String, String>() {{
- put("application/msword", ".doc");
- put("application/octet-stream", ".bin");
- put("application/pdf", ".pdf");
- put("application/xhtml+xml", ".xhtml");
- put("text/html", ".html");
- put("text/plain", ".txt");
- put("text/xml", ".xml");
- }};
-
- private static final Map<String , String> DESCRIPTIONS = new HashMap<String, String>() {{
- put("application/msword", "mimetype.desc.doc");
- put("application/octet-stream", "mimetype.desc.bin");
- put("application/pdf", "mimetype.desc.pdf");
- put("application/xhtml+xml", "mimetype.desc.xhtml");
- put("text/html", "mimetype.desc.html");
- put("text/plain", "mimetype.desc.txt");
- put("text/xml", "mimetype.desc.xml");
- }};
-
- public static String getExtension(String mimetype) {
- if (FILE_EXTENSIONS.containsKey(mimetype)) {
- return FILE_EXTENSIONS.get(mimetype);
- }
- return "";
- }
-
- /**
- * @return bundle key to be resolved in message resource bundle
- */
- public static String getDescriptionKey(String mimetype) {
- if (DESCRIPTIONS.containsKey(mimetype)) {
- return DESCRIPTIONS.get(mimetype);
- }
- return "mimetype.desc.unknown";
- }
-}
diff --git a/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/SecureViewerSaveDialog.java b/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/SecureViewerSaveDialog.java
deleted file mode 100644
index 3303d4ef..00000000
--- a/mocca-1.2.11/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/SecureViewerSaveDialog.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package at.gv.egiz.bku.gui.viewer;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.gui.BKUGUIFacade;
-import at.gv.egiz.stal.HashDataInput;
-
-public class SecureViewerSaveDialog {
-
- protected static final Log log = LogFactory.getLog(SecureViewerSaveDialog.class);
-
- public static void showSaveDialog(final HashDataInput hashDataInput, final ResourceBundle messages,
- final ActionListener okListener, final String okCommand) {
-
- log.debug("[" + Thread.currentThread().getName()
- + "] scheduling save dialog");
-
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
-
- log
- .debug("[" + Thread.currentThread().getName()
- + "] show save dialog");
-
- String userHome = System.getProperty("user.home");
-
- JFileChooser fileDialog = new JFileChooser(userHome);
- fileDialog.setMultiSelectionEnabled(false);
- fileDialog.setDialogType(JFileChooser.SAVE_DIALOG);
- fileDialog.setFileHidingEnabled(true);
- fileDialog.setDialogTitle(messages
- .getString(BKUGUIFacade.WINDOWTITLE_SAVE));
- fileDialog.setFileSelectionMode(JFileChooser.FILES_ONLY);
- String mimeType = hashDataInput.getMimeType();
- MimeFilter mimeFilter = new MimeFilter(mimeType, messages);
- fileDialog.setFileFilter(mimeFilter);
- String filename = (hashDataInput.getFilename() != null) ?
- hashDataInput.getFilename() :
- messages.getString(BKUGUIFacade.SAVE_HASHDATAINPUT_PREFIX)
- + MimeFilter.getExtension(mimeType);
- fileDialog.setSelectedFile(new File(userHome, filename));
-
- // parent contentPane -> placed over applet
- switch (fileDialog.showSaveDialog(fileDialog)) {
- case JFileChooser.APPROVE_OPTION:
- File file = fileDialog.getSelectedFile();
- String id = hashDataInput.getReferenceId();
- if (file.exists()) {
- String msgPattern = messages
- .getString(BKUGUIFacade.MESSAGE_OVERWRITE);
- int overwrite = JOptionPane.showConfirmDialog(fileDialog,
- MessageFormat.format(msgPattern, file), messages
- .getString(BKUGUIFacade.WINDOWTITLE_OVERWRITE),
- JOptionPane.OK_CANCEL_OPTION);
- if (overwrite != JOptionPane.OK_OPTION) {
- break;
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("writing hashdata input " + id + " (" + mimeType
- + ") to file " + file);
- }
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(file);
- BufferedOutputStream bos = new BufferedOutputStream(fos);
- InputStream hdi = hashDataInput.getHashDataInput();
- int b;
- while ((b = hdi.read()) != -1) {
- bos.write(b);
- }
- bos.flush();
- bos.close();
- } catch (IOException ex) {
- log.error("Failed to write " + file + ": " + ex.getMessage());
- log.debug(ex);
- String errPattern = messages
- .getString(BKUGUIFacade.ERR_WRITE_HASHDATA);
- JOptionPane.showMessageDialog(fileDialog, MessageFormat.format(
- errPattern, ex.getMessage()), messages
- .getString(BKUGUIFacade.WINDOWTITLE_ERROR),
- JOptionPane.ERROR_MESSAGE);
- } finally {
- try {
- if (fos != null) {
- fos.close();
- }
- } catch (IOException ex) {
- }
- }
- break;
- case JFileChooser.CANCEL_OPTION:
- log.debug("cancelled save dialog");
- break;
- }
- if (okListener != null) {
- okListener.actionPerformed(new ActionEvent(fileDialog,
- ActionEvent.ACTION_PERFORMED, okCommand));
- }
- }
- });
- }
-}