[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Optimize buildconsole selection
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.21
diff -u -r1.21 ChangeLog
--- ChangeLog 13 Nov 2002 20:39:29 -0000 1.21
+++ ChangeLog 14 Nov 2002 15:18:55 -0000
@@ -1,3 +1,9 @@
+2002-11-14 Alain Magloire
+
+ * src/.../internal/ui/buildconsole/BuildConsoleView.java (convertSelectionToProject):
+ new method.
+ (selectionChanged): Only reset the document if selected project changed.
+
2002-11-13 Judy N. Green
*/home/tools/org.eclipse.cdt.ui/plugin.properties
*/home/tools/org.eclipse.cdt.ui/plugin.xml
Index: src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java,v
retrieving revision 1.2
diff -u -r1.2 BuildConsoleView.java
--- src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java 30 Oct 2002 03:10:33 -0000 1.2
+++ src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java 14 Nov 2002 15:18:55 -0000
@@ -126,33 +126,14 @@
fConsoleManager.addConsoleListener(this);
}
- protected IProject setProject(ISelection selection) {
- if ( selection == null ) {
- return null;
- }
- try {
- IStructuredSelection ssel = (IStructuredSelection) selection;
- IAdaptable input = (IAdaptable) ssel.getFirstElement();
- if (input != null) {
- IResource resource = null;
- if (input instanceof IResource) {
- resource = (IResource) input;
- }
- else {
- resource = (IResource) input.getAdapter(IResource.class);
- }
- if (resource != null) {
- selProject = resource.getProject();
- return selProject;
- }
- }
- }
- catch (ClassCastException e) {
- }
- selProject = null;
- return selProject;
+ protected void setProject(ISelection selection) {
+ selProject = convertSelectionToProject(selection);
}
-
+
+ protected void setProject(IProject project) {
+ selProject = project;
+ }
+
protected IProject getProject() {
return selProject;
}
@@ -240,16 +221,6 @@
actionBars.getToolBarManager().add(fClearOutputAction);
actionBars.updateActionBars();
}
-
- /**
- * Clears the console
- */
- void clear() {
- if (selProject != null) {
- fConsoleManager.getConsole(selProject).clear();
- }
- }
-
/**
* Reveals (makes visible) the end of the current document
*/
@@ -282,9 +253,14 @@
}
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- setProject(selection);
- setDocument();
- setTitle();
+ IProject newProject = convertSelectionToProject(selection);
+ IProject oldProject = getProject();
+ if (oldProject == null ||
+ (newProject != null && !newProject.equals(oldProject))) {
+ setProject(newProject);
+ setDocument();
+ setTitle();
+ }
}
public void consoleChange(IBuildConsoleEvent event) {
@@ -297,6 +273,39 @@
setTitle();
}
});
+ }
+ }
+
+ IProject convertSelectionToProject(ISelection selection) {
+ IProject project = null;
+ if ( selection == null ) {
+ return project;
+ }
+ try {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
+ IAdaptable input = (IAdaptable) ssel.getFirstElement();
+ if (input != null) {
+ IResource resource = null;
+ if (input instanceof IResource) {
+ resource = (IResource) input;
+ } else {
+ resource = (IResource) input.getAdapter(IResource.class);
+ }
+ if (resource != null) {
+ project = resource.getProject();
+ }
+ }
+ } catch (ClassCastException e) {
+ }
+ return project;
+ }
+
+ /**
+ * Clears the console
+ */
+ void clear() {
+ if (selProject != null) {
+ fConsoleManager.getConsole(selProject).clear();
}
}