Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.TableEditor


            }
        });


        //Listener to put in table editor
        final TableEditor editor = new TableEditor (clientTable);
        editor.horizontalAlignment = SWT.LEFT;
        editor.grabHorizontal = true;
        clientTable.addListener (SWT.MouseDoubleClick, new Listener () {
            public void handleEvent (Event event) {
                Rectangle clientArea = clientTable.getClientArea ();
                Point pt = new Point (event.x, event.y);
                int index = clientTable.getTopIndex ();

                while (index < clientTable.getItemCount ()) {
                    boolean visible = false;
                    final TableItem item = clientTable.getItem (index);
                    oldName = item.getText(1);
                    final String number_of_client = item.getText(0);
                    //for (int i=0; i<clientTable.getColumnCount (); i++) {
                        Rectangle rect = item.getBounds (1);
                        if (rect.contains (pt)) {
                            final int column = 1;
                            final Text text = new Text (clientTable, SWT.NONE);
                            Listener textListener = new Listener () {
                                public void handleEvent (final Event e) {
                                    switch (e.type) {
                                        case SWT.FocusOut:
                                            item.setText (column, text.getText ());
                                            newName = text.getText();

                                            if(!newName.equalsIgnoreCase(oldName)){
                                                String rules[] = FileUtilities.getRules(Plugin.getTab2Utilities().stringNumberDownOne(number_of_client));
                                                if(rules[0].equalsIgnoreCase("1")){
                                                    try{
                                                        Pattern p = Pattern.compile(newName);
                                                        Matcher m = p.matcher("Test");
                                                        m.find();
                                                        FileUtilities.changeClientName(Plugin.getTab2Utilities().stringNumberDownOne(number_of_client),newName);
                                                    }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";
                                                        Plugin.getTab2Utilities().openErrorMessageBox("Error",errorText);
                                                        item.setText(column,oldName);
                                                        text.dispose ();
                                                        e.doit = false;
                                                        break;
                                                    }
                                                }else{
                                                    FileUtilities.changeClientName(Plugin.getTab2Utilities().stringNumberDownOne(number_of_client),newName);
                                                }
                                            }
                                            text.dispose ();
                                            break;
                                        case SWT.Traverse:
                                            switch (e.detail) {
                                                case SWT.TRAVERSE_RETURN:
                                                    item.setText (column, text.getText ());
                                                    newName = text.getText();

                                                    if(!newName.equalsIgnoreCase(oldName)){
                                                        String rules[] = FileUtilities.getRules(Plugin.getTab2Utilities().stringNumberDownOne(number_of_client));
                                                        if(rules[0].equalsIgnoreCase("1")){
                                                            try{
                                                                Pattern p = Pattern.compile(newName);
                                                                Matcher m = p.matcher("Test");
                                                                m.find();
                                                                FileUtilities.changeClientName(Plugin.getTab2Utilities().stringNumberDownOne(number_of_client),newName);
                                                            }catch(PatternSyntaxException f){
                                                                f.printStackTrace();

                                                                String errorText = ("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";
                                                                Plugin.getTab2Utilities().openErrorMessageBox("Error",errorText);
                                                                item.setText(column,oldName);
                                                                text.dispose ();
                                                                e.doit = false;
                                                                break;
                                                            }
                                                        }else{
                                                            FileUtilities.changeClientName(Plugin.getTab2Utilities().stringNumberDownOne(number_of_client),newName);
                                                        }
                                                    }
                                                    //FALL THROUGH
                                                case SWT.TRAVERSE_ESCAPE:
                                                    text.dispose ();
                                                    e.doit = false;
                                            }
                                            break;
                                    }
                                }
                            };
                            text.addListener (SWT.FocusOut, textListener);
                            text.addListener (SWT.Traverse, textListener);
                            editor.setEditor (text, item, 1);
                            text.setText (item.getText (1));
                            text.selectAll ();
                            text.setFocus ();

                            return;
View Full Code Here


         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);
           }
View Full Code Here

            }
        });
       
       
        //Listener for table double clicks
        final TableEditor editor = new TableEditor (table1);
        editor.horizontalAlignment = SWT.LEFT;
        editor.grabHorizontal = true;
       
       
        table1.addListener (SWT.MouseDoubleClick, new Listener () {
View Full Code Here

        .getResourceString("page2.package.caption"));
       
        namespace2packageTable.setVisible(true);
       
        // add the table editor
        final TableEditor editor = new TableEditor(namespace2packageTable);
        editor.setColumn(1);
        editor.horizontalAlignment = SWT.LEFT;
        editor.grabHorizontal = true;
        //This is the cute way of making the namespaces columns editable
        namespace2packageTable.addListener(SWT.MouseDown, new Listener() {
            public void handleEvent(Event event) {
              Rectangle clientArea = namespace2packageTable.getClientArea();
              Point pt = new Point(event.x, event.y);
              int index = namespace2packageTable.getTopIndex();
              while (index < namespace2packageTable.getItemCount()) {
                boolean visible = false;
                final TableItem item = namespace2packageTable.getItem(index);
                for (int i = 0; i < namespace2packageTable.getColumnCount(); i++) {
                  Rectangle rect = item.getBounds(i);
                  if (rect.contains(pt)) {
                    final int column = i;
                    final Text text = new Text(namespace2packageTable, SWT.NONE);
                    Listener textListener = new Listener() {
                      public void handleEvent(final Event e) {
                        switch (e.type) {
                        case SWT.FocusOut:
                          item.setText(column, text.getText());
                          text.dispose();
                          break;
                        case SWT.Traverse:
                          switch (e.detail) {
                          case SWT.TRAVERSE_RETURN:
                            item
                                .setText(column, text
                                    .getText());
                          // FALL THROUGH
                          case SWT.TRAVERSE_ESCAPE:
                            text.dispose();
                            e.doit = false;
                          }
                          break;
                        }
                      }
                    };
                    text.addListener(SWT.FocusOut, textListener);
                    text.addListener(SWT.Traverse, textListener);
                    editor.setEditor(text, item, i);
                    text.setText(item.getText(i));
                    text.selectAll();
                    text.setFocus();
                    return;
                  }
View Full Code Here

        item.setChecked(true);
      }

      TableItem[] items = tableFields.getItems();
      for (int i = 0; i < items.length; i++) {
        final TableEditor editor = new TableEditor(tableFields);
        Text text = new Text(tableFields, SWT.NONE);
        text.setText(items[i].getText(editableColumn));
        text.addModifyListener(new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            editor.getItem().setText(editableColumn, ((Text) editor.getEditor()).getText());
          }
        });
        text.selectAll();
        text.setFocus();
        editor.grabHorizontal = true;
        editor.setEditor(text, items[i], editableColumn);

      }
      colField.pack();

      runInBackgroundButton = new Button(group, SWT.CHECK);
View Full Code Here

TOP

Related Classes of org.eclipse.swt.custom.TableEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.