woproject/projects/wolips/plugins/org.objectstyle.wolips.componenteditor/java/org/objectstyle/wolips/componenteditor/editor ComponentEditorPart.java,1.8,1.9 ComponentEditor.java,1.9,1.10 ComponentEditorMatchingStrategy.java,1.2,1.3

[email protected]
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/editor
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18209/java/org/objectstyle/wolips/componenteditor/editor

Modified Files:
	ComponentEditorPart.java ComponentEditor.java 
	ComponentEditorMatchingStrategy.java 
Log Message:
some dirty hacks

Index: ComponentEditorPart.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.componenteditor/java/org/objectstyle/wolips/componenteditor/editor/ComponentEditorPart.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ComponentEditorPart.java	30 Dec 2005 15:45:30 -0000	1.8
+++ ComponentEditorPart.java	6 Jan 2006 12:42:40 -0000	1.9
@@ -63,10 +63,13 @@
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IEditorSite;
 import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
 import org.eclipse.ui.part.MultiPageEditorPart;
 import org.eclipse.ui.part.MultiPageSelectionProvider;
+import org.eclipse.ui.part.ViewPart;
 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 import org.objectstyle.wolips.apieditor.editor.ApiEditor;
 import org.objectstyle.wolips.componenteditor.ComponenteditorPlugin;
@@ -78,13 +81,17 @@
 import org.objectstyle.wolips.htmlpreview.editor.HtmlPreviewEditor;
 import org.objectstyle.wolips.wodclipse.WodclipsePlugin;
 import org.objectstyle.wolips.wodclipse.wod.WodEditor;
+import org.objectstyle.wolips.workbenchutilities.WorkbenchUtilitiesPlugin;
 
 /**
  * @author uli
  */
 public class ComponentEditorPart extends MultiPageEditorPart {
 
+	boolean running = false;
+	private IEditorPart lastEditorPart;
 	ComponentEditorInput componentEditorInput;
+
 	private EditorInteraction editorInteraction = new EditorInteraction();
 
 	private IEditorPart[] editorParts;
@@ -131,6 +138,35 @@
 		setPartName(partName);
 	}
 
+	public IEditorInput getEditorInput() {
+		if(componentEditorInput == null) {
+			return super.getEditorInput();
+		}
+		IEditorInput editorInput = null;
+		int activatePage = this.getActivePage();
+		switch (activatePage) {
+		case 0:
+			editorInput = componentEditorInput.getInput()[0];
+			break;
+
+		case 1:
+			if (this.htmlActive) {
+				editorInput = componentEditorInput.getInput()[1];
+			} else {
+				editorInput = componentEditorInput.getInput()[2];
+			}
+			break;
+
+		case 3:
+			editorInput = componentEditorInput.getInput()[3];
+			break;
+		default:
+			editorInput = componentEditorInput.getInput()[1];
+			break;
+		}
+		return editorInput;
+	}
+
 	public Composite createInnerPartControl(Composite parent,
 			final IEditorPart e) {
 		Composite content = new Composite(parent, SWT.NONE);
@@ -253,15 +289,15 @@
 			}
 
 			editorParts[i] = editorPart;
-			if(editorPart instanceof IEmbeddedEditor) {
-				IEmbeddedEditor embeddedEditor = (IEmbeddedEditor)editorPart;
+			if (editorPart instanceof IEmbeddedEditor) {
+				IEmbeddedEditor embeddedEditor = (IEmbeddedEditor) editorPart;
 				embeddedEditor.initEditorInteraction(editorInteraction);
 			}
 
 		}
-		
+
 		addWebObjectsTagNamesListener();
-		
+
 		CTabFolder tabFolder = (CTabFolder) this.getContainer();
 		tabFolder.addSelectionListener(new SelectionListener() {
 
@@ -403,26 +439,29 @@
 			}
 		});
 	}
