Java Code Examples for org.eclipse.swt.SWT#ICON_CANCEL

The following examples show how to use org.eclipse.swt.SWT#ICON_CANCEL . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: nebula   File: XFilteredTree.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create the button that clears the text.
 *
 * @param parent parent <code>Composite</code> of toolbar button
 */
private void createClearTextOld(Composite parent) {
   // only create the button if the text widget doesn't support one
   // natively
   if ((filterText.getStyle() & SWT.ICON_CANCEL) == 0) {
      filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
      filterToolBar.createControl(parent);

      IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$
            /**
             * @see org.eclipse.jface.action.Action#run()
             */
            @Override
            public void run() {
               clearText();
            }
         };

      clearTextAction.setToolTipText(XViewerText.get("button.clear")); //$NON-NLS-1$
      clearTextAction.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON));
      clearTextAction.setDisabledImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(DISABLED_CLEAR_ICON));

      filterToolBar.add(clearTextAction);
   }
}
 
Example 2
Source Project: ADT_Frontend   File: AbapGitStagingView.java    License: MIT License 6 votes vote down vote up
/**
 * Adds a filter text box in the view toolbar
 */
private ControlContribution createObjectsFilterText() {
	//create filter text composite
	ControlContribution filterTextboxContribution = new ControlContribution("AbapGitStagingView.filterText") { //$NON-NLS-1$
		protected Control createControl(Composite parent) {
			Composite filterComposite = AbapGitStagingView.this.toolkit.createComposite(parent, 0);
			GridLayoutFactory.fillDefaults().numColumns(2).applyTo(filterComposite);
			filterComposite.setBackground(null);

			AbapGitStagingView.this.filterText = new Text(filterComposite, SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH);
			AbapGitStagingView.this.filterText.setMessage(Messages.AbapGitStaging_object_filter_text);
			GridData data = new GridData(SWT.LEFT, SWT.TOP, true, false);
			data.minimumWidth = 150;
			AbapGitStagingView.this.filterText.setLayoutData(data);

			AbapGitStagingView.this.filterText.addModifyListener(e -> applyFilter());
			return filterComposite;
		}
	};
	return filterTextboxContribution;
}
 
Example 3
private void createFilter(final Composite listComposite) {
    final Text fileStoreListFilter = new Text(listComposite,
            SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    fileStoreListFilter.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    fileStoreListFilter.setMessage(WorkbenchMessages.FilteredTree_FilterMessage);
    fileStoreListFilter.addModifyListener(new ModifyListener() {

        private ViewerFilter filter;

        @Override
        public void modifyText(final ModifyEvent e) {
            final String textForFiltering = fileStoreListFilter.getText();
            if (filter != null) {
                fileStoreListViewer.removeFilter(filter);
            }
            if (textForFiltering != null
                    && !textForFiltering.isEmpty()) {
                filter = new ViewerFilterOnFileStoreName(textForFiltering);
                fileStoreListViewer.addFilter(filter);
            }

        }
    });
}
 
Example 4
protected void createFilterComposite(final Composite topComposite) {
    final Text findText = new Text(topComposite, SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH);
    findText.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).align(SWT.RIGHT, SWT.CENTER).hint(150, SWT.DEFAULT).create());
    findText.setMessage(Messages.find);
    findText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            searchQuery = findText.getText();
            tableViewer.refresh();

        }
    });
}
 
Example 5
private void createProjectIdSection() {
  Label projectIdLabel = new Label(this, SWT.LEAD);
  projectIdLabel.setText(Messages.getString("project"));
  projectIdLabel.setToolTipText(Messages.getString("tooltip.project.id"));
  GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).span(1, 2)
      .applyTo(projectIdLabel);

  Composite linkComposite = new Composite(this, SWT.NONE);
  Link createNewProject = new Link(linkComposite, SWT.WRAP);
  createNewProject.setText(Messages.getString("projectselector.createproject",
                                              CREATE_GCP_PROJECT_URL));
  createNewProject.setToolTipText(Messages.getString("projectselector.createproject.tooltip"));
  FontUtil.convertFontToItalic(createNewProject);
  createNewProject.addSelectionListener(new OpenUriSelectionListener(
      () -> accountSelector.getSelectedEmail().isEmpty()
          ? Collections.emptyMap()
          : Collections.singletonMap("authuser", accountSelector.getSelectedEmail()),
      new ErrorDialogErrorHandler(getShell())));
  GridDataFactory.fillDefaults().applyTo(linkComposite);
  GridLayoutFactory.fillDefaults().generateLayout(linkComposite);

  Composite projectSelectorComposite = new Composite(this, SWT.NONE);
  GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(projectSelectorComposite);
  GridDataFactory.fillDefaults().grab(true, false).applyTo(projectSelectorComposite);

  final Text filterField = new Text(projectSelectorComposite,
      SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
  filterField.setMessage(Messages.getString("projectselector.filter"));
  GridDataFactory.fillDefaults().applyTo(filterField);

  new Label(projectSelectorComposite, SWT.NONE); // spacer

  projectSelector = new ProjectSelector(projectSelectorComposite);
  GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 200)
      .applyTo(projectSelector);

  final Button refreshProjectsButton = new Button(projectSelectorComposite, SWT.NONE);
  refreshProjectsButton.setImage(refreshIcon);
  GridDataFactory.swtDefaults().align(SWT.END, SWT.BEGINNING).applyTo(refreshProjectsButton);
  refreshProjectsButton.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent event) {
      refreshProjectsForSelectedCredential();
    }
  });

  accountSelector.addSelectionListener(
      new RefreshProjectOnAccountSelection(refreshProjectsButton));

  projectSelector.addSelectionChangedListener(
      new ProjectSelectorSelectionChangedListener(accountSelector,
                                                  projectRepository,
                                                  projectSelector));
  filterField.addModifyListener(event -> {
    projectSelector.setFilter(filterField.getText());
  });
}
 
Example 6
private void createDBConnectorsList(Composite parent) {
    final Composite connectorListComposite = new Composite(parent, SWT.NONE);
    connectorListComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create());
    connectorListComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final Text searchField = new Text(connectorListComposite,
            SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    searchField.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    searchField.setMessage(Messages.search);
    viewer = new TableViewer(connectorListComposite, SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(false, true).hint(200, SWT.DEFAULT).create());
    viewer.setLabelProvider(new DabaBaseConnectorDefinitionLabelProvider());
    viewer.setContentProvider(new DatabaseConnectorDefinitionContentProvider());
    viewer.setInput(getCategory());
    connectorFilter = new DbConnectorsPreferenceFilter();
    viewer.addFilter(connectorFilter);
    searchField.addKeyListener(new KeyAdapter() {

        /*
         * (non-Javadoc)
         * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent)
         */
        @Override
        public void keyReleased(KeyEvent e) {
            connectorFilter.setSearchText(searchField.getText());
            viewer.refresh();
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            final ConnectorDefinition def = getSelectedConnector();
            if (def != null) {
                final String defId = def.getId();
                automaticallyAddDriver.setSelection(getAutoAddDriverProperty(defId));
                driversLabelProvider.setDefaultDriver(getDefaultDriver(defId));
                driverManagerViewer.setInput(defId);
            }
        }
    });
}
 
Example 7
Source Project: nebula   File: XFilteredTree.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Creates the text control for entering the filter text. Subclasses may override.
 *
 * @param parent the parent composite
 * @return the text widget
 * @since 3.3
 */
protected Text doCreateFilterText(Composite parent) {
   if (!useNewLook || useNativeSearchField(parent)) {
      return new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
   }
   return new Text(parent, SWT.SINGLE);
}