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

(-)a/cnd.navigation/src/org/netbeans/modules/cnd/navigation/macroview/MacroExpansionPanel.java (+2 lines)
Lines 495-506 Link Here
495
    private void fileContextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileContextActionPerformed
495
    private void fileContextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileContextActionPerformed
496
        fileContext.setSelected(true);
496
        fileContext.setSelected(true);
497
        localContext.setSelected(false);
497
        localContext.setSelected(false);
498
        MacroExpansionTopComponent.setLocalContext(false);
498
        update();
499
        update();
499
}//GEN-LAST:event_fileContextActionPerformed
500
}//GEN-LAST:event_fileContextActionPerformed
500
501
501
    private void localContextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_localContextActionPerformed
502
    private void localContextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_localContextActionPerformed
502
        localContext.setSelected(true);
503
        localContext.setSelected(true);
503
        fileContext.setSelected(false);
504
        fileContext.setSelected(false);
505
        MacroExpansionTopComponent.setLocalContext(true);
504
        update();
506
        update();
505
}//GEN-LAST:event_localContextActionPerformed
507
}//GEN-LAST:event_localContextActionPerformed
506
508
(-)a/cnd.navigation/src/org/netbeans/modules/cnd/navigation/macroview/MacroExpansionTopComponent.java (-9 / +7 lines)
Lines 48-53 Link Here
48
import org.netbeans.modules.cnd.modelutil.CsmUtilities;
48
import org.netbeans.modules.cnd.modelutil.CsmUtilities;
49
import org.openide.util.ImageUtilities;
49
import org.openide.util.ImageUtilities;
50
import org.openide.util.NbBundle;
50
import org.openide.util.NbBundle;
51
import org.openide.util.NbPreferences;
51
import org.openide.windows.TopComponent;
52
import org.openide.windows.TopComponent;
52
53
53
/**
54
/**
Lines 64-70 Link Here
64
    private static final String PREFERRED_ID = "MacroExpansionTopComponent"; // NOI18N
65
    private static final String PREFERRED_ID = "MacroExpansionTopComponent"; // NOI18N
65
    private MacroExpansionPanel panel = null;
66
    private MacroExpansionPanel panel = null;
66
    private int lastDividerLocation = -1;
67
    private int lastDividerLocation = -1;
67
    private boolean lastLocalContext = true;
68
    private boolean lastSyncCaret = true;
68
    private boolean lastSyncCaret = true;
69
    private boolean lastSyncContext = false;
69
    private boolean lastSyncContext = false;
70
    private Document lastExpandedContextDoc = null;
70
    private Document lastExpandedContextDoc = null;
Lines 83-89 Link Here
83
        lastExpandedContextDoc = expandedContextDoc;
83
        lastExpandedContextDoc = expandedContextDoc;
84
        if (panel != null) {
84
        if (panel != null) {
85
            lastDividerLocation = panel.getDividerLocation();
85
            lastDividerLocation = panel.getDividerLocation();
86
            lastLocalContext = panel.isLocalContext();
87
            lastSyncCaret = panel.isSyncCaret();
86
            lastSyncCaret = panel.isSyncCaret();
88
            lastSyncContext = panel.isSyncContext();
87
            lastSyncContext = panel.isSyncContext();
89
        }
88
        }
Lines 94-100 Link Here
94
        if (lastDividerLocation != -1) {
93
        if (lastDividerLocation != -1) {
95
            panel.setDividerLocation(lastDividerLocation);
94
            panel.setDividerLocation(lastDividerLocation);
96
        }
95
        }
97
        panel.setLocalContext(lastLocalContext);
96
        panel.setLocalContext(isLocalContext());
98
        panel.setSyncCaret(lastSyncCaret);
97
        panel.setSyncCaret(lastSyncCaret);
99
        panel.setSyncContext(lastSyncContext);
98
        panel.setSyncContext(lastSyncContext);
100
        if (panel.isSyncCaret()) {
99
        if (panel.isSyncCaret()) {
Lines 120-132 Link Here
120
     *
119
     *
121
     * @return is macro expansion local
120
     * @return is macro expansion local
122
     */
121
     */
123
    public boolean isLocalContext() {
122
    public static boolean isLocalContext() {
124
        if (panel != null) {
123
        return NbPreferences.forModule(MacroExpansionTopComponent.class).getBoolean("show-local-context", true);
125
            lastLocalContext = panel.isLocalContext();
126
        }
127
        return lastLocalContext;
128
    }
124
    }
129
125
126
    public static void setLocalContext(boolean localContext) {
127
        NbPreferences.forModule(MacroExpansionTopComponent.class).putBoolean("show-local-context", localContext);
128
    }
