Search in sources :

Example 91 with KeyEvent

use of org.eclipse.swt.events.KeyEvent in project tdi-studio-se by Talend.

the class JSONFileStep3Form method addFieldsListeners.

/**
     * Main Fields addControls.
     */
@Override
protected void addFieldsListeners() {
    // metadataNameText : Event modifyText
    metadataNameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            MetadataToolHelper.validateSchema(metadataNameText.getText());
            metadataTable.setLabel(metadataNameText.getText());
            checkFieldsValue();
        }
    });
    // metadataNameText : Event KeyListener
    metadataNameText.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            MetadataToolHelper.checkSchema(getShell(), e);
        }
    });
    // metadataCommentText : Event modifyText
    metadataCommentText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            metadataTable.setComment(metadataCommentText.getText());
        }
    });
    // add listener to tableMetadata (listen the event of the toolbars)
    tableEditorView.getMetadataEditor().addAfterOperationListListener(new IListenableListListener() {

        @Override
        public void handleEvent(ListenableListEvent event) {
            checkFieldsValue();
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener)

Example 92 with KeyEvent

use of org.eclipse.swt.events.KeyEvent in project bndtools by bndtools.

the class ReposPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginRight = 10;
    composite.setLayout(layout);
    Group group = new Group(composite, SWT.NONE);
    group.setText("Templates Repositories");
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    group.setLayout(new GridLayout(2, false));
    final Button btnEnableTemplateRepo = new Button(group, SWT.CHECK);
    btnEnableTemplateRepo.setText("Enable templates repositories");
    btnEnableTemplateRepo.setSelection(enableTemplateRepo);
    btnEnableTemplateRepo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    ControlDecoration decoration = new ControlDecoration(btnEnableTemplateRepo, SWT.RIGHT | SWT.TOP, composite);
    decoration.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
    decoration.setMarginWidth(3);
    decoration.setDescriptionText("These repositories are used to load\ntemplates, in addition to repositories\nconfigured in the Bnd OSGi Workspace.");
    decoration.setShowHover(true);
    decoration.setShowOnlyOnFocus(false);
    Label lblRepos = new Label(group, SWT.NONE);
    lblRepos.setText("Repository URLs:");
    lblRepos.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    final Table tblRepos = new Table(group, SWT.BORDER | SWT.MULTI);
    vwrRepos = new TableViewer(tblRepos);
    vwrRepos.setContentProvider(ArrayContentProvider.getInstance());
    vwrRepos.setLabelProvider(new URLLabelProvider(tblRepos.getDisplay()));
    vwrRepos.setInput(templateRepos);
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.widthHint = 260;
    gd.heightHint = 80;
    tblRepos.setLayoutData(gd);
    tblRepos.setEnabled(enableTemplateRepo);
    final AddRemoveButtonBarPart addRemoveRepoPart = new AddRemoveButtonBarPart();
    Control addRemovePanel = addRemoveRepoPart.createControl(group, SWT.FLAT | SWT.VERTICAL);
    addRemovePanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    addRemoveRepoPart.setRemoveEnabled(false);
    addRemoveRepoPart.addListener(new AddRemoveListener() {

        @Override
        public void addSelected() {
            doAddRepo();
        }

        @Override
        public void removeSelected() {
            doRemoveRepo();
        }
    });
    vwrRepos.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            addRemoveRepoPart.setRemoveEnabled(!vwrRepos.getSelection().isEmpty());
        }
    });
    tblRepos.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL && e.stateMask == 0)
                doRemoveRepo();
        }
    });
    btnEnableTemplateRepo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            enableTemplateRepo = btnEnableTemplateRepo.getSelection();
            tblRepos.setEnabled(enableTemplateRepo);
            validate();
        }
    });
    return composite;
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) AddRemoveButtonBarPart(org.bndtools.utils.swt.AddRemoveButtonBarPart) KeyEvent(org.eclipse.swt.events.KeyEvent) URLLabelProvider(bndtools.shared.URLLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) AddRemoveListener(org.bndtools.utils.swt.AddRemoveButtonBarPart.AddRemoveListener) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 93 with KeyEvent

use of org.eclipse.swt.events.KeyEvent in project bndtools by bndtools.

the class EditableParametersPart method createControl.

public Control createControl(Composite parent) {
    this.parent = parent;
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    composite.setLayout(layout);
    Label titleLabel = new Label(composite, SWT.NONE);
    titleLabel.setText(title);
    titleLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
    Table table = new Table(composite, SWT.BORDER | SWT.MULTI);
    viewer = new TableViewer(table);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    final Image iconImg = imageDescriptor.createImage(parent.getDisplay());
    viewer.setLabelProvider(new StyledCellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            @SuppressWarnings("unchecked") Pair<String, Attrs> entry = (Pair<String, Attrs>) cell.getElement();
            StyledString label = new StyledString(entry.getFirst(), BoldStyler.INSTANCE_DEFAULT);
            for (Entry<String, String> attribEntry : entry.getSecond().entrySet()) {
                label.append("; " + attribEntry.getKey() + "=", StyledString.QUALIFIER_STYLER);
                label.append(attribEntry.getValue());
            }
            cell.setText(label.toString());
            cell.setStyleRanges(label.getStyleRanges());
            cell.setImage(iconImg);
        }
    });
    viewer.setInput(entries);
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.widthHint = 280;
    gd.heightHint = 80;
    table.setLayoutData(gd);
    final AddRemoveButtonBarPart buttonBarPart = new AddRemoveButtonBarPart();
    ToolBar buttonBar = buttonBarPart.createControl(composite, SWT.FLAT | SWT.VERTICAL);
    buttonBar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    final Image imgEdit = ImageDescriptor.createFromURL(BUNDLE.getEntry("icons/edit.gif")).createImage(parent.getDisplay());
    final Image imgEditDisabled = ImageDescriptor.createFromURL(BUNDLE.getEntry("icons/edit-disabled.gif")).createImage(parent.getDisplay());
    final ToolItem btnEdit = new ToolItem(buttonBar, SWT.PUSH);
    btnEdit.setImage(imgEdit);
    btnEdit.setDisabledImage(imgEditDisabled);
    buttonBarPart.setRemoveEnabled(false);
    btnEdit.setEnabled(false);
    buttonBarPart.addListener(new AddRemoveListener() {

        @Override
        public void addSelected() {
            doAdd();
        }

        @Override
        public void removeSelected() {
            doRemove();
        }
    });
    btnEdit.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doEdit();
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            boolean enabled = !viewer.getSelection().isEmpty();
            buttonBarPart.setRemoveEnabled(enabled);
            btnEdit.setEnabled(enabled);
        }
    });
    viewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            doEdit();
        }
    });
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL && e.stateMask == 0)
                doRemove();
        }
    });
    composite.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent ev) {
            iconImg.dispose();
            imgEdit.dispose();
            imgEditDisabled.dispose();
        }
    });
    return composite;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Attrs(aQute.bnd.header.Attrs) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) DisposeEvent(org.eclipse.swt.events.DisposeEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Entry(java.util.Map.Entry) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem) Pair(aQute.libg.tuple.Pair) StyledCellLabelProvider(org.eclipse.jface.viewers.StyledCellLabelProvider) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StyledString(org.eclipse.jface.viewers.StyledString) ViewerCell(org.eclipse.jface.viewers.ViewerCell) AddRemoveButtonBarPart(org.bndtools.utils.swt.AddRemoveButtonBarPart) AddRemoveListener(org.bndtools.utils.swt.AddRemoveButtonBarPart.AddRemoveListener) IOpenListener(org.eclipse.jface.viewers.IOpenListener) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) TableViewer(org.eclipse.jface.viewers.TableViewer) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 94 with KeyEvent

use of org.eclipse.swt.events.KeyEvent in project bndtools by bndtools.

the class RunRequirementsPart method createSection.

private void createSection(Section section, FormToolkit tk) {
    section.setText("Run Requirements");
    section.setDescription("The specified requirements will be used to resolve a set of runtime bundles from available repositories.");
    // Create toolbar
    ToolBar toolbar = new ToolBar(section, SWT.FLAT);
    section.setTextClient(toolbar);
    fillToolBar(toolbar);
    // Create main panel
    Composite composite = tk.createComposite(section);
    section.setClient(composite);
    table = tk.createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    viewer = new TableViewer(table);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new RequirementLabelProvider());
    btnAutoResolve = tk.createButton(composite, "Auto-resolve on save", SWT.CHECK);
    btnResolveNow = tk.createButton(composite, "Resolve", SWT.PUSH);
    btnResolveNow.setImage(resolveIcon);
    // Listeners
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            removeTool.setEnabled(!viewer.getSelection().isEmpty());
        }
    });
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == SWT.DEL) {
                doRemove();
            } else if (e.character == '+') {
                doAddBundle();
            }
        }
    });
    RequirementViewerDropAdapter dropper = new RequirementViewerDropAdapter();
    dropper.install(viewer);
    btnAutoResolve.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ResolveMode old = resolveMode;
            resolveMode = btnAutoResolve.getSelection() ? ResolveMode.auto : ResolveMode.manual;
            updateButtonStates();
            if (old != resolveMode)
                markDirty();
        }
    });
    btnResolveNow.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            btnResolveNow.setEnabled(false);
            doResolve();
        }
    });
    // Layout
    GridLayout layout;
    GridData gd;
    layout = new GridLayout(2, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 5;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    gd.widthHint = 50;
    gd.heightHint = 50;
    table.setLayoutData(gd);
    gd = new GridData(SWT.RIGHT, SWT.CENTER, true, false);
    btnResolveNow.setLayoutData(gd);
}
Also used : ResolveMode(org.bndtools.api.ResolveMode) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) RequirementLabelProvider(org.bndtools.core.ui.resource.RequirementLabelProvider) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 95 with KeyEvent

use of org.eclipse.swt.events.KeyEvent in project bndtools by bndtools.

the class PluginsPart method createSection.

final void createSection(Section section, FormToolkit toolkit) {
    section.setText("Plugins");
    section.setDescription("Bnd plugins are used to specify repositories and extended behaviours.");
    createToolBar(section);
    Composite composite = toolkit.createComposite(section, SWT.NONE);
    table = toolkit.createTable(composite, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER);
    viewer = new TableViewer(table);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new PluginClauseLabelProvider(configElements));
    Button btnReload = toolkit.createButton(composite, "Reload", SWT.NONE);
    btnReload.setImage(refreshImg);
    // Listeners
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            boolean enable = !viewer.getSelection().isEmpty();
            removeItemTool.setEnabled(enable);
            editItemTool.setEnabled(enable);
        }
    });
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == SWT.DEL) {
                doRemove();
            } else if (e.character == '+') {
                doAdd();
            }
        }
    });
    btnReload.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doReload();
        }
    });
    composite.setLayout(new GridLayout(1, false));
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    btnReload.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    section.setClient(composite);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

KeyEvent (org.eclipse.swt.events.KeyEvent)98 KeyAdapter (org.eclipse.swt.events.KeyAdapter)63 GridData (org.eclipse.swt.layout.GridData)54 GridLayout (org.eclipse.swt.layout.GridLayout)42 Composite (org.eclipse.swt.widgets.Composite)42 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 Text (org.eclipse.swt.widgets.Text)34 KeyListener (org.eclipse.swt.events.KeyListener)32 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)32 Label (org.eclipse.swt.widgets.Label)29 ModifyEvent (org.eclipse.swt.events.ModifyEvent)22 ModifyListener (org.eclipse.swt.events.ModifyListener)22 Point (org.eclipse.swt.graphics.Point)21 Button (org.eclipse.swt.widgets.Button)21 MouseEvent (org.eclipse.swt.events.MouseEvent)20 TableViewer (org.eclipse.jface.viewers.TableViewer)19 StyledText (org.eclipse.swt.custom.StyledText)13 FocusEvent (org.eclipse.swt.events.FocusEvent)13 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)12 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)12