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

The following examples show how to use org.eclipse.swt.SWT#SEARCH . 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 File: SearchText.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected Control createControl(Composite parent) {
	parent.getParent().setRedraw(true); // fix tool-bar size on Windows
	parent.setLayout(new FillLayout());
	log.trace("create search text control");
	Composite composite = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 2;
	layout.horizontalSpacing = 5;
	layout.marginHeight = 0;
	layout.marginWidth = 5;
	layout.verticalSpacing = 0;
	composite.setLayout(layout);
	text = new Text(composite, SWT.BORDER | SWT.SEARCH);
	text.addTraverseListener(e -> {
		if (e.detail == SWT.TRAVERSE_RETURN) {
			doSearch(action.typeFilter);
		}
	});
	UI.gridData(text, true, false).minimumWidth = 180;
	createActionMenu(composite);
	return composite;
}
 
Example 2
Source File: AbapGitStagingView.java    From ADT_Frontend with 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
Source File: AbapGitView.java    From ADT_Frontend with MIT License 6 votes vote down vote up
private void setupFilterBox(Composite parent) {
	//Create Filter Text Box
	this.searchText = new Text(parent, SWT.SEARCH | SWT.CANCEL);
	this.searchText.setMessage(Messages.AbapGitView_Type_Filter_Text);
	this.searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));

	//Add Listener to the Filter Text Box
	this.searchText.addModifyListener(new ModifyListener() {

		@Override
		public void modifyText(ModifyEvent e) {
			AbapGitView.this.tableFilter.setSearchText(AbapGitView.this.searchText.getText());
			AbapGitView.this.viewer.refresh();
		}
	});

}
 
Example 4
Source File: MenuPage.java    From EasyShell with Eclipse Public License 2.0 6 votes vote down vote up
private void createSearchField(Composite parent) {
    //Label searchLabel = new Label(parent, SWT.NONE);
    //searchLabel.setText("Search: ");
    filter = new MenuDataFilter();
    searchText = new Text(parent, SWT.BORDER | SWT.SEARCH);
    searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
        | GridData.HORIZONTAL_ALIGN_FILL));
    searchText.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
          filter.setSearchText(searchText.getText());
          refreshTableViewer();
        }

    });
    searchText.setToolTipText(Activator.getResourceString("easyshell.command.page.text.tooltip.search"));
    // fake
    Label label = new Label(parent, SWT.NONE);
    label.setText("");
}
 
Example 5
Source File: CommandPage.java    From EasyShell with Eclipse Public License 2.0 6 votes vote down vote up
private void createSearchField(Composite parent) {
    //Label searchLabel = new Label(parent, SWT.NONE);
    //searchLabel.setText("Search: ");
    filter = new CommandDataFilter();
    searchText = new Text(parent, SWT.BORDER | SWT.SEARCH);
    searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
        | GridData.HORIZONTAL_ALIGN_FILL));
    searchText.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
          filter.setSearchText(searchText.getText());
          tableViewer.refresh();
        }

    });
    searchText.setToolTipText(Activator.getResourceString("easyshell.command.page.text.tooltip.search"));
    // fake
    Label label = new Label(parent, SWT.NONE);
    label.setText("");
}
 
Example 6
Source File: ManageJarDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createSearchText(final Composite composite) {
    searchText = new Text(composite, SWT.SEARCH | SWT.ICON_SEARCH | SWT.BORDER | SWT.CANCEL);
    searchText.setMessage(Messages.search);
    searchText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    searchFilter = new ViewerFilter() {

        @Override
        public boolean select(final Viewer arg0, final Object arg1, final Object element) {
            if (!searchText.getText().isEmpty()) {
                final String searchQuery = searchText.getText().toLowerCase();
                final IRepositoryFileStore file = (IRepositoryFileStore) element;
                return file.getName().toLowerCase().contains(searchQuery);
            }
            return true;
        }
    };

    searchText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            tableViewer.refresh();
        }
    });
}
 
Example 7
Source File: FileStoreSelectDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
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 8
Source File: MenuDataDialog.java    From EasyShell with Eclipse Public License 2.0 5 votes vote down vote up
private void createSearchField(Composite parent) {
    UtilsUI.createLabel(parent, Activator.getResourceString("easyshell.menu.editor.dialog.label.text.filter"), Activator.getResourceString("easyshell.menu.editor.dialog.label.tooltip.filter"));
    filter = new CommandDataFilter();
    searchText = new Text(parent, SWT.BORDER | SWT.SEARCH);
    searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    searchText.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
          filter.setSearchText(searchText.getText());
          commandComboViewer.getViewer().refresh();
          commandComboViewer.getViewer().getCombo().select(0);
          commandComboViewer.setSelection(getFirstSelected());
        }
    });
    searchText.setToolTipText(Activator.getResourceString("easyshell.command.page.text.tooltip.search"));
}
 
Example 9
Source File: GamlQuickOutlinePopup.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Text createFilterText(final Composite parent) {
	final Text filterText = new Text(parent, SWT.SEARCH | SWT.ICON_SEARCH);
	filterText.setMessage("Search keyword");
	Dialog.applyDialogFont(filterText);

	final GridData data = new GridData(GridData.FILL_HORIZONTAL);
	data.horizontalAlignment = GridData.FILL;
	data.verticalAlignment = GridData.CENTER;
	filterText.setLayoutData(data);

	filterText.addKeyListener(new KeyAdapter() {
		@Override
		public void keyPressed(final KeyEvent e) {
			if (e.keyCode == 0x0D) {
				gotoSelectedElement();
			}
			if (e.keyCode == SWT.ARROW_DOWN) {
				getTreeViewer().getTree().setFocus();
			}
			if (e.keyCode == SWT.ARROW_UP) {
				getTreeViewer().getTree().setFocus();
			}
			if (e.character == 0x1B) {
				dispose();
			}
		}
	});
	return filterText;
}
 
Example 10
Source File: MigrationStatusView.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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 11
Source File: GamlSearchField.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
private Text createText(final Composite parent) {
	final Text text = new Text(parent, SWT.SEARCH | SWT.ICON_SEARCH);
	final String message = "GAML reference (" + GamaKeyBindings.SEARCH_STRING + ")";
	text.setMessage(message);
	return text;
}
 
Example 12
Source File: TreeToolbar.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public TreeToolbar( Composite composite, int i ) {
  super( composite, i );

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;

  this.setLayout( formLayout );

  Label sep3 = new Label( this, SWT.SEPARATOR | SWT.HORIZONTAL );
  sep3.setBackground( GUIResource.getInstance().getColorWhite() );
  FormData fdSep3 = new FormData();
  fdSep3.left = new FormAttachment( 0, 0 );
  fdSep3.right = new FormAttachment( 100, 0 );
  fdSep3.top = new FormAttachment( 0 );
  sep3.setLayoutData( fdSep3 );

  ToolBar treeTb = new ToolBar( this, SWT.HORIZONTAL | SWT.FLAT );
  props.setLook( treeTb, Props.WIDGET_STYLE_TOOLBAR );
  /*
  This contains a map with all the unnamed transformation (just a filename)
 */
  expandAll = new ToolItem( treeTb, SWT.PUSH );
  expandAll.setImage( GUIResource.getInstance().getImageExpandAll() );
  collapseAll = new ToolItem( treeTb, SWT.PUSH );
  collapseAll.setImage( GUIResource.getInstance().getImageCollapseAll() );

  FormData fdTreeToolbar = new FormData();
  if ( Const.isLinux() ) {
    fdTreeToolbar.top = new FormAttachment( sep3, 3 );
  } else {
    fdTreeToolbar.top = new FormAttachment( sep3, 5 );
  }
  fdTreeToolbar.right = new FormAttachment( 100, -10 );
  treeTb.setLayoutData( fdTreeToolbar );

  ToolBar selectionFilterTb = new ToolBar( this, SWT.HORIZONTAL | SWT.FLAT );
  props.setLook( selectionFilterTb, Props.WIDGET_STYLE_TOOLBAR );

  ToolItem clearSelectionFilter = new ToolItem( selectionFilterTb, SWT.PUSH );
  clearSelectionFilter.setImage( GUIResource.getInstance().getImageClearText() );
  clearSelectionFilter.setDisabledImage( GUIResource.getInstance().getImageClearTextDisabled() );

  FormData fdSelectionFilterToolbar = new FormData();
  if ( Const.isLinux() ) {
    fdSelectionFilterToolbar.top = new FormAttachment( sep3, 3 );
  } else {
    fdSelectionFilterToolbar.top = new FormAttachment( sep3, 5 );
  }
  fdSelectionFilterToolbar.right = new FormAttachment( treeTb, -20 );
  selectionFilterTb.setLayoutData( fdSelectionFilterToolbar );

  selectionFilter = new Text( this, SWT.SINGLE | SWT.BORDER | SWT.LEFT | SWT.SEARCH );
  FormData fdSelectionFilter = new FormData();
  int offset = -( GUIResource.getInstance().getImageClearTextDisabled().getBounds().height + 6 );
  if ( Const.isLinux() ) {
    offset = -( GUIResource.getInstance().getImageClearTextDisabled().getBounds().height + 13 );
  }

  fdSelectionFilter.top = new FormAttachment( selectionFilterTb, offset );
  fdSelectionFilter.right = new FormAttachment( selectionFilterTb, 0 );
  fdSelectionFilter.left = new FormAttachment( 0, 10 );
  selectionFilter.setLayoutData( fdSelectionFilter );

  clearSelectionFilter.addSelectionListener( new SelectionAdapter() {
    @Override
    public void widgetSelected( SelectionEvent event ) {
      selectionFilter.setText( "" );
    }
  } );

  clearSelectionFilter.setEnabled( !Utils.isEmpty( selectionFilter.getText() ) );

  selectionFilter.addModifyListener( modifyEvent -> {
    clearSelectionFilter.setEnabled( !Utils.isEmpty( selectionFilter.getText() ) );
  } );

  Label sep4 = new Label( this, SWT.SEPARATOR | SWT.HORIZONTAL );
  sep4.setBackground( GUIResource.getInstance().getColorWhite() );
  FormData fdSep4 = new FormData();
  fdSep4.left = new FormAttachment( 0, 0 );
  fdSep4.right = new FormAttachment( 100, 0 );
  fdSep4.top = new FormAttachment( treeTb, 5 );
  sep4.setLayoutData( fdSep4 );
}
 
Example 13
Source File: ContactSelectorView.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void createPartControl(Composite parent){
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout(1, false));
	
	Composite compositeSearch = new Composite(composite, SWT.NONE);
	compositeSearch.setLayout(new GridLayout(1, false));
	compositeSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	txtFilter = new Text(compositeSearch, SWT.BORDER | SWT.SEARCH | SWT.CANCEL);
	txtFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	tableViewerContacts = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
	Table table = tableViewerContacts.getTable();
	table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	
	Composite compositeStatus = new Composite(composite, SWT.NONE);
	compositeStatus.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	compositeStatus.setLayout(new GridLayout(1, false));
	
	lblStatus = new Label(compositeStatus, SWT.NONE);
	lblStatus.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	tableViewerContacts.setComparator(new ContactSelectorViewerComparator(tableViewerContacts));
	filterAnzeigeTyp = new KontaktAnzeigeTypViewerFilter(tableViewerContacts);
	ViewerFilter[] filters = new ViewerFilter[] {
		filterAnzeigeTyp, filterPositionTitle
	};
	tableViewerContacts.setFilters(filters);
	
	int operations = DND.DROP_COPY | DND.DROP_MOVE;
	Transfer[] transferTypes = new Transfer[] {
		TextTransfer.getInstance()
	};
	tableViewerContacts.addDragSupport(operations, transferTypes,
		new ContactSelectorDragListener(tableViewerContacts));
	tableViewerContacts.addDropSupport(operations, transferTypes,
		new ContactSelectorDropListener(tableViewerContacts));
	
	txtFilter.addKeyListener(new FilterKeyListener(txtFilter, tableViewerContacts));
	txtFilter.addSelectionListener(new SelectionAdapter() {
		public void widgetDefaultSelected(SelectionEvent e){
			if (e.detail == SWT.CANCEL) {
				filterPositionTitle.setSearchText(null);
				tableViewerContacts.getControl().setRedraw(false);
				tableViewerContacts.refresh();
				tableViewerContacts.getControl().setRedraw(true);
			}
		}
	});
	
	initDataBindings();
	
	MenuManager menuManager = new MenuManager();
	menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
	tableViewerContacts.getTable().setMenu(
		menuManager.createContextMenu(tableViewerContacts.getTable()));
	
	getSite().registerContextMenu(menuManager, tableViewerContacts);
	getSite().setSelectionProvider(tableViewerContacts);
	
	contactList.getRealm().asyncExec(loadContactsRunnable);
	
	tableViewerContacts
		.addSelectionChangedListener(new ContactSelectionChangedToEventDispatcher());
	tableViewerContacts.addSelectionChangedListener(new ISelectionChangedListener() {
		
		@Override
		public void selectionChanged(SelectionChangedEvent event){
			StructuredSelection ss = (StructuredSelection) event.getSelection();
			tableViewerContacts.refresh(ss.getFirstElement());
		}
	});
}
 
Example 14
Source File: DBConnectorsPreferencePage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
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 15
Source File: AbstractOrganizationWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected StructuredViewer createViewer(final Composite parent) {
    final Composite viewerComposite = new Composite(parent, SWT.NONE);
    viewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewerComposite.setLayout(
            GridLayoutFactory.fillDefaults().numColumns(1).equalWidth(true).margins(0, 0).spacing(0, 5).create());

    final Text searchBox = new Text(viewerComposite, SWT.SEARCH | SWT.ICON_SEARCH | SWT.BORDER | SWT.CANCEL);
    searchBox.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    searchBox.setMessage(Messages.search);

    final Composite tableViewerComposite = new Composite(viewerComposite, SWT.NONE);
    tableViewerComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create());
    tableViewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final TableViewer tableViewer = new TableViewer(tableViewerComposite,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    final Table table = tableViewer.getTable();
    table.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 270).create());
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
            return viewerSelect(element, searchQuery);
        }
    });

    searchBox.addModifyListener(new ModifyListener() {

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

    });

    return tableViewer;
}
 
Example 16
Source File: ManageConnectorJarDialog.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void createTree(Composite composite) {
	final Text searchText = new Text(composite,SWT.SEARCH | SWT.ICON_SEARCH | SWT.BORDER | SWT.CANCEL) ;
	searchText.setMessage(Messages.search) ;
	searchText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()) ;

	searchFilter = new ViewerFilter() {

		@Override
		public boolean select(Viewer arg0, Object arg1, Object element) {
			if(!searchText.getText().isEmpty()){
				String searchQuery = searchText.getText().toLowerCase() ;
				IRepositoryFileStore file = (IRepositoryFileStore) element ;
				return file.getName().toLowerCase().contains(searchQuery) ;
			}
			return true;
		}
	};

	//new Label(composite,SWT.NONE) ; //FILLER

	languageViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL) ;
	languageViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 190).create()) ;
	languageViewer.getTable().setLinesVisible(true) ;
	languageViewer.getTable().setHeaderVisible(false) ;
	final TableLayout layout = new TableLayout() ;
	layout.addColumnData(new ColumnWeightData(65)) ;
	languageViewer.getTable().setLayout(layout) ;
	languageViewer.setContentProvider(new ArrayContentProvider()) ;
	languageViewer.setLabelProvider(new FileStoreLabelProvider()) ;
	languageViewer.addFilter(searchFilter) ;
	if(filter != null){
		languageViewer.addFilter(filter);
	}
	languageViewer.setInput(libStore.getChildren()) ;
	languageViewer.getTable().setFocus() ;


	searchText.addModifyListener(new ModifyListener() {

		@Override
		public void modifyText(ModifyEvent e) {
			languageViewer.refresh() ;
		}
	}) ;

}
 
