item.setText(1,name);
//rule Columns
TableEditor editor = new TableEditor(Plugin.getTab2().getClientTable());
final Combo isRegEx_combo = new Combo(Plugin.getTab2().getClientTable(),SWT.READ_ONLY);
final Button button_isDownload = new Button (Plugin.getTab2().getClientTable(), SWT.CHECK);
final Button button_isUpload = new Button (Plugin.getTab2().getClientTable(), SWT.CHECK);
final Button button_isSuperSeed = new Button (Plugin.getTab2().getClientTable(), SWT.CHECK);
final Label colorLabel = new Label (Plugin.getTab2().getClientTable(),SWT.BORDER);
editor = new TableEditor(Plugin.getTab2().getClientTable());
isRegEx_combo.add("String");
isRegEx_combo.add("RegEx");
isRegEx_combo.pack ();
isRegEx_combo.setBackground(item.getBackground());
editor.grabHorizontal = true;
editor.setEditor (isRegEx_combo, item, 2);
if(isRegEx.equalsIgnoreCase("1")){
isRegEx_combo.select(1);
isRegEx_combo.clearSelection();
}else{
isRegEx_combo.select(0);
isRegEx_combo.clearSelection();
}
isRegEx_combo.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
Plugin.getTab2().getClientTable().setSelection(item_number);
String position = item.getText(0);
position = stringNumberDownOne(position);
String clientName = item.getText(1);
String[] oldRules = FileUtilities.getRules(position);
if(isRegEx_combo.getSelectionIndex() == 0){
FileUtilities.changeClientRules(position,clientName,"0",oldRules[1],oldRules[2],oldRules[3],oldRules[4]);
isRegEx_combo.clearSelection();
}else{
try{
Pattern p = Pattern.compile(item.getText(1));
Matcher m = p.matcher("Test");
m.find();
FileUtilities.changeClientRules(position,clientName,"1",oldRules[1],oldRules[2],oldRules[3],oldRules[4]);
isRegEx_combo.clearSelection();
}catch(PatternSyntaxException f){
f.printStackTrace();
String errorText = ("Java is reporting that your RegEx is incorrectly formed, please correct this. \n\n" +
"For further information and examples, check the readme at \n\n" +
"http://azcvsupdater.sourceforge.net/stuffer/readme.txt \n\n" +
"Also check http://www.regular-expressions.info for more information\n\n" +
"Java is reporting the following problem with the expression: \n"
+ f.getDescription()) + " at position " + f.getIndex() + " in the rule";
openErrorMessageBox("Error",errorText);
isRegEx_combo.select(0);
isRegEx_combo.clearSelection();
}
}
}
});
editor = new TableEditor(Plugin.getTab2().getClientTable());
button_isDownload.pack ();
button_isDownload.setBackground(item.getBackground());
editor.minimumWidth = button_isDownload.getSize ().x;
editor.horizontalAlignment = SWT.CENTER;
editor.setEditor (button_isDownload, item, 3);
if(isDownload.equalsIgnoreCase("1")){
button_isDownload.setSelection(true);
}else{
button_isDownload.setSelection(false);
}
button_isDownload.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
Plugin.getTab2().getClientTable().setSelection(item_number);
String position = item.getText(0);
position = stringNumberDownOne(position);
String clientName = item.getText(1);
String[] oldRules = FileUtilities.getRules(position);
if(button_isDownload.getSelection()){
button_isSuperSeed.setSelection(false);
FileUtilities.changeClientRules(position,clientName,oldRules[0],"1",oldRules[2],"0",oldRules[4]);
}else{
FileUtilities.changeClientRules(position,clientName,oldRules[0],"0",oldRules[2],oldRules[3],oldRules[4]);
}
}
});
// Column three is isupload
editor = new TableEditor(Plugin.getTab2().getClientTable());
//button_isUpload = new Button (Tab2.clientTable, SWT.CHECK);
button_isUpload.pack ();
button_isUpload.setBackground(item.getBackground());
editor.minimumWidth = button_isUpload.getSize ().x;
editor.horizontalAlignment = SWT.CENTER;
editor.setEditor (button_isUpload, item, 4);
if(isUpload.equalsIgnoreCase("1")){
button_isUpload.setSelection(true);
}else{
button_isUpload.setSelection(false);
}
button_isUpload.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
Plugin.getTab2().getClientTable().setSelection(item_number);
String position = item.getText(0);
position = stringNumberDownOne(position);
String clientName = item.getText(1);
String[] oldRules = FileUtilities.getRules(position);
if(button_isUpload.getSelection()){
button_isSuperSeed.setSelection(false);
FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],"1","0",oldRules[4]);
}else{
FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],"0",oldRules[3],oldRules[4]);
}
}
});
//Column four is isSuperSeed
editor = new TableEditor(Plugin.getTab2().getClientTable());
button_isSuperSeed.pack ();
button_isSuperSeed.setBackground(item.getBackground());
editor.minimumWidth = button_isSuperSeed.getSize ().x;
editor.horizontalAlignment = SWT.CENTER;
editor.setEditor (button_isSuperSeed, item, 5);
if(isSuperSeed.equalsIgnoreCase("1")){
button_isSuperSeed.setSelection(true);
}else{
button_isSuperSeed.setSelection(false);
}
button_isSuperSeed.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
Plugin.getTab2().getClientTable().setSelection(item_number);
String position = item.getText(0);
position = stringNumberDownOne(position);
String clientName = item.getText(1);
String[] oldRules = FileUtilities.getRules(position);
if(button_isSuperSeed.getSelection()){
button_isDownload.setSelection(false);
button_isUpload.setSelection(false);
FileUtilities.changeClientRules(position,clientName,oldRules[0],"0","0","1",oldRules[4]);
}else{
FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],oldRules[2],"0",oldRules[4]);
}
}
});
//Column six is color
editor = new TableEditor(Plugin.getTab2().getClientTable());
colorLabel.pack ();
colorLabel.setToolTipText("Double-click to change color");
Color temp_color = new Color(Plugin.getDisplay(),Utils.getRGB(colorString));
colorLabel.setBackground(temp_color);
temp_color.dispose();
editor.minimumWidth = 20;
editor.horizontalAlignment = SWT.CENTER;
editor.setEditor (colorLabel, item, 6);
colorLabel.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event e) {
Plugin.getTab2().getClientTable().setSelection(item_number);
}