mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56:02 +02:00
Fix warnings.
This commit is contained in:
parent
02686bc022
commit
772a60e5b6
60 changed files with 671 additions and 826 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -43,7 +42,7 @@ public class Checksums {
|
||||||
* @throws NoSuchAlgorithmException
|
* @throws NoSuchAlgorithmException
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static MessageDigest getAlgorithm(Map persistedMap) throws NoSuchAlgorithmException {
|
public static MessageDigest getAlgorithm(Map<String, Object> persistedMap) throws NoSuchAlgorithmException {
|
||||||
Object obj= persistedMap.get(KEY_ALGORITHM);
|
Object obj= persistedMap.get(KEY_ALGORITHM);
|
||||||
String alg= obj instanceof String ? (String) obj : DEFAULT_ALGORITHM;
|
String alg= obj instanceof String ? (String) obj : DEFAULT_ALGORITHM;
|
||||||
return MessageDigest.getInstance(alg);
|
return MessageDigest.getInstance(alg);
|
||||||
|
@ -53,7 +52,7 @@ public class Checksums {
|
||||||
* Stores the algorithm in a map.
|
* Stores the algorithm in a map.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static void putAlgorithm(Map mapToPersist, MessageDigest md) {
|
public static void putAlgorithm(Map<String, Object> mapToPersist, MessageDigest md) {
|
||||||
mapToPersist.put(KEY_ALGORITHM, md.getAlgorithm());
|
mapToPersist.put(KEY_ALGORITHM, md.getAlgorithm());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,12 +80,11 @@ public class Checksums {
|
||||||
* Retrieves a checksum for a file from the persisted map. May return <code>null</code>.
|
* Retrieves a checksum for a file from the persisted map. May return <code>null</code>.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static byte[] getChecksum(Map persistedMap, IFile file) {
|
public static byte[] getChecksum(Map<String, Object> persistedMap, IFile file) {
|
||||||
IPath prjRel= file.getProjectRelativePath();
|
IPath prjRel= file.getProjectRelativePath();
|
||||||
Object checksum= persistedMap.get(prjRel.toString());
|
Object checksum= persistedMap.get(prjRel.toString());
|
||||||
if (checksum instanceof byte[]) {
|
if (checksum instanceof byte[])
|
||||||
return (byte[]) checksum;
|
return (byte[]) checksum;
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +92,7 @@ public class Checksums {
|
||||||
* Stores a checksum in a map.
|
* Stores a checksum in a map.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static void putChecksum(Map mapToPersist, IFile file, byte[] checksum) {
|
public static void putChecksum(Map<String, Object> mapToPersist, IFile file, byte[] checksum) {
|
||||||
IPath prjRel= file.getProjectRelativePath();
|
IPath prjRel= file.getProjectRelativePath();
|
||||||
mapToPersist.put(prjRel.toString(), checksum);
|
mapToPersist.put(prjRel.toString(), checksum);
|
||||||
}
|
}
|
||||||
|
@ -104,16 +102,15 @@ public class Checksums {
|
||||||
* @throws OperationCanceledException
|
* @throws OperationCanceledException
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static Map createChecksumMap(IFile[] tus, MessageDigest md, IProgressMonitor pm)
|
public static Map<String, Object> createChecksumMap(IFile[] tus, MessageDigest md, IProgressMonitor pm)
|
||||||
throws OperationCanceledException {
|
throws OperationCanceledException {
|
||||||
Map result= new HashMap();
|
Map<String, Object> result= new HashMap<String, Object>();
|
||||||
putAlgorithm(result, md);
|
putAlgorithm(result, md);
|
||||||
pm.beginTask(Messages.Checksums_taskComputeChecksums, tus.length);
|
pm.beginTask(Messages.Checksums_taskComputeChecksums, tus.length);
|
||||||
for (int i = 0; i < tus.length; i++) {
|
for (IFile file : tus) {
|
||||||
if (pm.isCanceled()) {
|
if (pm.isCanceled()) {
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
}
|
}
|
||||||
IFile file = tus[i];
|
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
IPath location= file.getLocation();
|
IPath location= file.getLocation();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class CHHistoryListAction extends Action {
|
||||||
|
|
||||||
private class HistoryListDialog extends StatusDialog {
|
private class HistoryListDialog extends StatusDialog {
|
||||||
|
|
||||||
private ListDialogField fHistoryList;
|
private ListDialogField<ICElement> fHistoryList;
|
||||||
private IStatus fHistoryStatus;
|
private IStatus fHistoryStatus;
|
||||||
private ICElement fResult;
|
private ICElement fResult;
|
||||||
|
|
||||||
|
@ -53,22 +53,22 @@ public class CHHistoryListAction extends Action {
|
||||||
CHMessages.CHHistoryListAction_Remove_label,
|
CHMessages.CHHistoryListAction_Remove_label,
|
||||||
};
|
};
|
||||||
|
|
||||||
IListAdapter adapter= new IListAdapter() {
|
IListAdapter<ICElement> adapter= new IListAdapter<ICElement>() {
|
||||||
public void customButtonPressed(ListDialogField field, int index) {
|
public void customButtonPressed(ListDialogField<ICElement> field, int index) {
|
||||||
doCustomButtonPressed();
|
doCustomButtonPressed();
|
||||||
}
|
}
|
||||||
public void selectionChanged(ListDialogField field) {
|
public void selectionChanged(ListDialogField<ICElement> field) {
|
||||||
doSelectionChanged();
|
doSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doubleClicked(ListDialogField field) {
|
public void doubleClicked(ListDialogField<ICElement> field) {
|
||||||
doDoubleClicked();
|
doDoubleClicked();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LabelProvider labelProvider= new CUILabelProvider(CHHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS);
|
LabelProvider labelProvider= new CUILabelProvider(CHHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS);
|
||||||
|
|
||||||
fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
|
fHistoryList= new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider);
|
||||||
fHistoryList.setLabelText(CHMessages.CHHistoryListAction_HistoryList_label);
|
fHistoryList.setLabelText(CHMessages.CHHistoryListAction_HistoryList_label);
|
||||||
fHistoryList.setElements(Arrays.asList(historyEntries));
|
fHistoryList.setElements(Arrays.asList(historyEntries));
|
||||||
|
|
||||||
|
@ -121,12 +121,12 @@ public class CHHistoryListAction extends Action {
|
||||||
|
|
||||||
private void doSelectionChanged() {
|
private void doSelectionChanged() {
|
||||||
StatusInfo status= new StatusInfo();
|
StatusInfo status= new StatusInfo();
|
||||||
List<?> selected= fHistoryList.getSelectedElements();
|
List<ICElement> selected= fHistoryList.getSelectedElements();
|
||||||
if (selected.size() != 1) {
|
if (selected.size() != 1) {
|
||||||
status.setError(""); //$NON-NLS-1$
|
status.setError(""); //$NON-NLS-1$
|
||||||
fResult= null;
|
fResult= null;
|
||||||
} else {
|
} else {
|
||||||
fResult= (ICElement) selected.get(0);
|
fResult= selected.get(0);
|
||||||
}
|
}
|
||||||
fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
|
fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
|
||||||
fHistoryStatus= status;
|
fHistoryStatus= status;
|
||||||
|
@ -138,7 +138,7 @@ public class CHHistoryListAction extends Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICElement[] getRemaining() {
|
public ICElement[] getRemaining() {
|
||||||
List<?> elems= fHistoryList.getElements();
|
List<ICElement> elems= fHistoryList.getElements();
|
||||||
return elems.toArray(new ICElement[elems.size()]);
|
return elems.toArray(new ICElement[elems.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.internal.ui.dnd;
|
package org.eclipse.cdt.internal.ui.dnd;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
@ -52,8 +51,7 @@ public class DelegatingDragAdapter implements DragSourceListener {
|
||||||
List<Transfer> transfers= new ArrayList<Transfer>(fPossibleListeners.length);
|
List<Transfer> transfers= new ArrayList<Transfer>(fPossibleListeners.length);
|
||||||
fActiveListeners= new ArrayList<TransferDragSourceListener>(fPossibleListeners.length);
|
fActiveListeners= new ArrayList<TransferDragSourceListener>(fPossibleListeners.length);
|
||||||
|
|
||||||
for (int i= 0; i < fPossibleListeners.length; i++) {
|
for (TransferDragSourceListener listener : fPossibleListeners) {
|
||||||
TransferDragSourceListener listener= fPossibleListeners[i];
|
|
||||||
event.doit= saveDoit;
|
event.doit= saveDoit;
|
||||||
listener.dragStart(event);
|
listener.dragStart(event);
|
||||||
if (event.doit) {
|
if (event.doit) {
|
||||||
|
@ -74,9 +72,10 @@ public class DelegatingDragAdapter implements DragSourceListener {
|
||||||
*/
|
*/
|
||||||
public void dragSetData(DragSourceEvent event) {
|
public void dragSetData(DragSourceEvent event) {
|
||||||
fFinishListener= getListener(event.dataType);
|
fFinishListener= getListener(event.dataType);
|
||||||
if (fFinishListener != null)
|
if (fFinishListener != null) {
|
||||||
fFinishListener.dragSetData(event);
|
fFinishListener.dragSetData(event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* non Java-doc
|
/* non Java-doc
|
||||||
* @see DragSourceListener
|
* @see DragSourceListener
|
||||||
|
@ -89,9 +88,10 @@ public class DelegatingDragAdapter implements DragSourceListener {
|
||||||
// If the user presses Escape then we get a dragFinished without
|
// If the user presses Escape then we get a dragFinished without
|
||||||
// getting a dragSetData before.
|
// getting a dragSetData before.
|
||||||
fFinishListener= getListener(event.dataType);
|
fFinishListener= getListener(event.dataType);
|
||||||
if (fFinishListener != null)
|
if (fFinishListener != null) {
|
||||||
fFinishListener.dragFinished(event);
|
fFinishListener.dragFinished(event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} finally{
|
} finally{
|
||||||
fFinishListener= null;
|
fFinishListener= null;
|
||||||
fActiveListeners= null;
|
fActiveListeners= null;
|
||||||
|
@ -102,12 +102,10 @@ public class DelegatingDragAdapter implements DragSourceListener {
|
||||||
if (type == null)
|
if (type == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
for (Iterator iter= fActiveListeners.iterator(); iter.hasNext();) {
|
for (TransferDragSourceListener listener : fActiveListeners) {
|
||||||
TransferDragSourceListener listener= (TransferDragSourceListener)iter.next();
|
if (listener.getTransfer().isSupportedType(type))
|
||||||
if (listener.getTransfer().isSupportedType(type)) {
|
|
||||||
return listener;
|
return listener;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,15 +81,13 @@ public class FileTransferDragAdapter implements TransferDragSourceListener {
|
||||||
private static class RefreshOperation extends WorkspaceModifyOperation {
|
private static class RefreshOperation extends WorkspaceModifyOperation {
|
||||||
private final Set<IResource> roots;
|
private final Set<IResource> roots;
|
||||||
|
|
||||||
public RefreshOperation(List resources) {
|
public RefreshOperation(List<IResource> resources) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
roots = new HashSet<IResource>(resources.size());
|
roots = new HashSet<IResource>(resources.size());
|
||||||
|
|
||||||
for (Iterator iterator = resources.iterator(); iterator.hasNext();) {
|
for (IResource resource : resources) {
|
||||||
IResource resource = (IResource) iterator.next();
|
|
||||||
IResource parent = resource.getParent();
|
IResource parent = resource.getParent();
|
||||||
|
|
||||||
roots.add(parent != null ? parent : resource);
|
roots.add(parent != null ? parent : resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,9 +98,7 @@ public class FileTransferDragAdapter implements TransferDragSourceListener {
|
||||||
monitor.beginTask(CUIMessages.getString("FileTransferDragAdapter.refreshing"), roots.size()); //$NON-NLS-1$
|
monitor.beginTask(CUIMessages.getString("FileTransferDragAdapter.refreshing"), roots.size()); //$NON-NLS-1$
|
||||||
MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, CUIMessages.getString("FileTransferDragAdapter.problem"), null); //$NON-NLS-1$
|
MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, CUIMessages.getString("FileTransferDragAdapter.problem"), null); //$NON-NLS-1$
|
||||||
|
|
||||||
for (Iterator iterator = roots.iterator(); iterator.hasNext();) {
|
for (IResource resource : roots) {
|
||||||
IResource resource = (IResource) iterator.next();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resource.refreshLocal(
|
resource.refreshLocal(
|
||||||
IResource.DEPTH_ONE,
|
IResource.DEPTH_ONE,
|
||||||
|
@ -120,7 +116,7 @@ public class FileTransferDragAdapter implements TransferDragSourceListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List getResources() {
|
private List<IResource> getResources() {
|
||||||
List<IResource> result = Collections.emptyList();
|
List<IResource> result = Collections.emptyList();
|
||||||
ISelection selection = provider.getSelection();
|
ISelection selection = provider.getSelection();
|
||||||
|
|
||||||
|
@ -129,7 +125,7 @@ public class FileTransferDragAdapter implements TransferDragSourceListener {
|
||||||
|
|
||||||
result = new ArrayList<IResource>(structured.size());
|
result = new ArrayList<IResource>(structured.size());
|
||||||
|
|
||||||
for (Iterator iterator = structured.iterator(); iterator.hasNext();) {
|
for (Iterator<?> iterator = structured.iterator(); iterator.hasNext();) {
|
||||||
Object object = iterator.next();
|
Object object = iterator.next();
|
||||||
IResource resource = null;
|
IResource resource = null;
|
||||||
|
|
||||||
|
@ -147,13 +143,12 @@ public class FileTransferDragAdapter implements TransferDragSourceListener {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] getResourceLocations(List resources) {
|
private static String[] getResourceLocations(List<IResource> resources) {
|
||||||
if (!resources.isEmpty()) {
|
if (!resources.isEmpty()) {
|
||||||
int count = resources.size();
|
int count = resources.size();
|
||||||
List<String> locations = new ArrayList<String>(count);
|
List<String> locations = new ArrayList<String>(count);
|
||||||
|
|
||||||
for (Iterator iterator = resources.iterator(); iterator.hasNext();) {
|
for (IResource resource : resources) {
|
||||||
IResource resource = (IResource) iterator.next();
|
|
||||||
IPath location = resource.getLocation();
|
IPath location = resource.getLocation();
|
||||||
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class ResourceTransferDragAdapter implements TransferDragSourceListener {
|
||||||
|
|
||||||
resources = new ArrayList<IResource>(structured.size());
|
resources = new ArrayList<IResource>(structured.size());
|
||||||
|
|
||||||
for (Iterator iterator = structured.iterator(); iterator.hasNext();) {
|
for (Iterator<?> iterator = structured.iterator(); iterator.hasNext();) {
|
||||||
Object element = iterator.next();
|
Object element = iterator.next();
|
||||||
IResource resource = null;
|
IResource resource = null;
|
||||||
if (element instanceof IResource) {
|
if (element instanceof IResource) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class ResourceTransferDropAdapter extends CDTViewerDropAdapter implements
|
||||||
.getSelection();
|
.getSelection();
|
||||||
if (selection instanceof IStructuredSelection) {
|
if (selection instanceof IStructuredSelection) {
|
||||||
IStructuredSelection ssel = (IStructuredSelection) selection;
|
IStructuredSelection ssel = (IStructuredSelection) selection;
|
||||||
for (Iterator i = ssel.iterator(); i.hasNext();) {
|
for (Iterator<?> i = ssel.iterator(); i.hasNext();) {
|
||||||
Object o = i.next();
|
Object o = i.next();
|
||||||
if (o instanceof IResource) {
|
if (o instanceof IResource) {
|
||||||
selectedResources.add((IResource) o);
|
selectedResources.add((IResource) o);
|
||||||
|
|
|
@ -67,22 +67,23 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements
|
||||||
* @see ITextEditorDropTargetListener
|
* @see ITextEditorDropTargetListener
|
||||||
*/
|
*/
|
||||||
public static class Factory implements IAdapterFactory {
|
public static class Factory implements IAdapterFactory {
|
||||||
private static final Class[] CLASSES= { ITextEditorDropTargetListener.class };
|
private static final Class<?>[] CLASSES= { ITextEditorDropTargetListener.class };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
|
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
|
||||||
* java.lang.Class)
|
* java.lang.Class)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||||
if (adaptableObject instanceof ITextEditor) {
|
if (adaptableObject instanceof ITextEditor)
|
||||||
return TextEditorDropAdapter.create((ITextEditor) adaptableObject);
|
return TextEditorDropAdapter.create((ITextEditor) adaptableObject);
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
|
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public Class[] getAdapterList() {
|
public Class[] getAdapterList() {
|
||||||
return CLASSES;
|
return CLASSES;
|
||||||
}
|
}
|
||||||
|
@ -323,13 +324,13 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements
|
||||||
* @param fileNames
|
* @param fileNames
|
||||||
*/
|
*/
|
||||||
private void dropFiles(String[] fileNames) throws CoreException {
|
private void dropFiles(String[] fileNames) throws CoreException {
|
||||||
for (int i= 0; i < fileNames.length; i++) {
|
for (String fileName : fileNames) {
|
||||||
Path path= new Path(fileNames[i]);
|
Path path= new Path(fileName);
|
||||||
java.io.File file= path.toFile();
|
java.io.File file= path.toFile();
|
||||||
if (!file.isFile()) {
|
if (!file.isFile()) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin
|
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin
|
||||||
.getPluginId(), 0, CUIMessages.getFormattedString(
|
.getPluginId(), 0, CUIMessages.getFormattedString(
|
||||||
"TextEditorDropAdapter.noFile", fileNames[i]), //$NON-NLS-1$
|
"TextEditorDropAdapter.noFile", fileName), //$NON-NLS-1$
|
||||||
null));
|
null));
|
||||||
}
|
}
|
||||||
if (file.canRead()) {
|
if (file.canRead()) {
|
||||||
|
@ -337,7 +338,7 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements
|
||||||
} else {
|
} else {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin
|
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin
|
||||||
.getPluginId(), 0, CUIMessages.getFormattedString(
|
.getPluginId(), 0, CUIMessages.getFormattedString(
|
||||||
"TextEditorDropAdapter.unreadableFile", fileNames[i]), //$NON-NLS-1$
|
"TextEditorDropAdapter.unreadableFile", fileName), //$NON-NLS-1$
|
||||||
null));
|
null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,8 +351,7 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements
|
||||||
* @throws PartInitException
|
* @throws PartInitException
|
||||||
*/
|
*/
|
||||||
private void dropMarkers(IMarker[] markers) throws PartInitException {
|
private void dropMarkers(IMarker[] markers) throws PartInitException {
|
||||||
for (int i= 0; i < markers.length; i++) {
|
for (IMarker marker : markers) {
|
||||||
IMarker marker= markers[i];
|
|
||||||
IDE.openEditor(getPage(), marker);
|
IDE.openEditor(getPage(), marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class IBHistoryListAction extends Action {
|
||||||
|
|
||||||
private class HistoryListDialog extends StatusDialog {
|
private class HistoryListDialog extends StatusDialog {
|
||||||
|
|
||||||
private ListDialogField fHistoryList;
|
private ListDialogField<ITranslationUnit> fHistoryList;
|
||||||
private IStatus fHistoryStatus;
|
private IStatus fHistoryStatus;
|
||||||
private ITranslationUnit fResult;
|
private ITranslationUnit fResult;
|
||||||
|
|
||||||
|
@ -53,22 +53,22 @@ public class IBHistoryListAction extends Action {
|
||||||
IBMessages.IBHistoryListAction_Remove_label,
|
IBMessages.IBHistoryListAction_Remove_label,
|
||||||
};
|
};
|
||||||
|
|
||||||
IListAdapter adapter= new IListAdapter() {
|
IListAdapter<ITranslationUnit> adapter= new IListAdapter<ITranslationUnit>() {
|
||||||
public void customButtonPressed(ListDialogField field, int index) {
|
public void customButtonPressed(ListDialogField<ITranslationUnit> field, int index) {
|
||||||
doCustomButtonPressed();
|
doCustomButtonPressed();
|
||||||
}
|
}
|
||||||
public void selectionChanged(ListDialogField field) {
|
public void selectionChanged(ListDialogField<ITranslationUnit> field) {
|
||||||
doSelectionChanged();
|
doSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doubleClicked(ListDialogField field) {
|
public void doubleClicked(ListDialogField<ITranslationUnit> field) {
|
||||||
doDoubleClicked();
|
doDoubleClicked();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CUILabelProvider labelProvider= new CUILabelProvider(CElementBaseLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS);
|
CUILabelProvider labelProvider= new CUILabelProvider(CElementBaseLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS);
|
||||||
|
|
||||||
fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
|
fHistoryList= new ListDialogField<ITranslationUnit>(adapter, buttonLabels, labelProvider);
|
||||||
fHistoryList.setLabelText(IBMessages.IBHistoryListAction_HistoryList_label);
|
fHistoryList.setLabelText(IBMessages.IBHistoryListAction_HistoryList_label);
|
||||||
fHistoryList.setElements(Arrays.asList(elements));
|
fHistoryList.setElements(Arrays.asList(elements));
|
||||||
|
|
||||||
|
@ -121,12 +121,12 @@ public class IBHistoryListAction extends Action {
|
||||||
|
|
||||||
private void doSelectionChanged() {
|
private void doSelectionChanged() {
|
||||||
StatusInfo status= new StatusInfo();
|
StatusInfo status= new StatusInfo();
|
||||||
List<?> selected= fHistoryList.getSelectedElements();
|
List<ITranslationUnit> selected= fHistoryList.getSelectedElements();
|
||||||
if (selected.size() != 1) {
|
if (selected.size() != 1) {
|
||||||
status.setError(""); //$NON-NLS-1$
|
status.setError(""); //$NON-NLS-1$
|
||||||
fResult= null;
|
fResult= null;
|
||||||
} else {
|
} else {
|
||||||
fResult= (ITranslationUnit) selected.get(0);
|
fResult= selected.get(0);
|
||||||
}
|
}
|
||||||
fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
|
fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
|
||||||
fHistoryStatus= status;
|
fHistoryStatus= status;
|
||||||
|
@ -138,7 +138,7 @@ public class IBHistoryListAction extends Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITranslationUnit[] getRemaining() {
|
public ITranslationUnit[] getRemaining() {
|
||||||
List<?> elems= fHistoryList.getElements();
|
List<ITranslationUnit> elems= fHistoryList.getElements();
|
||||||
return elems.toArray(new ITranslationUnit[elems.size()]);
|
return elems.toArray(new ITranslationUnit[elems.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
|
||||||
boolean hasBuilder= true; // false if any project is closed or does
|
boolean hasBuilder= true; // false if any project is closed or does
|
||||||
// not have builder
|
// not have builder
|
||||||
|
|
||||||
Iterator resources= selection.iterator();
|
Iterator<?> resources= selection.iterator();
|
||||||
while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) {
|
while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) {
|
||||||
Object next= resources.next();
|
Object next= resources.next();
|
||||||
IProject project= null;
|
IProject project= null;
|
||||||
|
|
|
@ -272,6 +272,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedChildren(java.lang.Object, java.util.Set)
|
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedChildren(java.lang.Object, java.util.Set)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void getPipelinedChildren(Object parent, Set currentChildren) {
|
public void getPipelinedChildren(Object parent, Set currentChildren) {
|
||||||
customizeCElements(getChildren(parent), currentChildren);
|
customizeCElements(getChildren(parent), currentChildren);
|
||||||
}
|
}
|
||||||
|
@ -279,6 +280,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedElements(java.lang.Object, java.util.Set)
|
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedElements(java.lang.Object, java.util.Set)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void getPipelinedElements(Object input, Set currentElements) {
|
public void getPipelinedElements(Object input, Set currentElements) {
|
||||||
// only replace plain resource elements with custom elements
|
// only replace plain resource elements with custom elements
|
||||||
// and avoid duplicating elements already customized
|
// and avoid duplicating elements already customized
|
||||||
|
@ -286,10 +288,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
|
||||||
customizeCElements(getElements(input), currentElements);
|
customizeCElements(getElements(input), currentElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void customizeCElements(Object[] cChildren, Set proposedChildren) {
|
private void customizeCElements(Object[] cChildren, Set<Object> proposedChildren) {
|
||||||
List elementList= Arrays.asList(cChildren);
|
List<Object> elementList= Arrays.asList(cChildren);
|
||||||
for (Iterator iter= proposedChildren.iterator(); iter.hasNext();) {
|
for (Object element : proposedChildren) {
|
||||||
Object element= iter.next();
|
|
||||||
IResource resource= null;
|
IResource resource= null;
|
||||||
if (element instanceof IResource) {
|
if (element instanceof IResource) {
|
||||||
resource= (IResource)element;
|
resource= (IResource)element;
|
||||||
|
@ -303,8 +304,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i= 0; i < cChildren.length; i++) {
|
for (Object element : cChildren) {
|
||||||
Object element= cChildren[i];
|
|
||||||
if (element instanceof ICElement) {
|
if (element instanceof ICElement) {
|
||||||
ICElement cElement= (ICElement)element;
|
ICElement cElement= (ICElement)element;
|
||||||
IResource resource= cElement.getResource();
|
IResource resource= cElement.getResource();
|
||||||
|
@ -343,7 +343,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
|
||||||
}
|
}
|
||||||
} else if (parent instanceof IWorkspaceRoot) {
|
} else if (parent instanceof IWorkspaceRoot) {
|
||||||
// ignore adds of C projects (we are issuing a refresh)
|
// ignore adds of C projects (we are issuing a refresh)
|
||||||
for (Iterator iterator = addModification.getChildren().iterator(); iterator.hasNext();) {
|
for (Iterator<?> iterator = addModification.getChildren().iterator(); iterator.hasNext();) {
|
||||||
Object child= iterator.next();
|
Object child= iterator.next();
|
||||||
if (child instanceof IProject) {
|
if (child instanceof IProject) {
|
||||||
if (CoreModel.hasCNature((IProject)child)) {
|
if (CoreModel.hasCNature((IProject)child)) {
|
||||||
|
@ -360,14 +360,18 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
|
||||||
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRefresh(org.eclipse.ui.navigator.PipelinedViewerUpdate)
|
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRefresh(org.eclipse.ui.navigator.PipelinedViewerUpdate)
|
||||||
*/
|
*/
|
||||||
public boolean interceptRefresh(PipelinedViewerUpdate refreshSynchronization) {
|
public boolean interceptRefresh(PipelinedViewerUpdate refreshSynchronization) {
|
||||||
return convertToCElements(refreshSynchronization.getRefreshTargets());
|
@SuppressWarnings("unchecked")
|
||||||
|
final Set<Object> refreshTargets = refreshSynchronization.getRefreshTargets();
|
||||||
|
return convertToCElements(refreshTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRemove(org.eclipse.ui.navigator.PipelinedShapeModification)
|
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRemove(org.eclipse.ui.navigator.PipelinedShapeModification)
|
||||||
*/
|
*/
|
||||||
public PipelinedShapeModification interceptRemove(PipelinedShapeModification removeModification) {
|
public PipelinedShapeModification interceptRemove(PipelinedShapeModification removeModification) {
|
||||||
convertToCElements(removeModification.getChildren());
|
@SuppressWarnings("unchecked")
|
||||||
|
final Set<Object> children = removeModification.getChildren();
|
||||||
|
convertToCElements(children);
|
||||||
return removeModification;
|
return removeModification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +379,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
|
||||||
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptUpdate(org.eclipse.ui.navigator.PipelinedViewerUpdate)
|
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptUpdate(org.eclipse.ui.navigator.PipelinedViewerUpdate)
|
||||||
*/
|
*/
|
||||||
public boolean interceptUpdate(PipelinedViewerUpdate updateSynchronization) {
|
public boolean interceptUpdate(PipelinedViewerUpdate updateSynchronization) {
|
||||||
return convertToCElements(updateSynchronization.getRefreshTargets());
|
@SuppressWarnings("unchecked")
|
||||||
|
final Set<Object> refreshTargets = updateSynchronization.getRefreshTargets();
|
||||||
|
return convertToCElements(refreshTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -399,7 +405,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
|
||||||
if( !(element instanceof ICModel) && !(element instanceof ICProject) ) {
|
if( !(element instanceof ICModel) && !(element instanceof ICProject) ) {
|
||||||
modification.setParent(element);
|
modification.setParent(element);
|
||||||
}
|
}
|
||||||
return convertToCElements(modification.getChildren());
|
@SuppressWarnings("unchecked")
|
||||||
|
final Set<Object> children = modification.getChildren();
|
||||||
|
return convertToCElements(children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,10 +422,10 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I
|
||||||
* refreshed in the viewer.
|
* refreshed in the viewer.
|
||||||
* @return <code>true</code> if the input set was modified
|
* @return <code>true</code> if the input set was modified
|
||||||
*/
|
*/
|
||||||
private boolean convertToCElements(Set currentChildren) {
|
private boolean convertToCElements(Set<Object> currentChildren) {
|
||||||
LinkedHashSet convertedChildren= new LinkedHashSet();
|
LinkedHashSet<ICElement> convertedChildren= new LinkedHashSet<ICElement>();
|
||||||
ICElement newChild;
|
ICElement newChild;
|
||||||
for (Iterator iter= currentChildren.iterator(); iter.hasNext();) {
|
for (Iterator<Object> iter= currentChildren.iterator(); iter.hasNext();) {
|
||||||
Object child= iter.next();
|
Object child= iter.next();
|
||||||
// do not convert IProject
|
// do not convert IProject
|
||||||
if (child instanceof IFile || child instanceof IFolder) {
|
if (child instanceof IFile || child instanceof IFolder) {
|
||||||
|
|
|
@ -45,11 +45,10 @@ public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant {
|
||||||
* @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection)
|
* @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean setDragData(DragSourceEvent event,
|
public boolean setDragData(DragSourceEvent event, IStructuredSelection selection) {
|
||||||
IStructuredSelection selection) {
|
|
||||||
if (selection != null) {
|
if (selection != null) {
|
||||||
boolean applicable= false;
|
boolean applicable= false;
|
||||||
for (Iterator iter= (selection).iterator(); iter.hasNext();) {
|
for (Iterator<?> iter= (selection).iterator(); iter.hasNext();) {
|
||||||
Object element= iter.next();
|
Object element= iter.next();
|
||||||
if (element instanceof ICElement) {
|
if (element instanceof ICElement) {
|
||||||
if (element instanceof ITranslationUnit) {
|
if (element instanceof ITranslationUnit) {
|
||||||
|
@ -68,5 +67,4 @@ public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,8 +179,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
|
||||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
|
if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
|
||||||
IResource[] selectedResources= getSelectedResources();
|
IResource[] selectedResources= getSelectedResources();
|
||||||
if (selectedResources.length > 0) {
|
if (selectedResources.length > 0) {
|
||||||
for (int iRes = 0; iRes < selectedResources.length; iRes++) {
|
for (IResource res : selectedResources) {
|
||||||
IResource res = selectedResources[iRes];
|
|
||||||
if(res instanceof IProject) {
|
if(res instanceof IProject) {
|
||||||
// drop of projects not supported on other IResources
|
// drop of projects not supported on other IResources
|
||||||
// "Path for project must have only one segment."
|
// "Path for project must have only one segment."
|
||||||
|
@ -362,10 +361,9 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
|
||||||
if (!(selection instanceof IStructuredSelection)) {
|
if (!(selection instanceof IStructuredSelection)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List elements = ((IStructuredSelection)selection).toList();
|
List<?> elements = ((IStructuredSelection)selection).toList();
|
||||||
List<Object> resources= new ArrayList<Object>(elements.size());
|
List<Object> resources= new ArrayList<Object>(elements.size());
|
||||||
for (Iterator iter= elements.iterator(); iter.hasNext();) {
|
for (Object element : elements) {
|
||||||
Object element= iter.next();
|
|
||||||
if (element instanceof ITranslationUnit) {
|
if (element instanceof ITranslationUnit) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -394,11 +392,12 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
|
||||||
ICElement parent = elements[0];
|
ICElement parent = elements[0];
|
||||||
for (int i = 0; i < elements.length; ++i) {
|
for (int i = 0; i < elements.length; ++i) {
|
||||||
ICElement p = elements[i].getParent();
|
ICElement p = elements[i].getParent();
|
||||||
if (parent == null && p!= null) {
|
if (parent == null) {
|
||||||
return false;
|
if (p!= null)
|
||||||
} else if (!parent.equals(p)){
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (!parent.equals(p))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -438,7 +437,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
|
||||||
private IResource[] getSelectedResources(IStructuredSelection selection) {
|
private IResource[] getSelectedResources(IStructuredSelection selection) {
|
||||||
ArrayList<Object> selectedResources = new ArrayList<Object>();
|
ArrayList<Object> selectedResources = new ArrayList<Object>();
|
||||||
|
|
||||||
for (Iterator i = selection.iterator(); i.hasNext();) {
|
for (Iterator<?> i = selection.iterator(); i.hasNext();) {
|
||||||
Object o = i.next();
|
Object o = i.next();
|
||||||
if (o instanceof IResource) {
|
if (o instanceof IResource) {
|
||||||
selectedResources.add(o);
|
selectedResources.add(o);
|
||||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.ui.navigator;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.jface.action.IMenuManager;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.window.SameShellProvider;
|
||||||
import org.eclipse.swt.dnd.Clipboard;
|
import org.eclipse.swt.dnd.Clipboard;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.ui.IActionBars;
|
import org.eclipse.ui.IActionBars;
|
||||||
|
@ -111,6 +112,7 @@ public class CNavigatorEditActionGroup extends ActionGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void makeActions() {
|
protected void makeActions() {
|
||||||
|
final SameShellProvider shellProvider= new SameShellProvider(shell);
|
||||||
clipboard = new Clipboard(shell.getDisplay());
|
clipboard = new Clipboard(shell.getDisplay());
|
||||||
|
|
||||||
pasteAction = new PasteAction(shell, clipboard);
|
pasteAction = new PasteAction(shell, clipboard);
|
||||||
|
@ -128,7 +130,7 @@ public class CNavigatorEditActionGroup extends ActionGroup {
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
|
.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
|
||||||
copyAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY);
|
copyAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY);
|
||||||
|
|
||||||
deleteAction = new DeleteResourceAction(shell);
|
deleteAction = new DeleteResourceAction(shellProvider);
|
||||||
deleteAction.setDisabledImageDescriptor(images
|
deleteAction.setDisabledImageDescriptor(images
|
||||||
.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
|
.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
|
||||||
deleteAction.setImageDescriptor(images
|
deleteAction.setImageDescriptor(images
|
||||||
|
|
|
@ -73,7 +73,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
|
||||||
protected final class SectionManager {
|
protected final class SectionManager {
|
||||||
/** The preference setting for keeping no section open. */
|
/** The preference setting for keeping no section open. */
|
||||||
private static final String __NONE= "__none"; //$NON-NLS-1$
|
private static final String __NONE= "__none"; //$NON-NLS-1$
|
||||||
private Set fSections= new HashSet();
|
private Set<ExpandableComposite> fSections= new HashSet<ExpandableComposite>();
|
||||||
private boolean fIsBeingManaged= false;
|
private boolean fIsBeingManaged= false;
|
||||||
private ExpansionAdapter fListener= new ExpansionAdapter() {
|
private ExpansionAdapter fListener= new ExpansionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,8 +85,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
|
||||||
if (e.getState()) {
|
if (e.getState()) {
|
||||||
try {
|
try {
|
||||||
fIsBeingManaged= true;
|
fIsBeingManaged= true;
|
||||||
for (Iterator iter= fSections.iterator(); iter.hasNext();) {
|
for (ExpandableComposite composite : fSections) {
|
||||||
ExpandableComposite composite= (ExpandableComposite) iter.next();
|
|
||||||
if (composite != source)
|
if (composite != source)
|
||||||
composite.setExpanded(false);
|
composite.setExpanded(false);
|
||||||
}
|
}
|
||||||
|
@ -206,26 +205,26 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
|
||||||
protected static final int INDENT= 20;
|
protected static final int INDENT= 20;
|
||||||
private OverlayPreferenceStore fStore;
|
private OverlayPreferenceStore fStore;
|
||||||
|
|
||||||
private Map fCheckBoxes= new HashMap();
|
private Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
|
||||||
private SelectionListener fCheckBoxListener= new SelectionListener() {
|
private SelectionListener fCheckBoxListener= new SelectionListener() {
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
}
|
}
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
Button button= (Button) e.widget;
|
Button button= (Button) e.widget;
|
||||||
fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
|
fStore.setValue(fCheckBoxes.get(button), button.getSelection());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private Map fTextFields= new HashMap();
|
private Map<Object, String> fTextFields= new HashMap<Object, String>();
|
||||||
private ModifyListener fTextFieldListener= new ModifyListener() {
|
private ModifyListener fTextFieldListener= new ModifyListener() {
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
Text text= (Text) e.widget;
|
Text text= (Text) e.widget;
|
||||||
fStore.setValue((String) fTextFields.get(text), text.getText());
|
fStore.setValue(fTextFields.get(text), text.getText());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private ArrayList fNumberFields= new ArrayList();
|
private ArrayList<Text> fNumberFields= new ArrayList<Text>();
|
||||||
private ModifyListener fNumberFieldListener= new ModifyListener() {
|
private ModifyListener fNumberFieldListener= new ModifyListener() {
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
numberFieldChanged((Text) e.widget);
|
numberFieldChanged((Text) e.widget);
|
||||||
|
@ -238,7 +237,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
|
||||||
* @see #createDependency(Button, Control)
|
* @see #createDependency(Button, Control)
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
private ArrayList fMasterSlaveListeners= new ArrayList();
|
private ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>();
|
||||||
|
|
||||||
private StatusInfo fStatus;
|
private StatusInfo fStatus;
|
||||||
private final PreferencePage fMainPage;
|
private final PreferencePage fMainPage;
|
||||||
|
@ -359,8 +358,8 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
|
||||||
SelectionListener listener= new SelectionListener() {
|
SelectionListener listener= new SelectionListener() {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
boolean state= master.getSelection();
|
boolean state= master.getSelection();
|
||||||
for (int i= 0; i < slaves.length; i++) {
|
for (Control slave : slaves) {
|
||||||
slaves[i].setEnabled(state);
|
slave.setEnabled(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,17 +379,17 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
|
||||||
|
|
||||||
private void initializeFields() {
|
private void initializeFields() {
|
||||||
|
|
||||||
Iterator iter= fCheckBoxes.keySet().iterator();
|
Iterator<Object> iter= fCheckBoxes.keySet().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Button b= (Button) iter.next();
|
Button b= (Button) iter.next();
|
||||||
String key= (String) fCheckBoxes.get(b);
|
String key= fCheckBoxes.get(b);
|
||||||
b.setSelection(fStore.getBoolean(key));
|
b.setSelection(fStore.getBoolean(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
iter= fTextFields.keySet().iterator();
|
iter= fTextFields.keySet().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Text t= (Text) iter.next();
|
Text t= (Text) iter.next();
|
||||||
String key= (String) fTextFields.get(t);
|
String key= fTextFields.get(t);
|
||||||
t.setText(fStore.getString(key));
|
t.setText(fStore.getString(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +426,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
|
||||||
String number= textControl.getText();
|
String number= textControl.getText();
|
||||||
IStatus status= validatePositiveNumber(number);
|
IStatus status= validatePositiveNumber(number);
|
||||||
if (!status.matches(IStatus.ERROR))
|
if (!status.matches(IStatus.ERROR))
|
||||||
fStore.setValue((String) fTextFields.get(textControl), number);
|
fStore.setValue(fTextFields.get(textControl), number);
|
||||||
updateStatus(status);
|
updateStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,7 +460,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
|
||||||
protected Composite createSubsection(Composite parent, SectionManager manager, String label) {
|
protected Composite createSubsection(Composite parent, SectionManager manager, String label) {
|
||||||
if (manager != null) {
|
if (manager != null) {
|
||||||
return manager.createSection(label);
|
return manager.createSection(label);
|
||||||
} else {
|
}
|
||||||
Group group= new Group(parent, SWT.SHADOW_NONE);
|
Group group= new Group(parent, SWT.SHADOW_NONE);
|
||||||
group.setText(label);
|
group.setText(label);
|
||||||
GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false);
|
GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
|
@ -469,4 +468,3 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -61,50 +61,50 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
|
||||||
* @see #createDependency(Button, String, Control)
|
* @see #createDependency(Button, String, Control)
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
private ArrayList fMasterSlaveListeners= new ArrayList();
|
private ArrayList<SelectionListener> fMasterSlaveListeners= new ArrayList<SelectionListener>();
|
||||||
|
|
||||||
protected Map fTextFields = new HashMap();
|
protected Map<Object, String> fTextFields = new HashMap<Object, String>();
|
||||||
private ModifyListener fTextFieldListener = new ModifyListener() {
|
private ModifyListener fTextFieldListener = new ModifyListener() {
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
Text text = (Text) e.widget;
|
Text text = (Text) e.widget;
|
||||||
fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
|
fOverlayStore.setValue(fTextFields.get(text), text.getText());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected Map fComboBoxes = new HashMap();
|
protected Map<Object, String> fComboBoxes = new HashMap<Object, String>();
|
||||||
private ModifyListener fComboBoxListener = new ModifyListener() {
|
private ModifyListener fComboBoxListener = new ModifyListener() {
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
Combo combo = (Combo) e.widget;
|
Combo combo = (Combo) e.widget;
|
||||||
String state = ProposalFilterPreferencesUtil.comboStateAsString(combo);
|
String state = ProposalFilterPreferencesUtil.comboStateAsString(combo);
|
||||||
fOverlayStore.setValue((String) fComboBoxes.get(combo), state);
|
fOverlayStore.setValue(fComboBoxes.get(combo), state);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
protected Map fCheckBoxes = new HashMap();
|
protected Map<Object, String> fCheckBoxes = new HashMap<Object, String>();
|
||||||
private SelectionListener fCheckBoxListener = new SelectionListener() {
|
private SelectionListener fCheckBoxListener = new SelectionListener() {
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
}
|
}
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
Button button = (Button) e.widget;
|
Button button = (Button) e.widget;
|
||||||
fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
|
fOverlayStore.setValue(fCheckBoxes.get(button), button.getSelection());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected ArrayList fNumberFields = new ArrayList();
|
protected ArrayList<Text> fNumberFields = new ArrayList<Text>();
|
||||||
private ModifyListener fNumberFieldListener = new ModifyListener() {
|
private ModifyListener fNumberFieldListener = new ModifyListener() {
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
numberFieldChanged((Text) e.widget);
|
numberFieldChanged((Text) e.widget);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected Map fColorButtons = new HashMap();
|
protected Map<Object, String> fColorButtons = new HashMap<Object, String>();
|
||||||
private SelectionListener fColorButtonListener = new SelectionListener() {
|
private SelectionListener fColorButtonListener = new SelectionListener() {
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
}
|
}
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
ColorSelector editor = (ColorSelector) e.widget.getData();
|
ColorSelector editor = (ColorSelector) e.widget.getData();
|
||||||
PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons.get(editor), editor.getColorValue());
|
PreferenceConverter.setValue(fOverlayStore, fColorButtons.get(editor), editor.getColorValue());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
|
||||||
String number = textControl.getText();
|
String number = textControl.getText();
|
||||||
IStatus status = validatePositiveNumber(number);
|
IStatus status = validatePositiveNumber(number);
|
||||||
if (!status.matches(IStatus.ERROR))
|
if (!status.matches(IStatus.ERROR))
|
||||||
fOverlayStore.setValue((String) fTextFields.get(textControl), number);
|
fOverlayStore.setValue(fTextFields.get(textControl), number);
|
||||||
updateStatus(status);
|
updateStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
|
||||||
protected void updateStatus(IStatus status) {
|
protected void updateStatus(IStatus status) {
|
||||||
if (!status.matches(IStatus.ERROR)) {
|
if (!status.matches(IStatus.ERROR)) {
|
||||||
for (int i = 0; i < fNumberFields.size(); i++) {
|
for (int i = 0; i < fNumberFields.size(); i++) {
|
||||||
Text text = (Text) fNumberFields.get(i);
|
Text text = fNumberFields.get(i);
|
||||||
IStatus s = validatePositiveNumber(text.getText());
|
IStatus s = validatePositiveNumber(text.getText());
|
||||||
status = StatusUtil.getMoreSevere(s, status);
|
status = StatusUtil.getMoreSevere(s, status);
|
||||||
}
|
}
|
||||||
|
@ -310,10 +310,10 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
|
||||||
|
|
||||||
protected void initializeFields() {
|
protected void initializeFields() {
|
||||||
|
|
||||||
Iterator e = fColorButtons.keySet().iterator();
|
Iterator<Object> e = fColorButtons.keySet().iterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
ColorSelector c = (ColorSelector) e.next();
|
ColorSelector c = (ColorSelector) e.next();
|
||||||
String key = (String) fColorButtons.get(c);
|
String key = fColorButtons.get(c);
|
||||||
RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
|
RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
|
||||||
c.setColorValue(rgb);
|
c.setColorValue(rgb);
|
||||||
}
|
}
|
||||||
|
@ -321,21 +321,21 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I
|
||||||
e = fCheckBoxes.keySet().iterator();
|
e = fCheckBoxes.keySet().iterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
Button b = (Button) e.next();
|
Button b = (Button) e.next();
|
||||||
String key = (String) fCheckBoxes.get(b);
|
String key = fCheckBoxes.get(b);
|
||||||
b.setSelection(fOverlayStore.getBoolean(key));
|
b.setSelection(fOverlayStore.getBoolean(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = fTextFields.keySet().iterator();
|
e = fTextFields.keySet().iterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
Text t = (Text) e.next();
|
Text t = (Text) e.next();
|
||||||
String key = (String) fTextFields.get(t);
|
String key = fTextFields.get(t);
|
||||||
t.setText(fOverlayStore.getString(key));
|
t.setText(fOverlayStore.getString(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = fComboBoxes.keySet().iterator();
|
e = fComboBoxes.keySet().iterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
Combo c = (Combo) e.next();
|
Combo c = (Combo) e.next();
|
||||||
String key = (String) fComboBoxes.get(c);
|
String key = fComboBoxes.get(c);
|
||||||
String state = fOverlayStore.getString(key);
|
String state = fOverlayStore.getString(key);
|
||||||
// Interpret the state string as a Combo state description
|
// Interpret the state string as a Combo state description
|
||||||
ProposalFilterPreferencesUtil.restoreComboFromString(c, state);
|
ProposalFilterPreferencesUtil.restoreComboFromString(c, state);
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
|
@ -371,26 +370,26 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
|
|
||||||
fColorManager= new CColorManager(false);
|
fColorManager= new CColorManager(false);
|
||||||
|
|
||||||
for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++)
|
for (String[] element : fSyntaxColorListModel)
|
||||||
fListModel.add(new HighlightingColorListItem (
|
fListModel.add(new HighlightingColorListItem (
|
||||||
fSyntaxColorListModel[i][0],
|
element[0],
|
||||||
fSyntaxColorListModel[i][1],
|
element[1],
|
||||||
fSyntaxColorListModel[i][1] + BOLD,
|
element[1] + BOLD,
|
||||||
fSyntaxColorListModel[i][1] + ITALIC,
|
element[1] + ITALIC,
|
||||||
fSyntaxColorListModel[i][1] + STRIKETHROUGH,
|
element[1] + STRIKETHROUGH,
|
||||||
fSyntaxColorListModel[i][1] + UNDERLINE));
|
element[1] + UNDERLINE));
|
||||||
|
|
||||||
SemanticHighlighting[] semanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
|
SemanticHighlighting[] semanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
|
||||||
for (int i= 0, n= semanticHighlightings.length; i < n; i++)
|
for (SemanticHighlighting semanticHighlighting : semanticHighlightings)
|
||||||
fListModel.add(
|
fListModel.add(
|
||||||
new SemanticHighlightingColorListItem(
|
new SemanticHighlightingColorListItem(
|
||||||
semanticHighlightings[i].getDisplayName(),
|
semanticHighlighting.getDisplayName(),
|
||||||
SemanticHighlightings.getColorPreferenceKey(semanticHighlightings[i]),
|
SemanticHighlightings.getColorPreferenceKey(semanticHighlighting),
|
||||||
SemanticHighlightings.getBoldPreferenceKey(semanticHighlightings[i]),
|
SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting),
|
||||||
SemanticHighlightings.getItalicPreferenceKey(semanticHighlightings[i]),
|
SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting),
|
||||||
SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlightings[i]),
|
SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting),
|
||||||
SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlightings[i]),
|
SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting),
|
||||||
SemanticHighlightings.getEnabledPreferenceKey(semanticHighlightings[i])
|
SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting)
|
||||||
));
|
));
|
||||||
|
|
||||||
store.addKeys(createOverlayStoreKeys());
|
store.addKeys(createOverlayStoreKeys());
|
||||||
|
@ -613,8 +612,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
gd= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true);
|
gd= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true);
|
||||||
gd.heightHint= convertHeightInCharsToPixels(9);
|
gd.heightHint= convertHeightInCharsToPixels(9);
|
||||||
int maxWidth= 0;
|
int maxWidth= 0;
|
||||||
for (Iterator it= fListModel.iterator(); it.hasNext();) {
|
for (HighlightingColorListItem item : fListModel) {
|
||||||
HighlightingColorListItem item= (HighlightingColorListItem) it.next();
|
|
||||||
maxWidth= Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
|
maxWidth= Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
|
||||||
}
|
}
|
||||||
ScrollBar vBar= ((Scrollable) fListViewer.getControl()).getVerticalBar();
|
ScrollBar vBar= ((Scrollable) fListViewer.getControl()).getVerticalBar();
|
||||||
|
|
|
@ -59,6 +59,7 @@ import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
||||||
|
import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
|
||||||
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
|
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
|
||||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||||
|
@ -171,7 +172,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
|
||||||
|
|
||||||
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
||||||
|
|
||||||
ArrayList overlayKeys= new ArrayList();
|
ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
|
||||||
|
|
||||||
//overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER));
|
//overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER));
|
||||||
//overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
|
//overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
|
||||||
|
@ -437,7 +438,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
|
||||||
String compiledTextHoverModifiers= fStore.getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
|
String compiledTextHoverModifiers= fStore.getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
|
||||||
|
|
||||||
StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, CEditorTextHoverDescriptor.VALUE_SEPARATOR);
|
StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, CEditorTextHoverDescriptor.VALUE_SEPARATOR);
|
||||||
HashMap idToModifier= new HashMap(tokenizer.countTokens() / 2);
|
HashMap<String, String> idToModifier= new HashMap<String, String>(tokenizer.countTokens() / 2);
|
||||||
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
String id= tokenizer.nextToken();
|
String id= tokenizer.nextToken();
|
||||||
|
@ -448,7 +449,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
|
||||||
String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
|
String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
|
||||||
|
|
||||||
tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, CEditorTextHoverDescriptor.VALUE_SEPARATOR);
|
tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, CEditorTextHoverDescriptor.VALUE_SEPARATOR);
|
||||||
HashMap idToModifierMask= new HashMap(tokenizer.countTokens() / 2);
|
HashMap<String, String> idToModifierMask= new HashMap<String, String>(tokenizer.countTokens() / 2);
|
||||||
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
String id= tokenizer.nextToken();
|
String id= tokenizer.nextToken();
|
||||||
|
@ -457,7 +458,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i= 0; i < fHoverConfigs.length; i++) {
|
for (int i= 0; i < fHoverConfigs.length; i++) {
|
||||||
String modifierString= (String)idToModifier.get(getContributedHovers()[i].getId());
|
String modifierString= idToModifier.get(getContributedHovers()[i].getId());
|
||||||
boolean enabled= true;
|
boolean enabled= true;
|
||||||
if (modifierString == null)
|
if (modifierString == null)
|
||||||
modifierString= CEditorTextHoverDescriptor.DISABLED_TAG;
|
modifierString= CEditorTextHoverDescriptor.DISABLED_TAG;
|
||||||
|
@ -476,7 +477,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
|
||||||
|
|
||||||
if (fHoverConfigs[i].fStateMask == -1) {
|
if (fHoverConfigs[i].fStateMask == -1) {
|
||||||
try {
|
try {
|
||||||
fHoverConfigs[i].fStateMask= Integer.parseInt((String)idToModifierMask.get(getContributedHovers()[i].getId()));
|
fHoverConfigs[i].fStateMask= Integer.parseInt(idToModifierMask.get(getContributedHovers()[i].getId()));
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
fHoverConfigs[i].fStateMask= -1;
|
fHoverConfigs[i].fStateMask= -1;
|
||||||
}
|
}
|
||||||
|
@ -531,7 +532,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
|
||||||
fStatus= new StatusInfo();
|
fStatus= new StatusInfo();
|
||||||
|
|
||||||
int i= 0;
|
int i= 0;
|
||||||
HashMap stateMasks= new HashMap(fHoverConfigs.length);
|
HashMap<Integer, String> stateMasks= new HashMap<Integer, String>(fHoverConfigs.length);
|
||||||
while (fStatus.isOK() && i < fHoverConfigs.length) {
|
while (fStatus.isOK() && i < fHoverConfigs.length) {
|
||||||
if (fHoverConfigs[i].fIsEnabled) {
|
if (fHoverConfigs[i].fIsEnabled) {
|
||||||
String label= getContributedHovers()[i].getLabel();
|
String label= getContributedHovers()[i].getLabel();
|
||||||
|
@ -539,7 +540,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
|
||||||
if (fHoverConfigs[i].fStateMask == -1)
|
if (fHoverConfigs[i].fStateMask == -1)
|
||||||
fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValidForHover, new String[] {fHoverConfigs[i].fModifierString, label}));
|
fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValidForHover, new String[] {fHoverConfigs[i].fModifierString, label}));
|
||||||
else if (stateMasks.containsKey(stateMask))
|
else if (stateMasks.containsKey(stateMask))
|
||||||
fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_duplicateModifier, new String[] {label, (String)stateMasks.get(stateMask)}));
|
fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_duplicateModifier, new String[] {label, stateMasks.get(stateMask)}));
|
||||||
else
|
else
|
||||||
stateMasks.put(stateMask, label);
|
stateMasks.put(stateMask, label);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Link;
|
import org.eclipse.swt.widgets.Link;
|
||||||
import org.eclipse.swt.widgets.List;
|
import org.eclipse.swt.widgets.List;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
import org.eclipse.swt.widgets.Listener;
|
||||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.dialogs.PreferencesUtil;
|
import org.eclipse.ui.dialogs.PreferencesUtil;
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
|
||||||
/*
|
/*
|
||||||
* The page for setting the editor options.
|
* The page for setting the editor options.
|
||||||
*/
|
*/
|
||||||
public class CEditorPreferencePage extends AbstractPreferencePage implements IWorkbenchPreferencePage {
|
public class CEditorPreferencePage extends AbstractPreferencePage {
|
||||||
|
|
||||||
protected final String[][] fAppearanceColorListModel = new String[][] {
|
protected final String[][] fAppearanceColorListModel = new String[][] {
|
||||||
{PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBracketColor, CEditor.MATCHING_BRACKETS_COLOR, null },
|
{PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBracketColor, CEditor.MATCHING_BRACKETS_COLOR, null },
|
||||||
|
@ -120,8 +119,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
||||||
if (control instanceof Composite) {
|
if (control instanceof Composite) {
|
||||||
Composite composite = (Composite) control;
|
Composite composite = (Composite) control;
|
||||||
Control[] children = composite.getChildren();
|
Control[] children = composite.getChildren();
|
||||||
for (int i = 0; i < children.length; i++)
|
for (Control element : children)
|
||||||
setEnabled(children[i], enable);
|
setEnabled(element, enable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,8 +301,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
|
||||||
initializeFields();
|
initializeFields();
|
||||||
initializeDefaultColors();
|
initializeDefaultColors();
|
||||||
|
|
||||||
for (int i = 0; i < fAppearanceColorListModel.length; i++) {
|
for (String[] element : fAppearanceColorListModel) {
|
||||||
fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
|
fAppearanceColorList.add(element[0]);
|
||||||
}
|
}
|
||||||
fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
|
fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.ui.preferences;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||||
|
@ -31,6 +30,8 @@ import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
|
||||||
public class CFileTypeDialog extends Dialog {
|
public class CFileTypeDialog extends Dialog {
|
||||||
|
|
||||||
public CFileTypeDialog(Shell parentShell) {
|
public CFileTypeDialog(Shell parentShell) {
|
||||||
|
@ -112,9 +113,9 @@ public class CFileTypeDialog extends Dialog {
|
||||||
private void populateTypesCombo() {
|
private void populateTypesCombo() {
|
||||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||||
String[] ids = CoreModel.getRegistedContentTypeIds();
|
String[] ids = CoreModel.getRegistedContentTypeIds();
|
||||||
ArrayList list = new ArrayList(ids.length);
|
ArrayList<IContentType> list = new ArrayList<IContentType>(ids.length);
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (String id : ids) {
|
||||||
IContentType ctype = manager.getContentType(ids[i]);
|
IContentType ctype = manager.getContentType(id);
|
||||||
if (ctype != null) {
|
if (ctype != null) {
|
||||||
list.add(ctype);
|
list.add(ctype);
|
||||||
}
|
}
|
||||||
|
@ -124,8 +125,8 @@ public class CFileTypeDialog extends Dialog {
|
||||||
list.toArray(ctypes);
|
list.toArray(ctypes);
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
|
||||||
for (int i = 0; i < ctypes.length; i++) {
|
for (IContentType ctype : ctypes) {
|
||||||
fComboType.add(ctypes[i].getName());
|
fComboType.add(ctype.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
fComboType.setData(ctypes);
|
fComboType.setData(ctypes);
|
||||||
|
@ -152,9 +153,9 @@ public class CFileTypeDialog extends Dialog {
|
||||||
if (-1 != index) {
|
if (-1 != index) {
|
||||||
String name = fComboType.getItem(index);
|
String name = fComboType.getItem(index);
|
||||||
IContentType[] types = (IContentType[]) fComboType.getData();
|
IContentType[] types = (IContentType[]) fComboType.getData();
|
||||||
for (int i = 0; i < types.length; i++) {
|
for (IContentType type2 : types) {
|
||||||
if (name.equals(types[i].getName())) {
|
if (name.equals(type2.getName())) {
|
||||||
type = types[i];
|
type = type2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,8 @@ public class CFileTypesPreferenceBlock {
|
||||||
private static final int COL_DESCRIPTION = 1;
|
private static final int COL_DESCRIPTION = 1;
|
||||||
private static final int COL_STATUS = 2;
|
private static final int COL_STATUS = 2;
|
||||||
|
|
||||||
private ArrayList fAddAssoc;
|
private ArrayList<CFileTypeAssociation> fAddAssoc;
|
||||||
private ArrayList fRemoveAssoc;
|
private ArrayList<CFileTypeAssociation> fRemoveAssoc;
|
||||||
private boolean fDirty = false;
|
private boolean fDirty = false;
|
||||||
private IProject fInput;
|
private IProject fInput;
|
||||||
private IContentType[] fContentTypes;
|
private IContentType[] fContentTypes;
|
||||||
|
@ -175,8 +175,8 @@ public class CFileTypesPreferenceBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CFileTypesPreferenceBlock(IProject input) {
|
public CFileTypesPreferenceBlock(IProject input) {
|
||||||
fAddAssoc = new ArrayList();
|
fAddAssoc = new ArrayList<CFileTypeAssociation>();
|
||||||
fRemoveAssoc = new ArrayList();
|
fRemoveAssoc = new ArrayList<CFileTypeAssociation>();
|
||||||
fInput = input;
|
fInput = input;
|
||||||
setDirty(false);
|
setDirty(false);
|
||||||
}
|
}
|
||||||
|
@ -318,8 +318,8 @@ public class CFileTypesPreferenceBlock {
|
||||||
boolean changed = fDirty;
|
boolean changed = fDirty;
|
||||||
|
|
||||||
if (fDirty) {
|
if (fDirty) {
|
||||||
CFileTypeAssociation[] add = (CFileTypeAssociation[]) fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]);
|
CFileTypeAssociation[] add = fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]);
|
||||||
CFileTypeAssociation[] rem = (CFileTypeAssociation[]) fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]);
|
CFileTypeAssociation[] rem = fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]);
|
||||||
|
|
||||||
changed = add.length > 0 || rem.length > 0;
|
changed = add.length > 0 || rem.length > 0;
|
||||||
adjustAssociations(add, rem);
|
adjustAssociations(add, rem);
|
||||||
|
@ -333,7 +333,7 @@ public class CFileTypesPreferenceBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
private CFileTypeAssociation[] getCFileTypeAssociations() {
|
private CFileTypeAssociation[] getCFileTypeAssociations() {
|
||||||
ArrayList list = new ArrayList();
|
ArrayList<CFileTypeAssociation> list = new ArrayList<CFileTypeAssociation>();
|
||||||
if (fInput == null) {
|
if (fInput == null) {
|
||||||
fillWithUserDefinedCFileTypeAssociations(list);
|
fillWithUserDefinedCFileTypeAssociations(list);
|
||||||
fillWithPredefinedCFileTypeAssociations(list);
|
fillWithPredefinedCFileTypeAssociations(list);
|
||||||
|
@ -411,33 +411,32 @@ public class CFileTypesPreferenceBlock {
|
||||||
return fContentTypes;
|
return fContentTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillWithUserDefinedCFileTypeAssociations(ArrayList list) {
|
private void fillWithUserDefinedCFileTypeAssociations(ArrayList<CFileTypeAssociation> list) {
|
||||||
IContentType[] ctypes = getRegistedContentTypes();
|
IContentType[] ctypes = getRegistedContentTypes();
|
||||||
fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
|
fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
|
||||||
fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list);
|
fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillWithPredefinedCFileTypeAssociations(ArrayList list) {
|
private void fillWithPredefinedCFileTypeAssociations(ArrayList<CFileTypeAssociation> list) {
|
||||||
IContentType[] ctypes = getRegistedContentTypes();
|
IContentType[] ctypes = getRegistedContentTypes();
|
||||||
fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
|
fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
|
||||||
fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_NAME_SPEC, list);
|
fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_NAME_SPEC, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillWithProjectCFileTypeAssociations(ArrayList list, IProject project) {
|
private void fillWithProjectCFileTypeAssociations(ArrayList<CFileTypeAssociation> list, IProject project) {
|
||||||
IContentType[] ctypes = getRegistedContentTypes();
|
IContentType[] ctypes = getRegistedContentTypes();
|
||||||
IScopeContext context = new ProjectScope(project);
|
IScopeContext context = new ProjectScope(project);
|
||||||
fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
|
fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
|
||||||
fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list);
|
fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillWithCFileTypeAssociations(IContentType[] ctypes, IScopeContext context, int type, ArrayList list) {
|
private void fillWithCFileTypeAssociations(IContentType[] ctypes, IScopeContext context, int type, ArrayList<CFileTypeAssociation> list) {
|
||||||
for (int i = 0; i < ctypes.length; i++) {
|
for (IContentType ctype : ctypes) {
|
||||||
try {
|
try {
|
||||||
IContentType ctype = ctypes[i];
|
|
||||||
IContentTypeSettings setting = ctype.getSettings(context);
|
IContentTypeSettings setting = ctype.getSettings(context);
|
||||||
String[] specs = setting.getFileSpecs(type);
|
String[] specs = setting.getFileSpecs(type);
|
||||||
for (int j = 0; j < specs.length; j++) {
|
for (String spec : specs) {
|
||||||
CFileTypeAssociation assoc = new CFileTypeAssociation(specs[j], type, ctype);
|
CFileTypeAssociation assoc = new CFileTypeAssociation(spec, type, ctype);
|
||||||
list.add(assoc);
|
list.add(assoc);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -461,9 +460,9 @@ public class CFileTypesPreferenceBlock {
|
||||||
fBtnRemove.setEnabled(false);
|
fBtnRemove.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
boolean enabled = true;
|
boolean enabled = true;
|
||||||
List elements = sel.toList();
|
List<?> elements = sel.toList();
|
||||||
for (Iterator i = elements.iterator(); i.hasNext();) {
|
for (Object element : elements) {
|
||||||
CFileTypeAssociation assoc = (CFileTypeAssociation) i.next();
|
CFileTypeAssociation assoc = (CFileTypeAssociation) element;
|
||||||
if (assoc.isPredefined())
|
if (assoc.isPredefined())
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
@ -516,8 +515,7 @@ public class CFileTypesPreferenceBlock {
|
||||||
}
|
}
|
||||||
String newSpec= assoc.getSpec();
|
String newSpec= assoc.getSpec();
|
||||||
String[] specs= settings.getFileSpecs(assoc.getFileSpecType());
|
String[] specs= settings.getFileSpecs(assoc.getFileSpecType());
|
||||||
for (int i = 0; i < specs.length; i++) {
|
for (String spec : specs) {
|
||||||
String spec = specs[i];
|
|
||||||
if (spec.equalsIgnoreCase(newSpec)) {
|
if (spec.equalsIgnoreCase(newSpec)) {
|
||||||
reportDuplicateAssociation(assoc);
|
reportDuplicateAssociation(assoc);
|
||||||
return false;
|
return false;
|
||||||
|
@ -527,9 +525,8 @@ public class CFileTypesPreferenceBlock {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsIgnoreCaseOfSpec(Collection collection, CFileTypeAssociation assoc) {
|
private boolean containsIgnoreCaseOfSpec(Collection<CFileTypeAssociation> collection, CFileTypeAssociation assoc) {
|
||||||
for (Iterator iter = collection.iterator(); iter.hasNext(); ) {
|
for (CFileTypeAssociation existing : collection) {
|
||||||
CFileTypeAssociation existing = (CFileTypeAssociation) iter.next();
|
|
||||||
if (assoc.equalsIgnoreCaseOfSpec(existing)) {
|
if (assoc.equalsIgnoreCaseOfSpec(existing)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -547,7 +544,7 @@ public class CFileTypesPreferenceBlock {
|
||||||
final protected void handleRemove() {
|
final protected void handleRemove() {
|
||||||
IStructuredSelection sel = getSelection();
|
IStructuredSelection sel = getSelection();
|
||||||
if ((null != sel) && (!sel.isEmpty())) {
|
if ((null != sel) && (!sel.isEmpty())) {
|
||||||
for (Iterator iter = sel.iterator(); iter.hasNext();) {
|
for (Iterator<?> iter = sel.iterator(); iter.hasNext();) {
|
||||||
CFileTypeAssociation assoc = (CFileTypeAssociation) iter.next();
|
CFileTypeAssociation assoc = (CFileTypeAssociation) iter.next();
|
||||||
handleRemove(assoc);
|
handleRemove(assoc);
|
||||||
fAssocViewer.remove(assoc);
|
fAssocViewer.remove(assoc);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeSettings;
|
import org.eclipse.core.runtime.content.IContentTypeSettings;
|
||||||
|
import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent;
|
||||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
@ -48,7 +49,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
public class CFileTypesPropertyPage extends PropertyPage {
|
public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
|
|
||||||
class FixCFileTypesPreferenceBlock extends CFileTypesPreferenceBlock {
|
class FixCFileTypesPreferenceBlock extends CFileTypesPreferenceBlock {
|
||||||
ArrayList list = new ArrayList();
|
ArrayList<ContentTypeChangeEvent> list = new ArrayList<ContentTypeChangeEvent>();
|
||||||
|
|
||||||
public FixCFileTypesPreferenceBlock() {
|
public FixCFileTypesPreferenceBlock() {
|
||||||
super();
|
super();
|
||||||
|
@ -229,9 +230,8 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
void computeEvents(IProject project) {
|
void computeEvents(IProject project) {
|
||||||
IScopeContext projectScope = new ProjectScope(project);
|
IScopeContext projectScope = new ProjectScope(project);
|
||||||
IContentType[] ctypes = getRegistedContentTypes();
|
IContentType[] ctypes = getRegistedContentTypes();
|
||||||
ArrayList list = new ArrayList(ctypes.length);
|
ArrayList<IContentType> list = new ArrayList<IContentType>(ctypes.length);
|
||||||
for (int i = 0; i < ctypes.length; i++) {
|
for (IContentType ctype : ctypes) {
|
||||||
IContentType ctype = ctypes[i];
|
|
||||||
try {
|
try {
|
||||||
IContentTypeSettings projectSettings = ctype.getSettings(projectScope);
|
IContentTypeSettings projectSettings = ctype.getSettings(projectScope);
|
||||||
String[] projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
|
String[] projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
|
||||||
|
@ -252,7 +252,7 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
IContentTypeManager.ContentTypeChangeEvent[] events = new IContentTypeManager.ContentTypeChangeEvent[list.size()];
|
IContentTypeManager.ContentTypeChangeEvent[] events = new IContentTypeManager.ContentTypeChangeEvent[list.size()];
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
IContentType source = (IContentType)list.get(i);
|
IContentType source = list.get(i);
|
||||||
events[i] = new IContentTypeManager.ContentTypeChangeEvent(source, projectScope);
|
events[i] = new IContentTypeManager.ContentTypeChangeEvent(source, projectScope);
|
||||||
}
|
}
|
||||||
CModelManager.getDefault().contentTypeChanged(events);
|
CModelManager.getDefault().contentTypeChanged(events);
|
||||||
|
|
|
@ -13,11 +13,6 @@ package org.eclipse.cdt.internal.ui.preferences;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.dom.CDOM;
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReaderCache;
|
|
||||||
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.core.runtime.Preferences;
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
@ -33,6 +28,14 @@ import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.ui.IWorkbench;
|
import org.eclipse.ui.IWorkbench;
|
||||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.CDOM;
|
||||||
|
import org.eclipse.cdt.core.parser.CodeReaderCache;
|
||||||
|
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
* @deprecated the one preference found on the page was moved to the
|
* @deprecated the one preference found on the page was moved to the
|
||||||
|
@ -51,7 +54,7 @@ public class CParserPreferencePage extends PreferencePage implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private OverlayPreferenceStore createOverlayStore() {
|
private OverlayPreferenceStore createOverlayStore() {
|
||||||
ArrayList overlayKeys = new ArrayList();
|
ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CodeReaderCache.CODE_READER_BUFFER));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CodeReaderCache.CODE_READER_BUFFER));
|
||||||
|
|
||||||
OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
|
OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
|
||||||
|
|
|
@ -24,9 +24,19 @@ import org.eclipse.core.commands.IParameter;
|
||||||
import org.eclipse.core.commands.Parameterization;
|
import org.eclipse.core.commands.Parameterization;
|
||||||
import org.eclipse.core.commands.ParameterizedCommand;
|
import org.eclipse.core.commands.ParameterizedCommand;
|
||||||
import org.eclipse.core.commands.common.NotDefinedException;
|
import org.eclipse.core.commands.common.NotDefinedException;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
import org.eclipse.jface.bindings.Binding;
|
||||||
|
import org.eclipse.jface.bindings.TriggerSequence;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
|
import org.eclipse.jface.viewers.ArrayContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||||
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
||||||
|
import org.eclipse.jface.viewers.ICheckStateListener;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.ViewerComparator;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -41,20 +51,6 @@ import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Link;
|
import org.eclipse.swt.widgets.Link;
|
||||||
import org.eclipse.swt.widgets.Table;
|
import org.eclipse.swt.widgets.Table;
|
||||||
import org.eclipse.swt.widgets.TableColumn;
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
|
||||||
import org.eclipse.jface.bindings.Binding;
|
|
||||||
import org.eclipse.jface.bindings.TriggerSequence;
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
|
||||||
import org.eclipse.jface.viewers.ArrayContentProvider;
|
|
||||||
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
|
||||||
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
|
||||||
import org.eclipse.jface.viewers.ICheckStateListener;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.ViewerComparator;
|
|
||||||
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.commands.ICommandService;
|
import org.eclipse.ui.commands.ICommandService;
|
||||||
import org.eclipse.ui.dialogs.PreferencesUtil;
|
import org.eclipse.ui.dialogs.PreferencesUtil;
|
||||||
|
@ -148,13 +144,9 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Comparator fCategoryComparator= new Comparator() {
|
private final Comparator<ModelElement> fCategoryComparator= new Comparator<ModelElement>() {
|
||||||
private int getRank(Object o) {
|
public int compare(ModelElement o1, ModelElement o2) {
|
||||||
return ((ModelElement) o).getRank();
|
return o1.getRank() - o2.getRank();
|
||||||
}
|
|
||||||
|
|
||||||
public int compare(Object o1, Object o2) {
|
|
||||||
return getRank(o1) - getRank(o2);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -163,17 +155,16 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
private static final String COLON= ":"; //$NON-NLS-1$
|
private static final String COLON= ":"; //$NON-NLS-1$
|
||||||
private static final String SEPARATOR= "\0"; //$NON-NLS-1$
|
private static final String SEPARATOR= "\0"; //$NON-NLS-1$
|
||||||
|
|
||||||
private final List fElements;
|
private final List<ModelElement> fElements;
|
||||||
/**
|
/**
|
||||||
* The read-only list of elements.
|
* The read-only list of elements.
|
||||||
*/
|
*/
|
||||||
final List elements;
|
final List<ModelElement> elements;
|
||||||
|
|
||||||
public PreferenceModel(CompletionProposalComputerRegistry registry) {
|
public PreferenceModel(CompletionProposalComputerRegistry registry) {
|
||||||
List categories= registry.getProposalCategories();
|
List<CompletionProposalCategory> categories= registry.getProposalCategories();
|
||||||
fElements= new ArrayList();
|
fElements= new ArrayList<ModelElement>();
|
||||||
for (Iterator it= categories.iterator(); it.hasNext();) {
|
for (CompletionProposalCategory category : categories) {
|
||||||
CompletionProposalCategory category= (CompletionProposalCategory) it.next();
|
|
||||||
if (category.hasComputers()) {
|
if (category.hasComputers()) {
|
||||||
fElements.add(new ModelElement(category, this));
|
fElements.add(new ModelElement(category, this));
|
||||||
}
|
}
|
||||||
|
@ -185,7 +176,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
public void moveUp(ModelElement category) {
|
public void moveUp(ModelElement category) {
|
||||||
int index= fElements.indexOf(category);
|
int index= fElements.indexOf(category);
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
Object item= fElements.remove(index);
|
ModelElement item= fElements.remove(index);
|
||||||
fElements.add(index - 1, item);
|
fElements.add(index - 1, item);
|
||||||
writeOrderPreference(null, false);
|
writeOrderPreference(null, false);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +185,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
public void moveDown(ModelElement category) {
|
public void moveDown(ModelElement category) {
|
||||||
int index= fElements.indexOf(category);
|
int index= fElements.indexOf(category);
|
||||||
if (index < fElements.size() - 1) {
|
if (index < fElements.size() - 1) {
|
||||||
Object item= fElements.remove(index);
|
ModelElement item= fElements.remove(index);
|
||||||
fElements.add(index + 1, item);
|
fElements.add(index + 1, item);
|
||||||
writeOrderPreference(null, false);
|
writeOrderPreference(null, false);
|
||||||
}
|
}
|
||||||
|
@ -202,8 +193,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
|
|
||||||
private void writeInclusionPreference(ModelElement changed, boolean isInDefaultCategory) {
|
private void writeInclusionPreference(ModelElement changed, boolean isInDefaultCategory) {
|
||||||
StringBuffer buf= new StringBuffer();
|
StringBuffer buf= new StringBuffer();
|
||||||
for (Iterator it= fElements.iterator(); it.hasNext();) {
|
for (Object element : fElements) {
|
||||||
ModelElement item= (ModelElement) it.next();
|
ModelElement item= (ModelElement) element;
|
||||||
boolean included= changed == item ? isInDefaultCategory : item.isInDefaultCategory();
|
boolean included= changed == item ? isInDefaultCategory : item.isInDefaultCategory();
|
||||||
if (!included)
|
if (!included)
|
||||||
buf.append(item.getId() + SEPARATOR);
|
buf.append(item.getId() + SEPARATOR);
|
||||||
|
@ -217,8 +208,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
private void writeOrderPreference(ModelElement changed, boolean isSeparate) {
|
private void writeOrderPreference(ModelElement changed, boolean isSeparate) {
|
||||||
StringBuffer buf= new StringBuffer();
|
StringBuffer buf= new StringBuffer();
|
||||||
int i= 0;
|
int i= 0;
|
||||||
for (Iterator it= fElements.iterator(); it.hasNext(); i++) {
|
for (Iterator<ModelElement> it= fElements.iterator(); it.hasNext(); i++) {
|
||||||
ModelElement item= (ModelElement) it.next();
|
ModelElement item= it.next();
|
||||||
boolean separate= changed == item ? isSeparate : item.isSeparateCommand();
|
boolean separate= changed == item ? isSeparate : item.isSeparateCommand();
|
||||||
int rank= separate ? i : i + LIMIT;
|
int rank= separate ? i : i + LIMIT;
|
||||||
buf.append(item.getId() + COLON + rank + SEPARATOR);
|
buf.append(item.getId() + COLON + rank + SEPARATOR);
|
||||||
|
@ -232,8 +223,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
|
|
||||||
private boolean readInclusionPreference(CompletionProposalCategory cat) {
|
private boolean readInclusionPreference(CompletionProposalCategory cat) {
|
||||||
String[] ids= getTokens(getValue(PREF_EXCLUDED_CATEGORIES), SEPARATOR);
|
String[] ids= getTokens(getValue(PREF_EXCLUDED_CATEGORIES), SEPARATOR);
|
||||||
for (int i= 0; i < ids.length; i++) {
|
for (String id : ids) {
|
||||||
if (ids[i].equals(cat.getId()))
|
if (id.equals(cat.getId()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -241,8 +232,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
|
|
||||||
private int readOrderPreference(CompletionProposalCategory cat) {
|
private int readOrderPreference(CompletionProposalCategory cat) {
|
||||||
String[] sortOrderIds= getTokens(getValue(PREF_CATEGORY_ORDER), SEPARATOR);
|
String[] sortOrderIds= getTokens(getValue(PREF_CATEGORY_ORDER), SEPARATOR);
|
||||||
for (int i= 0; i < sortOrderIds.length; i++) {
|
for (String sortOrderId : sortOrderIds) {
|
||||||
String[] idAndRank= getTokens(sortOrderIds[i], COLON);
|
String[] idAndRank= getTokens(sortOrderId, COLON);
|
||||||
if (idAndRank[0].equals(cat.getId()))
|
if (idAndRank[0].equals(cat.getId()))
|
||||||
return Integer.parseInt(idAndRank[1]);
|
return Integer.parseInt(idAndRank[1]);
|
||||||
}
|
}
|
||||||
|
@ -330,7 +321,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
|
|
||||||
/** element type: {@link ModelElement}. */
|
/** element type: {@link ModelElement}. */
|
||||||
private final PreferenceModel fModel;
|
private final PreferenceModel fModel;
|
||||||
private final Map fImages= new HashMap();
|
private final Map<ImageDescriptor, Image> fImages= new HashMap<ImageDescriptor, Image>();
|
||||||
|
|
||||||
private CheckboxTableViewer fDefaultViewer;
|
private CheckboxTableViewer fDefaultViewer;
|
||||||
private CheckboxTableViewer fSeparateViewer;
|
private CheckboxTableViewer fSeparateViewer;
|
||||||
|
@ -550,7 +541,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
int index= getSelectionIndex();
|
int index= getSelectionIndex();
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
((ModelElement) fModel.elements.get(index)).moveUp();
|
(fModel.elements.get(index)).moveUp();
|
||||||
fSeparateViewer.refresh();
|
fSeparateViewer.refresh();
|
||||||
handleTableSelection();
|
handleTableSelection();
|
||||||
}
|
}
|
||||||
|
@ -566,7 +557,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
int index= getSelectionIndex();
|
int index= getSelectionIndex();
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
((ModelElement) fModel.elements.get(index)).moveDown();
|
(fModel.elements.get(index)).moveDown();
|
||||||
fSeparateViewer.refresh();
|
fSeparateViewer.refresh();
|
||||||
handleTableSelection();
|
handleTableSelection();
|
||||||
}
|
}
|
||||||
|
@ -612,11 +603,11 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
|
|
||||||
private void updateCheckedState() {
|
private void updateCheckedState() {
|
||||||
final int size= fModel.elements.size();
|
final int size= fModel.elements.size();
|
||||||
List defaultChecked= new ArrayList(size);
|
List<ModelElement> defaultChecked= new ArrayList<ModelElement>(size);
|
||||||
List separateChecked= new ArrayList(size);
|
List<ModelElement> separateChecked= new ArrayList<ModelElement>(size);
|
||||||
|
|
||||||
for (Iterator it= fModel.elements.iterator(); it.hasNext();) {
|
for (Object element2 : fModel.elements) {
|
||||||
ModelElement element= (ModelElement) it.next();
|
ModelElement element= (ModelElement) element2;
|
||||||
if (element.isInDefaultCategory())
|
if (element.isInDefaultCategory())
|
||||||
defaultChecked.add(element);
|
defaultChecked.add(element);
|
||||||
if (element.isSeparateCommand())
|
if (element.isSeparateCommand())
|
||||||
|
@ -632,8 +623,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
|
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
|
||||||
for (Iterator it= fModel.elements.iterator(); it.hasNext();) {
|
for (Object element : fModel.elements) {
|
||||||
ModelElement item= (ModelElement) it.next();
|
ModelElement item= (ModelElement) element;
|
||||||
item.update();
|
item.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,8 +651,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
for (Iterator it= fImages.values().iterator(); it.hasNext();) {
|
for (Image image : fImages.values()) {
|
||||||
Image image= (Image) it.next();
|
|
||||||
image.dispose();
|
image.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,8 +673,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
private static String getKeyboardShortcut(ParameterizedCommand command) {
|
private static String getKeyboardShortcut(ParameterizedCommand command) {
|
||||||
final IBindingService bindingSvc= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
|
final IBindingService bindingSvc= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
|
||||||
final Binding[] bindings= bindingSvc.getBindings();
|
final Binding[] bindings= bindingSvc.getBindings();
|
||||||
for (int i= 0; i < bindings.length; i++) {
|
for (Binding binding : bindings) {
|
||||||
Binding binding= bindings[i];
|
|
||||||
if (command.equals(binding.getParameterizedCommand())) {
|
if (command.equals(binding.getParameterizedCommand())) {
|
||||||
TriggerSequence triggers= bindingSvc.getBestActiveBindingFor(command.getId());
|
TriggerSequence triggers= bindingSvc.getBestActiveBindingFor(command.getId());
|
||||||
return triggers.format();
|
return triggers.format();
|
||||||
|
@ -697,7 +686,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo
|
||||||
if (imgDesc == null)
|
if (imgDesc == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Image img= (Image) fImages.get(imgDesc);
|
Image img= fImages.get(imgDesc);
|
||||||
if (img == null) {
|
if (img == null) {
|
||||||
img= imgDesc.createImage(false);
|
img= imgDesc.createImage(false);
|
||||||
fImages.put(imgDesc, img);
|
fImages.put(imgDesc, img);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.ui.IWorkbench;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
|
import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +43,7 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
||||||
ArrayList overlayKeys = new ArrayList();
|
ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();
|
||||||
|
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectionChanged(TreeListDialogField field) {
|
public void selectionChanged(TreeListDialogField field) {
|
||||||
List selected= field.getSelectedElements();
|
List<Object> selected= field.getSelectedElements();
|
||||||
field.enableButton(IDX_ADD, canAdd(selected));
|
field.enableButton(IDX_ADD, canAdd(selected));
|
||||||
field.enableButton(IDX_EDIT, canEdit(selected));
|
field.enableButton(IDX_EDIT, canEdit(selected));
|
||||||
field.enableButton(IDX_REMOVE, canRemove(selected));
|
field.enableButton(IDX_REMOVE, canRemove(selected));
|
||||||
|
@ -100,7 +100,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doubleClicked(TreeListDialogField field) {
|
public void doubleClicked(TreeListDialogField field) {
|
||||||
List selected= field.getSelectedElements();
|
List<Object> selected= field.getSelectedElements();
|
||||||
if (canEdit(selected)) {
|
if (canEdit(selected)) {
|
||||||
doButtonPressed(IDX_EDIT, selected);
|
doButtonPressed(IDX_EDIT, selected);
|
||||||
}
|
}
|
||||||
|
@ -451,8 +451,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
protected TemplatePersistenceData[] getCodeTemplatesOfCategory(boolean isComment) {
|
protected TemplatePersistenceData[] getCodeTemplatesOfCategory(boolean isComment) {
|
||||||
ArrayList<TemplatePersistenceData> res= new ArrayList<TemplatePersistenceData>();
|
ArrayList<TemplatePersistenceData> res= new ArrayList<TemplatePersistenceData>();
|
||||||
TemplatePersistenceData[] templates= fTemplateStore.getTemplateData();
|
TemplatePersistenceData[] templates= fTemplateStore.getTemplateData();
|
||||||
for (int i= 0; i < templates.length; i++) {
|
for (TemplatePersistenceData curr : templates) {
|
||||||
TemplatePersistenceData curr= templates[i];
|
|
||||||
boolean isUserAdded= curr.getId() == null;
|
boolean isUserAdded= curr.getId() == null;
|
||||||
boolean isFileTemplate= FileTemplateContextType.isFileTemplateContextType(curr.getTemplate().getContextTypeId());
|
boolean isFileTemplate= FileTemplateContextType.isFileTemplateContextType(curr.getTemplate().getContextTypeId());
|
||||||
if (!isUserAdded && !isFileTemplate && isComment == curr.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
|
if (!isUserAdded && !isFileTemplate && isComment == curr.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
|
||||||
|
@ -469,8 +468,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
protected TemplatePersistenceData[] getTemplatesOfContextType(String contextTypeId) {
|
protected TemplatePersistenceData[] getTemplatesOfContextType(String contextTypeId) {
|
||||||
ArrayList<TemplatePersistenceData> res= new ArrayList<TemplatePersistenceData>();
|
ArrayList<TemplatePersistenceData> res= new ArrayList<TemplatePersistenceData>();
|
||||||
TemplatePersistenceData[] templates= fTemplateStore.getTemplateData();
|
TemplatePersistenceData[] templates= fTemplateStore.getTemplateData();
|
||||||
for (int i= 0; i < templates.length; i++) {
|
for (TemplatePersistenceData curr : templates) {
|
||||||
TemplatePersistenceData curr= templates[i];
|
|
||||||
if (contextTypeId.equals(curr.getTemplate().getContextTypeId())) {
|
if (contextTypeId.equals(curr.getTemplate().getContextTypeId())) {
|
||||||
res.add(curr);
|
res.add(curr);
|
||||||
}
|
}
|
||||||
|
@ -481,7 +479,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
protected ContextTypeRegistry getFileTemplateContextRegistry() {
|
protected ContextTypeRegistry getFileTemplateContextRegistry() {
|
||||||
if (fFileTemplateContextTypes == null) {
|
if (fFileTemplateContextTypes == null) {
|
||||||
fFileTemplateContextTypes= new ContextTypeRegistry();
|
fFileTemplateContextTypes= new ContextTypeRegistry();
|
||||||
Iterator contextTypesIter= CUIPlugin.getDefault().getCodeTemplateContextRegistry().contextTypes();
|
Iterator<?> contextTypesIter= CUIPlugin.getDefault().getCodeTemplateContextRegistry().contextTypes();
|
||||||
while(contextTypesIter.hasNext()) {
|
while(contextTypesIter.hasNext()) {
|
||||||
TemplateContextType contextType= (TemplateContextType)contextTypesIter.next();
|
TemplateContextType contextType= (TemplateContextType)contextTypesIter.next();
|
||||||
final String contextTypeId= contextType.getId();
|
final String contextTypeId= contextType.getId();
|
||||||
|
@ -495,7 +493,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TemplateContextType[] getFileTemplateContextTypes() {
|
protected TemplateContextType[] getFileTemplateContextTypes() {
|
||||||
Iterator iter= getFileTemplateContextRegistry().contextTypes();
|
Iterator<?> iter= getFileTemplateContextRegistry().contextTypes();
|
||||||
ArrayList<TemplateContextType> result= new ArrayList<TemplateContextType>();
|
ArrayList<TemplateContextType> result= new ArrayList<TemplateContextType>();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
TemplateContextType contextType= (TemplateContextType)iter.next();
|
TemplateContextType contextType= (TemplateContextType)iter.next();
|
||||||
|
@ -506,7 +504,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
return result.toArray(new TemplateContextType[0]);
|
return result.toArray(new TemplateContextType[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean canAdd(List selected) {
|
protected static boolean canAdd(List<Object> selected) {
|
||||||
if (selected.size() == 1) {
|
if (selected.size() == 1) {
|
||||||
Object element= selected.get(0);
|
Object element= selected.get(0);
|
||||||
if (element instanceof TemplateContextType || element == FILE_NODE) {
|
if (element instanceof TemplateContextType || element == FILE_NODE) {
|
||||||
|
@ -522,11 +520,11 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean canEdit(List selected) {
|
protected static boolean canEdit(List<Object> selected) {
|
||||||
return selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData);
|
return selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean canRemove(List selected) {
|
protected static boolean canRemove(List<Object> selected) {
|
||||||
if (selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData)) {
|
if (selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData)) {
|
||||||
TemplatePersistenceData data= (TemplatePersistenceData)selected.get(0);
|
TemplatePersistenceData data= (TemplatePersistenceData)selected.get(0);
|
||||||
return data.isUserAdded();
|
return data.isUserAdded();
|
||||||
|
@ -534,7 +532,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateSourceViewerInput(List selection) {
|
protected void updateSourceViewerInput(List<Object> selection) {
|
||||||
if (fPatternViewer == null || fPatternViewer.getTextWidget().isDisposed()) {
|
if (fPatternViewer == null || fPatternViewer.getTextWidget().isDisposed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -550,7 +548,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doButtonPressed(int buttonIndex, List selected) {
|
protected void doButtonPressed(int buttonIndex, List<Object> selected) {
|
||||||
switch (buttonIndex) {
|
switch (buttonIndex) {
|
||||||
case IDX_EDIT:
|
case IDX_EDIT:
|
||||||
edit((TemplatePersistenceData) selected.get(0), false);
|
edit((TemplatePersistenceData) selected.get(0), false);
|
||||||
|
@ -643,8 +641,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
InputStream input= new BufferedInputStream(new FileInputStream(file));
|
InputStream input= new BufferedInputStream(new FileInputStream(file));
|
||||||
try {
|
try {
|
||||||
TemplatePersistenceData[] datas= reader.read(input, null);
|
TemplatePersistenceData[] datas= reader.read(input, null);
|
||||||
for (int i= 0; i < datas.length; i++) {
|
for (TemplatePersistenceData data : datas) {
|
||||||
updateTemplate(datas[i]);
|
updateTemplate(data);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
@ -670,22 +668,22 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
TemplatePersistenceData[] datas= fTemplateStore.getTemplateData();
|
TemplatePersistenceData[] datas= fTemplateStore.getTemplateData();
|
||||||
if (dataId != null) {
|
if (dataId != null) {
|
||||||
// predefined
|
// predefined
|
||||||
for (int i= 0; i < datas.length; i++) {
|
for (TemplatePersistenceData data2 : datas) {
|
||||||
String id= datas[i].getId();
|
String id= data2.getId();
|
||||||
if (id != null && id.equals(dataId)) {
|
if (id != null && id.equals(dataId)) {
|
||||||
datas[i].setTemplate(data.getTemplate());
|
data2.setTemplate(data.getTemplate());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// user added
|
// user added
|
||||||
String dataName= data.getTemplate().getName();
|
String dataName= data.getTemplate().getName();
|
||||||
for (int i= 0; i < datas.length; i++) {
|
for (TemplatePersistenceData data2 : datas) {
|
||||||
if (datas[i].getId() == null) {
|
if (data2.getId() == null) {
|
||||||
String name= datas[i].getTemplate().getName();
|
String name= data2.getTemplate().getName();
|
||||||
String contextTypeId= datas[i].getTemplate().getContextTypeId();
|
String contextTypeId= data2.getTemplate().getContextTypeId();
|
||||||
if (name != null && name.equals(dataName) && contextTypeId.equals(data.getTemplate().getContextTypeId())) {
|
if (name != null && name.equals(dataName) && contextTypeId.equals(data.getTemplate().getContextTypeId())) {
|
||||||
datas[i].setTemplate(data.getTemplate());
|
data2.setTemplate(data.getTemplate());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -699,7 +697,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
export(fTemplateStore.getTemplateData());
|
export(fTemplateStore.getTemplateData());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void export(List selected) {
|
private void export(List<Object> selected) {
|
||||||
Set<Object> datas= new HashSet<Object>();
|
Set<Object> datas= new HashSet<Object>();
|
||||||
for (int i= 0; i < selected.size(); i++) {
|
for (int i= 0; i < selected.size(); i++) {
|
||||||
Object curr= selected.get(i);
|
Object curr= selected.get(i);
|
||||||
|
@ -710,8 +708,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
datas.addAll(Arrays.asList(cat));
|
datas.addAll(Arrays.asList(cat));
|
||||||
} else if (curr == FILE_NODE) {
|
} else if (curr == FILE_NODE) {
|
||||||
TemplateContextType[] types= getFileTemplateContextTypes();
|
TemplateContextType[] types= getFileTemplateContextTypes();
|
||||||
for (int j = 0; j < types.length; j++) {
|
for (TemplateContextType contextType : types) {
|
||||||
TemplateContextType contextType = types[j];
|
|
||||||
TemplatePersistenceData[] cat= getTemplatesOfContextType(contextType);
|
TemplatePersistenceData[] cat= getTemplatesOfContextType(contextType);
|
||||||
datas.addAll(Arrays.asList(cat));
|
datas.addAll(Arrays.asList(cat));
|
||||||
}
|
}
|
||||||
|
@ -793,8 +790,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
|
||||||
|
|
||||||
if (fProject != null) {
|
if (fProject != null) {
|
||||||
TemplatePersistenceData[] templateData= fTemplateStore.getTemplateData();
|
TemplatePersistenceData[] templateData= fTemplateStore.getTemplateData();
|
||||||
for (int i= 0; i < templateData.length; i++) {
|
for (TemplatePersistenceData element : templateData) {
|
||||||
fTemplateStore.setProjectSpecific(templateData[i].getId(), enabled);
|
fTemplateStore.setProjectSpecific(element.getId(), enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -160,12 +160,10 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
|
||||||
@Override
|
@Override
|
||||||
public void applyData(Object data) {
|
public void applyData(Object data) {
|
||||||
if (data instanceof Map) {
|
if (data instanceof Map) {
|
||||||
Object id= ((Map) data).get(DATA_SELECT_TEMPLATE);
|
Object id= ((Map<?, ?>) data).get(DATA_SELECT_TEMPLATE);
|
||||||
if (id instanceof String) {
|
if (id instanceof String) {
|
||||||
final TemplatePersistenceData[] templates= fCodeTemplateConfigurationBlock.fTemplateStore.getTemplateData();
|
final TemplatePersistenceData[] templates= fCodeTemplateConfigurationBlock.fTemplateStore.getTemplateData();
|
||||||
TemplatePersistenceData template= null;
|
for (TemplatePersistenceData template : templates) {
|
||||||
for (int index= 0; index < templates.length; index++) {
|
|
||||||
template= templates[index];
|
|
||||||
if (id.equals(template.getId()) || id.equals(template.getTemplate().getName())) {
|
if (id.equals(template.getId()) || id.equals(template.getTemplate().getName())) {
|
||||||
fCodeTemplateConfigurationBlock.postSetSelection(template);
|
fCodeTemplateConfigurationBlock.postSetSelection(template);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class CodeTemplateSourceViewerConfiguration extends SimpleCSourceViewerCo
|
||||||
String varName= doc.get(offset, subject.getLength());
|
String varName= doc.get(offset, subject.getLength());
|
||||||
TemplateContextType contextType= fProcessor.getContextType();
|
TemplateContextType contextType= fProcessor.getContextType();
|
||||||
if (contextType != null) {
|
if (contextType != null) {
|
||||||
Iterator iter= contextType.resolvers();
|
Iterator<?> iter= contextType.resolvers();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
TemplateVariableResolver var= (TemplateVariableResolver) iter.next();
|
TemplateVariableResolver var= (TemplateVariableResolver) iter.next();
|
||||||
if (varName.equals(var.getType())) {
|
if (varName.equals(var.getType())) {
|
||||||
|
|
|
@ -191,7 +191,7 @@ class EditTemplateDialog extends StatusDialog {
|
||||||
// String delim= new Document().getLegalLineDelimiters()[0];
|
// String delim= new Document().getLegalLineDelimiters()[0];
|
||||||
|
|
||||||
List<String[]> contexts= new ArrayList<String[]>();
|
List<String[]> contexts= new ArrayList<String[]>();
|
||||||
for (Iterator it= registry.contextTypes(); it.hasNext();) {
|
for (Iterator<?> it= registry.contextTypes(); it.hasNext();) {
|
||||||
TemplateContextType type= (TemplateContextType) it.next();
|
TemplateContextType type= (TemplateContextType) it.next();
|
||||||
// TODO cppdoc? doxygen?
|
// TODO cppdoc? doxygen?
|
||||||
// if (type.getId().equals("javadoc")) //$NON-NLS-1$
|
// if (type.getId().equals("javadoc")) //$NON-NLS-1$
|
||||||
|
@ -277,8 +277,8 @@ class EditTemplateDialog extends StatusDialog {
|
||||||
createLabel(composite, PreferencesMessages.EditTemplateDialog_contextType);
|
createLabel(composite, PreferencesMessages.EditTemplateDialog_contextType);
|
||||||
fContextCombo= new Combo(composite, SWT.READ_ONLY);
|
fContextCombo= new Combo(composite, SWT.READ_ONLY);
|
||||||
fContextCombo.setVisibleItemCount(10);
|
fContextCombo.setVisibleItemCount(10);
|
||||||
for (int i= 0; i < fContextTypes.length; i++) {
|
for (String[] contextType : fContextTypes) {
|
||||||
fContextCombo.add(fContextTypes[i][1]);
|
fContextCombo.add(contextType[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fContextCombo.addModifyListener(listener);
|
fContextCombo.addModifyListener(listener);
|
||||||
|
@ -359,9 +359,9 @@ class EditTemplateDialog extends StatusDialog {
|
||||||
private String getContextId() {
|
private String getContextId() {
|
||||||
if (fContextCombo != null && !fContextCombo.isDisposed()) {
|
if (fContextCombo != null && !fContextCombo.isDisposed()) {
|
||||||
String name= fContextCombo.getText();
|
String name= fContextCombo.getText();
|
||||||
for (int i= 0; i < fContextTypes.length; i++) {
|
for (String[] contextType : fContextTypes) {
|
||||||
if (name.equals(fContextTypes[i][1])) {
|
if (name.equals(contextType[1])) {
|
||||||
return fContextTypes[i][0];
|
return contextType[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,7 +475,6 @@ class EditTemplateDialog extends StatusDialog {
|
||||||
int idx= getIndex(id);
|
int idx= getIndex(id);
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
return fContextTypes[idx][2];
|
return fContextTypes[idx][2];
|
||||||
else
|
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock;
|
import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
|
||||||
import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderDescriptor;
|
import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderDescriptor;
|
||||||
import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistry;
|
import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistry;
|
||||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||||
|
@ -98,10 +99,10 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
|
||||||
private Combo fProviderCombo;
|
private Combo fProviderCombo;
|
||||||
protected Button fFoldingCheckbox;
|
protected Button fFoldingCheckbox;
|
||||||
private ComboViewer fProviderViewer;
|
private ComboViewer fProviderViewer;
|
||||||
protected Map fProviderDescriptors;
|
protected Map<String, CFoldingStructureProviderDescriptor> fProviderDescriptors;
|
||||||
private Composite fGroup;
|
private Composite fGroup;
|
||||||
private Map fProviderPreferences;
|
private Map<String, ICFoldingPreferenceBlock> fProviderPreferences;
|
||||||
private Map fProviderControls;
|
private Map<String, Control> fProviderControls;
|
||||||
private StackLayout fStackLayout;
|
private StackLayout fStackLayout;
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,15 +111,15 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
|
||||||
fStore= store;
|
fStore= store;
|
||||||
fStore.addKeys(createOverlayStoreKeys());
|
fStore.addKeys(createOverlayStoreKeys());
|
||||||
fProviderDescriptors= createListModel();
|
fProviderDescriptors= createListModel();
|
||||||
fProviderPreferences= new HashMap();
|
fProviderPreferences= new HashMap<String, ICFoldingPreferenceBlock>();
|
||||||
fProviderControls= new HashMap();
|
fProviderControls= new HashMap<String, Control>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map createListModel() {
|
private Map<String, CFoldingStructureProviderDescriptor> createListModel() {
|
||||||
CFoldingStructureProviderRegistry reg= CUIPlugin.getDefault().getFoldingStructureProviderRegistry();
|
CFoldingStructureProviderRegistry reg= CUIPlugin.getDefault().getFoldingStructureProviderRegistry();
|
||||||
reg.reloadExtensions();
|
reg.reloadExtensions();
|
||||||
CFoldingStructureProviderDescriptor[] descs= reg.getFoldingProviderDescriptors();
|
CFoldingStructureProviderDescriptor[] descs= reg.getFoldingProviderDescriptors();
|
||||||
Map map= new HashMap();
|
Map<String, CFoldingStructureProviderDescriptor> map= new HashMap<String, CFoldingStructureProviderDescriptor>();
|
||||||
for (int i= 0; i < descs.length; i++) {
|
for (int i= 0; i < descs.length; i++) {
|
||||||
map.put(descs[i].getId(), descs[i]);
|
map.put(descs[i].getId(), descs[i]);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +128,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
|
||||||
|
|
||||||
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
||||||
|
|
||||||
ArrayList overlayKeys= new ArrayList();
|
ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
|
||||||
|
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_ENABLED));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_ENABLED));
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOLDING_PROVIDER));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOLDING_PROVIDER));
|
||||||
|
@ -269,7 +270,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
|
||||||
|
|
||||||
void updateListDependencies() {
|
void updateListDependencies() {
|
||||||
String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
|
String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
|
||||||
CFoldingStructureProviderDescriptor desc= (CFoldingStructureProviderDescriptor) fProviderDescriptors.get(id);
|
CFoldingStructureProviderDescriptor desc= fProviderDescriptors.get(id);
|
||||||
ICFoldingPreferenceBlock prefs;
|
ICFoldingPreferenceBlock prefs;
|
||||||
|
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
|
@ -278,7 +279,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
|
||||||
CUIPlugin.log(new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null));
|
CUIPlugin.log(new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null));
|
||||||
prefs= new ErrorPreferences(message);
|
prefs= new ErrorPreferences(message);
|
||||||
} else {
|
} else {
|
||||||
prefs= (ICFoldingPreferenceBlock) fProviderPreferences.get(id);
|
prefs= fProviderPreferences.get(id);
|
||||||
if (prefs == null) {
|
if (prefs == null) {
|
||||||
try {
|
try {
|
||||||
prefs= desc.createPreferences();
|
prefs= desc.createPreferences();
|
||||||
|
@ -290,7 +291,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Control control= (Control) fProviderControls.get(id);
|
Control control= fProviderControls.get(id);
|
||||||
if (control == null) {
|
if (control == null) {
|
||||||
control= prefs.createControl(fGroup);
|
control= prefs.createControl(fGroup);
|
||||||
if (control == null) {
|
if (control == null) {
|
||||||
|
@ -319,8 +320,8 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
|
||||||
* @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk()
|
* @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk()
|
||||||
*/
|
*/
|
||||||
public void performOk() {
|
public void performOk() {
|
||||||
for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
|
for (Iterator<ICFoldingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
|
||||||
ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next();
|
ICFoldingPreferenceBlock prefs= it.next();
|
||||||
prefs.performOk();
|
prefs.performOk();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,8 +331,8 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
|
||||||
*/
|
*/
|
||||||
public void performDefaults() {
|
public void performDefaults() {
|
||||||
restoreFromPreferences();
|
restoreFromPreferences();
|
||||||
for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
|
for (Iterator<ICFoldingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
|
||||||
ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next();
|
ICFoldingPreferenceBlock prefs= it.next();
|
||||||
prefs.performDefaults();
|
prefs.performDefaults();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,8 +341,8 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
|
||||||
* @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
|
* @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
|
||||||
*/
|
*/
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
|
for (Iterator<ICFoldingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
|
||||||
ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next();
|
ICFoldingPreferenceBlock prefs= it.next();
|
||||||
prefs.dispose();
|
prefs.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.eclipse.ui.dialogs.PreferencesUtil;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||||
|
import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
|
||||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,13 +48,13 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock
|
||||||
private OverlayPreferenceStore fStore;
|
private OverlayPreferenceStore fStore;
|
||||||
|
|
||||||
|
|
||||||
private Map fCheckBoxes= new HashMap();
|
private Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
|
||||||
private SelectionListener fCheckBoxListener= new SelectionListener() {
|
private SelectionListener fCheckBoxListener= new SelectionListener() {
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
}
|
}
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
Button button= (Button) e.widget;
|
Button button= (Button) e.widget;
|
||||||
fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
|
fStore.setValue(fCheckBoxes.get(button), button.getSelection());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock
|
||||||
*
|
*
|
||||||
* @see #createDependency(Button, String, Control)
|
* @see #createDependency(Button, String, Control)
|
||||||
*/
|
*/
|
||||||
private ArrayList fMasterSlaveListeners= new ArrayList();
|
private ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>();
|
||||||
|
|
||||||
private StatusInfo fStatus;
|
private StatusInfo fStatus;
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock
|
||||||
|
|
||||||
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
||||||
|
|
||||||
ArrayList overlayKeys= new ArrayList();
|
ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
|
||||||
|
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES));
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
|
||||||
|
@ -180,10 +181,10 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock
|
||||||
|
|
||||||
void initializeFields() {
|
void initializeFields() {
|
||||||
|
|
||||||
Iterator iter= fCheckBoxes.keySet().iterator();
|
Iterator<Object> iter= fCheckBoxes.keySet().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Button b= (Button) iter.next();
|
Button b= (Button) iter.next();
|
||||||
String key= (String) fCheckBoxes.get(b);
|
String key= fCheckBoxes.get(b);
|
||||||
b.setSelection(fStore.getBoolean(key));
|
b.setSelection(fStore.getBoolean(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class PathEntryVariableDialog extends TitleAreaDialog {
|
||||||
* Set of variable names currently in use. Used when warning the user that
|
* Set of variable names currently in use. Used when warning the user that
|
||||||
* the currently selected name is already in use by another variable.
|
* the currently selected name is already in use by another variable.
|
||||||
*/
|
*/
|
||||||
private Set namesInUse;
|
private Set<String> namesInUse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current validation status. Its value can be one of the following:<ul>
|
* The current validation status. Its value can be one of the following:<ul>
|
||||||
|
@ -149,7 +149,7 @@ public class PathEntryVariableDialog extends TitleAreaDialog {
|
||||||
* this dialog. <code>IResource.FILE</code> or <code>IResource.FOLDER</code>
|
* this dialog. <code>IResource.FILE</code> or <code>IResource.FOLDER</code>
|
||||||
* @param namesInUse a set of variable names currently in use
|
* @param namesInUse a set of variable names currently in use
|
||||||
*/
|
*/
|
||||||
public PathEntryVariableDialog(Shell parentShell, int type, int variableType, Set namesInUse) {
|
public PathEntryVariableDialog(Shell parentShell, int type, int variableType, Set<String> namesInUse) {
|
||||||
super(parentShell);
|
super(parentShell);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.newVariable = type == NEW_VARIABLE;
|
this.newVariable = type == NEW_VARIABLE;
|
||||||
|
|
|
@ -14,15 +14,12 @@ package org.eclipse.cdt.internal.ui.preferences;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.core.resources.IPathVariableManager;
|
||||||
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -53,6 +50,11 @@ import org.eclipse.swt.widgets.TableItem;
|
||||||
import org.eclipse.ui.ISharedImages;
|
import org.eclipse.ui.ISharedImages;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
|
||||||
public class PathEntryVariablesGroup {
|
public class PathEntryVariablesGroup {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,10 +95,10 @@ public class PathEntryVariablesGroup {
|
||||||
protected Listener selectionListener;
|
protected Listener selectionListener;
|
||||||
|
|
||||||
// temporary collection for keeping currently defined variables
|
// temporary collection for keeping currently defined variables
|
||||||
private SortedMap tempPathVariables;
|
private SortedMap<String, IPath> tempPathVariables;
|
||||||
|
|
||||||
// set of removed variables' names
|
// set of removed variables' names
|
||||||
private Set removedVariableNames;
|
private Set<String> removedVariableNames;
|
||||||
|
|
||||||
// reference to the workspace's path variable manager
|
// reference to the workspace's path variable manager
|
||||||
private IPathEntryVariableManager pathEntryVariableManager;
|
private IPathEntryVariableManager pathEntryVariableManager;
|
||||||
|
@ -124,8 +126,8 @@ public class PathEntryVariablesGroup {
|
||||||
this.multiSelect = multiSelect;
|
this.multiSelect = multiSelect;
|
||||||
this.variableType = variableType;
|
this.variableType = variableType;
|
||||||
pathEntryVariableManager = CCorePlugin.getDefault().getPathEntryVariableManager();
|
pathEntryVariableManager = CCorePlugin.getDefault().getPathEntryVariableManager();
|
||||||
removedVariableNames = new HashSet();
|
removedVariableNames = new HashSet<String>();
|
||||||
tempPathVariables = new TreeMap();
|
tempPathVariables = new TreeMap<String, IPath>();
|
||||||
// initialize internal model
|
// initialize internal model
|
||||||
initTemporaryState();
|
initTemporaryState();
|
||||||
}
|
}
|
||||||
|
@ -252,7 +254,7 @@ public class PathEntryVariablesGroup {
|
||||||
TableItem item = variableTable.getItem(variableTable
|
TableItem item = variableTable.getItem(variableTable
|
||||||
.getSelectionIndex());
|
.getSelectionIndex());
|
||||||
String variableName = (String) item.getData();
|
String variableName = (String) item.getData();
|
||||||
IPath variableValue = (IPath) tempPathVariables.get(variableName);
|
IPath variableValue = tempPathVariables.get(variableName);
|
||||||
|
|
||||||
// constructs a dialog for editing the variable's current name and value
|
// constructs a dialog for editing the variable's current name and value
|
||||||
PathEntryVariableDialog dialog = new PathEntryVariableDialog(shell,
|
PathEntryVariableDialog dialog = new PathEntryVariableDialog(shell,
|
||||||
|
@ -312,7 +314,7 @@ public class PathEntryVariablesGroup {
|
||||||
String name = (String) items[i].getData();
|
String name = (String) items[i].getData();
|
||||||
selection[i] = new PathEntryVariableElement();
|
selection[i] = new PathEntryVariableElement();
|
||||||
selection[i].name = name;
|
selection[i].name = name;
|
||||||
selection[i].path = (IPath)tempPathVariables.get(name);
|
selection[i].path = tempPathVariables.get(name);
|
||||||
}
|
}
|
||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
|
@ -394,8 +396,8 @@ public class PathEntryVariablesGroup {
|
||||||
String[] varNames = pathEntryVariableManager.getVariableNames();
|
String[] varNames = pathEntryVariableManager.getVariableNames();
|
||||||
|
|
||||||
tempPathVariables.clear();
|
tempPathVariables.clear();
|
||||||
for (int i = 0; i < varNames.length; i++) {
|
for (String varName : varNames) {
|
||||||
IPath value = pathEntryVariableManager.getValue(varNames[i]);
|
IPath value = pathEntryVariableManager.getValue(varName);
|
||||||
|
|
||||||
// the value may not exist any more
|
// the value may not exist any more
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
@ -403,7 +405,7 @@ public class PathEntryVariablesGroup {
|
||||||
if ((isFile && (variableType & IResource.FILE) != 0)
|
if ((isFile && (variableType & IResource.FILE) != 0)
|
||||||
|| (isFile == false && (variableType & IResource.FOLDER) != 0)) {
|
|| (isFile == false && (variableType & IResource.FOLDER) != 0)) {
|
||||||
|
|
||||||
tempPathVariables.put(varNames[i], value);
|
tempPathVariables.put(varName, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -434,10 +436,9 @@ public class PathEntryVariablesGroup {
|
||||||
private void updateVariableTable(String selectedVarName) {
|
private void updateVariableTable(String selectedVarName) {
|
||||||
variableTable.removeAll();
|
variableTable.removeAll();
|
||||||
int selectedVarIndex = 0;
|
int selectedVarIndex = 0;
|
||||||
for (Iterator varNames = tempPathVariables.keySet().iterator(); varNames.hasNext();) {
|
for (String varName : tempPathVariables.keySet()) {
|
||||||
TableItem item = new TableItem(variableTable, SWT.NONE);
|
TableItem item = new TableItem(variableTable, SWT.NONE);
|
||||||
String varName = (String) varNames.next();
|
IPath value = tempPathVariables.get(varName);
|
||||||
IPath value = (IPath) tempPathVariables.get(varName);
|
|
||||||
File file = value.toFile();
|
File file = value.toFile();
|
||||||
|
|
||||||
item.setText(varName + " - " + value.toOSString()); //$NON-NLS-1$
|
item.setText(varName + " - " + value.toOSString()); //$NON-NLS-1$
|
||||||
|
@ -466,18 +467,16 @@ public class PathEntryVariablesGroup {
|
||||||
public boolean performOk() {
|
public boolean performOk() {
|
||||||
try {
|
try {
|
||||||
// first process removed variables
|
// first process removed variables
|
||||||
for (Iterator removed = removedVariableNames.iterator(); removed.hasNext();) {
|
for (String removedVariableName : removedVariableNames) {
|
||||||
String removedVariableName = (String) removed.next();
|
|
||||||
// only removes variables that have not been added again
|
// only removes variables that have not been added again
|
||||||
if (!tempPathVariables.containsKey(removedVariableName))
|
if (!tempPathVariables.containsKey(removedVariableName))
|
||||||
pathEntryVariableManager.setValue(removedVariableName, null);
|
pathEntryVariableManager.setValue(removedVariableName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// then process the current collection of variables, adding/updating them
|
// then process the current collection of variables, adding/updating them
|
||||||
for (Iterator current = tempPathVariables.entrySet().iterator(); current.hasNext();) {
|
for (Entry<String, IPath> entry : tempPathVariables.entrySet()) {
|
||||||
Map.Entry entry = (Map.Entry) current.next();
|
String variableName = entry.getKey();
|
||||||
String variableName = (String) entry.getKey();
|
IPath variableValue = entry.getValue();
|
||||||
IPath variableValue = (IPath) entry.getValue();
|
|
||||||
pathEntryVariableManager.setValue(variableName, variableValue);
|
pathEntryVariableManager.setValue(variableName, variableValue);
|
||||||
}
|
}
|
||||||
// re-initialize temporary state
|
// re-initialize temporary state
|
||||||
|
@ -497,8 +496,8 @@ public class PathEntryVariablesGroup {
|
||||||
protected void removeSelectedVariables() {
|
protected void removeSelectedVariables() {
|
||||||
// remove each selected element
|
// remove each selected element
|
||||||
int[] selectedIndices = variableTable.getSelectionIndices();
|
int[] selectedIndices = variableTable.getSelectionIndices();
|
||||||
for (int i = 0; i < selectedIndices.length; i++) {
|
for (int selectedIndice : selectedIndices) {
|
||||||
TableItem selectedItem = variableTable.getItem(selectedIndices[i]);
|
TableItem selectedItem = variableTable.getItem(selectedIndice);
|
||||||
String varName = (String) selectedItem.getData();
|
String varName = (String) selectedItem.getData();
|
||||||
removedVariableNames.add(varName);
|
removedVariableNames.add(varName);
|
||||||
tempPathVariables.remove(varName);
|
tempPathVariables.remove(varName);
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.eclipse.ui.dialogs.SelectionStatusDialog;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICModel;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.ui.CElementContentProvider;
|
import org.eclipse.cdt.ui.CElementContentProvider;
|
||||||
import org.eclipse.cdt.ui.CElementLabelProvider;
|
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||||
import org.eclipse.cdt.ui.CElementSorter;
|
import org.eclipse.cdt.ui.CElementSorter;
|
||||||
|
@ -48,7 +49,7 @@ public class ProjectSelectionDialog extends SelectionStatusDialog {
|
||||||
|
|
||||||
// the visual selection widget group
|
// the visual selection widget group
|
||||||
private TableViewer fTableViewer;
|
private TableViewer fTableViewer;
|
||||||
private Set fProjectsWithSpecifics;
|
private Set<ICProject> fProjectsWithSpecifics;
|
||||||
|
|
||||||
// sizing constants
|
// sizing constants
|
||||||
private final static int SIZING_SELECTION_WIDGET_HEIGHT= 250;
|
private final static int SIZING_SELECTION_WIDGET_HEIGHT= 250;
|
||||||
|
@ -58,7 +59,7 @@ public class ProjectSelectionDialog extends SelectionStatusDialog {
|
||||||
|
|
||||||
private ViewerFilter fFilter;
|
private ViewerFilter fFilter;
|
||||||
|
|
||||||
public ProjectSelectionDialog(Shell parentShell, Set projectsWithSpecifics) {
|
public ProjectSelectionDialog(Shell parentShell, Set<ICProject> projectsWithSpecifics) {
|
||||||
super(parentShell);
|
super(parentShell);
|
||||||
setTitle(PreferencesMessages.ProjectSelectionDialog_title);
|
setTitle(PreferencesMessages.ProjectSelectionDialog_title);
|
||||||
setMessage(PreferencesMessages.ProjectSelectionDialog_desciption);
|
setMessage(PreferencesMessages.ProjectSelectionDialog_desciption);
|
||||||
|
|
|
@ -63,7 +63,7 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
|
||||||
private Composite fParentComposite;
|
private Composite fParentComposite;
|
||||||
|
|
||||||
private IProject fProject; // project or null
|
private IProject fProject; // project or null
|
||||||
private Map fData; // page data
|
private Map <?,?> fData; // page data
|
||||||
|
|
||||||
public static final String DATA_NO_LINK= "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$
|
public static final String DATA_NO_LINK= "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -191,17 +191,16 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
|
||||||
* @param link the link
|
* @param link the link
|
||||||
*/
|
*/
|
||||||
final void doLinkActivated(Link link) {
|
final void doLinkActivated(Link link) {
|
||||||
Map data= new HashMap();
|
Map<String, Boolean> data= new HashMap<String, Boolean>();
|
||||||
data.put(DATA_NO_LINK, Boolean.TRUE);
|
data.put(DATA_NO_LINK, Boolean.TRUE);
|
||||||
|
|
||||||
if (isProjectPreferencePage()) {
|
if (isProjectPreferencePage()) {
|
||||||
openWorkspacePreferences(data);
|
openWorkspacePreferences(data);
|
||||||
} else {
|
} else {
|
||||||
HashSet projectsWithSpecifics= new HashSet();
|
HashSet<ICProject> projectsWithSpecifics= new HashSet<ICProject>();
|
||||||
try {
|
try {
|
||||||
ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
|
ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
|
||||||
for (int i= 0; i < projects.length; i++) {
|
for (ICProject curr : projects) {
|
||||||
ICProject curr= projects[i];
|
|
||||||
if (hasProjectSpecificOptions(curr.getProject())) {
|
if (hasProjectSpecificOptions(curr.getProject())) {
|
||||||
projectsWithSpecifics.add(curr);
|
projectsWithSpecifics.add(curr);
|
||||||
}
|
}
|
||||||
|
@ -334,7 +333,7 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
|
||||||
@Override
|
@Override
|
||||||
public void applyData(Object data) {
|
public void applyData(Object data) {
|
||||||
if (data instanceof Map) {
|
if (data instanceof Map) {
|
||||||
fData= (Map) data;
|
fData= (Map<?,?>) data;
|
||||||
}
|
}
|
||||||
if (fChangeWorkspaceSettings != null) {
|
if (fChangeWorkspaceSettings != null) {
|
||||||
if (!offerLink()) {
|
if (!offerLink()) {
|
||||||
|
@ -344,8 +343,7 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map getData() {
|
protected Map<?,?> getData() {
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,6 @@ package org.eclipse.cdt.internal.ui.preferences;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
|
@ -22,6 +20,10 @@ import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.swt.widgets.Combo;
|
import org.eclipse.swt.widgets.Combo;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class which encapsulates several utility functions
|
* A class which encapsulates several utility functions
|
||||||
* related to code completion preference settings.
|
* related to code completion preference settings.
|
||||||
|
@ -40,16 +42,14 @@ public class ProposalFilterPreferencesUtil {
|
||||||
* to fill into the Combo)
|
* to fill into the Combo)
|
||||||
*/
|
*/
|
||||||
public static String[] getProposalFilterNames() {
|
public static String[] getProposalFilterNames() {
|
||||||
ArrayList names = new ArrayList();
|
ArrayList<String> names = new ArrayList<String>();
|
||||||
try {
|
try {
|
||||||
IExtensionPoint point = Platform.getExtensionRegistry()
|
IExtensionPoint point = Platform.getExtensionRegistry()
|
||||||
.getExtensionPoint(CUIPlugin.PLUGIN_ID, "ProposalFilter"); //$NON-NLS-1$
|
.getExtensionPoint(CUIPlugin.PLUGIN_ID, "ProposalFilter"); //$NON-NLS-1$
|
||||||
if (point != null) {
|
if (point != null) {
|
||||||
IExtension[] extensions = point.getExtensions();
|
IExtension[] extensions = point.getExtensions();
|
||||||
for (int i = 0; i < extensions.length; i++) {
|
for (IExtension extension : extensions) {
|
||||||
IExtension extension = extensions[i];
|
IConfigurationElement[] elements = extension.getConfigurationElements();
|
||||||
IConfigurationElement[] elements = extension
|
|
||||||
.getConfigurationElements();
|
|
||||||
for (int j = 0; j < elements.length; ++j) {
|
for (int j = 0; j < elements.length; ++j) {
|
||||||
IConfigurationElement element = elements[j];
|
IConfigurationElement element = elements[j];
|
||||||
if ("ProposalFilter".equals(element.getName())) { //$NON-NLS-1$
|
if ("ProposalFilter".equals(element.getName())) { //$NON-NLS-1$
|
||||||
|
@ -65,8 +65,7 @@ public class ProposalFilterPreferencesUtil {
|
||||||
// No action required since we will at least be using the fail-safe default filter
|
// No action required since we will at least be using the fail-safe default filter
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
String[] filterNames = (String[]) names
|
String[] filterNames = names.toArray(new String[names.size()]);
|
||||||
.toArray(new String[names.size()]);
|
|
||||||
return filterNames;
|
return filterNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +81,7 @@ public class ProposalFilterPreferencesUtil {
|
||||||
StringBuffer filterNames = new StringBuffer("0;"); //$NON-NLS-1$
|
StringBuffer filterNames = new StringBuffer("0;"); //$NON-NLS-1$
|
||||||
filterNames.append(PreferencesMessages.ProposalFilterPreferencesUtil_defaultFilterName);
|
filterNames.append(PreferencesMessages.ProposalFilterPreferencesUtil_defaultFilterName);
|
||||||
String[] names = getProposalFilterNames();
|
String[] names = getProposalFilterNames();
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (String name : names) {
|
||||||
String name = names[i];
|
|
||||||
filterNames.append(";"); //$NON-NLS-1$
|
filterNames.append(";"); //$NON-NLS-1$
|
||||||
filterNames.append(name);
|
filterNames.append(name);
|
||||||
}
|
}
|
||||||
|
@ -104,9 +102,7 @@ public class ProposalFilterPreferencesUtil {
|
||||||
try {
|
try {
|
||||||
IExtension[] extensions = point.getExtensions();
|
IExtension[] extensions = point.getExtensions();
|
||||||
if (extensions.length >= 1) {
|
if (extensions.length >= 1) {
|
||||||
for (int i = 0; i < extensions.length; i++) {
|
for (IExtension extension : extensions) {
|
||||||
IExtension extension = extensions[i];
|
|
||||||
|
|
||||||
IConfigurationElement[] elements = extension
|
IConfigurationElement[] elements = extension
|
||||||
.getConfigurationElements();
|
.getConfigurationElements();
|
||||||
|
|
||||||
|
@ -153,9 +149,9 @@ public class ProposalFilterPreferencesUtil {
|
||||||
int selectionIndex = combo.getSelectionIndex();
|
int selectionIndex = combo.getSelectionIndex();
|
||||||
text.append(selectionIndex);
|
text.append(selectionIndex);
|
||||||
String[] entries = combo.getItems();
|
String[] entries = combo.getItems();
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (String entrie : entries) {
|
||||||
text.append(";"); //$NON-NLS-1$
|
text.append(";"); //$NON-NLS-1$
|
||||||
String entry = entries[i].replaceAll(";", ","); //$NON-NLS-1$ //$NON-NLS-2$
|
String entry = entrie.replaceAll(";", ","); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
text.append(entry);
|
text.append(entry);
|
||||||
}
|
}
|
||||||
return text.toString();
|
return text.toString();
|
||||||
|
|
|
@ -13,20 +13,21 @@ package org.eclipse.cdt.internal.ui.preferences;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.core.variables.IStringVariableManager;
|
|
||||||
import org.eclipse.core.variables.VariablesPlugin;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.variables.IStringVariableManager;
|
||||||
|
import org.eclipse.core.variables.VariablesPlugin;
|
||||||
|
import org.eclipse.jface.dialogs.DialogPage;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.jface.preference.PreferenceStore;
|
||||||
|
import org.eclipse.jface.window.Window;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -42,16 +43,9 @@ import org.eclipse.swt.widgets.FileDialog;
|
||||||
import org.eclipse.swt.widgets.Group;
|
import org.eclipse.swt.widgets.Group;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
import org.eclipse.jface.dialogs.DialogPage;
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
|
||||||
import org.eclipse.jface.preference.PreferenceStore;
|
|
||||||
import org.eclipse.jface.window.Window;
|
|
||||||
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
|
|
||||||
|
|
||||||
import org.eclipse.ui.ide.dialogs.EncodingFieldEditor;
|
import org.eclipse.ui.ide.dialogs.EncodingFieldEditor;
|
||||||
|
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
|
||||||
|
@ -123,13 +117,11 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
* The list of locales
|
* The list of locales
|
||||||
* @return Array of locale codes for the list
|
* @return Array of locale codes for the list
|
||||||
*/
|
*/
|
||||||
protected static String[] getDictionaryCodes(final Set locales) {
|
protected static String[] getDictionaryCodes(final Set<Locale> locales) {
|
||||||
int index= 0;
|
int index= 0;
|
||||||
Locale locale= null;
|
|
||||||
|
|
||||||
final String[] codes= new String[locales.size() + 1];
|
final String[] codes= new String[locales.size() + 1];
|
||||||
for (final Iterator iterator= locales.iterator(); iterator.hasNext();) {
|
for (Locale locale : locales) {
|
||||||
locale= (Locale)iterator.next();
|
|
||||||
codes[index++]= locale.toString();
|
codes[index++]= locale.toString();
|
||||||
}
|
}
|
||||||
codes[index++]= PREF_VALUE_NO_LOCALE;
|
codes[index++]= PREF_VALUE_NO_LOCALE;
|
||||||
|
@ -142,14 +134,11 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
* @param locales The list of locales
|
* @param locales The list of locales
|
||||||
* @return Array of display labels for the list
|
* @return Array of display labels for the list
|
||||||
*/
|
*/
|
||||||
protected static String[] getDictionaryLabels(final Set locales) {
|
protected static String[] getDictionaryLabels(final Set<Locale> locales) {
|
||||||
int index= 0;
|
int index= 0;
|
||||||
Locale locale= null;
|
|
||||||
|
|
||||||
final String[] labels= new String[locales.size() + 1];
|
final String[] labels= new String[locales.size() + 1];
|
||||||
for (final Iterator iterator= locales.iterator(); iterator.hasNext();) {
|
for (Locale locale : locales) {
|
||||||
|
|
||||||
locale= (Locale)iterator.next();
|
|
||||||
labels[index++]= locale.getDisplayName();
|
labels[index++]= locale.getDisplayName();
|
||||||
}
|
}
|
||||||
labels[index++]= PreferencesMessages.SpellingPreferencePage_dictionary_none;
|
labels[index++]= PreferencesMessages.SpellingPreferencePage_dictionary_none;
|
||||||
|
@ -214,10 +203,10 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
try {
|
try {
|
||||||
final int value= Integer.parseInt(number);
|
final int value= Integer.parseInt(number);
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
status.setError(PreferencesMessages.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
|
status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException exception) {
|
} catch (NumberFormatException exception) {
|
||||||
status.setError(PreferencesMessages.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
|
status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
|
@ -354,7 +343,7 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_STRING_LITERALS, trueFalse, 0);
|
slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_STRING_LITERALS, trueFalse, 0);
|
||||||
allControls.add(slave);
|
allControls.add(slave);
|
||||||
|
|
||||||
final Set locales= SpellCheckEngine.getLocalesWithInstalledDictionaries();
|
final Set<Locale> locales= SpellCheckEngine.getLocalesWithInstalledDictionaries();
|
||||||
boolean hasPlaformDictionaries= locales.size() > 0;
|
boolean hasPlaformDictionaries= locales.size() > 0;
|
||||||
|
|
||||||
final Group engine= new Group(composite, SWT.NONE);
|
final Group engine= new Group(composite, SWT.NONE);
|
||||||
|
@ -518,7 +507,6 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
private static Key[] getAllKeys() {
|
private static Key[] getAllKeys() {
|
||||||
if (SUPPORT_CONTENT_ASSIST_PROPOSALS)
|
if (SUPPORT_CONTENT_ASSIST_PROPOSALS)
|
||||||
return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST, PREF_SPELLING_IGNORE_STRING_LITERALS };
|
return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST, PREF_SPELLING_IGNORE_STRING_LITERALS };
|
||||||
else
|
|
||||||
return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_IGNORE_STRING_LITERALS };
|
return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_IGNORE_STRING_LITERALS };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,18 +15,8 @@ package org.eclipse.cdt.internal.ui.preferences;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.Font;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
|
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
import org.eclipse.jface.viewers.IFontProvider;
|
import org.eclipse.jface.viewers.IFontProvider;
|
||||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
|
@ -34,7 +24,13 @@ import org.eclipse.jface.viewers.LabelProvider;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.viewers.ViewerComparator;
|
import org.eclipse.jface.viewers.ViewerComparator;
|
||||||
import org.eclipse.jface.window.Window;
|
import org.eclipse.jface.window.Window;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.graphics.Font;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
|
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePreferenceConstants;
|
import org.eclipse.cdt.core.CCorePreferenceConstants;
|
||||||
|
@ -106,7 +102,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
name = Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name);
|
name = Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name);
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
} else {
|
}
|
||||||
if (TASK_PRIORITY_HIGH.equals(task.priority)) {
|
if (TASK_PRIORITY_HIGH.equals(task.priority)) {
|
||||||
return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
|
return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
|
||||||
} else if (TASK_PRIORITY_NORMAL.equals(task.priority)) {
|
} else if (TASK_PRIORITY_NORMAL.equals(task.priority)) {
|
||||||
|
@ -116,7 +112,6 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
|
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
|
||||||
|
@ -130,6 +125,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TodoTaskSorter extends ViewerComparator {
|
private static class TodoTaskSorter extends ViewerComparator {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||||
return getComparator().compare(((TodoTask) e1).name, ((TodoTask) e2).name);
|
return getComparator().compare(((TodoTask) e1).name, ((TodoTask) e2).name);
|
||||||
|
@ -142,7 +138,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
private static final int IDX_DEFAULT = 4;
|
private static final int IDX_DEFAULT = 4;
|
||||||
|
|
||||||
private IStatus fTaskTagsStatus;
|
private IStatus fTaskTagsStatus;
|
||||||
private ListDialogField fTodoTasksList;
|
private ListDialogField<TodoTask> fTodoTasksList;
|
||||||
private SelectionButtonDialogField fCaseSensitiveCheckBox;
|
private SelectionButtonDialogField fCaseSensitiveCheckBox;
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,7 +153,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
null,
|
null,
|
||||||
PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button,
|
PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button,
|
||||||
};
|
};
|
||||||
fTodoTasksList = new ListDialogField(adapter, buttons, new TodoTaskLabelProvider());
|
fTodoTasksList = new ListDialogField<TodoTask>(adapter, buttons, new TodoTaskLabelProvider());
|
||||||
fTodoTasksList.setDialogFieldListener(adapter);
|
fTodoTasksList.setDialogFieldListener(adapter);
|
||||||
fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE);
|
fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE);
|
||||||
|
|
||||||
|
@ -194,7 +190,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setToDefaultTask(TodoTask task) {
|
private void setToDefaultTask(TodoTask task) {
|
||||||
List elements = fTodoTasksList.getElements();
|
List<TodoTask> elements = fTodoTasksList.getElements();
|
||||||
elements.remove(task);
|
elements.remove(task);
|
||||||
elements.add(0, task);
|
elements.add(0, task);
|
||||||
fTodoTasksList.setElements(elements);
|
fTodoTasksList.setElements(elements);
|
||||||
|
@ -207,26 +203,26 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TaskTagAdapter implements IListAdapter, IDialogFieldListener {
|
public class TaskTagAdapter implements IListAdapter<TodoTask>, IDialogFieldListener {
|
||||||
private boolean canEdit(List selectedElements) {
|
private boolean canEdit(List<TodoTask> selectedElements) {
|
||||||
return selectedElements.size() == 1;
|
return selectedElements.size() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSetToDefault(List selectedElements) {
|
private boolean canSetToDefault(List<TodoTask> selectedElements) {
|
||||||
return selectedElements.size() == 1 && !isDefaultTask((TodoTask) selectedElements.get(0));
|
return selectedElements.size() == 1 && !isDefaultTask(selectedElements.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void customButtonPressed(ListDialogField field, int index) {
|
public void customButtonPressed(ListDialogField<TodoTask> field, int index) {
|
||||||
doTodoButtonPressed(index);
|
doTodoButtonPressed(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectionChanged(ListDialogField field) {
|
public void selectionChanged(ListDialogField<TodoTask> field) {
|
||||||
List selectedElements = field.getSelectedElements();
|
List<TodoTask> selectedElements = field.getSelectedElements();
|
||||||
field.enableButton(IDX_EDIT, canEdit(selectedElements));
|
field.enableButton(IDX_EDIT, canEdit(selectedElements));
|
||||||
field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements));
|
field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doubleClicked(ListDialogField field) {
|
public void doubleClicked(ListDialogField<TodoTask> field) {
|
||||||
if (canEdit(field.getSelectedElements())) {
|
if (canEdit(field.getSelectedElements())) {
|
||||||
doTodoButtonPressed(IDX_EDIT);
|
doTodoButtonPressed(IDX_EDIT);
|
||||||
}
|
}
|
||||||
|
@ -300,13 +296,13 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
if (field == fTodoTasksList) {
|
if (field == fTodoTasksList) {
|
||||||
StringBuffer tags = new StringBuffer();
|
StringBuffer tags = new StringBuffer();
|
||||||
StringBuffer prios = new StringBuffer();
|
StringBuffer prios = new StringBuffer();
|
||||||
List list = fTodoTasksList.getElements();
|
List<TodoTask> list = fTodoTasksList.getElements();
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
tags.append(',');
|
tags.append(',');
|
||||||
prios.append(',');
|
prios.append(',');
|
||||||
}
|
}
|
||||||
TodoTask elem = (TodoTask) list.get(i);
|
TodoTask elem = list.get(i);
|
||||||
tags.append(elem.name);
|
tags.append(elem.name);
|
||||||
prios.append(elem.priority);
|
prios.append(elem.priority);
|
||||||
}
|
}
|
||||||
|
@ -332,7 +328,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
String currPrios = getValue(PREF_TODO_TASK_PRIORITIES);
|
String currPrios = getValue(PREF_TODO_TASK_PRIORITIES);
|
||||||
String[] tags = getTokens(currTags, ","); //$NON-NLS-1$
|
String[] tags = getTokens(currTags, ","); //$NON-NLS-1$
|
||||||
String[] prios = getTokens(currPrios, ","); //$NON-NLS-1$
|
String[] prios = getTokens(currPrios, ","); //$NON-NLS-1$
|
||||||
ArrayList elements = new ArrayList(tags.length);
|
ArrayList<TodoTask> elements = new ArrayList<TodoTask>(tags.length);
|
||||||
for (int i = 0; i < tags.length; i++) {
|
for (int i = 0; i < tags.length; i++) {
|
||||||
TodoTask task = new TodoTask();
|
TodoTask task = new TodoTask();
|
||||||
task.name = tags[i].trim();
|
task.name = tags[i].trim();
|
||||||
|
@ -348,7 +344,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
|
||||||
private void doTodoButtonPressed(int index) {
|
private void doTodoButtonPressed(int index) {
|
||||||
TodoTask edited = null;
|
TodoTask edited = null;
|
||||||
if (index != IDX_ADD) {
|
if (index != IDX_ADD) {
|
||||||
edited = (TodoTask) fTodoTasksList.getSelectedElements().get(0);
|
edited = fTodoTasksList.getSelectedElements().get(0);
|
||||||
}
|
}
|
||||||
if (index == IDX_ADD || index == IDX_EDIT) {
|
if (index == IDX_ADD || index == IDX_EDIT) {
|
||||||
TodoTaskInputDialog dialog = new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements());
|
TodoTaskInputDialog dialog = new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements());
|
||||||
|
|
|
@ -15,14 +15,12 @@ package org.eclipse.cdt.internal.ui.preferences;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.jface.dialogs.StatusDialog;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
import org.eclipse.jface.dialogs.StatusDialog;
|
|
||||||
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePreferenceConstants;
|
import org.eclipse.cdt.core.CCorePreferenceConstants;
|
||||||
|
@ -50,14 +48,14 @@ public class TodoTaskInputDialog extends StatusDialog {
|
||||||
private StringDialogField fNameDialogField;
|
private StringDialogField fNameDialogField;
|
||||||
private ComboDialogField fPriorityDialogField;
|
private ComboDialogField fPriorityDialogField;
|
||||||
|
|
||||||
private List fExistingNames;
|
private List<String> fExistingNames;
|
||||||
|
|
||||||
public TodoTaskInputDialog(Shell parent, TodoTask task, List existingEntries) {
|
public TodoTaskInputDialog(Shell parent, TodoTask task, List<TodoTask> existingEntries) {
|
||||||
super(parent);
|
super(parent);
|
||||||
|
|
||||||
fExistingNames = new ArrayList(existingEntries.size());
|
fExistingNames = new ArrayList<String>(existingEntries.size());
|
||||||
for (int i = 0; i < existingEntries.size(); i++) {
|
for (int i = 0; i < existingEntries.size(); i++) {
|
||||||
TodoTask curr = (TodoTask) existingEntries.get(i);
|
TodoTask curr = existingEntries.get(i);
|
||||||
if (!curr.equals(task)) {
|
if (!curr.equals(task)) {
|
||||||
fExistingNames.add(curr.name);
|
fExistingNames.add(curr.name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,18 +36,18 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
*/
|
*/
|
||||||
public class WorkInProgressPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
|
public class WorkInProgressPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
|
||||||
|
|
||||||
private List fCheckBoxes;
|
private List<Button> fCheckBoxes;
|
||||||
private List fRadioButtons;
|
private List<Button> fRadioButtons;
|
||||||
private List fTextControls;
|
private List<Text> fTextControls;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a new preference page.
|
* creates a new preference page.
|
||||||
*/
|
*/
|
||||||
public WorkInProgressPreferencePage() {
|
public WorkInProgressPreferencePage() {
|
||||||
setPreferenceStore(getPreferenceStore());
|
setPreferenceStore(getPreferenceStore());
|
||||||
fRadioButtons= new ArrayList();
|
fRadioButtons= new ArrayList<Button>();
|
||||||
fCheckBoxes= new ArrayList();
|
fCheckBoxes= new ArrayList<Button>();
|
||||||
fTextControls= new ArrayList();
|
fTextControls= new ArrayList<Text>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Button addCheckBox(Composite parent, String label, String key) {
|
Button addCheckBox(Composite parent, String label, String key) {
|
||||||
|
@ -120,17 +120,17 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor
|
||||||
protected void performDefaults() {
|
protected void performDefaults() {
|
||||||
IPreferenceStore store= getPreferenceStore();
|
IPreferenceStore store= getPreferenceStore();
|
||||||
for (int i= 0; i < fCheckBoxes.size(); i++) {
|
for (int i= 0; i < fCheckBoxes.size(); i++) {
|
||||||
Button button= (Button) fCheckBoxes.get(i);
|
Button button= fCheckBoxes.get(i);
|
||||||
String key= (String) button.getData();
|
String key= (String) button.getData();
|
||||||
button.setSelection(store.getDefaultBoolean(key));
|
button.setSelection(store.getDefaultBoolean(key));
|
||||||
}
|
}
|
||||||
for (int i= 0; i < fRadioButtons.size(); i++) {
|
for (int i= 0; i < fRadioButtons.size(); i++) {
|
||||||
Button button= (Button) fRadioButtons.get(i);
|
Button button= fRadioButtons.get(i);
|
||||||
String[] info= (String[]) button.getData();
|
String[] info= (String[]) button.getData();
|
||||||
button.setSelection(info[1].equals(store.getDefaultString(info[0])));
|
button.setSelection(info[1].equals(store.getDefaultString(info[0])));
|
||||||
}
|
}
|
||||||
for (int i= 0; i < fTextControls.size(); i++) {
|
for (int i= 0; i < fTextControls.size(); i++) {
|
||||||
Text text= (Text) fTextControls.get(i);
|
Text text= fTextControls.get(i);
|
||||||
String key= (String) text.getData();
|
String key= (String) text.getData();
|
||||||
text.setText(store.getDefaultString(key));
|
text.setText(store.getDefaultString(key));
|
||||||
}
|
}
|
||||||
|
@ -145,19 +145,19 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor
|
||||||
public boolean performOk() {
|
public boolean performOk() {
|
||||||
IPreferenceStore store= getPreferenceStore();
|
IPreferenceStore store= getPreferenceStore();
|
||||||
for (int i= 0; i < fCheckBoxes.size(); i++) {
|
for (int i= 0; i < fCheckBoxes.size(); i++) {
|
||||||
Button button= (Button) fCheckBoxes.get(i);
|
Button button= fCheckBoxes.get(i);
|
||||||
String key= (String) button.getData();
|
String key= (String) button.getData();
|
||||||
store.setValue(key, button.getSelection());
|
store.setValue(key, button.getSelection());
|
||||||
}
|
}
|
||||||
for (int i= 0; i < fRadioButtons.size(); i++) {
|
for (int i= 0; i < fRadioButtons.size(); i++) {
|
||||||
Button button= (Button) fRadioButtons.get(i);
|
Button button= fRadioButtons.get(i);
|
||||||
if (button.getSelection()) {
|
if (button.getSelection()) {
|
||||||
String[] info= (String[]) button.getData();
|
String[] info= (String[]) button.getData();
|
||||||
store.setValue(info[0], info[1]);
|
store.setValue(info[0], info[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i= 0; i < fTextControls.size(); i++) {
|
for (int i= 0; i < fTextControls.size(); i++) {
|
||||||
Text text= (Text) fTextControls.get(i);
|
Text text= fTextControls.get(i);
|
||||||
String key= (String) text.getData();
|
String key= (String) text.getData();
|
||||||
store.setValue(key, text.getText());
|
store.setValue(key, text.getText());
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,8 @@ public class CreateFileChange extends Change {
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if(name == null) {
|
if(name == null) {
|
||||||
return NLS.bind(Messages.CreateFileChange_CreateFile, path.toOSString());
|
return NLS.bind(Messages.CreateFileChange_CreateFile, path.toOSString());
|
||||||
}else {
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -61,9 +61,8 @@ public class MethodContext {
|
||||||
IASTNode parent = declarationName.getParent().getParent();
|
IASTNode parent = declarationName.getParent().getParent();
|
||||||
if (parent instanceof IASTSimpleDeclaration) {
|
if (parent instanceof IASTSimpleDeclaration) {
|
||||||
return (IASTSimpleDeclaration) parent;
|
return (IASTSimpleDeclaration) parent;
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPASTVisiblityLabel getMethodDeclarationASTVisibility(){
|
public ICPPASTVisiblityLabel getMethodDeclarationASTVisibility(){
|
||||||
|
@ -101,9 +100,8 @@ public class MethodContext {
|
||||||
ICPPInternalBinding subclassBind = getICPPInternalBinding(contextOfSameOrSubclass);
|
ICPPInternalBinding subclassBind = getICPPInternalBinding(contextOfSameOrSubclass);
|
||||||
if(isSameClass(bind1,subclassBind)){
|
if(isSameClass(bind1,subclassBind)){
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return isSubclass(bind1,subclassBind);
|
|
||||||
}
|
}
|
||||||
|
return isSubclass(bind1,subclassBind);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSubclass(ICPPInternalBinding bind1, ICPPInternalBinding subclassBind) {
|
private static boolean isSubclass(ICPPInternalBinding bind1, ICPPInternalBinding subclassBind) {
|
||||||
|
@ -148,12 +146,10 @@ public class MethodContext {
|
||||||
if (bind1 instanceof ICPPInternalBinding) {
|
if (bind1 instanceof ICPPInternalBinding) {
|
||||||
ICPPInternalBinding bind1int = (ICPPInternalBinding) bind1;
|
ICPPInternalBinding bind1int = (ICPPInternalBinding) bind1;
|
||||||
return bind1int.getDefinition().equals(bind2.getDefinition());
|
return bind1int.getDefinition().equals(bind2.getDefinition());
|
||||||
} else {
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -173,9 +169,8 @@ public class MethodContext {
|
||||||
|
|
||||||
if( node1.equals(node2) ){
|
if( node1.equals(node2) ){
|
||||||
return bind1.getDefinition().equals(bind2.getDefinition());
|
return bind1.getDefinition().equals(bind2.getDefinition());
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,9 +245,8 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer {
|
||||||
CTextFileChange editChange= (CTextFileChange)change;
|
CTextFileChange editChange= (CTextFileChange)change;
|
||||||
setInput(editChange, editChange.getCurrentContent(new NullProgressMonitor()), editChange.getPreviewContent(new NullProgressMonitor()), editChange.getTextType());
|
setInput(editChange, editChange.getCurrentContent(new NullProgressMonitor()), editChange.getPreviewContent(new NullProgressMonitor()), editChange.getTextType());
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
viewer.setInput(null);
|
|
||||||
}
|
}
|
||||||
|
viewer.setInput(null);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
viewer.setInput(null);
|
viewer.setInput(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,10 +403,8 @@ public class ASTManager {
|
||||||
// todo check for const, restrict
|
// todo check for const, restrict
|
||||||
return r1;
|
return r1;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return r1;
|
return r1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,8 +691,7 @@ public class ASTManager {
|
||||||
ICPPClassScope classScope = (ICPPClassScope) scope;
|
ICPPClassScope classScope = (ICPPClassScope) scope;
|
||||||
ICPPClassType classType= classScope.getClassType();
|
ICPPClassType classType= classScope.getClassType();
|
||||||
ICPPBase[] bases= classType.getBases();
|
ICPPBase[] bases= classType.getBases();
|
||||||
for (int i = 0; i < bases.length; i++) {
|
for (ICPPBase base : bases) {
|
||||||
ICPPBase base = bases[i];
|
|
||||||
if( !(base.getBaseClass() instanceof ICPPClassType) )
|
if( !(base.getBaseClass() instanceof ICPPClassType) )
|
||||||
continue;
|
continue;
|
||||||
ICPPClassType baseType= (ICPPClassType) base.getBaseClass();
|
ICPPClassType baseType= (ICPPClassType) base.getBaseClass();
|
||||||
|
@ -702,8 +699,7 @@ public class ASTManager {
|
||||||
IScope baseScope= baseType.getCompositeScope();
|
IScope baseScope= baseType.getCompositeScope();
|
||||||
if (baseScope != null) {
|
if (baseScope != null) {
|
||||||
IBinding[] alternates= baseScope.find(method.getName());
|
IBinding[] alternates= baseScope.find(method.getName());
|
||||||
for (int j = 0; j < alternates.length; j++) {
|
for (IBinding binding : alternates) {
|
||||||
IBinding binding = alternates[j];
|
|
||||||
if (binding instanceof CPPMethod) {
|
if (binding instanceof CPPMethod) {
|
||||||
CPPMethod alternateMethod = (CPPMethod) binding;
|
CPPMethod alternateMethod = (CPPMethod) binding;
|
||||||
if (hasSameSignature(method, alternateMethod)!=FALSE) {
|
if (hasSameSignature(method, alternateMethod)!=FALSE) {
|
||||||
|
@ -773,8 +769,7 @@ public class ASTManager {
|
||||||
if (count < result.length) {
|
if (count < result.length) {
|
||||||
IBinding[] copy= new IBinding[count];
|
IBinding[] copy= new IBinding[count];
|
||||||
int i=0;
|
int i=0;
|
||||||
for (int j = 0; j < result.length; j++) {
|
for (IBinding b : result) {
|
||||||
IBinding b = result[j];
|
|
||||||
if (b != null) {
|
if (b != null) {
|
||||||
copy[i++]= b;
|
copy[i++]= b;
|
||||||
}
|
}
|
||||||
|
@ -861,7 +856,7 @@ public class ASTManager {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
status.addError(e.getMessage());
|
status.addError(e.getMessage());
|
||||||
}
|
}
|
||||||
if (tu != null && cacheit) {
|
if (cacheit) {
|
||||||
fTranslationUnits.put(sourceFile, ast);
|
fTranslationUnits.put(sourceFile, ast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -869,11 +864,10 @@ public class ASTManager {
|
||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void analyzeTextMatches(IIndex index, ArrayList matches, IProgressMonitor monitor,
|
public void analyzeTextMatches(IIndex index, ArrayList<CRefactoringMatch> matches, IProgressMonitor monitor,
|
||||||
RefactoringStatus status) {
|
RefactoringStatus status) {
|
||||||
CRefactoringMatchStore store= new CRefactoringMatchStore();
|
CRefactoringMatchStore store= new CRefactoringMatchStore();
|
||||||
for (Iterator iter = matches.iterator(); iter.hasNext();) {
|
for (CRefactoringMatch match : matches) {
|
||||||
CRefactoringMatch match = (CRefactoringMatch) iter.next();
|
|
||||||
store.addMatch(match);
|
store.addMatch(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,9 +891,9 @@ public class ASTManager {
|
||||||
update= now+1000;
|
update= now+1000;
|
||||||
}
|
}
|
||||||
boolean doParse= false;
|
boolean doParse= false;
|
||||||
Collection fm= store.getMatchesForFile(file);
|
Collection<CRefactoringMatch> fm= store.getMatchesForFile(file);
|
||||||
for (Iterator iterator = fm.iterator(); !doParse && iterator.hasNext();) {
|
for (Iterator<CRefactoringMatch> iterator = fm.iterator(); !doParse && iterator.hasNext();) {
|
||||||
CRefactoringMatch match = (CRefactoringMatch) iterator.next();
|
CRefactoringMatch match = iterator.next();
|
||||||
switch (match.getLocation()) {
|
switch (match.getLocation()) {
|
||||||
case CRefactory.OPTION_IN_COMMENT:
|
case CRefactory.OPTION_IN_COMMENT:
|
||||||
case CRefactory.OPTION_IN_INCLUDE_DIRECTIVE:
|
case CRefactory.OPTION_IN_INCLUDE_DIRECTIVE:
|
||||||
|
@ -951,8 +945,7 @@ public class ASTManager {
|
||||||
analyzeLanguageMatches(tu, store, paths, status);
|
analyzeLanguageMatches(tu, store, paths, status);
|
||||||
if (status.hasFatalError()) return;
|
if (status.hasFatalError()) return;
|
||||||
|
|
||||||
for (Iterator<IPath> iter = paths.iterator(); iter.hasNext();) {
|
for (IPath path : paths) {
|
||||||
IPath path = iter.next();
|
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
store.removePath(path);
|
store.removePath(path);
|
||||||
}
|
}
|
||||||
|
@ -981,8 +974,7 @@ public class ASTManager {
|
||||||
final RefactoringStatus status) {
|
final RefactoringStatus status) {
|
||||||
String lookfor= fArgument.getName();
|
String lookfor= fArgument.getName();
|
||||||
IASTPreprocessorMacroDefinition[] mdefs= tu.getMacroDefinitions();
|
IASTPreprocessorMacroDefinition[] mdefs= tu.getMacroDefinitions();
|
||||||
for (int i = 0; i < mdefs.length; i++) {
|
for (IASTPreprocessorMacroDefinition mdef : mdefs) {
|
||||||
IASTPreprocessorMacroDefinition mdef = mdefs[i];
|
|
||||||
IASTName macroName= mdef.getName();
|
IASTName macroName= mdef.getName();
|
||||||
String macroNameStr= macroName.toString();
|
String macroNameStr= macroName.toString();
|
||||||
if (fRenameTo.equals(macroNameStr)) {
|
if (fRenameTo.equals(macroNameStr)) {
|
||||||
|
@ -997,8 +989,8 @@ public class ASTManager {
|
||||||
IBinding macroBinding= macroName.resolveBinding();
|
IBinding macroBinding= macroName.resolveBinding();
|
||||||
if (macroBinding != null) {
|
if (macroBinding != null) {
|
||||||
IASTName[] refs= tu.getReferences(macroBinding);
|
IASTName[] refs= tu.getReferences(macroBinding);
|
||||||
for (int j = 0; j < refs.length; j++) {
|
for (IASTName ref : refs) {
|
||||||
path= analyzeAstMatch(refs[j], store, false, status);
|
path= analyzeAstMatch(ref, store, false, status);
|
||||||
pathsVisited.add(path);
|
pathsVisited.add(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1019,10 +1011,9 @@ public class ASTManager {
|
||||||
IASTFileLocation floc= mdef.getNodeLocations()[0].asFileLocation();
|
IASTFileLocation floc= mdef.getNodeLocations()[0].asFileLocation();
|
||||||
int offset= floc.getNodeOffset();
|
int offset= floc.getNodeOffset();
|
||||||
int end= offset+ floc.getNodeLength();
|
int end= offset+ floc.getNodeLength();
|
||||||
Collection matches= store.findMatchesInRange(
|
Collection<CRefactoringMatch> matches= store.findMatchesInRange(
|
||||||
new Path(floc.getFileName()), offset, end);
|
new Path(floc.getFileName()), offset, end);
|
||||||
for (Iterator iter = matches.iterator(); iter.hasNext();) {
|
for (CRefactoringMatch match : matches) {
|
||||||
CRefactoringMatch match = (CRefactoringMatch) iter.next();
|
|
||||||
match.setASTInformation(CRefactoringMatch.AST_REFERENCE_OTHER);
|
match.setASTInformation(CRefactoringMatch.AST_REFERENCE_OTHER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1081,7 +1072,6 @@ public class ASTManager {
|
||||||
IASTFileLocation floc= loc.asFileLocation();
|
IASTFileLocation floc= loc.asFileLocation();
|
||||||
if (floc != null) {
|
if (floc != null) {
|
||||||
path= new Path(floc.getFileName());
|
path= new Path(floc.getFileName());
|
||||||
if (path != null) {
|
|
||||||
IBinding binding= name.resolveBinding();
|
IBinding binding= name.resolveBinding();
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
handleProblemBinding(name.getTranslationUnit(),
|
handleProblemBinding(name.getTranslationUnit(),
|
||||||
|
@ -1092,7 +1082,6 @@ public class ASTManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1130,8 +1119,7 @@ public class ASTManager {
|
||||||
handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) binding, status);
|
handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) binding, status);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 0; i < fValidBindings.length; i++) {
|
for (IBinding renameBinding : fValidBindings) {
|
||||||
IBinding renameBinding = fValidBindings[i];
|
|
||||||
try {
|
try {
|
||||||
int cmp0= isSameBinding(binding, renameBinding);
|
int cmp0= isSameBinding(binding, renameBinding);
|
||||||
if (cmp0 != FALSE) {
|
if (cmp0 != FALSE) {
|
||||||
|
@ -1221,6 +1209,8 @@ public class ASTManager {
|
||||||
case CRefactory.ARGUMENT_LOCAL_VAR:
|
case CRefactory.ARGUMENT_LOCAL_VAR:
|
||||||
case CRefactory.ARGUMENT_PARAMETER:
|
case CRefactory.ARGUMENT_PARAMETER:
|
||||||
isLocalVarPar= true;
|
isLocalVarPar= true;
|
||||||
|
isVarParEnumerator= true;
|
||||||
|
break;
|
||||||
case CRefactory.ARGUMENT_FILE_LOCAL_VAR:
|
case CRefactory.ARGUMENT_FILE_LOCAL_VAR:
|
||||||
case CRefactory.ARGUMENT_GLOBAL_VAR:
|
case CRefactory.ARGUMENT_GLOBAL_VAR:
|
||||||
case CRefactory.ARGUMENT_FIELD:
|
case CRefactory.ARGUMENT_FIELD:
|
||||||
|
@ -1396,11 +1386,10 @@ public class ASTManager {
|
||||||
String space = " \n"; //$NON-NLS-1$
|
String space = " \n"; //$NON-NLS-1$
|
||||||
String formatted = message + space + message1 + space + message2 + space + message3;
|
String formatted = message + space + message1 + space + message2 + space + message3;
|
||||||
RefactoringStatusEntry[] entries= status.getEntries();
|
RefactoringStatusEntry[] entries= status.getEntries();
|
||||||
for (int j = 0; (conflict.getName() != null || msg != null || what != null)
|
for (RefactoringStatusEntry entry : entries) {
|
||||||
&& j<entries.length; j++) {
|
|
||||||
RefactoringStatusEntry entry = entries[j];
|
|
||||||
if (formatted.equals(entry.getMessage())) {
|
if (formatted.equals(entry.getMessage())) {
|
||||||
formatted= null;
|
formatted= null;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (formatted != null) {
|
if (formatted != null) {
|
||||||
|
@ -1423,10 +1412,9 @@ public class ASTManager {
|
||||||
String name= fArgument.getName();
|
String name= fArgument.getName();
|
||||||
IBinding[] newBindingsAboverOrEqual= null;
|
IBinding[] newBindingsAboverOrEqual= null;
|
||||||
IScope oldBindingsScope= null;
|
IScope oldBindingsScope= null;
|
||||||
for (Iterator iter= fKnownBindings.entrySet().iterator(); iter.hasNext();) {
|
for (Map.Entry<IBinding, Integer> entry : fKnownBindings.entrySet()) {
|
||||||
Map.Entry entry= (Map.Entry) iter.next();
|
IBinding oldBinding= entry.getKey();
|
||||||
IBinding oldBinding= (IBinding) entry.getKey();
|
Integer value= entry.getValue();
|
||||||
Integer value= (Integer) entry.getValue();
|
|
||||||
if (value.intValue() == TRUE && oldBinding.getName().equals(name)) {
|
if (value.intValue() == TRUE && oldBinding.getName().equals(name)) {
|
||||||
try {
|
try {
|
||||||
oldBindingsScope = oldBinding.getScope();
|
oldBindingsScope = oldBinding.getScope();
|
||||||
|
@ -1447,8 +1435,7 @@ public class ASTManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check conflicting bindings for being from above or equal level.
|
// check conflicting bindings for being from above or equal level.
|
||||||
for (Iterator<IBinding> iter = fConflictingBinding.iterator(); iter.hasNext();) {
|
for (IBinding conflictingBinding : fConflictingBinding) {
|
||||||
IBinding conflictingBinding= iter.next();
|
|
||||||
if (conflictingBinding != null) {
|
if (conflictingBinding != null) {
|
||||||
boolean isAboveOrEqual= false;
|
boolean isAboveOrEqual= false;
|
||||||
for (int i = 0; !isAboveOrEqual && i<newBindingsAboverOrEqual.length; i++) {
|
for (int i = 0; !isAboveOrEqual && i<newBindingsAboverOrEqual.length; i++) {
|
||||||
|
@ -1468,8 +1455,7 @@ public class ASTManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// find bindings on same level
|
// find bindings on same level
|
||||||
for (int i = 0; i<newBindingsAboverOrEqual.length; i++) {
|
for (IBinding aboveBinding : newBindingsAboverOrEqual) {
|
||||||
IBinding aboveBinding = newBindingsAboverOrEqual[i];
|
|
||||||
IScope aboveScope;
|
IScope aboveScope;
|
||||||
try {
|
try {
|
||||||
aboveScope = aboveBinding.getScope();
|
aboveScope = aboveBinding.getScope();
|
||||||
|
|
|
@ -95,17 +95,17 @@ public class CRefactoringMatchStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CRefactoringMatch findMatch(IPath path, int nodeOffset) {
|
public CRefactoringMatch findMatch(IPath path, int nodeOffset) {
|
||||||
Map map= fPathToMatches.get(path);
|
Map<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
return (CRefactoringMatch) map.get(new CRefactoringMatch(null, nodeOffset, 0, 0));
|
return map.get(new CRefactoringMatch(null, nodeOffset, 0, 0));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePath(IPath path) {
|
public void removePath(IPath path) {
|
||||||
Map map= fPathToMatches.remove(path);
|
Map<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.remove(path);
|
||||||
if (map != null && !map.isEmpty()) {
|
if (map != null && !map.isEmpty()) {
|
||||||
IFile file= ((CRefactoringMatch) map.values().iterator().next()).getFile();
|
IFile file= (map.values().iterator().next()).getFile();
|
||||||
fFileToPathMap.remove(file);
|
fFileToPathMap.remove(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,8 +130,7 @@ public class CRefactory {
|
||||||
public String[] getCCppPatterns() {
|
public String[] getCCppPatterns() {
|
||||||
IContentType[] cts= Platform.getContentTypeManager().getAllContentTypes();
|
IContentType[] cts= Platform.getContentTypeManager().getAllContentTypes();
|
||||||
HashSet<String> all= new HashSet<String>();
|
HashSet<String> all= new HashSet<String>();
|
||||||
for (int i= 0; i < cts.length; i++) {
|
for (IContentType type : cts) {
|
||||||
IContentType type= cts[i];
|
|
||||||
boolean useit= false;
|
boolean useit= false;
|
||||||
while (!useit && type != null) {
|
while (!useit && type != null) {
|
||||||
String id= type.getId();
|
String id= type.getId();
|
||||||
|
@ -152,9 +151,9 @@ public class CRefactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String[] result= new String[all.size()];
|
String[] result= new String[all.size()];
|
||||||
Iterator it= all.iterator();
|
Iterator<String> it= all.iterator();
|
||||||
for (int i= 0; i < result.length; i++) {
|
for (int i= 0; i < result.length; i++) {
|
||||||
result[i]= "*." + (String) it.next(); //$NON-NLS-1$
|
result[i]= "*." + it.next(); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,8 @@ public class CRenameLocalProcessor extends CRenameProcessorDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int[] range= result;
|
int[] range= result;
|
||||||
for (Iterator iter = matches.iterator(); iter.hasNext();) {
|
for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
|
||||||
CRefactoringMatch m = (CRefactoringMatch) iter.next();
|
CRefactoringMatch m = iter.next();
|
||||||
int off= m.getOffset();
|
int off= m.getOffset();
|
||||||
if (off < range[0] || off > range[1]) {
|
if (off < range[0] || off > range[1]) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.internal.ui.refactoring.rename;
|
package org.eclipse.cdt.internal.ui.refactoring.rename;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||||
|
@ -38,8 +37,7 @@ public class CRenameMacroProcessor extends CRenameGlobalProcessor {
|
||||||
@Override
|
@Override
|
||||||
protected void analyzeTextMatches(ArrayList<CRefactoringMatch> matches, IProgressMonitor monitor,
|
protected void analyzeTextMatches(ArrayList<CRefactoringMatch> matches, IProgressMonitor monitor,
|
||||||
RefactoringStatus status) {
|
RefactoringStatus status) {
|
||||||
for (Iterator iter = matches.iterator(); iter.hasNext();) {
|
for (CRefactoringMatch m : matches) {
|
||||||
CRefactoringMatch m = (CRefactoringMatch) iter.next();
|
|
||||||
if ((m.getLocation() & CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE) != 0) {
|
if ((m.getLocation() & CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE) != 0) {
|
||||||
m.setASTInformation(CRefactoringMatch.AST_REFERENCE);
|
m.setASTInformation(CRefactoringMatch.AST_REFERENCE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,8 +274,7 @@ public abstract class CRenameProcessorDelegate {
|
||||||
IFile file= null;
|
IFile file= null;
|
||||||
TextFileChange fileChange= null;
|
TextFileChange fileChange= null;
|
||||||
MultiTextEdit fileEdit= null;
|
MultiTextEdit fileEdit= null;
|
||||||
for (Iterator<CRefactoringMatch> iter = fMatches.iterator(); iter.hasNext();) {
|
for (CRefactoringMatch match : fMatches) {
|
||||||
CRefactoringMatch match= iter.next();
|
|
||||||
switch(match.getAstInformation()) {
|
switch(match.getAstInformation()) {
|
||||||
case CRefactoringMatch.AST_REFERENCE_OTHER:
|
case CRefactoringMatch.AST_REFERENCE_OTHER:
|
||||||
continue;
|
continue;
|
||||||
|
@ -287,7 +286,7 @@ public abstract class CRenameProcessorDelegate {
|
||||||
}
|
}
|
||||||
if (match.getAstInformation() != CRefactoringMatch.AST_REFERENCE_OTHER) {
|
if (match.getAstInformation() != CRefactoringMatch.AST_REFERENCE_OTHER) {
|
||||||
IFile mfile= match.getFile();
|
IFile mfile= match.getFile();
|
||||||
if (file==null || !file.equals(mfile)) {
|
if (file==null || !file.equals(mfile) || fileEdit == null || fileChange == null) {
|
||||||
file= mfile;
|
file= mfile;
|
||||||
fileEdit= new MultiTextEdit();
|
fileEdit= new MultiTextEdit();
|
||||||
fileChange = new CTextFileChange(file.getName(), file);
|
fileChange = new CTextFileChange(file.getName(), file);
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.ui.IWorkingSetManager;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
|
import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CConventions;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
|
||||||
|
@ -454,7 +455,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
|
||||||
setErrorMessage(null);
|
setErrorMessage(null);
|
||||||
setPageComplete(false);
|
setPageComplete(false);
|
||||||
}
|
}
|
||||||
else if (!isValidIdentifier(txt)) {
|
else if (!CConventions.isValidIdentifier(txt)) {
|
||||||
setErrorMessage(NLS.bind(Messages.getString("CRenameRefactoringInputPage.errorInvalidIdentifier"), txt)); //$NON-NLS-1$
|
setErrorMessage(NLS.bind(Messages.getString("CRenameRefactoringInputPage.errorInvalidIdentifier"), txt)); //$NON-NLS-1$
|
||||||
setPageComplete(false);
|
setPageComplete(false);
|
||||||
}
|
}
|
||||||
|
@ -464,76 +465,6 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidIdentifier(String txt) {
|
|
||||||
if (txt.length() < 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
char[] chars= txt.toCharArray();
|
|
||||||
for (int i = 0; i < chars.length; i++) {
|
|
||||||
final char c = chars[i];
|
|
||||||
switch(c) {
|
|
||||||
case '?':
|
|
||||||
// check for trigraph for backslash
|
|
||||||
if (i+2 >= chars.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (chars[++i] != '?') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (chars[++i] != '/') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// no break, continue with check for universal character name
|
|
||||||
case '\\':
|
|
||||||
// check for universal character name
|
|
||||||
if (++i >= chars.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int hexdigits= 0;
|
|
||||||
switch(chars[i]) {
|
|
||||||
case 'u':
|
|
||||||
hexdigits= 4;
|
|
||||||
break;
|
|
||||||
case 'U':
|
|
||||||
hexdigits= 8;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
while (hexdigits > 0) {
|
|
||||||
if (++i >= chars.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isHexDigit(chars[i])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
hexdigits--;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '_':
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (i==0) {
|
|
||||||
if (!Character.isLetter(c)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!Character.isLetterOrDigit(c)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isHexDigit(char c) {
|
|
||||||
return ( c >= '0' && c <= '9' )
|
|
||||||
|| ( c >= 'A' && c <= 'F' )
|
|
||||||
|| ( c >= 'a' && c <= 'f' );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateEnablement() {
|
protected void updateEnablement() {
|
||||||
boolean enable= fEnableScopeOptions==-1 ||
|
boolean enable= fEnableScopeOptions==-1 ||
|
||||||
(computeSelectedOptions() & fEnableScopeOptions) != 0;
|
(computeSelectedOptions() & fEnableScopeOptions) != 0;
|
||||||
|
|
|
@ -70,8 +70,8 @@ public class EclipseObjects {
|
||||||
static public IEditorPart getEditorForFile(IFile file) {
|
static public IEditorPart getEditorForFile(IFile file) {
|
||||||
IWorkbenchPage page = getActivePage();
|
IWorkbenchPage page = getActivePage();
|
||||||
IEditorReference[] editors = page.getEditorReferences();
|
IEditorReference[] editors = page.getEditorReferences();
|
||||||
for (int i = 0; i < editors.length; i++) {
|
for (IEditorReference editor2 : editors) {
|
||||||
IEditorPart editor = editors[i].getEditor(false);
|
IEditorPart editor = editor2.getEditor(false);
|
||||||
if (editor instanceof CEditor) {
|
if (editor instanceof CEditor) {
|
||||||
CEditor edi = ((CEditor)editor);
|
CEditor edi = ((CEditor)editor);
|
||||||
IResource resource = edi.getInputCElement().getResource();
|
IResource resource = edi.getInputCElement().getResource();
|
||||||
|
@ -136,9 +136,8 @@ public class EclipseObjects {
|
||||||
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
|
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
|
||||||
IFile file = getFile((IStructuredSelection)selection);
|
IFile file = getFile((IStructuredSelection)selection);
|
||||||
return file;
|
return file;
|
||||||
} else {
|
|
||||||
return EclipseObjects.getActiveFile();
|
|
||||||
}
|
}
|
||||||
|
return EclipseObjects.getActiveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
static private IFile getFile(IStructuredSelection selection) {
|
static private IFile getFile(IStructuredSelection selection) {
|
||||||
|
|
|
@ -12,12 +12,11 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.refactoring.utils;
|
package org.eclipse.cdt.internal.ui.refactoring.utils;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.KeywordSetKey;
|
import org.eclipse.cdt.core.parser.KeywordSetKey;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
|
||||||
|
@ -44,9 +43,7 @@ public class IdentifierHelper {
|
||||||
if(isKeyword(identifier)){
|
if(isKeyword(identifier)){
|
||||||
return new IdentifierResult(IdentifierResult.KEYWORD, MessageFormat.format(Messages.IdentifierHelper_isKeyword, new Object[] {identifier}));
|
return new IdentifierResult(IdentifierResult.KEYWORD, MessageFormat.format(Messages.IdentifierHelper_isKeyword, new Object[] {identifier}));
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
return new IdentifierResult(IdentifierResult.VALID, MessageFormat.format(Messages.IdentifierHelper_isValid, new Object[] {identifier}));
|
return new IdentifierResult(IdentifierResult.VALID, MessageFormat.format(Messages.IdentifierHelper_isValid, new Object[] {identifier}));
|
||||||
}
|
|
||||||
} else if(isLeadingADigit(identifier)){
|
} else if(isLeadingADigit(identifier)){
|
||||||
return new IdentifierResult(IdentifierResult.DIGIT_FIRST, MessageFormat.format(Messages.IdentifierHelper_leadingDigit, new Object[] {identifier}));
|
return new IdentifierResult(IdentifierResult.DIGIT_FIRST, MessageFormat.format(Messages.IdentifierHelper_leadingDigit, new Object[] {identifier}));
|
||||||
} else if(identifier.length() == 0){
|
} else if(identifier.length() == 0){
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.FileLocator;
|
import org.eclipse.core.runtime.FileLocator;
|
||||||
|
@ -27,6 +26,8 @@ import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
import org.eclipse.jface.action.LegacyActionTools;
|
import org.eclipse.jface.action.LegacyActionTools;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
|
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
@ -200,9 +201,8 @@ public final class CompletionProposalCategory {
|
||||||
* otherwise
|
* otherwise
|
||||||
*/
|
*/
|
||||||
public boolean hasComputers() {
|
public boolean hasComputers() {
|
||||||
List descriptors= fRegistry.getProposalComputerDescriptors();
|
List<CompletionProposalComputerDescriptor> descriptors= fRegistry.getProposalComputerDescriptors();
|
||||||
for (Iterator it= descriptors.iterator(); it.hasNext();) {
|
for (CompletionProposalComputerDescriptor desc : descriptors) {
|
||||||
CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next();
|
|
||||||
if (desc.getCategory() == this)
|
if (desc.getCategory() == this)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -218,9 +218,8 @@ public final class CompletionProposalCategory {
|
||||||
* otherwise
|
* otherwise
|
||||||
*/
|
*/
|
||||||
public boolean hasComputers(String partition) {
|
public boolean hasComputers(String partition) {
|
||||||
List descriptors= fRegistry.getProposalComputerDescriptors(partition);
|
List<CompletionProposalComputerDescriptor> descriptors= fRegistry.getProposalComputerDescriptors(partition);
|
||||||
for (Iterator it= descriptors.iterator(); it.hasNext();) {
|
for (CompletionProposalComputerDescriptor desc : descriptors) {
|
||||||
CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next();
|
|
||||||
if (desc.getCategory() == this)
|
if (desc.getCategory() == this)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -252,12 +251,11 @@ public final class CompletionProposalCategory {
|
||||||
* @return the list of computed completion proposals (element type:
|
* @return the list of computed completion proposals (element type:
|
||||||
* {@link org.eclipse.jface.text.contentassist.ICompletionProposal})
|
* {@link org.eclipse.jface.text.contentassist.ICompletionProposal})
|
||||||
*/
|
*/
|
||||||
public List computeCompletionProposals(ContentAssistInvocationContext context, String partition, SubProgressMonitor monitor) {
|
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, String partition, SubProgressMonitor monitor) {
|
||||||
fLastError= null;
|
fLastError= null;
|
||||||
List result= new ArrayList();
|
List<ICompletionProposal> result= new ArrayList<ICompletionProposal>();
|
||||||
List descriptors= new ArrayList(fRegistry.getProposalComputerDescriptors(partition));
|
List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors(partition));
|
||||||
for (Iterator it= descriptors.iterator(); it.hasNext();) {
|
for (CompletionProposalComputerDescriptor desc : descriptors) {
|
||||||
CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next();
|
|
||||||
if (desc.getCategory() == this)
|
if (desc.getCategory() == this)
|
||||||
result.addAll(desc.computeCompletionProposals(context, monitor));
|
result.addAll(desc.computeCompletionProposals(context, monitor));
|
||||||
if (fLastError == null)
|
if (fLastError == null)
|
||||||
|
@ -277,12 +275,11 @@ public final class CompletionProposalCategory {
|
||||||
* @return the list of computed context information objects (element type:
|
* @return the list of computed context information objects (element type:
|
||||||
* {@link org.eclipse.jface.text.contentassist.IContextInformation})
|
* {@link org.eclipse.jface.text.contentassist.IContextInformation})
|
||||||
*/
|
*/
|
||||||
public List computeContextInformation(ContentAssistInvocationContext context, String partition, SubProgressMonitor monitor) {
|
public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, String partition, SubProgressMonitor monitor) {
|
||||||
fLastError= null;
|
fLastError= null;
|
||||||
List result= new ArrayList();
|
List<IContextInformation> result= new ArrayList<IContextInformation>();
|
||||||
List descriptors= new ArrayList(fRegistry.getProposalComputerDescriptors(partition));
|
List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors(partition));
|
||||||
for (Iterator it= descriptors.iterator(); it.hasNext();) {
|
for (CompletionProposalComputerDescriptor desc : descriptors) {
|
||||||
CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next();
|
|
||||||
if (desc.getCategory() == this)
|
if (desc.getCategory() == this)
|
||||||
result.addAll(desc.computeContextInformation(context, monitor));
|
result.addAll(desc.computeContextInformation(context, monitor));
|
||||||
if (fLastError == null)
|
if (fLastError == null)
|
||||||
|
@ -304,9 +301,8 @@ public final class CompletionProposalCategory {
|
||||||
* Notifies the computers in this category of a proposal computation session start.
|
* Notifies the computers in this category of a proposal computation session start.
|
||||||
*/
|
*/
|
||||||
public void sessionStarted() {
|
public void sessionStarted() {
|
||||||
List descriptors= new ArrayList(fRegistry.getProposalComputerDescriptors());
|
List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors());
|
||||||
for (Iterator it= descriptors.iterator(); it.hasNext();) {
|
for (CompletionProposalComputerDescriptor desc : descriptors) {
|
||||||
CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next();
|
|
||||||
if (desc.getCategory() == this)
|
if (desc.getCategory() == this)
|
||||||
desc.sessionStarted();
|
desc.sessionStarted();
|
||||||
if (fLastError == null)
|
if (fLastError == null)
|
||||||
|
@ -318,9 +314,8 @@ public final class CompletionProposalCategory {
|
||||||
* Notifies the computers in this category of a proposal computation session end.
|
* Notifies the computers in this category of a proposal computation session end.
|
||||||
*/
|
*/
|
||||||
public void sessionEnded() {
|
public void sessionEnded() {
|
||||||
List descriptors= new ArrayList(fRegistry.getProposalComputerDescriptors());
|
List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors());
|
||||||
for (Iterator it= descriptors.iterator(); it.hasNext();) {
|
for (CompletionProposalComputerDescriptor desc : descriptors) {
|
||||||
CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next();
|
|
||||||
if (desc.getCategory() == this)
|
if (desc.getCategory() == this)
|
||||||
desc.sessionEnded();
|
desc.sessionEnded();
|
||||||
if (fLastError == null)
|
if (fLastError == null)
|
||||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -29,9 +28,9 @@ import org.eclipse.core.runtime.InvalidRegistryObjectException;
|
||||||
import org.eclipse.core.runtime.PerformanceStats;
|
import org.eclipse.core.runtime.PerformanceStats;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
|
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
@ -63,7 +62,7 @@ final class CompletionProposalComputerDescriptor {
|
||||||
/** The extension schema name of the partition child elements. */
|
/** The extension schema name of the partition child elements. */
|
||||||
private static final String PARTITION= "partition"; //$NON-NLS-1$
|
private static final String PARTITION= "partition"; //$NON-NLS-1$
|
||||||
/** Set of Java partition types. */
|
/** Set of Java partition types. */
|
||||||
private static final Set PARTITION_SET;
|
private static final Set<String> PARTITION_SET;
|
||||||
/** The name of the performance event used to trace extensions. */
|
/** The name of the performance event used to trace extensions. */
|
||||||
private static final String PERFORMANCE_EVENT= CUIPlugin.getPluginId() + "/perf/content_assist/extensions"; //$NON-NLS-1$
|
private static final String PERFORMANCE_EVENT= CUIPlugin.getPluginId() + "/perf/content_assist/extensions"; //$NON-NLS-1$
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +85,7 @@ final class CompletionProposalComputerDescriptor {
|
||||||
private static final String SESSION_ENDED= "sessionEnded()"; //$NON-NLS-1$
|
private static final String SESSION_ENDED= "sessionEnded()"; //$NON-NLS-1$
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Set partitions= new HashSet();
|
Set<String> partitions= new HashSet<String>();
|
||||||
partitions.add(IDocument.DEFAULT_CONTENT_TYPE);
|
partitions.add(IDocument.DEFAULT_CONTENT_TYPE);
|
||||||
partitions.addAll(Arrays.asList(ICPartitions.ALL_CPARTITIONS));
|
partitions.addAll(Arrays.asList(ICPartitions.ALL_CPARTITIONS));
|
||||||
|
|
||||||
|
@ -102,7 +101,7 @@ final class CompletionProposalComputerDescriptor {
|
||||||
/** The activate attribute value. */
|
/** The activate attribute value. */
|
||||||
private final boolean fActivate;
|
private final boolean fActivate;
|
||||||
/** The partition of the extension (element type: {@link String}). */
|
/** The partition of the extension (element type: {@link String}). */
|
||||||
private final Set fPartitions;
|
private final Set<String> fPartitions;
|
||||||
/** The configuration element of this extension. */
|
/** The configuration element of this extension. */
|
||||||
private final IConfigurationElement fElement;
|
private final IConfigurationElement fElement;
|
||||||
/** The registry we are registered with. */
|
/** The registry we are registered with. */
|
||||||
|
@ -128,7 +127,8 @@ final class CompletionProposalComputerDescriptor {
|
||||||
* @param element the configuration element to read
|
* @param element the configuration element to read
|
||||||
* @param registry the computer registry creating this descriptor
|
* @param registry the computer registry creating this descriptor
|
||||||
*/
|
*/
|
||||||
CompletionProposalComputerDescriptor(IConfigurationElement element, CompletionProposalComputerRegistry registry, List categories) throws InvalidRegistryObjectException {
|
@SuppressWarnings("null")
|
||||||
|
CompletionProposalComputerDescriptor(IConfigurationElement element, CompletionProposalComputerRegistry registry, List<CompletionProposalCategory> categories) throws InvalidRegistryObjectException {
|
||||||
Assert.isLegal(registry != null);
|
Assert.isLegal(registry != null);
|
||||||
Assert.isLegal(element != null);
|
Assert.isLegal(element != null);
|
||||||
|
|
||||||
|
@ -144,13 +144,13 @@ final class CompletionProposalComputerDescriptor {
|
||||||
else
|
else
|
||||||
fName= name;
|
fName= name;
|
||||||
|
|
||||||
Set partitions= new HashSet();
|
Set<String> partitions= new HashSet<String>();
|
||||||
IConfigurationElement[] children= element.getChildren(PARTITION);
|
IConfigurationElement[] children= element.getChildren(PARTITION);
|
||||||
if (children.length == 0) {
|
if (children.length == 0) {
|
||||||
fPartitions= PARTITION_SET; // add to all partition types if no partition is configured
|
fPartitions= PARTITION_SET; // add to all partition types if no partition is configured
|
||||||
} else {
|
} else {
|
||||||
for (int i= 0; i < children.length; i++) {
|
for (IConfigurationElement element2 : children) {
|
||||||
String type= children[i].getAttribute(TYPE);
|
String type= element2.getAttribute(TYPE);
|
||||||
checkNotNull(type, TYPE);
|
checkNotNull(type, TYPE);
|
||||||
partitions.add(type);
|
partitions.add(type);
|
||||||
}
|
}
|
||||||
|
@ -167,8 +167,7 @@ final class CompletionProposalComputerDescriptor {
|
||||||
if (categoryId == null)
|
if (categoryId == null)
|
||||||
categoryId= DEFAULT_CATEGORY_ID;
|
categoryId= DEFAULT_CATEGORY_ID;
|
||||||
CompletionProposalCategory category= null;
|
CompletionProposalCategory category= null;
|
||||||
for (Iterator it= categories.iterator(); it.hasNext();) {
|
for (CompletionProposalCategory cat : categories) {
|
||||||
CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
|
|
||||||
if (cat.getId().equals(categoryId)) {
|
if (cat.getId().equals(categoryId)) {
|
||||||
category= cat;
|
category= cat;
|
||||||
break;
|
break;
|
||||||
|
@ -222,7 +221,7 @@ final class CompletionProposalComputerDescriptor {
|
||||||
*
|
*
|
||||||
* @return the set of partition types (element type: {@link String})
|
* @return the set of partition types (element type: {@link String})
|
||||||
*/
|
*/
|
||||||
public Set getPartitions() {
|
public Set<String> getPartitions() {
|
||||||
return fPartitions;
|
return fPartitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,19 +282,19 @@ final class CompletionProposalComputerDescriptor {
|
||||||
* @return the list of computed completion proposals (element type:
|
* @return the list of computed completion proposals (element type:
|
||||||
* {@link org.eclipse.jface.text.contentassist.ICompletionProposal})
|
* {@link org.eclipse.jface.text.contentassist.ICompletionProposal})
|
||||||
*/
|
*/
|
||||||
public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
if (!isEnabled())
|
if (!isEnabled())
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
|
|
||||||
IStatus status;
|
IStatus status;
|
||||||
try {
|
try {
|
||||||
ICompletionProposalComputer computer= getComputer();
|
ICompletionProposalComputer computer= getComputer();
|
||||||
if (computer == null) // not active yet
|
if (computer == null) // not active yet
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PerformanceStats stats= startMeter(context, computer);
|
PerformanceStats stats= startMeter(context, computer);
|
||||||
List proposals= computer.computeCompletionProposals(context, monitor);
|
List<ICompletionProposal> proposals= computer.computeCompletionProposals(context, monitor);
|
||||||
stopMeter(stats, COMPUTE_COMPLETION_PROPOSALS);
|
stopMeter(stats, COMPUTE_COMPLETION_PROPOSALS);
|
||||||
|
|
||||||
if (proposals != null) {
|
if (proposals != null) {
|
||||||
|
@ -318,7 +317,7 @@ final class CompletionProposalComputerDescriptor {
|
||||||
|
|
||||||
fRegistry.informUser(this, status);
|
fRegistry.informUser(this, status);
|
||||||
|
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -331,18 +330,18 @@ final class CompletionProposalComputerDescriptor {
|
||||||
* @return the list of computed context information objects (element type:
|
* @return the list of computed context information objects (element type:
|
||||||
* {@link org.eclipse.jface.text.contentassist.IContextInformation})
|
* {@link org.eclipse.jface.text.contentassist.IContextInformation})
|
||||||
*/
|
*/
|
||||||
public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
if (!isEnabled())
|
if (!isEnabled())
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
|
|
||||||
IStatus status;
|
IStatus status;
|
||||||
try {
|
try {
|
||||||
ICompletionProposalComputer computer= getComputer();
|
ICompletionProposalComputer computer= getComputer();
|
||||||
if (computer == null) // not active yet
|
if (computer == null) // not active yet
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
|
|
||||||
PerformanceStats stats= startMeter(context, computer);
|
PerformanceStats stats= startMeter(context, computer);
|
||||||
List proposals= computer.computeContextInformation(context, monitor);
|
List<IContextInformation> proposals= computer.computeContextInformation(context, monitor);
|
||||||
stopMeter(stats, COMPUTE_CONTEXT_INFORMATION);
|
stopMeter(stats, COMPUTE_CONTEXT_INFORMATION);
|
||||||
|
|
||||||
if (proposals != null) {
|
if (proposals != null) {
|
||||||
|
@ -363,7 +362,7 @@ final class CompletionProposalComputerDescriptor {
|
||||||
|
|
||||||
fRegistry.informUser(this, status);
|
fRegistry.informUser(this, status);
|
||||||
|
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,9 @@ import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.InvalidRegistryObjectException;
|
import org.eclipse.core.runtime.InvalidRegistryObjectException;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -38,11 +40,6 @@ import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Link;
|
import org.eclipse.swt.widgets.Link;
|
||||||
|
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
|
||||||
|
|
||||||
import org.eclipse.ui.dialogs.PreferencesUtil;
|
import org.eclipse.ui.dialogs.PreferencesUtil;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
@ -85,26 +82,26 @@ public final class CompletionProposalComputerRegistry {
|
||||||
* {@link String}, value type:
|
* {@link String}, value type:
|
||||||
* {@linkplain List List<CompletionProposalComputerDescriptor>}).
|
* {@linkplain List List<CompletionProposalComputerDescriptor>}).
|
||||||
*/
|
*/
|
||||||
private final Map fDescriptorsByPartition= new HashMap();
|
private final Map<String, List<CompletionProposalComputerDescriptor>> fDescriptorsByPartition= new HashMap<String, List<CompletionProposalComputerDescriptor>>();
|
||||||
/**
|
/**
|
||||||
* Unmodifiable versions of the sets stored in
|
* Unmodifiable versions of the sets stored in
|
||||||
* <code>fDescriptorsByPartition</code> (key type: {@link String},
|
* <code>fDescriptorsByPartition</code> (key type: {@link String},
|
||||||
* value type:
|
* value type:
|
||||||
* {@linkplain List List<CompletionProposalComputerDescriptor>}).
|
* {@linkplain List List<CompletionProposalComputerDescriptor>}).
|
||||||
*/
|
*/
|
||||||
private final Map fPublicDescriptorsByPartition= new HashMap();
|
private final Map<String, List<CompletionProposalComputerDescriptor>> fPublicDescriptorsByPartition= new HashMap<String, List<CompletionProposalComputerDescriptor>>();
|
||||||
/**
|
/**
|
||||||
* All descriptors (element type:
|
* All descriptors (element type:
|
||||||
* {@link CompletionProposalComputerDescriptor}).
|
* {@link CompletionProposalComputerDescriptor}).
|
||||||
*/
|
*/
|
||||||
private final List fDescriptors= new ArrayList();
|
private final List<CompletionProposalComputerDescriptor> fDescriptors= new ArrayList<CompletionProposalComputerDescriptor>();
|
||||||
/**
|
/**
|
||||||
* Unmodifiable view of <code>fDescriptors</code>
|
* Unmodifiable view of <code>fDescriptors</code>
|
||||||
*/
|
*/
|
||||||
private final List fPublicDescriptors= Collections.unmodifiableList(fDescriptors);
|
private final List<CompletionProposalComputerDescriptor> fPublicDescriptors= Collections.unmodifiableList(fDescriptors);
|
||||||
|
|
||||||
private final List fCategories= new ArrayList();
|
private final List<CompletionProposalCategory> fCategories= new ArrayList<CompletionProposalCategory>();
|
||||||
private final List fPublicCategories= Collections.unmodifiableList(fCategories);
|
private final List<CompletionProposalCategory> fPublicCategories= Collections.unmodifiableList(fCategories);
|
||||||
/**
|
/**
|
||||||
* <code>true</code> if this registry has been loaded.
|
* <code>true</code> if this registry has been loaded.
|
||||||
*/
|
*/
|
||||||
|
@ -140,10 +137,12 @@ public final class CompletionProposalComputerRegistry {
|
||||||
* @return the list of extensions to the <code>completionProposalComputer</code> extension
|
* @return the list of extensions to the <code>completionProposalComputer</code> extension
|
||||||
* point (element type: {@link CompletionProposalComputerDescriptor})
|
* point (element type: {@link CompletionProposalComputerDescriptor})
|
||||||
*/
|
*/
|
||||||
List getProposalComputerDescriptors(String partition) {
|
List<CompletionProposalComputerDescriptor> getProposalComputerDescriptors(String partition) {
|
||||||
ensureExtensionPointRead();
|
ensureExtensionPointRead();
|
||||||
List result= (List) fPublicDescriptorsByPartition.get(partition);
|
List<CompletionProposalComputerDescriptor> result= fPublicDescriptorsByPartition.get(partition);
|
||||||
return result != null ? result : Collections.EMPTY_LIST;
|
if (result == null)
|
||||||
|
return Collections.emptyList();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,7 +160,7 @@ public final class CompletionProposalComputerRegistry {
|
||||||
* @return the list of extensions to the <code>completionProposalComputer</code> extension
|
* @return the list of extensions to the <code>completionProposalComputer</code> extension
|
||||||
* point (element type: {@link CompletionProposalComputerDescriptor})
|
* point (element type: {@link CompletionProposalComputerDescriptor})
|
||||||
*/
|
*/
|
||||||
List getProposalComputerDescriptors() {
|
List<CompletionProposalComputerDescriptor> getProposalComputerDescriptors() {
|
||||||
ensureExtensionPointRead();
|
ensureExtensionPointRead();
|
||||||
return fPublicDescriptors;
|
return fPublicDescriptors;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +179,7 @@ public final class CompletionProposalComputerRegistry {
|
||||||
* <code>completionProposalComputer</code> extension point (element type:
|
* <code>completionProposalComputer</code> extension point (element type:
|
||||||
* {@link CompletionProposalCategory})
|
* {@link CompletionProposalCategory})
|
||||||
*/
|
*/
|
||||||
public List getProposalCategories() {
|
public List<CompletionProposalCategory> getProposalCategories() {
|
||||||
ensureExtensionPointRead();
|
ensureExtensionPointRead();
|
||||||
return fPublicCategories;
|
return fPublicCategories;
|
||||||
}
|
}
|
||||||
|
@ -208,22 +207,21 @@ public final class CompletionProposalComputerRegistry {
|
||||||
*/
|
*/
|
||||||
public void reload() {
|
public void reload() {
|
||||||
IExtensionRegistry registry= Platform.getExtensionRegistry();
|
IExtensionRegistry registry= Platform.getExtensionRegistry();
|
||||||
List elements= new ArrayList(Arrays.asList(registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT)));
|
List<IConfigurationElement> elements= new ArrayList<IConfigurationElement>(Arrays.asList(registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT)));
|
||||||
|
|
||||||
Map map= new HashMap();
|
Map<String, List<CompletionProposalComputerDescriptor>> map= new HashMap<String, List<CompletionProposalComputerDescriptor>>();
|
||||||
List all= new ArrayList();
|
List<CompletionProposalComputerDescriptor> all= new ArrayList<CompletionProposalComputerDescriptor>();
|
||||||
|
|
||||||
List categories= getCategories(elements);
|
List<CompletionProposalCategory> categories= getCategories(elements);
|
||||||
for (Iterator iter= elements.iterator(); iter.hasNext();) {
|
for (IConfigurationElement element : elements) {
|
||||||
IConfigurationElement element= (IConfigurationElement) iter.next();
|
|
||||||
try {
|
try {
|
||||||
CompletionProposalComputerDescriptor desc= new CompletionProposalComputerDescriptor(element, this, categories);
|
CompletionProposalComputerDescriptor desc= new CompletionProposalComputerDescriptor(element, this, categories);
|
||||||
Set partitions= desc.getPartitions();
|
Set<String> partitions= desc.getPartitions();
|
||||||
for (Iterator it= partitions.iterator(); it.hasNext();) {
|
for (Object element2 : partitions) {
|
||||||
String partition= (String) it.next();
|
String partition= (String) element2;
|
||||||
List list= (List) map.get(partition);
|
List<CompletionProposalComputerDescriptor> list= map.get(partition);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list= new ArrayList();
|
list= new ArrayList<CompletionProposalComputerDescriptor>();
|
||||||
map.put(partition, list);
|
map.put(partition, list);
|
||||||
}
|
}
|
||||||
list.add(desc);
|
list.add(desc);
|
||||||
|
@ -247,13 +245,12 @@ public final class CompletionProposalComputerRegistry {
|
||||||
fCategories.clear();
|
fCategories.clear();
|
||||||
fCategories.addAll(categories);
|
fCategories.addAll(categories);
|
||||||
|
|
||||||
Set partitions= map.keySet();
|
Set<String> partitions= map.keySet();
|
||||||
fDescriptorsByPartition.keySet().retainAll(partitions);
|
fDescriptorsByPartition.keySet().retainAll(partitions);
|
||||||
fPublicDescriptorsByPartition.keySet().retainAll(partitions);
|
fPublicDescriptorsByPartition.keySet().retainAll(partitions);
|
||||||
for (Iterator it= partitions.iterator(); it.hasNext();) {
|
for (String partition : partitions) {
|
||||||
String partition= (String) it.next();
|
List<CompletionProposalComputerDescriptor> old= fDescriptorsByPartition.get(partition);
|
||||||
List old= (List) fDescriptorsByPartition.get(partition);
|
List<CompletionProposalComputerDescriptor> current= map.get(partition);
|
||||||
List current= (List) map.get(partition);
|
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
old.clear();
|
old.clear();
|
||||||
old.addAll(current);
|
old.addAll(current);
|
||||||
|
@ -268,14 +265,14 @@ public final class CompletionProposalComputerRegistry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List getCategories(List elements) {
|
private List<CompletionProposalCategory> getCategories(List<IConfigurationElement> elements) {
|
||||||
IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
|
IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
|
||||||
String preference= store.getString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
|
String preference= store.getString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
|
||||||
Set disabled= new HashSet();
|
Set<String> disabled= new HashSet<String>();
|
||||||
StringTokenizer tok= new StringTokenizer(preference, "\0"); //$NON-NLS-1$
|
StringTokenizer tok= new StringTokenizer(preference, "\0"); //$NON-NLS-1$
|
||||||
while (tok.hasMoreTokens())
|
while (tok.hasMoreTokens())
|
||||||
disabled.add(tok.nextToken());
|
disabled.add(tok.nextToken());
|
||||||
Map ordered= new HashMap();
|
Map<String, Integer> ordered= new HashMap<String, Integer>();
|
||||||
preference= store.getString(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
|
preference= store.getString(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
|
||||||
tok= new StringTokenizer(preference, "\0"); //$NON-NLS-1$
|
tok= new StringTokenizer(preference, "\0"); //$NON-NLS-1$
|
||||||
while (tok.hasMoreTokens()) {
|
while (tok.hasMoreTokens()) {
|
||||||
|
@ -285,9 +282,9 @@ public final class CompletionProposalComputerRegistry {
|
||||||
ordered.put(id, new Integer(rank));
|
ordered.put(id, new Integer(rank));
|
||||||
}
|
}
|
||||||
|
|
||||||
List categories= new ArrayList();
|
List<CompletionProposalCategory> categories= new ArrayList<CompletionProposalCategory>();
|
||||||
for (Iterator iter= elements.iterator(); iter.hasNext();) {
|
for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) {
|
||||||
IConfigurationElement element= (IConfigurationElement) iter.next();
|
IConfigurationElement element= iter.next();
|
||||||
try {
|
try {
|
||||||
if (element.getName().equals("proposalCategory")) { //$NON-NLS-1$
|
if (element.getName().equals("proposalCategory")) { //$NON-NLS-1$
|
||||||
iter.remove(); // remove from list to leave only computers
|
iter.remove(); // remove from list to leave only computers
|
||||||
|
@ -295,7 +292,7 @@ public final class CompletionProposalComputerRegistry {
|
||||||
CompletionProposalCategory category= new CompletionProposalCategory(element, this);
|
CompletionProposalCategory category= new CompletionProposalCategory(element, this);
|
||||||
categories.add(category);
|
categories.add(category);
|
||||||
category.setIncluded(!disabled.contains(category.getId()));
|
category.setIncluded(!disabled.contains(category.getId()));
|
||||||
Integer rank= (Integer) ordered.get(category.getId());
|
Integer rank= ordered.get(category.getId());
|
||||||
if (rank != null) {
|
if (rank != null) {
|
||||||
int r= rank.intValue();
|
int r= rank.intValue();
|
||||||
boolean separate= r < 0xffff;
|
boolean separate= r < 0xffff;
|
||||||
|
@ -329,7 +326,7 @@ public final class CompletionProposalComputerRegistry {
|
||||||
String title= ContentAssistMessages.CompletionProposalComputerRegistry_error_dialog_title;
|
String title= ContentAssistMessages.CompletionProposalComputerRegistry_error_dialog_title;
|
||||||
CompletionProposalCategory category= descriptor.getCategory();
|
CompletionProposalCategory category= descriptor.getCategory();
|
||||||
IContributor culprit= descriptor.getContributor();
|
IContributor culprit= descriptor.getContributor();
|
||||||
Set affectedPlugins= getAffectedContributors(category, culprit);
|
Set<String> affectedPlugins= getAffectedContributors(category, culprit);
|
||||||
|
|
||||||
final String avoidHint;
|
final String avoidHint;
|
||||||
final String culpritName= culprit == null ? null : culprit.getName();
|
final String culpritName= culprit == null ? null : culprit.getName();
|
||||||
|
@ -371,10 +368,9 @@ public final class CompletionProposalComputerRegistry {
|
||||||
* @param culprit the culprit plug-in, which is not included in the returned list
|
* @param culprit the culprit plug-in, which is not included in the returned list
|
||||||
* @return the names of the contributors other than <code>culprit</code> that contribute to <code>category</code> (element type: {@link String})
|
* @return the names of the contributors other than <code>culprit</code> that contribute to <code>category</code> (element type: {@link String})
|
||||||
*/
|
*/
|
||||||
private Set getAffectedContributors(CompletionProposalCategory category, IContributor culprit) {
|
private Set<String> getAffectedContributors(CompletionProposalCategory category, IContributor culprit) {
|
||||||
Set affectedPlugins= new HashSet();
|
Set<String> affectedPlugins= new HashSet<String>();
|
||||||
for (Iterator it= getProposalComputerDescriptors().iterator(); it.hasNext();) {
|
for (CompletionProposalComputerDescriptor desc : getProposalComputerDescriptors()) {
|
||||||
CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next();
|
|
||||||
CompletionProposalCategory cat= desc.getCategory();
|
CompletionProposalCategory cat= desc.getCategory();
|
||||||
if (cat.equals(category)) {
|
if (cat.equals(category)) {
|
||||||
IContributor contributor= desc.getContributor();
|
IContributor contributor= desc.getContributor();
|
||||||
|
@ -385,7 +381,7 @@ public final class CompletionProposalComputerRegistry {
|
||||||
return affectedPlugins;
|
return affectedPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object toString(Collection collection) {
|
private Object toString(Collection<String> collection) {
|
||||||
// strip brackets off AbstractCollection.toString()
|
// strip brackets off AbstractCollection.toString()
|
||||||
String string= collection.toString();
|
String string= collection.toString();
|
||||||
return string.substring(1, string.length() - 1);
|
return string.substring(1, string.length() - 1);
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
/**
|
/**
|
||||||
* Caches the locales of installed dictionaries.
|
* Caches the locales of installed dictionaries.
|
||||||
*/
|
*/
|
||||||
private static Set fgLocalesWithInstalledDictionaries;
|
private static Set<Locale> fgLocalesWithInstalledDictionaries;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +62,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
*
|
*
|
||||||
* @return The available locales for this engine
|
* @return The available locales for this engine
|
||||||
*/
|
*/
|
||||||
public static Set getLocalesWithInstalledDictionaries() {
|
public static Set<Locale> getLocalesWithInstalledDictionaries() {
|
||||||
if (fgLocalesWithInstalledDictionaries != null)
|
if (fgLocalesWithInstalledDictionaries != null)
|
||||||
return fgLocalesWithInstalledDictionaries;
|
return fgLocalesWithInstalledDictionaries;
|
||||||
|
|
||||||
|
@ -70,10 +70,10 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
try {
|
try {
|
||||||
location= getDictionaryLocation();
|
location= getDictionaryLocation();
|
||||||
if (location == null)
|
if (location == null)
|
||||||
return fgLocalesWithInstalledDictionaries= Collections.EMPTY_SET;
|
return fgLocalesWithInstalledDictionaries= Collections.emptySet();
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
CUIPlugin.log(ex);
|
CUIPlugin.log(ex);
|
||||||
return fgLocalesWithInstalledDictionaries= Collections.EMPTY_SET;
|
return fgLocalesWithInstalledDictionaries= Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] fileNames;
|
String[] fileNames;
|
||||||
|
@ -81,16 +81,16 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
URL url= FileLocator.toFileURL(location);
|
URL url= FileLocator.toFileURL(location);
|
||||||
File file= new File(url.getFile());
|
File file= new File(url.getFile());
|
||||||
if (!file.isDirectory())
|
if (!file.isDirectory())
|
||||||
return fgLocalesWithInstalledDictionaries= Collections.EMPTY_SET;
|
return fgLocalesWithInstalledDictionaries= Collections.emptySet();
|
||||||
fileNames= file.list();
|
fileNames= file.list();
|
||||||
if (fileNames == null)
|
if (fileNames == null)
|
||||||
return fgLocalesWithInstalledDictionaries= Collections.EMPTY_SET;
|
return fgLocalesWithInstalledDictionaries= Collections.emptySet();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
CUIPlugin.log(ex);
|
CUIPlugin.log(ex);
|
||||||
return fgLocalesWithInstalledDictionaries= Collections.EMPTY_SET;
|
return fgLocalesWithInstalledDictionaries= Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
fgLocalesWithInstalledDictionaries= new HashSet();
|
fgLocalesWithInstalledDictionaries= new HashSet<Locale>();
|
||||||
int fileNameCount= fileNames.length;
|
int fileNameCount= fileNames.length;
|
||||||
for (int i= 0; i < fileNameCount; i++) {
|
for (int i= 0; i < fileNameCount; i++) {
|
||||||
String fileName= fileNames[i];
|
String fileName= fileNames[i];
|
||||||
|
@ -127,18 +127,18 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
* @return the dictionary or <code>null</code> if none is suitable
|
* @return the dictionary or <code>null</code> if none is suitable
|
||||||
*/
|
*/
|
||||||
public ISpellDictionary findDictionary(Locale locale) {
|
public ISpellDictionary findDictionary(Locale locale) {
|
||||||
ISpellDictionary dictionary= (ISpellDictionary)fLocaleDictionaries.get(locale);
|
ISpellDictionary dictionary= fLocaleDictionaries.get(locale);
|
||||||
if (dictionary != null)
|
if (dictionary != null)
|
||||||
return dictionary;
|
return dictionary;
|
||||||
|
|
||||||
// Try same language
|
// Try same language
|
||||||
String language= locale.getLanguage();
|
String language= locale.getLanguage();
|
||||||
Iterator iter= fLocaleDictionaries.entrySet().iterator();
|
Iterator<Map.Entry<Locale, ISpellDictionary>> iter= fLocaleDictionaries.entrySet().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Entry entry= (Entry)iter.next();
|
Entry<Locale, ISpellDictionary> entry= iter.next();
|
||||||
Locale dictLocale= (Locale)entry.getKey();
|
Locale dictLocale= entry.getKey();
|
||||||
if (dictLocale.getLanguage().equals(language))
|
if (dictLocale.getLanguage().equals(language))
|
||||||
return (ISpellDictionary)entry.getValue();
|
return entry.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -156,9 +156,9 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
|
|
||||||
// Try same language
|
// Try same language
|
||||||
String language= locale.getLanguage();
|
String language= locale.getLanguage();
|
||||||
Iterator iter= getLocalesWithInstalledDictionaries().iterator();
|
Iterator<Locale> iter= getLocalesWithInstalledDictionaries().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Locale dictLocale= (Locale)iter.next();
|
Locale dictLocale= iter.next();
|
||||||
if (dictLocale.getLanguage().equals(language))
|
if (dictLocale.getLanguage().equals(language))
|
||||||
return dictLocale;
|
return dictLocale;
|
||||||
}
|
}
|
||||||
|
@ -215,13 +215,13 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The registered locale insensitive dictionaries */
|
/** The registered locale insensitive dictionaries */
|
||||||
private Set fGlobalDictionaries= new HashSet();
|
private Set<ISpellDictionary> fGlobalDictionaries= new HashSet<ISpellDictionary>();
|
||||||
|
|
||||||
/** The spell checker for fLocale */
|
/** The spell checker for fLocale */
|
||||||
private ISpellChecker fChecker= null;
|
private ISpellChecker fChecker= null;
|
||||||
|
|
||||||
/** The registered locale sensitive dictionaries */
|
/** The registered locale sensitive dictionaries */
|
||||||
private Map fLocaleDictionaries= new HashMap();
|
private Map<Locale, ISpellDictionary> fLocaleDictionaries= new HashMap<Locale, ISpellDictionary>();
|
||||||
|
|
||||||
/** The user dictionary */
|
/** The user dictionary */
|
||||||
private ISpellDictionary fUserDictionary= null;
|
private ISpellDictionary fUserDictionary= null;
|
||||||
|
@ -233,11 +233,9 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
fGlobalDictionaries.add(new TaskTagDictionary());
|
fGlobalDictionaries.add(new TaskTagDictionary());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Locale locale= null;
|
|
||||||
final URL location= getDictionaryLocation();
|
final URL location= getDictionaryLocation();
|
||||||
|
|
||||||
for (final Iterator iterator= getLocalesWithInstalledDictionaries().iterator(); iterator.hasNext();) {
|
for (Locale locale : getLocalesWithInstalledDictionaries()) {
|
||||||
locale= (Locale)iterator.next();
|
|
||||||
fLocaleDictionaries.put(locale, new LocaleSensitiveSpellDictionary(locale, location));
|
fLocaleDictionaries.put(locale, new LocaleSensitiveSpellDictionary(locale, location));
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException exception) {
|
} catch (MalformedURLException exception) {
|
||||||
|
@ -267,8 +265,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
fChecker= new DefaultSpellChecker(store, locale);
|
fChecker= new DefaultSpellChecker(store, locale);
|
||||||
resetUserDictionary();
|
resetUserDictionary();
|
||||||
|
|
||||||
for (Iterator iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) {
|
for (ISpellDictionary dictionary : fGlobalDictionaries) {
|
||||||
ISpellDictionary dictionary= (ISpellDictionary)iterator.next();
|
|
||||||
fChecker.addDictionary(dictionary);
|
fChecker.addDictionary(dictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,14 +389,14 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
SpellingPreferences.removePropertyChangeListener(this);
|
SpellingPreferences.removePropertyChangeListener(this);
|
||||||
|
|
||||||
ISpellDictionary dictionary= null;
|
ISpellDictionary dictionary= null;
|
||||||
for (final Iterator iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) {
|
for (final Iterator<ISpellDictionary> iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) {
|
||||||
dictionary= (ISpellDictionary)iterator.next();
|
dictionary= iterator.next();
|
||||||
dictionary.unload();
|
dictionary.unload();
|
||||||
}
|
}
|
||||||
fGlobalDictionaries= null;
|
fGlobalDictionaries= null;
|
||||||
|
|
||||||
for (final Iterator iterator= fLocaleDictionaries.values().iterator(); iterator.hasNext();) {
|
for (Object element : fLocaleDictionaries.values()) {
|
||||||
dictionary= (ISpellDictionary)iterator.next();
|
dictionary= (ISpellDictionary)element;
|
||||||
dictionary.unload();
|
dictionary.unload();
|
||||||
}
|
}
|
||||||
fLocaleDictionaries= null;
|
fLocaleDictionaries= null;
|
||||||
|
@ -410,7 +407,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe
|
||||||
|
|
||||||
private synchronized void resetSpellChecker() {
|
private synchronized void resetSpellChecker() {
|
||||||
if (fChecker != null) {
|
if (fChecker != null) {
|
||||||
ISpellDictionary dictionary= (ISpellDictionary)fLocaleDictionaries.get(fChecker.getLocale());
|
ISpellDictionary dictionary= fLocaleDictionaries.get(fChecker.getLocale());
|
||||||
if (dictionary != null)
|
if (dictionary != null)
|
||||||
dictionary.unload();
|
dictionary.unload();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,21 +13,21 @@ package org.eclipse.cdt.internal.ui.wizards.dialogfields;
|
||||||
/**
|
/**
|
||||||
* Change listener used by <code>ListDialogField</code> and <code>CheckedListDialogField</code>
|
* Change listener used by <code>ListDialogField</code> and <code>CheckedListDialogField</code>
|
||||||
*/
|
*/
|
||||||
public interface IListAdapter {
|
public interface IListAdapter<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A button from the button bar has been pressed.
|
* A button from the button bar has been pressed.
|
||||||
*/
|
*/
|
||||||
void customButtonPressed(ListDialogField field, int index);
|
void customButtonPressed(ListDialogField<T> field, int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The selection of the list has changed.
|
* The selection of the list has changed.
|
||||||
*/
|
*/
|
||||||
void selectionChanged(ListDialogField field);
|
void selectionChanged(ListDialogField<T> field);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* En entry in the list has been double clicked
|
* En entry in the list has been double clicked
|
||||||
*/
|
*/
|
||||||
void doubleClicked(ListDialogField field);
|
void doubleClicked(ListDialogField<T> field);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,21 +14,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.KeyAdapter;
|
|
||||||
import org.eclipse.swt.events.KeyEvent;
|
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Button;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.Table;
|
|
||||||
import org.eclipse.swt.widgets.TableColumn;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.jface.viewers.ColumnLayoutData;
|
import org.eclipse.jface.viewers.ColumnLayoutData;
|
||||||
import org.eclipse.jface.viewers.ColumnWeightData;
|
import org.eclipse.jface.viewers.ColumnWeightData;
|
||||||
|
@ -45,6 +30,20 @@ import org.eclipse.jface.viewers.TableLayout;
|
||||||
import org.eclipse.jface.viewers.TableViewer;
|
import org.eclipse.jface.viewers.TableViewer;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.viewers.ViewerComparator;
|
import org.eclipse.jface.viewers.ViewerComparator;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.KeyAdapter;
|
||||||
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.events.SelectionListener;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||||
|
@ -56,7 +55,7 @@ import org.eclipse.cdt.internal.ui.util.TableLayoutComposite;
|
||||||
* List model is independend of widget creation.
|
* List model is independend of widget creation.
|
||||||
* DialogFields controls are: Label, List and Composite containing buttons.
|
* DialogFields controls are: Label, List and Composite containing buttons.
|
||||||
*/
|
*/
|
||||||
public class ListDialogField extends DialogField {
|
public class ListDialogField<T> extends DialogField {
|
||||||
|
|
||||||
public static class ColumnsDescription {
|
public static class ColumnsDescription {
|
||||||
protected ColumnLayoutData[] columns;
|
protected ColumnLayoutData[] columns;
|
||||||
|
@ -89,7 +88,7 @@ public class ListDialogField extends DialogField {
|
||||||
protected TableViewer fTable;
|
protected TableViewer fTable;
|
||||||
protected IBaseLabelProvider fLabelProvider;
|
protected IBaseLabelProvider fLabelProvider;
|
||||||
protected ListViewerAdapter fListViewerAdapter;
|
protected ListViewerAdapter fListViewerAdapter;
|
||||||
protected List fElements;
|
protected List<T> fElements;
|
||||||
protected ViewerComparator fViewerComparator;
|
protected ViewerComparator fViewerComparator;
|
||||||
|
|
||||||
protected String[] fButtonLabels;
|
protected String[] fButtonLabels;
|
||||||
|
@ -107,7 +106,7 @@ public class ListDialogField extends DialogField {
|
||||||
private Composite fButtonsControl;
|
private Composite fButtonsControl;
|
||||||
private ISelection fSelectionWhenEnabled;
|
private ISelection fSelectionWhenEnabled;
|
||||||
|
|
||||||
private IListAdapter fListAdapter;
|
private IListAdapter<T> fListAdapter;
|
||||||
|
|
||||||
private Object fParentElement;
|
private Object fParentElement;
|
||||||
|
|
||||||
|
@ -122,7 +121,7 @@ public class ListDialogField extends DialogField {
|
||||||
* marks a separator.
|
* marks a separator.
|
||||||
* @param lprovider The label provider to render the table entries
|
* @param lprovider The label provider to render the table entries
|
||||||
*/
|
*/
|
||||||
public ListDialogField(IListAdapter adapter, String[] buttonLabels, IBaseLabelProvider lprovider) {
|
public ListDialogField(IListAdapter<T> adapter, String[] buttonLabels, IBaseLabelProvider lprovider) {
|
||||||
super();
|
super();
|
||||||
fListAdapter= adapter;
|
fListAdapter= adapter;
|
||||||
|
|
||||||
|
@ -130,7 +129,7 @@ public class ListDialogField extends DialogField {
|
||||||
fListViewerAdapter= new ListViewerAdapter();
|
fListViewerAdapter= new ListViewerAdapter();
|
||||||
fParentElement= this;
|
fParentElement= this;
|
||||||
|
|
||||||
fElements= new ArrayList(10);
|
fElements= new ArrayList<T>(10);
|
||||||
|
|
||||||
fButtonLabels= buttonLabels;
|
fButtonLabels= buttonLabels;
|
||||||
if (fButtonLabels != null) {
|
if (fButtonLabels != null) {
|
||||||
|
@ -542,8 +541,8 @@ public class ListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Sets the elements shown in the list.
|
* Sets the elements shown in the list.
|
||||||
*/
|
*/
|
||||||
public void setElements(List elements) {
|
public void setElements(List<? extends T> elements) {
|
||||||
fElements= new ArrayList(elements);
|
fElements= new ArrayList<T>(elements);
|
||||||
if (fTable != null) {
|
if (fTable != null) {
|
||||||
fTable.refresh();
|
fTable.refresh();
|
||||||
}
|
}
|
||||||
|
@ -554,14 +553,14 @@ public class ListDialogField extends DialogField {
|
||||||
* Gets the elements shown in the list.
|
* Gets the elements shown in the list.
|
||||||
* The list returned is a copy, so it can be modified by the user.
|
* The list returned is a copy, so it can be modified by the user.
|
||||||
*/
|
*/
|
||||||
public List getElements() {
|
public List<T> getElements() {
|
||||||
return new ArrayList(fElements);
|
return new ArrayList<T>(fElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the elements shown at the given index.
|
* Gets the elements shown at the given index.
|
||||||
*/
|
*/
|
||||||
public Object getElement(int index) {
|
public T getElement(int index) {
|
||||||
return fElements.get(index);
|
return fElements.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,12 +574,12 @@ public class ListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Replace an element.
|
* Replace an element.
|
||||||
*/
|
*/
|
||||||
public void replaceElement(Object oldElement, Object newElement) throws IllegalArgumentException {
|
public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
|
||||||
int idx= fElements.indexOf(oldElement);
|
int idx= fElements.indexOf(oldElement);
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
fElements.set(idx, newElement);
|
fElements.set(idx, newElement);
|
||||||
if (fTable != null) {
|
if (fTable != null) {
|
||||||
List selected= getSelectedElements();
|
List<T> selected= getSelectedElements();
|
||||||
if (selected.remove(oldElement)) {
|
if (selected.remove(oldElement)) {
|
||||||
selected.add(newElement);
|
selected.add(newElement);
|
||||||
}
|
}
|
||||||
|
@ -596,7 +595,7 @@ public class ListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Adds an element at the end of the list.
|
* Adds an element at the end of the list.
|
||||||
*/
|
*/
|
||||||
public void addElement(Object element) {
|
public void addElement(T element) {
|
||||||
if (fElements.contains(element)) {
|
if (fElements.contains(element)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -610,15 +609,15 @@ public class ListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Adds elements at the end of the list.
|
* Adds elements at the end of the list.
|
||||||
*/
|
*/
|
||||||
public void addElements(List elements) {
|
public void addElements(List<? extends T> elements) {
|
||||||
int nElements= elements.size();
|
int nElements= elements.size();
|
||||||
|
|
||||||
if (nElements > 0) {
|
if (nElements > 0) {
|
||||||
// filter duplicated
|
// filter duplicated
|
||||||
ArrayList elementsToAdd= new ArrayList(nElements);
|
ArrayList<T> elementsToAdd= new ArrayList<T>(nElements);
|
||||||
|
|
||||||
for (int i= 0; i < nElements; i++) {
|
for (int i= 0; i < nElements; i++) {
|
||||||
Object elem= elements.get(i);
|
T elem= elements.get(i);
|
||||||
if (!fElements.contains(elem)) {
|
if (!fElements.contains(elem)) {
|
||||||
elementsToAdd.add(elem);
|
elementsToAdd.add(elem);
|
||||||
}
|
}
|
||||||
|
@ -634,7 +633,7 @@ public class ListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Adds an element at a position.
|
* Adds an element at a position.
|
||||||
*/
|
*/
|
||||||
public void insertElementAt(Object element, int index) {
|
public void insertElementAt(T element, int index) {
|
||||||
if (fElements.contains(element)) {
|
if (fElements.contains(element)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -677,7 +676,7 @@ public class ListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Removes elements from the list.
|
* Removes elements from the list.
|
||||||
*/
|
*/
|
||||||
public void removeElements(List elements) {
|
public void removeElements(List<? extends T> elements) {
|
||||||
if (elements.size() > 0) {
|
if (elements.size() > 0) {
|
||||||
fElements.removeAll(elements);
|
fElements.removeAll(elements);
|
||||||
if (fTable != null) {
|
if (fTable != null) {
|
||||||
|
@ -745,12 +744,12 @@ public class ListDialogField extends DialogField {
|
||||||
|
|
||||||
// ------- list maintenance
|
// ------- list maintenance
|
||||||
|
|
||||||
private List moveUp(List elements, List move) {
|
private List<T> moveUp(List<? extends T> elements, List<? extends T> move) {
|
||||||
int nElements= elements.size();
|
int nElements= elements.size();
|
||||||
List res= new ArrayList(nElements);
|
List<T> res= new ArrayList<T>(nElements);
|
||||||
Object floating= null;
|
T floating= null;
|
||||||
for (int i= 0; i < nElements; i++) {
|
for (int i= 0; i < nElements; i++) {
|
||||||
Object curr= elements.get(i);
|
T curr= elements.get(i);
|
||||||
if (move.contains(curr)) {
|
if (move.contains(curr)) {
|
||||||
res.add(curr);
|
res.add(curr);
|
||||||
} else {
|
} else {
|
||||||
|
@ -766,22 +765,22 @@ public class ListDialogField extends DialogField {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveUp(List toMoveUp) {
|
private void moveUp(List<? extends T> toMoveUp) {
|
||||||
if (toMoveUp.size() > 0) {
|
if (toMoveUp.size() > 0) {
|
||||||
setElements(moveUp(fElements, toMoveUp));
|
setElements(moveUp(fElements, toMoveUp));
|
||||||
fTable.reveal(toMoveUp.get(0));
|
fTable.reveal(toMoveUp.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveDown(List toMoveDown) {
|
private void moveDown(List<? extends T> toMoveDown) {
|
||||||
if (toMoveDown.size() > 0) {
|
if (toMoveDown.size() > 0) {
|
||||||
setElements(reverse(moveUp(reverse(fElements), toMoveDown)));
|
setElements(reverse(moveUp(reverse(fElements), toMoveDown)));
|
||||||
fTable.reveal(toMoveDown.get(toMoveDown.size() - 1));
|
fTable.reveal(toMoveDown.get(toMoveDown.size() - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List reverse(List p) {
|
private List<T> reverse(List<? extends T> p) {
|
||||||
List reverse= new ArrayList(p.size());
|
List<T> reverse= new ArrayList<T>(p.size());
|
||||||
for (int i= p.size()-1; i >= 0; i--) {
|
for (int i= p.size()-1; i >= 0; i--) {
|
||||||
reverse.add(p.get(i));
|
reverse.add(p.get(i));
|
||||||
}
|
}
|
||||||
|
@ -829,12 +828,13 @@ public class ListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Returns the selected elements.
|
* Returns the selected elements.
|
||||||
*/
|
*/
|
||||||
public List getSelectedElements() {
|
public List<T> getSelectedElements() {
|
||||||
List result= new ArrayList();
|
List<T> result= new ArrayList<T>();
|
||||||
if (fTable != null) {
|
if (fTable != null) {
|
||||||
ISelection selection= fTable.getSelection();
|
ISelection selection= fTable.getSelection();
|
||||||
if (selection instanceof IStructuredSelection) {
|
if (selection instanceof IStructuredSelection) {
|
||||||
Iterator iter= ((IStructuredSelection)selection).iterator();
|
@SuppressWarnings("unchecked")
|
||||||
|
Iterator<T> iter= ((IStructuredSelection)selection).iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
result.add(iter.next());
|
result.add(iter.next());
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,20 +15,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.KeyAdapter;
|
|
||||||
import org.eclipse.swt.events.KeyEvent;
|
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Button;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.Tree;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.jface.viewers.DoubleClickEvent;
|
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||||
import org.eclipse.jface.viewers.IDoubleClickListener;
|
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||||
|
@ -43,6 +29,19 @@ import org.eclipse.jface.viewers.TreeViewer;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.viewers.ViewerComparator;
|
import org.eclipse.jface.viewers.ViewerComparator;
|
||||||
import org.eclipse.jface.viewers.ViewerSorter;
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.KeyAdapter;
|
||||||
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.events.SelectionListener;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Tree;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||||
|
@ -57,7 +56,7 @@ public class TreeListDialogField extends DialogField {
|
||||||
protected TreeViewer fTree;
|
protected TreeViewer fTree;
|
||||||
protected ILabelProvider fLabelProvider;
|
protected ILabelProvider fLabelProvider;
|
||||||
protected TreeViewerAdapter fTreeViewerAdapter;
|
protected TreeViewerAdapter fTreeViewerAdapter;
|
||||||
protected List fElements;
|
protected List<Object> fElements;
|
||||||
protected ViewerComparator fViewerComparator;
|
protected ViewerComparator fViewerComparator;
|
||||||
|
|
||||||
protected String[] fButtonLabels;
|
protected String[] fButtonLabels;
|
||||||
|
@ -92,7 +91,7 @@ public class TreeListDialogField extends DialogField {
|
||||||
fTreeViewerAdapter = new TreeViewerAdapter();
|
fTreeViewerAdapter = new TreeViewerAdapter();
|
||||||
fParentElement = this;
|
fParentElement = this;
|
||||||
|
|
||||||
fElements = new ArrayList(10);
|
fElements = new ArrayList<Object>(10);
|
||||||
|
|
||||||
fButtonLabels = buttonLabels;
|
fButtonLabels = buttonLabels;
|
||||||
if (fButtonLabels != null) {
|
if (fButtonLabels != null) {
|
||||||
|
@ -452,7 +451,7 @@ public class TreeListDialogField extends DialogField {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean containsAttributes(List selected) {
|
protected boolean containsAttributes(List<Object> selected) {
|
||||||
for (int i = 0; i < selected.size(); i++) {
|
for (int i = 0; i < selected.size(); i++) {
|
||||||
if (!fElements.contains(selected.get(i))) {
|
if (!fElements.contains(selected.get(i))) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -462,7 +461,7 @@ public class TreeListDialogField extends DialogField {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean getManagedButtonState(ISelection sel, int index) {
|
protected boolean getManagedButtonState(ISelection sel, int index) {
|
||||||
List selected = getSelectedElements();
|
List<Object> selected = getSelectedElements();
|
||||||
boolean hasAttributes = containsAttributes(selected);
|
boolean hasAttributes = containsAttributes(selected);
|
||||||
if (index == fRemoveButtonIndex) {
|
if (index == fRemoveButtonIndex) {
|
||||||
return !selected.isEmpty() && !hasAttributes;
|
return !selected.isEmpty() && !hasAttributes;
|
||||||
|
@ -515,8 +514,8 @@ public class TreeListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Sets the elements shown in the list.
|
* Sets the elements shown in the list.
|
||||||
*/
|
*/
|
||||||
public void setElements(List elements) {
|
public void setElements(List<Object> elements) {
|
||||||
fElements = new ArrayList(elements);
|
fElements = new ArrayList<Object>(elements);
|
||||||
refresh();
|
refresh();
|
||||||
if (fTree != null) {
|
if (fTree != null) {
|
||||||
fTree.expandToLevel(fTreeExpandLevel);
|
fTree.expandToLevel(fTreeExpandLevel);
|
||||||
|
@ -528,8 +527,8 @@ public class TreeListDialogField extends DialogField {
|
||||||
* Gets the elements shown in the list. The list returned is a copy, so it
|
* Gets the elements shown in the list. The list returned is a copy, so it
|
||||||
* can be modified by the user.
|
* can be modified by the user.
|
||||||
*/
|
*/
|
||||||
public List getElements() {
|
public List<Object> getElements() {
|
||||||
return new ArrayList(fElements);
|
return new ArrayList<Object>(fElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -554,7 +553,7 @@ public class TreeListDialogField extends DialogField {
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
fElements.set(idx, newElement);
|
fElements.set(idx, newElement);
|
||||||
if (fTree != null) {
|
if (fTree != null) {
|
||||||
List selected = getSelectedElements();
|
List<Object> selected = getSelectedElements();
|
||||||
if (selected.remove(oldElement)) {
|
if (selected.remove(oldElement)) {
|
||||||
selected.add(newElement);
|
selected.add(newElement);
|
||||||
}
|
}
|
||||||
|
@ -590,12 +589,12 @@ public class TreeListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Adds elements at the end of the tree list.
|
* Adds elements at the end of the tree list.
|
||||||
*/
|
*/
|
||||||
public void addElements(List elements) {
|
public void addElements(List<Object> elements) {
|
||||||
int nElements = elements.size();
|
int nElements = elements.size();
|
||||||
|
|
||||||
if (nElements > 0) {
|
if (nElements > 0) {
|
||||||
// filter duplicated
|
// filter duplicated
|
||||||
ArrayList elementsToAdd = new ArrayList(nElements);
|
ArrayList<Object> elementsToAdd = new ArrayList<Object>(nElements);
|
||||||
|
|
||||||
for (int i = 0; i < nElements; i++) {
|
for (int i = 0; i < nElements; i++) {
|
||||||
Object elem = elements.get(i);
|
Object elem = elements.get(i);
|
||||||
|
@ -660,7 +659,7 @@ public class TreeListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Removes elements from the list.
|
* Removes elements from the list.
|
||||||
*/
|
*/
|
||||||
public void removeElements(List elements) {
|
public void removeElements(List<Object> elements) {
|
||||||
if (elements.size() > 0) {
|
if (elements.size() > 0) {
|
||||||
fElements.removeAll(elements);
|
fElements.removeAll(elements);
|
||||||
if (fTree != null) {
|
if (fTree != null) {
|
||||||
|
@ -736,9 +735,9 @@ public class TreeListDialogField extends DialogField {
|
||||||
|
|
||||||
// ------- list maintenance
|
// ------- list maintenance
|
||||||
|
|
||||||
private List moveUp(List elements, List move) {
|
private List<Object> moveUp(List<Object> elements, List<Object> move) {
|
||||||
int nElements = elements.size();
|
int nElements = elements.size();
|
||||||
List res = new ArrayList(nElements);
|
List<Object> res = new ArrayList<Object>(nElements);
|
||||||
Object floating = null;
|
Object floating = null;
|
||||||
for (int i = 0; i < nElements; i++) {
|
for (int i = 0; i < nElements; i++) {
|
||||||
Object curr = elements.get(i);
|
Object curr = elements.get(i);
|
||||||
|
@ -757,22 +756,22 @@ public class TreeListDialogField extends DialogField {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveUp(List toMoveUp) {
|
private void moveUp(List<Object> toMoveUp) {
|
||||||
if (toMoveUp.size() > 0) {
|
if (toMoveUp.size() > 0) {
|
||||||
setElements(moveUp(fElements, toMoveUp));
|
setElements(moveUp(fElements, toMoveUp));
|
||||||
fTree.reveal(toMoveUp.get(0));
|
fTree.reveal(toMoveUp.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveDown(List toMoveDown) {
|
private void moveDown(List<Object> toMoveDown) {
|
||||||
if (toMoveDown.size() > 0) {
|
if (toMoveDown.size() > 0) {
|
||||||
setElements(reverse(moveUp(reverse(fElements), toMoveDown)));
|
setElements(reverse(moveUp(reverse(fElements), toMoveDown)));
|
||||||
fTree.reveal(toMoveDown.get(toMoveDown.size() - 1));
|
fTree.reveal(toMoveDown.get(toMoveDown.size() - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List reverse(List p) {
|
private List<Object> reverse(List<Object> p) {
|
||||||
List reverse = new ArrayList(p.size());
|
List<Object> reverse = new ArrayList<Object>(p.size());
|
||||||
for (int i = p.size() - 1; i >= 0; i--) {
|
for (int i = p.size() - 1; i >= 0; i--) {
|
||||||
reverse.add(p.get(i));
|
reverse.add(p.get(i));
|
||||||
}
|
}
|
||||||
|
@ -791,7 +790,7 @@ public class TreeListDialogField extends DialogField {
|
||||||
moveDown(getSelectedElements());
|
moveDown(getSelectedElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canMoveUp(List selectedElements) {
|
private boolean canMoveUp(List<Object> selectedElements) {
|
||||||
if (isOkToUse(fTreeControl)) {
|
if (isOkToUse(fTreeControl)) {
|
||||||
int nSelected = selectedElements.size();
|
int nSelected = selectedElements.size();
|
||||||
int nElements = fElements.size();
|
int nElements = fElements.size();
|
||||||
|
@ -805,7 +804,7 @@ public class TreeListDialogField extends DialogField {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canMoveDown(List selectedElements) {
|
private boolean canMoveDown(List<Object> selectedElements) {
|
||||||
if (isOkToUse(fTreeControl)) {
|
if (isOkToUse(fTreeControl)) {
|
||||||
int nSelected = selectedElements.size();
|
int nSelected = selectedElements.size();
|
||||||
for (int i = fElements.size() - 1; i >= 0 && nSelected > 0; i--) {
|
for (int i = fElements.size() - 1; i >= 0 && nSelected > 0; i--) {
|
||||||
|
@ -821,12 +820,13 @@ public class TreeListDialogField extends DialogField {
|
||||||
/**
|
/**
|
||||||
* Returns the selected elements.
|
* Returns the selected elements.
|
||||||
*/
|
*/
|
||||||
public List getSelectedElements() {
|
public List<Object> getSelectedElements() {
|
||||||
ArrayList result = new ArrayList();
|
ArrayList<Object> result = new ArrayList<Object>();
|
||||||
if (fTree != null) {
|
if (fTree != null) {
|
||||||
ISelection selection = fTree.getSelection();
|
ISelection selection = fTree.getSelection();
|
||||||
if (selection instanceof IStructuredSelection) {
|
if (selection instanceof IStructuredSelection) {
|
||||||
Iterator iter = ((IStructuredSelection) selection).iterator();
|
@SuppressWarnings("unchecked")
|
||||||
|
Iterator<Object> iter = ((IStructuredSelection) selection).iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
result.add(iter.next());
|
result.add(iter.next());
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public interface ICompletionContributor {
|
||||||
* @param proposals the current list of proposals. This method should add any additional
|
* @param proposals the current list of proposals. This method should add any additional
|
||||||
* proposals to this list.
|
* proposals to this list.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked") // no need to change, it's deprecated
|
||||||
void contributeCompletionProposals(ITextViewer viewer,
|
void contributeCompletionProposals(ITextViewer viewer,
|
||||||
int offset,
|
int offset,
|
||||||
IWorkingCopy workingCopy,
|
IWorkingCopy workingCopy,
|
||||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.ui.text.contentassist;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
import org.eclipse.jface.text.contentassist.IContextInformation;
|
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ public interface ICompletionProposalComputer {
|
||||||
* invocation, i.e. there is no need for the receiver to spawn a sub monitor.
|
* invocation, i.e. there is no need for the receiver to spawn a sub monitor.
|
||||||
* @return a list of completion proposals (element type: {@link ICompletionProposal})
|
* @return a list of completion proposals (element type: {@link ICompletionProposal})
|
||||||
*/
|
*/
|
||||||
List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor);
|
List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns context information objects valid at the given invocation context.
|
* Returns context information objects valid at the given invocation context.
|
||||||
|
@ -53,7 +52,7 @@ public interface ICompletionProposalComputer {
|
||||||
* invocation, i.e. there is no need for the receiver to spawn a sub monitor.
|
* invocation, i.e. there is no need for the receiver to spawn a sub monitor.
|
||||||
* @return a list of context information objects (element type: {@link IContextInformation})
|
* @return a list of context information objects (element type: {@link IContextInformation})
|
||||||
*/
|
*/
|
||||||
List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor);
|
List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the reason why this computer was unable to produce any completion proposals or
|
* Returns the reason why this computer was unable to produce any completion proposals or
|
||||||
|
|
Loading…
Add table
Reference in a new issue