Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.TreeEditor


   
    computeSaveEnable();
    refresh();
    constructMenu();
   
    editor = new TreeEditor (treeGroups);
    treeGroups.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {       
        if(itemEdited != null && !editor.getEditor().isDisposed())
          itemEdited.setText(((Text)editor.getEditor()).getText());
        removeEditor();
View Full Code Here


   
    computeSaveEnable();
    refresh();
    constructMenu();
   
    editor = new TreeEditor (treeGroups);
    treeGroups.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {       
        if(itemEdited != null && !editor.getEditor().isDisposed())
          itemEdited.setText(((Text)editor.getEditor()).getText());
        removeEditor();
View Full Code Here

    }
    return delegate;
  }

  public static ControlEditor createTableOrTreeEditor(TableOrTreeSWT tableOrTree) {
    return (tableOrTree instanceof TreeDelegate) ? new TreeEditor(
        (Tree) tableOrTree.getComposite()) : new TableEditor(
        (Table) tableOrTree.getComposite());
  }
View Full Code Here

   */
  TreeViewerEditor(TreeViewer viewer, SWTFocusCellManager focusCellManager,
      ColumnViewerEditorActivationStrategy editorActivationStrategy,
      int feature) {
    super(viewer, editorActivationStrategy, feature);
    treeEditor = new TreeEditor(viewer.getTree());
    this.focusCellManager = focusCellManager;
  }
View Full Code Here

    public RenameAction( ServersView view )
    {
        super( Messages.getString( "RenameAction.Rename" ) ); //$NON-NLS-1$
        this.view = view;
        this.tree = view.getViewer().getTree();
        this.treeEditor = new TreeEditor( tree );
        init();
    }
View Full Code Here

    MenuItem deleteItem = new MenuItem(this.menu, SWT.PUSH);
    deleteItem.setText("Delete");
    this.deleteListener = new DeleteListener();
    deleteItem.addListener(SWT.Selection, this.deleteListener);

    this.editor = new TreeEditor(this.tree);
    this.editor.horizontalAlignment = SWT.LEFT;
    this.editor.grabHorizontal = true;
    this.editor.minimumWidth = 50;

    // create white space menu
View Full Code Here

    this.discardListener = new DiscardListener();
    discardItem.addListener(SWT.Selection, this.discardListener);
    this.tree.setMenu(this.menu);

    // Allow cells to be edited on double click or when pressing enter on them.
    this.editor = new TreeEditor(this.tree);
    this.editor.horizontalAlignment = SWT.LEFT;
    this.editor.grabHorizontal = true;
    this.editor.minimumWidth = 50;
   
    // Listen to OSGi for models being added by plugins.
