You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2006/11/22 17:50:31 UTC
svn commit: r478232 [12/22] - in
/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima:
taeconfigurator/ taeconfigurator/editors/ taeconfigurator/editors/ui/
taeconfigurator/editors/ui/dialogs/ taeconfigurator/editors/xml/ tae...
Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PrimitiveSection.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PrimitiveSection.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PrimitiveSection.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PrimitiveSection.java Wed Nov 22 08:50:24 2006
@@ -41,187 +41,184 @@
import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.ui.forms.IManagedForm;
-
-
/**
* This class is misnamed - refers really to Runtime Information
- *
+ *
*/
public class PrimitiveSection extends AbstractSection {
-
- public void enable(){}
-
- private Label implNameLabel;
- private Text implName;
- private Button findButton;
- private Button multipleDeploymentAllowed;
- private Button modifiesCas;
+
+ public void enable() {
+ }
+
+ private Label implNameLabel;
+
+ private Text implName;
+
+ private Button findButton;
+
+ private Button multipleDeploymentAllowed;
+
+ private Button modifiesCas;
+
private Button outputsNewCASes;
- /**
- * Creates a section with a text field for the name of the annotator.
- * Only enabled if annotator is primitive
- * Also has the operational parameters
- */
- public PrimitiveSection(MultiPageEditor editor, Composite parent) {
- super(editor, parent, "Runtime Information",
- "This section describes information about how to run this component");
- }
-
- public void initialize(IManagedForm form) {
- super.initialize(form);
-
- Composite sectionClient = new2ColumnComposite(getSection());
- enableBorders(sectionClient);
-
- modifiesCas = newCheckBox(sectionClient, "updates the CAS",
- "check this if this component updates the CAS");
+ /**
+ * Creates a section with a text field for the name of the annotator. Only enabled if annotator is
+ * primitive Also has the operational parameters
+ */
+ public PrimitiveSection(MultiPageEditor editor, Composite parent) {
+ super(editor, parent, "Runtime Information",
+ "This section describes information about how to run this component");
+ }
+
+ public void initialize(IManagedForm form) {
+ super.initialize(form);
+
+ Composite sectionClient = new2ColumnComposite(getSection());
+ enableBorders(sectionClient);
+
+ modifiesCas = newCheckBox(sectionClient, "updates the CAS",
+ "check this if this component updates the CAS");
spacer(sectionClient);
if (isAeDescriptor() || isCasConsumerDescriptor() || isFlowControllerDescriptor()) {
- multipleDeploymentAllowed = newCheckBox(
- sectionClient,
- "multiple deployment allowed",
- "check this to allow multiple instances of this engine to be deployed that can run in parallel");
+ multipleDeploymentAllowed = newCheckBox(sectionClient, "multiple deployment allowed",
+ "check this to allow multiple instances of this engine to be deployed that can run in parallel");
spacer(sectionClient);
}
if (isAeDescriptor()) {
outputsNewCASes = newCheckBox(sectionClient, "Outputs new CASes",
- "check this for primitive components that output new CASes, "
- + "or for aggregates which contain a CAS Multiplier, "
- + "where the new CASes are returned out of the aggregate.");
+ "check this for primitive components that output new CASes, "
+ + "or for aggregates which contain a CAS Multiplier, "
+ + "where the new CASes are returned out of the aggregate.");
spacer(sectionClient);
}
-
- implNameLabel = newLabelWithData(sectionClient, "");
- implName = newTextWithTip(sectionClient, "", "");
-
- spacer(sectionClient); // skip first column
-
- findButton = newPushButton(sectionClient, "Browse", "", true, SWT.RIGHT);
- // next line makes the browse button just big enough for the text,
- // otherwise it's very long...
- findButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-
- toolkit.paintBordersFor(sectionClient);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.forms.IFormPart#refresh()
- */
+
+ implNameLabel = newLabelWithData(sectionClient, "");
+ implName = newTextWithTip(sectionClient, "", "");
+
+ spacer(sectionClient); // skip first column
+
+ findButton = newPushButton(sectionClient, "Browse", "", true, SWT.RIGHT);
+ // next line makes the browse button just big enough for the text,
+ // otherwise it's very long...
+ findButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+
+ toolkit.paintBordersFor(sectionClient);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.forms.IFormPart#refresh()
+ */
public void refresh() {
super.refresh();
- //set description for enter field (either .class or .dll file)
+ // set description for enter field (either .class or .dll file)
String implKind = editor.getAeDescription().getFrameworkImplementation();
- if ("TAF".equals(implKind) || "org.apache.uima.cpp".equals(implKind)) {
- implNameLabel.setText("Name of the .dll file");
- implName.setToolTipText("Enter the name of the .dll file here.");
- findButton.setToolTipText("Browse the file system for the .dll file.");
- } else {
- implNameLabel.setText("Name of the Java class file");
- implName.setToolTipText("Enter the name of the Java class that implements this component.");
- findButton.setToolTipText("Browse for the Java class that implmenets this component.");
- }
-
- if (isPrimitive()) {
- setEnabled(true);
-
- //AnnotatorImplementationName may be null
- //due to change from aggregate to primitive
- String modelImplName = editor.getAeDescription().getAnnotatorImplementationName();
- implName.setText(convertNull(modelImplName));
+ if ("TAF".equals(implKind) || "org.apache.uima.cpp".equals(implKind)) {
+ implNameLabel.setText("Name of the .dll file");
+ implName.setToolTipText("Enter the name of the .dll file here.");
+ findButton.setToolTipText("Browse the file system for the .dll file.");
+ } else {
+ implNameLabel.setText("Name of the Java class file");
+ implName.setToolTipText("Enter the name of the Java class that implements this component.");
+ findButton.setToolTipText("Browse for the Java class that implmenets this component.");
+ }
+
+ if (isPrimitive()) {
+ setEnabled(true);
+
+ // AnnotatorImplementationName may be null
+ // due to change from aggregate to primitive
+ String modelImplName = editor.getAeDescription().getAnnotatorImplementationName();
+ implName.setText(convertNull(modelImplName));
this.getSection().layout();
- } else {
- implName.setText("");
- setEnabled(false);
- }
- OperationalProperties ops = getOperationalProperties();
+ } else {
+ implName.setText("");
+ setEnabled(false);
+ }
+ OperationalProperties ops = getOperationalProperties();
if (null != ops) {
- setButtonSelection(modifiesCas, ops.getModifiesCas());
+ setButtonSelection(modifiesCas, ops.getModifiesCas());
setButtonSelection(multipleDeploymentAllowed, ops.isMultipleDeploymentAllowed());
setButtonSelection(outputsNewCASes, ops.getOutputsNewCASes());
- }
- else {
+ } else {
setButtonSelection(modifiesCas, true);
setButtonSelection(multipleDeploymentAllowed, false);
setButtonSelection(outputsNewCASes, false);
}
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
- */
- public void handleEvent(Event event) {
- valueChanged = false;
- OperationalProperties ops = getOperationalProperties();
- if (event.widget == findButton) {
- String className = null;
- try {
- String implKind = editor.getAeDescription().getFrameworkImplementation();
- if ("TAF".equals(implKind) || "org.apache.uima.cpp".equals(implKind)) {
- FileDialog dialog = new FileDialog(getSection().getShell(),
- SWT.NONE);
- String[] extensions = { "*.dll" };
- dialog.setFilterExtensions(extensions);
- String sStartDir = Platform.getLocation().toString();
- dialog.setFilterPath(sStartDir);
- className = dialog.open();
-
- } else {
- SelectionDialog typeDialog = JavaUI.createTypeDialog(
- getSection().getShell(), editor.getEditorSite()
- .getWorkbenchWindow(),
- editor.getSearchScopeForDescriptorType(),
- IJavaElementSearchConstants.CONSIDER_CLASSES,
- false, "*");
- typeDialog.setTitle(MessageFormat.format("Choose the {0} implementation class",
- new Object[] {editor.descriptorTypeString()}));
- typeDialog.setMessage("Filter/mask:");
- if (typeDialog.open() == Window.CANCEL)
- return;
- Object[] result = typeDialog.getResult();
- if (result != null && result.length > 0)
- className = ((IType) result[0]).getFullyQualifiedName();
- }
- if (className == null || className.equals("")) //$NON-NLS-1$
- return;
- implName.setText(className);
- editor.getAeDescription().setAnnotatorImplementationName(
- className);
- valueChanged = true;
- } catch (JavaModelException e) {
- throw new InternalErrorCDE("unexpected Exception", e);
- }
- } else if (event.widget == modifiesCas) {
- ops.setModifiesCas(
- setValueChangedBoolean(modifiesCas.getSelection(), ops.getModifiesCas()));
- } else if (event.widget == multipleDeploymentAllowed) {
- ops.setMultipleDeploymentAllowed(
- setValueChangedBoolean(multipleDeploymentAllowed.getSelection(), ops.isMultipleDeploymentAllowed()));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ public void handleEvent(Event event) {
+ valueChanged = false;
+ OperationalProperties ops = getOperationalProperties();
+ if (event.widget == findButton) {
+ String className = null;
+ try {
+ String implKind = editor.getAeDescription().getFrameworkImplementation();
+ if ("TAF".equals(implKind) || "org.apache.uima.cpp".equals(implKind)) {
+ FileDialog dialog = new FileDialog(getSection().getShell(), SWT.NONE);
+ String[] extensions = { "*.dll" };
+ dialog.setFilterExtensions(extensions);
+ String sStartDir = Platform.getLocation().toString();
+ dialog.setFilterPath(sStartDir);
+ className = dialog.open();
+
+ } else {
+ SelectionDialog typeDialog = JavaUI.createTypeDialog(getSection().getShell(), editor
+ .getEditorSite().getWorkbenchWindow(), editor
+ .getSearchScopeForDescriptorType(),
+ IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*");
+ typeDialog.setTitle(MessageFormat.format("Choose the {0} implementation class",
+ new Object[] { editor.descriptorTypeString() }));
+ typeDialog.setMessage("Filter/mask:");
+ if (typeDialog.open() == Window.CANCEL)
+ return;
+ Object[] result = typeDialog.getResult();
+ if (result != null && result.length > 0)
+ className = ((IType) result[0]).getFullyQualifiedName();
+ }
+ if (className == null || className.equals("")) //$NON-NLS-1$
+ return;
+ implName.setText(className);
+ editor.getAeDescription().setAnnotatorImplementationName(className);
+ valueChanged = true;
+ } catch (JavaModelException e) {
+ throw new InternalErrorCDE("unexpected Exception", e);
+ }
+ } else if (event.widget == modifiesCas) {
+ ops.setModifiesCas(setValueChangedBoolean(modifiesCas.getSelection(), ops.getModifiesCas()));
+ } else if (event.widget == multipleDeploymentAllowed) {
+ ops.setMultipleDeploymentAllowed(setValueChangedBoolean(multipleDeploymentAllowed
+ .getSelection(), ops.isMultipleDeploymentAllowed()));
} else if (event.widget == outputsNewCASes) {
- ops.setOutputsNewCASes(
- setValueChangedBoolean(outputsNewCASes.getSelection(), ops.getOutputsNewCASes()));
- } else if (event.widget == implName){
- editor.getAeDescription().setAnnotatorImplementationName(
- setValueChanged(implName.getText(), editor
- .getAeDescription()
- .getAnnotatorImplementationName()));
- }
- if (valueChanged)
- editor.setFileDirty();
- }
-
- /**
- * @param enabled
- * indicator for the section to be enabled.
- */
- public void setEnabled(boolean enabled) {
- implNameLabel.setEnabled(enabled);
- implName.setEnabled(enabled);
+ ops.setOutputsNewCASes(setValueChangedBoolean(outputsNewCASes.getSelection(), ops
+ .getOutputsNewCASes()));
+ } else if (event.widget == implName) {
+ editor.getAeDescription().setAnnotatorImplementationName(
+ setValueChanged(implName.getText(), editor.getAeDescription()
+ .getAnnotatorImplementationName()));
+ }
+ if (valueChanged)
+ editor.setFileDirty();
+ }
+
+ /**
+ * @param enabled
+ * indicator for the section to be enabled.
+ */
+ public void setEnabled(boolean enabled) {
+ implNameLabel.setEnabled(enabled);
+ implName.setEnabled(enabled);
findButton.setEnabled(enabled);
enableCtrl(modifiesCas, true);
enableCtrl(multipleDeploymentAllowed, true);
enableCtrl(outputsNewCASes, true);
- }
+ }
}
Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PriorityListSection.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PriorityListSection.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PriorityListSection.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PriorityListSection.java Wed Nov 22 08:50:24 2006
@@ -35,226 +35,227 @@
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.forms.IManagedForm;
-
public class PriorityListSection extends AbstractSection {
-
+
public static final String PRIORITY_LIST = "<Priority List>";
-
+
private Tree tree;
+
private Button addSetButton;
+
private Button addButton;
+
private Button removeButton;
+
private Button upButton;
+
private Button downButton;
private TypePriorityImportSection typePriorityImportSection;
private Button exportButton;
-
- public PriorityListSection(MultiPageEditor editor, Composite parent) {
- super(editor, parent, "Priority Lists", "This section shows the defined Prioirity Lists");
- }
-
- public void initialize(IManagedForm form) {
- super.initialize(form);
+
+ public PriorityListSection(MultiPageEditor editor, Composite parent) {
+ super(editor, parent, "Priority Lists", "This section shows the defined Prioirity Lists");
+ }
+
+ public void initialize(IManagedForm form) {
+ super.initialize(form);
Composite sectionClient = new2ColumnComposite(getSection());
enableBorders(sectionClient);
tree = newTree(sectionClient);
-
+
final Composite buttonContainer = newButtonContainer(sectionClient);
- addSetButton = newPushButton(buttonContainer, "Add Set", "Click here to add another priority list.");
+ addSetButton = newPushButton(buttonContainer, "Add Set",
+ "Click here to add another priority list.");
addButton = newPushButton(buttonContainer, S_ADD, "Click here to add a type");
removeButton = newPushButton(buttonContainer, S_REMOVE, S_REMOVE_TIP);
new Button(buttonContainer, SWT.PUSH).setVisible(false); // spacer
- upButton = newPushButton(buttonContainer, S_UP, "Click here to move the selected item up in the priority order.");
- downButton = newPushButton(buttonContainer, S_DOWN, "Click here to move the selected item down in the priority order");
+ upButton = newPushButton(buttonContainer, S_UP,
+ "Click here to move the selected item up in the priority order.");
+ downButton = newPushButton(buttonContainer, S_DOWN,
+ "Click here to move the selected item down in the priority order");
exportButton = newPushButton(buttonContainer, S_EXPORT, S_EXPORT_TIP);
-
+
toolkit.paintBordersFor(sectionClient);
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.forms.IFormPart#refresh()
- */
- public void refresh() {
- if (null == typePriorityImportSection)
- typePriorityImportSection = editor.getIndexesPage().getTypePriorityImportSection();
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.forms.IFormPart#refresh()
+ */
+ public void refresh() {
+ if (null == typePriorityImportSection)
+ typePriorityImportSection = editor.getIndexesPage().getTypePriorityImportSection();
super.refresh();
- tree.removeAll();
-
- TypePriorities typePriorities = getTypePriorities();
-
- if(typePriorities != null) {
- TypePriorityList [] priorityLists = typePriorities.getPriorityLists();
- for(int i = 0; i < priorityLists.length; i++) {
- TreeItem item = new TreeItem(tree, SWT.NONE);
- item.setText(PRIORITY_LIST);
- String [] types = priorityLists[i].getTypes();
- if (null != types) {
- for (int j = 0; j < types.length; j++) {
- TreeItem tItem = new TreeItem(item, SWT.NONE);
- tItem.setText(formatName(types[j]));
- }
- }
- item.setExpanded(true);
- }
- }
- if (tree.getItemCount() > 0)
- tree.setSelection(new TreeItem[] {tree.getItems()[0]});
- enable();
- }
+ tree.removeAll();
+
+ TypePriorities typePriorities = getTypePriorities();
+
+ if (typePriorities != null) {
+ TypePriorityList[] priorityLists = typePriorities.getPriorityLists();
+ for (int i = 0; i < priorityLists.length; i++) {
+ TreeItem item = new TreeItem(tree, SWT.NONE);
+ item.setText(PRIORITY_LIST);
+ String[] types = priorityLists[i].getTypes();
+ if (null != types) {
+ for (int j = 0; j < types.length; j++) {
+ TreeItem tItem = new TreeItem(item, SWT.NONE);
+ tItem.setText(formatName(types[j]));
+ }
+ }
+ item.setExpanded(true);
+ }
+ }
+ if (tree.getItemCount() > 0)
+ tree.setSelection(new TreeItem[] { tree.getItems()[0] });
+ enable();
+ }
public TypePriorityList getTypePriorityListFromTreeItem(TreeItem item) {
- TypePriorityList [] typePriorityLists = getAnalysisEngineMetaData().getTypePriorities().getPriorityLists();
+ TypePriorityList[] typePriorityLists = getAnalysisEngineMetaData().getTypePriorities()
+ .getPriorityLists();
return typePriorityLists[tree.indexOf(item)];
}
- public void handleEvent(Event event) {
- if (event.widget == addSetButton) {
- TypePriorityList typePriorityList =
- UIMAFramework.getResourceSpecifierFactory().
- createTypePriorityList();
-
- TypePriorities typePriorities = getTypePriorities();
- if(typePriorities == null) {
- typePriorities = UIMAFramework.getResourceSpecifierFactory().
- createTypePriorities();
- getAnalysisEngineMetaData().setTypePriorities(typePriorities);
- }
-
- getTypePriorities().addPriorityList(typePriorityList);
-
- TreeItem item = new TreeItem(tree, SWT.NONE);
- item.setText(PRIORITY_LIST);
-
- tree.setSelection(new TreeItem[] {item});
- setFileDirty();
- }
- else if (event.widget == addButton) { // add type to set
- if (editor.isTypePriorityDescriptor() && !editor.getIsContextLoaded()) {
- Utility.popMessage("Can''t add types here",
- "Types cannot be added here, because there is no loaded context type system to pick the types from",
- MessageDialog.WARNING);
- return;
- }
- TreeItem parent = tree.getSelection()[0];
- if (null != parent.getParentItem())
- parent = parent.getParentItem();
- AddTypeToPriorityListDialog dialog = new AddTypeToPriorityListDialog(
- this,
- editor.definedTypesWithSupers.get(), // types
- getTypePriorityListFromTreeItem(parent).getTypes()); // types already in list
-
- if (dialog.open() == Window.CANCEL)
- return;
-
- TypePriorityList typePriorityList = getTypePriorityListFromTreeItem(parent);
-
- String[] newTypeNames = dialog.getSelectedTypeNames();
+ public void handleEvent(Event event) {
+ if (event.widget == addSetButton) {
+ TypePriorityList typePriorityList = UIMAFramework.getResourceSpecifierFactory()
+ .createTypePriorityList();
+
+ TypePriorities typePriorities = getTypePriorities();
+ if (typePriorities == null) {
+ typePriorities = UIMAFramework.getResourceSpecifierFactory().createTypePriorities();
+ getAnalysisEngineMetaData().setTypePriorities(typePriorities);
+ }
+
+ getTypePriorities().addPriorityList(typePriorityList);
+
+ TreeItem item = new TreeItem(tree, SWT.NONE);
+ item.setText(PRIORITY_LIST);
+
+ tree.setSelection(new TreeItem[] { item });
+ setFileDirty();
+ } else if (event.widget == addButton) { // add type to set
+ if (editor.isTypePriorityDescriptor() && !editor.getIsContextLoaded()) {
+ Utility
+ .popMessage(
+ "Can''t add types here",
+ "Types cannot be added here, because there is no loaded context type system to pick the types from",
+ MessageDialog.WARNING);
+ return;
+ }
+ TreeItem parent = tree.getSelection()[0];
+ if (null != parent.getParentItem())
+ parent = parent.getParentItem();
+ AddTypeToPriorityListDialog dialog = new AddTypeToPriorityListDialog(this,
+ editor.definedTypesWithSupers.get(), // types
+ getTypePriorityListFromTreeItem(parent).getTypes()); // types already in list
+
+ if (dialog.open() == Window.CANCEL)
+ return;
+
+ TypePriorityList typePriorityList = getTypePriorityListFromTreeItem(parent);
+
+ String[] newTypeNames = dialog.getSelectedTypeNames();
for (int i = 0; i < newTypeNames.length; i++) {
typePriorityList.addType(newTypeNames[i]);
TreeItem item = new TreeItem(parent, SWT.NONE);
item.setText(formatName(newTypeNames[i]));
}
-
+
setFileDirty();
- }
- else if (event.widget == removeButton) {
- TreeItem item = tree.getSelection()[0];
+ } else if (event.widget == removeButton) {
+ TreeItem item = tree.getSelection()[0];
TreeItem parent = item.getParentItem();
-
+
if (null == parent) { // removing a priority set
- if (Window.CANCEL == Utility.popOkCancel(
- "ConfirmRemove", "ConfirmRemoveSet", MessageDialog.WARNING))
+ if (Window.CANCEL == Utility.popOkCancel("ConfirmRemove", "ConfirmRemoveSet",
+ MessageDialog.WARNING))
return;
TypePriorityList removedTypePriorityList = getTypePriorityListFromTreeItem(item);
- TypePriorityList [] oldPriorityLists = getAnalysisEngineMetaData().
- getTypePriorities().getPriorityLists();
- TypePriorityList [] newPriorityLists = new TypePriorityList[oldPriorityLists.length - 1];
-
- for(int i = 0, j = 0; i < oldPriorityLists.length; i++) {
- if(oldPriorityLists[i] != removedTypePriorityList) {
- newPriorityLists[j++] = oldPriorityLists[i];
- }
- }
-
- getAnalysisEngineMetaData().
- getTypePriorities().setPriorityLists(newPriorityLists);
-
+ TypePriorityList[] oldPriorityLists = getAnalysisEngineMetaData().getTypePriorities()
+ .getPriorityLists();
+ TypePriorityList[] newPriorityLists = new TypePriorityList[oldPriorityLists.length - 1];
+
+ for (int i = 0, j = 0; i < oldPriorityLists.length; i++) {
+ if (oldPriorityLists[i] != removedTypePriorityList) {
+ newPriorityLists[j++] = oldPriorityLists[i];
+ }
+ }
+
+ getAnalysisEngineMetaData().getTypePriorities().setPriorityLists(newPriorityLists);
+
} else { // removing a type
- if (Window.CANCEL == Utility.popOkCancel(
- "ConfirmRemove", "ConfirmRemoveType", MessageDialog.WARNING))
+ if (Window.CANCEL == Utility.popOkCancel("ConfirmRemove", "ConfirmRemoveType",
+ MessageDialog.WARNING))
return;
TypePriorityList typePriorityList = getTypePriorityListFromTreeItem(parent);
typePriorityList.removeType(item.getText());
}
-
- TreeItem previousSelection = getPreviousSelection(
- parent == null ? tree.getItems() : parent.getItems(),
- item);
+
+ TreeItem previousSelection = getPreviousSelection(parent == null ? tree.getItems() : parent
+ .getItems(), item);
if (null != previousSelection)
- tree.setSelection(new TreeItem [] {previousSelection});
+ tree.setSelection(new TreeItem[] { previousSelection });
item.dispose();
setFileDirty();
}
- // only enabled for types
- else if (event.widget == downButton ||
- event.widget == upButton) {
- TreeItem item = tree.getSelection()[0];
- TreeItem parent = item.getParentItem();
- TreeItem [] items = parent.getItems();
+ // only enabled for types
+ else if (event.widget == downButton || event.widget == upButton) {
+ TreeItem item = tree.getSelection()[0];
+ TreeItem parent = item.getParentItem();
+ TreeItem[] items = parent.getItems();
int i = getItemIndex(items, item);
-
- TypePriorityList typePriorityList = getTypePriorityListFromTreeItem(parent);
- String [] types = typePriorityList.getTypes();
- String temp = types[i];
- if (event.widget == downButton) {
- types[i] = types[i+1];
- types[i+1] = temp;
- typePriorityList.setTypes(types);
-
- new TreeItem(parent, SWT.NONE, i).setText(formatName(types[i]));
- TreeItem t = new TreeItem(parent, SWT.NONE, i+1);
- t.setText(formatName(types[i+1]));
- tree.setSelection(new TreeItem [] {t});
-
- items[i].dispose();
- items[i+1].dispose();
- } else {
- types[i] = types[i-1];
- types[i-1] = temp;
- typePriorityList.setTypes(types);
-
- TreeItem t = new TreeItem(parent, SWT.NONE, i-1);
- t.setText(formatName(types[i-1]));
- tree.setSelection(new TreeItem [] {t});
- new TreeItem(parent, SWT.NONE, i).setText(formatName(types[i]));
-
- items[i-1].dispose();
- items[i].dispose();
- setFileDirty();
- }
- TypePriorityList [] tpl = getTypePriorities().getPriorityLists();
+
+ TypePriorityList typePriorityList = getTypePriorityListFromTreeItem(parent);
+ String[] types = typePriorityList.getTypes();
+ String temp = types[i];
+ if (event.widget == downButton) {
+ types[i] = types[i + 1];
+ types[i + 1] = temp;
+ typePriorityList.setTypes(types);
+
+ new TreeItem(parent, SWT.NONE, i).setText(formatName(types[i]));
+ TreeItem t = new TreeItem(parent, SWT.NONE, i + 1);
+ t.setText(formatName(types[i + 1]));
+ tree.setSelection(new TreeItem[] { t });
+
+ items[i].dispose();
+ items[i + 1].dispose();
+ } else {
+ types[i] = types[i - 1];
+ types[i - 1] = temp;
+ typePriorityList.setTypes(types);
+
+ TreeItem t = new TreeItem(parent, SWT.NONE, i - 1);
+ t.setText(formatName(types[i - 1]));
+ tree.setSelection(new TreeItem[] { t });
+ new TreeItem(parent, SWT.NONE, i).setText(formatName(types[i]));
+
+ items[i - 1].dispose();
+ items[i].dispose();
+ setFileDirty();
+ }
+ TypePriorityList[] tpl = getTypePriorities().getPriorityLists();
tpl[tree.indexOf(parent)] = typePriorityList;
getTypePriorities().setPriorityLists(tpl);
- }
- else if (event.widget == exportButton) {
- typePriorityImportSection.exportImportablePart(
- "<typePriorities>", TypePrioritiesNewWizard.TYPEPRIORITIES_TEMPLATE);
+ } else if (event.widget == exportButton) {
+ typePriorityImportSection.exportImportablePart("<typePriorities>",
+ TypePrioritiesNewWizard.TYPEPRIORITIES_TEMPLATE);
refresh();
}
- enable();
- }
-
- public void enable() {
-
+ enable();
+ }
+
+ public void enable() {
+
if (tree.getSelectionCount() == 1) {
- addButton.setEnabled(true);
+ addButton.setEnabled(true);
TreeItem item = tree.getSelection()[0];
removeButton.setEnabled(true);
if (null != item.getParentItem()) {
@@ -264,7 +265,7 @@
downButton.setEnabled(i < (items.length - 1));
}
} else {
- addButton.setEnabled(false);
+ addButton.setEnabled(false);
removeButton.setEnabled(false);
upButton.setEnabled(false);
downButton.setEnabled(false);
Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourceDependencySection.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourceDependencySection.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourceDependencySection.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourceDependencySection.java Wed Nov 22 08:50:24 2006
@@ -44,25 +44,29 @@
import org.eclipse.ui.forms.IManagedForm;
/**
- * Declaration of primitive external resource dependencies A 4 col table:
- * bound/unbound, keys, opt flag, and interface name
+ * Declaration of primitive external resource dependencies A 4 col table: bound/unbound, keys, opt
+ * flag, and interface name
*/
public class ResourceDependencySection extends AbstractSection {
public final static int KEY_COL = 2;
+
public final static int OPT_COL = 1;
-
+
private final static String BOUND = "Bound";
public Table table; // accessed by inner class
private Button addButton;
+
private Button editButton;
+
private Button removeButton;
public ResourceDependencySection(MultiPageEditor editor, Composite parent) {
- super(editor, parent, "Resource Dependencies", "Primitives declare what resources they need. A primitive can only bind to one external resource.");
+ super(editor, parent, "Resource Dependencies",
+ "Primitives declare what resources they need. A primitive can only bind to one external resource.");
}
public void initialize(IManagedForm form) {
@@ -95,16 +99,15 @@
}
public void refresh() {
- super.refresh();
+ super.refresh();
table.getParent().setRedraw(false);
table.removeAll();
if (isPrimitive())
addPrimitiveToGUI("", editor.getAeDescription());
else { // is aggregate
- for (Iterator it = editor.getResolvedDelegates().entrySet()
- .iterator(); it.hasNext();) {
+ for (Iterator it = editor.getResolvedDelegates().entrySet().iterator(); it.hasNext();) {
Map.Entry item = (Map.Entry) it.next();
- addDelegateToGUI("", (String)item.getKey(), (ResourceSpecifier)item.getValue());
+ addDelegateToGUI("", (String) item.getKey(), (ResourceSpecifier) item.getValue());
}
FlowControllerDeclaration fcd = editor.getResolvedFlowControllerDeclaration();
if (null != fcd) {
@@ -116,29 +119,28 @@
}
private void addDelegateToGUI(String keys, String newKey, ResourceSpecifier o) {
- if (o instanceof AnalysisEngineDescription) {
- AnalysisEngineDescription aeDescription = (AnalysisEngineDescription) o;
- if (aeDescription.isPrimitive())
- addPrimitiveToGUI(keys + newKey + "/", aeDescription);
- else {
- for (Iterator it = editor.getDelegateAEdescriptions(
- aeDescription).entrySet().iterator(); it.hasNext();) {
- Map.Entry item = (Map.Entry) it.next();
- addDelegateToGUI(keys + newKey + "/",
- (String)item.getKey(), (ResourceSpecifier)item.getValue());
- }
- FlowControllerDeclaration fcd = getFlowControllerDeclaration();
- if (null != fcd) {
- addPrimitiveToGUI(keys + fcd.getKey() + "/",
- ((ResourceCreationSpecifier)editor.getResolvedFlowControllerDeclaration().getSpecifier()));
- }
- }
+ if (o instanceof AnalysisEngineDescription) {
+ AnalysisEngineDescription aeDescription = (AnalysisEngineDescription) o;
+ if (aeDescription.isPrimitive())
+ addPrimitiveToGUI(keys + newKey + "/", aeDescription);
+ else {
+ for (Iterator it = editor.getDelegateAEdescriptions(aeDescription).entrySet().iterator(); it
+ .hasNext();) {
+ Map.Entry item = (Map.Entry) it.next();
+ addDelegateToGUI(keys + newKey + "/", (String) item.getKey(), (ResourceSpecifier) item
+ .getValue());
+ }
+ FlowControllerDeclaration fcd = getFlowControllerDeclaration();
+ if (null != fcd) {
+ addPrimitiveToGUI(keys + fcd.getKey() + "/", ((ResourceCreationSpecifier) editor
+ .getResolvedFlowControllerDeclaration().getSpecifier()));
}
+ }
}
+ }
private void addPrimitiveToGUI(String keys, ResourceCreationSpecifier aeDescription) {
- ExternalResourceDependency[] xrd = aeDescription
- .getExternalResourceDependencies();
+ ExternalResourceDependency[] xrd = aeDescription.getExternalResourceDependencies();
if (null != xrd) {
for (int i = 0; i < xrd.length; i++) {
addXrdToGUI(keys, xrd[i]);
@@ -146,8 +148,7 @@
}
}
- private void updateXrdToGUI(TableItem item, ExternalResourceDependency xrd,
- String keys) {
+ private void updateXrdToGUI(TableItem item, ExternalResourceDependency xrd, String keys) {
String key = keys + xrd.getKey();
item.setText(0, isBound(key) ? BOUND : "");
item.setText(KEY_COL, key);
@@ -157,7 +158,8 @@
}
private boolean isBound(String key) {
- ExternalResourceBinding[] xrb = editor.getResolvedExternalResourcesAndBindings().getExternalResourceBindings();
+ ExternalResourceBinding[] xrb = editor.getResolvedExternalResourcesAndBindings()
+ .getExternalResourceBindings();
if (null != xrb)
for (int i = 0; i < xrb.length; i++) {
if (key.equals(xrb[i].getKey()))
@@ -171,12 +173,13 @@
if (null != xrb)
for (int i = 0; i < xrb.length; i++) {
if (oldKey.equals(xrb[i].getKey())) {
- xrb[i].setKey(newKey);
- editor.getResourcesPage().getResourceBindingsSection().markStale();
- return; // only 1 binding at most
+ xrb[i].setKey(newKey);
+ editor.getResourcesPage().getResourceBindingsSection().markStale();
+ return; // only 1 binding at most
}
}
}
+
/**
*
* @param keys
@@ -197,14 +200,14 @@
if (event.widget == addButton) {
handleAdd();
} else if (event.widget == removeButton
- || (event.type == SWT.KeyUp && event.character == SWT.DEL)) {
+ || (event.type == SWT.KeyUp && event.character == SWT.DEL)) {
handleRemove();
} else if (event.widget == editButton || event.type == SWT.MouseDoubleClick) {
handleEdit();
}
- // else if (event.type == SWT.MouseDown && event.button == 3) {
- // handleTableContextMenuRequest(event);
- // }
+ // else if (event.type == SWT.MouseDown && event.button == 3) {
+ // handleTableContextMenuRequest(event);
+ // }
else if (event.type == SWT.MouseHover) {
handleTableHoverHelp(event);
} else if (event.type == SWT.Selection) {
@@ -214,13 +217,13 @@
}
public ExternalResourceDependency getXRDependencyFromTableItem(TableItem item) {
- return (ExternalResourceDependency) item.getData();
+ return (ExternalResourceDependency) item.getData();
}
-
- //*****************************************************
- //* When hovering over an item in the table, show the
- //* description
- //*****************************************************
+
+ // *****************************************************
+ // * When hovering over an item in the table, show the
+ // * description
+ // *****************************************************
private void handleTableHoverHelp(Event event) {
TableItem item = table.getItem(new Point(event.x, event.y));
if (null != item) {
@@ -234,8 +237,7 @@
private void handleEdit() {
TableItem item = table.getSelection()[0];
ExternalResourceDependency xrd = getXRDependencyFromTableItem(item);
- AddExternalResourceDependencyDialog dialog = new AddExternalResourceDependencyDialog(
- this, xrd);
+ AddExternalResourceDependencyDialog dialog = new AddExternalResourceDependencyDialog(this, xrd);
if (dialog.open() == Window.CANCEL)
return;
@@ -256,11 +258,11 @@
private void handleRemove() {
TableItem item = table.getSelection()[0];
editor.getAeDescription().setExternalResourceDependencies(
- (ExternalResourceDependency [])Utility.removeElementFromArray(
- getExternalResourceDependencies(),
- getXRDependencyFromTableItem(item),
- ExternalResourceDependency.class));
-
+ (ExternalResourceDependency[]) Utility.removeElementFromArray(
+ getExternalResourceDependencies(),
+ getXRDependencyFromTableItem(item),
+ ExternalResourceDependency.class));
+
table.setSelection(table.getSelectionIndices()[0] - 1);
item.dispose();
finishAction();
@@ -268,11 +270,10 @@
/**
* add a external resource dependency to the model
- *
+ *
*/
private void handleAdd() {
- AddExternalResourceDependencyDialog dialog = new AddExternalResourceDependencyDialog(
- this);
+ AddExternalResourceDependencyDialog dialog = new AddExternalResourceDependencyDialog(this);
if (dialog.open() == Window.CANCEL)
return;
@@ -281,17 +282,15 @@
addXrdToGUI("", xrd);
}
- private void alterExistingExternalResourceDependency(
- ExternalResourceDependency xrd, AddExternalResourceDependencyDialog dialog) {
+ private void alterExistingExternalResourceDependency(ExternalResourceDependency xrd,
+ AddExternalResourceDependencyDialog dialog) {
valueChanged = false;
String oldKey = xrd.getKey();
xrd.setKey(setValueChanged(dialog.keyName, xrd.getKey()));
if (valueChanged)
- propagateKeyChange(dialog.keyName, oldKey);
- xrd.setDescription(setValueChanged(multiLineFix(dialog.description), xrd
- .getDescription()));
- xrd.setInterfaceName(setValueChanged(dialog.interfaceName, xrd
- .getInterfaceName()));
+ propagateKeyChange(dialog.keyName, oldKey);
+ xrd.setDescription(setValueChanged(multiLineFix(dialog.description), xrd.getDescription()));
+ xrd.setInterfaceName(setValueChanged(dialog.interfaceName, xrd.getInterfaceName()));
if (dialog.optional != xrd.isOptional()) {
xrd.setOptional(dialog.optional);
valueChanged = true;
@@ -301,7 +300,7 @@
}
private ExternalResourceDependency addNewExternalResourceDependency(
- AddExternalResourceDependencyDialog dialog) {
+ AddExternalResourceDependencyDialog dialog) {
ExternalResourceDependency[] xrds = getExternalResourceDependencies();
ExternalResourceDependency xrd = new ExternalResourceDependency_impl();
@@ -309,7 +308,7 @@
if (null == xrds)
editor.getAeDescription().setExternalResourceDependencies(
- new ExternalResourceDependency[] { xrd });
+ new ExternalResourceDependency[] { xrd });
else {
ExternalResourceDependency[] newXrds = new ExternalResourceDependency[xrds.length + 1];
System.arraycopy(xrds, 0, newXrds, 0, xrds.length);
@@ -338,9 +337,14 @@
if (null != xrds) {
for (int i = 0; i < xrds.length; i++) {
if (key.equals(xrds[i].getKey())) {
- Utility.popMessage("Key Already Defined",
- MessageFormat.format("The key name you specified, ''{0}'', is already defined. Please pick a different key name.",
- new String [] {key}), MessageDialog.ERROR);
+ Utility
+ .popMessage(
+ "Key Already Defined",
+ MessageFormat
+ .format(
+ "The key name you specified, ''{0}'', is already defined. Please pick a different key name.",
+ new String[] { key }),
+ MessageDialog.ERROR);
return true;
}
Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourcesPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourcesPage.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourcesPage.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourcesPage.java Wed Nov 22 08:50:24 2006
@@ -24,37 +24,40 @@
import org.eclipse.ui.forms.IManagedForm;
public class ResourcesPage extends HeaderPageWithSash {
-
+
private ResourceDependencySection resourceDependencySection;
-// private ExternalResourceSection externalResourceSection;
+
+ // private ExternalResourceSection externalResourceSection;
private ExtnlResBindSection extnlResBindSection;
+
private ImportResBindSection resBindImportSection;
-
- public ResourcesPage(MultiPageEditor editor) {
- super(editor, "Resource Definitions and Bindings");
- }
-
- /**
- * Called by the framework to fill in the contents
- */
- protected void createFormContent(IManagedForm managedForm) {
-
+
+ public ResourcesPage(MultiPageEditor editor) {
+ super(editor, "Resource Definitions and Bindings");
+ }
+
+ /**
+ * Called by the framework to fill in the contents
+ */
+ protected void createFormContent(IManagedForm managedForm) {
+
// Only primitive engines can declare Resource Dependencies
- // Both Primitive and aggregates can delcare External Resources and their bindings
- // Bindings always refer to a primitive, if needed via
- // annotatorkey / key / key ... / declaredDependencyName
- // Bindings for same dependencyName at multiple levels:
- // outer ones override inner ones.
-
- managedForm.getForm().setText("Resources");
- Form2Panel form2panel = setup2ColumnLayout(managedForm, 50, 50);
-
- managedForm.addPart(extnlResBindSection = new ExtnlResBindSection(editor, form2panel.left));
- managedForm.addPart(resBindImportSection = new ImportResBindSection(editor, form2panel.left));
- managedForm.addPart(resourceDependencySection = new ResourceDependencySection(editor, form2panel.right));
- createToolBarActions(managedForm);
- }
-
+ // Both Primitive and aggregates can delcare External Resources and their bindings
+ // Bindings always refer to a primitive, if needed via
+ // annotatorkey / key / key ... / declaredDependencyName
+ // Bindings for same dependencyName at multiple levels:
+ // outer ones override inner ones.
+
+ managedForm.getForm().setText("Resources");
+ Form2Panel form2panel = setup2ColumnLayout(managedForm, 50, 50);
+
+ managedForm.addPart(extnlResBindSection = new ExtnlResBindSection(editor, form2panel.left));
+ managedForm.addPart(resBindImportSection = new ImportResBindSection(editor, form2panel.left));
+ managedForm.addPart(resourceDependencySection = new ResourceDependencySection(editor,
+ form2panel.right));
+ createToolBarActions(managedForm);
+ }
+
public ResourceDependencySection getResourceDependencySection() {
return resourceDependencySection;
}
Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SettingsPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SettingsPage.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SettingsPage.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SettingsPage.java Wed Nov 22 08:50:24 2006
@@ -25,40 +25,40 @@
public class SettingsPage extends HeaderPageWithSash {
- private ParameterSettingsSection parameterSettingsSection;
- private ValueSection valueSection;
+ private ParameterSettingsSection parameterSettingsSection;
- public SettingsPage(MultiPageEditor editor) {
- super(editor, "Parameter Value Settings");
- }
-
- /**
- * Called by the framework to fill in the contents
- */
- protected void createFormContent(IManagedForm managedForm) {
-
- final Form2Panel form2Panel = setup2ColumnLayout(managedForm, EQUAL_WIDTH);
-
- managedForm.getForm().setText("Parameter Settings");
- managedForm.addPart(parameterSettingsSection =
- new ParameterSettingsSection(editor, form2Panel.left));
- managedForm.addPart(valueSection =
- new ValueSection(editor, form2Panel.right));
- createToolBarActions(managedForm);
- }
-
- /**
- * @return
- */
- public ParameterSettingsSection getParameterSettingsSection() {
- return parameterSettingsSection;
- }
-
- /**
- * @return
- */
- public ValueSection getValueSection() {
- return valueSection;
- }
+ private ValueSection valueSection;
+
+ public SettingsPage(MultiPageEditor editor) {
+ super(editor, "Parameter Value Settings");
+ }
+
+ /**
+ * Called by the framework to fill in the contents
+ */
+ protected void createFormContent(IManagedForm managedForm) {
+
+ final Form2Panel form2Panel = setup2ColumnLayout(managedForm, EQUAL_WIDTH);
+
+ managedForm.getForm().setText("Parameter Settings");
+ managedForm.addPart(parameterSettingsSection = new ParameterSettingsSection(editor,
+ form2Panel.left));
+ managedForm.addPart(valueSection = new ValueSection(editor, form2Panel.right));
+ createToolBarActions(managedForm);
+ }
+
+ /**
+ * @return
+ */
+ public ParameterSettingsSection getParameterSettingsSection() {
+ return parameterSettingsSection;
+ }
+
+ /**
+ * @return
+ */
+ public ValueSection getValueSection() {
+ return valueSection;
+ }
}
Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java Wed Nov 22 08:50:24 2006
@@ -49,217 +49,225 @@
public class SofaMapSection extends AbstractSection {
- private Composite sectionClient;
-
- private Button addButton;
- private Button editButton;
- private Button removeButton;
-
- private Tree tree;
-
- private static final String INPUTS = "Inputs";
- private static final String OUTPUTS = "Outputs";
+ private Composite sectionClient;
+
+ private Button addButton;
+
+ private Button editButton;
+
+ private Button removeButton;
+
+ private Tree tree;
+
+ private static final String INPUTS = "Inputs";
+
+ private static final String OUTPUTS = "Outputs";
+
private static final boolean INPUT = true;
+
private static final boolean OUTPUT = false;
- private static final String titleMsg = "This section shows all defined Sofas for an Aggregate and their mappings to the component Sofas.\n" +
- "Add Aggregate Sofa Names using the Capabilities section; Select an Aggregate Sofa Name and Add/Edit mappings for that Sofa in this section.\n";
-
- public SofaMapSection(MultiPageEditor aEditor, Composite parent) {
- super(aEditor, parent, "Sofa Mappings (Only used in aggregate Descriptors)",
- titleMsg);
- }
-
- /* Called by the page constructor after all sections are created, to initialize them.
- * (non-Javadoc)
+
+ private static final String titleMsg = "This section shows all defined Sofas for an Aggregate and their mappings to the component Sofas.\n"
+ + "Add Aggregate Sofa Names using the Capabilities section; Select an Aggregate Sofa Name and Add/Edit mappings for that Sofa in this section.\n";
+
+ public SofaMapSection(MultiPageEditor aEditor, Composite parent) {
+ super(aEditor, parent, "Sofa Mappings (Only used in aggregate Descriptors)", titleMsg);
+ }
+
+ /*
+ * Called by the page constructor after all sections are created, to initialize them.
+ * (non-Javadoc)
+ *
* @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
- */
- public void initialize(IManagedForm form) {
-
- super.initialize(form);
- sectionClient = new2ColumnComposite(getSection());
+ */
+ public void initialize(IManagedForm form) {
+
+ super.initialize(form);
+ sectionClient = new2ColumnComposite(getSection());
tree = newTree(sectionClient);
Composite buttonContainer = newButtonContainer(sectionClient);
- addButton = newPushButton(buttonContainer, S_ADD, "Click here to add a component Sofa binding.");
- editButton = newPushButton(buttonContainer, S_EDIT, S_EDIT_TIP);
+ addButton = newPushButton(buttonContainer, S_ADD, "Click here to add a component Sofa binding.");
+ editButton = newPushButton(buttonContainer, S_EDIT, S_EDIT_TIP);
removeButton = newPushButton(buttonContainer, S_REMOVE, S_REMOVE_TIP);
-
+
tree.addListener(SWT.MouseDoubleClick, this); // edit gesture
-
- enableBorders(sectionClient);
- toolkit.paintBordersFor(sectionClient);
- if (!isAggregate())
- getSection().setExpanded(false);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.IFormPart#refresh()
- */
- public void refresh() {
- super.refresh();
- tree.removeAll();
- if (!isAggregate()) {
- getSection().setText("Sofa Mappings (Only used in aggregate Descriptors)");
- getSection().setDescription("This part is only used for Aggregate Descriptors");
- getSection().setExpanded(false);
+
+ enableBorders(sectionClient);
+ toolkit.paintBordersFor(sectionClient);
+ if (!isAggregate())
+ getSection().setExpanded(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.forms.IFormPart#refresh()
+ */
+ public void refresh() {
+ super.refresh();
+ tree.removeAll();
+ if (!isAggregate()) {
+ getSection().setText("Sofa Mappings (Only used in aggregate Descriptors)");
+ getSection().setDescription("This part is only used for Aggregate Descriptors");
+ getSection().setExpanded(false);
} else {
- getSection().setDescription(titleMsg);
+ getSection().setDescription(titleMsg);
- String [] [] sns = getCapabilitySofaNames();
- String [] inputSofaNames = sns[0];
- String [] outputSofaNames = sns[1];
+ String[][] sns = getCapabilitySofaNames();
+ String[] inputSofaNames = sns[0];
+ String[] outputSofaNames = sns[1];
// getAggrSofas the names declared in the capability
- // plus any undeclared names in the mappings
+ // plus any undeclared names in the mappings
// sorted... alphabetically
- String [] inputAggrSofas = getAggrSofas(inputSofaNames, outputSofaNames);
-
+ String[] inputAggrSofas = getAggrSofas(inputSofaNames, outputSofaNames);
+
fillMap(inputAggrSofas, INPUT);
fillMap(outputSofaNames, OUTPUT);
- tree.setSelection(new TreeItem[] {tree.getItems()[0]});
-
+ tree.setSelection(new TreeItem[] { tree.getItems()[0] });
+
if (0 == (inputAggrSofas.length + outputSofaNames.length)) {
- getSection().setText("Sofa Mappings (No Sofas are defined)");
- getSection().setExpanded(false);
+ getSection().setText("Sofa Mappings (No Sofas are defined)");
+ getSection().setExpanded(false);
} else {
- getSection().setText("Sofa Mappings");
- getSection().setExpanded(true);
+ getSection().setText("Sofa Mappings");
+ getSection().setExpanded(true);
+ }
+
+ }
+ enable();
+ }
+
+ private String[] getAggrSofas(String[] inputCapabilityNames, String[] outputCapabilityNames) {
+ SofaMapping[] allMappings = getSofaMappings();
+ Set names = new TreeSet();
+ Set undeclaredNames = new TreeSet();
+ if (null != inputCapabilityNames)
+ for (int i = 0; i < inputCapabilityNames.length; i++)
+ names.add(inputCapabilityNames[i]);
+ if (null != allMappings) {
+ for (int i = 0; i < allMappings.length; i++) {
+ String sofaName = allMappings[i].getAggregateSofaName();
+ if (0 > Arrays.binarySearch(inputCapabilityNames, sofaName)
+ && 0 > Arrays.binarySearch(outputCapabilityNames, sofaName))
+ undeclaredNames.add(sofaName);
}
-
}
- enable();
- }
- private String [] getAggrSofas(
- String [] inputCapabilityNames,
- String [] outputCapabilityNames) {
- SofaMapping [] allMappings = getSofaMappings();
- Set names = new TreeSet();
- Set undeclaredNames = new TreeSet();
- if (null != inputCapabilityNames)
- for (int i = 0; i < inputCapabilityNames.length; i++)
- names.add(inputCapabilityNames[i]);
- if (null != allMappings) {
- for (int i = 0; i < allMappings.length; i++) {
- String sofaName = allMappings[i].getAggregateSofaName();
- if (0 > Arrays.binarySearch(inputCapabilityNames, sofaName) &&
- 0 > Arrays.binarySearch(outputCapabilityNames, sofaName))
- undeclaredNames.add(sofaName);
- }
- }
-
- // It is an error to have a mapping without having the aggregate name
- // declared as either an input our output. If the name is not
- // declared, (silently) consider it to have been an input.
- if (undeclaredNames.size() > 0)
- names.addAll(undeclaredNames);
-
- return (String []) names.toArray(stringArray0);
- }
-
-
- private void fillMap(String [] aggrKeys, boolean isInput) {
-
+ // It is an error to have a mapping without having the aggregate name
+ // declared as either an input our output. If the name is not
+ // declared, (silently) consider it to have been an input.
+ if (undeclaredNames.size() > 0)
+ names.addAll(undeclaredNames);
+
+ return (String[]) names.toArray(stringArray0);
+ }
+
+ private void fillMap(String[] aggrKeys, boolean isInput) {
+
TreeItem d = new TreeItem(tree, SWT.NONE);
- d.setText(isInput? INPUTS : OUTPUTS);
+ d.setText(isInput ? INPUTS : OUTPUTS);
for (int i = 0; i < aggrKeys.length; i++) {
- TreeItem a = new TreeItem(d, SWT.NONE);
- a.setText(aggrKeys[i]);
- fillBindings(a, aggrKeys[i]);
- a.setExpanded(true);
+ TreeItem a = new TreeItem(d, SWT.NONE);
+ a.setText(aggrKeys[i]);
+ fillBindings(a, aggrKeys[i]);
+ a.setExpanded(true);
}
d.setExpanded(true);
- }
-
+ }
+
private void fillBindings(TreeItem parent, String aggrSofa) {
- // bindings are a string of key-name / sofa-name or "<default>"
- String [] bindings = getSofaBindingsForAggrSofa(aggrSofa);
- for (int j = 0; j < bindings.length; j++) {
- TreeItem b = new TreeItem(parent, SWT.NONE);
- b.setText(bindings[j]);
- }
- }
- private String [] getSofaBindingsForAggrSofa(String aggrSofa) {
- SofaMapping [] sofaMappings = getSofaMappings();
- if (null == sofaMappings) return stringArray0;
- Set bindings = new TreeSet();
- for (int i = 0; i < sofaMappings.length; i++) {
- SofaMapping sofaMapping = sofaMappings[i];
- if (sofaMapping.getAggregateSofaName().equals(aggrSofa))
- if (null != sofaMapping.getComponentSofaName() &&
- !"".equals(sofaMapping.getComponentSofaName()))
- bindings.add(sofaMapping.getComponentKey() + '/' +
- sofaMapping.getComponentSofaName());
- else
- bindings.add(sofaMapping.getComponentKey());
- }
- String[] results = (String [])bindings.toArray(stringArray0);
- Arrays.sort(results);
- return results;
- }
-
-
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
- */
- public void handleEvent(Event event) {
- // Note: to add aggrSofa names, use capabilitySection.
- // Updates there are propagated here.
-
- // only enabled when one existing AggrSofa
- // or its child is selected
- if (event.widget == editButton ||
- event.type == SWT.MouseDoubleClick) {
- if (!editButton.getEnabled())
- return;
- // Edit a map: a new aggr capability + a delegate sofa, or
- // a delegate sofa to an existing map.
- TreeItem selected = tree.getSelection()[0];
- TreeItem parent = selected.getParentItem();
- if (null != parent.getParentItem()) {
- selected = parent;
- }
- editAggrMap(selected);
- } else if (event.widget == addButton ) {
- // Add one or more new mappings
- TreeItem selected = tree.getSelection()[0];
- TreeItem parent = selected.getParentItem();
- if (null != parent.getParentItem()) {
- selected = parent;
- }
- addAggrMap(selected);
- } else if (event.widget == removeButton) {
- // only enabled for aggr or component
- TreeItem selected = tree.getSelection()[0];
- TreeItem parent = selected.getParentItem();
- if (null == parent.getParentItem())
- removeAggr(selected);
- else
- removeComponentFromAggr(selected);
- }
- enable();
- }
-
- private static final boolean AVAIL_ONLY = true;
-
- private void editAggrMap(TreeItem selected) {
- // pop up window: shows all available component mappings
- // plus current mappings for this aggrSofa
- // Available: a) not mapped
- // User selects mappings to update
- // update model: add (multiple) mappings
- // Remove all under item
- // update model.
- String aggrSofa = selected.getText();
- Map availAndBoundSofas = getAvailAndBoundSofas(aggrSofa, !AVAIL_ONLY);
- if (availAndBoundSofas.size() == 0) {
- Utility.popMessage("No available sofas",
- "Because there are no sofas in the delegates that are not already bound, no sofa mapping can be created.",
- MessageDialog.WARNING);
- return;
- }
-
- EditSofaBindingsDialog dialog = new EditSofaBindingsDialog(
- this, aggrSofa, availAndBoundSofas);
+ // bindings are a string of key-name / sofa-name or "<default>"
+ String[] bindings = getSofaBindingsForAggrSofa(aggrSofa);
+ for (int j = 0; j < bindings.length; j++) {
+ TreeItem b = new TreeItem(parent, SWT.NONE);
+ b.setText(bindings[j]);
+ }
+ }
+
+ private String[] getSofaBindingsForAggrSofa(String aggrSofa) {
+ SofaMapping[] sofaMappings = getSofaMappings();
+ if (null == sofaMappings)
+ return stringArray0;
+ Set bindings = new TreeSet();
+ for (int i = 0; i < sofaMappings.length; i++) {
+ SofaMapping sofaMapping = sofaMappings[i];
+ if (sofaMapping.getAggregateSofaName().equals(aggrSofa))
+ if (null != sofaMapping.getComponentSofaName()
+ && !"".equals(sofaMapping.getComponentSofaName()))
+ bindings.add(sofaMapping.getComponentKey() + '/' + sofaMapping.getComponentSofaName());
+ else
+ bindings.add(sofaMapping.getComponentKey());
+ }
+ String[] results = (String[]) bindings.toArray(stringArray0);
+ Arrays.sort(results);
+ return results;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ public void handleEvent(Event event) {
+ // Note: to add aggrSofa names, use capabilitySection.
+ // Updates there are propagated here.
+
+ // only enabled when one existing AggrSofa
+ // or its child is selected
+ if (event.widget == editButton || event.type == SWT.MouseDoubleClick) {
+ if (!editButton.getEnabled())
+ return;
+ // Edit a map: a new aggr capability + a delegate sofa, or
+ // a delegate sofa to an existing map.
+ TreeItem selected = tree.getSelection()[0];
+ TreeItem parent = selected.getParentItem();
+ if (null != parent.getParentItem()) {
+ selected = parent;
+ }
+ editAggrMap(selected);
+ } else if (event.widget == addButton) {
+ // Add one or more new mappings
+ TreeItem selected = tree.getSelection()[0];
+ TreeItem parent = selected.getParentItem();
+ if (null != parent.getParentItem()) {
+ selected = parent;
+ }
+ addAggrMap(selected);
+ } else if (event.widget == removeButton) {
+ // only enabled for aggr or component
+ TreeItem selected = tree.getSelection()[0];
+ TreeItem parent = selected.getParentItem();
+ if (null == parent.getParentItem())
+ removeAggr(selected);
+ else
+ removeComponentFromAggr(selected);
+ }
+ enable();
+ }
+
+ private static final boolean AVAIL_ONLY = true;
+
+ private void editAggrMap(TreeItem selected) {
+ // pop up window: shows all available component mappings
+ // plus current mappings for this aggrSofa
+ // Available: a) not mapped
+ // User selects mappings to update
+ // update model: add (multiple) mappings
+ // Remove all under item
+ // update model.
+ String aggrSofa = selected.getText();
+ Map availAndBoundSofas = getAvailAndBoundSofas(aggrSofa, !AVAIL_ONLY);
+ if (availAndBoundSofas.size() == 0) {
+ Utility
+ .popMessage(
+ "No available sofas",
+ "Because there are no sofas in the delegates that are not already bound, no sofa mapping can be created.",
+ MessageDialog.WARNING);
+ return;
+ }
+
+ EditSofaBindingsDialog dialog = new EditSofaBindingsDialog(this, aggrSofa, availAndBoundSofas);
if (dialog.open() == Window.CANCEL)
return;
removeAggr(aggrSofa);
@@ -268,24 +276,25 @@
fillBindings(selected, aggrSofa);
selected.setExpanded(true);
setFileDirty();
- }
-
- private void addAggrMap(TreeItem selected) {
- // pop up window: shows all available component mappings
- // minus current mappings for this aggrSofa
- // Available: a) not mapped,
- // User selects mappings to add
- String aggrSofa = selected.getText();
- Map availAndBoundSofas = getAvailAndBoundSofas(aggrSofa, AVAIL_ONLY);
- if (availAndBoundSofas.size() == 0) {
- Utility.popMessage("No available sofas",
- "Because there are no sofas in the delegates that are not already bound, no sofa mapping can be created.",
- MessageDialog.WARNING);
- return;
- }
-
- EditSofaBindingsDialog dialog = new EditSofaBindingsDialog(
- this, aggrSofa, availAndBoundSofas);
+ }
+
+ private void addAggrMap(TreeItem selected) {
+ // pop up window: shows all available component mappings
+ // minus current mappings for this aggrSofa
+ // Available: a) not mapped,
+ // User selects mappings to add
+ String aggrSofa = selected.getText();
+ Map availAndBoundSofas = getAvailAndBoundSofas(aggrSofa, AVAIL_ONLY);
+ if (availAndBoundSofas.size() == 0) {
+ Utility
+ .popMessage(
+ "No available sofas",
+ "Because there are no sofas in the delegates that are not already bound, no sofa mapping can be created.",
+ MessageDialog.WARNING);
+ return;
+ }
+
+ EditSofaBindingsDialog dialog = new EditSofaBindingsDialog(this, aggrSofa, availAndBoundSofas);
if (dialog.open() == Window.CANCEL)
return;
addAggr(aggrSofa, dialog.selectedSofaNames);
@@ -293,18 +302,14 @@
fillBindings(selected, aggrSofa);
selected.setExpanded(true);
setFileDirty();
- }
+ }
- private void addSofasToAllComponentSofaMap (
- Map allComponentSofas,
- String key,
- ResourceSpecifier delegate,
- boolean isInput) {
+ private void addSofasToAllComponentSofaMap(Map allComponentSofas, String key,
+ ResourceSpecifier delegate, boolean isInput) {
// delegates can be AnalysisEngines, CasConsmers, flowControllers, or remotes
- if (delegate instanceof AnalysisEngineDescription ||
- delegate instanceof CasConsumerDescription ||
- delegate instanceof FlowControllerDescription) {
- Set [] inAndOut = getCapabilitySofaNames((ResourceCreationSpecifier)delegate, key);
+ if (delegate instanceof AnalysisEngineDescription || delegate instanceof CasConsumerDescription
+ || delegate instanceof FlowControllerDescription) {
+ Set[] inAndOut = getCapabilitySofaNames((ResourceCreationSpecifier) delegate, key);
Set inOut = inAndOut[isInput ? 0 : 1];
if (!isInput) { // Aggr "output" can be mapped to delegate "input"
inOut.addAll(inAndOut[0]);
@@ -319,204 +324,199 @@
}
}
}
+
/**
*
* @param aggrSofa
* @return a Map, keys = component/sofaname, value = aggrsofa or null
*/
- private Map getAvailAndBoundSofas(String aggrSofa, boolean availOnly) {
- boolean isInput = isInput(aggrSofa);
- Map allComponentSofas = new TreeMap(); // key = component/sofa, value = AggrSofa bound to
-
- // put all delegate component/sofa items in a Map
- for (Iterator it = editor.getResolvedDelegates().entrySet().iterator();
- it.hasNext();) {
- Map.Entry entry = (Map.Entry)it.next();
- addSofasToAllComponentSofaMap(
- allComponentSofas, (String)entry.getKey(), (ResourceSpecifier) entry.getValue(), isInput);
- }
- // pick up any sofa info from flow controller
+ private Map getAvailAndBoundSofas(String aggrSofa, boolean availOnly) {
+ boolean isInput = isInput(aggrSofa);
+ Map allComponentSofas = new TreeMap(); // key = component/sofa, value = AggrSofa bound to
+
+ // put all delegate component/sofa items in a Map
+ for (Iterator it = editor.getResolvedDelegates().entrySet().iterator(); it.hasNext();) {
+ Map.Entry entry = (Map.Entry) it.next();
+ addSofasToAllComponentSofaMap(allComponentSofas, (String) entry.getKey(),
+ (ResourceSpecifier) entry.getValue(), isInput);
+ }
+ // pick up any sofa info from flow controller
FlowControllerDeclaration fcd = editor.getResolvedFlowControllerDeclaration();
if (null != fcd) {
- addSofasToAllComponentSofaMap(
- allComponentSofas, fcd.getKey(), fcd.getSpecifier(), isInput);
+ addSofasToAllComponentSofaMap(allComponentSofas, fcd.getKey(), fcd.getSpecifier(), isInput);
}
-
- // mark the bound ones with a value which is the aggr sofa they're bound to
- // also, add any that were not spec'd in the delegates (because
- // for instance, they were remote)
- SofaMapping [] sofaMappings = getSofaMappings();
+
+ // mark the bound ones with a value which is the aggr sofa they're bound to
+ // also, add any that were not spec'd in the delegates (because
+ // for instance, they were remote)
+ SofaMapping[] sofaMappings = getSofaMappings();
for (int i = 0; i < sofaMappings.length; i++) {
- SofaMapping sm = sofaMappings[i];
- String key = sm.getComponentKey();
- if (null != sm.getComponentSofaName())
- key = key + '/' + sm.getComponentSofaName();
- if (availOnly)
- allComponentSofas.remove(key);
- else
- allComponentSofas.put(key, sm.getAggregateSofaName());
+ SofaMapping sm = sofaMappings[i];
+ String key = sm.getComponentKey();
+ if (null != sm.getComponentSofaName())
+ key = key + '/' + sm.getComponentSofaName();
+ if (availOnly)
+ allComponentSofas.remove(key);
+ else
+ allComponentSofas.put(key, sm.getAggregateSofaName());
}
-
- //remove all that are bound to other Aggr sofa names
+
+ // remove all that are bound to other Aggr sofa names
// because although an Aggr sofa can be bound to many delegate sofas,
// a delegate sofa can only be bound to one aggr one.
-
+
for (Iterator i3 = allComponentSofas.entrySet().iterator(); i3.hasNext();) {
- Map.Entry entry = (Map.Entry)i3.next();
- String boundAggrSofa = (String)entry.getValue();
- if (null != boundAggrSofa && !boundAggrSofa.equals(aggrSofa))
- i3.remove();
+ Map.Entry entry = (Map.Entry) i3.next();
+ String boundAggrSofa = (String) entry.getValue();
+ if (null != boundAggrSofa && !boundAggrSofa.equals(aggrSofa))
+ i3.remove();
}
-
+
return allComponentSofas;
- }
-
- private boolean isInput(String sofaName) {
- String [] [] sns = getCapabilitySofaNames();
- for (int i = 0; i < sns[0].length; i++) {
- if (sofaName.equals(sns[0][i]))
- return true;
- }
- return false;
- }
-
- private void addAggr(String aggrSofa, String [] sofaNames) {
- SofaMapping [] newSofas = new SofaMapping[sofaNames.length];
- for (int i = 0; i < sofaNames.length; i++) {
- newSofas[i] = UIMAFramework.getResourceSpecifierFactory().createSofaMapping();
- newSofas[i].setAggregateSofaName(aggrSofa);
- newSofas[i].setComponentKey(getComponentOnly(sofaNames[i]));
- newSofas[i].setComponentSofaName(getSofaOnly(sofaNames[i]));
- }
- SofaMapping [] oldSofas = getSofaMappings();
- SofaMapping [] result = new SofaMapping[oldSofas.length + newSofas.length];
- System.arraycopy(oldSofas, 0, result, 0, oldSofas.length);
- System.arraycopy(newSofas, 0, result, oldSofas.length, newSofas.length);
- editor.getAeDescription().setSofaMappings(result);
- }
-
- private void removeAggr(String aggrSofa) {
- Comparator comparator = new Comparator() {
- public int compare(Object AggrSofaName, Object o2) {
- SofaMapping sofaMapping = (SofaMapping) o2;
- if (sofaMapping.getAggregateSofaName().equals((String)AggrSofaName))
- return 0;
- else
- return -1;
- } };
- editor.getAeDescription().setSofaMappings(
- (SofaMapping []) Utility.removeElementsFromArray(
- getSofaMappings(),
- aggrSofa,
- SofaMapping.class,
- comparator));
- }
-
- private void removeAggr(TreeItem selected) {
- if (Window.CANCEL == Utility.popOkCancel(
- "Confirm delete of sofa mappings",
- "Please confirm deletion of all sofa mappings for this Aggregate Sofa name. Note this will not delete the Sofa name. To do that, remove the name from the Component Capabilities panel (the other panel on this page).",
- MessageDialog.WARNING))
- return;
- removeAggr(selected.getText());
- removeChildren(selected);
- setFileDirty();
- }
-
- /**
- * Removes a delegate map from a particular aggr sofa mapping.
- * @param selected
- */
- private void removeComponentFromAggr(TreeItem selected) {
- final String aggrName = selected.getParentItem().getText();
- Comparator comparator = new Comparator() {
- public int compare(Object componentAndSofa, Object o2) {
- SofaMapping sofaMapping = (SofaMapping)o2;
- if (!sofaMapping.getAggregateSofaName().equals(aggrName))
- return -1;
- String component = getComponentOnly((String)componentAndSofa);
- if (!sofaMapping.getComponentKey().equals(component))
- return -1;
- String sofa = getSofaOnly((String)componentAndSofa);
- if (null == sofa || sofa.equals(""))
- if (null == sofaMapping.getComponentSofaName() ||
- "".equals(sofaMapping.getComponentSofaName()))
- return 0;
- else return -1;
- else if (sofa.equals(sofaMapping.getComponentSofaName()))
- return 0;
- else return -1;
- } };
-
- editor.getAeDescription().setSofaMappings(
- (SofaMapping [])Utility.removeElementsFromArray(
- getSofaMappings(),
- selected.getText(),
- SofaMapping.class,
- comparator));
- selected.dispose();
+ }
+
+ private boolean isInput(String sofaName) {
+ String[][] sns = getCapabilitySofaNames();
+ for (int i = 0; i < sns[0].length; i++) {
+ if (sofaName.equals(sns[0][i]))
+ return true;
+ }
+ return false;
+ }
+
+ private void addAggr(String aggrSofa, String[] sofaNames) {
+ SofaMapping[] newSofas = new SofaMapping[sofaNames.length];
+ for (int i = 0; i < sofaNames.length; i++) {
+ newSofas[i] = UIMAFramework.getResourceSpecifierFactory().createSofaMapping();
+ newSofas[i].setAggregateSofaName(aggrSofa);
+ newSofas[i].setComponentKey(getComponentOnly(sofaNames[i]));
+ newSofas[i].setComponentSofaName(getSofaOnly(sofaNames[i]));
+ }
+ SofaMapping[] oldSofas = getSofaMappings();
+ SofaMapping[] result = new SofaMapping[oldSofas.length + newSofas.length];
+ System.arraycopy(oldSofas, 0, result, 0, oldSofas.length);
+ System.arraycopy(newSofas, 0, result, oldSofas.length, newSofas.length);
+ editor.getAeDescription().setSofaMappings(result);
+ }
+
+ private void removeAggr(String aggrSofa) {
+ Comparator comparator = new Comparator() {
+ public int compare(Object aggrSofaName, Object o2) {
+ SofaMapping sofaMapping = (SofaMapping) o2;
+ if (sofaMapping.getAggregateSofaName().equals(aggrSofaName))
+ return 0;
+ else
+ return -1;
+ }
+ };
+ editor.getAeDescription().setSofaMappings(
+ (SofaMapping[]) Utility.removeElementsFromArray(getSofaMappings(), aggrSofa,
+ SofaMapping.class, comparator));
+ }
+
+ private void removeAggr(TreeItem selected) {
+ if (Window.CANCEL == Utility
+ .popOkCancel(
+ "Confirm delete of sofa mappings",
+ "Please confirm deletion of all sofa mappings for this Aggregate Sofa name. Note this will not delete the Sofa name. To do that, remove the name from the Component Capabilities panel (the other panel on this page).",
+ MessageDialog.WARNING))
+ return;
+ removeAggr(selected.getText());
+ removeChildren(selected);
setFileDirty();
}
-
+
+ /**
+ * Removes a delegate map from a particular aggr sofa mapping.
+ *
+ * @param selected
+ */
+ private void removeComponentFromAggr(TreeItem selected) {
+ final String aggrName = selected.getParentItem().getText();
+ Comparator comparator = new Comparator() {
+ public int compare(Object componentAndSofa, Object o2) {
+ SofaMapping sofaMapping = (SofaMapping) o2;
+ if (!sofaMapping.getAggregateSofaName().equals(aggrName))
+ return -1;
+ String component = getComponentOnly((String) componentAndSofa);
+ if (!sofaMapping.getComponentKey().equals(component))
+ return -1;
+ String sofa = getSofaOnly((String) componentAndSofa);
+ if (null == sofa || sofa.equals(""))
+ if (null == sofaMapping.getComponentSofaName()
+ || "".equals(sofaMapping.getComponentSofaName()))
+ return 0;
+ else
+ return -1;
+ else if (sofa.equals(sofaMapping.getComponentSofaName()))
+ return 0;
+ else
+ return -1;
+ }
+ };
+
+ editor.getAeDescription().setSofaMappings(
+ (SofaMapping[]) Utility.removeElementsFromArray(getSofaMappings(), selected
+ .getText(), SofaMapping.class, comparator));
+ selected.dispose();
+ setFileDirty();
+ }
+
/**
- * Called when removing a delegate from the aggr.
- * Removes from the sofaMappings, any and all mappings associated with
- * the delegate.
+ * Called when removing a delegate from the aggr. Removes from the sofaMappings, any and all
+ * mappings associated with the delegate.
+ *
* @param componentSofa
*/
- public static void removeSofaMappings(
- String componentKey, ResourceSpecifier delegate, MultiPageEditor pEditor) {
- if (delegate instanceof AnalysisEngineDescription ||
- delegate instanceof CasConsumerDescription) {
- Set [] inOut = getCapabilitySofaNames((ResourceCreationSpecifier)delegate, componentKey);
- inOut[0].addAll(inOut[1]);
- final Set allDelegateComponentSofas = inOut[0];
- Comparator comparator = new Comparator() {
- public int compare(Object ignore, Object elementOfArray) {
- SofaMapping sofaMapping = (SofaMapping)elementOfArray;
- String key = sofaMapping.getComponentKey();
- if (null != sofaMapping.getComponentSofaName())
- key = key + '/' + sofaMapping.getComponentSofaName();
- if (allDelegateComponentSofas.contains(key)) {
- return 0;
- }
- return -1;
- } };
-
- pEditor.getAeDescription().setSofaMappings(
- (SofaMapping [])Utility.removeElementsFromArray(
- getSofaMappings(pEditor),
- null,
- SofaMapping.class,
- comparator));
- }
- }
-
-
- private String getSofaOnly(String componentAndSofa) {
- int locOfSlash = componentAndSofa.indexOf('/');
- if (locOfSlash < 0)
- return null;
- return componentAndSofa.substring(locOfSlash + 1);
- }
-
- private String getComponentOnly(String componentAndSofa) {
- int locOfSlash = componentAndSofa.indexOf('/');
- if (locOfSlash < 0)
- return componentAndSofa;
- return componentAndSofa.substring(0, locOfSlash);
- }
-
- public void enable() {
- boolean oneSelected = tree.getSelectionCount() == 1;
- boolean topLevelSelected = false;
- if (oneSelected) {
- TreeItem selected = tree.getSelection()[0];
- topLevelSelected = (null == selected.getParentItem());
- }
- addButton.setEnabled(oneSelected && !topLevelSelected);
- editButton.setEnabled(oneSelected && !topLevelSelected);
- removeButton.setEnabled(oneSelected && !topLevelSelected);
- }
-
+ public static void removeSofaMappings(String componentKey, ResourceSpecifier delegate,
+ MultiPageEditor pEditor) {
+ if (delegate instanceof AnalysisEngineDescription || delegate instanceof CasConsumerDescription) {
+ Set[] inOut = getCapabilitySofaNames((ResourceCreationSpecifier) delegate, componentKey);
+ inOut[0].addAll(inOut[1]);
+ final Set allDelegateComponentSofas = inOut[0];
+ Comparator comparator = new Comparator() {
+ public int compare(Object ignore, Object elementOfArray) {
+ SofaMapping sofaMapping = (SofaMapping) elementOfArray;
+ String key = sofaMapping.getComponentKey();
+ if (null != sofaMapping.getComponentSofaName())
+ key = key + '/' + sofaMapping.getComponentSofaName();
+ if (allDelegateComponentSofas.contains(key)) {
+ return 0;
+ }
+ return -1;
+ }
+ };
+
+ pEditor.getAeDescription().setSofaMappings(
+ (SofaMapping[]) Utility.removeElementsFromArray(getSofaMappings(pEditor),
+ null, SofaMapping.class, comparator));
+ }
+ }
+
+ private String getSofaOnly(String componentAndSofa) {
+ int locOfSlash = componentAndSofa.indexOf('/');
+ if (locOfSlash < 0)
+ return null;
+ return componentAndSofa.substring(locOfSlash + 1);
+ }
+
+ private String getComponentOnly(String componentAndSofa) {
+ int locOfSlash = componentAndSofa.indexOf('/');
+ if (locOfSlash < 0)
+ return componentAndSofa;
+ return componentAndSofa.substring(0, locOfSlash);
+ }
+
+ public void enable() {
+ boolean oneSelected = tree.getSelectionCount() == 1;
+ boolean topLevelSelected = false;
+ if (oneSelected) {
+ TreeItem selected = tree.getSelection()[0];
+ topLevelSelected = (null == selected.getParentItem());
+ }
+ addButton.setEnabled(oneSelected && !topLevelSelected);
+ editButton.setEnabled(oneSelected && !topLevelSelected);
+ removeButton.setEnabled(oneSelected && !topLevelSelected);
+ }
+
}
Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeImportSection.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeImportSection.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeImportSection.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeImportSection.java Wed Nov 22 08:50:24 2006
@@ -36,51 +36,52 @@
/**
*/
public class TypeImportSection extends ImportSection {
-
- private TCAS savedTCAS;
- private boolean importWasRemoved;
-
- public TypeImportSection(MultiPageEditor editor, Composite parent) {
- super(editor, parent, "Imported Type Systems", "The following type systems are included as part of this one." );
- }
-
- //**************************************
- //* Code to support type import section
- //**************************************
-
- protected boolean isAppropriate(){
- if (isAggregate()) {
- getSection().setText("Not Used");
- getSection().setDescription("Types can't be imported in an Aggregate Descriptor");
- return false;
- }
+
+ private TCAS savedTCAS;
+
+ private boolean importWasRemoved;
+
+ public TypeImportSection(MultiPageEditor editor, Composite parent) {
+ super(editor, parent, "Imported Type Systems",
+ "The following type systems are included as part of this one.");
+ }
+
+ // **************************************
+ // * Code to support type import section
+ // **************************************
+
+ protected boolean isAppropriate() {
+ if (isAggregate()) {
+ getSection().setText("Not Used");
+ getSection().setDescription("Types can't be imported in an Aggregate Descriptor");
+ return false;
+ }
getSection().setText("Imported Type Systems");
getSection().setDescription("The following type systems are included as part of this one.");
return true;
- }
-
- protected String getDescriptionFromImport(String source) throws InvalidXMLException, IOException {
- TypeSystemDescription parsedImportItem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
- new XMLInputSource(source));
+ }
+
+ protected String getDescriptionFromImport(String source) throws InvalidXMLException, IOException {
+ TypeSystemDescription parsedImportItem = UIMAFramework.getXMLParser()
+ .parseTypeSystemDescription(new XMLInputSource(source));
return parsedImportItem.getDescription();
}
- protected Import [] getModelImportArray () {
+ protected Import[] getModelImportArray() {
return getTypeSystemDescription().getImports();
}
-
- protected void setModelImportArray(Import [] imports) {
+
+ protected void setModelImportArray(Import[] imports) {
savedTCAS = editor.getTCAS();
- Import [] oldImports = getTypeSystemDescription().getImports();
- importWasRemoved = (null != oldImports) &&
- (oldImports.length > imports.length);
+ Import[] oldImports = getTypeSystemDescription().getImports();
+ importWasRemoved = (null != oldImports) && (oldImports.length > imports.length);
getTypeSystemDescription().setImports(imports);
}
-
+
protected void clearModelBaseValue() {
getTypeSystemDescription().setTypes(typeDescription0);
}
-
+
protected boolean isValidImport(String title, String msg) {
TypeSystemDescription savedTSD = getMergedTypeSystemDescription();
TypeSystemDescription savedITSD = editor.getImportedTypeSystemDesription();
@@ -96,26 +97,26 @@
return false;
}
if (importWasRemoved)
- if (Window.CANCEL ==Utility.popOkCancel("May need to remove dependencies",
- "A type import is being removed. If this would removed some types or features in the" +
- " merged type system, which are referenced in the Capabilities or Indexes " +
- "section, you will need to update those sections as appropriate.",
- MessageDialog.INFORMATION)) {
+ if (Window.CANCEL == Utility
+ .popOkCancel(
+ "May need to remove dependencies",
+ "A type import is being removed. If this would removed some types or features in the"
+ + " merged type system, which are referenced in the Capabilities or Indexes "
+ + "section, you will need to update those sections as appropriate.",
+ MessageDialog.INFORMATION)) {
revertMsg(title, msg, "Cancelled by user.");
editor.setMergedTypeSystemDescription(savedTSD);
editor.setImportedTypeSystemDescription(savedITSD);
editor.descriptorTCAS.set(savedTCAS);
return false;
- }
-
- return true;
- }
+ }
+ return true;
+ }
/**
- * At this point, the basic type system description is updated.
- * and validated. Validation has updated the merged type system description,
- * and updated the TCAS.
+ * At this point, the basic type system description is updated. and validated. Validation has
+ * updated the merged type system description, and updated the TCAS.
*/
protected void finishImportChangeAction() {
@@ -123,5 +124,5 @@
editor.getTypePage().getTypeSection().refresh();
editor.addDirtyTypeName("<import>");
}
-
+
}