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 221662
Collapse All | Expand All

(-)a/nbproject/project.properties (+1 lines)
Lines 19-21 Link Here
19
license.file=LICENSE
19
license.file=LICENSE
20
nbm.homepage=http://nbgit.org/
20
nbm.homepage=http://nbgit.org/
21
nbm.module.author=Alex Coles <alex@alexcolesportfolio.com>, Jonas Fonseca <fonseca@diku.dk>
21
nbm.module.author=Alex Coles <alex@alexcolesportfolio.com>, Jonas Fonseca <fonseca@diku.dk>
22
run.args.extra=-J-javaagent:d:/tools/JRebel/jrebel.jar -J-Drebel.log=true
(-)a/src/org/nbgit/ui/browser/BrowserTopComponent.form (-1 / +1 lines)
Lines 71-77 Link Here
71
            <DimensionLayout dim="0">
71
            <DimensionLayout dim="0">
72
              <Group type="103" groupAlignment="0" attributes="0">
72
              <Group type="103" groupAlignment="0" attributes="0">
73
                  <Component id="textScrollPane" alignment="0" pref="451" max="32767" attributes="0"/>
73
                  <Component id="textScrollPane" alignment="0" pref="451" max="32767" attributes="0"/>
74
                  <Component id="toolBar" alignment="0" pref="451" max="32767" attributes="0"/>
74
                  <Component id="toolBar" alignment="0" pref="449" max="32767" attributes="0"/>
75
              </Group>
75
              </Group>
76
            </DimensionLayout>
76
            </DimensionLayout>
77
            <DimensionLayout dim="1">
77
            <DimensionLayout dim="1">
(-)a/src/org/nbgit/ui/browser/BrowserTopComponent.java (-32 / +80 lines)
Lines 35-40 Link Here
35
 */
35
 */
36
package org.nbgit.ui.browser;
36
package org.nbgit.ui.browser;
37
37
38
import java.util.Collection;
39
import javax.swing.JComponent;
40
import javax.swing.JOptionPane;
38
import javax.swing.ListSelectionModel;
41
import javax.swing.ListSelectionModel;
39
import javax.swing.SwingUtilities;
42
import javax.swing.SwingUtilities;
40
import javax.swing.event.DocumentEvent;
43
import javax.swing.event.DocumentEvent;
Lines 43-90 Link Here
43
import javax.swing.event.ListSelectionListener;
46
import javax.swing.event.ListSelectionListener;
44
47
45
import org.eclipse.jgit.awtui.CommitGraphPane;
48
import org.eclipse.jgit.awtui.CommitGraphPane;
49
import org.eclipse.jgit.lib.Constants;
50
import org.netbeans.modules.versioning.spi.VCSContext;
51
import org.openide.nodes.Node;
46
import org.openide.util.NbBundle;
52
import org.openide.util.NbBundle;
47
import org.openide.windows.TopComponent;
53
import org.openide.windows.TopComponent;
48
import org.openide.util.ImageUtilities;
54
import org.openide.util.ImageUtilities;
55
import org.openide.util.Lookup.Result;
56
import org.openide.util.LookupEvent;
57
import org.openide.util.LookupListener;
58
import org.openide.util.Utilities;
49
59
50
/**
60
/**
51
 * Repository browser top component.
61
 * Repository browser top component.
52
 */
62
 */