View Full Code Here

        }
    }

    private void updateChildren() {
        for (TreeItem item : tree.getItems()) {
            TreeEditor treeEditor = (TreeEditor) item.getData(TREE_EDITOR_KEY);
            if (treeEditor != null) {
                treeEditor.getEditor().dispose();
            }
            item.dispose();
        }
       
        if (source == null) {
            return;
        }
        IPropertyDescriptor[] descriptors = source.getPropertyDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            IPropertyDescriptor descriptor = descriptors[i];
            Object value = source.getPropertyValue(descriptor.getId());

            final TreeItem item = new TreeItem(tree, SWT.NONE, i);
            item.setText(0, descriptor.getDisplayName());
            item.setText(1, getStringValue(descriptor, value));

            CellEditor cellEditor = descriptor.createPropertyEditor(tree);
            CellEditorListener cellEditorListener = null;
            if (cellEditor != null) {
                cellEditor.setValue(value);
                cellEditorListener = new CellEditorListener(item, descriptor, cellEditor);
                cellEditor.addListener(cellEditorListener);
                CellEditor.LayoutData layout = cellEditor.getLayoutData();
                TreeEditor treeEditor = new TreeEditor(tree);
                treeEditor.horizontalAlignment = layout.horizontalAlignment;
                treeEditor.grabHorizontal = layout.grabHorizontal;
                treeEditor.minimumWidth = layout.minimumWidth;
                if (cellEditor instanceof ComboBoxCellEditor) {
                    cellEditor.getControl().setBackground(ColorConstants.white);
                    cellEditor.setValidator(new ICellEditorValidator() {
                        public String isValid(Object object) {
                            if (object instanceof Integer && ((Integer) object).intValue() > -1) {
                                return null;
                            }
                            return "empty";
                        }
                    });
                }
                treeEditor.setEditor(cellEditor.getControl(), item, columnToEdit);
                item.setData(CELL_EDITOR_KEY, cellEditor);
                item.setData(TREE_EDITOR_KEY, treeEditor);
            }
            item.setData(PROPERTY_DESCRIPTOR_KEY, descriptor);
            item.setData(CELL_EDITOR_LISTENER_KEY, cellEditorListener);
View Full Code Here

  private void updatePresenceOfItem(TreeItem item, RosterEntry entry,
      Presence presence) {
    item.setImage(GOIMIcons.getImageForPresence(entry, presence));
    int extensions = 0;
    TreeEditor editor = getEditor(item, false);
    if (presence != null) {
      Iterator iterator = presence.getExtensions();
      if (editor != null)
        if (editor.getEditor() == null) {
          System.err.println("editor.getEditor() is null !! "
              + this.getClass().toString());
        } else {
          for (Control control : ((Composite) editor.getEditor())
              .getChildren())
            control.dispose();
        }
      while (iterator.hasNext()) {
        PacketExtension ex = (PacketExtension) iterator.next();
        if (ex instanceof IGameExtension) {
          extensions++;
          if (editor == null)
            editor = getEditor(item, true);
          final IGameExtension gameEx = (IGameExtension) ex;
          final GOIMGameItem game = gameEx.getGameItem();
          final GameExtensionProxy proxy = gameEx.getGameExtension();
          // final InetSocketAddress target = gameEx.getDestination();
          Label label = new Label((Composite) editor.getEditor(),
              SWT.NULL);
          // Button label = new
          // Button((Composite)editor.getEditor(),SWT.PUSH);
          try {
            label.setImage(proxy.getIcon().createImage());
          } catch(SWTError error) {
            error.printStackTrace();
            // Since we still want the user to know about the error .. i throw an exception for now ..
            throw new RuntimeException("An SWT Error occurred during setting game icon",error);
          }
          label.setToolTipText(proxy.getTooltipText(game, gameEx));
          System.out.println("Addin label with image: " + proxy.icon
              + ": " + label.computeSize(-1, -1));
          // label.setEnabled(true);
          // label.setText("Muh");
          label.setLayoutData(new RowData(16,16));
          if (game != null) {
            label.addListener(SWT.MouseUp, new Listener() {

              public void handleEvent(Event event) {
                //System.out.println("mouseup");
                proxy.execute(game, gameEx);
              }
            });
            label.setFocus();
          } else {
            label.setToolTipText("Game not installed: "
                + label.getToolTipText());
          }
          ((Composite) editor.getEditor()).layout(true, true);
          ((Composite) editor.getEditor()).pack(true);
          editor.minimumWidth = editor.getEditor().getSize().x;
          editor.layout();
        }
      }
    }
    if (extensions < 1 && editor != null) {
      editor.getEditor().dispose();
      editor.dispose();
      item.setData("editor",null);
    }
    contactList.redraw();
  }
View Full Code Here

    }
    contactList.redraw();
  }

  public TreeEditor getEditor(TreeItem item, boolean create) {
    TreeEditor editor = (TreeEditor) item.getData("editor");
    if (create && (editor == null || editor.getEditor() == null)) {
      if (item.getParent() == null)
        System.err.println("tree is null ?!");
      item.setData("editor", editor = new TreeEditor(item.getParent()));
      final Composite c = new Composite(contactList, SWT.NULL);
      c.setBackground(contactList.getBackground());
      RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
      rowLayout.marginBottom = rowLayout.marginLeft = rowLayout.marginTop = rowLayout.marginRight = 0;
      rowLayout.spacing = 2;
      rowLayout.wrap = rowLayout.pack = false;
      rowLayout.pack = true;
      c.setLayout(rowLayout);
      editor.setEditor(c, item, 0);
      editor.grabHorizontal = false;editor.horizontalAlignment = SWT.RIGHT;
      final TreeEditor _editor = editor;
      item.addListener(SWT.Dispose, new Listener() {
        public void handleEvent(Event event) {
          if (!c.isDisposed()) {
            c.dispose();
          }
          if (_editor.getEditor() == null)
            System.out.println("TreeEditor already disposed ?!");
          else
            _editor.dispose();
        }
      });
    }
    return editor;
  }
View Full Code Here

TOP

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

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.