Skip to content
Snippets Groups Projects
Commit 002780da authored by Christoph Döbber's avatar Christoph Döbber
Browse files

adapting eclipse API to AF3 mechanisms

refs 86
parent 5a20958a
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,8 @@ Bundle-SymbolicName: org.fortiss.tooling.base.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.fortiss.tooling.base.ui.ToolingBaseUIActivator
Require-Bundle: org.fortiss.tooling.base;bundle-version="1.0.0";visibility:=reexport,
org.fortiss.tooling.kernel.ui;bundle-version="1.0.0";visibility:=reexport
org.fortiss.tooling.kernel.ui;bundle-version="1.0.0";visibility:=reexport,
org.eclipse.jface.text;bundle-version="3.7.1"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: fortiss
......
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed 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.fortiss.tooling.base.ui.editor;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.editors.text.TextEditor;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.internal.editor.ModelElementEditorInput;
/**
*
* @author doebber
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public class TextEditorBase<T extends EObject> extends TextEditor {
/**
* The object shown in this editor. This is valid as soon as
* {@link #init(IEditorSite, IEditorInput)} has been called.
*/
protected T editedObject;
/** The model element handler to be used with the {@link #editedObject}. */
protected IModelElementHandler<T> handler;
/** Databinding context used for model changes. */
protected final EMFDataBindingContext dbc = new EMFDataBindingContext();
/** Returns the edited object. */
public T getEditedObject() {
return editedObject;
}
// /** {@inheritDoc} */
// @Override
// protected void doSetInput(IEditorInput input) throws CoreException {
// super.doSetInput(new ModelElementEditorInput(getEditedObject()));
// }
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
if (!(input instanceof ModelElementEditorInput)) {
throw new PartInitException("Expected input of type "
+ ModelElementEditorInput.class);
}
ModelElementEditorInput meInput = (ModelElementEditorInput) input;
editedObject = (T) meInput.getModelElement();
if (editedObject == null) {
throw new PartInitException("Missing model element!");
}
handler = (IModelElementHandler<T>) meInput.getModelElementHandler();
if (handler == null) {
throw new PartInitException("Missing model element handler!");
}
setSite(site);
setInput(input);
setPartName(handler.getName(editedObject));
setContentDescription(handler.getDescription(editedObject));
}
/** {@inheritDoc} */
@Override
public final boolean isDirty() {
return ICommandStackService.INSTANCE.isDirty(editedObject);
}
/** {@inheritDoc} */
@Override
public final void doSave(IProgressMonitor monitor) {
ICommandStackService.INSTANCE.doSave(editedObject, monitor);
}
/** {@inheritDoc} */
@Override
public final boolean isSaveAsAllowed() {
return false;
}
/** {@inheritDoc} */
@Override
public final void doSaveAs() {
// Saving is handled automatically by persistency service
}
/** {@inheritDoc} */
@Override
public void setFocus() {
// nothing to do
}
}
......@@ -22,6 +22,7 @@ Export-Package: org.fortiss.tooling.kernel.ui,
org.fortiss.tooling.kernel.ui.extension.base,
org.fortiss.tooling.kernel.ui.extension.data,
org.fortiss.tooling.kernel.ui.extension.editingsupport,
org.fortiss.tooling.kernel.ui.internal.editor,
org.fortiss.tooling.kernel.ui.listener,
org.fortiss.tooling.kernel.ui.service,
org.fortiss.tooling.kernel.ui.util
......@@ -94,8 +94,8 @@ public abstract class EditorBase<T extends EObject> extends EditorPart
throw new PartInitException("Missing model element handler!");
}
setInput(input);
setSite(site);
setInput(input);
setPartName(handler.getName(editedObject));
setContentDescription(handler.getDescription(editedObject));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment