This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 185414
Collapse All | Expand All

(-)subversion/src/org/netbeans/modules/subversion/ui/history/SumaryViewRenderer.java (+48 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.subversion.ui.history;
41
42
/**
43
 *
44
 * @author tomas
45
 */
46
public class SumaryViewRenderer {
47
48
}
(-)subversion/src/org/netbeans/modules/subversion/ui/history/SummaryView.java (-40 / +34 lines)
Lines 69-74 Link Here
69
import java.text.DateFormat;
69
import java.text.DateFormat;
70
import java.util.ArrayList;
70
import java.util.ArrayList;
71
import java.util.logging.Level;
71
import java.util.logging.Level;
72
import javax.swing.border.LineBorder;
72
import org.netbeans.modules.subversion.FileStatusCache;
73
import org.netbeans.modules.subversion.FileStatusCache;
73
import org.netbeans.modules.subversion.kenai.SvnKenaiAccessor;
74
import org.netbeans.modules.subversion.kenai.SvnKenaiAccessor;
74
import org.netbeans.modules.subversion.client.SvnClient;
75
import org.netbeans.modules.subversion.client.SvnClient;
Lines 610-617 Link Here
610
    }
611
    }
611
612
612
    private class SummaryCellRenderer extends JPanel implements ListCellRenderer {
613
    private class SummaryCellRenderer extends JPanel implements ListCellRenderer {
613
614
        private static final String FIELDS_SEPARATOR = "        "; // NOI18N
614
        private static final String FIELDS_SEPARATOR = "        "; // NOI18N
615
616
        private ContainerRenderer cr = new ContainerRenderer();
617
        private RevisionRenderer rr = new RevisionRenderer();
618
619
        @Override
620
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
621
            if (value instanceof RepositoryRevision) {
622
                return cr.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
623
            } else {
624
                return rr.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
625
            }
626
        }
627
628
        private class ContainerRenderer extends JPanel implements ListCellRenderer {
629
615
        private static final double DARKEN_FACTOR = 0.95;
630
        private static final double DARKEN_FACTOR = 0.95;
616
631
617
        private Style selectedStyle;
632
        private Style selectedStyle;
Lines 635-641 Link Here
635
        private HyperlinkLabel  diffLink;
650
        private HyperlinkLabel  diffLink;
636
        private HyperlinkLabel  revertLink;
651
        private HyperlinkLabel  revertLink;
637
652
638
        public SummaryCellRenderer() {
653
            public ContainerRenderer() {
639
            selectionBackground = new JList().getSelectionBackground();
654
            selectionBackground = new JList().getSelectionBackground();
640
            selectionForeground = new JList().getSelectionForeground();
655
            selectionForeground = new JList().getSelectionForeground();
641
656
Lines 688-698 Link Here
688
703
689
        @Override
704
        @Override
690
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
705
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
691
            if (value instanceof RepositoryRevision) {
692
                renderContainer(list, (RepositoryRevision) value, index, isSelected);
706
                renderContainer(list, (RepositoryRevision) value, index, isSelected);
693
            } else {
694
                renderRevision(list, (RepositoryRevision.Event) value, index, isSelected);
695
            }
696
            return this;
707
            return this;
697
        }
708
        }
698
709
Lines 802-841 Link Here
802
            revertLink.set(NbBundle.getMessage(SummaryView.class, "CTL_Action_Revert"), foregroundColor, backgroundColor); // NOI18N
813
            revertLink.set(NbBundle.getMessage(SummaryView.class, "CTL_Action_Revert"), foregroundColor, backgroundColor); // NOI18N
803
        }
814
        }
804
815
805
        private void renderRevision(JList list, RepositoryRevision.Event dispRevision, final int index, boolean isSelected) {
806
            Style style;
807
            StyledDocument sd = textPane.getStyledDocument();
808
809
            Color backgroundColor;
810
            Color foregroundColor;
811
812
            if (isSelected) {
813
                foregroundColor = selectionForeground;
814
                backgroundColor = selectionBackground;
815
                style = selectedStyle;
816
            } else {
817
                foregroundColor = UIManager.getColor("List.foreground"); // NOI18N
818
                backgroundColor = UIManager.getColor("List.background"); // NOI18N
819
                style = normalStyle;
820
            }
821
            textPane.setBackground(backgroundColor);
822
            actionsPane.setVisible(false);
823
824
            this.index = -1;
825
            try {
826
                sd.remove(0, sd.getLength());
827
                sd.setParagraphAttributes(0, sd.getLength(), indentStyle, false);
828
829
                sd.insertString(sd.getLength(), String.valueOf(dispRevision.getChangedPath().getAction()), null);
830
                sd.insertString(sd.getLength(), FIELDS_SEPARATOR + dispRevision.getChangedPath().getPath(), null);
831
832
                sd.setCharacterAttributes(0, Integer.MAX_VALUE, style, false);
833
                resizePane(sd.getText(0, sd.getLength() - 1), list.getFontMetrics(list.getFont()));
834
            } catch (BadLocationException e) {
835
                Subversion.LOG.log(Level.SEVERE, null, e);
836
            }
837
        }
838
839
        private void resizePane(String text, FontMetrics fm) {
816
        private void resizePane(String text, FontMetrics fm) {
840
            if(text == null) {
817
            if(text == null) {
841
                text = "";
818
                text = "";
Lines 871-876 Link Here
871
848
872
    }
849
    }
873
850
851
        private class RevisionRenderer extends DefaultListCellRenderer {
852
            @Override
853
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
854
                renderRevision(list, (RepositoryRevision.Event) value, index, isSelected);
855
                return this;
856
            }
857
            private void renderRevision(JList list, RepositoryRevision.Event dispRevision, final int index, boolean isSelected) {
858
                StringBuilder sb = new StringBuilder();
859
                sb.append(FIELDS_SEPARATOR);
860
                sb.append(String.valueOf(dispRevision.getChangedPath().getAction()));
861
                sb.append(FIELDS_SEPARATOR);
862
                sb.append(dispRevision.getChangedPath().getPath());
863
                super.getListCellRendererComponent(list, sb.toString(), index, isSelected, isSelected);
864
            }
865
        }
866
    }
867
874
    private static class HyperlinkLabel extends JLabel {
868
    private static class HyperlinkLabel extends JLabel {
875
869
876
        public HyperlinkLabel() {
870
        public HyperlinkLabel() {

Return to bug 185414