1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Patch for Victor Mozgin

Fix for PR 39476: Preference listeners for task tags do not work.
Fix for PR 39477: Task tags options dialogs ask for project rebuilds.
This commit is contained in:
John Camelon 2003-07-07 15:35:46 +00:00
parent 91794dcff9
commit 4576601158
8 changed files with 132 additions and 11 deletions

View file

@ -48,6 +48,7 @@ public interface IOpenable extends IBufferChangedListener{
* by updating the element's structure and properties as necessary.
*/
void makeConsistent(IProgressMonitor progress) throws CModelException;
void makeConsistent(IProgressMonitor progress, boolean forced) throws CModelException;
/**
* Opens this element and all parent elements that are not already open.

View file

@ -216,7 +216,11 @@ public abstract class Openable extends Parent implements IOpenable, IBufferChang
* @see org.eclipse.cdt.core.model.IOpenable#makeConsistent(IProgressMonitor)
*/
public void makeConsistent(IProgressMonitor pm) throws CModelException {
if (!isConsistent()) {
makeConsistent(pm, false);
}
public void makeConsistent(IProgressMonitor pm, boolean forced) throws CModelException {
if (!isConsistent() || forced) {
buildStructure((OpenableInfo)getElementInfo(), pm);
}
}

View file

@ -440,7 +440,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
* @see org.eclipse.cdt.core.model.IOpenable#makeConsistent(IProgressMonitor)
*/
public void makeConsistent(IProgressMonitor pm) throws CModelException {
if (!isConsistent()) {
makeConsistent(pm, false);
}
public void makeConsistent(IProgressMonitor pm, boolean forced) throws CModelException {
if (!isConsistent() || forced) {
// create a new info and make it the current info
OpenableInfo info = (OpenableInfo) createElementInfo();
buildStructure(info, pm);

View file

@ -4,6 +4,10 @@
the include and defined symbol information for a standard make project.
* src/org/eclipse/cdt/ui/wizards/BuildPathInfoBlock.java
2003-07-04 Victor Mozgin
Fix for PR 39476: Preference listeners for task tags do not work.
Fix for PR 39477: Task tags options dialogs ask for project rebuilds.
2003-06-27 Andrew Niefer
Changes for C/C++ Search:
Added:

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.text.CPairMatcher;
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
@ -836,6 +837,15 @@ public class CEditor extends TextEditor implements ISelectionChangedListener {
setKeyBindingScopes(new String [] { "org.eclipse.cdt.ui.cEditorScope" } );
}
/* (non-Javadoc)
* @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
*/
protected boolean affectsTextPresentation(PropertyChangeEvent event) {
CTextTools textTools = CUIPlugin.getDefault().getTextTools();
AsmTextTools asmTools = CUIPlugin.getDefault().getAsmTextTools();
return textTools.affectsBehavior(event) || asmTools.affectsBehavior(event);
}
/**
* Handles a property change event describing a change
* of the C core's preferences and updates the preference

View file

@ -17,6 +17,10 @@ import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
@ -41,11 +45,17 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.ui.IEditorInput;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener;
/**
@ -314,26 +324,27 @@ public abstract class OptionsConfigurationBlock {
if (hasChanges) {
boolean doBuild= false;
String[] strings= getFullBuildDialogStrings(fProject == null);
boolean doReParse = false;
String[] strings = getFullReParseDialogStrings(fProject == null);
if (strings != null) {
MessageDialog dialog= new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2);
MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2);
int res= dialog.open();
if (res == 0) {
doBuild= true;
doReParse = true;
} else if (res != 1) {
return false; // cancel pressed
}
}
setOptions(actualOptions);
if (doBuild) {
doFullBuild();
if (doReParse) {
doFullReParse();
}
}
return true;
}
protected abstract String[] getFullBuildDialogStrings(boolean workspaceSettings);
protected abstract String[] getFullReParseDialogStrings(boolean workspaceSettings);
protected void doFullBuild() {
ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
@ -363,7 +374,73 @@ public abstract class OptionsConfigurationBlock {
String message= PreferencesMessages.getString("OptionsConfigurationBlock.builderror.message"); //$NON-NLS-1$
ExceptionHandler.handle(e, getShell(), title, message);
}
}
}
protected void doFullReParse() {
ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
try {
dialog.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
monitor.beginTask("", 1); //$NON-NLS-1$
if (fProject != null) {
monitor.setTaskName(PreferencesMessages.getFormattedString("OptionsConfigurationBlock.parseproject.taskname", fProject.getElementName())); //$NON-NLS-1$
reParseHierarchy(fProject.getResource(), monitor);
} else {
monitor.setTaskName(PreferencesMessages.getString("OptionsConfigurationBlock.parseall.taskname")); //$NON-NLS-1$
reParseHierarchy(CUIPlugin.getWorkspace().getRoot(), monitor);
}
monitor.done();
}
});
} catch (InterruptedException e) {
// cancelled by user
} catch (InvocationTargetException e) {
String title= PreferencesMessages.getString("OptionsConfigurationBlock.parseerror.title"); //$NON-NLS-1$
String message= PreferencesMessages.getString("OptionsConfigurationBlock.parseerror.message"); //$NON-NLS-1$
ExceptionHandler.handle(e, getShell(), title, message);
}
}
protected void reParseHierarchy(IResource root, final IProgressMonitor monitor) {
try {
root.accept(
new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) {
switch(proxy.getType()) {
case IResource.FILE :
IFile file = (IFile)proxy.requestResource();
CoreModel cModel = CCorePlugin.getDefault().getCoreModel();
if (cModel.isTranslationUnit(file)) {
ITranslationUnit translationUnit = (ITranslationUnit)cModel.create(file);
try {
IEditorInput input = EditorUtility.getEditorInput(file);
if (input != null) {
ITranslationUnit workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input);
if (workingCopy != null) {
// We have a copy in an editor - use it
translationUnit = workingCopy;
}
}
translationUnit.makeConsistent(monitor, true /*forced*/);
} catch (CModelException e) {
}
}
return false; // Do not look into file's structure
}
return true;
}
}
, IResource.NONE);
} catch (CoreException e) {
}
}
public void performDefaults() {
fWorkingValues= getDefaultOptions();

View file

@ -16,6 +16,13 @@ OptionsConfigurationBlock.buildall.taskname=Build all...
OptionsConfigurationBlock.buildproject.taskname=Build project ''{0}''...
OptionsConfigurationBlock.parseerror.title=Preference Changes
OptionsConfigurationBlock.parseerror.message=Problem while parsing. Check log for details.
OptionsConfigurationBlock.parseall.taskname=Parse all...
OptionsConfigurationBlock.parseproject.taskname=Parse project ''{0}''...
TodoTaskPreferencePage.title=Task Tags
TodoTaskPropertyPage.useworkspacesettings.label=Use &workspace settings
@ -36,6 +43,10 @@ TodoTaskConfigurationBlock.needsbuild.title=Task Tags Settings Changed
TodoTaskConfigurationBlock.needsfullbuild.message=The task tags settings have changed. A full rebuild is required to make changes effective. Do the full build now?
TodoTaskConfigurationBlock.needsprojectbuild.message=The task tags settings have changed. A rebuild of the project is required to make changes effective. Do the project build now?
TodoTaskConfigurationBlock.needsparse.title=Task Tags Settings Changed
TodoTaskConfigurationBlock.needsfullparse.message=The task tags settings have changed. A full re-parse is required to make changes effective. Do the full re-parse now?
TodoTaskConfigurationBlock.needsprojectparse.message=The task tags settings have changed. Re-parsing of the project is required to make changes effective. Do the project re-parse now?
TodoTaskInputDialog.new.title=New Task Tag
TodoTaskInputDialog.edit.title=Edit Task Tag
TodoTaskInputDialog.name.label=T&ag:

View file

@ -225,7 +225,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
return super.performOk(enabled);
}
protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
String title= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsbuild.title"); //$NON-NLS-1$
String message;
@ -235,6 +235,17 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$
}
return new String[] { title, message };
}
protected String[] getFullReParseDialogStrings(boolean workspaceSettings) {
String title= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsparse.title"); //$NON-NLS-1$
String message;
if (fProject == null) {
message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsfullparse.message"); //$NON-NLS-1$
} else {
message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsprojectparse.message"); //$NON-NLS-1$
}
return new String[] { title, message };
}
/* (non-Javadoc)