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