import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.awt.event.*;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
*
*
* @author $author$
- * @version $Revision$
+ * @version $Revision: 1.155 $
*/
public class Desktop extends jalview.jbgui.GDesktop implements
- DropTargetListener, ClipboardOwner, IProgressIndicator
+ DropTargetListener, ClipboardOwner, IProgressIndicator, jalview.api.StructureSelectionManagerProvider
{
private JalviewChangeSupport changeSupport = new JalviewChangeSupport();
Cache.log.debug("Filechooser init thread finished.");
}
}).start();
+ // Add the service change listener
+ changeSupport.addJalviewPropertyChangeListener("services",
+ new PropertyChangeListener()
+ {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ Cache.log.debug("Firing service changed event for "
+ + evt.getNewValue());
+ JalviewServicesChanged(evt);
+ }
+
+ });
}
/**
}
}
});
+ menuItem.addMouseListener(new MouseListener()
+ {
+
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e)
+ {
+ try
+ {
+ frame.setSelected(false);
+ } catch (PropertyVetoException e1)
+ {
+ }
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ try
+ {
+ frame.setSelected(true);
+ } catch (PropertyVetoException e1)
+ {
+ }
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e)
+ {
+
+ }
+ });
windowMenu.add(menuItem);
validate();
}
- public static int getViewCount(String viewId)
+ public static int getViewCount(String alignmentId)
{
- AlignViewport[] aps = getViewports(viewId);
+ AlignViewport[] aps = getViewports(alignmentId);
return (aps == null) ? 0 : aps.length;
}
/**
*
- * @param viewId
- * @return all AlignmentPanels concerning the viewId sequence set
+ * @param alignmentId
+ * @return all AlignmentPanels concerning the alignmentId sequence set
*/
- public static AlignmentPanel[] getAlignmentPanels(String viewId)
+ public static AlignmentPanel[] getAlignmentPanels(String alignmentId)
{
int count = 0;
if (Desktop.desktop == null)
AlignFrame af = (AlignFrame) frames[t];
for (int a = 0; a < af.alignPanels.size(); a++)
{
- if (viewId
+ if (alignmentId
.equals(((AlignmentPanel) af.alignPanels.elementAt(a)).av
.getSequenceSetId()))
{
avp.clear();
return afs;
}
+ public AppJmol[] getJmols()
+ {
+ JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+
+ if (frames == null)
+ {
+ return null;
+ }
+ Vector avp = new Vector();
+ try
+ {
+ // REVERSE ORDER
+ for (int i = frames.length - 1; i > -1; i--)
+ {
+ if (frames[i] instanceof AppJmol)
+ {
+ AppJmol af = (AppJmol) frames[i];
+ avp.addElement(af);
+ }
+ }
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ if (avp.size() == 0)
+ {
+ return null;
+ }
+ AppJmol afs[] = new AppJmol[avp.size()];
+ for (int i = 0, j = avp.size(); i < j; i++)
+ {
+ afs[i] = (AppJmol) avp.elementAt(i);
+ }
+ avp.clear();
+ return afs;
+ }
/**
* Add Groovy Support to Jalview
}
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
- if (jalview.ws.jws2.Jws2Discoverer.getDiscoverer().isRunning()) {
+ if (jalview.ws.jws2.Jws2Discoverer.getDiscoverer().isRunning())
+ {
jalview.ws.jws2.Jws2Discoverer.getDiscoverer().setAborted(true);
}
- t2=jalview.ws.jws2.Jws2Discoverer.getDiscoverer().startDiscoverer(changeSupport);
+ t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer().startDiscoverer(
+ changeSupport);
}
+ Thread t3=null;
+ {
+ // TODO: do rest service discovery
+ }
if (blocking)
{
while (alive)
}
alive = (t1 != null && t1.isAlive())
|| (t2 != null && t2.isAlive())
+ || (t3 != null && t3.isAlive())
|| (t0 != null && t0.isAlive());
}
}
}
/**
+ * called to check if the service discovery process completed successfully.
+ *
+ * @param evt
+ */
+ protected void JalviewServicesChanged(PropertyChangeEvent evt)
+ {
+ if (evt.getNewValue() == null || evt.getNewValue() instanceof Vector)
+ {
+ final String ermsg = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+ .getErrorMessages();
+ if (ermsg != null)
+ {
+ if (Cache.getDefault("SHOW_WSDISCOVERY_ERRORS", true))
+ {
+ if (serviceChangedDialog == null)
+ {
+ // only run if we aren't already displaying one of these.
+ javax.swing.SwingUtilities
+ .invokeLater(serviceChangedDialog = new Runnable()
+ {
+ public void run()
+ {
+
+ JOptionPane
+ .showInternalMessageDialog(
+ Desktop.desktop,
+ ermsg
+ + "It may be that you have invalid JABA URLs\nin your web service preferences.\n\nGo to the Web services tab of the\nTools->Preferences dialog box to change them.\n",
+ "Preferences Problem",
+ JOptionPane.WARNING_MESSAGE);
+ serviceChangedDialog = null;
+
+ }
+ });
+ }
+ }
+ else
+ {
+ Cache.log
+ .error("Errors reported by JABA discovery service. Check web services preferences.\n"
+ + ermsg);
+ }
+ }
+ }
+ }
+
+ private Runnable serviceChangedDialog = null;
+
+ /**
* start a thread to open a URL in the configured browser. Pops up a warning
* dialog to the user if there is an exception when calling out to the browser
* to open the URL.
*/
public static void showUrl(final String url)
{
+ showUrl(url, Desktop.instance);
+ }
+ /**
+ * Like showUrl but allows progress handler to be specified
+ * @param url
+ * @param progress (null) or object implementing IProgressIndicator
+ */
+ public static void showUrl(final String url, final IProgressIndicator progress)
+ {
new Thread(new Runnable()
{
public void run()
{
try
{
+ if (progress!=null) {
+ progress.setProgressBar("Opening "+url, this.hashCode());
+ }
jalview.util.BrowserLauncher.openURL(url);
} catch (Exception ex)
{
ex.printStackTrace();
}
+ if (progress!=null) {
+ progress.setProgressBar(null, this.hashCode());
+ }
}
}).start();
}
return wsparamManager;
}
+
}