Examples of TableEditor


Examples of org.eclipse.swt.custom.TableEditor

   * @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

Examples of org.eclipse.swt.custom.TableEditor

   * @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

Examples of org.eclipse.swt.custom.TableEditor

        .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

Examples of org.eclipse.swt.custom.TableEditor

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

Examples of org.eclipse.swt.custom.TableEditor

        .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

Examples of org.eclipse.swt.custom.TableEditor

    }

    private void configTable() {
        table.setHeaderVisible(true);
        table.setLinesVisible(true);
        final TableEditor tableEditor = new TableEditor(table);
        tableEditor.grabHorizontal = true;
    }
View Full Code Here

Examples of org.eclipse.swt.custom.TableEditor

        data.right = new FormAttachment(100, 0);
        workTimeTable.setLayoutData(data);

        workTimeTable.setHeaderVisible(true);
        workTimeTable.setLinesVisible(true);
        new TableEditor(workTimeTable).grabHorizontal = true;

        createItems();
        addWorkTimeTableListener();
    }
View Full Code Here

Examples of org.eclipse.swt.custom.TableEditor

        .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

Examples of org.eclipse.swt.custom.TableEditor

        // create dn link control
        dnLink = new Hyperlink( viewer.getTable(), SWT.NONE );
        dnLink.setLayoutData( new GridData( SWT.BOTTOM, SWT.LEFT, true, true ) );
        dnLink.setText( "" ); //$NON-NLS-1$
        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

Examples of org.eclipse.swt.custom.TableEditor

        gridData.widthHint = 200;
        gridData.minimumWidth = 200;
        aliasesTable.setLayoutData( gridData );

        // Aliases Table Editor
        tableEditor = new TableEditor( aliasesTable );
        tableEditor.horizontalAlignment = SWT.LEFT;
        tableEditor.grabHorizontal = true;
        tableEditor.minimumWidth = 200;

        // Add Button
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.