53
public final class BrowserTopComponent extends TopComponent {
63
public final class BrowserTopComponent extends TopComponent implements LookupListener {
54
64
55
    private static final String ICON_PATH = "org/nbgit/resources/icons/gitvcs-icon.png"; // NOI18N
65
    private static final String ICON_PATH = "org/nbgit/resources/icons/gitvcs-icon.png"; // NOI18N
56
    private static final String PREFERRED_ID = "org-nbgit-ui-browser"; // NOI18N
66
    private static final String PREFERRED_ID = "org-nbgit-ui-browser"; // NOI18N
57
    private int commitIndex = -1;
67
    private int commitIndex = -1;
68
    private Result<Node> lookupResult;
58
69
59
    public BrowserTopComponent(BrowserModel model) {
70
    public BrowserTopComponent(BrowserModel model) {
60
        initComponents();
71
        initComponents();
61
        setName(_("CTL_BrowserTopComponent")); // NOI18N
72
        setName(_("CTL_BrowserTopComponent")); // NOI18N
62
        setToolTipText(_("HINT_BrowserTopComponent")); // NOI18N
73
        setToolTipText(_("HINT_BrowserTopComponent")); // NOI18N
63
        setIcon(ImageUtilities.loadImage(ICON_PATH, true));
74
        setIcon(ImageUtilities.loadImage(ICON_PATH, true));
64
        model.setCommitList(commitGraphPane.getCommitList());
75
        setModel(model);
65
        textArea.setDocument(model.getDocument());
66
        model.getDocument().addDocumentListener(new DocumentListener() {
67
68
            public void updateId(DocumentEvent e) {
69
                String id = e.getDocument().getProperty(BrowserModel.CONTENT_ID).toString();
70
                idField.setText(id);
71
                scrollTextToStart();
72
            }
73
74
            public void insertUpdate(DocumentEvent e) {
75
                updateId(e);
76
            }
77
78
            public void removeUpdate(DocumentEvent e) {
79
                updateId(e);
80
            }
81
82
            public void changedUpdate(DocumentEvent e) {
83
                updateId(e);
84
            }
85
        });
86
        commitGraphPane.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
76
        commitGraphPane.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
87
88
            public void valueChanged(ListSelectionEvent event) {
77
            public void valueChanged(ListSelectionEvent event) {
89
                ListSelectionModel listModel = (ListSelectionModel) event.getSource();
78
                ListSelectionModel listModel = (ListSelectionModel) event.getSource();
90
                for (int i = event.getFirstIndex(); i <= event.getLastIndex(); i++) {
79
                for (int i = event.getFirstIndex(); i <= event.getLastIndex(); i++) {
Lines 95-112 Link Here
95
                    break;
84
                    break;
96
                }
85
                }
97
            }
86
            }
98
99
        });
87
        });
100
    }
88
    }
101
89
102
    private void scrollTextToStart() {
90
    private void scrollTextToStart() {
103
        SwingUtilities.invokeLater(new Runnable() {
91
        SwingUtilities.invokeLater(new Runnable() {
104
105
            public void run() {
92
            public void run() {
106
                idField.setCaretPosition(0);
93
                idField.setCaretPosition(0);
107
                textArea.setCaretPosition(0);
94
                textArea.setCaretPosition(0);
108
            }
95
            }
109
110
        });
96
        });
111
    }
97
    }
112
98
Lines 128-137 Link Here
128
        return NbBundle.getMessage(BrowserTopComponent.class, id, args);
114
        return NbBundle.getMessage(BrowserTopComponent.class, id, args);
129
    }
115
    }
130
116
131
    /** This method is called from within the constructor to
117
    /**
132
     * initialize the form.
118
     * This method is called from within the constructor to initialize the form.
133
     * WARNING: Do NOT modify this code. The content of this method is
119
     * WARNING: Do NOT modify this code. The content of this method is always
134
     * always regenerated by the Form Editor.
120
     * regenerated by the Form Editor.
135
     */
121
     */
136
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
122
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
137
    private void initComponents() {
123
    private void initComponents() {
Lines 188-194 Link Here
188
            .add(browserSplitPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
174
            .add(browserSplitPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
189
        );
175
        );
190
    }// </editor-fold>//GEN-END:initComponents
176
    }// </editor-fold>//GEN-END:initComponents
191
192
    // Variables declaration - do not modify//GEN-BEGIN:variables
177
    // Variables declaration - do not modify//GEN-BEGIN:variables
193
    private final javax.swing.JSplitPane browserSplitPane = new javax.swing.JSplitPane();
178
    private final javax.swing.JSplitPane browserSplitPane = new javax.swing.JSplitPane();
194
    private final CommitGraphPane commitGraphPane = new CommitGraphPane();
179
    private final CommitGraphPane commitGraphPane = new CommitGraphPane();
Lines 200-203 Link Here
200
    private final javax.swing.JScrollPane textScrollPane = new javax.swing.JScrollPane();
185
    private final javax.swing.JScrollPane textScrollPane = new javax.swing.JScrollPane();
201
    private final javax.swing.JToolBar toolBar = new javax.swing.JToolBar();
186
    private final javax.swing.JToolBar toolBar = new javax.swing.JToolBar();
202
    // End of variables declaration//GEN-END:variables
187
    // End of variables declaration//GEN-END:variables
188
189
    public void resultChanged(LookupEvent le) {
190
        this.setDisplayName(lookupResult.allInstances().toString());
191
        Collection<? extends Node> nodes = lookupResult.allInstances();
192
        updateViewForNodes(nodes);
193
    }
