Package org.eclipse.swt.events

Examples of org.eclipse.swt.events.SelectionAdapter


    /* Mark Read after Millis */
    fMarkReadStateCheck = new Button(markReadAfterContainer, SWT.CHECK);
    fMarkReadStateCheck.setText("Mark news as read after ");
    fMarkReadStateCheck.setSelection(fGlobalScope.getBoolean(DefaultPreferences.MARK_READ_STATE));
    fMarkReadStateCheck.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        fMarkReadAfterSpinner.setEnabled(fMarkReadStateCheck.getSelection());
      }
    });
View Full Code Here


    /* Delete by Count */
    fDeleteNewsByCountCheck = new Button(group, SWT.CHECK);
    fDeleteNewsByCountCheck.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    fDeleteNewsByCountCheck.setSelection(fGlobalScope.getBoolean(DefaultPreferences.DEL_NEWS_BY_COUNT_STATE));
    fDeleteNewsByCountCheck.setText("Maximum number of news to keep: ");
    fDeleteNewsByCountCheck.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        fDeleteNewsByCountValue.setEnabled(fDeleteNewsByCountCheck.getSelection());
      }
    });

    fDeleteNewsByCountValue = new Spinner(group, SWT.BORDER);
    fDeleteNewsByCountValue.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    fDeleteNewsByCountValue.setEnabled(fDeleteNewsByCountCheck.getSelection());
    fDeleteNewsByCountValue.setMinimum(0);
    fDeleteNewsByCountValue.setMaximum(99999);
    fDeleteNewsByCountValue.setSelection(fGlobalScope.getInteger(DefaultPreferences.DEL_NEWS_BY_COUNT_VALUE));

    /* Delete by Age */
    fDeleteNewsByAgeCheck = new Button(group, SWT.CHECK);
    fDeleteNewsByAgeCheck.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    fDeleteNewsByAgeCheck.setSelection(fGlobalScope.getBoolean(DefaultPreferences.DEL_NEWS_BY_AGE_STATE));
    fDeleteNewsByAgeCheck.setText("Maximum age of news in days: ");
    fDeleteNewsByAgeCheck.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        fDeleteNewsByAgeValue.setEnabled(fDeleteNewsByAgeCheck.getSelection());
      }
    });
View Full Code Here

    /* Button to delete Condition */
    ToolItem deleteButton = new ToolItem(buttonBar, SWT.PUSH);
    deleteButton.setImage(fDeleteIcon);
    deleteButton.setDisabledImage(fDeleteDisabledIcon);
    deleteButton.setToolTipText(Messages.SearchConditionList_DELETE_CONDITION);
    deleteButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        JobRunner.runInUIThread(0, true, buttonBar, new Runnable() {
          public void run() {
            onDelete(item, itemContainer);
View Full Code Here

      hookSelectionListener(mItem, item, factory.createSearchField(INews.LABEL, news));
    }
  }

  private void hookSelectionListener(MenuItem item, final SearchConditionItem condition, final ISearchField field) {
    item.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onAdd(condition, field);
      }
    });
View Full Code Here

        NewsColumn[] newsColumns = NewsColumn.values();
        for (final NewsColumn column : newsColumns) {
          if (column.isSelectable() && !fModel.contains(column)) {
            MenuItem item = new MenuItem(menu, SWT.PUSH);
            item.setText(column.getName());
            item.addSelectionListener(new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                fModel.addColumn(column);
                fNewsColumnViewer.add(column);
                updateRemoveEnablement();
                fNewsColumnViewer.setSelection(new StructuredSelection(column));
              }
            });
          }
        }
      }

      public void menuHidden(MenuEvent e) {}
    });

    final Button addButton = new Button(buttonContainer, SWT.DOWN);
    setButtonLayoutData(addButton);
    addButton.setText(Messages.NewsColumnSelectionControl_ADD);
    addButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        Rectangle rect = addButton.getBounds();
        Point pt = new Point(rect.x, rect.y + rect.height);
        pt = addButton.toDisplay(pt);
        menu.setLocation(pt.x, pt.y);
        menu.setVisible(true);
      }
    });

    addButton.addDisposeListener(new DisposeListener() {
      public void widgetDisposed(DisposeEvent e) {
        menu.dispose();
      }
    });

    /* Remove */
    fRemoveButton = new Button(buttonContainer, SWT.PUSH);
    setButtonLayoutData(fRemoveButton);
    fRemoveButton.setText(Messages.NewsColumnSelectionControl_REMOVE);
    fRemoveButton.setEnabled(false);
    fRemoveButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onDelete();
      }
    });

    /* Move Up */
    fMoveUpButton = new Button(buttonContainer, SWT.PUSH);
    setButtonLayoutData(fMoveUpButton);
    fMoveUpButton.setText(Messages.NewsColumnSelectionControl_MOVE_UP);
    fMoveUpButton.setEnabled(false);
    fMoveUpButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onMove(true);
      }
    });

    /* Move Down */
    fMoveDownButton = new Button(buttonContainer, SWT.PUSH);
    setButtonLayoutData(fMoveDownButton);
    fMoveDownButton.setText(Messages.NewsColumnSelectionControl_MOVE_DOWN);
    fMoveDownButton.setEnabled(false);
    fMoveDownButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onMove(false);
      }
    });
View Full Code Here

      final ControlDecoration unreadControlDeco = new ControlDecoration(fUnreadState, SWT.LEFT | SWT.TOP);
      unreadControlDeco.setImage(OwlUI.getImage(fUnreadState, "icons/obj16/dotempty.gif")); //$NON-NLS-1$
      unreadControlDeco.hide();

      fNewState.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          if (fNewState.getSelection() && !fUnreadState.getSelection()) {
            unreadControlDeco.show();
            unreadControlDeco.showHoverText(Messages.StateConditionControl_UNREAD_HINT);
          } else {
            unreadControlDeco.hide();
            unreadControlDeco.hideHover();
          }
        }
      });

      fUnreadState.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          if (fUnreadState.getSelection() && !fNewState.getSelection()) {
            newControlDeco.show();
            newControlDeco.showHoverText(Messages.StateConditionControl_NEW_HINT);
          } else {
            newControlDeco.hide();
            newControlDeco.hideHover();
          }
        }
      });

      fNewState.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
          newControlDeco.hide();
          newControlDeco.hideHover();
        }
      });

      fUnreadState.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
          unreadControlDeco.hide();
          unreadControlDeco.hideHover();
        }
      });
    }

    /* Use Balloon Tooltip on Windows and Linux */
    else {

      /* Use a Tooltip to help the user understand the State Semantic */
      final ToolTip newStateToolTip = new ToolTip(getShell(), SWT.BALLOON);
      newStateToolTip.setMessage(Messages.StateConditionControl_NEW_HINT);
      newStateToolTip.setAutoHide(false);

      final ToolTip unreadStateToolTip = new ToolTip(getShell(), SWT.BALLOON);
      unreadStateToolTip.setMessage(Messages.StateConditionControl_UNREAD_HINT);
      unreadStateToolTip.setAutoHide(false);

      fNewState.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          if (fNewState.getSelection() && !fUnreadState.getSelection()) {
            Point toolTipLocation = toDisplay(fUnreadState.getLocation());
            toolTipLocation.y += fUnreadState.getSize().y;
            if (Application.IS_WINDOWS)
              toolTipLocation.x += 5;
            else if (Application.IS_LINUX)
              toolTipLocation.x += 12;

            unreadStateToolTip.setLocation(toolTipLocation);
            unreadStateToolTip.setVisible(true);
          } else {
            unreadStateToolTip.setVisible(false);
          }
        }
      });

      fUnreadState.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          if (fUnreadState.getSelection() && !fNewState.getSelection()) {
            Point toolTipLocation = toDisplay(fNewState.getLocation());
            toolTipLocation.y += fNewState.getSize().y;
            if (Application.IS_WINDOWS)
              toolTipLocation.x += 5;
            else if (Application.IS_LINUX)
              toolTipLocation.x += 12;

            newStateToolTip.setLocation(toolTipLocation);
            newStateToolTip.setVisible(true);
          } else {
            newStateToolTip.setVisible(false);
          }
        }
      });

      fNewState.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
          newStateToolTip.setVisible(false);
        }

        @Override
        public void focusLost(FocusEvent e) {
          unreadStateToolTip.setVisible(false);
        }
      });

      fUnreadState.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
          unreadStateToolTip.setVisible(false);
        }

        @Override
        public void focusLost(FocusEvent e) {
          newStateToolTip.setVisible(false);
        }
      });

      addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
          unreadStateToolTip.dispose();
          newStateToolTip.dispose();
        }
      });
    }

    /* State: Updated */
    fUpdatedState = new Button(this, SWT.CHECK);
    fUpdatedState.setText(Messages.StateConditionControl_UPDATED);
    fUpdatedState.setToolTipText(Messages.StateConditionControl_UPDATED_INFO);
    fUpdatedState.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true));

    /* State: Read */
    fReadState = new Button(this, SWT.CHECK);
    fReadState.setText(Messages.StateConditionControl_READ);
    fReadState.setToolTipText(Messages.StateConditionControl_READ_INFO);
    fReadState.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true));

    /* Selection Listener to issue modify events */
    SelectionListener selectionListener = new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        notifyListeners(SWT.Modify, new Event());
      }
    };
View Full Code Here

    /* Apply Gridlayout */
    setLayout(LayoutUtils.createGridLayout(1, 5, 1));

    fConditionLabel = new Link(this, SWT.NONE);
    fConditionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    fConditionLabel.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        IFolderChild selectedChild = null;
        if (e.text != null && e.text.length() > 0)
          selectedChild = fSelection.get(Integer.valueOf(e.text));
