Commit 186ccc1c authored by Simon Barner's avatar Simon Barner
Browse files

Remove deprecated, unused class.

refs 3126
parent 4cbdd6a0
/*-------------------------------------------------------------------------+
| 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.af3.mira.ui.editor;
import static org.eclipse.jface.databinding.swt.SWTObservables.observeText;
import static org.eclipse.jface.databinding.viewers.ViewersObservables.observeSinglePostSelection;
import static org.fortiss.af3.mira.model.verification.VerificationPackage.Literals.CHECK_ITEM__CATEGORY;
import static org.fortiss.af3.mira.model.verification.VerificationPackage.Literals.CHECK_ITEM__LAST_UPDATE;
import static org.fortiss.af3.mira.model.verification.VerificationPackage.Literals.CHECK_ITEM__STATUS;
import static org.fortiss.af3.mira.ui.editor.highlight.ScannerManager.getScanner;
import static org.fortiss.af3.mira.ui.utils.HighlightUtils.createSourceViewer;
import static org.fortiss.tooling.kernel.model.FortissToolingKernelPackage.Literals.INAMED_COMMENTED_ELEMENT__COMMENT;
import static org.fortiss.tooling.kernel.model.FortissToolingKernelPackage.Literals.INAMED_ELEMENT__NAME;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.bind;
import static org.fortiss.tooling.kernel.ui.util.ObservableUtils.observeValue;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.TextStyledTextActionHandler;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.verification.CheckItem;
import org.fortiss.af3.mira.model.verification.CheckList;
import org.fortiss.af3.mira.model.verification.CheckStatus;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import org.fortiss.tooling.base.ui.editor.FormsEditorBase;
/**
* Editor for the {@link CheckList} in requirement and use case
*
* @author mou
*/
@Deprecated
public class CheckListEditor extends FormsEditorBase<Requirement> {
/** List of all Text fields on the form (needed to add {@link TextStyledTextActionHandler}) */
protected List<Text> registeredTextFields;
/**
* List of sourceViewers on the form (needed to inform on the updates of glossary and
* requirement source).
*/
private ArrayList<SourceViewer> registeredSourceViewers;
/** The {@link Analysis} which contains this {@link Requirement}. */
protected Analysis analysis;
/** {@inheritDoc} */
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
analysis = editedObject.getAnalysis();
registeredTextFields = new ArrayList<Text>();
registeredSourceViewers = new ArrayList<SourceViewer>();
createUpdateListener();
}
/** Create a listener to get informed when the glossary and requirement source changed. */
private void createUpdateListener() {
IChangeListener wordRuleUpdateListener = new IChangeListener() {
@Override
public void handleChange(ChangeEvent event) {
// refresh after changes to guarantee update of the text highlighting
registeredSourceViewers.stream().forEach(v -> v.refresh());
}
};
getScanner(analysis).getObservableWordRule().addChangeListener(wordRuleUpdateListener);
}
/** {@inheritDoc} */
@Override
protected void createSections() {
List<CheckList> allchecklist =
pickInstanceOf(CheckList.class, editedObject.getSpecifications());
for(IModelElementSpecification spec : allchecklist) {
CheckList checklist = (CheckList)spec;
Composite composite = createNewSection(checklist.getName(), checklist.getComment());
GridLayout layout = new GridLayout(5, false);
layout.horizontalSpacing = 15;
composite.setLayout(layout);
// create content of the section
for(final CheckItem item : checklist.getItems()) {
Label id = toolkit.createLabel(composite, "");
GridDataFactory.swtDefaults().minSize(25, SWT.DEFAULT).applyTo(id);
dbc.bindValue(observeText(id), observeValue(item, CHECK_ITEM__CATEGORY));
Label name = toolkit.createLabel(composite, "");
GridDataFactory.swtDefaults().minSize(100, SWT.DEFAULT).applyTo(name);
dbc.bindValue(observeText(name), observeValue(item, INAMED_ELEMENT__NAME));
final ComboViewer status = new ComboViewer(composite, SWT.DROP_DOWN);
toolkit.adapt(status.getCombo());
GridDataFactory.swtDefaults().minSize(75, SWT.DEFAULT).applyTo(status.getControl());
status.setContentProvider(new ArrayContentProvider());
status.setLabelProvider(new LabelProvider());
status.setInput(CheckStatus.values());
dbc.bindValue(observeSinglePostSelection(status),
observeValue(item, CHECK_ITEM__STATUS));
status.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if(status.getCombo().getSelectionIndex() != item.getStatus().getValue()) {
executeCommand(new Runnable() {
@Override
public void run() {
item.setLastUpdate(new Date());
}
});
}
}
});
Label date = toolkit.createLabel(composite, "");
GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).applyTo(date);
dbc.bindValue(observeText(date), observeValue(item, CHECK_ITEM__LAST_UPDATE), null,
new UpdateValueStrategy().setConverter(new DateToStringConverter(
"yyyy-MM-dd HH:mm")));
SourceViewer comment = createSourceViewer(form, composite, SWT.BORDER, analysis);
registeredSourceViewers.add(comment);
GridDataFactory.swtDefaults().minSize(300, SWT.DEFAULT).grab(true, false)
.applyTo(comment.getControl());
bind(dbc, comment.getTextWidget(), item, INAMED_COMMENTED_ELEMENT__COMMENT);
}
}
}
/** {@inheritDoc} */
@Override
protected void addTextStyledText(TextStyledTextActionHandler textStyledTextActionHandler) {
for(Text text : registeredTextFields) {
textStyledTextActionHandler.addText(text);
}
for(SourceViewer sourceViewer : registeredSourceViewers) {
textStyledTextActionHandler.addText(sourceViewer.getTextWidget());
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment