From: <dal...@us...> - 2008-05-07 05:49:57
|
Revision: 12587 http://jedit.svn.sourceforge.net/jedit/?rev=12587&view=rev Author: daleanson Date: 2008-05-06 22:49:56 -0700 (Tue, 06 May 2008) Log Message: ----------- Fix so layout works properly when switching between buffers. Required a fix in jEdit TextArea as occasionally the blame pane would actually appear right of the right scroll bar rather than left of the scroll bar. Modified Paths: -------------- plugins/SVNPlugin/trunk/src/ise/plugin/svn/gui/component/BasicBlamePaneUI.java plugins/SVNPlugin/trunk/src/ise/plugin/svn/gui/component/BlamePane.java Modified: plugins/SVNPlugin/trunk/src/ise/plugin/svn/gui/component/BasicBlamePaneUI.java =================================================================== --- plugins/SVNPlugin/trunk/src/ise/plugin/svn/gui/component/BasicBlamePaneUI.java 2008-05-07 05:41:07 UTC (rev 12586) +++ plugins/SVNPlugin/trunk/src/ise/plugin/svn/gui/component/BasicBlamePaneUI.java 2008-05-07 05:49:56 UTC (rev 12587) @@ -49,7 +49,7 @@ uninstallComponents(); uninstallDefaults(); - blamePane = null; + //blamePane = null; } public void installDefaults() {} @@ -67,7 +67,7 @@ public void uninstallComponents() { blamePane.remove( blameRendererPane ); - blamePane = null; + //blamePane = null; } public void uninstallListeners() { Modified: plugins/SVNPlugin/trunk/src/ise/plugin/svn/gui/component/BlamePane.java =================================================================== --- plugins/SVNPlugin/trunk/src/ise/plugin/svn/gui/component/BlamePane.java 2008-05-07 05:41:07 UTC (rev 12586) +++ plugins/SVNPlugin/trunk/src/ise/plugin/svn/gui/component/BlamePane.java 2008-05-07 05:49:56 UTC (rev 12587) @@ -1,20 +1,20 @@ /* - * Copyright (c) 2008, Dale Anson - * - * 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 any later version. - * - * 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. - * - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ +* Copyright (c) 2008, Dale Anson +* +* 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 any later version. +* +* 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. +* +* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ package ise.plugin.svn.gui.component; @@ -30,10 +30,16 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import org.gjt.sp.jedit.EditBus; +import org.gjt.sp.jedit.EBComponent; +import org.gjt.sp.jedit.EBMessage; +import org.gjt.sp.jedit.GUIUtilities; import org.gjt.sp.jedit.View; import org.gjt.sp.jedit.textarea.JEditTextArea; +import org.gjt.sp.jedit.msg.EditPaneUpdate; +import org.gjt.sp.jedit.buffer.JEditBuffer; -public class BlamePane extends JComponent implements CaretListener { +public class BlamePane extends JComponent implements CaretListener, EBComponent { private static final String uiClassID = "BlamePaneUI"; private Set<ChangeListener> changeListeners = new HashSet<ChangeListener>(); @@ -41,12 +47,9 @@ public BlamePane() { updateUI(); + EditBus.addToBus( this ); } - public void setUI( BlamePaneUI ui ) { - super.setUI( ui ); - } - public void updateUI() { if ( UIManager.get( getUIClassID() ) != null ) { setUI( ( BlamePaneUI ) UIManager.getUI( this ) ); @@ -105,17 +108,18 @@ return model; } - public JPanel getCloser(final View view) { - final JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - JButton button = new JButton("Close Blame"); - panel.add(button); + public JPanel getCloser( final View view ) { + final JPanel panel = new JPanel( new FlowLayout( FlowLayout.RIGHT, 16, 0 ) ); + JButton button = new JButton( "Close blame", GUIUtilities.loadIcon( "10x10/actions/close.png" ) ); + button.setBorder( null ); + panel.add( button ); button.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ae ) { - getUI().uninstallUI(BlamePane.this); - view.getEditPane().getTextArea().removeTopComponent(panel); - view.getEditPane().getTextArea().removeLeftOfScrollBar(BlamePane.this); - model.getTextArea().removeCaretListener(BlamePane.this); + getUI().uninstallUI( BlamePane.this ); + view.getEditPane().getTextArea().removeTopComponent( panel ); + view.getEditPane().getTextArea().removeLeftOfScrollBar( BlamePane.this ); + model.getTextArea().removeCaretListener( BlamePane.this ); view.invalidate(); view.validate(); } @@ -123,4 +127,40 @@ ); return panel; } -} + + public void handleMessage( EBMessage msg ) { + if ( msg instanceof EditPaneUpdate ) { + EditPaneUpdate epu = ( EditPaneUpdate ) msg; + if ( EditPaneUpdate.BUFFER_CHANGING.equals( epu.getWhat() ) ) { + // remove the blame components from the text area + JEditTextArea textArea = epu.getEditPane().getTextArea(); + JEditBuffer buffer = textArea.getBuffer(); + Object old_blame = buffer.getProperty( "_old_blame_" ); + if ( old_blame != null ) { + textArea.removeLeftOfScrollBar( ( JComponent ) old_blame ); + } + Object old_closer = buffer.getProperty( "_old_closer_" ); + if ( old_closer != null ) { + textArea.removeTopComponent( ( JComponent ) old_closer ); + } + epu.getEditPane().getView().invalidate(); + epu.getEditPane().getView().validate(); + + } + else if ( EditPaneUpdate.BUFFER_CHANGED.equals( epu.getWhat() ) ) { + // check if the new buffer has stored blame parts, if so, add + // them to the text area + JEditTextArea textArea = epu.getEditPane().getTextArea(); + JEditBuffer buffer = textArea.getBuffer(); + Object old_blame = buffer.getProperty( "_old_blame_" ); + Object old_closer = buffer.getProperty( "_old_closer_" ); + if ( old_blame != null && old_closer != null ) { + textArea.addLeftOfScrollBar( ( JComponent ) old_blame ); + textArea.addTopComponent( ( JComponent ) old_closer ); + epu.getEditPane().getView().invalidate(); + epu.getEditPane().getView().validate(); + } + } + } + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |