Search in sources :

Example 6 with ImportPattern

use of aQute.bnd.build.model.clauses.ImportPattern in project bndtools by bndtools.

the class ImportPatternsListPart method createSection.

@Override
protected void createSection(Section section, FormToolkit toolkit) {
    super.createSection(section, toolkit);
    Composite parentComposite = (Composite) getSection().getClient();
    pnlDetails = toolkit.createComposite(parentComposite);
    toolkit.createLabel(pnlDetails, "Pattern:");
    txtPattern = toolkit.createText(pnlDetails, "");
    toolkit.createLabel(pnlDetails, "Version:");
    txtVersion = toolkit.createText(pnlDetails, "", SWT.BORDER);
    btnOptional = toolkit.createButton(pnlDetails, "Optional", SWT.CHECK);
    pnlDetails.setLayout(new GridLayout(5, false));
    txtPattern.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    pnlDetails.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    SWTUtil.recurseEnable(false, pnlDetails);
    txtPattern.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            if (!modifyLock.isUnderModification()) {
                List<ImportPattern> selectedClauses = getSelection();
                if (selectedClauses.size() == 1) {
                    selectedClauses.get(0).setName(txtPattern.getText());
                    updateLabels(selectedClauses);
                    validate();
                    markDirty();
                }
            }
        }
    });
    txtVersion.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            if (!modifyLock.isUnderModification()) {
                String text = txtVersion.getText();
                if (text.length() == 0)
                    text = null;
                List<ImportPattern> selectedClauses = getSelection();
                for (ImportPattern clause : selectedClauses) {
                    clause.getAttribs().put(Constants.VERSION_ATTRIBUTE, text);
                }
                updateLabels(selectedClauses);
                validate();
                markDirty();
            }
        }
    });
    btnOptional.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (!modifyLock.isUnderModification()) {
                boolean optional = btnOptional.getSelection();
                List<ImportPattern> patterns = getSelection();
                for (ImportPattern pattern : patterns) {
                    pattern.setOptional(optional);
                }
                updateLabels(patterns);
                validate();
                markDirty();
            }
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ImportPattern(aQute.bnd.build.model.clauses.ImportPattern) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LinkedList(java.util.LinkedList) List(java.util.List)

Aggregations

ImportPattern (aQute.bnd.build.model.clauses.ImportPattern)6 ExportedPackage (aQute.bnd.build.model.clauses.ExportedPackage)2 BndEditModel (aQute.bnd.build.model.BndEditModel)1 Attrs (aQute.bnd.header.Attrs)1 Document (aQute.bnd.properties.Document)1 IDocument (aQute.bnd.properties.IDocument)1 BundleContentPage (bndtools.editor.pages.BundleContentPage)1 WorkspacePage (bndtools.editor.pages.WorkspacePage)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IResourceProxy (org.eclipse.core.resources.IResourceProxy)1