-	
-	/* (non-Javadoc)
+
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see org.eclipse.ui.part.MultiPageEditorPart#pageChange(int)
 	 * 
 	 * Because of a assert error we have to overwrite this method
 	 */
 	protected void pageChange(int newPageIndex) {
-        setFocus();
-        IEditorPart activeEditor = getEditor(newPageIndex);
-        IEditorActionBarContributor contributor = getEditorSite()
-                .getActionBarContributor();
-        if (contributor != null
-                && contributor instanceof MultiPageEditorActionBarContributor) {
-            ((MultiPageEditorActionBarContributor) contributor)
-                    .setActivePage(activeEditor);
-        }
-        if (activeEditor != null) {
+		setFocus();
+		final IEditorPart activeEditor = getEditor(newPageIndex);
+		IEditorActionBarContributor contributor = getEditorSite()
+				.getActionBarContributor();
+		if (contributor != null
+				&& contributor instanceof MultiPageEditorActionBarContributor) {
+			((MultiPageEditorActionBarContributor) contributor)
+					.setActivePage(activeEditor);
+		}
+		if (activeEditor != null) {
 			ISelectionProvider selectionProvider = activeEditor.getSite()
 					.getSelectionProvider();
-			if (selectionProvider != null && selectionProvider.getSelection() != null) {
+			if (selectionProvider != null
+					&& selectionProvider.getSelection() != null) {
 				SelectionChangedEvent event = new SelectionChangedEvent(
 						selectionProvider, selectionProvider.getSelection());
 				MultiPageSelectionProvider provider = (MultiPageSelectionProvider) getSite()
@@ -430,10 +469,39 @@
 				provider.fireSelectionChanged(event);
 				provider.firePostSelectionChanged(event);
 			}
-			 if (activeEditor instanceof IEmbeddedEditorSelected) {
-				 IEmbeddedEditorSelected embeddedEditorPageChanged = (IEmbeddedEditorSelected)activeEditor;
-				 embeddedEditorPageChanged.editorSelected();
-			 }
+			if (activeEditor instanceof IEmbeddedEditorSelected) {
+				IEmbeddedEditorSelected embeddedEditorPageChanged = (IEmbeddedEditorSelected) activeEditor;
+				embeddedEditorPageChanged.editorSelected();
+			}
+			//force activation to send part activated events
+			//WorkbenchUtilitiesPlugin.getActivePage().activate(this);
+			if(!running && lastEditorPart != null && activeEditor != lastEditorPart) {
+			Display.getCurrent().asyncExec(new Runnable() {
+
+				public void run() {
+					running = true;
+					IViewReference[] viewReferences =  WorkbenchUtilitiesPlugin.getActivePage().getViewReferences();
+					WorkbenchUtilitiesPlugin.getActivePage().activate(viewReferences[0].getPart(false));
+
+					Display.getCurrent().asyncExec(new Runnable() {
+
+						public void run() {
+							WorkbenchUtilitiesPlugin.getActivePage().activate(activeEditor);
+
+							Display.getDefault().asyncExec(new Runnable() {
+								public void run() {
+									setFocus();
+									running = false;
+								}
+							});
+						}
+						
+					});
+				}
+				
+			});
+			}
+			lastEditorPart = activeEditor;
 		}
-    }
+	}
 }

Index: ComponentEditor.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.componenteditor/java/org/objectstyle/wolips/componenteditor/editor/ComponentEditor.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ComponentEditor.java	30 Dec 2005 15:44:54 -0000	1.9
+++ ComponentEditor.java	6 Jan 2006 12:42:40 -0000	1.10
@@ -90,7 +90,6 @@
 	}
 
 	public void gotoMarker(IMarker marker) {
-		ComponenteditorPlugin.getDefault().log(marker);
 		IResource resource = marker.getResource();
 		if(resource == null) {
 			return;

Index: ComponentEditorMatchingStrategy.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.componenteditor/java/org/objectstyle/wolips/componenteditor/editor/ComponentEditorMatchingStrategy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ComponentEditorMatchingStrategy.java	30 Dec 2005 15:44:37 -0000	1.2
+++ ComponentEditorMatchingStrategy.java	6 Jan 2006 12:42:40 -0000	1.3
@@ -83,20 +83,16 @@
 				.equalsIgnoreCase(extension))) {
 			return false;
 		}
-		IEditorInput editorReferenceEditorInput = null;
-		try {
-			//expensive call it as late as possible
-			editorReferenceEditorInput = editorReference.getEditorInput();
-		} catch (PartInitException e) {
-			ComponenteditorPlugin.getDefault().log(e);
-		}
-		if(editorReferenceEditorInput == null) {
-			return false;
-		}
-		if(!(editorReferenceEditorInput instanceof ComponentEditorInput)) {
-			return false;
-		}
-		ComponentEditorInput componentEditorInput = (ComponentEditorInput)editorReferenceEditorInput;
+//		IEditorInput editorReferenceEditorInput = null;
+		//expensive: call it as late as possible
+		ComponentEditorInput componentEditorInput = ((ComponentEditorPart)editorReference.getPart(false)).componentEditorInput;
+//		if(editorReferenceEditorInput == null) {
+//			return false;
+//		}
+//		if(!(editorReferenceEditorInput instanceof ComponentEditorInput)) {
+//			return false;
+//		}
+//		ComponentEditorInput componentEditorInput = (ComponentEditorInput)editorReferenceEditorInput;
 		IEditorInput[] editorInputArray = componentEditorInput.getInput();
 		for (int i = 0; i < editorInputArray.length; i++) {
 			IFile inputFileFromEditor = ResourceUtil.getFile(editorInputArray[i]);



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.