use of org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component in project titan.EclipsePlug-ins by eclipse.
the class ComponentItemTransfer method nativeToJava.
@Override
protected Component[] nativeToJava(final TransferData transferData) {
byte[] bytes = (byte[]) super.nativeToJava(transferData);
DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
try {
int n = in.readInt();
Component[] items = new Component[n];
String componentName;
String hostName;
String hiddenBefore;
for (int i = 0; i < n; i++) {
items[i] = new Component();
final ParseTree root = new ParserRuleContext();
items[i].setRoot(root);
hiddenBefore = in.readUTF();
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
componentName = in.readUTF();
final ParseTree componentNameNode = new AddedParseTree(componentName);
items[i].setComponentName(componentNameNode);
ConfigTreeNodeUtilities.addChild(root, componentNameNode);
hiddenBefore = in.readUTF();
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(":="));
hiddenBefore = in.readUTF();
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
hostName = in.readUTF();
final ParseTree hostNameNode = new AddedParseTree(hostName);
items[i].setHostName(hostNameNode);
ConfigTreeNodeUtilities.addChild(root, hostNameNode);
}
return items;
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
return new Component[] {};
}
}
use of org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component in project titan.EclipsePlug-ins by eclipse.
the class ComponentItemTransfer method javaToNative.
@Override
protected void javaToNative(final Object object, final TransferData transferData) {
Component[] items = (Component[]) object;
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(byteOut);
byte[] bytes = null;
try {
out.writeInt(items.length);
for (int i = 0; i < items.length; i++) {
out.writeUTF(convertToString(items[i].getRoot()));
}
out.close();
bytes = byteOut.toByteArray();
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
}
if (bytes != null) {
super.javaToNative(bytes, transferData);
}
}
use of org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component in project titan.EclipsePlug-ins by eclipse.
the class ComponentsSubPage method removeSelectedComponents.
public void removeSelectedComponents() {
if (componentsTableViewer == null || componentsSectionHandler == null) {
return;
}
StructuredSelection selection = (StructuredSelection) componentsTableViewer.getSelection();
// remove the selected elements
for (Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) {
Component component = (Component) iterator.next();
if (component != null) {
ConfigTreeNodeUtilities.removeChild(componentsSectionHandler.getLastSectionRoot(), component.getRoot());
componentsSectionHandler.getComponents().remove(component);
}
}
}
use of org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component in project titan.EclipsePlug-ins by eclipse.
the class ComponentsSubPage method createNewComponent.
private Component createNewComponent() {
if (componentsSectionHandler == null) {
return null;
}
final Component newcomponent = new Component();
final ParseTree root = new ParserRuleContext();
newcomponent.setRoot(root);
final ParseTree componentName = new AddedParseTree("component_name");
final ParseTree hostName = new AddedParseTree("host_name");
newcomponent.setComponentName(componentName);
newcomponent.setHostName(hostName);
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode("\n"));
ConfigTreeNodeUtilities.addChild(root, componentName);
ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(" := "));
ConfigTreeNodeUtilities.addChild(root, hostName);
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode("\n"));
return newcomponent;
}
Aggregations