194
195
    @Override
196
    protected void componentOpened() {
197
        lookupResult = Utilities.actionsGlobalContext().lookupResult(Node.class);
198
        lookupResult.addLookupListener(this);
199
    }
200
201
    @Override
202
    protected void componentClosed() {
203
        lookupResult.removeLookupListener(this);
204
    }
205
206
    private void setModel(BrowserModel model) {
207
        model.setCommitList(commitGraphPane.getCommitList());
208
        textArea.setDocument(model.getDocument());
209
        model.getDocument().addDocumentListener(new DocumentListener() {
210
            public void updateId(DocumentEvent e) {
211
                String id = e.getDocument().getProperty(BrowserModel.CONTENT_ID).toString();
212
                idField.setText(id);
213
                scrollTextToStart();
214
            }
215
216
            public void insertUpdate(DocumentEvent e) {
217
                updateId(e);
218
            }
219
220
            public void removeUpdate(DocumentEvent e) {
221
                updateId(e);
222
            }
223
224
            public void changedUpdate(DocumentEvent e) {
225
                updateId(e);
226
            }
227
        });
228
    }
229
230
    public void updateViewForNodes(Collection<? extends Node> nodeColl) {
231
        final BrowserTopComponent comp = this;
232
        final Node[] nodes = nodeColl.toArray(new Node[nodeColl.size()]);
233
        SwingUtilities.invokeLater(new Runnable() {
234
            public void run() {
235
236
                final VCSContext ctx = VCSContext.forNodes(nodes);
237
                if (ctx != null && ctx.getRootFiles() != null && !ctx.getRootFiles().isEmpty()) {
238
239
                    BrowserModel model = new BrowserModel(ctx.getRootFiles(), Constants.HEAD);
240
                    setModel(model);
241
                    System.out.println("model" + model);
242
243
                    BrowserController controller = new BrowserController(comp, model);
244
                    controller.show();
245
246
                    SwingUtilities.updateComponentTreeUI(comp);
247
                }
248
            }
249
        });
250
    }
203
}
251
}
(-)a/src/org/nbgit/ui/browser/ShowCommitGraphWindowAction.java (+55 lines)
Line 0 Link Here
1
/*
2
 * To change this template, choose Tools | Templates
3
 * and open the template in the editor.
4
 */
5
package org.nbgit.ui.browser;
6
7
import java.awt.event.ActionEvent;
8
import java.awt.event.ActionListener;
9
import java.util.List;
10
import javax.swing.SwingUtilities;
11
import org.eclipse.jgit.lib.Constants;
12
import org.netbeans.modules.versioning.spi.VCSContext;
13
import org.openide.awt.ActionID;
14
import org.openide.awt.ActionReference;
15
import org.openide.awt.ActionRegistration;
16
import org.openide.nodes.Node;
17
import org.openide.util.NbBundle.Messages;
18
19
@ActionID(
20
    category = "Versioning",
21
    id = "org.nbgit.ui.browser.ShowCommitGraphWindow")
22
@ActionRegistration(
23
    displayName = "#CTL_ShowCommitGraphWindowAction")
24
@ActionReference(path = "Menu/File", position = 0)
25
@Messages("CTL_ShowCommitGraphWindowAction=Show CommitGraph ")
26
public final class ShowCommitGraphWindowAction implements ActionListener {
27
28
    private final List<Node> context;
29
30
    public ShowCommitGraphWindowAction(List<Node> context) {
31
        this.context = context;
32
    }
33
34
    @Override
35
    public void actionPerformed(ActionEvent ev) {
36
        Node[] nodes = context.toArray(new Node[context.size()]);
37
        final VCSContext ctx = VCSContext.forNodes(nodes);
38
39
        SwingUtilities.invokeLater(new Runnable() {
40
            public void run() {
41
                if (ctx != null && ctx.getRootFiles() != null && !ctx.getRootFiles().isEmpty()) {
42
43
                    BrowserModel model = new BrowserModel(ctx.getRootFiles(), Constants.HEAD);
44
                    BrowserTopComponent view = new BrowserTopComponent(model);
45
                    view.setDisplayName(ctx.toString());
46
                    view.open();
47
                    view.requestActive();
48
49
                    BrowserController controller = new BrowserController(view, model);
50
                    controller.show();
51
                }
52
            }
53
        });
54
    }
55
}

Return to bug 221662