From: gmungoc Date: Wed, 19 Sep 2018 14:26:17 +0000 (+0100) Subject: Merge branch 'develop' into features/JAL-3010ontologyFeatureSettings X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=19273dc7a1f9695ded523b670362e0cab31958fb Merge branch 'develop' into features/JAL-3010ontologyFeatureSettings Conflicts: src/jalview/gui/FeatureSettings.java src/jalview/gui/FeatureTypeSettings.java --- 19273dc7a1f9695ded523b670362e0cab31958fb diff --cc src/jalview/gui/FeatureSettings.java index 5f06439,1358c8f..a53d730 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@@ -98,9 -91,7 +94,8 @@@ import javax.swing.JScrollPane import javax.swing.JSlider; import javax.swing.JTable; import javax.swing.ListSelectionModel; +import javax.swing.RowFilter; import javax.swing.SwingConstants; - import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.AbstractTableModel; @@@ -170,12 -152,12 +159,6 @@@ public class FeatureSettings extends JP int selectedRow = -1; -- JButton fetchDAS = new JButton(); -- -- JButton saveDAS = new JButton(); -- -- JButton cancelDAS = new JButton(); -- boolean resettingTable = false; /* @@@ -226,73 -195,6 +209,69 @@@ ex.printStackTrace(); } + initTable(); + + scrollPane.setViewportView(table); + - dassourceBrowser = new DasSourceBrowser(this); - dasSettingsPane.add(dassourceBrowser, BorderLayout.CENTER); - + if (af.getViewport().isShowSequenceFeatures() || !fr.hasRenderOrder()) + { + fr.findAllFeatures(true); // display everything! + } + + discoverAllFeatureData(); + final PropertyChangeListener change; + final FeatureSettings fs = this; + fr.addPropertyChangeListener(change = new PropertyChangeListener() + { + @Override + public void propertyChange(PropertyChangeEvent evt) + { + if (!fs.resettingTable && !fs.handlingUpdate) + { + fs.handlingUpdate = true; + fs.resetTable(null); + // new groups may be added with new sequence feature types only + fs.handlingUpdate = false; + } + } + }); + + frame = new JInternalFrame(); + frame.setContentPane(this); + if (Platform.isAMac()) + { + Desktop.addInternalFrame(frame, + MessageManager.getString("label.sequence_feature_settings"), + 600, 480); + } + else + { + Desktop.addInternalFrame(frame, + MessageManager.getString("label.sequence_feature_settings"), + 600, 450); + } + frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT)); + + frame.addInternalFrameListener( + new javax.swing.event.InternalFrameAdapter() + { + @Override + public void internalFrameClosed( + javax.swing.event.InternalFrameEvent evt) + { + fr.removePropertyChangeListener(change); - dassourceBrowser.fs = null; + }; + }); + frame.setLayer(JLayeredPane.PALETTE_LAYER); + inConstruction = false; + } + + /** + * Constructs and configures the JTable which displays columns of data for + * each feature type + */ + protected void initTable() + { table = new JTable() { @Override @@@ -1408,41 -1297,9 +1385,9 @@@ transparency.setMaximum(70); transparency.setToolTipText( MessageManager.getString("label.transparency_tip")); - fetchDAS.setText(MessageManager.getString("label.fetch_das_features")); - fetchDAS.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - fetchDAS_actionPerformed(e); - } - }); - saveDAS.setText(MessageManager.getString("action.save_as_default")); - saveDAS.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - saveDAS_actionPerformed(e); - } - }); - - JPanel dasButtonPanel = new JPanel(); - dasButtonPanel.setBorder(BorderFactory.createEtchedBorder()); - dasSettingsPane.setBorder(null); - cancelDAS.setEnabled(false); - cancelDAS.setText(MessageManager.getString("action.cancel_fetch")); - cancelDAS.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - cancelDAS_actionPerformed(e); - } - }); - JPanel transPanel = new JPanel(new GridLayout(1, 2)); - bigPanel.add(transPanel, BorderLayout.SOUTH); + JPanel lowerPanel = new JPanel(new GridLayout(1, 2)); + bigPanel.add(lowerPanel, BorderLayout.SOUTH); JPanel transbuttons = new JPanel(new GridLayout(5, 1)); transbuttons.add(optimizeOrder); @@@ -1472,216 -1321,6 +1413,59 @@@ this.add(settingsPane); } - public void fetchDAS_actionPerformed(ActionEvent e) - { - fetchDAS.setEnabled(false); - cancelDAS.setEnabled(true); - dassourceBrowser.setGuiEnabled(false); - Vector selectedSources = dassourceBrowser - .getSelectedSources(); - doDasFeatureFetch(selectedSources, true, true); - } - - /** - * get the features from selectedSources for all or the current selection - * - * @param selectedSources - * @param checkDbRefs - * @param promptFetchDbRefs - */ - private void doDasFeatureFetch(List selectedSources, - boolean checkDbRefs, boolean promptFetchDbRefs) - { - SequenceI[] dataset, seqs; - int iSize; - AlignmentViewport vp = af.getViewport(); - if (vp.getSelectionGroup() != null - && vp.getSelectionGroup().getSize() > 0) - { - iSize = vp.getSelectionGroup().getSize(); - dataset = new SequenceI[iSize]; - seqs = vp.getSelectionGroup().getSequencesInOrder(vp.getAlignment()); - } - else - { - iSize = vp.getAlignment().getHeight(); - seqs = vp.getAlignment().getSequencesArray(); - } - - dataset = new SequenceI[iSize]; - for (int i = 0; i < iSize; i++) - { - dataset[i] = seqs[i].getDatasetSequence(); - } - - cancelDAS.setEnabled(true); - dasFeatureFetcher = new jalview.ws.DasSequenceFeatureFetcher(dataset, - this, selectedSources, checkDbRefs, promptFetchDbRefs); - af.getViewport().setShowSequenceFeatures(true); - af.showSeqFeatures.setSelected(true); - } - - /** - * blocking call to initialise the das source browser - */ - public void initDasSources() - { - dassourceBrowser.initDasSources(); - } - - /** - * examine the current list of das sources and return any matching the given - * nicknames in sources - * - * @param sources - * Vector of Strings to resolve to DAS source nicknames. - * @return sources that are present in source list. - */ - public List resolveSourceNicknames(Vector sources) - { - return dassourceBrowser.sourceRegistry.resolveSourceNicknames(sources); - } - - /** - * get currently selected das sources. ensure you have called initDasSources - * before calling this. - * - * @return vector of selected das source nicknames - */ - public Vector getSelectedSources() - { - return dassourceBrowser.getSelectedSources(); - } - - /** - * properly initialise DAS fetcher and then initiate a new thread to fetch - * features from the named sources (rather than any turned on by default) - * - * @param sources - * @param block - * if true then runs in same thread, otherwise passes to the Swing - * executor - */ - public void fetchDasFeatures(Vector sources, boolean block) - { - initDasSources(); - List resolved = dassourceBrowser.sourceRegistry - .resolveSourceNicknames(sources); - if (resolved.size() == 0) - { - resolved = dassourceBrowser.getSelectedSources(); - } - if (resolved.size() > 0) - { - final List dassources = resolved; - fetchDAS.setEnabled(false); - // cancelDAS.setEnabled(true); doDasFetch does this. - Runnable fetcher = new Runnable() - { - - @Override - public void run() - { - doDasFeatureFetch(dassources, true, false); - - } - }; - if (block) - { - fetcher.run(); - } - else - { - SwingUtilities.invokeLater(fetcher); - } - } - } - - public void saveDAS_actionPerformed(ActionEvent e) - { - dassourceBrowser - .saveProperties(jalview.bin.Cache.applicationProperties); - } - - public void complete() - { - fetchDAS.setEnabled(true); - cancelDAS.setEnabled(false); - dassourceBrowser.setGuiEnabled(true); - - } - - public void cancelDAS_actionPerformed(ActionEvent e) - { - if (dasFeatureFetcher != null) - { - dasFeatureFetcher.cancel(); - } - complete(); - } - - public void noDasSourceActive() - { - complete(); - JvOptionPane.showInternalConfirmDialog(Desktop.desktop, - MessageManager.getString("label.no_das_sources_selected_warn"), - MessageManager.getString("label.no_das_sources_selected_title"), - JvOptionPane.DEFAULT_OPTION, JvOptionPane.INFORMATION_MESSAGE); - } - + /** + * Reorders features by 'dragging' selectedRow to 'newRow' + * + * @param newRow + */ + protected void dragRow(int newRow) + { + if (summaryView.isSelected()) + { + // no drag while in summary view + return; + } + + if (newRow != selectedRow && selectedRow != -1 && newRow != -1) + { + /* + * reposition 'selectedRow' to 'newRow' (the dragged to location) + * this could be more than one row away for a very fast drag action + * so just swap it with adjacent rows until we get it there + */ + Object[][] data = ((FeatureTableModel) table.getModel()) + .getData(); + int direction = newRow < selectedRow ? -1 : 1; + for (int i = selectedRow; i != newRow; i += direction) + { + Object[] temp = data[i]; + data[i] = data[i + direction]; + data[i + direction] = temp; + } + updateFeatureRenderer(data); + table.repaint(); + selectedRow = newRow; + } + } + + protected void refreshTable() + { + Object[][] data = ((FeatureTableModel) table.getModel()).getData(); + for (Object[] row : data) + { + String type = (String) row[TYPE_COLUMN]; + FeatureColourI colour = fr.getFeatureColours().get(type); + FeatureMatcherSetI filter = fr.getFeatureFilter(type); + if (filter == null) + { + filter = new FeatureMatcherSet(); + } + row[COLOUR_COLUMN] = colour; + row[FILTER_COLUMN] = filter; + } + repaint(); + } + // /////////////////////////////////////////////////////////////////////// // http://java.sun.com/docs/books/tutorial/uiswing/components/table.html // /////////////////////////////////////////////////////////////////////// @@@ -1775,32 -1402,6 +1559,31 @@@ updateFeatureRenderer(data); } + /** + * Sets the visibility of any feature types which are sub-types of the type + * in the given row of the table + * + * @param row + * @param value + */ + protected void setSubtypesVisibility(int row, Boolean value) + { + String type = (String) data[row][TYPE_COLUMN]; + OntologyI so = SequenceOntologyFactory.getInstance(); + + for (int r = 0; r < data.length; r++) + { + if (r != row) + { + String type2 = (String) data[r][TYPE_COLUMN]; + if (so.isA(type2, type)) + { + data[r][SHOW_COLUMN] = value; + fireTableCellUpdated(r, SHOW_COLUMN); + } + } + } + } - } class ColorRenderer extends JLabel implements TableCellRenderer @@@ -2064,13 -1665,17 +1847,12 @@@ { // bring up graduated chooser. chooser = new FeatureTypeSettings(me.fr, type); - /** - * @j2sNative - */ - { - chooser.setRequestFocusEnabled(true); - chooser.requestFocus(); - } + chooser.setRequestFocusEnabled(true); + chooser.requestFocus(); chooser.addActionListener(this); - chooser.showTab(true); + // Make the renderer reappear. + fireEditingStopped(); } - // Make the renderer reappear. - fireEditingStopped(); } else { diff --cc src/jalview/gui/FeatureTypeSettings.java index c71d878,c572798..7aef644 --- a/src/jalview/gui/FeatureTypeSettings.java +++ b/src/jalview/gui/FeatureTypeSettings.java @@@ -205,27 -204,8 +210,22 @@@ public class FeatureTypeSettings extend */ private List filters; - // set white normally, black to debug layout - private Color debugBorderColour = Color.white; - private JPanel chooseFiltersPanel; - private JTabbedPane tabbedPane; - + /* + * feature types present in Feature Renderer which are + * sub-types of the one this editor is acting on + */ + private final List subTypes; + + /* + * if true, filter or colour settings are also applied to + * any feature sub-types in the Sequence Ontology + */ + private boolean applyFiltersToSubtypes; + + private boolean applyColourToSubtypes; + /** * Constructor * @@@ -776,18 -732,12 +772,21 @@@ private JPanel initialiseColoursPanel() { JPanel colourByPanel = new JPanel(); + colourByPanel.setBackground(Color.white); colourByPanel.setLayout(new BoxLayout(colourByPanel, BoxLayout.Y_AXIS)); + JvSwingUtils.createTitledBorder(colourByPanel, + MessageManager.getString("action.colour"), true); /* + * option to apply colour to sub-types as well (if there are any) + */ + if (!subTypes.isEmpty()) + { + applyColourToSubtypes = false; + colourByPanel.add(initSubtypesPanel(false)); + } + + /* * simple colour radio button and colour picker */ JPanel simpleColourPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); @@@ -1320,12 -1185,8 +1319,15 @@@ */ private JPanel initialiseAndOrPanel() { - JPanel andOrPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel andOrPanel = new JPanel(new BorderLayout()); andOrPanel.setBackground(Color.white); - JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - andOrPanel.add(panel1, BorderLayout.WEST); - panel1.setBackground(Color.white); - panel1.setBorder(BorderFactory.createLineBorder(debugBorderColour)); ++//<<<<<<< HEAD ++// JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); ++// andOrPanel.add(panel1, BorderLayout.WEST); ++// panel1.setBackground(Color.white); ++// panel1.setBorder(BorderFactory.createLineBorder(debugBorderColour)); ++//======= ++//>>>>>>> refs/heads/develop andFilters = new JRadioButton(MessageManager.getString("label.and")); orFilters = new JRadioButton(MessageManager.getString("label.or")); ActionListener actionListener = new ActionListener() @@@ -1342,11 -1203,10 +1344,11 @@@ andOr.add(andFilters); andOr.add(orFilters); andFilters.setSelected(true); - panel1.add( + andOrPanel.add( new JLabel(MessageManager.getString("label.join_conditions"))); - panel1.add(andFilters); - panel1.add(orFilters); + andOrPanel.add(andFilters); + andOrPanel.add(orFilters); + return andOrPanel; }