Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 18-41
Link Here
|
18 |
import java.util.Comparator; |
18 |
import java.util.Comparator; |
19 |
import java.util.List; |
19 |
import java.util.List; |
20 |
|
20 |
|
21 |
import org.eclipse.core.resources.IContainer; |
21 |
import com.ibm.icu.text.Collator; |
22 |
import org.eclipse.core.resources.IResource; |
22 |
|
23 |
import org.eclipse.core.resources.IResourceProxy; |
23 |
import org.eclipse.swt.SWT; |
24 |
import org.eclipse.core.resources.IResourceProxyVisitor; |
24 |
import org.eclipse.swt.graphics.Font; |
25 |
import org.eclipse.core.resources.IWorkspace; |
25 |
import org.eclipse.swt.graphics.FontData; |
26 |
import org.eclipse.core.resources.ResourcesPlugin; |
26 |
import org.eclipse.swt.graphics.Image; |
|
|
27 |
import org.eclipse.swt.graphics.TextStyle; |
28 |
import org.eclipse.swt.widgets.Composite; |
29 |
import org.eclipse.swt.widgets.Control; |
30 |
import org.eclipse.swt.widgets.Shell; |
31 |
|
27 |
import org.eclipse.core.runtime.CoreException; |
32 |
import org.eclipse.core.runtime.CoreException; |
28 |
import org.eclipse.core.runtime.IPath; |
33 |
import org.eclipse.core.runtime.IPath; |
29 |
import org.eclipse.core.runtime.IProgressMonitor; |
34 |
import org.eclipse.core.runtime.IProgressMonitor; |
30 |
import org.eclipse.core.runtime.IStatus; |
35 |
import org.eclipse.core.runtime.IStatus; |
31 |
import org.eclipse.core.runtime.ListenerList; |
36 |
import org.eclipse.core.runtime.ListenerList; |
32 |
import org.eclipse.core.runtime.Status; |
37 |
import org.eclipse.core.runtime.Status; |
|
|
38 |
|
39 |
import org.eclipse.core.resources.IContainer; |
40 |
import org.eclipse.core.resources.IResource; |
41 |
import org.eclipse.core.resources.IResourceProxy; |
42 |
import org.eclipse.core.resources.IResourceProxyVisitor; |
43 |
import org.eclipse.core.resources.IWorkspace; |
44 |
import org.eclipse.core.resources.ResourcesPlugin; |
45 |
|
33 |
import org.eclipse.jface.action.Action; |
46 |
import org.eclipse.jface.action.Action; |
34 |
import org.eclipse.jface.action.IAction; |
47 |
import org.eclipse.jface.action.IAction; |
35 |
import org.eclipse.jface.action.IMenuManager; |
48 |
import org.eclipse.jface.action.IMenuManager; |
36 |
import org.eclipse.jface.action.Separator; |
49 |
import org.eclipse.jface.action.Separator; |
37 |
import org.eclipse.jface.dialogs.IDialogSettings; |
50 |
import org.eclipse.jface.dialogs.IDialogSettings; |
38 |
import org.eclipse.jface.text.ITextSelection; |
|
|
39 |
import org.eclipse.jface.util.IPropertyChangeListener; |
51 |
import org.eclipse.jface.util.IPropertyChangeListener; |
40 |
import org.eclipse.jface.util.PropertyChangeEvent; |
52 |
import org.eclipse.jface.util.PropertyChangeEvent; |
41 |
import org.eclipse.jface.viewers.ILabelProviderListener; |
53 |
import org.eclipse.jface.viewers.ILabelProviderListener; |
Lines 46-55
Link Here
|
46 |
import org.eclipse.jface.viewers.Viewer; |
58 |
import org.eclipse.jface.viewers.Viewer; |
47 |
import org.eclipse.jface.viewers.ViewerFilter; |
59 |
import org.eclipse.jface.viewers.ViewerFilter; |
48 |
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; |
60 |
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; |
49 |
import org.eclipse.swt.graphics.Image; |
61 |
import org.eclipse.jface.viewers.StyledString.Styler; |
50 |
import org.eclipse.swt.widgets.Composite; |
62 |
|
51 |
import org.eclipse.swt.widgets.Control; |
63 |
import org.eclipse.jface.text.ITextSelection; |
52 |
import org.eclipse.swt.widgets.Shell; |
64 |
|
53 |
import org.eclipse.ui.IMemento; |
65 |
import org.eclipse.ui.IMemento; |
54 |
import org.eclipse.ui.IWorkbenchPage; |
66 |
import org.eclipse.ui.IWorkbenchPage; |
55 |
import org.eclipse.ui.IWorkbenchWindow; |
67 |
import org.eclipse.ui.IWorkbenchWindow; |
Lines 68-75
Link Here
|
68 |
import org.eclipse.ui.model.WorkbenchLabelProvider; |
80 |
import org.eclipse.ui.model.WorkbenchLabelProvider; |
69 |
import org.eclipse.ui.statushandlers.StatusManager; |
81 |
import org.eclipse.ui.statushandlers.StatusManager; |
70 |
|
82 |
|
71 |
import com.ibm.icu.text.Collator; |
|
|
72 |
|
73 |
/** |
83 |
/** |
74 |
* Shows a list of resources to the user with a text entry field for a string |
84 |
* Shows a list of resources to the user with a text entry field for a string |
75 |
* pattern used to filter the list of resources. |
85 |
* pattern used to filter the list of resources. |
Lines 103-108
Link Here
|
103 |
|
113 |
|
104 |
private boolean isDerived; |
114 |
private boolean isDerived; |
105 |
|
115 |
|
|
|
116 |
private SearchPattern searchPattern; |
117 |
|
106 |
/** |
118 |
/** |
107 |
* Creates a new instance of the class |
119 |
* Creates a new instance of the class |
108 |
* |
120 |
* |
Lines 377-383
Link Here
|
377 |
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter() |
389 |
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter() |
378 |
*/ |
390 |
*/ |
379 |
protected ItemsFilter createFilter() { |
391 |
protected ItemsFilter createFilter() { |
380 |
return new ResourceFilter(container, isDerived, typeMask); |
392 |
ItemsFilter filter= new ResourceFilter(container, isDerived, typeMask); |
|
|
393 |
searchPattern= filter.getPatternMatcher(); |
394 |
return filter; |
381 |
} |
395 |
} |
382 |
|
396 |
|
383 |
/* (non-Javadoc) |
397 |
/* (non-Javadoc) |
Lines 478-489
Link Here
|
478 |
|
492 |
|
479 |
WorkbenchLabelProvider provider = new WorkbenchLabelProvider(); |
493 |
WorkbenchLabelProvider provider = new WorkbenchLabelProvider(); |
480 |
|
494 |
|
|
|
495 |
private Font fBoldFont; |
496 |
|
497 |
private Styler boldStyler; |
498 |
|
499 |
private Styler boldQualifierStyler; |
500 |
|
501 |
|
481 |
/** |
502 |
/** |
482 |
* Creates a new instance of the class |
503 |
* Creates a new instance of the class |
483 |
*/ |
504 |
*/ |
484 |
public ResourceItemLabelProvider() { |
505 |
public ResourceItemLabelProvider() { |
485 |
super(); |
506 |
super(); |
486 |
provider.addListener(this); |
507 |
provider.addListener(this); |
|
|
508 |
boldStyler= createBoldStyler(); |
509 |
boldQualifierStyler= createBoldQualifierStyler(); |
487 |
} |
510 |
} |
488 |
|
511 |
|
489 |
/* |
512 |
/* |
Lines 533-548
Link Here
|
533 |
|
556 |
|
534 |
IResource res = (IResource) element; |
557 |
IResource res = (IResource) element; |
535 |
|
558 |
|
|
|
559 |
String name= res.getName(); |
536 |
StyledString str = new StyledString(res.getName()); |
560 |
StyledString str = new StyledString(res.getName()); |
|
|
561 |
markMatchingRegions(str, 0, searchPattern.getMatchingRegions(name), boldStyler); |
537 |
|
562 |
|
538 |
// extra info for duplicates |
563 |
// extra info for duplicates |
539 |
if (isDuplicateElement(element)) { |
564 |
if (isDuplicateElement(element)) { |
540 |
str.append(" - ", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$ |
565 |
str.append(" - ", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$ |
541 |
str.append(res.getParent().getFullPath().makeRelative().toString(), StyledString.QUALIFIER_STYLER); |
566 |
final String fullPath= res.getParent().getFullPath().makeRelative().toString(); |
|
|
567 |
int index= str.length(); |
568 |
str.append(fullPath, StyledString.QUALIFIER_STYLER); |
569 |
markMatchingRegions(str, index, searchPattern.getMatchingRegions(fullPath), boldQualifierStyler); |
542 |
} |
570 |
} |
543 |
return str; |
571 |
return str; |
544 |
} |
572 |
} |
545 |
|
573 |
|
|
|
574 |
private void markMatchingRegions(StyledString string, int index, int[] matchingRegions, Styler styler) { |
575 |
if (matchingRegions != null) { |
576 |
for (int i= 0; i + 1 < matchingRegions.length; i= i + 2) |
577 |
string.setStyle(index + matchingRegions[i], matchingRegions[i + 1], styler); |
578 |
} |
579 |
} |
580 |
|
581 |
private Styler createBoldStyler() { |
582 |
return new Styler() { |
583 |
public void applyStyles(TextStyle textStyle) { |
584 |
textStyle.font= getBoldFont(); |
585 |
} |
586 |
}; |
587 |
} |
588 |
|
589 |
private Styler createBoldQualifierStyler() { |
590 |
return new Styler() { |
591 |
public void applyStyles(TextStyle textStyle) { |
592 |
StyledString.QUALIFIER_STYLER.applyStyles(textStyle); |
593 |
textStyle.font= getBoldFont(); |
594 |
} |
595 |
}; |
596 |
} |
597 |
|
598 |
|
599 |
/** |
600 |
* Create the bold variant of the currently used font. |
601 |
* |
602 |
* @return the bold font |
603 |
* @since 3.5 |
604 |
*/ |
605 |
private Font getBoldFont() { |
606 |
if (fBoldFont == null) { |
607 |
Font font= getDialogArea().getFont(); |
608 |
FontData[] data= font.getFontData(); |
609 |
for (int i= 0; i < data.length; i++) { |
610 |
data[i].setStyle(SWT.BOLD); |
611 |
} |
612 |
fBoldFont= new Font(font.getDevice(), data); |
613 |
} |
614 |
return fBoldFont; |
615 |
} |
616 |
|
546 |
/* |
617 |
/* |
547 |
* (non-Javadoc) |
618 |
* (non-Javadoc) |
548 |
* |
619 |
* |