git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-3253-applet JAL-3424 headless fix for Windows
[jalview.git]
/
src
/
jalview
/
gui
/
Desktop.java
diff --git
a/src/jalview/gui/Desktop.java
b/src/jalview/gui/Desktop.java
index
826a869
..
ace7529
100644
(file)
--- a/
src/jalview/gui/Desktop.java
+++ b/
src/jalview/gui/Desktop.java
@@
-22,8
+22,10
@@
package jalview.gui;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
+import jalview.api.StructureSelectionManagerProvider;
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
import jalview.bin.Cache;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.gui.ImageExporter.ImageWriterI;
import jalview.io.BackupFiles;
import jalview.bin.Jalview;
import jalview.gui.ImageExporter.ImageWriterI;
import jalview.io.BackupFiles;
@@
-37,6
+39,7
@@
import jalview.io.FormatAdapter;
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
+import jalview.jbgui.GDesktop;
import jalview.jbgui.GSplitFrame;
import jalview.jbgui.GStructureViewer;
import jalview.project.Jalview2XML;
import jalview.jbgui.GSplitFrame;
import jalview.jbgui.GStructureViewer;
import jalview.project.Jalview2XML;
@@
-135,9
+138,9
@@
import org.stackoverflowusers.file.WindowsShortcut;
* @version $Revision: 1.155 $
*/
@SuppressWarnings("serial")
* @version $Revision: 1.155 $
*/
@SuppressWarnings("serial")
-public class Desktop extends jalview.jbgui.GDesktop
+public class Desktop extends GDesktop
implements DropTargetListener, ClipboardOwner, IProgressIndicator,
implements DropTargetListener, ClipboardOwner, IProgressIndicator,
- jalview.api.StructureSelectionManagerProvider
+ StructureSelectionManagerProvider, ApplicationSingletonI
{
private final static int DEFAULT_MIN_WIDTH = 300;
{
private final static int DEFAULT_MIN_WIDTH = 300;
@@
-196,13
+199,14
@@
public class Desktop extends jalview.jbgui.GDesktop
public static MyDesktopPane getDesktopPane()
{
public static MyDesktopPane getDesktopPane()
{
- return Desktop.getInstance().desktopPane;
+ Desktop desktop = Desktop.getInstance();
+ return desktop == null ? null : desktop.desktopPane;
}
public static StructureSelectionManager getStructureSelectionManager()
{
return StructureSelectionManager
}
public static StructureSelectionManager getStructureSelectionManager()
{
return StructureSelectionManager
- .getStructureSelectionManager(Desktop.getInstance());
+ .getStructureSelectionManager(getInstance());
}
static int openFrameCount = 0;
}
static int openFrameCount = 0;
@@
-219,7
+223,9
@@
public class Desktop extends jalview.jbgui.GDesktop
private static int fileLoadingCount = 0;
private static int fileLoadingCount = 0;
- public JInternalFrame conservationSlider, PIDSlider;
+ public JInternalFrame conservationSlider;
+
+ public JInternalFrame PIDSlider;
/**
* just an instance (for testng, probably); no actual frames
/**
* just an instance (for testng, probably); no actual frames
@@
-351,11
+357,18
@@
public class Desktop extends jalview.jbgui.GDesktop
public MyDesktopPane desktopPane;
public MyDesktopPane desktopPane;
+ /**
+ * Answers an 'application scope' singleton instance of this class. Separate
+ * SwingJS 'applets' running in the same browser page will each have a
+ * distinct instance of Desktop.
+ *
+ * @return
+ */
public static Desktop getInstance()
{
public static Desktop getInstance()
{
- Instance i = Instance.getInstance();
- return (i.desktop == null ? (i.desktop = new Desktop(true))
- : i.desktop);
+ return Jalview.isHeadlessMode() ? null
+ : (Desktop) ApplicationSingletonProvider
+ .getInstance(Desktop.class);
}
/**
}
/**
@@
-365,25
+378,31
@@
public class Desktop extends jalview.jbgui.GDesktop
*/
public Desktop(boolean forInstance)
{
*/
public Desktop(boolean forInstance)
{
+
+ Cache.initLogger();
instanceOnly = true;
}
instanceOnly = true;
}
+
/**
/**
- * Creates a new Desktop object.
+ * Private constructor enforces singleton pattern. It is called by reflection
+ * from ApplicationSingletonProvider.getInstance().
*/
*/
- public Desktop()
+ @SuppressWarnings("unused")
+ private Desktop()
{
{
+ Cache.initLogger();
+ try
+ {
/**
* 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.getInstance().desktop = this;
-
if (!Platform.isJS())
{
doVamsasClientCheck();
}
if (!Platform.isJS())
{
doVamsasClientCheck();
}
-
+
doConfigureStructurePrefs();
setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
doConfigureStructurePrefs();
setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@@
-392,7
+411,7
@@
public class Desktop extends jalview.jbgui.GDesktop
boolean showjconsole = jalview.bin.Cache.getDefault("SHOW_JAVA_CONSOLE",
false);
desktopPane = new MyDesktopPane(selmemusage);
boolean showjconsole = jalview.bin.Cache.getDefault("SHOW_JAVA_CONSOLE",
false);
desktopPane = new MyDesktopPane(selmemusage);
-
+
showMemusage.setSelected(selmemusage);
desktopPane.setBackground(Color.white);
getContentPane().setLayout(new BorderLayout());
showMemusage.setSelected(selmemusage);
desktopPane.setBackground(Color.white);
getContentPane().setLayout(new BorderLayout());
@@
-400,16
+419,16
@@
public class Desktop extends jalview.jbgui.GDesktop
// JScrollPane sp = new JScrollPane();
// sp.getViewport().setView(desktop);
// getContentPane().add(sp, BorderLayout.CENTER);
// JScrollPane sp = new JScrollPane();
// sp.getViewport().setView(desktop);
// getContentPane().add(sp, BorderLayout.CENTER);
-
+
// BH 2018 - just an experiment to try unclipped JInternalFrames.
if (Platform.isJS())
{
getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
}
// BH 2018 - just an experiment to try unclipped JInternalFrames.
if (Platform.isJS())
{
getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
}
-
+
getContentPane().add(desktopPane, BorderLayout.CENTER);
desktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
getContentPane().add(desktopPane, BorderLayout.CENTER);
desktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
-
+
// This line prevents Windows Look&Feel resizing all new windows to maximum
// if previous window was maximised
desktopPane.setDesktopManager(new MyDesktopManager(
// This line prevents Windows Look&Feel resizing all new windows to maximum
// if previous window was maximised
desktopPane.setDesktopManager(new MyDesktopManager(
@@
-418,7
+437,7
@@
public class Desktop extends jalview.jbgui.GDesktop
? new AquaInternalFrameManager(
desktopPane.getDesktopManager())
: desktopPane.getDesktopManager())));
? new AquaInternalFrameManager(
desktopPane.getDesktopManager())
: desktopPane.getDesktopManager())));
-
+
Rectangle dims = getLastKnownDimensions("");
if (dims != null)
{
Rectangle dims = getLastKnownDimensions("");
if (dims != null)
{
@@
-431,7
+450,7
@@
public class Desktop extends jalview.jbgui.GDesktop
int yPos = Math.max(5, (screenSize.height - 650) / 2);
setBounds(xPos, yPos, 900, 650);
}
int yPos = Math.max(5, (screenSize.height - 650) / 2);
setBounds(xPos, yPos, 900, 650);
}
-
+
if (!Platform.isJS())
/**
* Java only
if (!Platform.isJS())
/**
* Java only
@@
-439,7
+458,7
@@
public class Desktop extends jalview.jbgui.GDesktop
* @j2sIgnore
*/
{
* @j2sIgnore
*/
{
-
+
jconsole = new Console(this, showjconsole);
// add essential build information
jconsole.setHeader("Jalview Version: "
jconsole = new Console(this, showjconsole);
// add essential build information
jconsole.setHeader("Jalview Version: "
@@
-452,19
+471,19
@@
public class Desktop extends jalview.jbgui.GDesktop
+ System.getProperty("os.arch") + " "
+ System.getProperty("os.name") + " "
+ System.getProperty("os.version"));
+ System.getProperty("os.arch") + " "
+ System.getProperty("os.name") + " "
+ System.getProperty("os.version"));
-
+
showConsole(showjconsole);
showConsole(showjconsole);
-
+
showNews.setVisible(false);
showNews.setVisible(false);
-
+
experimentalFeatures.setSelected(showExperimental());
experimentalFeatures.setSelected(showExperimental());
-
+
getIdentifiersOrgData();
getIdentifiersOrgData();
-
+
checkURLLinks();
checkURLLinks();
-
+
// Spawn a thread that shows the splashscreen
// Spawn a thread that shows the splashscreen
-
+
SwingUtilities.invokeLater(new Runnable()
{
@Override
SwingUtilities.invokeLater(new Runnable()
{
@Override
@@
-473,7
+492,7
@@
public class Desktop extends jalview.jbgui.GDesktop
new SplashScreen();
}
});
new SplashScreen();
}
});
-
+
// Thread off a new instance of the file chooser - this reduces the time
// it
// takes to open it later on.
// Thread off a new instance of the file chooser - this reduces the time
// it
// takes to open it later on.
@@
-493,7
+512,7
@@
public class Desktop extends jalview.jbgui.GDesktop
changeSupport.addJalviewPropertyChangeListener("services",
new PropertyChangeListener()
{
changeSupport.addJalviewPropertyChangeListener("services",
new PropertyChangeListener()
{
-
+
@Override
public void propertyChange(PropertyChangeEvent evt)
{
@Override
public void propertyChange(PropertyChangeEvent evt)
{
@@
-501,13
+520,13
@@
public class Desktop extends jalview.jbgui.GDesktop
+ evt.getNewValue());
JalviewServicesChanged(evt);
}
+ evt.getNewValue());
JalviewServicesChanged(evt);
}
-
+
});
});
-
+
}
}
-
+
this.setDropTarget(new java.awt.dnd.DropTarget(desktopPane, this));
this.setDropTarget(new java.awt.dnd.DropTarget(desktopPane, this));
-
+
this.addWindowListener(new WindowAdapter()
{
@Override
this.addWindowListener(new WindowAdapter()
{
@Override
@@
-516,7
+535,7
@@
public class Desktop extends jalview.jbgui.GDesktop
quit();
}
});
quit();
}
});
-
+
MouseAdapter ma;
this.addMouseListener(ma = new MouseAdapter()
{
MouseAdapter ma;
this.addMouseListener(ma = new MouseAdapter()
{
@@
-528,7
+547,7
@@
public class Desktop extends jalview.jbgui.GDesktop
showPasteMenu(evt.getX(), evt.getY());
}
}
showPasteMenu(evt.getX(), evt.getY());
}
}
-
+
@Override
public void mouseReleased(MouseEvent evt)
{
@Override
public void mouseReleased(MouseEvent evt)
{
@@
-539,7
+558,10
@@
public class Desktop extends jalview.jbgui.GDesktop
}
});
desktopPane.addMouseListener(ma);
}
});
desktopPane.addMouseListener(ma);
-
+ } catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
}
/**
}
/**
@@
-558,7
+580,8
@@
public class Desktop extends jalview.jbgui.GDesktop
public void doConfigureStructurePrefs()
{
// configure services
public void doConfigureStructurePrefs()
{
// configure services
- StructureSelectionManager ssm = getStructureSelectionManager();
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(this);
if (jalview.bin.Cache.getDefault(Preferences.ADD_SS_ANN, true))
{
ssm.setAddTempFacAnnot(jalview.bin.Cache
if (jalview.bin.Cache.getDefault(Preferences.ADD_SS_ANN, true))
{
ssm.setAddTempFacAnnot(jalview.bin.Cache
@@
-614,7
+637,7
@@
public class Desktop extends jalview.jbgui.GDesktop
}
}
}).start();
}
}
}).start();
- ;
+
}
@Override
}
@Override
@@
-776,7
+799,7
@@
public class Desktop extends jalview.jbgui.GDesktop
FileFormatI format = new IdentifyFile().identify(file,
DataSourceType.PASTE);
FileFormatI format = new IdentifyFile().identify(file,
DataSourceType.PASTE);
- new FileLoader().LoadFile(file, DataSourceType.PASTE, format);
+ new FileLoader().loadFile(file, DataSourceType.PASTE, format);
}
} catch (Exception ex)
}
} catch (Exception ex)
@@
-871,13
+894,14
@@
public class Desktop extends jalview.jbgui.GDesktop
int w, int h, boolean resizable, boolean ignoreMinSize)
{
int w, int h, boolean resizable, boolean ignoreMinSize)
{
+
// TODO: allow callers to determine X and Y position of frame (eg. via
// bounds object).
// TODO: consider fixing method to update entries in the window submenu with
// the current window title
frame.setTitle(title);
// TODO: allow callers to determine X and Y position of frame (eg. via
// bounds object).
// TODO: consider fixing method to update entries in the window submenu with
// the current window title
frame.setTitle(title);
- if (frame.getWidth() < 1 || frame.getHeight() < 1)
+ if (w > 0 && (frame.getWidth() < 1 || frame.getHeight() < 1))
{
frame.setSize(w, h);
}
{
frame.setSize(w, h);
}
@@
-885,7
+909,7
@@
public class Desktop extends jalview.jbgui.GDesktop
// A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN
// IF JALVIEW IS RUNNING HEADLESS
// ///////////////////////////////////////////////
// A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN
// IF JALVIEW IS RUNNING HEADLESS
// ///////////////////////////////////////////////
- if (Desktop.getInstance().instanceOnly || Jalview.isHeadlessMode())
+ if (Jalview.isHeadlessMode() || Desktop.getInstance().instanceOnly)
{
return;
}
{
return;
}
@@
-964,7
+988,7
@@
public class Desktop extends jalview.jbgui.GDesktop
menuItem.removeActionListener(menuItem.getActionListeners()[0]);
}
Desktop.getInstance().windowMenu.remove(menuItem);
menuItem.removeActionListener(menuItem.getActionListeners()[0]);
}
Desktop.getInstance().windowMenu.remove(menuItem);
- };
+ }
});
menuItem.addActionListener(new ActionListener()
});
menuItem.addActionListener(new ActionListener()
@@
-1123,7
+1147,7
@@
public class Desktop extends jalview.jbgui.GDesktop
{
Platform.cacheFileData((File) file);
}
{
Platform.cacheFileData((File) file);
}
- new FileLoader().LoadFile(null, file, protocol, format);
+ new FileLoader().loadFile(null, file, protocol, format);
}
} catch (Exception ex)
}
} catch (Exception ex)
@@
-1180,7
+1204,7
@@
public class Desktop extends jalview.jbgui.GDesktop
}
}
}
}
- new FileLoader().LoadFile(viewport, selectedFile,
+ new FileLoader().loadFile(viewport, selectedFile,
DataSourceType.FILE, format);
}
});
DataSourceType.FILE, format);
}
});
@@
-1254,12
+1278,12
@@
public class Desktop extends jalview.jbgui.GDesktop
{
if (viewport != null)
{
{
if (viewport != null)
{
- new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
+ new FileLoader().loadFile(viewport, url, DataSourceType.URL,
FileFormat.Jalview);
}
else
{
FileFormat.Jalview);
}
else
{
- new FileLoader().LoadFile(url, DataSourceType.URL,
+ new FileLoader().loadFile(url, DataSourceType.URL,
FileFormat.Jalview);
}
}
FileFormat.Jalview);
}
}
@@
-1289,12
+1313,12
@@
public class Desktop extends jalview.jbgui.GDesktop
if (viewport != null)
{
if (viewport != null)
{
- new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
+ new FileLoader().loadFile(viewport, url, DataSourceType.URL,
format);
}
else
{
format);
}
else
{
- new FileLoader().LoadFile(url, DataSourceType.URL, format);
+ new FileLoader().loadFile(url, DataSourceType.URL, format);
}
}
}
}
}
}
@@
-2366,7
+2390,7
@@
public class Desktop extends jalview.jbgui.GDesktop
});
rthr.start();
}
});
rthr.start();
}
- };
+ }
});
VamsasStMenu.add(sessit);
}
});
VamsasStMenu.add(sessit);
}
@@
-3266,7
+3290,6
@@
public class Desktop extends jalview.jbgui.GDesktop
} catch (InterruptedException x)
{
}
} catch (InterruptedException x)
{
}
- ;
}
if (instanceOnly)
{
}
if (instanceOnly)
{
@@
-3477,7
+3500,8
@@
public class Desktop extends jalview.jbgui.GDesktop
public static groovy.ui.Console getGroovyConsole()
{
public static groovy.ui.Console getGroovyConsole()
{
- return Desktop.getInstance().groovyConsole;
+ Desktop desktop = Desktop.getInstance();
+ return desktop == null ? null : desktop.groovyConsole;
}
/**
}
/**
@@
-3555,7
+3579,6
@@
public class Desktop extends jalview.jbgui.GDesktop
System.err.println(
"Please ignore plist error - occurs due to problem with java 8 on OSX");
}
System.err.println(
"Please ignore plist error - occurs due to problem with java 8 on OSX");
}
- ;
}
} catch (Throwable ex)
{
}
} catch (Throwable ex)
{