Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Listener


  spellDescr.setText("A spell checker can provide alternative queries");
  spellDescr.setBackground( labelColors, new int[] {100} );
  spellDescr.setLayoutData(freshlGd);
  //*-- build the listener
  Listener selectionListener = new Listener()
  { public void handleEvent(Event event)
  {
   //*-- set the crawl configuration based on the selected buttons
   if (skipYesButton.getSelection())   ( (CrawlConfigWizard) getWizard() ).crawlConfig.setSkipHidden(true);
   if (skipNoButton.getSelection())   ( (CrawlConfigWizard) getWizard() ).crawlConfig.setSkipHidden(false);
View Full Code Here


  //*-- add the two buttons to add and delete directory names
  final Button addButton = new Button(composite, SWT.PUSH); addButton.setText("Add");
  GridData addButtonGd = new GridData(); addButtonGd.horizontalAlignment = GridData.BEGINNING;
  addButtonGd.grabExcessHorizontalSpace = false;
  addButton.setLayoutData(addButtonGd);
  addButton.addListener( SWT.Selection, new Listener()
  {
   public void handleEvent(Event e)
   {
    DirectoryDialog dd = new DirectoryDialog(composite.getShell());
    dd.setMessage("Please select a directory to exclude from the scan");
    String dir = dd.open();
    if (dir != null)  { dirs.add(dir); fillUpTable(); }
   }
  });

  final Button deleteButton = new Button(composite, SWT.PUSH); deleteButton.setText("Delete");
  GridData delButtonGd = new GridData(); delButtonGd.horizontalAlignment = GridData.BEGINNING;
  delButtonGd.grabExcessHorizontalSpace = false;
  deleteButton.setLayoutData(delButtonGd);
  deleteButton.addListener( SWT.Selection, new Listener()
  {
   public void handleEvent(Event e)
   {
    int i = table.getSelectionIndex();
    if (i != -1) { dirs.remove(i); fillUpTable(); }
View Full Code Here

  Button indexButton = new Button(composite, SWT.PUSH); indexButton.setText("Browse");
  GridData indexButtonGd = new GridData(); indexButtonGd.horizontalAlignment = GridData.BEGINNING;
  indexButtonGd.grabExcessHorizontalSpace = false;
  indexButton.setLayoutData(indexButtonGd);
  indexButton.addListener( SWT.Selection, new Listener() {
   public void handleEvent(Event e)
   {
    DirectoryDialog dd = new DirectoryDialog(composite.getShell());
    dd.setMessage("Please select the Lucene index directory");
    String dir = dd.open();
    if (dir != null)
      { indexText.setText(dir);( (CrawlConfigWizard) getWizard() ).crawlConfig.setIndexDir(dir); }
   }
  });

  //*-- description of the Lucene index dir.
  GridData indexDescrGd = new GridData(); indexDescrGd.grabExcessHorizontalSpace = true;
  indexDescrGd.horizontalAlignment = GridData.FILL; indexDescrGd.horizontalSpan = 3;
  indexDescrGd.widthHint = 350;
  Text indexDescrText = new Text(composite,  SWT.LEFT | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
  indexDescrText.setEditable(false);
  indexDescrText.setText("The Lucene index directory is where one or more indexes will be stored. If there are " + Constants.NEWLINE +
    "sub-directories in this directory, a multisearcher will be created to scan all index. Otherwise, a " + Constants.NEWLINE +
  "single index reader will be used. The files in this directory can become quite large.");
  indexDescrText.setLayoutData(indexDescrGd);

  //*-- add the database directory selector
  GridData dbGd = new GridData(); dbGd.grabExcessHorizontalSpace = false; dbGd.horizontalAlignment = GridData.FILL;
  CLabel dbLabel = new CLabel(composite, SWT.LEFT); dbLabel.setText("Berkeley DB dir.: ");
  dbLabel.setBackground( labelColors, new int[] {100} );
  dbLabel.setLayoutData(dbGd);

  final Text dbText = new Text(composite, SWT.SINGLE | SWT.BORDER);
  dbText.setText( ( (CrawlConfigWizard) getWizard() ).crawlConfig.getDbDir() );
  if (dbText.getText().length() == 0)
   dbText.setText(Constants.MUSTRU_HOME + Constants.fs + "data" + Constants.fs + "bdb");
  GridData dbTextGd = new GridData(); dbTextGd.horizontalAlignment = GridData.BEGINNING;
  dbTextGd.minimumWidth = 350; dbTextGd.grabExcessHorizontalSpace = true;
  dbText.setEditable(false);
  dbText.setLayoutData(dbTextGd);

  Button dbButton = new Button(composite, SWT.PUSH); dbButton.setText("Browse");
  GridData dbButtonGd = new GridData(); dbButtonGd.horizontalAlignment = GridData.BEGINNING;
  dbButtonGd.grabExcessHorizontalSpace = false;
  dbButton.setLayoutData(dbButtonGd);
  dbButton.addListener( SWT.Selection, new Listener() {
   public void handleEvent(Event e)
   {
    DirectoryDialog dd = new DirectoryDialog(composite.getShell());
    dd.setMessage("Please select the Berekeley DB directory");
    String dir = dd.open();
    if (dir != null
    { dbText.setText(dir); ( (CrawlConfigWizard) getWizard() ).crawlConfig.setDbDir(dir); }
   }
  });

  //*-- description of the Berkeley DB dir.
  GridData dbDescrGd = new GridData(); dbDescrGd.grabExcessHorizontalSpace = true;
  dbDescrGd.horizontalAlignment = GridData.FILL; dbDescrGd.horizontalSpan = 3;
  dbDescrGd.widthHint = 350;
  Text dbDescrText = new Text(composite,  SWT.LEFT | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
  dbDescrText.setEditable(false);
  dbDescrText.setText("The Berkeley database directory contains the log and data files for the database. " + Constants.NEWLINE +
  "For a large database, there will be many files and sufficient space will be required in this directory.");
  dbDescrText.setLayoutData(dbDescrGd);

  //*-- add the web directory selector
  GridData webGd = new GridData(); webGd.grabExcessHorizontalSpace = false; webGd.horizontalAlignment = GridData.FILL;
  CLabel webLabel = new CLabel(composite, SWT.LEFT); webLabel.setText("Web Server Root dir.: ");
  webLabel.setBackground( labelColors, new int[] {100} );
  webLabel.setLayoutData(dbGd);

  final Text webText = new Text(composite, SWT.SINGLE | SWT.BORDER);
  webText.setText( ( (CrawlConfigWizard) getWizard() ).crawlConfig.getWebDir() );
  GridData webTextGd = new GridData(); webTextGd.horizontalAlignment = GridData.BEGINNING;
  webTextGd.minimumWidth = 350; webTextGd.grabExcessHorizontalSpace = true;
  webText.setEditable(false);
  webText.setLayoutData(webTextGd);

  Button webButton = new Button(composite, SWT.PUSH); webButton.setText("Browse");
  GridData webButtonGd = new GridData(); webButtonGd.horizontalAlignment = GridData.BEGINNING;
  webButtonGd.grabExcessHorizontalSpace = false;
  webButton.setLayoutData(dbButtonGd);
  webButton.addListener( SWT.Selection, new Listener() {
   public void handleEvent(Event e)
   {
    DirectoryDialog dd = new DirectoryDialog(composite.getShell());
    dd.setMessage("Please select the Web server root directory");
    String dir = dd.open();
View Full Code Here

    mDirectoryField.setText(fGlobalScope
        .getString(DefaultPreferences.PODCAST_DIRECTORY));

    Button folderButton = new Button(autoReloadContainer, SWT.PUSH);
    folderButton.setText(Messages.getString("general.browse"));
    folderButton.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        String lPath = mDirectoryField.getText();
        Shell lShell = OwlUI.getPrimaryShell();
        DirectoryDialog dialog = new DirectoryDialog(lShell, SWT.OPEN);
        dialog.setFilterPath(lPath);
View Full Code Here

    }

    /* Specially treat News-State */
    if (field.getId() == INews.STATE) {
      final StateConditionControl stateConditionControl = new StateConditionControl(inputField, SWT.NONE);
      stateConditionControl.addListener(SWT.Modify, new Listener() {
        public void handleEvent(Event event) {
          fInputValue = stateConditionControl.getSelection();

          if (fInputValue == null && input != null || (fInputValue != null && !fInputValue.equals(input)))
            fModified = true;
        }
      });

      /* Pre-Select input if given */
      Object presetInput = (input == null) ? fInputValue : input;
      if (presetInput != null && presetInput instanceof EnumSet)
        stateConditionControl.select((EnumSet<State>) presetInput);

      /* Update Input Value */
      fInputValue = stateConditionControl.getSelection();
    }

    /* Specially treat News-Location */
    else if (field.getId() == INews.LOCATION) {
      final LocationConditionControl locationConditionControl = new LocationConditionControl(inputField, SWT.NONE);
      locationConditionControl.addListener(SWT.Modify, new Listener() {
        public void handleEvent(Event event) {
          fInputValue = locationConditionControl.getSelection();

          if (fInputValue == null && input != null || (fInputValue != null && !fInputValue.equals(input)))
            fModified = true;
        }
      });

      /* Pre-Select input if given */
      Object presetInput = (input == null) ? fInputValue : input;
      if (presetInput != null && presetInput instanceof Long[][])
        locationConditionControl.select((Long[][]) presetInput);

      /* Update Input Value */
      fInputValue = locationConditionControl.getSelection();
    }

    /* Create new Input Field based on search-value-type */
    else {
      switch (field.getSearchValueType().getId()) {

        /* Type: Boolean */
        case ISearchValueType.BOOLEAN: {
          final Combo combo = new Combo(inputField, SWT.BORDER | SWT.READ_ONLY);
          combo.add("true");
          combo.add("false");
          combo.addListener(SWT.Modify, new Listener() {
            public void handleEvent(Event event) {
              fInputValue = Boolean.valueOf(combo.getItem(combo.getSelectionIndex()));

              if (!fInputValue.equals(input))
                fModified = true;
            }
          });

          /* Pre-Select input if given */
          Object presetInput = (input == null) ? fInputValue : input;
          if (presetInput != null && presetInput instanceof Boolean)
            combo.select(((Boolean) presetInput) ? 0 : 1);
          else
            combo.select(0);

          /* Update Input Value */
          fInputValue = Boolean.valueOf(combo.getItem(combo.getSelectionIndex()));

          break;
        }

          /* Type: Date / Time */
        case ISearchValueType.DATE:
        case ISearchValueType.TIME:
        case ISearchValueType.DATETIME: {
          final Calendar cal = Calendar.getInstance();
          final DateTime datetime = new DateTime(inputField, SWT.DATE);
          datetime.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event event) {
              cal.set(Calendar.DATE, datetime.getDay());
              cal.set(Calendar.MONTH, datetime.getMonth());
              cal.set(Calendar.YEAR, datetime.getYear());

              fInputValue = cal.getTime();

              if (!fInputValue.equals(input))
                fModified = true;
            }
          });

          /* Pre-Select input if given */
          Object presetInput = (input == null) ? fInputValue : input;
          if (presetInput != null && presetInput instanceof Date)
            cal.setTime((Date) presetInput);

          datetime.setDay(cal.get(Calendar.DATE));
          datetime.setMonth(cal.get(Calendar.MONTH));
          datetime.setYear(cal.get(Calendar.YEAR));

          /* Update Input Value */
          fInputValue = cal.getTime();

          break;
        }

          /* Type: Enumeration */
        case ISearchValueType.ENUM: {
          final Text text = new Text(inputField, SWT.BORDER);
          text.addListener(SWT.Modify, new Listener() {
            public void handleEvent(Event event) {
              fInputValue = text.getText();

              if (!fInputValue.equals(input))
                fModified = true;
            }
          });

          /* Provide Auto-Complete Field */
          hookAutoComplete(text, field.getSearchValueType().getEnumValues());

          /* Show UI Hint that Content Assist is available */
          ControlDecoration controlDeco = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
          controlDeco.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage());
          controlDeco.setDescriptionText("Content Assist Available (Press Arrow-Down Key)");
          controlDeco.setShowOnlyOnFocus(true);

          /* Pre-Select input if given */
          String inputValue = (input != null ? input.toString() : null);
          if (inputValue != null)
            text.setText(inputValue);

          /* Update Input Value */
          fInputValue = text.getText();

          break;
        }

          /* Type: Number */
        case ISearchValueType.NUMBER:
        case ISearchValueType.INTEGER: {
          final Spinner spinner = new Spinner(inputField, SWT.BORDER);
          spinner.setMinimum(0);
          spinner.setMaximum(1000);
          spinner.addListener(SWT.Modify, new Listener() {
            public void handleEvent(Event event) {
              fInputValue = spinner.getSelection();

              if (!fInputValue.equals(input))
                fModified = true;
            }
          });

          /* Pre-Select input if given */
          Object presetInput = (input == null) ? fInputValue : input;
          if (presetInput != null && presetInput instanceof Integer)
            spinner.setSelection((Integer) presetInput);

          /* Update Input Value */
          fInputValue = spinner.getSelection();

          break;
        }

          /* Type: String */
        case ISearchValueType.STRING:
        case ISearchValueType.LINK: {
          final Text text = new Text(inputField, SWT.BORDER);
          text.addListener(SWT.Modify, new Listener() {
            public void handleEvent(Event event) {
              fInputValue = text.getText();

              if (!fInputValue.equals(input))
                fModified = true;
View Full Code Here

      }
    };
    shell.addShellListener(fTrayShellListener);

    /* Show Menu on Selection */
    fTrayItem.addListener(SWT.MenuDetect, new Listener() {
      public void handleEvent(Event event) {
        MenuManager trayMenu = new MenuManager();

        /* Restore */
        trayMenu.add(new ContributionItem() {
          @Override
          public void fill(Menu menu, int index) {
            MenuItem restoreItem = new MenuItem(menu, SWT.PUSH);
            restoreItem.setText("Restore");
            restoreItem.addSelectionListener(new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                restoreFromTray(shell);
              }
            });
            menu.setDefaultItem(restoreItem);
          }
        });

        /* Separator */
        trayMenu.add(new Separator());

        /* Other Items */
        fActionBarAdvisor.fillTrayItem(trayMenu);

        Menu menu = trayMenu.createContextMenu(shell);
        menu.setVisible(true);
      }
    });

    /* Handle DefaultSelection */
    fTrayItem.addListener(SWT.DefaultSelection, new Listener() {
      public void handleEvent(Event event) {

        /* Restore from Tray */
        if (!shell.isVisible())
          restoreFromTray(shell);
View Full Code Here

      getWindowConfigurer().getWindow().getShell().removeShellListener(fTrayShellListener);
  }

  /* Support for focusless scrolling */
  private void hookFocuslessScrolling(final Display display) {
    display.addFilter(SWT.MouseWheel, new Listener() {
      public void handleEvent(Event event) {
        Control control = display.getCursorControl();

        /* Control must be non-focus undisposed */
        if (control == null || control.isDisposed() || control.isFocusControl())
View Full Code Here

        onMouseDoubleClick(event);
      }
    });

    /* Perform Action on Mouse-Down */
    fViewer.getControl().addListener(SWT.MouseDown, new Listener() {
      public void handleEvent(Event event) {
        onMouseDown(event);
      }
    });

    /* Update Cursor on Mouse-Move */
    fViewer.getControl().addListener(SWT.MouseMove, new Listener() {
      public void handleEvent(Event event) {
        onMouseMove(event);
      }
    });

View Full Code Here

    addButton.setToolTipText("Add Condition");

    /* Add Menu */
    final Menu conditionMenu = new Menu(buttonBar);
    createConditionMenu(conditionMenu, item);
    addButton.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        if (event.detail == SWT.ARROW) {
          Rectangle rect = item.getBounds();
          Point pt = new Point(rect.x, rect.y + rect.height);
          pt = buttonBar.toDisplay(pt);
View Full Code Here

   * @param parent
   * @param style
   */
  public CTree(Composite parent, int style) {
    fTree = new Tree(parent, style);
    parent.addListener(SWT.Resize, new Listener() {
      public void handleEvent(Event event) {
        onTreeResize();
      }
    });
  }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.Listener

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.