action_table.setLocation(0, 76);
action_table.setSize(392, 263);
action_table.setHeaderVisible(true);
action_table.setLinesVisible(true);
// Editor
actionEditor = new TableEditor(action_table);
actionEditor.horizontalAlignment = SWT.LEFT;
actionEditor.grabHorizontal = true;
actionEditor.minimumWidth = 50;
action_table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
disposeEditors("action");
// Identify the selected row
TableItem item = (TableItem) e.item;
if (item == null)
return;
// The control that will be the editor must be a child of the
// Table
Text newEditor = new Text(action_table, SWT.NONE);
newEditor.setText(item.getText(EDITABLECOLUMN));
newEditor.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent me) {
Text text = (Text) actionEditor.getEditor();
actionEditor.getItem()
.setText(EDITABLECOLUMN, text.getText());
}
});
newEditor.selectAll();
newEditor.setFocus();
actionEditor.setEditor(newEditor, item, EDITABLECOLUMN);
}
});
TableColumn tblclmnParameter_1 = new TableColumn(action_table, SWT.NONE);
tblclmnParameter_1.setWidth(161);
tblclmnParameter_1.setText("Action Parameter");
TableColumn tblclmnValue_1 = new TableColumn(action_table, SWT.NONE);
tblclmnValue_1.setWidth(226);
tblclmnValue_1.setText("Value");
Button btnSave_1 = new Button(composite_6, SWT.NONE);
btnSave_1.setBounds(33, 10, 75, 25);
btnSave_1.setText("Save");
Button btnRemove = new Button(composite_6, SWT.NONE);
btnRemove.setBounds(33, 41, 75, 25);
btnRemove.setText("Remove");
combo = new Combo(composite_6, SWT.NONE);
combo.setBounds(277, 37, 91, 29);
combo.setItems(new String[] { "output", "enqueue", "strip-vlan",
"set-vlan-id", "set-vlan-priority", "set-src-mac",
"set-dst-mac", "set-tos-bits", "set-src-ip", "set-dst-ip",
"set-src-port", "set-dst-port" });
Label lblNewAction = new Label(composite_6, SWT.NONE);
lblNewAction.setBounds(178, 41, 91, 15);
lblNewAction.setText("New Action :");
Button btnRemoveAllActions = new Button(composite_6, SWT.NONE);
btnRemoveAllActions.setBounds(176, 10, 145, 25);
btnRemoveAllActions.setText("Remove All Actions");
btnRemoveAllActions.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Remove all the actions and refresh the action tree
if(flow != null){
ActionManagerPusher.removeAllActions(flow);
populateActionTree();
}
else{
DisplayMessage.displayError(shell, "You must select a flow or create a new one before modifying actions!");
}
}
});
combo.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
disposeEditors("action");
if(flow != null)
setupAction(combo.getItem(combo.getSelectionIndex()));
else
DisplayMessage.displayError(shell, "You must select a flow or create a new one before modifying actions!");
}
});
btnRemove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Remove the action
if(flow != null){
if (currAction != null) {
ActionManagerPusher.removeAction(flow, currAction);
populateActionTree();
}
}
else{
DisplayMessage.displayError(shell,"You must select a flow or create a new one before modifying actions!");
}
}
});
btnSave_1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if(flow != null){
if (currAction != null) {
if (!action_table.getItems()[0].getText(1).isEmpty()) {
if (ActionToTable.errorChecksPassed(
currSwitch, currAction,
action_table.getItems())) {
ActionManagerPusher.addAction(
action_table.getItems(), currAction, flow);
disposeEditors("action");
populateActionTree();
}
} else {
DisplayMessage.displayError(shell, "You must enter a value before you save an action!");
}
} else {
DisplayMessage.displayError(shell, "You must create an action to save!");
}
}
else{
DisplayMessage.displayError(shell, "You must select a flow or create a new one before modifying actions!");
}
}
});
Composite composite_8 = new Composite(composite, SWT.NONE);
composite_8.setBounds(791, 89, 387, 339);
match_table = new Table(composite_8, SWT.BORDER | SWT.FULL_SELECTION);
match_table.setLocation(0, 0);
match_table.setSize(387, 339);
match_table.setHeaderVisible(true);
match_table.setLinesVisible(true);
matchEditor = new TableEditor(match_table);
matchEditor.horizontalAlignment = SWT.LEFT;
matchEditor.grabHorizontal = true;
matchEditor.minimumWidth = 50;
match_table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {