Skip to content
Snippets Groups Projects
Commit ca22b06f authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

The copy-and-paste buttons from property view were extracted in org.fortiss.tooling.base.ui.

refs 378
parent 18d56b2b
No related branches found
No related tags found
No related merge requests found
......@@ -28,4 +28,5 @@ Export-Package: org.fortiss.tooling.base.ui,
org.fortiss.tooling.base.ui.fieldassist,
org.fortiss.tooling.base.ui.layout,
org.fortiss.tooling.base.ui.preferences,
org.fortiss.tooling.base.ui.properties.view,
org.fortiss.tooling.base.ui.utils
/*--------------------------------------------------------------------------+
$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.properties.view;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import org.fortiss.tooling.kernel.ui.extension.base.PropertySectionBase;
/**
* Base class for adding copy-and-paste functionality to property sections.
*
* @author ratiu
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 3386CF920FA51BB64D0B8035BB9EB721
*/
public abstract class PropertySectionWithCopyPasteBase<T extends IModelElementSpecification>
extends PropertySectionBase implements SelectionListener {
/** Widget for clip board copy. */
protected Button clipboardCopy;
/** Widget for clip board paste. */
protected Button clipboardPaste;
/** The current edited specification. */
protected T specification;
/** Copy-paste composite. */
protected void createCopyPasteComposite() {
final Composite copyPasteComposite = getWidgetFactory()
.createComposite(composite);
copyPasteComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
clipboardCopy = getWidgetFactory().createButton(copyPasteComposite,
"copy", SWT.PUSH);
clipboardCopy.addSelectionListener(this);
clipboardPaste = getWidgetFactory().createButton(copyPasteComposite,
"paste", SWT.PUSH);
clipboardPaste.addSelectionListener(this);
clipboardPaste.setEnabled(false);
createFormEntry(copyPasteComposite, "Clipboard");
}
/** {@inheritDoc} */
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// nothing to do
}
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
if (e.widget == clipboardCopy) {
setClipboardSpec(specification);
clipboardPaste.setEnabled(false);
} else if (e.widget == clipboardPaste && getClipboardSpec() != null
&& getClipboardSpec() != specification) {
doPerformCopy();
setClipboardSpec(null);
clipboardPaste.setEnabled(false);
}
}
/** Performs the copy. */
protected abstract void doPerformCopy();
/** Sets the specification to be saved in the clipboard. */
protected abstract void setClipboardSpec(T currentSpec);
/** Returns the current specification from the clipboard. */
protected abstract T getClipboardSpec();
}
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