/*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
*/
package jalview.gui;
import jalview.jbgui.*;
import jalview.schemes.*;
import jalview.ws.*;
+import jalview.ws.jws1.Discoverer;
+import jalview.ws.jws2.Jws2Discoverer;
/**
* DOCUMENT ME!
{
boolean toggleSeqs = !evt.isControlDown();
boolean toggleCols = !evt.isShiftDown();
- toggleHiddenRegions(toggleSeqs,toggleCols);
- break;
+ toggleHiddenRegions(toggleSeqs, toggleCols);
+ break;
}
case KeyEvent.VK_PAGE_UP:
if (viewport.wrapAlignment)
/* Set up intrinsic listeners for dynamically generated GUI bits. */
private void addServiceListeners()
{
- final java.beans.PropertyChangeListener thisListener;
+ final java.beans.PropertyChangeListener thisListener, thatListener;
// Do this once to get current state
BuildWebServiceMenu();
Desktop.discoverer
// System.out.println("Discoverer property change.");
if (evt.getPropertyName().equals("services"))
{
- // System.out.println("Rebuilding web service menu");
- BuildWebServiceMenu();
+ SwingUtilities.invokeLater(new Runnable()
+ {
+
+ @Override
+ public void run()
+ {
+ System.err
+ .println("Change support JWS1: build services again.");
+ BuildWebServiceMenu();
+ }
+
+ });
}
}
});
-
+ jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+ .addPropertyChangeListener(
+ thatListener = new java.beans.PropertyChangeListener()
+ {
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ System.err
+ .println("Change support JWS2: build services again.");
+ BuildWebServiceMenu();
+ }
+ });
addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
{
public void internalFrameClosed(
{
// System.out.println("deregistering discoverer listener");
Desktop.discoverer.removePropertyChangeListener(thisListener);
+ jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+ .removePropertyChangeListener(thatListener);
closeMenuItem_actionPerformed(true);
};
});
annotationPanelMenuItem.setState(av.showAnnotation);
viewBoxesMenuItem.setSelected(av.showBoxes);
viewTextMenuItem.setSelected(av.showText);
- showUnconservedMenuItem.setSelected(av.showUnconserved);
+ showNonconservedMenuItem.setSelected(av.showUnconserved);
showGroupConsensus.setSelected(av.showGroupConsensus);
showGroupConservation.setSelected(av.showGroupConservation);
showConsensusHistogram.setSelected(av.showConsensusHistogram);
}
JPanel progressPanel;
- Long lId=new Long(id);
+ Long lId = new Long(id);
GridLayout layout = (GridLayout) statusPanel.getLayout();
if (progressBars.get(lId) != null)
{
{
if (fileName != null)
{
- // TODO: work out how to recover feature settings for correct view(s) when file is reloaded.
+ // TODO: work out how to recover feature settings for correct view(s) when
+ // file is reloaded.
if (currentFileFormat.equals("Jalview"))
{
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
protocol, currentFileFormat);
newframe.setBounds(bounds);
- if (featureSettings!=null && featureSettings.isShowing()) {
+ if (featureSettings != null && featureSettings.isShowing())
+ {
final Rectangle fspos = featureSettings.frame.getBounds();
- // TODO: need a 'show feature settings' function that takes bounds - need to refactor Desktop.addFrame
+ // TODO: need a 'show feature settings' function that takes bounds -
+ // need to refactor Desktop.addFrame
newframe.featureSettings_actionPerformed(null);
final FeatureSettings nfs = newframe.featureSettings;
- SwingUtilities.invokeLater(new Runnable() {
+ SwingUtilities.invokeLater(new Runnable()
+ {
public void run()
{
nfs.frame.setBounds(fspos);
}
});
this.featureSettings.close();
- this.featureSettings=null;
+ this.featureSettings = null;
}
this.closeMenuItem_actionPerformed(true);
}
viewport.historyList.push(command);
viewport.redoList.clear();
updateEditMenuBar();
- viewport.hasHiddenColumns = (viewport.colSel!=null && viewport.colSel.getHiddenColumns() != null && viewport.colSel.getHiddenColumns().size()>0);
+ viewport.hasHiddenColumns = (viewport.colSel != null
+ && viewport.colSel.getHiddenColumns() != null && viewport.colSel
+ .getHiddenColumns().size() > 0);
}
}
if (originalSource != null)
{
- originalSource.hasHiddenColumns = (viewport.colSel!=null && viewport.colSel.getHiddenColumns() != null && viewport.colSel.getHiddenColumns().size()>0);
+ originalSource.hasHiddenColumns = (viewport.colSel != null
+ && viewport.colSel.getHiddenColumns() != null && viewport.colSel
+ .getHiddenColumns().size() > 0);
originalSource.firePropertyChange("alignment", null,
originalSource.alignment.getSequences());
}
if (originalSource != null)
{
- originalSource.hasHiddenColumns = (viewport.colSel!=null && viewport.colSel.getHiddenColumns() != null && viewport.colSel.getHiddenColumns().size()>0);
+ originalSource.hasHiddenColumns = (viewport.colSel != null
+ && viewport.colSel.getHiddenColumns() != null && viewport.colSel
+ .getHiddenColumns().size() > 0);
originalSource.firePropertyChange("alignment", null,
originalSource.alignment.getSequences());
}
if (viewport.hasHiddenColumns)
{
hiddenColumns = new Vector();
- int hiddenOffset = viewport.getSelectionGroup().getStartRes();
+ int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport
+ .getSelectionGroup().getEndRes();
for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns()
.size(); i++)
{
int[] region = (int[]) viewport.getColumnSelection()
.getHiddenColumns().elementAt(i);
-
- hiddenColumns.addElement(new int[]
- { region[0] - hiddenOffset, region[1] - hiddenOffset });
+ if (region[0] >= hiddenOffset && region[1] <= hiddenCutoff)
+ {
+ hiddenColumns.addElement(new int[]
+ { region[0] - hiddenOffset, region[1] - hiddenOffset });
+ }
}
}
viewport.hideAllSelectedSeqs();
alignPanel.paintAlignment(true);
}
+
/**
* called by key handler and the hide all/show all menu items
+ *
* @param toggleSeqs
* @param toggleCols
*/
- private void toggleHiddenRegions(boolean toggleSeqs,
- boolean toggleCols)
+ private void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
{
boolean hide = false;
SequenceGroup sg = viewport.getSelectionGroup();
if (!toggleSeqs && !toggleCols)
{
- // Hide everything by the current selection - this is a hack - we do the invert and then hide
+ // Hide everything by the current selection - this is a hack - we do the
+ // invert and then hide
// first check that there will be visible columns after the invert.
- if ((viewport.colSel!=null && viewport.colSel.getSelected()!=null && viewport.colSel.getSelected().size()>0) || (sg!=null && sg.getSize()>0 && sg.getStartRes()<=sg.getEndRes()))
+ if ((viewport.colSel != null && viewport.colSel.getSelected() != null && viewport.colSel
+ .getSelected().size() > 0)
+ || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
+ .getEndRes()))
{
- // now invert the sequence set, if required - empty selection implies that no hiding is required.
- if (sg!=null) {
- invertSequenceMenuItem_actionPerformed(null);
- sg = viewport.getSelectionGroup();
- toggleSeqs = true;
-
- }
- viewport.expandColSelection(sg,true);
- // finally invert the column selection and get the new sequence selection.
- invertColSel_actionPerformed(null);
- toggleCols = true;
+ // now invert the sequence set, if required - empty selection implies
+ // that no hiding is required.
+ if (sg != null)
+ {
+ invertSequenceMenuItem_actionPerformed(null);
+ sg = viewport.getSelectionGroup();
+ toggleSeqs = true;
+
+ }
+ viewport.expandColSelection(sg, true);
+ // finally invert the column selection and get the new sequence
+ // selection.
+ invertColSel_actionPerformed(null);
+ toggleCols = true;
}
}
if (toggleSeqs)
{
- if (sg != null
- && sg.getSize() != viewport.alignment.getHeight())
+ if (sg != null && sg.getSize() != viewport.alignment.getHeight())
{
hideSelSequences_actionPerformed(null);
hide = true;
{
showAllColumns_actionPerformed(null);
}
- }
+ }
}
- /* (non-Javadoc)
- * @see jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.event.ActionEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.
+ * event.ActionEvent)
*/
public void hideAllButSelection_actionPerformed(ActionEvent e)
{
toggleHiddenRegions(false, false);
}
- /* (non-Javadoc)
- * @see jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event.ActionEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event
+ * .ActionEvent)
*/
public void hideAllSelection_actionPerformed(ActionEvent e)
{
SequenceGroup sg = viewport.getSelectionGroup();
- viewport.expandColSelection(sg,false);
+ viewport.expandColSelection(sg, false);
viewport.hideAllSelectedSeqs();
viewport.hideSelectedColumns();
alignPanel.paintAlignment(true);
}
- /* (non-Javadoc)
- * @see jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.ActionEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.
+ * ActionEvent)
*/
public void showAllhidden_actionPerformed(ActionEvent e)
{
{
seqs.setSequences(new SeqCigar[]
{ seqs.getSequences()[0] });
- // TODO: if seqs.getSequences().length>1 then should really have warned user!
+ // TODO: if seqs.getSequences().length>1 then should really have warned
+ // user!
}
return seqs;
return tp;
}
+ private boolean buildingMenu = false;
+
/**
* Generates menu items and listener event actions for web service clients
*
*/
public void BuildWebServiceMenu()
{
- // TODO: add support for context dependent disabling of services based on
- // alignment and current selection
- // TODO: add additional serviceHandle parameter to specify abstract handler
- // class independently of AbstractName
- // TODO: add in rediscovery GUI function to restart discoverer
- // TODO: group services by location as well as function and/or introduce
- // object broker mechanism.
- if ((Discoverer.services != null) && (Discoverer.services.size() > 0))
- {
- // TODO: refactor to allow list of AbstractName/Handler bindings to be
- // stored or retrieved from elsewhere
- Vector msaws = (Vector) Discoverer.services.get("MsaWS");
- Vector secstrpr = (Vector) Discoverer.services.get("SecStrPred");
- Vector seqsrch = (Vector) Discoverer.services.get("SeqSearch");
- // TODO: move GUI generation code onto service implementation - so a
- // client instance attaches itself to the GUI with method call like
- // jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance,
- // alignframe)
+ while (buildingMenu)
+ {
+ try
+ {
+ System.err.println("Waiting for building menu to finish.");
+ Thread.sleep(10);
+ } catch (Exception e)
+ {
+ }
+ ;
+ }
+ buildingMenu = true;
+ try
+ {
+ System.err
+ .println("Building ws menu again " + Thread.currentThread());
+ // TODO: add support for context dependent disabling of services based on
+ // alignment and current selection
+ // TODO: add additional serviceHandle parameter to specify abstract
+ // handler
+ // class independently of AbstractName
+ // TODO: add in rediscovery GUI function to restart discoverer
+ // TODO: group services by location as well as function and/or introduce
+ // object broker mechanism.
Vector wsmenu = new Vector();
final IProgressIndicator af = this;
- if (msaws != null)
+ if ((Discoverer.services != null) && (Discoverer.services.size() > 0))
{
- // Add any Multiple Sequence Alignment Services
- final JMenu msawsmenu = new JMenu("Alignment");
- for (int i = 0, j = msaws.size(); i < j; i++)
+ // TODO: refactor to allow list of AbstractName/Handler bindings to be
+ // stored or retrieved from elsewhere
+ Vector msaws = (Vector) Discoverer.services.get("MsaWS");
+ Vector secstrpr = (Vector) Discoverer.services.get("SecStrPred");
+ Vector seqsrch = (Vector) Discoverer.services.get("SeqSearch");
+ // TODO: move GUI generation code onto service implementation - so a
+ // client instance attaches itself to the GUI with method call like
+ // jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance,
+ // alignframe)
+ if (msaws != null)
{
- final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws
- .get(i);
- jalview.ws.WSClient impl = jalview.ws.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(msawsmenu, this);
+ // Add any Multiple Sequence Alignment Services
+ final JMenu msawsmenu = new JMenu("Alignment");
+ for (int i = 0, j = msaws.size(); i < j; i++)
+ {
+ final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws
+ .get(i);
+ jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
+ .getServiceClient(sh);
+ impl.attachWSMenuEntry(msawsmenu, this);
+ }
+ wsmenu.add(msawsmenu);
+ }
+ if (secstrpr != null)
+ {
+ // Add any secondary structure prediction services
+ final JMenu secstrmenu = new JMenu(
+ "Secondary Structure Prediction");
+ for (int i = 0, j = secstrpr.size(); i < j; i++)
+ {
+ final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) secstrpr
+ .get(i);
+ jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
+ .getServiceClient(sh);
+ impl.attachWSMenuEntry(secstrmenu, this);
+ }
+ wsmenu.add(secstrmenu);
+ }
+ if (seqsrch != null)
+ {
+ // Add any sequence search services
+ final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
+ for (int i = 0, j = seqsrch.size(); i < j; i++)
+ {
+ final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) seqsrch
+ .elementAt(i);
+ jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
+ .getServiceClient(sh);
+ impl.attachWSMenuEntry(seqsrchmenu, this);
+ }
+ wsmenu.add(seqsrchmenu);
}
- wsmenu.add(msawsmenu);
}
- if (secstrpr != null)
+
+ // TODO: move into separate menu builder class.
{
- // Add any secondary structure prediction services
- final JMenu secstrmenu = new JMenu("Secondary Structure Prediction");
- for (int i = 0, j = secstrpr.size(); i < j; i++)
+ Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
+ if (jws2servs != null)
{
- final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) secstrpr
- .get(i);
- jalview.ws.WSClient impl = jalview.ws.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(secstrmenu, this);
+ if (jws2servs.hasServices())
+ {
+ JMenu jws2men = new JMenu("Jalview 2 Services");
+ jws2servs.attachWSMenuEntry(jws2men, this);
+ wsmenu.add(jws2men);
+ }
+ else
+ {
+ if (!jws2servs.isRunning())
+ {
+ new Thread(jws2servs).start();
+ }
+ }
}
- wsmenu.add(secstrmenu);
}
- if (seqsrch != null)
+ resetWebServiceMenu();
+ // finally, add the whole shebang onto the webservices menu
+ if (wsmenu.size() > 0)
{
- // Add any sequence search services
- final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
- for (int i = 0, j = seqsrch.size(); i < j; i++)
+ for (int i = 0, j = wsmenu.size(); i < j; i++)
{
- final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) seqsrch
- .elementAt(i);
- jalview.ws.WSClient impl = jalview.ws.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(seqsrchmenu, this);
+ webService.add((JMenu) wsmenu.get(i));
}
- wsmenu.add(seqsrchmenu);
}
- // finally, add the whole shebang onto the webservices menu
- resetWebServiceMenu();
- for (int i = 0, j = wsmenu.size(); i < j; i++)
+ else
{
- webService.add((JMenu) wsmenu.get(i));
+ this.webService.add(this.webServiceNoServices);
}
- }
- else
+ } catch (Exception e)
{
- resetWebServiceMenu();
- this.webService.add(this.webServiceNoServices);
}
+ ;
+ buildingMenu = false;
}
/**
/**
* construct any groupURL type service menu entries.
+ *
* @param webService
*/
private void build_urlServiceMenu(JMenu webService)
{
- jalview.ws.EnfinEnvision2OneWay.getInstance().attachWSMenuEntry(webService, this);
+ jalview.ws.EnfinEnvision2OneWay.getInstance().attachWSMenuEntry(
+ webService, this);
}
/*
// update the min/max ranges where necessary
alignPanel.seqPanel.seqCanvas.fr.findAllFeatures(true);
}
- if (featureSettings!=null)
+ if (featureSettings != null)
{
featureSettings.setTableData();
}
*/
protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
{
- viewport.setShowUnconserved(showUnconservedMenuItem.getState());
+ viewport.setShowUnconserved(showNonconservedMenuItem.getState());
alignPanel.paintAlignment(true);
}
alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
}
- /* (non-Javadoc)
- * @see jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt.event.ActionEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
+ * .event.ActionEvent)
*/
protected void showConsensusHistogram_actionPerformed(ActionEvent e)
{
alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
}
- /* (non-Javadoc)
- * @see jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt.event.ActionEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
+ * .event.ActionEvent)
*/
protected void showSequenceLogo_actionPerformed(ActionEvent e)
{
viewport.setShowSequenceLogo(showSequenceLogo.getState());
alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
}
+
protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
{
alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
// set view properties for each group
for (int g = 0; g < gps.length; g++)
{
- gps[g].setShowunconserved(viewport.getShowUnconserved());
- gps[g].setIncludeAllConsSymbols(viewport.isIncludeAllConsensusSymbols());
+ gps[g].setShowNonconserved(viewport.getShowUnconserved());
+ gps[g].setIncludeAllConsSymbols(viewport
+ .isIncludeAllConsensusSymbols());
viewport.alignment.addGroup(gps[g]);
Color col = new Color((int) (Math.random() * 255), (int) (Math
.random() * 255), (int) (Math.random() * 255));