Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.TableEditor


if( dataManager.getCollName().equals( "system.indexes" ) )
  {
  return;
  }

final TableEditor editor = new TableEditor( table );

shell.getDisplay().asyncExec( new Runnable(){ public void run()  {//*****

Point point = new Point( x, y );
final TableItem item = table.getItem( point );
if( item == null )
  {
  return;
  }
int columnIndex = -1;
for( int i = 0; i < table.getColumnCount(); ++i )
  {
  if( item.getBounds( i ).contains( point ) )
    {
    columnIndex = i;
    break;
    }
  }
if( columnIndex == -1 || columnIndex == 0 ) //ObjectId
  {
  return;
  }

final Class clazz = getCurrentClass( item, columnIndex );
if( clazz == CodeWScope.class
|| clazz == BSONTimestamp.class
|| clazz == byte[].class
|| clazz == MinKey.class
|| clazz == MaxKey.class
  )
  {
  return;
  }

final Text text = new Text( table, SWT.NONE | SWT.BORDER );
text.setText( item.getText( columnIndex ) );
//text.selectAll();

editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.setEditor( text, item, columnIndex );

final int selectedColumn = columnIndex;
Listener textListener = new Listener(){
public void handleEvent( final Event e )
{
View Full Code Here


    item.setText(new String[] { "Attributes", "Enter attributes to search" });
    item = new TableItem(table, SWT.NONE);
    item.setText(new String[] { "Attribute values contain", "Enter attributes values to search for" });
    col1.pack();
    col2.pack();
    final TableEditor editor = new TableEditor(table);
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    editor.minimumWidth = 50;
    // editing the second column
    final int EDITABLECOLUMN = 1;
    table.setHeaderVisible(true);
    table.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        // Clean up any previous editor control
        Control oldEditor = editor.getEditor();
        if (oldEditor != null)
          oldEditor.dispose();

        // 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(table, SWT.NONE);
        newEditor.setText(item.getText(EDITABLECOLUMN));
        newEditor.addModifyListener(new ModifyListener() {
          public void modifyText(ModifyEvent me) {
            Text text = (Text) editor.getEditor();
            editor.getItem().setText(EDITABLECOLUMN, text.getText());
          }
        });
        newEditor.selectAll();
        newEditor.setFocus();
        editor.setEditor(newEditor, item, EDITABLECOLUMN);
      }
    });

    PShelfItem item2 = new PShelfItem(shelf, SWT.NONE);
    item2.setText("CFScript Search");
View Full Code Here

  private void createTableItems(Table table, String key, boolean editable) {

    TableItem item = new TableItem(table, SWT.NONE);
    String labelText = key;

    TableEditor foldEditor = new TableEditor(table);
    final Button foldCheckBox = new Button(table, SWT.CHECK);
    foldCheckBox.pack();
    foldEditor.minimumWidth = foldCheckBox.getSize().x;
    foldEditor.horizontalAlignment = SWT.CENTER;
    foldEditor.setEditor(foldCheckBox, item, 0);
    fCheckBoxes.put(foldCheckBox,key+".fold");
    foldCheckBox.addSelectionListener(fCheckBoxListener);

    TableEditor collapseEditor = new TableEditor(table);
    final Button initialCheckBox = new Button(table, SWT.CHECK);
    initialCheckBox.pack();
    collapseEditor.minimumWidth = initialCheckBox.getSize().x;
    collapseEditor.horizontalAlignment = SWT.CENTER;
    collapseEditor.setEditor(initialCheckBox, item, 1);
    fCheckBoxes.put(initialCheckBox,key+".collapse");
    initialCheckBox.addSelectionListener(fCheckBoxListener);

    if (editable) {
        TableEditor regionEditor = new TableEditor(table);
       
      final Text regionText = new Text(table,SWT.SINGLE);
      regionText.setText(key);
      regionText.pack();
     
      regionEditor.minimumWidth = 90;
      regionEditor.horizontalAlignment = SWT.LEFT;
      regionEditor.setEditor(regionText, item, 2);
      fTextFields.put(regionText,key+".name");
      regionText.addModifyListener(fTextFieldListener);
     
      regionText.addListener(SWT.Modify, new Listener() {
View Full Code Here

    /**
     * http://www.eclipse.org/swt/snippets/
     */
    public void handleEvent(Event event) {

        final TableEditor editor = new TableEditor(table);
        editor.horizontalAlignment = SWT.LEFT;
        editor.grabHorizontal = true;

        Rectangle clientArea = table.getClientArea();
        if (table.getSelection().length != 1) {
            return;
        }

        Rectangle bounds = table.getSelection()[0].getBounds();
        Point pt = new Point(bounds.x, bounds.y);
        int index = table.getTopIndex();
        while (index < table.getItemCount()) {
            boolean visible = false;
            final SimpleTableItem item = (SimpleTableItem) table.getItem(index);
            for (int i = 0; i < table.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {

                    final Text text = new Text(table, SWT.NONE);
                    Listener textListener = new TextListener(item, text);

                    text.addListener(SWT.FocusOut, textListener);
                    text.addListener(SWT.Traverse, textListener);
                    text.addListener(SWT.FocusOut, wizard);
                    editor.setEditor(text, item, i);
                    text.setText(item.getText(i));
                    text.selectAll();
                    text.setFocus();
                    return;
                }
View Full Code Here

        }
        layout.addColumnData(new ColumnWeightData(100,
            columnWidths[columnNames.length - 1], true));
        table.setLayout(layout);
      }
      final TableEditor editor = new TableEditor(table);
      editor.horizontalAlignment = SWT.LEFT;
      editor.grabHorizontal = true;
   
    } else {
      checkParent(table, parent);
View Full Code Here

                newEditor.setFocus();
                editor.setEditor(newEditor, item, EDITABLECOLUMN);
            }
        });

        editor = new TableEditor(table_rule);
        // The editor must have the same size as the cell and must
        // not be any smaller than 50 pixels.
        editor.horizontalAlignment = SWT.LEFT;
        editor.grabHorizontal = true;
        editor.minimumWidth = 50;
View Full Code Here

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

            public void linkExited( HyperlinkEvent e )
            {
            }
        } );
        tableEditor = new TableEditor( viewer.getTable() );
        tableEditor.horizontalAlignment = SWT.LEFT;
        tableEditor.verticalAlignment = SWT.BOTTOM;
        tableEditor.grabHorizontal = true;
        tableEditor.grabVertical = true;
View Full Code Here

        // create dn link control
        dnLink = new Hyperlink( viewer.getTable(), SWT.NONE );
        dnLink.setLayoutData( new GridData( SWT.BOTTOM, SWT.LEFT, true, true ) );
        dnLink.setText( "" );
        dnLink.setMenu( viewer.getTable().getMenu() );
        tableEditor = new TableEditor( viewer.getTable() );
        tableEditor.horizontalAlignment = SWT.LEFT;
        tableEditor.verticalAlignment = SWT.BOTTOM;
        tableEditor.grabHorizontal = true;
        tableEditor.grabVertical = true;
View Full Code Here

  private void createTableItems(Table table, String key) {

    TableItem item = new TableItem(table, SWT.NONE);
    String labelText = FoldingPlugin.getMessage(key);

    TableEditor foldEditor = new TableEditor(table);
    final Button foldCheckBox = new Button(table, SWT.CHECK);
    foldCheckBox.pack();
    foldEditor.minimumWidth = foldCheckBox.getSize().x;
    foldEditor.horizontalAlignment = SWT.CENTER;
    foldEditor.setEditor(foldCheckBox, item, 0);

    TableEditor collapseEditor = new TableEditor(table);
    final Button initialCheckBox = new Button(table, SWT.CHECK);
    initialCheckBox.pack();
    collapseEditor.minimumWidth = initialCheckBox.getSize().x;
    collapseEditor.horizontalAlignment = SWT.CENTER;
    collapseEditor.setEditor(initialCheckBox, item, 1);

    item.setText(2, labelText);

    foldCheckBox.addListener(SWT.Selection, new Listener() {
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.