130
    /**
129
    /**
131
     * Indicates is caret synchronization enabled or not.
130
     * Indicates is caret synchronization enabled or not.
132
     *
131
     *
Lines 232-238 Link Here
232
        initComponents();
231
        initComponents();
233
        if (panel != null) {
232
        if (panel != null) {
234
            lastDividerLocation = panel.getDividerLocation();
233
            lastDividerLocation = panel.getDividerLocation();
235
            lastLocalContext = panel.isLocalContext();
236
            lastSyncCaret = panel.isSyncCaret();
234
            lastSyncCaret = panel.isSyncCaret();
237
            lastSyncContext = panel.isSyncContext();
235
            lastSyncContext = panel.isSyncContext();
238
236
(-)a/cnd.navigation/src/org/netbeans/modules/cnd/navigation/macroview/MacroExpansionViewUtils.java (-8 / +2 lines)
Lines 98-104 Link Here
98
     */
98
     */
99
    public static boolean updateView(int newOffset) {
99
    public static boolean updateView(int newOffset) {
100
        final MacroExpansionTopComponent view = MacroExpansionTopComponent.findInstance();
100
        final MacroExpansionTopComponent view = MacroExpansionTopComponent.findInstance();
101
        boolean localContext = view.isLocalContext();
101
        boolean localContext = MacroExpansionTopComponent.isLocalContext();
102
102
103
        final Document expandedContextDoc = view.getExpandedContextDoc();
103
        final Document expandedContextDoc = view.getExpandedContextDoc();
104
        if (expandedContextDoc == null) {
104
        if (expandedContextDoc == null) {
Lines 165-177 Link Here
165
        if (SwingUtilities.isEventDispatchThread()) {
165
        if (SwingUtilities.isEventDispatchThread()) {
166
            openView.run();
166
            openView.run();
167
        } else {
167
        } else {
168
            try {
168
            SwingUtilities.invokeLater(openView);
169
                SwingUtilities.invokeAndWait(openView);
170
            } catch (InterruptedException ex) {
171
                Exceptions.printStackTrace(ex);
172
            } catch (InvocationTargetException ex) {
173
                Exceptions.printStackTrace(ex);
174
            }
175
        }
169
        }
176
        return true;
170
        return true;
177
    }
171
    }
(-)a/cnd.navigation/src/org/netbeans/modules/cnd/navigation/macroview/impl/services/MacroExpansionViewProviderImpl.java (-12 / +4 lines)
Lines 88-105 Link Here
88
        if (mainDoc == null) {
88
        if (mainDoc == null) {
89
            return;
89
            return;
90
        }
90
        }
91
        CsmFile csmFile = CsmUtilities.getCsmFile(mainDoc, true);
91
        final CsmFile csmFile = CsmUtilities.getCsmFile(mainDoc, true);
92
        if (csmFile == null) {
92
        if (csmFile == null) {
93
            return;
93
            return;
94
        }
94
        }
95
95
96
        final MacroExpansionTopComponent view = MacroExpansionTopComponent.findInstance();
97
        boolean localContext = view.isLocalContext();
98
99
        // Get ofsets
96
        // Get ofsets
100
        int startOffset = 0;
97
        int startOffset = 0;
101
        int endOffset = mainDoc.getLength();
98
        int endOffset = mainDoc.getLength();
102
        if (localContext) {
99
        if (MacroExpansionTopComponent.isLocalContext()) {
103
            CsmScope scope = ContextUtils.findInnerFileScope(csmFile, offset);
100
            CsmScope scope = ContextUtils.findInnerFileScope(csmFile, offset);
104
            if (CsmKindUtilities.isOffsetable(scope)) {
101
            if (CsmKindUtilities.isOffsetable(scope)) {
105
                startOffset = ((CsmOffsetable) scope).getStartOffset();
102
                startOffset = ((CsmOffsetable) scope).getStartOffset();
Lines 135-140 Link Here
135
        Runnable openView = new Runnable() {
132
        Runnable openView = new Runnable() {
136
133
137
            public void run() {
134
            public void run() {
135
                MacroExpansionTopComponent view = MacroExpansionTopComponent.findInstance();
138
                if (!view.isOpened()) {
136
                if (!view.isOpened()) {
139
                    view.open();
137
                    view.open();
140
                }
138
                }
Lines 147-159 Link Here
147
        if (SwingUtilities.isEventDispatchThread()) {
145
        if (SwingUtilities.isEventDispatchThread()) {
148
            openView.run();
146
            openView.run();
149
        } else {
147
        } else {
150
            try {
148
            SwingUtilities.invokeLater(openView);
151
                SwingUtilities.invokeAndWait(openView);
152
            } catch (InterruptedException ex) {
153
                Exceptions.printStackTrace(ex);
154
            } catch (InvocationTargetException ex) {
155
                Exceptions.printStackTrace(ex);
156
            }
157
        }
149
        }
158
    }
150
    }
159
}
151
}

Return to bug 158663