You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by bj...@apache.org on 2008/11/18 20:45:11 UTC
svn commit: r718691 - in /geronimo/devtools/eclipse-plugin:
branches/2.1.4/plugins/org.apache.geronimo.st.ui/META-INF/
branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/
branches/2.1.4/plugins/org.apache.g...
Author: bjreed
Date: Tue Nov 18 11:45:11 2008
New Revision: 718691
URL: http://svn.apache.org/viewvc?rev=718691&view=rev
Log:
GERONIMODEVTOOLS-400 change for updating deployment plan editors when Source page has been saved
Added:
geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java (with props)
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java (with props)
Modified:
geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF
geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoDeploymentPlanEditor.java
geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties
geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/AbstractGeronimoFormPage.java
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoDeploymentPlanEditor.java
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/AbstractGeronimoFormPage.java
Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF?rev=718691&r1=718690&r2=718691&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF Tue Nov 18 11:45:11 2008
@@ -24,7 +24,9 @@
org.eclipse.ui.workbench,
org.eclipse.core.resources,
org.apache.geronimo.runtime.common,
- org.eclipse.wst.sse.ui
+ org.eclipse.wst.sse.ui,
+ org.eclipse.text,
+ org.eclipse.jface.text
Bundle-ActivationPolicy: lazy
Export-Package: org,
org.apache,
Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoDeploymentPlanEditor.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoDeploymentPlanEditor.java?rev=718691&r1=718690&r2=718691&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoDeploymentPlanEditor.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoDeploymentPlanEditor.java Tue Nov 18 11:45:11 2008
@@ -27,6 +27,8 @@
import org.apache.geronimo.st.core.operations.ImportDeploymentPlanOperation;
import org.apache.geronimo.st.ui.internal.Messages;
import org.apache.geronimo.st.ui.internal.Trace;
+import org.apache.geronimo.st.ui.pages.AbstractGeronimoFormPage;
+import org.apache.geronimo.st.ui.pages.DeploymentPlanSourcePage;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -37,7 +39,7 @@
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.IFormPage;
@@ -55,163 +57,203 @@
*/
public abstract class AbstractGeronimoDeploymentPlanEditor extends FormEditor {
- protected JAXBElement deploymentPlan;
+ protected JAXBElement deploymentPlan;
- public AbstractGeronimoDeploymentPlanEditor() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void doSave(IProgressMonitor monitor) {
- InputStream is = null;
- try {
- IEditorInput input = getEditorInput();
- if (input instanceof IFileEditorInput) {
- IFileEditorInput fei = (IFileEditorInput) input;
- if (deploymentPlan != null) {
- saveDeploymentPlan(fei.getFile());
- commitFormPages(true);
- }
-
- if (getActiveEditor() == null) {
- editorDirtyStateChanged();
- } else {
- getActiveEditor().doSave(monitor);
- if (deploymentPlan != null) {
-// if (deploymentPlan.eResource() != null) {
-// deploymentPlan.eResource().unload();
-// }
- // TODO not sure if this is the best way to refresh
- // model
- deploymentPlan = loadDeploymentPlan(fei.getFile());
- }
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error saving", e);
- } finally {
- try {
- if (is != null)
- is.close();
- } catch (Exception e) {
- // do nothing
- }
- }
- }
-
-// private void saveEditors(IFile file) throws IOException, JAXBException {
-// JAXBContext jb = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1", Activator.class.getClassLoader() );
-// jb.createMarshaller().marshal( deploymentPlan, new File( file.getLocationURI().toURL().getFile()) );
-// commitFormPages(true);
-// }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
- */
- protected void addPages() {
- try {
- doAddPages();
- } catch (PartInitException e1) {
- e1.printStackTrace();
- }
- }
-
- abstract public void doAddPages() throws PartInitException;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#doSaveAs()
- */
- public final void doSaveAs() {
- // do nothing
- }
-
- protected void addSourcePage() throws PartInitException {
- StructuredTextEditor source = new StructuredTextEditor();
- int index = addPage(source, getEditorInput());
- setPageText(index, Messages.editorTabSource);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
- */
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- public void commitFormPages(boolean onSave) {
- IFormPage[] pages = getPages();
- for (int i = 0; i < pages.length; i++) {
- IFormPage page = pages[i];
- IManagedForm mform = page.getManagedForm();
- if (mform != null && mform.isDirty())
- mform.commit(true);
- }
- }
-
- public IFormPage[] getPages() {
- ArrayList formPages = new ArrayList();
- for (int i = 0; i < pages.size(); i++) {
- Object page = pages.get(i);
- if (page instanceof IFormPage)
- formPages.add(page);
- }
- return (IFormPage[]) formPages.toArray(new IFormPage[formPages.size()]);
- }
-
- public JAXBElement getDeploymentPlan() {
- return deploymentPlan;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite,
- * org.eclipse.ui.IEditorInput)
- */
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- super.init(site, input);
- if (input instanceof IFileEditorInput) {
- IFileEditorInput fei = (IFileEditorInput) input;
- deploymentPlan = loadDeploymentPlan(fei.getFile());
-
- boolean fix = false;
- if(deploymentPlan == null) {
- fix = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.errorOpenDialog, Messages.editorCorrect);
- }
-
- if(fix) {
- IProject project = fei.getFile().getProject();
- IDataModel model = DataModelFactory.createDataModel(new ImportDeploymentPlanDataModelProvider());
- model.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, project.getName());
- try {
- IFacetedProject facetedProject = ProjectFacetsManager.create(project);
- model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, facetedProject.getPrimaryRuntime());
- IDataModelOperation op = new ImportDeploymentPlanOperation(model);
- op.execute(new NullProgressMonitor(), null);
- } catch (Exception e) {
- //ingnore
- }
-
- deploymentPlan = loadDeploymentPlan(fei.getFile());
-
- if (deploymentPlan == null) {
- MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.errorOpenDialog, Messages.editorDefault);
- }
- }
- }
- }
+ public AbstractGeronimoDeploymentPlanEditor() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void doSave(IProgressMonitor monitor) {
+ InputStream is = null;
+ try {
+ IEditorInput input = getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFileEditorInput fei = (IFileEditorInput) input;
+ if (deploymentPlan != null) {
+ saveDeploymentPlan(fei.getFile());
+ commitFormPages(true);
+ }
+
+ if (getActiveEditor() == null) {
+ editorDirtyStateChanged();
+ } else {
+ getActiveEditor().doSave(monitor);
+ if (deploymentPlan != null) {
+// if (deploymentPlan.eResource() != null) {
+// deploymentPlan.eResource().unload();
+// }
+ // TODO not sure if this is the best way to refresh
+ // model
+ deploymentPlan = loadDeploymentPlan(fei.getFile());
+ }
+ }
+ }
+ } catch (Exception e) {
+ Trace.trace(Trace.SEVERE, "Error saving", e);
+ } finally {
+ try {
+ if (is != null)
+ is.close();
+ } catch (Exception e) {
+ // do nothing
+ }
+ }
+ }
+
+// private void saveEditors(IFile file) throws IOException, JAXBException {
+// JAXBContext jb = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1", Activator.class.getClassLoader() );
+// jb.createMarshaller().marshal( deploymentPlan, new File( file.getLocationURI().toURL().getFile()) );
+// commitFormPages(true);
+// }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+ */
+ protected void addPages() {
+ try {
+ doAddPages();
+ } catch (PartInitException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ abstract public void doAddPages() throws PartInitException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+ */
+ public final void doSaveAs() {
+ // do nothing
+ }
+
+ protected void addSourcePage() throws PartInitException {
+ DeploymentPlanSourcePage source = new DeploymentPlanSourcePage(this);
+ int index = addPage(source, getEditorInput());
+ setPageText(index, Messages.editorTabSource);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ public void commitFormPages(boolean onSave) {
+ IFormPage[] pages = getPages();
+ for (int i = 0; i < pages.length; i++) {
+ IFormPage page = pages[i];
+ IManagedForm mform = page.getManagedForm();
+ if (mform != null && mform.isDirty())
+ mform.commit(true);
+ }
+ }
+
+ public IFormPage[] getPages() {
+ ArrayList formPages = new ArrayList();
+ for (int i = 0; i < pages.size(); i++) {
+ Object page = pages.get(i);
+ if (page instanceof IFormPage)
+ formPages.add(page);
+ }
+ return (IFormPage[]) formPages.toArray(new IFormPage[formPages.size()]);
+ }
+
+ public JAXBElement getDeploymentPlan() {
+ return deploymentPlan;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite,
+ * org.eclipse.ui.IEditorInput)
+ */
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ super.init(site, input);
+ if (input instanceof IFileEditorInput) {
+ IFileEditorInput fei = (IFileEditorInput) input;
+ deploymentPlan = loadDeploymentPlan(fei.getFile());
+
+ boolean fix = false;
+ if(deploymentPlan == null) {
+ fix = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.errorOpenDialog, Messages.editorCorrect);
+ }
+
+ if(fix) {
+ IProject project = fei.getFile().getProject();
+ IDataModel model = DataModelFactory.createDataModel(new ImportDeploymentPlanDataModelProvider());
+ model.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, project.getName());
+ try {
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, facetedProject.getPrimaryRuntime());
+ IDataModelOperation op = new ImportDeploymentPlanOperation(model);
+ op.execute(new NullProgressMonitor(), null);
+ } catch (Exception e) {
+ //ingnore
+ }
+
+ deploymentPlan = loadDeploymentPlan(fei.getFile());
+
+ if (deploymentPlan == null) {
+ MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.errorOpenDialog, Messages.editorDefault);
+ }
+ }
+ }
+ }
+
+ public void reloadDeploymentPlan() {
+ IEditorInput input = getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFileEditorInput fei = (IFileEditorInput) input;
+ if (deploymentPlan != null) {
+ deploymentPlan = loadDeploymentPlan(fei.getFile());
+ IFormPage[] pages = getPages();
+ for (int i = 0; i < pages.length; i++) {
+ IFormPage page = pages[i];
+ IManagedForm mform = page.getManagedForm();
+ if (mform != null) {
+ if (page instanceof AbstractGeronimoFormPage) {
+ AbstractGeronimoFormPage geronimoPage = (AbstractGeronimoFormPage)page;
+ geronimoPage.refresh();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void pageChange(int newPageIndex) {
+ if (isDirty()) {
+ IFormPage[] pages = getPages();
+ IFormPage active = getActivePageInstance();
+ int curr = getCurrentPage();
+ if (getCurrentPage() == newPageIndex) {
+ return;
+ }
+ // if the old or the new page are the source page, don't allow the page change
+ if (newPageIndex == pages.length || getCurrentPage() == pages.length) {
+ setActivePage(curr);
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.savePageTitle, Messages.savePageMessage);
+ return;
+ }
+ }
+ super.pageChange(newPageIndex);
+ }
- abstract public JAXBElement loadDeploymentPlan(IFile file);
- abstract public void saveDeploymentPlan(IFile file) throws IOException, JAXBException;
+ abstract public JAXBElement loadDeploymentPlan(IFile file);
+ abstract public void saveDeploymentPlan(IFile file) throws IOException, JAXBException;
}
Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties?rev=718691&r1=718690&r2=718691&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties Tue Nov 18 11:45:11 2008
@@ -406,4 +406,4 @@
plugin=Plugin
savePageTitle=Save Resource
-savePageMessage=Please save the page before proceeding to the Source page.
+savePageMessage=Data must be saved before entering or leaving the Source page.
Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/AbstractGeronimoFormPage.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/AbstractGeronimoFormPage.java?rev=718691&r1=718690&r2=718691&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/AbstractGeronimoFormPage.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/AbstractGeronimoFormPage.java Tue Nov 18 11:45:11 2008
@@ -22,14 +22,13 @@
import org.apache.geronimo.st.core.descriptor.AbstractDeploymentDescriptor;
import org.apache.geronimo.st.ui.Activator;
import org.apache.geronimo.st.ui.editors.AbstractGeronimoDeploymentPlanEditor;
-import org.apache.geronimo.st.ui.internal.Messages;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
@@ -71,6 +70,16 @@
super(id, title);
}
+ public void refresh() {
+ // clear the old composite and tool bar
+ Control[] controls = body.getChildren();
+ for (int i = 0; i < controls.length; i++) {
+ controls[i].dispose();
+ }
+ getManagedForm().getForm().getToolBarManager().removeAll();
+ createFormContent(getManagedForm());
+ }
+
/*
* (non-Javadoc)
*
@@ -166,15 +175,4 @@
public String getFormTitle() {
return getTitle();
}
-
- // Do not allow the user to go to the source page if data has not been saved.
- @Override
- public boolean canLeaveThePage() {
- if (getEditor().isDirty() &&
- getEditor().getActivePageInstance() == getEditor().findPage(Messages.editorTabSource)) {
- MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.savePageTitle, Messages.savePageMessage);
- return false;
- }
- return true;
- }
}
Added: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java?rev=718691&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java Tue Nov 18 11:45:11 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.ui.pages;
+
+import org.apache.geronimo.st.ui.editors.AbstractGeronimoDeploymentPlanEditor;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DeploymentPlanSourcePage extends StructuredTextEditor {
+
+ protected AbstractGeronimoDeploymentPlanEditor editor;
+
+ public DeploymentPlanSourcePage (AbstractGeronimoDeploymentPlanEditor editor) {
+ super();
+ this.editor = editor;
+ }
+
+ @Override
+ public void doSave(IProgressMonitor progressMonitor) {
+ super.doSave(progressMonitor);
+ editor.reloadDeploymentPlan();
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF?rev=718691&r1=718690&r2=718691&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF Tue Nov 18 11:45:11 2008
@@ -24,7 +24,9 @@
org.eclipse.ui.workbench,
org.eclipse.core.resources,
org.apache.geronimo.runtime.common,
- org.eclipse.wst.sse.ui
+ org.eclipse.wst.sse.ui,
+ org.eclipse.text,
+ org.eclipse.jface.text
Bundle-ActivationPolicy: lazy
Export-Package: org,
org.apache,
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoDeploymentPlanEditor.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoDeploymentPlanEditor.java?rev=718691&r1=718690&r2=718691&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoDeploymentPlanEditor.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoDeploymentPlanEditor.java Tue Nov 18 11:45:11 2008
@@ -27,6 +27,8 @@
import org.apache.geronimo.st.core.operations.ImportDeploymentPlanOperation;
import org.apache.geronimo.st.ui.internal.Messages;
import org.apache.geronimo.st.ui.internal.Trace;
+import org.apache.geronimo.st.ui.pages.AbstractGeronimoFormPage;
+import org.apache.geronimo.st.ui.pages.DeploymentPlanSourcePage;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -37,7 +39,7 @@
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.IFormPage;
@@ -55,163 +57,203 @@
*/
public abstract class AbstractGeronimoDeploymentPlanEditor extends FormEditor {
- protected JAXBElement deploymentPlan;
+ protected JAXBElement deploymentPlan;
- public AbstractGeronimoDeploymentPlanEditor() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void doSave(IProgressMonitor monitor) {
- InputStream is = null;
- try {
- IEditorInput input = getEditorInput();
- if (input instanceof IFileEditorInput) {
- IFileEditorInput fei = (IFileEditorInput) input;
- if (deploymentPlan != null) {
- saveDeploymentPlan(fei.getFile());
- commitFormPages(true);
- }
-
- if (getActiveEditor() == null) {
- editorDirtyStateChanged();
- } else {
- getActiveEditor().doSave(monitor);
- if (deploymentPlan != null) {
-// if (deploymentPlan.eResource() != null) {
-// deploymentPlan.eResource().unload();
-// }
- // TODO not sure if this is the best way to refresh
- // model
- deploymentPlan = loadDeploymentPlan(fei.getFile());
- }
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error saving", e);
- } finally {
- try {
- if (is != null)
- is.close();
- } catch (Exception e) {
- // do nothing
- }
- }
- }
-
-// private void saveEditors(IFile file) throws IOException, JAXBException {
-// JAXBContext jb = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1", Activator.class.getClassLoader() );
-// jb.createMarshaller().marshal( deploymentPlan, new File( file.getLocationURI().toURL().getFile()) );
-// commitFormPages(true);
-// }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
- */
- protected void addPages() {
- try {
- doAddPages();
- } catch (PartInitException e1) {
- e1.printStackTrace();
- }
- }
-
- abstract public void doAddPages() throws PartInitException;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#doSaveAs()
- */
- public final void doSaveAs() {
- // do nothing
- }
-
- protected void addSourcePage() throws PartInitException {
- StructuredTextEditor source = new StructuredTextEditor();
- int index = addPage(source, getEditorInput());
- setPageText(index, Messages.editorTabSource);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
- */
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- public void commitFormPages(boolean onSave) {
- IFormPage[] pages = getPages();
- for (int i = 0; i < pages.length; i++) {
- IFormPage page = pages[i];
- IManagedForm mform = page.getManagedForm();
- if (mform != null && mform.isDirty())
- mform.commit(true);
- }
- }
-
- public IFormPage[] getPages() {
- ArrayList formPages = new ArrayList();
- for (int i = 0; i < pages.size(); i++) {
- Object page = pages.get(i);
- if (page instanceof IFormPage)
- formPages.add(page);
- }
- return (IFormPage[]) formPages.toArray(new IFormPage[formPages.size()]);
- }
-
- public JAXBElement getDeploymentPlan() {
- return deploymentPlan;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite,
- * org.eclipse.ui.IEditorInput)
- */
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- super.init(site, input);
- if (input instanceof IFileEditorInput) {
- IFileEditorInput fei = (IFileEditorInput) input;
- deploymentPlan = loadDeploymentPlan(fei.getFile());
-
- boolean fix = false;
- if(deploymentPlan == null) {
- fix = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.errorOpenDialog, Messages.editorCorrect);
- }
-
- if(fix) {
- IProject project = fei.getFile().getProject();
- IDataModel model = DataModelFactory.createDataModel(new ImportDeploymentPlanDataModelProvider());
- model.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, project.getName());
- try {
- IFacetedProject facetedProject = ProjectFacetsManager.create(project);
- model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, facetedProject.getPrimaryRuntime());
- IDataModelOperation op = new ImportDeploymentPlanOperation(model);
- op.execute(new NullProgressMonitor(), null);
- } catch (Exception e) {
- //ingnore
- }
-
- deploymentPlan = loadDeploymentPlan(fei.getFile());
-
- if (deploymentPlan == null) {
- MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.errorOpenDialog, Messages.editorDefault);
- }
- }
- }
- }
+ public AbstractGeronimoDeploymentPlanEditor() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void doSave(IProgressMonitor monitor) {
+ InputStream is = null;
+ try {
+ IEditorInput input = getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFileEditorInput fei = (IFileEditorInput) input;
+ if (deploymentPlan != null) {
+ saveDeploymentPlan(fei.getFile());
+ commitFormPages(true);
+ }
+
+ if (getActiveEditor() == null) {
+ editorDirtyStateChanged();
+ } else {
+ getActiveEditor().doSave(monitor);
+ if (deploymentPlan != null) {
+// if (deploymentPlan.eResource() != null) {
+// deploymentPlan.eResource().unload();
+// }
+ // TODO not sure if this is the best way to refresh
+ // model
+ deploymentPlan = loadDeploymentPlan(fei.getFile());
+ }
+ }
+ }
+ } catch (Exception e) {
+ Trace.trace(Trace.SEVERE, "Error saving", e);
+ } finally {
+ try {
+ if (is != null)
+ is.close();
+ } catch (Exception e) {
+ // do nothing
+ }
+ }
+ }
+
+// private void saveEditors(IFile file) throws IOException, JAXBException {
+// JAXBContext jb = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1", Activator.class.getClassLoader() );
+// jb.createMarshaller().marshal( deploymentPlan, new File( file.getLocationURI().toURL().getFile()) );
+// commitFormPages(true);
+// }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+ */
+ protected void addPages() {
+ try {
+ doAddPages();
+ } catch (PartInitException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ abstract public void doAddPages() throws PartInitException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+ */
+ public final void doSaveAs() {
+ // do nothing
+ }
+
+ protected void addSourcePage() throws PartInitException {
+ DeploymentPlanSourcePage source = new DeploymentPlanSourcePage(this);
+ int index = addPage(source, getEditorInput());
+ setPageText(index, Messages.editorTabSource);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ public void commitFormPages(boolean onSave) {
+ IFormPage[] pages = getPages();
+ for (int i = 0; i < pages.length; i++) {
+ IFormPage page = pages[i];
+ IManagedForm mform = page.getManagedForm();
+ if (mform != null && mform.isDirty())
+ mform.commit(true);
+ }
+ }
+
+ public IFormPage[] getPages() {
+ ArrayList formPages = new ArrayList();
+ for (int i = 0; i < pages.size(); i++) {
+ Object page = pages.get(i);
+ if (page instanceof IFormPage)
+ formPages.add(page);
+ }
+ return (IFormPage[]) formPages.toArray(new IFormPage[formPages.size()]);
+ }
+
+ public JAXBElement getDeploymentPlan() {
+ return deploymentPlan;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite,
+ * org.eclipse.ui.IEditorInput)
+ */
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ super.init(site, input);
+ if (input instanceof IFileEditorInput) {
+ IFileEditorInput fei = (IFileEditorInput) input;
+ deploymentPlan = loadDeploymentPlan(fei.getFile());
+
+ boolean fix = false;
+ if(deploymentPlan == null) {
+ fix = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.errorOpenDialog, Messages.editorCorrect);
+ }
+
+ if(fix) {
+ IProject project = fei.getFile().getProject();
+ IDataModel model = DataModelFactory.createDataModel(new ImportDeploymentPlanDataModelProvider());
+ model.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, project.getName());
+ try {
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, facetedProject.getPrimaryRuntime());
+ IDataModelOperation op = new ImportDeploymentPlanOperation(model);
+ op.execute(new NullProgressMonitor(), null);
+ } catch (Exception e) {
+ //ingnore
+ }
+
+ deploymentPlan = loadDeploymentPlan(fei.getFile());
+
+ if (deploymentPlan == null) {
+ MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.errorOpenDialog, Messages.editorDefault);
+ }
+ }
+ }
+ }
+
+ public void reloadDeploymentPlan() {
+ IEditorInput input = getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFileEditorInput fei = (IFileEditorInput) input;
+ if (deploymentPlan != null) {
+ deploymentPlan = loadDeploymentPlan(fei.getFile());
+ IFormPage[] pages = getPages();
+ for (int i = 0; i < pages.length; i++) {
+ IFormPage page = pages[i];
+ IManagedForm mform = page.getManagedForm();
+ if (mform != null) {
+ if (page instanceof AbstractGeronimoFormPage) {
+ AbstractGeronimoFormPage geronimoPage = (AbstractGeronimoFormPage)page;
+ geronimoPage.refresh();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void pageChange(int newPageIndex) {
+ if (isDirty()) {
+ IFormPage[] pages = getPages();
+ IFormPage active = getActivePageInstance();
+ int curr = getCurrentPage();
+ if (getCurrentPage() == newPageIndex) {
+ return;
+ }
+ // if the old or the new page are the source page, don't allow the page change
+ if (newPageIndex == pages.length || getCurrentPage() == pages.length) {
+ setActivePage(curr);
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.savePageTitle, Messages.savePageMessage);
+ return;
+ }
+ }
+ super.pageChange(newPageIndex);
+ }
- abstract public JAXBElement loadDeploymentPlan(IFile file);
- abstract public void saveDeploymentPlan(IFile file) throws IOException, JAXBException;
+ abstract public JAXBElement loadDeploymentPlan(IFile file);
+ abstract public void saveDeploymentPlan(IFile file) throws IOException, JAXBException;
}
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties?rev=718691&r1=718690&r2=718691&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties Tue Nov 18 11:45:11 2008
@@ -406,4 +406,4 @@
plugin=Plugin
savePageTitle=Save Resource
-savePageMessage=Please save the page before proceeding to the Source page.
+savePageMessage=Data must be saved before entering or leaving the Source page.
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/AbstractGeronimoFormPage.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/AbstractGeronimoFormPage.java?rev=718691&r1=718690&r2=718691&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/AbstractGeronimoFormPage.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/AbstractGeronimoFormPage.java Tue Nov 18 11:45:11 2008
@@ -22,14 +22,13 @@
import org.apache.geronimo.st.core.descriptor.AbstractDeploymentDescriptor;
import org.apache.geronimo.st.ui.Activator;
import org.apache.geronimo.st.ui.editors.AbstractGeronimoDeploymentPlanEditor;
-import org.apache.geronimo.st.ui.internal.Messages;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
@@ -71,6 +70,16 @@
super(id, title);
}
+ public void refresh() {
+ // clear the old composite and tool bar
+ Control[] controls = body.getChildren();
+ for (int i = 0; i < controls.length; i++) {
+ controls[i].dispose();
+ }
+ getManagedForm().getForm().getToolBarManager().removeAll();
+ createFormContent(getManagedForm());
+ }
+
/*
* (non-Javadoc)
*
@@ -166,15 +175,4 @@
public String getFormTitle() {
return getTitle();
}
-
- // Do not allow the user to go to the source page if data has not been saved.
- @Override
- public boolean canLeaveThePage() {
- if (getEditor().isDirty() &&
- getEditor().getActivePageInstance() == getEditor().findPage(Messages.editorTabSource)) {
- MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.savePageTitle, Messages.savePageMessage);
- return false;
- }
- return true;
- }
}
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java?rev=718691&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java Tue Nov 18 11:45:11 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.ui.pages;
+
+import org.apache.geronimo.st.ui.editors.AbstractGeronimoDeploymentPlanEditor;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DeploymentPlanSourcePage extends StructuredTextEditor {
+
+ protected AbstractGeronimoDeploymentPlanEditor editor;
+
+ public DeploymentPlanSourcePage (AbstractGeronimoDeploymentPlanEditor editor) {
+ super();
+ this.editor = editor;
+ }
+
+ @Override
+ public void doSave(IProgressMonitor progressMonitor) {
+ super.doSave(progressMonitor);
+ editor.reloadDeploymentPlan();
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/pages/DeploymentPlanSourcePage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain