org.eclipse.swt.events.KeyAdapter Java Examples

The following examples show how to use org.eclipse.swt.events.KeyAdapter. 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: DocumentPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private ListViewer createList(final Composite mainComposite) {
    final List list = getWidgetFactory().createList(mainComposite,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    list.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final ListViewer documentListViewer = new ListViewer(list);
    documentListViewer.setLabelProvider(new ElementForIdLabelProvider());
    documentListViewer.setContentProvider(new ObservableListContentProvider());
    documentListViewer.addDoubleClickListener(this);
    documentListViewer.addSelectionChangedListener(this);
    documentListViewer.getList().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                e.doit = false;
                removeDocuments();
            }
        }
    });

    return documentListViewer;
}
 
Example #2
Source File: TextCellEditor.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
protected Text createTextControl(Composite parent) {
	IStyle cellStyle = getCellStyle();
	final Text textControl = new Text(parent, HorizontalAlignmentEnum.getSWTStyle(cellStyle));
	textControl.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
	textControl.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
	textControl.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
	
	textControl.addKeyListener(new KeyAdapter() {
		private final Color originalColor = textControl.getForeground();
		@Override
		public void keyReleased(KeyEvent e) {
			if (!validateCanonicalValue()) {
				textControl.setForeground(GUIHelper.COLOR_RED);
			} else {
				textControl.setForeground(originalColor);
			}
		};
	});
	
	return textControl;
}
 
Example #3
Source File: TypeHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private KeyListener createKeyListener() {
	return new KeyAdapter() {
		@Override
		public void keyReleased(KeyEvent event) {
			if (event.stateMask == 0) {
				if (event.keyCode == SWT.F5) {
					ITypeHierarchy hierarchy= fHierarchyLifeCycle.getHierarchy();
					if (hierarchy != null) {
						fHierarchyLifeCycle.typeHierarchyChanged(hierarchy);
						doTypeHierarchyChangedOnViewers(null);
					}
					updateHierarchyViewer(false);
					return;
				}
				}
		}
	};
}
 
Example #4
Source File: WsdlFieldPart.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
@Override
public Control createControl(Composite parent) {
	wsdlField = new LabelledFileField(parent, "WSDL:", new String[] { "*.wsdl", "*.*" }, 1, SWT.BORDER) {

		protected void setFileFieldValue(String result) {
			if (result != null) {
				setRawFieldValue(result);
			}
		}
	};

	wsdlField.getTextControl().addKeyListener(new KeyAdapter() {
		public void keyPressed(KeyEvent event) {
			switch (event.keyCode) {
			case SWT.CR:
			case SWT.KEYPAD_CR:
				refreshTriggered();
			}
		}
	});
	return wsdlField.getTextControl();
}
 
Example #5
Source File: SpecialCharacters.java    From Rel with Apache License 2.0 6 votes vote down vote up
/**
 * Create the dialog.
 * 
 * @param parent
 * @param style
 */
public SpecialCharacters(Shell parent, StyledText inputText) {
	super(parent, SWT.NONE);
	this.inputText = inputText;
	inputText.addKeyListener(new KeyAdapter() {
		@Override
		public void keyReleased(KeyEvent e) {
			// System.out.println("character = '" + e.character + "' keycode = '" +
			// (char)e.keyCode + "' " + (((e.stateMask & SWT.CTRL) != 0) ? "CTRL" : "") + "
			// " + (((e.stateMask & SWT.SHIFT) != 0) ? "SHIFT" : ""));
			for (SpecialCharacter specialCharacter : specialCharacters) {
				if (specialCharacter.matches(e)) {
					emit(specialCharacter.symbol);
					break;
				}
			}
		}
	});
}
 
Example #6
Source File: TextCellEditor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
protected Text createTextControl(Composite parent) {
	IStyle cellStyle = getCellStyle();
	final Text textControl = new Text(parent, HorizontalAlignmentEnum.getSWTStyle(cellStyle));
	textControl.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
	textControl.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
	textControl.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
	
	textControl.addKeyListener(new KeyAdapter() {
		private final Color originalColor = textControl.getForeground();
		@Override
		public void keyReleased(KeyEvent e) {
			if (!validateCanonicalValue()) {
				textControl.setForeground(GUIHelper.COLOR_RED);
			} else {
				textControl.setForeground(originalColor);
			}
		};
	});
	
	return textControl;
}
 
Example #7
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 #8
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 #9
Source File: JIDCombo.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
protected void registerListeners() {
  this.control.addKeyListener(
      new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
          switch (e.keyCode) {
            case SWT.HOME:
            case SWT.END:
            case SWT.ARROW_UP:
            case SWT.ARROW_RIGHT:
            case SWT.ARROW_DOWN:
            case SWT.ARROW_LEFT:
              // no need to update
              break;
            default:
              update();
          }
        }
      });
}
 
Example #10
Source File: NodesSearcher.java    From jbt with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the search text field (Text).
 * 
 * @param parent
 *            the Composite where the text field is placed.
 * @return the text field.
 */
private Text createTextField(Composite parent) {
	final Text textField = new Text(parent, SWT.BORDER);

	textField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

	/* If "enter" is pressed, perform the search. */
	textField.addKeyListener(new KeyAdapter() {
		public void keyPressed(KeyEvent e) {
			if (e.keyCode == SWT.CR) {
				performSearch(textField.getText());
			}
		}
	});

	return textField;
}
 
Example #11
Source File: ParameterizeTextView.java    From http4e with Apache License 2.0 6 votes vote down vote up
private StyledText buildEditorText( Composite parent){
   final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
   final HConfiguration sourceConf = new HConfiguration(HContentAssistProcessor.PARAM_PROCESSOR);
   sourceViewer.configure(sourceConf);
   sourceViewer.setDocument(DocumentUtils.createDocument1());

   sourceViewer.getControl().addKeyListener(new KeyAdapter() {

      public void keyPressed( KeyEvent e){
         // if ((e.character == ' ') && ((e.stateMask & SWT.CTRL) != 0)) {
         if (Utils.isAutoAssistInvoked(e)) {
            IContentAssistant ca = sourceConf.getContentAssistant(sourceViewer);
            ca.showPossibleCompletions();
         }
      }
   });

   return sourceViewer.getTextWidget();
}
 
Example #12
Source File: FilterAdvancedComposite.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private Text createValueText ()
{
    final Text t = new Text ( this, SWT.BORDER );
    t.setMessage ( Messages.argument );
    t.addKeyListener ( new KeyAdapter () {
        @Override
        public void keyReleased ( final KeyEvent e )
        {
            AssertionComposite.this.orCondition.updateFilter ();
        }
    } );
    final RowData rowData = new RowData ();
    rowData.width = 132;
    t.setLayoutData ( rowData );
    return t;
}
 
Example #13
Source File: FilterAdvancedComposite.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private Text createAttributeText ( final String attribute )
{
    final Text t = new Text ( this, SWT.BORDER );
    final Fields field = Fields.byField ( attribute );
    if ( field == null )
    {
        t.setEditable ( true );
        t.setMessage ( Messages.custom_field );
    }
    else
    {
        t.setEditable ( false );
        t.setText ( field.getName () );
    }
    t.addKeyListener ( new KeyAdapter () {
        @Override
        public void keyReleased ( final KeyEvent e )
        {
            AssertionComposite.this.orCondition.updateFilter ();
        };
    } );
    final RowData rowData = new RowData ();
    rowData.width = 132;
    t.setLayoutData ( rowData );
    return t;
}
 
Example #14
Source File: FilterFreeFormComposite.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private void createComponents ()
{
    final FillLayout layout = new FillLayout ( SWT.VERTICAL );
    layout.marginHeight = 12;
    layout.marginWidth = 12;
    setLayout ( layout );

    final Text filterTextField = new Text ( this, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL );
    filterTextField.setText ( this.filter );
    filterTextField.addKeyListener ( new KeyAdapter () {
        @Override
        public void keyReleased ( final KeyEvent e )
        {
            verifyFilter ( filterTextField.getText () );
        }
    } );
}
 
Example #15
Source File: MultilineFieldEditor.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Text getTextControl(Composite parent){
	if (textField == null) {
		textField = SWTHelper.createText(parent, numOfLines, flags);
		textField.setFont(parent.getFont());
		textField.addKeyListener(new KeyAdapter() {
			public void keyReleased(KeyEvent e){
				valueChanged();
			}
		});
		textField.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent event){
				textField = null;
			}
		});
	} else {
		checkParent(textField, parent);
	}
	return textField;
}
 
Example #16
Source File: SquareButton.java    From swt-bling with MIT License 6 votes vote down vote up
public DefaultButtonClickHandler(final SquareButton button) {
  button.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseUp(MouseEvent e) {
      clicked();
    }
  });
  button.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent keyEvent) {
      switch (keyEvent.character) {
        case ' ':
        case '\r':
        case '\n':
          clicked();
          break;
        default:
          break;
      }
    }
  });
}
 
Example #17
Source File: JavaBrowsingPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds the KeyListener
 */
protected void addKeyListener() {
	fViewer.getControl().addKeyListener(new KeyAdapter() {
		@Override
		public void keyReleased(KeyEvent event) {
			handleKeyReleased(event);
		}
	});
}
 
Example #18
Source File: ConnectorSection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createConnectorComposite(final Composite parent) {
    final Composite buttonsComposite = getWidgetFactory()
            .createComposite(parent);
    buttonsComposite.setLayoutData(GridDataFactory.fillDefaults()
            .grab(false, true).create());
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults()
            .numColumns(1).margins(5, 0).spacing(0, 3).create());

    createAddConnectorButton(buttonsComposite);
    updateConnectorButton = createUpdateConnectorButton(buttonsComposite);
    removeConnectorButton = createRemoveConnectorButton(buttonsComposite);
    upConnectorButton = createUpConnectorButton(buttonsComposite);
    downConnectorButton = createDownConnectorButton(buttonsComposite);
    moveButton = createMoveConnectorButton(buttonsComposite);

    tableViewer = new TableViewer(parent, GTKStyleHandler.removeBorderFlag(SWT.BORDER | SWT.MULTI
            | SWT.NO_FOCUS));
    getWidgetFactory().adapt(tableViewer.getTable(), false, false);
    tableViewer.getTable().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true)
                    .hint(SWT.DEFAULT, 120).create());

    tableViewer.addDoubleClickListener(this);
    tableViewer.addSelectionChangedListener(this);
    tableViewer.getTable().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                e.doit = false;
                removeSelectedConnectors();
            }
        }
    });
    tableViewer.setContentProvider(new EMFListFeatureTreeContentProvider(
            getConnectorFeature()));
    tableViewer.setLabelProvider(new StyledConnectorLabelProvider());
    tableViewer.addFilter(getViewerFilter());

}
 
Example #19
Source File: ParameterPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createParameterComposite(final Composite parent) {
    final Composite parameterComposite = getWidgetFactory().createComposite(parent);
    parameterComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    parameterComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());

    final Composite buttonsComposite = getWidgetFactory().createComposite(parameterComposite, SWT.NONE);
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 3).create());
    buttonsComposite.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).create());

    createAddParameterButton(buttonsComposite);
    updateButton = createUpdateParameterButton(buttonsComposite);
    createRemoveParameterButton(buttonsComposite);

    parameterTableViewer = new TableViewer(widgetFactory.createTable(parameterComposite,
            GTKStyleHandler.removeBorderFlag(SWT.BORDER | SWT.MULTI | SWT.NO_FOCUS | SWT.H_SCROLL | SWT.V_SCROLL)));
    parameterTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create());
    getWidgetFactory().adapt(parameterTableViewer.getTable(), false, false);
    parameterTableViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create());
    parameterTableViewer.setSorter(new ViewerSorter());
    parameterTableViewer.addDoubleClickListener(this);
    parameterTableViewer.addSelectionChangedListener(this);
    parameterTableViewer.getTable().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                e.doit = false;
                remove();
            }
        }
    });

    parameterTableViewer.setContentProvider(new ArrayContentProvider());
    parameterTableViewer.setLabelProvider(new ParameterStyledLabelProvider());
    ColumnViewerToolTipSupport.enableFor(parameterTableViewer, ToolTip.RECREATE);
}
 
Example #20
Source File: AggregateEditorComposite.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void placeComponents( )
{
	GridLayout layout = new GridLayout( 2, false );
	layout.horizontalSpacing = 2;
	layout.verticalSpacing = 0;
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	setLayout( layout );

	fBtnDropDown = new ToolBar( this, SWT.FLAT );
	ChartUIUtil.addScreenReaderAccessbility( fBtnDropDown, "Aggregation");
	if( fEnabled && this.isEnabled( ) )
	{
		fBtnDropDown.setToolTipText( Messages.getString("AggregateEditorComposite.Tooltip.SetAggregateFunction") ); //$NON-NLS-1$
	}
	ToolBarManager toolManager = new ToolBarManager( fBtnDropDown );
	toolManager.add( new AggregationAction( fEnabled ) );
	toolManager.update( true );
	fBtnDropDown.addMouseListener( this );

	fBtnDropDown.addKeyListener( new KeyAdapter( ) {

		public void keyReleased( KeyEvent e )
		{
			if ( e.keyCode == SWT.ARROW_DOWN )
			{
				toggleDropDown( );
			}
		}
	} );
}
 
Example #21
Source File: MoveEntryWithinListAction.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 * @param listViewerArea
 * @param areas
 * @param moveUpwards
 *            move entry upwards (true) or downwards (false) on execution
 */
public MoveEntryWithinListAction(StructuredViewer structuredViewer,
	List<String> targetCollection, boolean moveUpwards){
	this.structuredViewer = structuredViewer;
	this.targetCollection = targetCollection;
	this.moveUpwards = moveUpwards;
	
	if (moveUpwards) {
		setImageDescriptor(Images.IMG_ARROWUP.getImageDescriptor());
		setText(Messages.Leistungscodes_moveItemUp);
		setAccelerator(SWT.COMMAND + SWT.ARROW_UP);
	} else {
		setImageDescriptor(Images.IMG_ARROWDOWN.getImageDescriptor());
		setText(Messages.Leistungscodes_moveItemDown);
		setAccelerator(SWT.COMMAND + SWT.ARROW_DOWN);
	}
	
	structuredViewer.getControl().addKeyListener(new KeyAdapter() {
		@Override
		public void keyPressed(KeyEvent e){
			if (e.stateMask == SWT.COMMAND && e.keyCode == SWT.ARROW_UP && moveUpwards) {
				run();
				e.doit = false;
			} else if (e.stateMask == SWT.COMMAND && e.keyCode == SWT.ARROW_DOWN
				&& !moveUpwards) {
				run();
				e.doit = false;
			}
		}
	});
}
 
Example #22
Source File: PackageExplorerPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create the KeyListener for doing the refresh on the viewer.
 */
private void initKeyListener() {
	fViewer.getControl().addKeyListener(new KeyAdapter() {
		@Override
		public void keyReleased(KeyEvent event) {
			fActionSet.handleKeyEvent(event);
		}
	});
}
 
Example #23
Source File: AbapGitStagingView.java    From ADT_Frontend with MIT License 5 votes vote down vote up
private void addKeyListener(TreeViewer viewer, boolean unstaged) {
	viewer.getTree().addKeyListener(new KeyAdapter() {
		@Override
		public void keyPressed(KeyEvent e) {
			//add key listener for text copy
			if (e.keyCode == KEY_STROKE_COPY.getNaturalKey() && e.stateMask == KEY_STROKE_COPY.getModifierKeys()) {
				if (unstaged) {
					new CopyNameAction(AbapGitStagingView.this.unstagedTreeViewer).run();
				} else {
					new CopyNameAction(AbapGitStagingView.this.stagedTreeViewer).run();
				}
			}
		}
	});
}
 
Example #24
Source File: AbapGitView.java    From ADT_Frontend with MIT License 5 votes vote down vote up
private void addKeyListeners() {
	this.viewer.getTable().addKeyListener(new KeyAdapter() {
		@Override
		public void keyPressed(KeyEvent e) {
			//add key listener for text copy
			if (e.keyCode == KEY_STROKE_COPY.getNaturalKey() && e.stateMask == KEY_STROKE_COPY.getModifierKeys()) {
				copy();
			}
		}
	});
}
 
Example #25
Source File: TrackerView.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TableViewSWT<TrackerPeerSource>
initYourTableView()
{
	registerPluginViews();

	tv = TableViewFactory.createTableViewSWT(
			PLUGIN_DS_TYPE,
			TableManager.TABLE_TORRENT_TRACKERS,
			getPropertiesPrefix(),
			basicItems,
			basicItems[0].getName(),
			SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL );

	tv.addLifeCycleListener(this);
	tv.addMenuFillListener(this);
	tv.addTableDataSourceChangedListener(this, true);
	tv.addSelectionListener(this, false);

	tv.addKeyListener(
		new KeyAdapter(){
			@Override
			public void
			keyPressed(
				KeyEvent e )
			{
				if ( e.stateMask == 0 && e.keyCode == SWT.DEL ){

					removeTrackerPeerSources(tv.getSelectedDataSources().toArray());
					
					e.doit = false;
				}
			}});
	
	return tv;
}
 
Example #26
Source File: WorkspaceWizardPage.java    From eclipse with Apache License 2.0 5 votes vote down vote up
private void createTargetTextField() {
  target = new Text(container, SWT.BORDER);
  setAutoCompletion();
  target.addKeyListener(new KeyAdapter() {
    @Override
    public void keyReleased(KeyEvent ke) {
      if (ke.keyCode == '\r' && (ke.stateMask & SWT.SHIFT) != 0 && !target.getText().isEmpty()) {
        addTarget();
      }
    }
  });
  target.addModifyListener(e -> updateControls());
}
 
Example #27
Source File: QuickOutlinePopup.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected Text createFilterText(Composite parent) {
	filterText = new Text(parent, SWT.NONE);
	Dialog.applyDialogFont(filterText);

	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(KeyEvent e) {
			if (e.keyCode == 0x0D) // return
				gotoSelectedElement();
			if (e.keyCode == SWT.ARROW_DOWN)
				treeViewer.getTree().setFocus();
			if (e.keyCode == SWT.ARROW_UP)
				treeViewer.getTree().setFocus();
			if (e.character == 0x1B) // ESC
				dispose();
			if (e.keyCode == invokingKeystroke.getNaturalKey()
					&& e.stateMask == invokingKeystroke.getModifierKeys()) {
				changeOutlineMode();
				e.doit = false;
			}

		}
	});
	return filterText;
}
 
Example #28
Source File: RenameRefactoringPage.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private void createTxtNewName(Composite composite) {
	txtNewName = new Text(composite, SWT.BORDER);
	txtNewName.setText(refactoringInfo.getSelectedIdentifier());
	txtNewName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	txtNewName.selectAll();
	txtNewName.addKeyListener( new KeyAdapter() {
		public void keyReleased( final KeyEvent e ) {
			refactoringInfo.setNewName( txtNewName.getText() );
			validate();
		}
	} );
}
 
Example #29
Source File: TerminalConnectorWrapper.java    From typescript.java with MIT License 5 votes vote down vote up
private void bindWithTerminalTextData(ITerminalViewControl terminal) {
	ITerminalTextData data = getTerminaltextData();
	if (data == null) {
		return;
	}
	terminal.getControl().addKeyListener(new KeyAdapter() {

		private int startLine = -1;

		@Override
		public void keyPressed(KeyEvent e) {
			if (startLine == -1) {
				startLine = data.getCursorLine();
			}
			char character = e.character;
			if (character == '\r') {
				// User is typing enter
				StringBuilder line = new StringBuilder();
				int endLine = data.getHeight();
				for (int i = startLine; i <= endLine; i++) {
					char[] chars = data.getChars(i);
					if (chars != null) {
						line.append(chars);
					}
				}
				String c = line.toString();
				int index = c.indexOf(">");
				if (index == -1) {
					index = c.indexOf("$");
				}
				if (index != -1) {
					String command = line.substring(index + 1, line.length());
					submitCommand(new LineCommand(command), false);
				}
				startLine = -1;
			}
		}
	});
}
 
Example #30
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"));
}