Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.TableEditor


      }
    });
    cancelButton.setBounds(458, 173, 86, 23);
    cancelButton.setText(ApplicationResources.getString("SetInitialConcepts.13")); //$NON-NLS-1$
    //
    valueEditor = new TableEditor(initialConcepts);
  }
View Full Code Here


        tableViewer.setInput(constraintList);
        tableViewer.refresh();
      }
    });

    editor = new TableEditor(table);
    // 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

   
    TableColumn wait = new TableColumn(executeCommandsTable,SWT.NULL);
    wait.setText("Wait");
    wait.setWidth(50);
   
    final TableEditor cmdEditor = new TableEditor(executeCommandsTable);
    final TableEditor typeEditor = new TableEditor(executeCommandsTable);
    final TableEditor waitEditor = new TableEditor(executeCommandsTable);
    cmdEditor.horizontalAlignment =
      typeEditor.horizontalAlignment =
        waitEditor.horizontalAlignment = SWT.LEFT;
    cmdEditor.grabHorizontal =
      typeEditor.grabHorizontal =
        waitEditor.grabHorizontal = true;
   
    Composite executeCommandsOptions = new Composite(executeCommands,SWT.NULL);
    executeCommandsOptions.setLayoutData(new GridData(SWT.CENTER,SWT.TOP,true,false));
    executeCommandsOptions.setLayout(new GridLayout(2,true));
   
    addCommand = new Button(executeCommandsOptions,SWT.PUSH);
    addCommand.setText("Add Command");
   
    delCommand = new Button(executeCommandsOptions,SWT.PUSH);
    delCommand.setText("Delete Command");
   
    executeCommandsCustomize.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event event) {
        updateExecuteCommands();
      }
    });
    addCommand.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event event) {
        TableItem item = new TableItem(executeCommandsTable,SWT.NULL);
        GOIMGameExecuteCommands cmd = new GOIMGameExecuteCommands();
        item.setData(cmd);
        item.setText(getGOIMGameExecuteCommandToString(cmd));
        executeCommandsTable.setFocus();
        executeCommandsTable.setSelection(new TableItem[] { item });
      }
    });
    delCommand.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event event) {
        TableItem[] items = executeCommandsTable.getSelection();
        if(items.length > 0) {
          items[0].dispose();
        }
      }
    });
    executeCommandsTable.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event event) {
        TableItem[] items = executeCommandsTable.getSelection();
        if(items.length < 1) return;
        final TableItem item = items[0];
        if(cmdEditor.getEditor() != null) {
          cmdEditor.getEditor().dispose();
          typeEditor.getEditor().dispose();
          waitEditor.getEditor().dispose();
        }
       
        final GOIMGameExecuteCommands cmd = (GOIMGameExecuteCommands)item.getData();
        final Text command = new Text(executeCommandsTable,SWT.NONE);
        command.setText(cmd.command);
        command.selectAll();
        command.setFocus();
       
        cmdEditor.setEditor(command, item, 0);
       
        final Combo type = new Combo(executeCommandsTable,SWT.DROP_DOWN | SWT.READ_ONLY);
        type.add(GOIMGameExecuteCommands.ExecuteCommandType.BOTH.toString());
        type.add(GOIMGameExecuteCommands.ExecuteCommandType.CONNECT.toString());
        type.add(GOIMGameExecuteCommands.ExecuteCommandType.LAUNCH.toString());
        if(cmd.commandType == GOIMGameExecuteCommands.ExecuteCommandType.BOTH) {
          type.select(0);
        } else if(cmd.commandType == GOIMGameExecuteCommands.ExecuteCommandType.CONNECT) {
          type.select(1);
        } else if(cmd.commandType == GOIMGameExecuteCommands.ExecuteCommandType.LAUNCH) {
          type.select(2);
        }
        typeEditor.setEditor(type, item, 1);
       
        final Button wait = new Button(executeCommandsTable,SWT.CHECK);
        wait.setText("Wait");
        wait.setToolTipText("Wait until command exits.");
        wait.setSelection(cmd.waitforterminate);
        waitEditor.setEditor(wait, item, 2);
       
        command.addListener(SWT.Modify,new Listener() {
          public void handleEvent(Event event) {
            cmdEditor.getItem().setText(0,command.getText());
            cmd.command = command.getText();
View Full Code Here

      TableColumn column = new TableColumn(table, SWT.NONE);
      column.setText(titles[i]);
      column.setWidth(100);
    }

    final TableEditor editor = new TableEditor(table);
    // 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;
    // editing the second column
    final int EDITABLECOLUMN = 1;

    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();
            String s = text.getText();
            editor.getItem().setText(EDITABLECOLUMN, s);
            setDirty(true);
            updateLaunchConfigurationDialog();
          }

        });
        newEditor.addModifyListener(fListener);

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

      }
    });
  }
