import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.bin.Jalview;
+import jalview.gui.ImageExporter.ImageWriterI;
import jalview.io.DataSourceType;
import jalview.io.FileFormat;
import jalview.io.FileFormatException;
import jalview.jbgui.GStructureViewer;
import jalview.structure.StructureSelectionManager;
import jalview.urls.IdOrgSettings;
-import jalview.util.ImageMaker;
+import jalview.util.BrowserLauncher;
+import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.util.UrlConstants;
import java.util.Hashtable;
import java.util.List;
import java.util.ListIterator;
-import java.util.StringTokenizer;
import java.util.Vector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
-import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JProgressBar;
+import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
*/
public Desktop()
{
+ super();
/**
- * A note to implementors. It is ESSENTIAL that any activities that might
- * block are spawned off as threads rather than waited for during this
- * constructor.
+ * A note to implementors. It is ESSENTIAL that any activities that might block
+ * are spawned off as threads rather than waited for during this constructor.
*/
instance = this;
- doVamsasClientCheck();
+ if (!Jalview.isJS())
+ {
+ doVamsasClientCheck();
+ }
doConfigureStructurePrefs();
setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
boolean showjconsole = jalview.bin.Cache.getDefault("SHOW_JAVA_CONSOLE",
false);
desktop = new MyDesktopPane(selmemusage);
+
+
showMemusage.setSelected(selmemusage);
desktop.setBackground(Color.white);
getContentPane().setLayout(new BorderLayout());
// JScrollPane sp = new JScrollPane();
// sp.getViewport().setView(desktop);
// getContentPane().add(sp, BorderLayout.CENTER);
+
+ // BH 2018 - just an experiment to try unclipped JInternalFrames.
+ // Must set for all three to be active:
+ if (Jalview.isJS())
+ {
+ getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
+ ((JComponent) getContentPane()).putClientProperty("swingjs.overflow.hidden", "false");
+ desktop.putClientProperty("swingjs.overflow.hidden", "false");
+ }
+
getContentPane().add(desktop, BorderLayout.CENTER);
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
-
+
// This line prevents Windows Look&Feel resizing all new windows to maximum
// if previous window was maximised
- desktop.setDesktopManager(
- new MyDesktopManager(
- (Platform.isWindows() ? new DefaultDesktopManager()
- : Platform.isAMac()
- ? new AquaInternalFrameManager(
- desktop.getDesktopManager())
- : desktop.getDesktopManager())));
+ desktop.setDesktopManager(new MyDesktopManager(
+ (Platform.isWindows() ? new DefaultDesktopManager()
+ : Platform.isAMac()
+ ? new AquaInternalFrameManager(
+ desktop.getDesktopManager())
+ : desktop.getDesktopManager())));
Rectangle dims = getLastKnownDimensions("");
if (dims != null)
int yPos = Math.max(5, (screenSize.height - 650) / 2);
setBounds(xPos, yPos, 900, 650);
}
- /**
- * BH 2018
- *
- * @j2sNative
- */
- {
-
+
+ boolean doFullLoad = /** @j2sNative ! */true;
+
+ if (doFullLoad) {
+
jconsole = new Console(this, showjconsole);
// add essential build information
jconsole.setHeader("Jalview Version: "
});
- } // end BH 2018 ignore
+ }
this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this));
public void checkForNews()
{
-
- /**
- * BH 2018
- *
- * @j2sNative
- */
- {
final Desktop me = this;
// Thread off the news reader, in case there are connection problems.
- addDialogThread(new Runnable()
+ new Thread(new Runnable()
{
- @Override
- public void run()
- {
- Cache.log.debug("Starting news thread.");
-
- jvnews = new BlogReader(me);
- showNews.setVisible(true);
- Cache.log.debug("Completed news thread.");
- }
- });
- }
+ @Override
+ public void run()
+ {
+ Cache.log.debug("Starting news thread.");
+ jvnews = new BlogReader(me);
+ showNews.setVisible(true);
+ Cache.log.debug("Completed news thread.");
+ }
+ }).start();
}
public void getIdentifiersOrgData()
{
// Thread off the identifiers fetcher
- addDialogThread(new Runnable()
+ new Thread(new Runnable()
{
@Override
public void run()
+ e.getMessage());
}
}
- });
+ }).start();
+ ;
}
@Override
void showNews(boolean visible)
{
- /**
- * BH 2018
- *
- * @j2sNative
- *
- */
+ Cache.log.debug((visible ? "Showing" : "Hiding") + " news.");
+ showNews.setSelected(visible);
+ if (visible && !jvnews.isVisible())
{
- Cache.log.debug((visible ? "Showing" : "Hiding") + " news.");
- showNews.setSelected(visible);
- if (visible && !jvnews.isVisible())
+ new Thread(new Runnable()
{
- new Thread(new Runnable()
+ @Override
+ public void run()
{
- @Override
- public void run()
- {
- long now = System.currentTimeMillis();
- Desktop.instance.setProgressBar(
- MessageManager.getString("status.refreshing_news"),
- now);
- jvnews.refreshNews();
- Desktop.instance.setProgressBar(null, now);
- jvnews.showNews();
- }
- }).start();
- }
+ long now = System.currentTimeMillis();
+ Desktop.instance.setProgressBar(
+ MessageManager.getString("status.refreshing_news"), now);
+ jvnews.refreshNews();
+ Desktop.instance.setProgressBar(null, now);
+ jvnews.showNews();
+ }
+ }).start();
}
}
private void doVamsasClientCheck()
{
- if (/** @j2sNative false && */ // BH 2018
- jalview.bin.Cache.vamsasJarsPresent())
+ if (Cache.vamsasJarsPresent())
{
setupVamsasDisconnectedGui();
VamsasMenu.setVisible(true);
frame.setIcon(false);
} catch (java.beans.PropertyVetoException ex)
{
-
+ // System.err.println(ex.toString());
}
}
});
}
/**
- * Add key bindings to a JInternalFrame so that Ctrl-W and Cmd-W will close
- * the window
+ * Add key bindings to a JInternalFrame so that Ctrl-W and Cmd-W will close the
+ * window
*
* @param frame
*/
MessageManager.getString("label.open_local_file"));
chooser.setToolTipText(MessageManager.getString("action.open"));
- chooser.setCallback(new Runnable()
+ chooser.setResponseHandler(0, new Runnable()
{
-
@Override
public void run()
{
DataSourceType.FILE, format);
}
});
-
- int value = chooser.showOpenDialog(this);
- if (value == JFileChooser.APPROVE_OPTION)
- {
- chooser.getCallback().run();
- }
-
+ chooser.showOpenDialog(this);
}
/**
- * DOCUMENT ME!
+ * Shows a dialog for input of a URL at which to retrieve alignment data
*
- * @param e
- * DOCUMENT ME!
+ * @param viewport
*/
@Override
public void inputURLMenuItem_actionPerformed(AlignViewport viewport)
JLabel label = new JLabel(
MessageManager.getString("label.input_file_url"));
- JComboBox history = new JComboBox();
JPanel panel = new JPanel(new GridLayout(2, 1));
panel.add(label);
- panel.add(history);
- history.setPreferredSize(new Dimension(400, 20));
- history.setEditable(true);
- history.addItem("http://www.");
-
- String historyItems = jalview.bin.Cache.getProperty("RECENT_URL");
-
- StringTokenizer st;
-
- if (historyItems != null)
+
+ /*
+ * the URL to fetch is
+ * Java: an editable combobox with history
+ * JS: (pending JAL-3038) a plain text field
+ */
+ JComponent history;
+ String urlBase = "http://www.";
+ if (Jalview.isJS())
{
- st = new StringTokenizer(historyItems, "\t");
-
- while (st.hasMoreTokens())
+ history = new JTextField(urlBase, 35);
+ }
+ else
+ {
+ JComboBox<String> asCombo = new JComboBox<>();
+ asCombo.setPreferredSize(new Dimension(400, 20));
+ asCombo.setEditable(true);
+ asCombo.addItem(urlBase);
+ String historyItems = Cache.getProperty("RECENT_URL");
+ if (historyItems != null)
{
- history.addItem(st.nextElement());
+ for (String token : historyItems.split("\\t"))
+ {
+ asCombo.addItem(token);
+ }
}
+ history = asCombo;
}
+ panel.add(history);
+
+ Object[] options = new Object[] { MessageManager.getString("action.ok"),
+ MessageManager.getString("action.cancel") };
+ Runnable action = new Runnable() {
+ @Override
+ public void run()
+ {
+ String url = Jalview.isJS() ? ((JTextField) history).getText()
+ : ((JComboBox<String>) history).getSelectedItem()
+ .toString();
- // BH 2018 -- providing a callback for SwingJS
- // dialogOption is just a simple way to provide
- // context for the modal-like response.
- // The only requirement is that desktop implement
- // PropertyChangeListener, which is used already in Java
- // for changes in input value and such within the dialogs.
+ if (url.toLowerCase().endsWith(".jar"))
+ {
+ if (viewport != null)
+ {
+ new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
+ FileFormat.Jalview);
+ }
+ else
+ {
+ new FileLoader().LoadFile(url, DataSourceType.URL,
+ FileFormat.Jalview);
+ }
+ }
+ else
+ {
+ FileFormatI format = null;
+ try
+ {
+ format = new IdentifyFile().identify(url, DataSourceType.URL);
+ } catch (FileFormatException e)
+ {
+ // TODO revise error handling, distinguish between
+ // URL not found and response not valid
+ }
- String dialogOption = "label.input_alignment_from_url";
- desktop.dialogData = new Object[] { dialogOption, viewport, history };
- desktop.onDialogReturn(
- JvOptionPane.showInternalConfirmDialog(desktop, panel,
- MessageManager.getString(dialogOption),
- JvOptionPane.OK_CANCEL_OPTION));
+ if (format == null)
+ {
+ String msg = MessageManager.formatMessage("label.couldnt_locate", url);
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop, msg,
+ MessageManager.getString("label.url_not_found"),
+ JvOptionPane.WARNING_MESSAGE);
- // no code may follow this, as SwingJS will not block
- // callback in JavaScript comes via a property change event,
- // thus going into desktop.onDialogReturn(int) just the same as
- // in Java.
+ return;
+ }
+ if (viewport != null)
+ {
+ new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
+ format);
+ }
+ else
+ {
+ new FileLoader().LoadFile(url, DataSourceType.URL, format);
+ }
+ }
+ }};
+ String dialogOption = MessageManager
+ .getString("label.input_alignment_from_url");
+ JvOptionPane.newOptionDialog(desktop).setResponseHandler(0, action)
+ .showInternalDialog(panel, dialogOption,
+ JvOptionPane.YES_NO_CANCEL_OPTION,
+ JvOptionPane.PLAIN_MESSAGE, null, options,
+ MessageManager.getString("action.ok"));
}
-
/**
* Opens the CutAndPaste window for the user to paste an alignment in to
*
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Action on requesting Help documentation
*/
@Override
- public void documentationMenuItem_actionPerformed(ActionEvent e)
+ public void documentationMenuItem_actionPerformed()
{
try
{
- Help.showHelpWindow();
+ if (Jalview.isJS())
+ {
+ BrowserLauncher.openURL("http://www.jalview.org/help.html");
+ }
+ else
+ {
+ Help.showHelpWindow();
+ }
} catch (Exception ex)
{
+ System.err.println("Error opening help: " + ex.getMessage());
}
}
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Prompts the user to choose a file and then saves the Jalview state as a
+ * Jalview project file
*/
@Override
- public void saveState_actionPerformed(ActionEvent e)
+ public void saveState_actionPerformed(boolean asCastor)
{
- // TODO: JAL-3048 not needed for Jalview-JS
-
- JalviewFileChooser chooser = new JalviewFileChooser("jvp",
+ JalviewFileChooser chooser = new JalviewFileChooser(
+ asCastor ? "jvp" : "jvx",
"Jalview Project");
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager.getString("label.save_state"));
-
- int value = chooser.showSaveDialog(this);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
+ int option = chooser.showSaveDialog(this);
+ if (option == JalviewFileChooser.APPROVE_OPTION)
{
- final Desktop me = this;
- final java.io.File choice = chooser.getSelectedFile();
+ File choice = chooser.getSelectedFile();
setProjectFile(choice);
new Thread(new Runnable()
// TODO prevent user from messing with the Desktop whilst we're saving
try
{
- new Jalview2XML().saveState(choice);
+ if (asCastor)
+ {
+ new Jalview2XML().saveState(choice);
+ }
+ else
+ {
+ new jalview.project.Jalview2XML().saveState(choice);
+ }
} catch (OutOfMemoryError oom)
{
new OOMWarning(
Cache.log.error(
"Problems whilst trying to save to " + choice.getName(),
ex);
- JvOptionPane.showMessageDialog(me,
+ JvOptionPane.showMessageDialog(Desktop.this,
MessageManager.formatMessage(
"label.error_whilst_saving_current_state_to",
new Object[]
setProgressBar(null, choice.hashCode());
}
}).start();
- }
+ }
}
- private void setProjectFile(File choice)
+ void setProjectFile(File choice)
{
this.projectFile = choice;
}
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Prompts the user to choose a file and loads in as a Jalview project file
*/
@Override
- public void loadState_actionPerformed(ActionEvent e)
- {
- // TODO: JAL-3048 not needed for Jalview-JS
-
+ public void loadState_actionPerformed(boolean asCastor)
+ {
+ // TODO: GET RID OF .JVX BEFORE RELEASE JIM!
+ final String[] suffix = asCastor ? new String[] { "jvp", "jar" }
+ : new String[]
+ { "jvx" };
+ final String[] desc = asCastor
+ ? new String[]
+ { "Jalview Project", "Jalview Project (old)" }
+ : new String[]
+ { "Jalview Project" };
JalviewFileChooser chooser = new JalviewFileChooser(
- Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "jvp", "jar" },
- new String[]
- { "Jalview Project", "Jalview Project (old)" },
+ Cache.getProperty("LAST_DIRECTORY"), suffix,
+ desc,
"Jalview Project");
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager.getString("label.restore_state"));
-
- int value = chooser.showOpenDialog(this);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
+ chooser.setResponseHandler(0, new Runnable()
{
- final File selectedFile = chooser.getSelectedFile();
- setProjectFile(selectedFile);
- final String choice = selectedFile.getAbsolutePath();
- Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent());
- new Thread(new Runnable()
+ @Override
+ public void run()
{
- @Override
- public void run()
+ File selectedFile = chooser.getSelectedFile();
+ setProjectFile(selectedFile);
+ final String choice = selectedFile.getAbsolutePath();
+ Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent());
+ new Thread(new Runnable()
{
- setProgressBar(MessageManager.formatMessage(
- "label.loading_jalview_project", new Object[]
- { choice }), choice.hashCode());
- try
- {
- new Jalview2XML().loadJalviewAlign(choice);
- } catch (OutOfMemoryError oom)
+ @Override
+ public void run()
{
+ try {
+ if (asCastor)
+ {
+ new Jalview2XML().loadJalviewAlign(choice);
+ }
+ else
+ {
+ new jalview.project.Jalview2XML().loadJalviewAlign(choice);
+ }
+ } catch (OutOfMemoryError oom)
+ {
new OOMWarning("Whilst loading project from " + choice, oom);
- } catch (Exception ex)
- {
+ } catch (Exception ex)
+ {
Cache.log.error(
"Problems whilst loading project from " + choice, ex);
JvOptionPane.showMessageDialog(Desktop.desktop,
{ choice }),
MessageManager.getString("label.couldnt_load_project"),
JvOptionPane.WARNING_MESSAGE);
+ }
}
- setProgressBar(null, choice.hashCode());
- }
- }).start();
- }
+ }).start();
+ }
+ });
+
+ chooser.showOpenDialog(this);
}
@Override
/**
* Gather expanded views (separate AlignFrame's) with the same sequence set
- * identifier back in to this frame as additional views, and close the
- * expanded views. Note the expanded frames may themselves have multiple
- * views. We take the lot.
+ * identifier back in to this frame as additional views, and close the expanded
+ * views. Note the expanded frames may themselves have multiple views. We take
+ * the lot.
*
* @param source
*/
@Override
public void run()
{
- if (/** @j2sNative false && */ // BH 2018
- Cache.getDefault("CHECKURLLINKS", true))
+ if (Cache.getDefault("CHECKURLLINKS", true))
{
// check what the actual links are - if it's just the default don't
// bother with the warning
/**
* Proxy class for JDesktopPane which optionally displays the current memory
- * usage and highlights the desktop area with a red bar if free memory runs
- * low.
+ * usage and highlights the desktop area with a red bar if free memory runs low.
*
* @author AMW
*/
public class MyDesktopPane extends JDesktopPane
- implements Runnable, PropertyChangeListener
+ implements Runnable
{
-
- public Object[] dialogData;
-
- // @Override
- @Override
- public void propertyChange(PropertyChangeEvent event)
- {
- Object val = event.getNewValue();
- String name = event.getPropertyName();
- System.out.println(name);
- switch (event.getSource().getClass().getName())
- {
- case "javax.swing.JOptionPane":
- switch (name)
- {
- case "inputValue":
- onDialogReturn(val);
- return;
- case "value":
- if (val instanceof Integer)
- {
- onDialogReturn(((Integer) val).intValue());
- }
- else
- {
- onDialogReturn(val);
- }
- return;
- }
- break;
- case "javax.swing.ColorChooserDialog":
- switch (name)
- {
- case "SelectedColor":
- onDialogReturn(val);
- return;
- }
- break;
- case "javax.swing.JFileChooser":
- switch (name)
- {
- case "SelectedFile":
- // in JavaScript, this File object will have a _bytes property,
- // because the file data has already been loaded
- onDialogReturn(new Object[] { (File) val });
- return;
- }
- break;
- }
- System.out.println(event.getSource().getClass().getName() + " "
- + event.getPropertyName() + ": " + event.getNewValue());
- }
-
- // JSCOmponent.DialogCaller interface
- void onDialogReturn(Object value)
- {
- switch ((String) dialogData[0])
- {
- case "SelectedFile":
- case "runnable":
- dialogData[0] = value;
- ((Runnable) dialogData[1]).run();
- break;
- case "label.select_feature_colour":
- ((FeatureRenderer) dialogData[1]).processColorDialog((Color) value);
- break;
- }
- }
-
- // JSCOmponent.DialogCaller interface
- void onDialogReturn(int value)
- {
- if (value != Math.floor(value))
- {
- // in JavaScript, this will be NaN, oddly enough
- return;
- }
-
- switch ((String) dialogData[0])
- {
- case "runnable":
- dialogData[0] = Integer.valueOf(value);
- ((Runnable) dialogData[1]).run();
- break;
- case "label.input_alignment_from_url":
- // reconstruct the parameter data
- int reply = value;
- AlignViewport viewport = (AlignViewport) dialogData[1];
- JComboBox history = (JComboBox) dialogData[2];
- // the rest of this is unchangaed
- if (reply != JvOptionPane.OK_OPTION)
- {
- return;
- }
-
- String url = history.getSelectedItem().toString();
-
- if (url.toLowerCase().endsWith(".jar"))
- {
- if (viewport != null)
- {
- new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
- FileFormat.Jalview);
- }
- else
- {
- new FileLoader().LoadFile(url, DataSourceType.URL,
- FileFormat.Jalview);
- }
- }
- else
- {
- FileFormatI format = null;
- try
- {
- format = new IdentifyFile().identify(url, DataSourceType.URL);
- } catch (FileFormatException e)
- {
- // TODO revise error handling, distinguish between
- // URL not found and response not valid
- }
-
- if (format == null)
- {
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.formatMessage("label.couldnt_locate",
- new Object[]
- { url }),
- MessageManager.getString("label.url_not_found"),
- JvOptionPane.WARNING_MESSAGE);
-
- return;
- }
-
- if (viewport != null)
- {
- new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
- format);
- }
- else
- {
- new FileLoader().LoadFile(url, DataSourceType.URL, format);
- }
- }
-
- break;
- }
-
- }
-
private static final float ONE_MB = 1048576f;
boolean showMemoryUsage = false;
}
}
-
/**
* Accessor method to quickly get all the AlignmentFrames loaded.
*
}
/**
- * Bind Ctrl/Cmd-Q to Quit - for reset as Groovy Console takes over this
- * binding when opened
+ * Bind Ctrl/Cmd-Q to Quit - for reset as Groovy Console takes over this binding
+ * when opened
*/
protected void addQuitHandler()
{
}
/**
- * This will return the first AlignFrame holding the given viewport instance.
- * It will break if there are more than one AlignFrames viewing a particular
- * av.
+ * This will return the first AlignFrame holding the given viewport instance. It
+ * will break if there are more than one AlignFrames viewing a particular av.
*
* @param viewport
* @return alignFrame for viewport
block.release();
}
+ /**
+ * Outputs an image of the desktop to file in EPS format, after prompting the
+ * user for choice of Text or Lineart character rendering (unless a preference
+ * has been set). The file name is generated as
+ *
+ * <pre>
+ * Jalview_snapshot_nnnnn.eps where nnnnn is the current timestamp in milliseconds
+ * </pre>
+ */
@Override
protected void snapShotWindow_actionPerformed(ActionEvent e)
{
+ // currently the menu option to do this is not shown
invalidate();
- File of;
- ImageMaker im = new jalview.util.ImageMaker(
- this, ImageMaker.TYPE.EPS, "View of Desktop", getWidth(),
- getHeight(), of = new File("Jalview_snapshot"
- + System.currentTimeMillis() + ".eps"),
- "View of desktop", null, 0, false);
- try
- {
- paintAll(im.getGraphics());
- im.writeImage();
- } catch (Exception q)
+
+ int width = getWidth();
+ int height = getHeight();
+ File of = new File(
+ "Jalview_snapshot_" + System.currentTimeMillis() + ".eps");
+ ImageWriterI writer = new ImageWriterI()
{
- Cache.log.error("Couldn't write snapshot to " + of.getAbsolutePath(),
- q);
- return;
- }
- Cache.log.info("Successfully written snapshot to file "
- + of.getAbsolutePath());
+ @Override
+ public void exportImage(Graphics g) throws Exception
+ {
+ paintAll(g);
+ Cache.log.info("Successfully written snapshot to file "
+ + of.getAbsolutePath());
+ }
+ };
+ String title = "View of desktop";
+ ImageExporter exporter = new ImageExporter(writer, null, TYPE.EPS,
+ title);
+ exporter.doExport(of, this, width, height, title);
}
/**
* Explode the views in the given SplitFrame into separate SplitFrame windows.
- * This respects (remembers) any previous 'exploded geometry' i.e. the size
- * and location last time the view was expanded (if any). However it does not
+ * This respects (remembers) any previous 'exploded geometry' i.e. the size and
+ * location last time the view was expanded (if any). However it does not
* remember the split pane divider location - this is set to match the
* 'exploding' frame.
*
List<DataSourceType> protocols, DropTargetDropEvent evt,
Transferable t) throws Exception
{
-
+
// BH 2018 changed List<String> to List<Object> to allow for File from SwingJS
-// DataFlavor[] flavors = t.getTransferDataFlavors();
-// for (int i = 0; i < flavors.length; i++) {
-// if (flavors[i].isFlavorJavaFileListType()) {
-// evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
-// List<File> list = (List<File>) t.getTransferData(flavors[i]);
-// for (int j = 0; j < list.size(); j++) {
-// File file = (File) list.get(j);
-// byte[] data = getDroppedFileBytes(file);
-// fileName.setText(file.getName() + " - " + data.length + " " + evt.getLocation());
-// JTextArea target = (JTextArea) ((DropTarget) evt.getSource()).getComponent();
-// target.setText(new String(data));
-// }
-// dtde.dropComplete(true);
-// return;
-// }
-//
+ // DataFlavor[] flavors = t.getTransferDataFlavors();
+ // for (int i = 0; i < flavors.length; i++) {
+ // if (flavors[i].isFlavorJavaFileListType()) {
+ // evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
+ // List<File> list = (List<File>) t.getTransferData(flavors[i]);
+ // for (int j = 0; j < list.size(); j++) {
+ // File file = (File) list.get(j);
+ // byte[] data = getDroppedFileBytes(file);
+ // fileName.setText(file.getName() + " - " + data.length + " " +
+ // evt.getLocation());
+ // JTextArea target = (JTextArea) ((DropTarget) evt.getSource()).getComponent();
+ // target.setText(new String(data));
+ // }
+ // dtde.dropComplete(true);
+ // return;
+ // }
+ //
DataFlavor uriListFlavor = new DataFlavor(
"text/uri-list;class=java.lang.String"), urlFlavour = null;
try
{
- java.net.URL url = (URL) t.getTransferData(urlFlavour);
+ java.net.URL url = (URL) t.getTransferData(urlFlavour);
// nb: java 8 osx bug https://bugs.openjdk.java.net/browse/JDK-8156099
// means url may be null.
- if (url != null)
- {
- protocols.add(DataSourceType.URL);
- files.add(url.toString());
- Cache.log.debug("Drop handled as URL dataflavor "
- + files.get(files.size() - 1));
+ if (url != null)
+ {
+ protocols.add(DataSourceType.URL);
+ files.add(url.toString());
+ Cache.log.debug("Drop handled as URL dataflavor "
+ + files.get(files.size() - 1));
return;
}
else
"Please ignore plist error - occurs due to problem with java 8 on OSX");
}
;
- }
+ }
} catch (Throwable ex)
{
Cache.log.debug("URL drop handler failed.", ex);
&& (source.endsWith(".lnk") || source.endsWith(".url")
|| source.endsWith(".site")))
{
- try {
+ try
+ {
Object obj = files.get(f);
- File lf = (obj instanceof File ? (File) obj : new File((String) obj));
+ File lf = (obj instanceof File ? (File) obj
+ : new File((String) obj));
// process link file to get a URL
Cache.log.debug("Found potential link file: " + lf);
WindowsShortcut wscfile = new WindowsShortcut(lf);
files.set(f, fullname);
Cache.log.debug("Parsed real filename " + fullname
+ " to extract protocol: " + protocols.get(f));
- }
- catch (Exception ex)
+ } catch (Exception ex)
{
- Cache.log.error("Couldn't parse "+files.get(f)+" as a link file.",ex);
+ Cache.log.error(
+ "Couldn't parse " + files.get(f) + " as a link file.",
+ ex);
}
}
}
}
/**
- * Answers a (possibly empty) list of any structure viewer frames (currently
- * for either Jmol or Chimera) which are currently open. This may optionally
- * be restricted to viewers of a specified class, or viewers linked to a
- * specified alignment panel.
+ * Answers a (possibly empty) list of any structure viewer frames (currently for
+ * either Jmol or Chimera) which are currently open. This may optionally be
+ * restricted to viewers of a specified class, or viewers linked to a specified
+ * alignment panel.
*
* @param apanel
* if not null, only return viewers linked to this panel