Lines 57-68
Link Here
|
57 |
import java.lang.ref.WeakReference; |
57 |
import java.lang.ref.WeakReference; |
58 |
import java.lang.reflect.InvocationTargetException; |
58 |
import java.lang.reflect.InvocationTargetException; |
59 |
import java.util.*; |
59 |
import java.util.*; |
60 |
import java.util.Collection; |
60 |
import java.util.Map.Entry; |
61 |
import java.util.concurrent.atomic.AtomicBoolean; |
61 |
import java.util.concurrent.atomic.AtomicBoolean; |
62 |
import java.util.Map.Entry; |
|
|
63 |
import java.util.prefs.Preferences; |
62 |
import java.util.prefs.Preferences; |
64 |
import javax.swing.*; |
63 |
import javax.swing.*; |
65 |
import javax.swing.border.EmptyBorder; |
64 |
import javax.swing.border.EmptyBorder; |
|
|
65 |
import javax.swing.event.ChangeEvent; |
66 |
import javax.swing.text.html.HTMLEditorKit; |
66 |
import javax.swing.text.html.HTMLEditorKit; |
67 |
import javax.swing.text.html.parser.ParserDelegator; |
67 |
import javax.swing.text.html.parser.ParserDelegator; |
68 |
import javax.swing.tree.DefaultTreeModel; |
68 |
import javax.swing.tree.DefaultTreeModel; |
Lines 73-78
Link Here
|
73 |
import org.netbeans.api.project.*; |
73 |
import org.netbeans.api.project.*; |
74 |
import org.netbeans.modules.parsing.api.indexing.IndexingManager; |
74 |
import org.netbeans.modules.parsing.api.indexing.IndexingManager; |
75 |
import org.netbeans.modules.refactoring.api.*; |
75 |
import org.netbeans.modules.refactoring.api.*; |
|
|
76 |
import org.netbeans.modules.refactoring.spi.ui.FiltersDescription; |
76 |
import org.netbeans.modules.refactoring.spi.ui.RefactoringCustomUI; |
77 |
import org.netbeans.modules.refactoring.spi.ui.RefactoringCustomUI; |
77 |
import org.netbeans.modules.refactoring.spi.ui.RefactoringUI; |
78 |
import org.netbeans.modules.refactoring.spi.ui.RefactoringUI; |
78 |
import org.netbeans.modules.refactoring.spi.ui.TreeElement; |
79 |
import org.netbeans.modules.refactoring.spi.ui.TreeElement; |
Lines 85-92
Link Here
|
85 |
import org.openide.awt.Mnemonics; |
86 |
import org.openide.awt.Mnemonics; |
86 |
import org.openide.filesystems.FileObject; |
87 |
import org.openide.filesystems.FileObject; |
87 |
import org.openide.loaders.DataObject; |
88 |
import org.openide.loaders.DataObject; |
88 |
import org.openide.text.CloneableEditorSupport; |
|
|
89 |
import org.openide.text.PositionBounds; |
90 |
import org.openide.util.*; |
89 |
import org.openide.util.*; |
91 |
import org.openide.windows.TopComponent; |
90 |
import org.openide.windows.TopComponent; |
92 |
|
91 |
|
Lines 95-101
Link Here
|
95 |
* |
94 |
* |
96 |
* @author Pavel Flaska, Martin Matula |
95 |
* @author Pavel Flaska, Martin Matula |
97 |
*/ |
96 |
*/ |
98 |
public class RefactoringPanel extends JPanel { |
97 |
public class RefactoringPanel extends JPanel implements FiltersManagerImpl.FilterChangeListener { |
99 |
private static final RequestProcessor RP = new RequestProcessor(RefactoringPanel.class.getName(), 1, false, false); |
98 |
private static final RequestProcessor RP = new RequestProcessor(RefactoringPanel.class.getName(), 1, false, false); |
100 |
|
99 |
|
101 |
// PRIVATE FIELDS |
100 |
// PRIVATE FIELDS |
Lines 105-111
Link Here
|
105 |
private transient JButton refreshButton = null; |
104 |
private transient JButton refreshButton = null; |
106 |
/* button lying in the toolbar allows expansion of all nodes in a tree */ |
105 |
/* button lying in the toolbar allows expansion of all nodes in a tree */ |
107 |
private transient JToggleButton expandButton = null; |
106 |
private transient JToggleButton expandButton = null; |
108 |
private JToolBar toolBar = null; |
|
|
109 |
|
107 |
|
110 |
private transient JButton refactorButton = null; |
108 |
private transient JButton refactorButton = null; |
111 |
private transient JButton cancelButton = null; |
109 |
private transient JButton cancelButton = null; |
Lines 118-124
Link Here
|
118 |
private transient boolean isVisible = false; |
116 |
private transient boolean isVisible = false; |
119 |
private transient RefactoringSession session = null; |
117 |
private transient RefactoringSession session = null; |
120 |
private transient ParametersPanel parametersPanel = null; |
118 |
private transient ParametersPanel parametersPanel = null; |
121 |
private transient JScrollPane scrollPane = null; |
119 |
private transient JScrollPane scrollPane = null; |
122 |
private transient JPanel southPanel; |
120 |
private transient JPanel southPanel; |
123 |
public JSplitPane splitPane; |
121 |
public JSplitPane splitPane; |
124 |
private JPanel left; |
122 |
private JPanel left; |
Lines 141-158
Link Here
|
141 |
private Component customComponent; |
139 |
private Component customComponent; |
142 |
private AtomicBoolean cancelRequest = new AtomicBoolean(); |
140 |
private AtomicBoolean cancelRequest = new AtomicBoolean(); |
143 |
private int size = 0; |
141 |
private int size = 0; |
144 |
|
|
|
145 |
|
146 |
|
142 |
|
147 |
static Image PACKAGE_BADGE = ImageUtilities.loadImage( "org/netbeans/spi/java/project/support/ui/packageBadge.gif" ); // NOI18N |
143 |
static Image PACKAGE_BADGE = ImageUtilities.loadImage( "org/netbeans/spi/java/project/support/ui/packageBadge.gif" ); // NOI18N |
|
|
144 |
private FiltersManagerImpl filtersManager; |
145 |
private JComponent filterBar; |
146 |
private JPanel toolbars; |
148 |
|
147 |
|
149 |
public RefactoringPanel(RefactoringUI ui) { |
148 |
public RefactoringPanel(RefactoringUI ui) { |
150 |
this(ui,null); |
149 |
this(ui,null); |
151 |
} |
150 |
} |
152 |
|
151 |
|
153 |
public RefactoringPanel(RefactoringUI ui, TopComponent caller) { |
152 |
public RefactoringPanel(RefactoringUI ui, TopComponent caller) { |
154 |
if (caller!=null) |
153 |
if (caller!=null) { |
155 |
refCallerTC = new WeakReference<TopComponent>(caller); |
154 |
refCallerTC = new WeakReference<TopComponent>(caller); |
|
|
155 |
} |
156 |
this.ui = ui; |
156 |
this.ui = ui; |
157 |
this.isQuery = ui.isQuery(); |
157 |
this.isQuery = ui.isQuery(); |
158 |
if (isQuery) { |
158 |
if (isQuery) { |
Lines 170-175
Link Here
|
170 |
ui.getRefactoring().addProgressListener(fuListener = new FUListener()); |
170 |
ui.getRefactoring().addProgressListener(fuListener = new FUListener()); |
171 |
} |
171 |
} |
172 |
initialize(); |
172 |
initialize(); |
|
|
173 |
updateFilters(); |
173 |
refresh(false); |
174 |
refresh(false); |
174 |
} |
175 |
} |
175 |
|
176 |
|
Lines 181-188
Link Here
|
181 |
|
182 |
|
182 |
/* initializes all the ui */ |
183 |
/* initializes all the ui */ |
183 |
private void initialize() { |
184 |
private void initialize() { |
184 |
if (inited) |
185 |
if (inited) { |
185 |
return ; |
186 |
return ; |
|
|
187 |
} |
186 |
checkEventThread(); |
188 |
checkEventThread(); |
187 |
setFocusCycleRoot(true); |
189 |
setFocusCycleRoot(true); |
188 |
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
190 |
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
Lines 197-232
Link Here
|
197 |
splitPane.setBorder(null); |
199 |
splitPane.setBorder(null); |
198 |
// add panel with buttons |
200 |
// add panel with buttons |
199 |
JButton[] buttons = getButtons(); |
201 |
JButton[] buttons = getButtons(); |
200 |
//if (buttons.length != 0) { |
202 |
// there will be at least one button on panel |
201 |
// there will be at least one button on panel |
203 |
southPanel = new JPanel(new GridBagLayout()); |
202 |
southPanel = new JPanel(new GridBagLayout()); |
204 |
for (int i = 0; i < buttons.length; i++) { |
203 |
for (int i = 0; i < buttons.length; i++) { |
|
|
204 |
GridBagConstraints c = new GridBagConstraints(); |
205 |
c.gridy = 0; |
206 |
c.insets = new Insets(5, 5, 5, 0); |
207 |
southPanel.add(buttons[i], c); |
208 |
} |
209 |
JPanel pp = new JPanel(new BorderLayout()); |
210 |
GridBagConstraints c = new GridBagConstraints(); |
205 |
GridBagConstraints c = new GridBagConstraints(); |
211 |
c.gridy = 0; |
206 |
c.gridy = 0; |
212 |
c.insets = new Insets(5, 5, 5, 5); |
207 |
c.insets = new Insets(5, 5, 5, 0); |
213 |
c.weightx = 1; |
208 |
southPanel.add(buttons[i], c); |
214 |
c.fill = GridBagConstraints.HORIZONTAL; |
209 |
} |
215 |
southPanel.add(pp, c); |
210 |
JPanel pp = new JPanel(new BorderLayout()); |
216 |
|
211 |
GridBagConstraints c = new GridBagConstraints(); |
217 |
if (!isQuery|| callback != null) { |
212 |
c.gridy = 0; |
218 |
left.add(southPanel, BorderLayout.SOUTH); |
213 |
c.insets = new Insets(5, 5, 5, 5); |
219 |
} |
214 |
c.weightx = 1; |
220 |
//} |
215 |
c.fill = GridBagConstraints.HORIZONTAL; |
|
|
216 |
southPanel.add(pp, c); |
217 |
|
218 |
if (!isQuery|| callback != null) { |
219 |
left.add(southPanel, BorderLayout.SOUTH); |
220 |
} |
221 |
if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N |
222 |
southPanel.setBackground(UIManager.getColor("NbExplorerView.background")); |
223 |
} |
221 |
// put the toolbar to the panel. If the getToolBar() returns null, |
224 |
// put the toolbar to the panel. If the getToolBar() returns null, |
222 |
// suppose the toolbar does not exist. |
225 |
// suppose the toolbar does not exist. |
223 |
JToolBar toolBar = getToolBar(); |
226 |
JToolBar toolbar = getToolBar(); |
224 |
if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N |
227 |
if (toolbar != null) { |
225 |
toolBar.setBackground(UIManager.getColor("NbExplorerView.background")); |
228 |
if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N |
226 |
southPanel.setBackground(UIManager.getColor("NbExplorerView.background")); |
229 |
toolbar.setBackground(UIManager.getColor("NbExplorerView.background")); |
|
|
230 |
} |
231 |
toolbars = new JPanel(new BorderLayout()); |
232 |
toolbars.add(toolbar, BorderLayout.WEST); |
233 |
left.add(toolbars, BorderLayout.WEST); |
227 |
} |
234 |
} |
228 |
if (toolBar != null) |
|
|
229 |
left.add(toolBar, BorderLayout.WEST); |
230 |
validate(); |
235 |
validate(); |
231 |
inited=true; |
236 |
inited=true; |
232 |
} |
237 |
} |
Lines 267-275
Link Here
|
267 |
); |
272 |
); |
268 |
expandButton.setBorderPainted(false); |
273 |
expandButton.setBorderPainted(false); |
269 |
expandButton.addActionListener(getButtonListener()); |
274 |
expandButton.addActionListener(getButtonListener()); |
270 |
// create toolbar |
|
|
271 |
toolBar = new JToolBar(JToolBar.VERTICAL); |
272 |
toolBar.setFloatable(false); |
273 |
|
275 |
|
274 |
logicalViewButton = new JToggleButton( |
276 |
logicalViewButton = new JToggleButton( |
275 |
ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/api/resources/logical_view.png", false)); |
277 |
ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/api/resources/logical_view.png", false)); |
Lines 360-378
Link Here
|
360 |
stopButton.setBorderPainted(false); |
362 |
stopButton.setBorderPainted(false); |
361 |
stopButton.addActionListener(getButtonListener()); |
363 |
stopButton.addActionListener(getButtonListener()); |
362 |
|
364 |
|
363 |
|
365 |
// create toolbar |
364 |
toolBar.add(refreshButton); |
366 |
JToolBar toolbar = new JToolBar(JToolBar.VERTICAL); |
365 |
toolBar.add(prevMatch); |
367 |
toolbar.setFloatable(false); |
366 |
toolBar.add(nextMatch); |
368 |
|
367 |
toolBar.add(logicalViewButton); |
369 |
toolbar.add(refreshButton); |
368 |
toolBar.add(physicalViewButton); |
370 |
toolbar.add(stopButton); |
369 |
toolBar.add(expandButton); |
371 |
toolbar.add(prevMatch); |
|
|
372 |
toolbar.add(nextMatch); |
373 |
toolbar.add(logicalViewButton); |
374 |
toolbar.add(physicalViewButton); |
375 |
toolbar.add(expandButton); |
370 |
if (ui instanceof RefactoringCustomUI) { |
376 |
if (ui instanceof RefactoringCustomUI) { |
371 |
toolBar.add(customViewButton); |
377 |
toolbar.add(customViewButton); |
372 |
} |
378 |
} |
373 |
toolBar.add(stopButton); |
379 |
return toolbar; |
374 |
|
|
|
375 |
return toolBar; |
376 |
} |
380 |
} |
377 |
|
381 |
|
378 |
/** |
382 |
/** |
Lines 381-387
Link Here
|
381 |
* if you want to provide any other buttons with different action to be |
385 |
* if you want to provide any other buttons with different action to be |
382 |
* performed. |
386 |
* performed. |
383 |
* |
387 |
* |
384 |
* @return array of avasilable buttons. |
388 |
* @return array of available buttons. |
385 |
*/ |
389 |
*/ |
386 |
private JButton[] getButtons() { |
390 |
private JButton[] getButtons() { |
387 |
checkEventThread(); |
391 |
checkEventThread(); |
Lines 416-423
Link Here
|
416 |
|
420 |
|
417 |
void switchToLogicalView() { |
421 |
void switchToLogicalView() { |
418 |
logicalViewButton.setSelected(true); |
422 |
logicalViewButton.setSelected(true); |
419 |
if (currentView == LOGICAL) |
423 |
if (currentView == LOGICAL) { |
420 |
return ; |
424 |
return ; |
|
|
425 |
} |
421 |
currentView = LOGICAL; |
426 |
currentView = LOGICAL; |
422 |
physicalViewButton.setSelected(false); |
427 |
physicalViewButton.setSelected(false); |
423 |
if (customViewButton!=null) { |
428 |
if (customViewButton!=null) { |
Lines 432-439
Link Here
|
432 |
|
437 |
|
433 |
void switchToPhysicalView() { |
438 |
void switchToPhysicalView() { |
434 |
physicalViewButton.setSelected(true); |
439 |
physicalViewButton.setSelected(true); |
435 |
if (currentView == PHYSICAL) |
440 |
if (currentView == PHYSICAL) { |
436 |
return ; |
441 |
return ; |
|
|
442 |
} |
437 |
currentView = PHYSICAL; |
443 |
currentView = PHYSICAL; |
438 |
logicalViewButton.setSelected(false); |
444 |
logicalViewButton.setSelected(false); |
439 |
if (customViewButton!=null) { |
445 |
if (customViewButton!=null) { |
Lines 448-455
Link Here
|
448 |
|
454 |
|
449 |
void switchToCustomView() { |
455 |
void switchToCustomView() { |
450 |
customViewButton.setSelected(true); |
456 |
customViewButton.setSelected(true); |
451 |
if (currentView == GRAPHICAL) |
457 |
if (currentView == GRAPHICAL) { |
452 |
return ; |
458 |
return ; |
|
|
459 |
} |
453 |
currentView = GRAPHICAL; |
460 |
currentView = GRAPHICAL; |
454 |
logicalViewButton.setSelected(false); |
461 |
logicalViewButton.setSelected(false); |
455 |
physicalViewButton.setSelected(false); |
462 |
physicalViewButton.setSelected(false); |
Lines 512-527
Link Here
|
512 |
return node; |
519 |
return node; |
513 |
} |
520 |
} |
514 |
|
521 |
|
515 |
private static final String getString(String key) { |
|
|
516 |
return NbBundle.getMessage(RefactoringPanel.class, key); |
517 |
} |
518 |
|
519 |
/** |
520 |
* Overrides default ExplorerPanel behaviour. Does nothing now. |
521 |
*/ |
522 |
protected void updateTitle() { |
523 |
} |
524 |
|
525 |
/** |
522 |
/** |
526 |
* Method is responsible for making changes in sources. |
523 |
* Method is responsible for making changes in sources. |
527 |
*/ |
524 |
*/ |
Lines 590-597
Link Here
|
590 |
* This is the reason of lazy initialization. |
587 |
* This is the reason of lazy initialization. |
591 |
*/ |
588 |
*/ |
592 |
private ButtonL getButtonListener() { |
589 |
private ButtonL getButtonListener() { |
593 |
if (buttonListener == null) |
590 |
if (buttonListener == null) { |
594 |
buttonListener = new ButtonL(); |
591 |
buttonListener = new ButtonL(); |
|
|
592 |
} |
595 |
|
593 |
|
596 |
return buttonListener; |
594 |
return buttonListener; |
597 |
} |
595 |
} |
Lines 698-714
Link Here
|
698 |
final RefactoringPanelContainer cont = isQuery ? RefactoringPanelContainer.getUsagesComponent() : RefactoringPanelContainer.getRefactoringComponent(); |
696 |
final RefactoringPanelContainer cont = isQuery ? RefactoringPanelContainer.getUsagesComponent() : RefactoringPanelContainer.getRefactoringComponent(); |
699 |
cont.makeBusy(true); |
697 |
cont.makeBusy(true); |
700 |
initialize(); |
698 |
initialize(); |
|
|
699 |
if(showParametersPanel) { |
700 |
updateFilters(); |
701 |
} |
701 |
|
702 |
|
702 |
cancelRequest.set(false); |
703 |
cancelRequest.set(false); |
703 |
stopButton.setVisible(isQuery); |
704 |
stopButton.setVisible(isQuery && showParametersPanel); |
|
|
705 |
refreshButton.setVisible(!isQuery || !showParametersPanel); |
704 |
stopButton.setEnabled(showParametersPanel); |
706 |
stopButton.setEnabled(showParametersPanel); |
705 |
final String description = ui.getDescription(); |
707 |
final String description = ui.getDescription(); |
706 |
setToolTipText("<html>" + description + "</html>"); // NOI18N |
708 |
setToolTipText("<html>" + description + "</html>"); // NOI18N |
707 |
final Collection<RefactoringElement> elements = session.getRefactoringElements(); |
709 |
final Collection<RefactoringElement> elements = session.getRefactoringElements(); |
708 |
setName(ui.getName()); |
710 |
setName(ui.getName()); |
709 |
if (ui instanceof RefactoringCustomUI) { |
711 |
if (ui instanceof RefactoringCustomUI) { |
710 |
if (customComponent==null) |
712 |
if (customComponent==null) { |
711 |
customComponent = ((RefactoringCustomUI) ui).getCustomComponent(elements); |
713 |
customComponent = ((RefactoringCustomUI) ui).getCustomComponent(elements); |
|
|
714 |
} |
712 |
this.left.remove(customComponent); |
715 |
this.left.remove(customComponent); |
713 |
} |
716 |
} |
714 |
final ProgressHandle progressHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(RefactoringPanel.class, isQuery ? "LBL_PreparingUsagesTree":"LBL_PreparingRefactoringTree")); |
717 |
final ProgressHandle progressHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(RefactoringPanel.class, isQuery ? "LBL_PreparingUsagesTree":"LBL_PreparingRefactoringTree")); |
Lines 726-732
Link Here
|
726 |
RP.post(new Runnable() { |
729 |
RP.post(new Runnable() { |
727 |
@Override |
730 |
@Override |
728 |
public void run() { |
731 |
public void run() { |
729 |
setTreeControlsEnabled(false); |
732 |
SwingUtilities.invokeLater(new Runnable() { |
|
|
733 |
@Override |
734 |
public void run() { |
735 |
setTreeControlsEnabled(false); |
736 |
} |
737 |
}); |
730 |
Set<FileObject> fileObjects = new HashSet<FileObject>(); |
738 |
Set<FileObject> fileObjects = new HashSet<FileObject>(); |
731 |
int errorsNum = 0; |
739 |
int errorsNum = 0; |
732 |
if (!isQuery) { |
740 |
if (!isQuery) { |
Lines 737-743
Link Here
|
737 |
} |
745 |
} |
738 |
} |
746 |
} |
739 |
} |
747 |
} |
740 |
StringBuffer errorsDesc = getErrorDesc(errorsNum, isQuery?size:elements.size()); |
748 |
StringBuffer errorsDesc = getErrorDesc(errorsNum, isQuery?size:elements.size(), 0); |
741 |
final CheckNode root = new CheckNode(ui, description + errorsDesc.toString() + " ",ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/api/resources/" + (isQuery ? "findusages.png" : "refactoring.gif"), false), isQuery); |
749 |
final CheckNode root = new CheckNode(ui, description + errorsDesc.toString() + " ",ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/api/resources/" + (isQuery ? "findusages.png" : "refactoring.gif"), false), isQuery); |
742 |
final Map<Object, CheckNode> nodes = new HashMap<Object, CheckNode>(); |
750 |
final Map<Object, CheckNode> nodes = new HashMap<Object, CheckNode>(); |
743 |
|
751 |
|
Lines 754-767
Link Here
|
754 |
} |
762 |
} |
755 |
|
763 |
|
756 |
int i=0; |
764 |
int i=0; |
|
|
765 |
int hidden = 0; |
757 |
try { |
766 |
try { |
758 |
//[retouche] JavaModel.getJavaRepository().beginTrans(false); |
767 |
//[retouche] JavaModel.getJavaRepository().beginTrans(false); |
759 |
try { |
768 |
try { |
760 |
// ui.getRefactoring().setClassPath(); |
769 |
// ui.getRefactoring().setClassPath(); |
761 |
for (Iterator it = elements.iterator(); it.hasNext();i++) { |
770 |
for (Iterator it = elements.iterator(); it.hasNext();i++) { |
762 |
final RefactoringElement e = (RefactoringElement) it.next(); |
771 |
final RefactoringElement e = (RefactoringElement) it.next(); |
763 |
createNode(TreeElementFactory.getTreeElement(e), nodes, root); |
772 |
if(e.include(filtersManager)) { |
764 |
|
773 |
createNode(TreeElementFactory.getTreeElement(e), nodes, root); |
|
|
774 |
} else { |
775 |
hidden++; |
776 |
} |
765 |
if (isQuery && showParametersPanel) { |
777 |
if (isQuery && showParametersPanel) { |
766 |
if (cancelRequest.get()) { |
778 |
if (cancelRequest.get()) { |
767 |
break; |
779 |
break; |
Lines 769-781
Link Here
|
769 |
|
781 |
|
770 |
final boolean last = !it.hasNext(); |
782 |
final boolean last = !it.hasNext(); |
771 |
final int occurrences = i + 1; |
783 |
final int occurrences = i + 1; |
|
|
784 |
final int hiddenOccurrences = hidden; |
772 |
size = occurrences; |
785 |
size = occurrences; |
773 |
if (occurrences % 10 == 0 || last) { |
786 |
if ((occurrences % 10 == 0 && !session.isFinished()) || last) { |
774 |
SwingUtilities.invokeLater(new Runnable() { |
787 |
SwingUtilities.invokeLater(new Runnable() { |
775 |
|
788 |
|
776 |
@Override |
789 |
@Override |
777 |
public void run() { |
790 |
public void run() { |
778 |
root.setNodeLabel(description + getErrorDesc(0, occurrences)); |
791 |
root.setNodeLabel(description + getErrorDesc(0, occurrences, hiddenOccurrences)); |
779 |
if (last) { |
792 |
if (last) { |
780 |
tree.repaint(); |
793 |
tree.repaint(); |
781 |
} |
794 |
} |
Lines 783-789
Link Here
|
783 |
}); |
796 |
}); |
784 |
} |
797 |
} |
785 |
} |
798 |
} |
786 |
PositionBounds pb = e.getPosition(); |
799 |
// PositionBounds pb = e.getPosition(); |
787 |
fileObjects.add(e.getParentFile()); |
800 |
fileObjects.add(e.getParentFile()); |
788 |
|
801 |
|
789 |
if (!isQuery) { |
802 |
if (!isQuery) { |
Lines 807-828
Link Here
|
807 |
} finally { |
820 |
} finally { |
808 |
progressHandle.finish(); |
821 |
progressHandle.finish(); |
809 |
cont.makeBusy(false); |
822 |
cont.makeBusy(false); |
810 |
setTreeControlsEnabled(true); |
|
|
811 |
SwingUtilities.invokeLater(new Runnable() { |
823 |
SwingUtilities.invokeLater(new Runnable() { |
812 |
@Override |
824 |
@Override |
813 |
public void run() { |
825 |
public void run() { |
|
|
826 |
setTreeControlsEnabled(true); |
814 |
stopButton.setEnabled(false); |
827 |
stopButton.setEnabled(false); |
|
|
828 |
stopButton.setVisible(false); |
829 |
refreshButton.setVisible(true); |
830 |
if(showParametersPanel) { |
831 |
updateFilters(); |
832 |
} |
815 |
} |
833 |
} |
816 |
}); |
834 |
}); |
817 |
} |
835 |
} |
818 |
|
836 |
|
819 |
if (!(isQuery && showParametersPanel)) { |
837 |
if (!(isQuery && showParametersPanel)) { |
|
|
838 |
root.setNodeLabel(description + getErrorDesc(errorsNum, isQuery?size:elements.size(), hidden).toString()); |
820 |
setupTree(root, showParametersPanel, elements.size()); |
839 |
setupTree(root, showParametersPanel, elements.size()); |
821 |
} |
840 |
} |
822 |
|
841 |
|
823 |
} |
842 |
} |
824 |
|
843 |
|
825 |
private StringBuffer getErrorDesc(int errorsNum, int occurencesNum) throws MissingResourceException { |
844 |
private StringBuffer getErrorDesc(int errorsNum, int occurencesNum, int hiddenNum) throws MissingResourceException { |
826 |
StringBuffer errorsDesc = new StringBuffer(); |
845 |
StringBuffer errorsDesc = new StringBuffer(); |
827 |
errorsDesc.append(" [").append(occurencesNum); // NOI18N |
846 |
errorsDesc.append(" [").append(occurencesNum); // NOI18N |
828 |
errorsDesc.append(' '); |
847 |
errorsDesc.append(' '); |
Lines 841-846
Link Here
|
841 |
); |
860 |
); |
842 |
errorsDesc.append("</font>"); // NOI18N |
861 |
errorsDesc.append("</font>"); // NOI18N |
843 |
} |
862 |
} |
|
|
863 |
if (hiddenNum > 0) { |
864 |
errorsDesc.append(','); |
865 |
errorsDesc.append(' '); |
866 |
errorsDesc.append("<font color=#CC0000>").append(hiddenNum); // NOI18N |
867 |
errorsDesc.append(' '); |
868 |
errorsDesc.append(NbBundle.getMessage(RefactoringPanel.class, "LBL_Hidden")); |
869 |
errorsDesc.append("</font>"); // NOI18N |
870 |
} |
844 |
errorsDesc.append(']'); |
871 |
errorsDesc.append(']'); |
845 |
return errorsDesc; |
872 |
return errorsDesc; |
846 |
} |
873 |
} |
Lines 857-878
Link Here
|
857 |
cont.addPanel(this); |
884 |
cont.addPanel(this); |
858 |
isVisible = true; |
885 |
isVisible = true; |
859 |
} |
886 |
} |
860 |
if (!isQuery) |
887 |
if (!isQuery) { |
861 |
setRefactoringEnabled(false, true); |
888 |
setRefactoringEnabled(false, true); |
|
|
889 |
} |
862 |
} |
890 |
} |
863 |
|
891 |
|
864 |
private void setTreeControlsEnabled(final boolean b) { |
892 |
private void setTreeControlsEnabled(final boolean b) { |
865 |
SwingUtilities.invokeLater(new Runnable() { |
893 |
expandButton.setEnabled(b); |
866 |
|
894 |
logicalViewButton.setEnabled(b); |
867 |
@Override |
895 |
physicalViewButton.setEnabled(b); |
868 |
public void run() { |
896 |
if (customViewButton != null) { |
869 |
expandButton.setEnabled(b); |
897 |
customViewButton.setEnabled(b); |
870 |
logicalViewButton.setEnabled(b); |
898 |
} |
871 |
physicalViewButton.setEnabled(b); |
|
|
872 |
if (customViewButton != null) |
873 |
customViewButton.setEnabled(b); |
874 |
} |
875 |
}); |
876 |
} |
899 |
} |
877 |
|
900 |
|
878 |
|
901 |
|
Lines 923-943
Link Here
|
923 |
} |
946 |
} |
924 |
} |
947 |
} |
925 |
|
948 |
|
926 |
/** |
949 |
/** |
927 |
* @return true if timestamps are OK |
950 |
* @return true if timestamps are OK |
928 |
*/ |
951 |
*/ |
929 |
private boolean checkTimeStamps() { |
952 |
private boolean checkTimeStamps() { |
930 |
Set<FileObject> modified = getModifiedFileObjects(); |
953 |
Set<FileObject> modified = getModifiedFileObjects(); |
931 |
for (Entry<FileObject, Long> entry: timeStamps.entrySet()) { |
954 |
for (Entry<FileObject, Long> entry: timeStamps.entrySet()) { |
932 |
if (modified.contains(entry.getKey())) |
955 |
if (modified.contains(entry.getKey())) |
933 |
return false; |
956 |
return false; |
934 |
if (!entry.getKey().isValid()) |
957 |
if (!entry.getKey().isValid()) |
935 |
return false; |
958 |
return false; |
936 |
if (entry.getKey().lastModified().getTime() != entry.getValue()) |
959 |
if (entry.getKey().lastModified().getTime() != entry.getValue()) |
937 |
return false; |
960 |
return false; |
938 |
} |
961 |
} |
939 |
return true; |
962 |
return true; |
940 |
} |
963 |
} |
941 |
|
964 |
|
942 |
private Set<FileObject> getModifiedFileObjects() { |
965 |
private Set<FileObject> getModifiedFileObjects() { |
943 |
Set<FileObject> result = new HashSet(); |
966 |
Set<FileObject> result = new HashSet(); |
Lines 997-1004
Link Here
|
997 |
if (refactorButton != null) { |
1020 |
if (refactorButton != null) { |
998 |
refactorButton.requestFocus(); |
1021 |
refactorButton.requestFocus(); |
999 |
} else { |
1022 |
} else { |
1000 |
if (tree!=null) |
1023 |
if (tree!=null) { |
1001 |
tree.requestFocus(); |
1024 |
tree.requestFocus(); |
|
|
1025 |
} |
1002 |
} |
1026 |
} |
1003 |
} |
1027 |
} |
1004 |
|
1028 |
|
Lines 1046-1058
Link Here
|
1046 |
|
1070 |
|
1047 |
private int location; |
1071 |
private int location; |
1048 |
public void storeDividerLocation() { |
1072 |
public void storeDividerLocation() { |
1049 |
if (splitPane.getRightComponent()!=null) |
1073 |
if (splitPane.getRightComponent()!=null) { |
1050 |
location = splitPane.getDividerLocation(); |
1074 |
location = splitPane.getDividerLocation(); |
|
|
1075 |
} |
1051 |
} |
1076 |
} |
1052 |
|
1077 |
|
1053 |
public void restoreDeviderLocation() { |
1078 |
public void restoreDeviderLocation() { |
1054 |
if (splitPane.getRightComponent()!=null) |
1079 |
if (splitPane.getRightComponent()!=null) { |
1055 |
splitPane.setDividerLocation(location); |
1080 |
splitPane.setDividerLocation(location); |
|
|
1081 |
} |
1056 |
} |
1082 |
} |
1057 |
|
1083 |
|
1058 |
private byte getPrefViewType() { |
1084 |
private byte getPrefViewType() { |
Lines 1066-1071
Link Here
|
1066 |
prefs.putInt(PREF_VIEW_TYPE, currentView); |
1092 |
prefs.putInt(PREF_VIEW_TYPE, currentView); |
1067 |
} |
1093 |
} |
1068 |
|
1094 |
|
|
|
1095 |
private void updateFilters() { |
1096 |
if(!ui.isQuery()) { |
1097 |
if(filterBar != null) { |
1098 |
toolbars.remove(filterBar); |
1099 |
filterBar = null; |
1100 |
filtersManager = null; |
1101 |
} |
1102 |
return; |
1103 |
} |
1104 |
|
1105 |
if(filtersManager != null) { |
1106 |
toolbars.remove(filterBar); |
1107 |
filterBar = null; |
1108 |
filtersManager = null; |
1109 |
} |
1110 |
final FiltersDescription desc = ui.getRefactoring().getFiltersDescription(); |
1111 |
filtersManager = FiltersManagerImpl.create(desc == null? new FiltersDescription() : desc); |
1112 |
filterBar = filtersManager.getComponent(); |
1113 |
toolbars.add(filterBar, BorderLayout.EAST); |
1114 |
filtersManager.hookChangeListener(this); |
1115 |
toolbars.validate(); |
1116 |
} |
1117 |
|
1118 |
@Override |
1119 |
public void filterStateChanged(ChangeEvent e) { |
1120 |
refresh(false); |
1121 |
} |
1122 |
|
1069 |
//////////////////////////////////////////////////////////////////////////// |
1123 |
//////////////////////////////////////////////////////////////////////////// |
1070 |
// INNER CLASSES |
1124 |
// INNER CLASSES |
1071 |
//////////////////////////////////////////////////////////////////////////// |
1125 |
//////////////////////////////////////////////////////////////////////////// |
Lines 1085-1094
Link Here
|
1085 |
} |
1139 |
} |
1086 |
// expandAll button selected/deselected |
1140 |
// expandAll button selected/deselected |
1087 |
else if (o == expandButton && tree != null) { |
1141 |
else if (o == expandButton && tree != null) { |
1088 |
if (expandButton.isSelected()) |
1142 |
if (expandButton.isSelected()) { |
1089 |
expandAll(); |
1143 |
expandAll(); |
1090 |
else |
1144 |
} else { |
1091 |
collapseAll(); |
1145 |
collapseAll(); |
|
|
1146 |
} |
1092 |
} else if (o == refreshButton) { |
1147 |
} else if (o == refreshButton) { |
1093 |
if (callback!=null) { |
1148 |
if (callback!=null) { |
1094 |
close(); |
1149 |
close(); |
Lines 1116-1121
Link Here
|
1116 |
|
1171 |
|
1117 |
private void stopSearch() { |
1172 |
private void stopSearch() { |
1118 |
stopButton.setEnabled(false); |
1173 |
stopButton.setEnabled(false); |
|
|
1174 |
stopButton.setVisible(false); |
1175 |
refreshButton.setVisible(true); |
1119 |
cancelRequest.set(true); |
1176 |
cancelRequest.set(true); |
1120 |
ui.getRefactoring().cancelRequest(); |
1177 |
ui.getRefactoring().cancelRequest(); |
1121 |
} |
1178 |
} |