woproject/projects/wolips/plugins/org.objectstyle.wolips.componenteditor/java/org/objectstyle/wolips/componenteditor/part ComponentEditor.java,1.2,1.3 ComponentEditorPart.java,1.1,1.2

[email protected] Fri, 3 Mar 2006 09:54:02 -0800 (PST)
Newsgroups gmane.comp.web.webobjects.woproject.cvs
Message-ID <[email protected]>
Update of /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.componenteditor/java/org/objectstyle/wolips/componenteditor/part
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22350/java/org/objectstyle/wolips/componenteditor/part

Modified Files:
	ComponentEditor.java ComponentEditorPart.java 
Log Message:
Switch between debugger, search results, package explorer and problems view. Everything should work as expected.

Index: ComponentEditor.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.componenteditor/java/org/objectstyle/wolips/componenteditor/part/ComponentEditor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ComponentEditor.java	1 Mar 2006 16:54:35 -0000	1.2
+++ ComponentEditor.java	3 Mar 2006 17:53:29 -0000	1.3
@@ -69,122 +69,137 @@
 
 	
 	public IDocumentProvider getDocumentProvider() {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return null;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		return textEditor.getDocumentProvider();
 	}
 
 	public void close(boolean save) {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		textEditor.close(save);
 	}
 
 	public boolean isEditable() {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return false;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		return textEditor.isEditable();
 	}
 
 	public void doRevertToSaved() {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		textEditor.doRevertToSaved();
 	}
 
 	public void setAction(String actionID, IAction action) {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		textEditor.setAction(actionID, action);
 	}
 
 	public IAction getAction(String actionId) {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return null;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		return textEditor.getAction(actionId);
 	}
 
 	public void setActionActivationCode(String actionId, char activationCharacter, int activationKeyCode, int activationStateMask) {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		textEditor.setActionActivationCode(actionId, activationCharacter, activationKeyCode, activationStateMask);
 	}
 
 	public void removeActionActivationCode(String actionId) {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		textEditor.removeActionActivationCode(actionId);
 	}
 
 	public boolean showsHighlightRangeOnly() {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return false;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		return textEditor.showsHighlightRangeOnly();
 	}
 
 	public void showHighlightRangeOnly(boolean showHighlightRangeOnly) {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		textEditor.showHighlightRangeOnly(showHighlightRangeOnly);
 	}
 
 	public void setHighlightRange(int offset, int length, boolean moveCursor) {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		textEditor.setHighlightRange(offset, length, moveCursor);
 	}
 
 	public IRegion getHighlightRange() {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return null;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		return textEditor.getHighlightRange();
 	}
 
 	public void resetHighlightRange() {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		textEditor.resetHighlightRange();
 	}
 
 	public ISelectionProvider getSelectionProvider() {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return null;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		return textEditor.getSelectionProvider();
 	}
 
 	public void selectAndReveal(int offset, int length) {
-		if(this.getActivePage() != 0) {
-			this.switchToJava();
+		IEditorPart editorPart = this.getActiveEditor();
+		if(editorPart == null || !(this.getActiveEditor() instanceof ITextEditor)) {
+			return;
 		}
-		ITextEditor textEditor = (ITextEditor)compilationUnitEditor;
+		ITextEditor textEditor = (ITextEditor)editorPart;
 		textEditor.selectAndReveal(offset, length);
 	}
 

Index: ComponentEditorPart.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.componenteditor/java/org/objectstyle/wolips/componenteditor/part/ComponentEditorPart.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ComponentEditorPart.java	1 Mar 2006 16:43:43 -0000	1.1
+++ ComponentEditorPart.java	3 Mar 2006 17:53:29 -0000	1.2
@@ -437,11 +437,7 @@
 
 	public void switchToPage(int page) {
 		this.setActivePage(page);
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				setFocus();
-			}
-		});
+		setFocus();
 	}
 
 	/*



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642