|
From: <oms...@us...> - 2007-07-20 22:01:12
|
Revision: 988
http://svn.sourceforge.net/azcvsupdater/?rev=988&view=rev
Author: omschaub
Date: 2007-07-20 15:01:13 -0700 (Fri, 20 Jul 2007)
Log Message:
-----------
changed CCombo to just a combo to see if this helps the8549863905793769376 any
Modified Paths:
--------------
trunk/omschaub/omschaub/stuffer/main/Tab2Utilities.java
Modified: trunk/omschaub/omschaub/stuffer/main/Tab2Utilities.java
===================================================================
--- trunk/omschaub/omschaub/stuffer/main/Tab2Utilities.java 2007-07-20 16:52:19 UTC (rev 987)
+++ trunk/omschaub/omschaub/stuffer/main/Tab2Utilities.java 2007-07-20 22:01:13 UTC (rev 988)
@@ -13,7 +13,7 @@
import omschaub.stuffer.utilities.ImageRepository;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
+
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
@@ -23,6 +23,7 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ColorDialog;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
@@ -34,702 +35,702 @@
import org.eclipse.swt.widgets.Text;
public class Tab2Utilities {
-
- private Shell errorShell;
-
-
- public void addNewClient(){
- final Thread addNew_thread = new Thread() {
- public void run() {
- if(Plugin.getDisplay()==null && Plugin.getDisplay().isDisposed())
- return;
- Plugin.getDisplay().asyncExec( new Runnable() {
- public void run() {
+
+ private Shell errorShell;
+
+
+ public void addNewClient(){
+ final Thread addNew_thread = new Thread() {
+ public void run() {
+ if(Plugin.getDisplay()==null && Plugin.getDisplay().isDisposed())
+ return;
+ Plugin.getDisplay().asyncExec( new Runnable() {
+ public void run() {
// Shell Initialize
-
- final Shell shell = new Shell(SWT.DIALOG_TRIM);
- if(!Plugin.getPluginInterface().getUtilities().isOSX())
- shell.setImage(ImageRepository.getImage("plus"));
-
- //Grid Layout
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- shell.setLayout(layout);
-
- //composite for shell
- Composite backup_composite = new Composite(shell,SWT.NULL);
-
- //Grid Layout
- layout = new GridLayout();
- layout.numColumns = 3;
- backup_composite.setLayout(layout);
-
- //shell title
- shell.setText("Add New Client");
-
-
- //Text Line 1
- Label nameLabel = new Label(backup_composite, SWT.NONE);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 3;
- nameLabel.setLayoutData( gridData );
- nameLabel.setText("Input Name of Client you wish to block");
-
-
+ final Shell shell = new Shell(SWT.DIALOG_TRIM);
+ if(!Plugin.getPluginInterface().getUtilities().isOSX())
+ shell.setImage(ImageRepository.getImage("plus"));
- //Input field
- final Text line1 = new Text(backup_composite,SWT.BORDER);
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 3;
- line1.setLayoutData( gridData);
-
- //Radio buttons for Normal vs RegEx
- Composite comp_buttons = new Composite(backup_composite,SWT.NULL);
- comp_buttons.setLayout(new GridLayout(3,false));
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 3;
- comp_buttons.setLayoutData(gridData);
-
- final Button choiceString = new Button(comp_buttons,SWT.RADIO);
- choiceString.setText("Simple String (simple match)");
- choiceString.setSelection(true);
-
- final Button choiceRegEx = new Button(comp_buttons,SWT.RADIO);
- choiceRegEx.setText("RegEx (complex match)");
-
-
-
- //Color Comp
- Composite color_comp = new Composite(backup_composite,SWT.NULL);
- color_comp.setLayout(new GridLayout(3,false));
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 3;
- color_comp.setLayoutData(gridData);
-
- final Label labelcolor = new Label(color_comp,SWT.BORDER);
- labelcolor.setBackground(Plugin.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- gridData = new GridData (GridData.FILL_HORIZONTAL);
- gridData.widthHint = 50;
- labelcolor.setLayoutData(gridData);
-
- final Button color_choose = new Button(color_comp,SWT.PUSH);
- color_choose.setText("Choose Color for Client");
- color_choose.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- //Choose color
- ColorDialog colorDialog1 = new ColorDialog(shell);
- colorDialog1.setText("Choose Color for Client");
- colorDialog1.setRGB(new RGB(0,0,0));
- RGB selectedColor = colorDialog1.open();
-
- if(selectedColor != null){
- Color color = new Color(Plugin.getDisplay(),
- selectedColor.red,
- selectedColor.green,
- selectedColor.blue);
- labelcolor.setBackground(color);
- color.dispose();
- }
- }
- });
-
-
-
-
-
- //Button for Accept
- Button commit = new Button(backup_composite, SWT.PUSH);
- gridData = new GridData(GridData.CENTER);
- gridData.horizontalSpan = 1;
- commit.setLayoutData( gridData);
- commit.setText( "Accept");
- commit.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
-
- if(line1.getText().equalsIgnoreCase("")){
- MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR);
- mb.setText("Error");
- mb.setMessage("Please input the client name you wish to block.");
- mb.open();
- return;
- }
- if(!choiceString.getSelection() && !choiceRegEx.getSelection()){
- MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR);
- mb.setText("Error");
- mb.setMessage("Please select whether this new client's name is a regular string or a regex expression.");
- mb.open();
- return;
- }else{
- if(choiceString.getSelection()){
- FileUtilities.writeNewClient(line1.getText(),"0","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue());
- }else{
- try{
- Pattern p = Pattern.compile(line1.getText());
- Matcher m = p.matcher("Test");
- m.find();
- }catch(PatternSyntaxException f){
- f.printStackTrace();
-
- String text = ("Java is reporting that your RegEx is incorrectly formed, please correcct 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",text);
-
-
- return;
- }
-
-
- FileUtilities.writeNewClient(line1.getText(),"1","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue());
- }
- loadClientTable(-1);
- shell.dispose();
- }
- }
- });
-
+ //Grid Layout
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ shell.setLayout(layout);
+
+ //composite for shell
+ Composite backup_composite = new Composite(shell,SWT.NULL);
+
+ //Grid Layout
+ layout = new GridLayout();
+ layout.numColumns = 3;
+ backup_composite.setLayout(layout);
+
+ //shell title
+ shell.setText("Add New Client");
+
+
+
+ //Text Line 1
+ Label nameLabel = new Label(backup_composite, SWT.NONE);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 3;
+ nameLabel.setLayoutData( gridData );
+ nameLabel.setText("Input Name of Client you wish to block");
+
+
+
+ //Input field
+ final Text line1 = new Text(backup_composite,SWT.BORDER);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 3;
+ line1.setLayoutData( gridData);
+
+ //Radio buttons for Normal vs RegEx
+ Composite comp_buttons = new Composite(backup_composite,SWT.NULL);
+ comp_buttons.setLayout(new GridLayout(3,false));
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 3;
+ comp_buttons.setLayoutData(gridData);
+
+ final Button choiceString = new Button(comp_buttons,SWT.RADIO);
+ choiceString.setText("Simple String (simple match)");
+ choiceString.setSelection(true);
+
+ final Button choiceRegEx = new Button(comp_buttons,SWT.RADIO);
+ choiceRegEx.setText("RegEx (complex match)");
+
+
+
+ //Color Comp
+ Composite color_comp = new Composite(backup_composite,SWT.NULL);
+ color_comp.setLayout(new GridLayout(3,false));
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 3;
+ color_comp.setLayoutData(gridData);
+
+ final Label labelcolor = new Label(color_comp,SWT.BORDER);
+ labelcolor.setBackground(Plugin.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ gridData = new GridData (GridData.FILL_HORIZONTAL);
+ gridData.widthHint = 50;
+ labelcolor.setLayoutData(gridData);
+
+ final Button color_choose = new Button(color_comp,SWT.PUSH);
+ color_choose.setText("Choose Color for Client");
+ color_choose.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ //Choose color
+ ColorDialog colorDialog1 = new ColorDialog(shell);
+ colorDialog1.setText("Choose Color for Client");
+ colorDialog1.setRGB(new RGB(0,0,0));
+ RGB selectedColor = colorDialog1.open();
+
+ if(selectedColor != null){
+ Color color = new Color(Plugin.getDisplay(),
+ selectedColor.red,
+ selectedColor.green,
+ selectedColor.blue);
+ labelcolor.setBackground(color);
+ color.dispose();
+ }
+ }
+ });
+
+
+
+
+
+ //Button for Accept
+ Button commit = new Button(backup_composite, SWT.PUSH);
+ gridData = new GridData(GridData.CENTER);
+ gridData.horizontalSpan = 1;
+ commit.setLayoutData( gridData);
+ commit.setText( "Accept");
+ commit.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+
+ if(line1.getText().equalsIgnoreCase("")){
+ MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR);
+ mb.setText("Error");
+ mb.setMessage("Please input the client name you wish to block.");
+ mb.open();
+ return;
+ }
+ if(!choiceString.getSelection() && !choiceRegEx.getSelection()){
+ MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR);
+ mb.setText("Error");
+ mb.setMessage("Please select whether this new client's name is a regular string or a regex expression.");
+ mb.open();
+ return;
+ }else{
+ if(choiceString.getSelection()){
+ FileUtilities.writeNewClient(line1.getText(),"0","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue());
+ }else{
+ try{
+ Pattern p = Pattern.compile(line1.getText());
+ Matcher m = p.matcher("Test");
+ m.find();
+ }catch(PatternSyntaxException f){
+ f.printStackTrace();
+
+ String text = ("Java is reporting that your RegEx is incorrectly formed, please correcct 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",text);
+
+
+ return;
+ }
+
+
+ FileUtilities.writeNewClient(line1.getText(),"1","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue());
+ }
+ loadClientTable(-1);
+ shell.dispose();
+ }
+ }
+ });
+
// Button for Cancel
- Button cancel = new Button(backup_composite, SWT.PUSH);
- gridData = new GridData(GridData.CENTER);
- gridData.horizontalSpan = 2;
- cancel.setLayoutData( gridData);
- cancel.setText( "Cancel");
- cancel.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- shell.dispose();
- }
- });
-
-
-
- line1.addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent e) {
- //Empty
- }
-
- public void keyReleased (KeyEvent e) {
- switch (e.character){
- case SWT.ESC:
-
- shell.dispose();
- break;
-
- case SWT.CR:
-
- if(line1.getText().equalsIgnoreCase("") || line1.getText().equalsIgnoreCase(" ")){
- MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR);
- mb.setText("Error");
- mb.setMessage("Please input the client name you wish to block.");
- mb.open();
- break;
- }
- if(!choiceString.getSelection() && !choiceRegEx.getSelection()){
- MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR);
- mb.setText("Error");
- mb.setMessage("Please select whether this new client's name is a regular string or a regex expression.");
- mb.open();
- break;
- }else{
- if(choiceString.getSelection()){
- FileUtilities.writeNewClient(line1.getText(),"0","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue());
- }else{
- FileUtilities.writeNewClient(line1.getText(),"1","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue());
- }
- loadClientTable(-1);
- shell.dispose();
- }
- break;
- }
- }
- });
-
- Utils.centerShellandOpen(shell);
-
- }
- });
- }
- };
- addNew_thread.run();
-
-
-
- }
-
-
-
- public void loadClientTable(final int selection){
- final Thread load_client_list_thread = new Thread() {
- public void run() {
-
- try {
- if(Plugin.getDisplay()== null && Plugin.getDisplay().isDisposed())
- return;
-
- Plugin.getDisplay().syncExec(new Runnable (){
- public void run () {
- if (Plugin.getTab2().getClientTable() != null && !Plugin.getTab2().getClientTable().isDisposed()){
- Control[] controls = Plugin.getTab2().getClientTable().getChildren();
- for(int i = 0; i < controls.length ; i++){
-
- controls[i].dispose();
- controls[i] = null;
- }
- Plugin.getTab2().getClientTable().setEnabled(true);
- Plugin.getTab2().getClientTable().removeAll();
- }
-
-
- }
- });
-
- FileUtilities.readClientList();
- Iterator it = Plugin.clientBlock_set.getIterator();
- while(it.hasNext()){
- ClientBlock cb = (ClientBlock)it.next();
- addTableElement(String.valueOf(cb.getIndex()),
- cb.getClientName(),
- (cb.get_isRegEx() ? "1" : "0"),
- (cb.get_isDownloading() ? "1" : "0"),
- (cb.get_isUploading() ? "1" : "0"),
- (cb.get_isSuperseeding() ? "1" : "0"),
- cb.getColor(),
- cb.getHitsThisSession());
- }
-
- Plugin.getDisplay().syncExec(new Runnable (){
- public void run () {
- if (Plugin.getTab2().getClientTable() !=null && !Plugin.getTab2().getClientTable().isDisposed()){
- if(selection > -1){
- Plugin.getTab2().getClientTable().setSelection(selection);
- }
- }
- }
- });
-
-
- /*String[][] clientList = FileUtilities.getClientList(true);
+ Button cancel = new Button(backup_composite, SWT.PUSH);
+ gridData = new GridData(GridData.CENTER);
+ gridData.horizontalSpan = 2;
+ cancel.setLayoutData( gridData);
+ cancel.setText( "Cancel");
+ cancel.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ shell.dispose();
+ }
+ });
- for(int i = 0 ; i < 200 ; i++) {
- if(clientList[i][0] != null){
- //add table element
- addTableElement(clientList[i][0],
- clientList[i][1],
- clientList[i][2],
- clientList[i][3],
- clientList[i][4],
- clientList[i][5],
- clientList[i][6]);
- }
-
- }*/
-
-
- } catch(Exception e) {
- //Stop process and trace the exception
- e.printStackTrace();
- }
- }
- };
- load_client_list_thread.setDaemon(true);
- load_client_list_thread.start();
-
- }
-
-
- public void addTableElement(final String number,
- final String name,
- final String isRegEx,
- final String isDownload,
- final String isUpload,
- final String isSuperSeed,
- final String colorString,
- final int hits){
- if(Plugin.getDisplay() == null || Plugin.getDisplay().isDisposed())
- return;
-
- Plugin.getDisplay().asyncExec( new Runnable() {
- public void run() {
- if(Plugin.getTab2().getClientTable() == null || Plugin.getTab2().getClientTable().isDisposed())
- return;
- final int item_number = Plugin.getTab2().getClientTable().getItemCount();
- final TableItem item = new TableItem(Plugin.getTab2().getClientTable(),SWT.NULL);
- if (Plugin.getTab2().getClientTable().getItemCount()%2==0) {
- item.setBackground(ColorUtilities.getBackgroundColor());
- }
-
- //set the initial hits
- item.setText(7, String.valueOf(hits));
-
- //column one is the number
- item.setText(0,stringNumberUpOne(number));
-
-
- // column two is the name
- item.setText(1,name);
-
-
-
- //rule Columns
- TableEditor editor = new TableEditor(Plugin.getTab2().getClientTable());
- final CCombo isRegEx_combo = new CCombo(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.setSelecti...
[truncated message content] |