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

ported property sections

refs 288
parent 3fd499a4
No related branches found
No related tags found
No related merge requests found
/*--------------------------------------------------------------------------+
$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.IModelEditor;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
/**
*
* @author doebber
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public abstract class TextEditorBase<T extends EObject> extends TextEditor
implements IModelEditor<T> {
/**
* 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. */
@Override
public T getEditedObject() {
return editedObject;
}
/** {@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
}
}
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