View Full Code Here

  }

  private void addEditorToIncrementTable()
  {
    // Create an editor object to use for text editing
    final TableEditor editor = new TableEditor(incrementTable);
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;

    // Use a mouse listener, not a selection listener, since we're interested
    // in the selected column as well as row
    incrementTable.addMouseListener(new MouseAdapter()
    {
      public void mouseDown(MouseEvent event)
      {
        // Dispose any existing editor
        Control old = editor.getEditor();
        if (old != null)
          old.dispose();

        // Determine where the mouse was clicked
        Point pt = new Point(event.x, event.y);

        // Determine which row was selected
        final TableItem item = incrementTable.getItem(pt);
        if (item != null)
        {
          // Determine which column was selected
          int column = -1;
          for (int i = 0, n = incrementTable.getColumnCount(); i < n; i++)
          {
            Rectangle rect = item.getBounds(i);
            if (rect.contains(pt))
            {
              // This is the selected column
              column = i;
              break;
            }
          }

          // Column 2 holds dropdowns
          if (column == 0)
          {
            // Create the dropdown and add data to it
            final CCombo combo = new CCombo(incrementTable, SWT.READ_ONLY);
            // for (int i = 0, n = sdps.keySet().size(); i < n; i++)
            // {
            // combo.add(sdps.keySet().toArray()[i].toString());
            // }
            for (String key : sdps)
            {
              if(key.contains("["))
                continue;
             
              if (getItemIfPresent(key) == null
                  || item.getText(column).equals(key))
              {
                combo.add(key);
              }
            }
           
            // Select the previously selected item from the cell
            combo.select(combo.indexOf(item.getText(column)));

            // Compute the width for the editor
            // Also, compute the column width, so that the dropdown fits
            editor.minimumWidth = combo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            if (incrementTable.getColumn(column).getWidth() < editor.minimumWidth)
            {
              incrementTable.getColumn(column).setWidth(editor.minimumWidth);
            }
            // Set the focus on the dropdown and set into the editor
            combo.setFocus();
            editor.setEditor(combo, item, column);

            combo.addModifyListener(fListener);

            // Add a listener to set the selected item back into the cell
            final int col = column;
            combo.addSelectionListener(new SelectionAdapter()
            {
              public void widgetSelected(SelectionEvent event)
              {
                item.setText(col, combo.getText());
                Button a = new Button(incrementTable, SWT.PUSH);
                TableEditor editor = new TableEditor(incrementTable);
                a.setText("Delete");
                a.computeSize(SWT.DEFAULT, incrementTable.getItemHeight());

                editor.grabHorizontal = true;
                editor.minimumHeight = a.getSize().y;
                editor.minimumWidth = a.getSize().x;

                editor.setEditor(a, item, 4);
                a.addSelectionListener(new SelectionListener() {
                 
                  public void widgetSelected(SelectionEvent e) {
                    removeItem(incrementTable, col, e);
                   
                  }
                 
                  public void widgetDefaultSelected(SelectionEvent e) {
                   
                  }
                });              // setDirty(true);
                // updateLaunchConfigurationDialog();

                // They selected an item; end the editing session
                combo.dispose();
              }
            });
           
         
           
          } else if (column > 0)
          {
            // Create the Text object for our editor
            final Text text = new Text(incrementTable, SWT.NONE);
            text.setForeground(item.getForeground());

            // Transfer any text from the cell to the Text control,
            // set the color to match this row, select the text,
            // and set focus to the control
            text.setText(item.getText(column));
            text.setForeground(item.getForeground());
            text.selectAll();
            text.setFocus();

            // Recalculate the minimum width for the editor
            editor.minimumWidth = text.getBounds().width;

            // Set the control into the editor
            editor.setEditor(text, item, column);

//            text.addModifyListener(fListener);

            // Add a handler to transfer the text back to the cell
            // any time it's modified
View Full Code Here

  }

  private void addEditorToValueSetTable()
  {
    // Create an editor object to use for text editing
    final TableEditor editor = new TableEditor(valueSetTable);
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;

    // Use a mouse listener, not a selection listener, since we're interested
    // in the selected column as well as row
    valueSetTable.addMouseListener(new MouseAdapter()
    {
      public void mouseDown(MouseEvent event)
      {
        // Dispose any existing editor
        Control old = editor.getEditor();
        if (old != null)
          old.dispose();

        // Determine where the mouse was clicked
        Point pt = new Point(event.x, event.y);

        // Determine which row was selected
        final TableItem item = valueSetTable.getItem(pt);
        if (item != null)
        {
          // Determine which column was selected
          int column = -1;
          for (int i = 0, n = valueSetTable.getColumnCount(); i < n; i++)
          {
            Rectangle rect = item.getBounds(i);
            if (rect.contains(pt))
            {
              // This is the selected column
              column = i;
              break;
            }
          }

          // Column 2 holds dropdowns
          if (column == 0)
          {
            // Create the dropdown and add data to it
            final CCombo combo = new CCombo(valueSetTable, SWT.READ_ONLY);
            // for (int i = 0, n = sdps.keySet().size(); i < n; i++)
            // {
            // combo.add(sdps.keySet().toArray()[i].toString());
            // }
            for (String key : sdps)
            {
              if (getItemIfPresent(key) == null
                  || item.getText(column).equals(key))
              {
                combo.add(key);
              }
            }

            // Select the previously selected item from the cell
            combo.select(combo.indexOf(item.getText(column)));

            // Compute the width for the editor
            // Also, compute the column width, so that the dropdown fits
            editor.minimumWidth = combo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            if (valueSetTable.getColumn(column).getWidth() < editor.minimumWidth)
            {
              valueSetTable.getColumn(column).setWidth(editor.minimumWidth);
            }
            // Set the focus on the dropdown and set into the editor
            combo.setFocus();
            editor.setEditor(combo, item, column);

//            combo.addModifyListener(fListener);

            // Add a listener to set the selected item back into the cell
            final int col = column;
            combo.addSelectionListener(new SelectionAdapter()
            {
              public void widgetSelected(SelectionEvent event)
              {
                item.setText(col, combo.getText());
                // setDirty(true);
                // updateLaunchConfigurationDialog();
                updateLaunchConfigurationDialog();
                // They selected an item; end the editing session
                combo.dispose();
               
                Button a = new Button(valueSetTable, SWT.PUSH);
                TableEditor editor = new TableEditor(valueSetTable);
                a.setText("Delete");
                a.computeSize(SWT.DEFAULT, valueSetTable.getItemHeight());

                editor.grabHorizontal = true;
                editor.minimumHeight = a.getSize().y;
                editor.minimumWidth = a.getSize().x;

                editor.setEditor(a, item, 2);
                a.addSelectionListener(new SelectionListener() {
                 
                  public void widgetSelected(SelectionEvent e) {
                    removeItem(valueSetTable, col, e);
                  }
                 
                  public void widgetDefaultSelected(SelectionEvent e) {
                   
                  }
                });         
              }
            });
          } else if (column > 0)
          {
            // Create the Text object for our editor
            final Text text = new Text(valueSetTable, SWT.NONE);
            text.setForeground(item.getForeground());

            // Transfer any text from the cell to the Text control,
            // set the color to match this row, select the text,
            // and set focus to the control
            text.setText(item.getText(column));
            text.setForeground(item.getForeground());
            text.selectAll();
            text.setFocus();

            // Recalculate the minimum width for the editor
            editor.minimumWidth = text.getBounds().width;

            // Set the control into the editor
            editor.setEditor(text, item, column);

//            text.addModifyListener(fListener);

            // Add a handler to transfer the text back to the cell
            // any time it's modified
View Full Code Here

          if (colls.length == incrementTable.getColumnCount() - 1)
          {
            TableItem tableItem = new TableItem(incrementTable, SWT.NONE);
            tableItem.setText(colls);
            Button a = new Button(incrementTable, SWT.PUSH);
            TableEditor editor = new TableEditor(incrementTable);
            a.setText("Delete");
            a.computeSize(SWT.DEFAULT, incrementTable.getItemHeight());

            editor.grabHorizontal = true;
            editor.minimumHeight = a.getSize().y;
            editor.minimumWidth = a.getSize().x;

            editor.setEditor(a, tableItem, 4);
            final int col = collumn;
           
            a.addSelectionListener(new SelectionListener() {
             
              public void widgetSelected(SelectionEvent e) {
                removeItem(incrementTable, col, e);
              }
             
              public void widgetDefaultSelected(SelectionEvent e) {
               
              }
            })
            collumn++;
          }
        }
      }
     
      data = configuration.getAttribute(IDebugConstants.DESTECS_ACA_VALUESET_SDPS, "");
      if (data != null && !data.isEmpty())
      {
        String[] items = data.split(",");
        int collumn = 0;
        for (String item : items)
        {
          String[] colls = item.split("\\|");
          if (colls.length == valueSetTable.getColumnCount() -1 )
          {
            TableItem tableItem = new TableItem(valueSetTable, SWT.NONE);
            tableItem.setText(colls);
                       
            Button a = new Button(valueSetTable, SWT.PUSH);
            TableEditor editor = new TableEditor(valueSetTable);
            a.setText("Delete");
            a.computeSize(SWT.DEFAULT, valueSetTable.getItemHeight());

            editor.grabHorizontal = true;
            editor.minimumHeight = a.getSize().y;
            editor.minimumWidth = a.getSize().x;

            editor.setEditor(a, tableItem, 2);
            final int col = collumn;
           
            a.addSelectionListener(new SelectionListener() {
             
              public void widgetSelected(SelectionEvent e) {
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

        // 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

   * @param shell
   */
  public void createContents(final Shell shell)
  {
    // Create an editor object to use for text editing
    final TableEditor editor = new TableEditor(table);
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    editor.grabVertical = true;

    // Use a selection listener to get seleceted row
    table.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent event)
      {
        // Dispose any existing editor
        Control old = editor.getEditor();

        if (old != null)
        {
          old.dispose();
        }

        // Determine which row was selected
        final TableItem item = (TableItem) event.item;

        if (item != null)
        {
          // COMBO
          if (item.getText().equals("Style")
            || item.getText().equals("Arrow")
            || item.getText().equals("Shape"))
          {
            // Create the dropdown and add data to it
            final CCombo combo = new CCombo(table, SWT.READ_ONLY);

            if (item.getText().equals("Style"))
            {
              String[] styleOfEdge = {"Solid", "Dashed"};
              combo.setItems(styleOfEdge);
            }
            else if (item.getText().equals("Arrow"))
            {
              String[] arrowOfEdge = {"None",
                "Source",
                "Target",
                "Both"};
              combo.setItems(arrowOfEdge);
            }
            else if (item.getText().equals("Shape"))
            {
               combo.setItems(NodeModel.shapes);
            }

            // Select the previously selected item from the cell
            combo.select(combo.indexOf(item.getText(1)));
//            combo.setFont(tableFont);
            editor.setEditor(combo, item, 1);

            // Add a listener to set the selected item back into the
            // cell
            combo.addSelectionListener(new SelectionAdapter()
            {
              public void widgetSelected(SelectionEvent event)
              {
                item.setText(1, combo.getText());
                                // They selected an item; end the editing
                // session
                combo.dispose();
              }
            });
          }

          // TEXT
          else if (item.getText().equals("Text"))
          {
            // Create the Text object for our editor
            final Text text = new Text(table, SWT.LEFT);
            // text.setForeground(item.getForeground());

            // Transfer any text from the cell to the Text control,
            // set the color to match this row, select the text,
            // and set focus to the control
            text.setText(item.getText(1));
//            text.setFont(tableFont);

            // text.setForeground(item.getForeground());
            text.selectAll();
            text.setFocus();
            editor.setEditor(text, item, 1);

            // Add a handler to transfer the text back to the cell
            // any time it's modified
            text.addModifyListener(new ModifyListener()
            {
              public void modifyText(ModifyEvent event)
              {
                // Set the text of the editor's control back
                // into the cell
                item.setText(1, text.getText());
              }
            });
          }

          // NUMBER
          else if (item.getText().equals("Margin")
            || item.getText().equals("Cluster ID")
            || item.getText().equals("Width"))
          {
            // Create the Text object for our editor
            final Text text = new Text(table, SWT.LEFT);
            // text.setForeground(item.getForeground());

            // Transfer any text from the cell to the Text control,
            // set the color to match this row, select the text,
            // and set focus to the control
            text.setText(item.getText(1));
//            text.setFont(tableFont);

            // text.setForeground(item.getForeground());
            text.selectAll();
            text.setFocus();
            editor.setEditor(text, item, 1);

            // Add a handler to transfer the text back to the cell
            // any time it's modified
            text.addModifyListener(new ModifyListener()
            {
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.