Example 17
Source File: TreeToolbar.java    From hop with Apache License 2.0 4 votes vote down vote up
public TreeToolbar( Composite composite, int i ) {
  super( composite, i );

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;

  this.setLayout( formLayout );

  Label sep3 = new Label( this, SWT.SEPARATOR | SWT.HORIZONTAL );
  sep3.setBackground( GuiResource.getInstance().getColorWhite() );
  FormData fdSep3 = new FormData();
  fdSep3.left = new FormAttachment( 0, 0 );
  fdSep3.right = new FormAttachment( 100, 0 );
  fdSep3.top = new FormAttachment( 0 );
  sep3.setLayoutData( fdSep3 );

  ToolBar treeTb = new ToolBar( this, SWT.HORIZONTAL | SWT.FLAT );
  props.setLook( treeTb, Props.WIDGET_STYLE_TOOLBAR );
  /*
  This contains a map with all the unnamed pipeline (just a filename)
 */
  expandAll = new ToolItem( treeTb, SWT.PUSH );
  expandAll.setImage( GuiResource.getInstance().getImageExpandAll() );
  collapseAll = new ToolItem( treeTb, SWT.PUSH );
  collapseAll.setImage( GuiResource.getInstance().getImageCollapseAll() );

  FormData fdTreeToolbar = new FormData();
  if ( Const.isLinux() ) {
    fdTreeToolbar.top = new FormAttachment( sep3, 3 );
  } else {
    fdTreeToolbar.top = new FormAttachment( sep3, 5 );
  }
  fdTreeToolbar.right = new FormAttachment( 100, -10 );
  treeTb.setLayoutData( fdTreeToolbar );

  ToolBar selectionFilterTb = new ToolBar( this, SWT.HORIZONTAL | SWT.FLAT );
  props.setLook( selectionFilterTb, Props.WIDGET_STYLE_TOOLBAR );

  ToolItem clearSelectionFilter = new ToolItem( selectionFilterTb, SWT.PUSH );
  clearSelectionFilter.setImage( GuiResource.getInstance().getImageClearText() );
  clearSelectionFilter.setDisabledImage( GuiResource.getInstance().getImageClearTextDisabled() );

  FormData fdSelectionFilterToolbar = new FormData();
  if ( Const.isLinux() ) {
    fdSelectionFilterToolbar.top = new FormAttachment( sep3, 3 );
  } else {
    fdSelectionFilterToolbar.top = new FormAttachment( sep3, 5 );
  }
  fdSelectionFilterToolbar.right = new FormAttachment( treeTb, -20 );
  selectionFilterTb.setLayoutData( fdSelectionFilterToolbar );

  selectionFilter = new Text( this, SWT.SINGLE | SWT.BORDER | SWT.LEFT | SWT.SEARCH );
  FormData fdSelectionFilter = new FormData();
  int offset = -( GuiResource.getInstance().getImageClearTextDisabled().getBounds().height + 6 );
  if ( Const.isLinux() ) {
    offset = -( GuiResource.getInstance().getImageClearTextDisabled().getBounds().height + 13 );
  }

  fdSelectionFilter.top = new FormAttachment( selectionFilterTb, offset );
  fdSelectionFilter.right = new FormAttachment( selectionFilterTb, 0 );
  fdSelectionFilter.left = new FormAttachment( 0, 10 );
  selectionFilter.setLayoutData( fdSelectionFilter );

  clearSelectionFilter.addSelectionListener( new SelectionAdapter() {
    @Override
    public void widgetSelected( SelectionEvent event ) {
      selectionFilter.setText( "" );
    }
  } );

  clearSelectionFilter.setEnabled( !Utils.isEmpty( selectionFilter.getText() ) );

  selectionFilter.addModifyListener( modifyEvent -> {
    clearSelectionFilter.setEnabled( !Utils.isEmpty( selectionFilter.getText() ) );
  } );

  Label sep4 = new Label( this, SWT.SEPARATOR | SWT.HORIZONTAL );
  sep4.setBackground( GuiResource.getInstance().getColorWhite() );
  FormData fdSep4 = new FormData();
  fdSep4.left = new FormAttachment( 0, 0 );
  fdSep4.right = new FormAttachment( 100, 0 );
  fdSep4.top = new FormAttachment( treeTb, 5 );
  sep4.setLayoutData( fdSep4 );
}
 
Example 18
Source File: AppEngineDeployPreferencesPanel.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
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 19
Source File: XFilteredTree.java    From nebula with 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);
}
 
Example 20
Source File: FilteredTreeComposite.java    From nebula with Eclipse Public License 2.0 2 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) {
   return new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.CANCEL);
}