import jalview.bin.Cache;
import jalview.gui.Help.HelpId;
import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.FileFormatI;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.jbgui.GPreferences;
import jalview.jbgui.GSequenceLink;
-import jalview.schemes.ColourSchemeProperty;
-import jalview.urls.DesktopUrlProviderFactory;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemes;
+import jalview.schemes.ResidueColourScheme;
import jalview.urls.UrlLinkTableModel;
-import jalview.urls.UrlProviderFactoryI;
-import jalview.urls.UrlProviderI;
+import jalview.urls.api.UrlProviderFactoryI;
+import jalview.urls.api.UrlProviderI;
+import jalview.urls.desktop.DesktopUrlProviderFactory;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.util.UrlConstants;
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import javax.swing.RowFilter;
public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
+ public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
+
private static final int MIN_FONT_SIZE = 1;
private static final int MAX_FONT_SIZE = 30;
public static List<String> groupURLLinks;
static
{
- String string = Cache.getDefault("SEQUENCE_LINKS",
- UrlConstants.DEFAULT_STRING);
- UrlProviderFactoryI factory = new DesktopUrlProviderFactory(
- UrlConstants.DEFAULT_LABEL, string);
+ // get links selected to be in the menu (SEQUENCE_LINKS)
+ // and links entered by the user but not selected (STORED_LINKS)
+ String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
+ String notInMenuString = Cache.getDefault("STORED_LINKS", "");
+ String defaultUrl = Cache.getDefault("DEFAULT_URL",
+ UrlConstants.DEFAULT_LABEL);
+
+ // if both links lists are empty, add the DEFAULT_URL link
+ // otherwise we assume the default link is in one of the lists
+ if (inMenuString.isEmpty() && notInMenuString.isEmpty())
+ {
+ inMenuString = UrlConstants.DEFAULT_STRING;
+ }
+ UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
+ inMenuString, notInMenuString);
sequenceUrlLinks = factory.createUrlProvider();
dataModel = new UrlLinkTableModel(sequenceUrlLinks);
openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
showUnconserved
.setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
+ showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
false));
showGroupConservation.setSelected(Cache.getDefault(
/*
* Set Colours tab defaults
*/
- for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
+ protColour.addItem(ResidueColourScheme.NONE);
+ nucColour.addItem(ResidueColourScheme.NONE);
+ for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
{
- protColour.addItem(ColourSchemeProperty.getColourName(i));
- nucColour.addItem(ColourSchemeProperty.getColourName(i));
+ String name = cs.getSchemeName();
+ protColour.addItem(name);
+ nucColour.addItem(name);
}
- String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
+ String oldProp = Cache.getDefault(DEFAULT_COLOUR,
+ ResidueColourScheme.NONE);
String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
protColour.setSelectedItem(newProp != null ? newProp : oldProp);
newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
linkUrlTable.setRowSorter(sorter);
List<RowSorter.SortKey> sortKeys = new ArrayList<>();
- sortKeys.add(new RowSorter.SortKey(3,
+ UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
+ sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
+ SortOrder.DESCENDING));
+ sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
SortOrder.DESCENDING));
- sortKeys.add(new RowSorter.SortKey(2, SortOrder.DESCENDING));
- sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
+ sortKeys.add(new RowSorter.SortKey(m.getNameColumn(),
+ SortOrder.ASCENDING));
sorter.setSortKeys(sortKeys);
sorter.sort();
public boolean include(
Entry<? extends TableModel, ? extends Object> entry)
{
- String id = entry.getStringValue(4);
- return sequenceUrlLinks.isUserEntry(id);
+ return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
}
};
filterTB.getDocument().addDocumentListener(new DocumentListener()
{
+ String caseInsensitiveFlag = "(?i)";
+
@Override
public void changedUpdate(DocumentEvent e)
{
- sorter.setRowFilter(RowFilter.regexFilter("(?i)"
+ sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
+ filterTB.getText()));
}
@Override
public void removeUpdate(DocumentEvent e)
{
- sorter.setRowFilter(RowFilter.regexFilter("(?i)"
+ sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
+ filterTB.getText()));
}
@Override
public void insertUpdate(DocumentEvent e)
{
- sorter.setRowFilter(RowFilter.regexFilter("(?i)"
+ sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
+ filterTB.getText()));
}
});
new UrlListSelectionHandler());
// set up radio buttons
- linkUrlTable.getColumn("Default").setCellRenderer(
- new RadioButtonRenderer());
- linkUrlTable.getColumn("Default")
+ int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
+ .getPrimaryColumn();
+ String onClickName = linkUrlTable.getColumnName(onClickCol);
+ linkUrlTable.getColumn(onClickName).setCellRenderer(
+ new RadioButtonRenderer());
+ linkUrlTable.getColumn(onClickName)
.setCellEditor(new RadioButtonEditor());
// get boolean columns and resize those to min possible
useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
useProxy_actionPerformed(); // make sure useProxy is correctly initialised
- proxyServerTB.setEnabled(useProxy.isSelected());
- proxyPortTB.setEnabled(useProxy.isSelected());
proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
Boolean.toString(idItalics.isSelected()));
Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
Boolean.toString(showUnconserved.isSelected()));
+ Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
+ Boolean.toString(showOccupancy.isSelected()));
Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
Boolean.toString(showGroupConsensus.isSelected()));
Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
jalview.util.BrowserLauncher.resetBrowser();
// save user-defined and selected links
- String links = linkUrlTable.getModel().toString();
- if (links.isEmpty())
+ String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
+ if (menuLinks.isEmpty())
{
Cache.applicationProperties.remove("SEQUENCE_LINKS");
}
else
{
Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
- links.toString());
+ menuLinks.toString());
+ }
+
+ String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
+ if (nonMenuLinks.isEmpty())
+ {
+ Cache.applicationProperties.remove("STORED_LINKS");
+ }
+ else
+ {
+ Cache.applicationProperties.setProperty("STORED_LINKS",
+ nonMenuLinks.toString());
}
+ Cache.applicationProperties.setProperty("DEFAULT_URL",
+ sequenceUrlLinks.getPrimaryUrlId());
+
Cache.applicationProperties.setProperty("USE_PROXY",
Boolean.toString(useProxy.isSelected()));
@Override
public void startupFileTextfield_mouseClicked()
{
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
- "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
- "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
- "PIR", "BLC", "Jalview" },
- jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
+ String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
+ JalviewFileChooser chooser = JalviewFileChooser.forRead(
+ Cache.getProperty("LAST_DIRECTORY"), fileFormat);
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.select_startup_file"));
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- jalview.bin.Cache.applicationProperties.setProperty(
- "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
+ FileFormatI format = chooser.getSelectedFormat();
+ if (format != null)
+ {
+ Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
+ format.getName());
+ }
startupFileTextfield.setText(chooser.getSelectedFile()
.getAbsolutePath());
}
conservation.setEnabled(annotations.isSelected());
quality.setEnabled(annotations.isSelected());
identity.setEnabled(annotations.isSelected());
+ showOccupancy.setEnabled(annotations.isSelected());
showGroupConsensus.setEnabled(annotations.isSelected());
showGroupConservation.setEnabled(annotations.isSelected());
showConsensHistogram.setEnabled(annotations.isSelected()
boolean valid = false;
while (!valid)
{
- if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
+ if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
MessageManager.getString("label.new_sequence_url_link"),
- JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
+ JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION)
{
if (link.checkValid())
{
- ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow(
- link.getName(), link.getURL());
- valid = true;
+ if (((UrlLinkTableModel) linkUrlTable.getModel())
+ .isUniqueName(link.getName()))
+ {
+ ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow(
+ link.getName(), link.getURL());
+ valid = true;
+ }
+ else
+ {
+ link.notifyDuplicate();
+ continue;
+ }
}
}
else
int index = linkUrlTable.getSelectedRow();
if (index == -1)
{
- // no row was selected
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.getString("label.no_link_selected"),
- MessageManager.getString("label.no_link_selected"),
- JOptionPane.WARNING_MESSAGE);
+ // button no longer enabled if row is not selected
+ Cache.log.debug("Edit with no row selected in linkUrlTable");
return;
}
- link.setName(linkUrlTable.getValueAt(index, 0).toString());
- link.setURL(linkUrlTable.getValueAt(index, 1).toString());
+ int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
+ .getNameColumn();
+ int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
+ .getUrlColumn();
+ String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
+ link.setName(oldName);
+ link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
boolean valid = false;
while (!valid)
{
- if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
- MessageManager.getString("label.new_sequence_url_link"),
- JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
+ if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
+ MessageManager.getString("label.edit_sequence_url_link"),
+ JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION)
{
if (link.checkValid())
{
- linkUrlTable.setValueAt(link.getName(), index, 0);
- linkUrlTable.setValueAt(link.getURL(), index, 1);
- valid = true;
+ if ((oldName.equals(link.getName()))
+ || (((UrlLinkTableModel) linkUrlTable.getModel())
+ .isUniqueName(link.getName())))
+ {
+ linkUrlTable.setValueAt(link.getName(), index, nameCol);
+ linkUrlTable.setValueAt(link.getURL(), index, urlCol);
+ valid = true;
+ }
+ else
+ {
+ link.notifyDuplicate();
+ continue;
+ }
}
}
else
int modelIndex = -1;
if (index == -1)
{
- // no row is selected
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.getString("label.no_link_selected"),
- MessageManager.getString("label.no_link_selected"),
- JOptionPane.WARNING_MESSAGE);
+ // button no longer enabled if row is not selected
+ Cache.log.debug("Delete with no row selected in linkUrlTable");
return;
}
else
}
} catch (NumberFormatException x)
{
- JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
.getString("warn.user_defined_width_requirements"),
MessageManager.getString("label.invalid_id_column_width"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
userIdWidth.setText("");
}
}
File f = new File(chimeraPath.getText());
if (!f.canExecute())
{
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
MessageManager.getString("label.invalid_chimera_path"),
MessageManager.getString("label.invalid_name"),
- JOptionPane.ERROR_MESSAGE);
+ JvOptionPane.ERROR_MESSAGE);
return false;
}
}
if (!found)
{
String[] options = { "OK", "Help" };
- int showHelp = JOptionPane.showInternalOptionDialog(
+ int showHelp = JvOptionPane.showInternalOptionDialog(
Desktop.desktop,
JvSwingUtils.wrapTooltip(true,
MessageManager.getString("label.chimera_missing")),
- "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
+ "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
null, options, options[0]);
- if (showHelp == JOptionPane.NO_OPTION)
+ if (showHelp == JvOptionPane.NO_OPTION)
{
try
{
}
int modelIndex = linkUrlTable.convertRowIndexToModel(index);
- // determine if the new selection is a custom url or not
- if (!sequenceUrlLinks.isUserEntry((String) linkUrlTable
-.getModel()
- .getValueAt(modelIndex, 4))) // KM TODO do this better
+ // enable/disable edit and delete link buttons
+ if (((UrlLinkTableModel) linkUrlTable.getModel())
+ .isRowDeletable(modelIndex))
{
- // entry is not a user-defined url and so should not be edited
- // disable edit and delete buttons
- deleteLink.setEnabled(false);
- editLink.setEnabled(false);
+ deleteLink.setEnabled(true);
}
else
{
- deleteLink.setEnabled(true);
- editLink.setEnabled(true);
+ deleteLink.setEnabled(false);
}
- // BUT it's the default url, don't allow deletion
- if ((boolean) linkUrlTable.getValueAt(index, 3))
+ if (((UrlLinkTableModel) linkUrlTable.getModel())
+ .isRowEditable(modelIndex))
{
- deleteLink.setEnabled(false);
+ editLink.setEnabled(true);
+ }
+ else
+ {
+ editLink.setEnabled(false);
}
}
}