import java.util.Set;
import javax.help.HelpSetException;
+import javax.swing.AbstractButton;
import javax.swing.AbstractCellEditor;
import javax.swing.BorderFactory;
import javax.swing.Icon;
*/
Map<String, float[]> typeWidth = null;
+ private void storeOriginalSettings()
+ {
+ // save transparency for restore on Cancel
+ originalTransparency = fr.getTransparency();
+ int originalTransparencyAsPercent = (int) (originalTransparency * 100);
+ transparency.setMaximum(100 - originalTransparencyAsPercent);
+
+ originalFilters = new HashMap<>(fr.getFeatureFilters()); // shallow copy
+ originalViewStyle = new ViewStyle(af.viewport.getViewStyle());
+ }
/**
* Constructor
*
{
this.af = alignFrame;
fr = af.getFeatureRenderer();
-
- // save transparency for restore on Cancel
- originalTransparency = fr.getTransparency();
- int originalTransparencyAsPercent = (int) (originalTransparency * 100);
- transparency.setMaximum(100 - originalTransparencyAsPercent);
-
- originalFilters = new HashMap<>(fr.getFeatureFilters()); // shallow copy
- originalViewStyle = new ViewStyle(af.viewport.getViewStyle());
-
+ storeOriginalSettings();
try
{
jbInit();
PropertyChangeListener change;
+ private JCheckBox showComplementOnTop;
+
+ private AbstractButton showComplement;
+
+ private void updateComplementButtons()
+ {
+ showComplement.setSelected(af.getViewport().isShowComplementFeatures());
+ showComplementOnTop
+ .setSelected(af.getViewport().isShowComplementFeaturesOnTop());
+ }
+
@Override
public AlignViewControllerGuiI getAlignframe()
{
{
this.setLayout(new BorderLayout());
+ final boolean hasComplement = af.getViewport()
+ .getCodingComplement() != null;
+
JPanel settingsPane = new JPanel();
settingsPane.setLayout(new BorderLayout());
}
}
});
-
- JButton cancel = new JButton(MessageManager.getString("action.cancel"));
+ // Cancel for a SplitFrame should just revert changes to the currently displayed
+ // settings. May want to do this for either or both - so need a splitview
+ // feature settings cancel/OK.
+ JButton cancel = new JButton(MessageManager
+ .getString(hasComplement ? "action.revert" : "action.cancel"));
+ cancel.setToolTipText(MessageManager.getString(hasComplement
+ ? "action.undo_changes_to_feature_settings"
+ : "action.undo_changes_to_feature_settings_and_close_the_dialog"));
cancel.setFont(JvSwingUtils.getLabelFont());
+ // TODO: disable cancel until current settings are different
cancel.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- fr.setTransparency(originalTransparency);
- fr.setFeatureFilters(originalFilters);
- updateFeatureRenderer(originalData);
- af.getViewport().setViewStyle(originalViewStyle);
- close();
+ revert();
+ if (!hasComplement)
+ {
+ close();
+ }
}
});
-
- JButton ok = new JButton(MessageManager.getString("action.ok"));
+ // Cancel for the whole dialog should cancel both CDS and Protein.
+ // OK for an individual feature settings just applies changes, but dialog
+ // remains open
+ JButton ok = new JButton(MessageManager
+ .getString(hasComplement ? "action.apply" : "action.ok"));
ok.setFont(JvSwingUtils.getLabelFont());
ok.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- close();
+ if (!hasComplement)
+ {
+ close();
+ }
+ else
+ {
+ storeOriginalSettings();
+ }
}
});
? MessageManager.getString("label.protein")
.toLowerCase()
: "CDS");
- JCheckBox showComplement = new JCheckBox(text);
- showComplement.setSelected(af.getViewport().isShowComplementFeatures());
+ showComplement = new JCheckBox(text);
showComplement.addActionListener(new ActionListener()
{
@Override
}
});
- JCheckBox showComplementOnTop = new JCheckBox(
+ showComplementOnTop = new JCheckBox(
MessageManager.getString("label.on_top"));
- showComplementOnTop
- .setSelected(af.getViewport().isShowComplementFeaturesOnTop());
showComplementOnTop.addActionListener(new ActionListener()
{
@Override
transbuttons.add(sortByDens);
transbuttons.add(help);
- boolean hasComplement = af.getViewport().getCodingComplement() != null;
JPanel transPanelLeft = new JPanel(
new GridLayout(hasComplement ? 4 : 2, 1));
transPanelLeft.add(new JLabel(" Colour transparency" + ":"));
}
return frame != null && !frame.isClosed();
}
+
+ @Override
+ public void revert()
+ {
+ fr.setTransparency(originalTransparency);
+ fr.setFeatureFilters(originalFilters);
+ updateFeatureRenderer(originalData);
+ af.getViewport().setViewStyle(originalViewStyle);
+ updateComplementButtons();
+ refreshDisplay();
+ }
}
class FeatureIcon implements Icon
import jalview.util.Platform;
import jalview.viewmodel.AlignmentViewport;
+import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.InputMap;
+import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
featureSettingsUI = new JInternalFrame(MessageManager.getString(
"label.sequence_feature_settings_for_CDS_and_Protein"));
featureSettingsPanels.setOpaque(true);
- featureSettingsUI.setContentPane(featureSettingsPanels);
+
+ JPanel dialog = new JPanel();
+ dialog.setOpaque(true);
+ dialog.setLayout(new BorderLayout());
+ dialog.add(featureSettingsPanels, BorderLayout.CENTER);
+ JPanel buttons = new JPanel();
+ JButton ok = new JButton(MessageManager.getString("action.ok"));
+ ok.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ featureSettingsUI.setClosed(true);
+ } catch (PropertyVetoException pv)
+ {
+ pv.printStackTrace();
+ }
+ }
+ });
+ JButton cancel = new JButton(
+ MessageManager.getString("action.cancel"));
+ cancel.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ for (Component fspanel : featureSettingsPanels.getComponents())
+ {
+ if (fspanel instanceof FeatureSettingsControllerGuiI)
+ {
+ ((FeatureSettingsControllerGuiI) fspanel).revert();
+ }
+ }
+ featureSettingsUI.setClosed(true);
+ } catch (Exception pv)
+ {
+ pv.printStackTrace();
+ }
+ }
+ });
+ buttons.add(ok);
+ buttons.add(cancel);
+ dialog.add(buttons, BorderLayout.SOUTH);
+ featureSettingsUI.setContentPane(dialog);
createDummyTabs();
}
if (featureSettingsPanels