View Full Code Here

      item.setText(COLOR_LABELS[i]);

      final RGB color = COLOR_VALUES[i];
      item.setImage(createColorImage(color));
      item.setData(color);
      item.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          onColorSelected(color);
        }
      });
    }

    /* Add Item to open the native Color Picker */
    new MenuItem(fColorMenu, SWT.SEPARATOR);
    MenuItem moreColor = new MenuItem(fColorMenu, SWT.PUSH);
    moreColor.setText(Messages.ColorPicker_OTHER);
    moreColor.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onSelectOtherColor();
      }
    });
View Full Code Here

          setChildsChecked(child, true, true, true);
        }
      }

      /* Update Checks on Selection */
      fViewer.getTree().addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          if (e.detail == SWT.CHECK) {
            TreeItem item = (TreeItem) e.item;

            /* Disable selection for Folders if SELECT_BIN */
            if (fMode == Mode.SELECT_BIN && item.getData() instanceof IFolder) {
              e.detail = SWT.NONE;
              e.doit = false;
              item.setChecked(false);
            }

            /* Normal selection behavior otherwise */
            else {
              IFolderChild folderChild = (IFolderChild) item.getData();
              setChildsChecked(folderChild, item.getChecked(), false, true);
              cache(folderChild, item.getChecked());

              if (!item.getChecked())
                setParentsChecked(folderChild, false, true);
            }
          }
        }
      });

      /* Update Checks on Expand */
      fViewer.addTreeListener(new ITreeViewerListener() {
        public void treeExpanded(TreeExpansionEvent event) {
          boolean isChecked = fViewer.getChecked(event.getElement());
          if (isChecked)
            setChildsChecked((IFolderChild) event.getElement(), isChecked, false, false);
        }

        public void treeCollapsed(TreeExpansionEvent event) {}
      });

      /* Select and Show Selection */
      if (fSelectedElement != null) {
        fViewer.setSelection(new StructuredSelection(fSelectedElement));
        fViewer.getTree().showSelection();
      }

      /* Buttons */
      Composite buttonContainer = new Composite(composite, SWT.NONE);
      buttonContainer.setLayout(LayoutUtils.createGridLayout(2, 0, 0));
      buttonContainer.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));

      /* Select All / Deselect All for Location Lookup */
      if (fMode == Mode.SEARCH_LOCATION) {
        Button selectAll = new Button(buttonContainer, SWT.PUSH);
        selectAll.setText(Messages.LocationControl_SELECT_ALL);
        Dialog.applyDialogFont(selectAll);
        setButtonLayoutData(selectAll);
        selectAll.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            OwlUI.setAllChecked(fViewer.getTree(), true);
            cacheAll(true);
          }
        });

        Button deselectAll = new Button(buttonContainer, SWT.PUSH);
        deselectAll.setText(Messages.LocationControl_DESELECT_ALL);
        Dialog.applyDialogFont(deselectAll);
        setButtonLayoutData(deselectAll);
        deselectAll.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            OwlUI.setAllChecked(fViewer.getTree(), false);
            cacheAll(false);
          }
        });
      }

      /* Create Bin for Bin Selection */
      else {
        Button createBin = new Button(buttonContainer, SWT.PUSH);
        createBin.setText(Messages.LocationControl_NEW_NEWSBIN);
        Dialog.applyDialogFont(createBin);
        setButtonLayoutData(createBin);
        createBin.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            onCreateNewsBin();
          }
        });
View Full Code Here

    for (Control c : control) {

      /* Button */
      if (c instanceof Button) {
        Button button = (Button) c;
        button.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            run.run();
          }
        });
      }

      /* Combo */
      else if (c instanceof Combo) {
        Combo combo = (Combo) c;
        combo.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            run.run();
          }
        });
      }

      /* Tree */
      else if (c instanceof Tree) {
        Tree tree = (Tree) c;
        tree.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if ((e.detail & SWT.CHECK) != 0)
              run.run();
          }
        });

        tree.addDragDetectListener(new DragDetectListener() {
          public void dragDetected(DragDetectEvent e) {
            run.run();
          }
        });
      }

      /* Table */
      else if (c instanceof Table) {
        Table table = (Table) c;
        table.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if ((e.detail & SWT.CHECK) != 0)
              run.run();
          }
        });

        table.addDragDetectListener(new DragDetectListener() {
          public void dragDetected(DragDetectEvent e) {
            run.run();
          }
        });
      }

      /* Spinner */
      else if (c instanceof Spinner) {
        Spinner spinner = (Spinner) c;
        spinner.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            run.run();
          }
        });
View Full Code Here

TOP

Related Classes of org.eclipse.swt.events.SelectionAdapter

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.