You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/07/13 15:26:06 UTC
svn commit: r793581 [17/23] - in /felix/trunk/sigil: ./ bld-ivy/
bld-ivy/example/ bld-ivy/example/dependence/
bld-ivy/example/dependence/dependee/ bld-ivy/example/dependence/dependee/src/
bld-ivy/example/dependence/dependee/src/standalone/ bld-ivy/exam...
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContentSummarySection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContentSummarySection.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContentSummarySection.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContentSummarySection.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.cauldron.sigil.ui.form.SigilSection;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.Section;
+
+public class ContentSummarySection extends SigilSection {
+
+ public ContentSummarySection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException {
+ super( page, parent, project );
+ }
+
+ @Override
+ protected void createSection(Section section, FormToolkit toolkit) {
+ setTitle( "Project Content");
+
+ Composite body = createTableWrapBody(2, toolkit);
+ Hyperlink link = toolkit.createHyperlink( body, "Contents:", SWT.NONE );
+ link.setHref( ContentsForm.PAGE_ID );
+ link.addHyperlinkListener(this);
+ toolkit.createLabel( body, "Manage the content that this bundle provides." );
+
+ link = toolkit.createHyperlink( body, "Dependencies:", SWT.NONE );
+ link.setHref( DependenciesForm.PAGE_ID );
+ link.addHyperlinkListener(this);
+ toolkit.createLabel( body, "Manage the dependencies that this bundle needs to run." );
+
+ link = toolkit.createHyperlink( body, "Exports:", SWT.NONE );
+ link.setHref( ExportsForm.PAGE_ID );
+ link.addHyperlinkListener(this);
+ toolkit.createLabel( body, "Manage the resources that this bundle exports." );
+ }
+
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ getPage().getEditor().setActivePage( (String) e.getHref() );
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContentsForm.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContentsForm.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContentsForm.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContentsForm.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+public class ContentsForm extends SigilPage {
+
+ public static final String PAGE_ID = "contents";
+
+ private ISigilProjectModel project;
+
+ public ContentsForm(FormEditor editor, ISigilProjectModel project) {
+ super(editor, PAGE_ID, "Contents");
+ this.project = project;
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ FormToolkit toolkit = managedForm.getToolkit();
+
+ ScrolledForm form = managedForm.getForm();
+ form.setText( "Contents" );
+
+ Composite body = form.getBody();
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.bottomMargin = 10;
+ layout.topMargin = 5;
+ layout.leftMargin = 10;
+ layout.rightMargin = 10;
+ layout.numColumns = 2;
+ layout.horizontalSpacing = 10;
+ body.setLayout(layout);
+ body.setLayoutData(new TableWrapData(TableWrapData.FILL));
+
+ Composite top = toolkit.createComposite(body);
+ layout = new TableWrapLayout();
+ layout.verticalSpacing = 20;
+ top.setLayout(layout);
+ TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
+ data.colspan = 2;
+ top.setLayoutData(data);
+
+ Composite left = toolkit.createComposite(body);
+ layout = new TableWrapLayout();
+ layout.verticalSpacing = 20;
+ left.setLayout(layout);
+ left.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+
+ Composite right = toolkit.createComposite(body);
+ layout = new TableWrapLayout();
+ layout.verticalSpacing = 20;
+ right.setLayout(layout);
+ right.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB) );
+
+ try {
+ ClasspathSection classpath = new ClasspathSection( this, top, project );
+ managedForm.addPart( classpath );
+
+ ResourceBuildSection runtimeBuild = new ResourceBuildSection( this, left, project );
+ managedForm.addPart( runtimeBuild );
+
+ DownloadSection download = new DownloadSection( this, right, project );
+ managedForm.addPart( download );
+ }
+ catch (CoreException e) {
+ SigilCore.error( "Failed to create contents form", e);
+ }
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DependenciesForm.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DependenciesForm.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DependenciesForm.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DependenciesForm.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import java.util.Set;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.IModelElement;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+public class DependenciesForm extends SigilPage {
+
+ public static final String PAGE_ID = "dependencies";
+
+ private final ISigilProjectModel project;
+ private final Set<IModelElement> unresolvedElements;
+
+ private ImportPackagesSection importPackages;
+ private RequiresBundleSection requiresSection;
+
+
+ public DependenciesForm(FormEditor editor, ISigilProjectModel project, Set<IModelElement> unresolved) {
+ super(editor, PAGE_ID, "Dependencies");
+ this.project = project;
+ this.unresolvedElements = unresolved;
+ }
+
+ @Override
+ public boolean canLeaveThePage() {
+ return !isDirty();
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ FormToolkit toolkit = managedForm.getToolkit();
+
+ ScrolledForm form = managedForm.getForm();
+ form.setText( "Dependencies" );
+
+ Composite body = form.getBody();
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.bottomMargin = 10;
+ layout.topMargin = 5;
+ layout.leftMargin = 10;
+ layout.rightMargin = 10;
+ layout.numColumns = 2;
+ layout.horizontalSpacing = 10;
+ body.setLayout(layout);
+ body.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+
+ Composite left = toolkit.createComposite(body);
+ layout = new TableWrapLayout();
+ layout.verticalSpacing = 20;
+ left.setLayout(layout);
+ TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB);
+ layoutData.rowspan = 2;
+ left.setLayoutData(layoutData);
+
+ Composite right = toolkit.createComposite(body);
+ layout = new TableWrapLayout();
+ layout.verticalSpacing = 20;
+ right.setLayout(layout);
+ right.setLayoutData(new TableWrapData( TableWrapData.FILL_GRAB) );
+
+ Composite bottom = toolkit.createComposite(body);
+ layout = new TableWrapLayout();
+ layout.verticalSpacing = 20;
+ bottom.setLayout(layout);
+ bottom.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+
+ try {
+ importPackages = new ImportPackagesSection( this, left, project, unresolvedElements );
+ managedForm.addPart( importPackages );
+
+ requiresSection = new RequiresBundleSection(this, right, project, unresolvedElements );
+ managedForm.addPart(requiresSection);
+
+ DependencyManagementSection depMgmt = new DependencyManagementSection(this, bottom, project);
+ managedForm.addPart(depMgmt);
+ }
+ catch (CoreException e) {
+ SigilCore.error( "Failed to create dependencies form", e);
+ }
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DependencyManagementSection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DependencyManagementSection.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DependencyManagementSection.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DependencyManagementSection.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.ModelElementFactory;
+import org.cauldron.sigil.model.common.VersionRange;
+import org.cauldron.sigil.model.common.VersionRangeBoundingRule;
+import org.cauldron.sigil.model.osgi.IBundleModelElement;
+import org.cauldron.sigil.model.osgi.IPackageExport;
+import org.cauldron.sigil.model.osgi.IPackageImport;
+import org.cauldron.sigil.model.osgi.IRequiredBundle;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.SigilUI;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.cauldron.sigil.ui.form.SigilSection;
+import org.cauldron.sigil.ui.util.AccumulatorAdapter;
+import org.cauldron.sigil.ui.util.ExportedPackageFinder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IImportDeclaration;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.AbstractFormPart;
+import org.eclipse.ui.forms.IFormPart;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.Section;
+
+public class DependencyManagementSection extends SigilSection {
+
+ private Hyperlink hypConvertRBtoIP;
+
+ public DependencyManagementSection(SigilPage page, Composite parent,
+ ISigilProjectModel project) throws CoreException {
+ super(page, parent, project);
+ }
+
+ protected void createSection(Section section, FormToolkit toolkit) throws CoreException {
+ setTitle("Dependency Management");
+
+ Composite body = createGridBody(1, false, toolkit);
+
+ hypConvertRBtoIP = toolkit.createHyperlink(body, "Convert Required Bundles to Imported Packages", SWT.NONE);
+ hypConvertRBtoIP.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ hypConvertRBtoIP.addHyperlinkListener(new HyperlinkAdapter() {
+ public void linkActivated(HyperlinkEvent e) {
+ run();
+ }
+ });
+ }
+
+ protected void run() {
+ final Map<String, IPackageExport> exports = new HashMap<String, IPackageExport>();
+ final Set<String> imports = new HashSet<String>();
+
+ // Find all exports
+ final ExportedPackageFinder exportFinder = new ExportedPackageFinder(getProjectModel(), new AccumulatorAdapter<IPackageExport>() {
+ public void addElements(Collection<? extends IPackageExport> elements) {
+ for (IPackageExport export : elements) {
+ exports.put(export.getPackageName(), export);
+ }
+ }
+ });
+ Job findExportsJob = new Job("Find exports") {
+ protected IStatus run(IProgressMonitor monitor) {
+ return exportFinder.run(monitor);
+ }
+ };
+ findExportsJob.setUser(true);
+ findExportsJob.schedule();
+
+ // Find imports from Java source
+ Job findImportsJob = new Job("Find imports") {
+ protected IStatus run(IProgressMonitor monitor) {
+ IJavaProject javaProject = getProjectModel().getJavaModel();
+ try {
+ IPackageFragment[] packages = javaProject.getPackageFragments();
+ for (IPackageFragment pkg : packages) {
+ ICompilationUnit[] compilationUnits = pkg.getCompilationUnits();
+ for (ICompilationUnit compilationUnit : compilationUnits) {
+ IImportDeclaration[] importDecls = compilationUnit.getImports();
+ for (IImportDeclaration importDecl : importDecls) {
+ imports.add(getPackageName(importDecl));
+ }
+ }
+ }
+ return Status.OK_STATUS;
+ } catch (JavaModelException e) {
+ return new Status(IStatus.ERROR, SigilUI.PLUGIN_ID, 0, "Error finding imports", e);
+ }
+ }
+ };
+ findImportsJob.setUser(true);
+ findImportsJob.schedule();
+
+ // Wait for both jobs to complete
+ try {
+ findImportsJob.join();
+ findExportsJob.join();
+ } catch (InterruptedException e) {
+ // Aborted, just do nothing
+ return;
+ }
+
+ // Get the version rules
+ IPreferenceStore prefStore = SigilCore.getDefault().getPreferenceStore();
+ VersionRangeBoundingRule lowerBoundRule = VersionRangeBoundingRule.valueOf(prefStore.getString(SigilCore.DEFAULT_VERSION_LOWER_BOUND));
+ VersionRangeBoundingRule upperBoundRule = VersionRangeBoundingRule.valueOf(prefStore.getString(SigilCore.DEFAULT_VERSION_UPPER_BOUND));
+
+ // Get the existing imports for the bundle
+ IBundleModelElement bundleInfo = getProjectModel().getBundle().getBundleInfo();
+ Set<IPackageImport> existingImports = bundleInfo.getImports();
+ Map<String, IPackageImport> existingImportsMap = new HashMap<String, IPackageImport>();
+ for (IPackageImport existingImport : existingImports) {
+ existingImportsMap.put(existingImport.getPackageName(), existingImport);
+ }
+
+ // Add imports to the bundle
+ ModelElementFactory elementFactory = ModelElementFactory.getInstance();
+ int count = 0;
+ for (String pkgImport : imports) {
+ IPackageExport export = exports.get(pkgImport);
+ if(export != null && !existingImportsMap.containsKey(pkgImport)) {
+ VersionRange versionRange = VersionRange.newInstance(export.getVersion(), lowerBoundRule, upperBoundRule);
+ IPackageImport newImport = elementFactory.newModelElement(IPackageImport.class);
+ newImport.setPackageName(pkgImport);
+ newImport.setVersions(versionRange);
+ newImport.setOptional(false);
+
+ bundleInfo.addImport(newImport);
+ count++;
+ }
+ }
+
+ // Remove required bundles
+ Set<IRequiredBundle> requiredBundles = bundleInfo.getRequiredBundles();
+ int requiredBundlesSize = requiredBundles.size();
+ for (IRequiredBundle requiredBundle : requiredBundles) {
+ bundleInfo.removeRequiredBundle(requiredBundle);
+ }
+
+ // Update the editor
+ if(count + requiredBundlesSize > 0) {
+ IFormPart[] parts = getPage().getManagedForm().getParts();
+ for (IFormPart formPart : parts) {
+ formPart.refresh();
+ ((AbstractFormPart) formPart).markDirty();
+ }
+ }
+
+ MessageDialog.openInformation(getManagedForm().getForm().getShell(), "Dependency Management", "Removed " + requiredBundlesSize + " required bundle(s) and added " + count + " imported package(s).");
+ }
+
+ private static String getPackageName(IImportDeclaration decl) {
+ String name = decl.getElementName();
+ int lastDot = name.lastIndexOf('.');
+ return name.substring(0, lastDot);
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DownloadSection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DownloadSection.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DownloadSection.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/DownloadSection.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+
+
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.ModelElementFactory;
+import org.cauldron.sigil.model.ModelElementFactoryException;
+import org.cauldron.sigil.model.eclipse.IDownloadJar;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.cauldron.sigil.ui.util.ModelLabelProvider;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+
+/**
+ * @author dave
+ *
+ */
+public class DownloadSection extends AbstractResourceSection {
+
+ /**
+ * @param page
+ * @param parent
+ * @param project
+ * @throws CoreException
+ */
+
+ private IDownloadJar dl;
+
+ public DownloadSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException {
+ super( page, parent, project );
+ }
+
+ /* (non-Javadoc)
+ * @see org.cauldron.sigil.ui.editors.project.SigilSection#createSection(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ @Override
+ protected void createSection(Section section, FormToolkit toolkit) throws CoreException {
+ setTitle( "Codebase" );
+
+ Composite body = createTableWrapBody(1, toolkit);
+
+ toolkit.createLabel( body, "Specify which resources are included as part of this bundles remote codebase." );
+
+ tree = toolkit.createTree( body, SWT.CHECK | SWT.BORDER );
+
+ TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB);
+ data.heightHint = 200;
+ tree.setLayoutData( data );
+
+ viewer = new CheckboxTreeViewer( tree );
+ IFolder base = ResourcesPlugin.getWorkspace().getRoot().getFolder(getProjectModel().getJavaModel().getOutputLocation());
+ viewer.setContentProvider( new ContainerTreeProvider() );
+ viewer.setLabelProvider( new ModelLabelProvider() );
+ viewer.addCheckStateListener( this );
+ viewer.setInput( base );
+
+ dl = getProjectModel().getBundle().getDownloadJar();
+
+ startWorkspaceListener(base.getWorkspace());
+ }
+
+ @Override
+ public void refresh() {
+ dl = getProjectModel().getBundle().getDownloadJar();
+ super.refresh();
+ }
+
+ @Override
+ public void commit(boolean onSave) {
+ getProjectModel().getBundle().setDownloadJar(dl);
+ super.commit(onSave);
+ }
+
+ @Override
+ protected void refreshSelections() {
+ // zero the state
+ if ( dl != null ) {
+ for ( IPath path : dl.getEntrys() ) {
+ IResource r = findResource( path );
+ if ( r != null ) {
+ viewer.expandToLevel(r, 0);
+ viewer.setChecked( r, true );
+ viewer.setGrayed( r, false );
+ handleStateChanged(r, true, false, false);
+ }
+ else {
+ SigilCore.error( "Unknown path " + path );
+ }
+ }
+ }
+ }
+
+ protected void syncResourceModel(IResource element, boolean checked) {
+ try {
+ if ( dl == null ) {
+ dl = ModelElementFactory.getInstance().newModelElement(IDownloadJar.class);
+ getProjectModel().getBundle().setDownloadJar(dl);
+ }
+
+ if ( checked ) {
+ dl.addEntry( element.getProjectRelativePath() );
+ }
+ else {
+ dl.removeEntry( element.getProjectRelativePath() );
+ }
+
+ markDirty();
+ }
+ catch (ModelElementFactoryException e) {
+ SigilCore.error( "Failed to create model element", e );
+ }
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExcludedResourcesFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExcludedResourcesFilter.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExcludedResourcesFilter.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExcludedResourcesFilter.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.preferences.PrefsUtils;
+import org.cauldron.sigil.utils.GlobCompiler;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+public class ExcludedResourcesFilter extends ViewerFilter {
+
+ private final Set<Pattern> exclusionSet = new HashSet<Pattern>();
+
+ public ExcludedResourcesFilter() {
+ loadExclusions();
+ }
+
+ public final synchronized void loadExclusions() {
+ exclusionSet.clear();
+ IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
+ String[] exclusions = PrefsUtils.stringToArray(store.getString(SigilCore.DEFAULT_EXCLUDED_RESOURCES));
+ for (String exclusion : exclusions) {
+ exclusionSet.add(GlobCompiler.compile(exclusion));
+ }
+ }
+
+ @Override
+ public synchronized boolean select(Viewer viewer, Object parentElement, Object element) {
+ IResource file = (IResource) element;
+ String path = file.getName();
+ for ( Pattern p :exclusionSet ) {
+ if ( p.matcher(path).matches() ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExportPackagesSection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExportPackagesSection.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExportPackagesSection.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExportPackagesSection.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.ModelElementFactory;
+import org.cauldron.sigil.model.ModelElementFactoryException;
+import org.cauldron.sigil.model.common.VersionRange;
+import org.cauldron.sigil.model.common.VersionRangeBoundingRule;
+import org.cauldron.sigil.model.eclipse.ISigilBundle;
+import org.cauldron.sigil.model.osgi.IPackageExport;
+import org.cauldron.sigil.model.osgi.IPackageImport;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.cauldron.sigil.ui.preferences.OptionalPrompt;
+import org.cauldron.sigil.ui.util.DefaultTableProvider;
+import org.cauldron.sigil.ui.util.ResourcesDialogHelper;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.osgi.framework.Version;
+
+public class ExportPackagesSection extends BundleDependencySection {
+
+ public ExportPackagesSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException {
+ super( page, parent, project );
+ }
+
+ @Override
+ protected String getTitle() {
+ return "Export Packages";
+ }
+
+ @Override
+ protected Label createLabel(Composite parent, FormToolkit toolkit) {
+ return toolkit.createLabel( parent, "Specify which packages this bundle shares with other bundles." );
+ }
+
+ @Override
+ protected IContentProvider getContentProvider() {
+ return new DefaultTableProvider() {
+ public Object[] getElements(Object inputElement) {
+ return getBundle().getBundleInfo().getExports().toArray();
+ }
+ };
+ }
+
+ @Override
+ protected void handleAdd() {
+ NewPackageExportDialog dialog = ResourcesDialogHelper.createNewExportDialog(getSection().getShell(), "Add Exported Package", null, getProjectModel(), true);
+
+ if ( dialog.open() == Window.OK ) {
+ try {
+ // Add selected exports
+ boolean exportsAdded = false;
+
+ List<IPackageFragment> newPkgFragments = dialog.getSelectedElements();
+ for (IPackageFragment pkgFragment : newPkgFragments) {
+ IPackageExport pkgExport = ModelElementFactory.getInstance().newModelElement(IPackageExport.class);
+ pkgExport.setPackageName(pkgFragment.getElementName());
+ pkgExport.setVersion(dialog.getVersion());
+ getBundle().getBundleInfo().addExport(pkgExport);
+
+ exportsAdded = true;
+ }
+
+ // Add corresponding imports (maybe)
+ boolean importsAdded = false;
+
+ IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
+ boolean shouldAddImports = OptionalPrompt.optionallyPrompt(store, SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT, "Add Exports", "Should corresponding imports be added?", getSection().getShell());
+ if(shouldAddImports) {
+ for (IPackageFragment pkgFragment : newPkgFragments) {
+ IPackageImport pkgImport = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
+ pkgImport.setPackageName(pkgFragment.getElementName());
+ VersionRangeBoundingRule lowerBound = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_LOWER_BOUND));
+ VersionRangeBoundingRule upperBound = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_UPPER_BOUND));
+ Version version = dialog.getVersion();
+ if(version == null) {
+ version = getBundle().getVersion();
+ }
+ VersionRange versionRange = VersionRange.newInstance(version, lowerBound, upperBound);
+ pkgImport.setVersions(versionRange);
+
+ getBundle().getBundleInfo().addImport(pkgImport);
+
+ importsAdded = true;
+ }
+ }
+
+ if(importsAdded) {
+ ((SigilProjectEditorPart) getPage().getEditor()).refreshAllPages();
+ markDirty();
+ } else if(exportsAdded) {
+ refresh();
+ markDirty();
+ }
+ }
+ catch (ModelElementFactoryException e) {
+ SigilCore.error( "Failed to buiild model element for package export", e);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void handleEdit() {
+ IStructuredSelection selection = (IStructuredSelection) getSelection();
+
+ boolean changed = false;
+
+ if ( !selection.isEmpty() ) {
+ for ( Iterator<IPackageExport> i = selection.iterator(); i.hasNext(); ) {
+ IPackageExport packageExport = i.next();
+ NewPackageExportDialog dialog = ResourcesDialogHelper.createNewExportDialog(getSection().getShell(), "Edit Imported Package", packageExport, getProjectModel(), false);
+ if ( dialog.open() == Window.OK ) {
+ changed = true;
+ IPackageFragment pkgFragment = dialog.getSelectedElement();
+ packageExport.setPackageName(pkgFragment.getElementName());
+ packageExport.setVersion(dialog.getVersion());
+ }
+ }
+ }
+
+ if ( changed ) {
+ refresh();
+ markDirty();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void handleRemoved() {
+ IStructuredSelection selection = (IStructuredSelection) getSelection();
+
+ if ( !selection.isEmpty() ) {
+ for ( Iterator<IPackageExport> i = selection.iterator(); i.hasNext(); ) {
+ getBundle().getBundleInfo().removeExport( i.next() );
+ }
+
+ refresh();
+ markDirty();
+ }
+ }
+
+ private ISigilBundle getBundle() {
+ return getProjectModel().getBundle();
+ }
+
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExportsForm.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExportsForm.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExportsForm.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ExportsForm.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+public class ExportsForm extends SigilPage {
+
+ public static final String PAGE_ID = "exports";
+
+ private ISigilProjectModel project;
+
+ public ExportsForm(FormEditor editor, ISigilProjectModel project) {
+ super(editor, PAGE_ID, "Exports");
+ this.project = project;
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ ScrolledForm form = managedForm.getForm();
+ form.setText( "Exports" );
+
+ Composite body = form.getBody();
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.bottomMargin = 10;
+ layout.topMargin = 5;
+ layout.leftMargin = 10;
+ layout.rightMargin = 10;
+ layout.numColumns = 1;
+ layout.horizontalSpacing = 10;
+ layout.verticalSpacing = 20;
+ body.setLayout(layout);
+ body.setLayoutData(new TableWrapData(TableWrapData.FILL));
+
+ try {
+ ExportPackagesSection exportPackages = new ExportPackagesSection( this, body, project );
+ managedForm.addPart( exportPackages );
+ }
+ catch (CoreException e) {
+ SigilCore.error( "Failed to create contents form", e);
+ }
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/GeneralInfoSection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/GeneralInfoSection.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/GeneralInfoSection.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/GeneralInfoSection.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,258 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import org.cauldron.sigil.model.ModelElementFactory;
+import org.cauldron.sigil.model.eclipse.ISigilBundle;
+import org.cauldron.sigil.model.osgi.IBundleModelElement;
+import org.cauldron.sigil.model.osgi.IRequiredBundle;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.IFormValueConverter;
+import org.cauldron.sigil.ui.form.SigilFormEntry;
+import org.cauldron.sigil.ui.form.SigilFormEntryAdapter;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.cauldron.sigil.ui.form.SigilSection;
+import org.cauldron.sigil.ui.util.BackgroundLoadingSelectionDialog;
+import org.cauldron.sigil.ui.util.ResourcesDialogHelper;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.Version;
+
+/**
+ * @author dave
+ *
+ */
+public class GeneralInfoSection extends SigilSection {
+
+ private String name;
+ private String symbolicName;
+ private Version version;
+ private String description;
+ private String provider;
+ private String activator;
+ private IRequiredBundle fragmentHost;
+
+ private SigilFormEntry nameEntry;
+ private SigilFormEntry symbolicNameEntry;
+ private SigilFormEntry versionEntry;
+ private SigilFormEntry descriptionEntry;
+ private SigilFormEntry providerEntry;
+ private SigilFormEntry activatorEntry;
+ private SigilFormEntry fragmentHostEntry;
+
+ /**
+ * @param parent
+ * @param toolkit
+ * @param style
+ * @throws CoreException
+ */
+ public GeneralInfoSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException {
+ super( page, parent, project );
+ }
+
+ protected void createSection(Section section,FormToolkit toolkit ) {
+ setTitle("General Information");
+
+ Composite body = createGridBody(3, false, toolkit);
+
+ Label label = toolkit.createLabel( body, "This section describes general information about this project." );
+ label.setLayoutData( new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1) );
+
+ symbolicNameEntry = new SigilFormEntry(body, toolkit, "Symbolic Name");
+ symbolicNameEntry.setFormEntryListener( new SigilFormEntryAdapter() {
+ @Override
+ public void textValueChanged(SigilFormEntry form) {
+ symbolicName = nullIfEmpty((String) form.getValue());
+ checkDirty();
+ }
+ });
+
+ nameEntry = new SigilFormEntry(body, toolkit, "Name");
+ nameEntry.setFormEntryListener( new SigilFormEntryAdapter() {
+ @Override
+ public void textValueChanged(SigilFormEntry form) {
+ name = nullIfEmpty((String) form.getValue());
+ checkDirty();
+ }
+ });
+
+ descriptionEntry = new SigilFormEntry(body, toolkit, "Description");
+ descriptionEntry.setFormEntryListener( new SigilFormEntryAdapter() {
+ @Override
+ public void textValueChanged(SigilFormEntry form) {
+ description = nullIfEmpty((String) form.getValue());
+ checkDirty();
+ }
+ });
+
+ IFormValueConverter converter = new IFormValueConverter() {
+ public String getLabel(Object value) {
+ Version v = (Version) value;
+ return v.toString();
+ }
+
+ public Object getValue(String label) {
+ return Version.parseVersion(label);
+ }
+ };
+
+ versionEntry = new SigilFormEntry(body, toolkit, "Version", null, converter);
+ versionEntry.setFormEntryListener( new SigilFormEntryAdapter() {
+ @Override
+ public void textValueChanged(SigilFormEntry form) {
+ version = (Version) form.getValue();
+ checkDirty();
+ }
+ });
+
+ providerEntry = new SigilFormEntry(body, toolkit, "Provider");
+ providerEntry.setFormEntryListener( new SigilFormEntryAdapter() {
+ @Override
+ public void textValueChanged(SigilFormEntry form) {
+ provider = nullIfEmpty((String) form.getValue());
+ checkDirty();
+ }
+ });
+
+ activatorEntry = new SigilFormEntry(body, toolkit, "Bundle Activator", "Browse...", null);
+ activatorEntry.setFormEntryListener( new SigilFormEntryAdapter() {
+ @Override
+ public void textValueChanged(SigilFormEntry form) {
+ activator = (String) form.getValue();
+ checkDirty();
+ }
+
+ @Override
+ public void browseButtonSelected(SigilFormEntry form) {
+ BackgroundLoadingSelectionDialog<String> dialog = ResourcesDialogHelper.createClassSelectDialog(getShell(), "Add Bundle Activator", getProjectModel(), activator, BundleActivator.class.getName());
+
+ if (dialog.open() == Window.OK) {
+ form.setValue(dialog.getSelectedElement());
+ }
+ }
+ });
+
+ converter = new IFormValueConverter() {
+ public String getLabel(Object value) {
+ IRequiredBundle b = (IRequiredBundle) value;
+ return b == null ? null : b.getSymbolicName() + " " + b.getVersions();
+ }
+
+ public Object getValue(String label) {
+ return null;
+ }
+ };
+
+ fragmentHostEntry = new SigilFormEntry(body, toolkit, "Fragment Host", "Browse...", converter );
+ fragmentHostEntry.setFormEntryListener( new SigilFormEntryAdapter() {
+ @Override
+ public void textValueChanged(SigilFormEntry form) {
+ fragmentHost = (IRequiredBundle) form.getValue();
+ checkDirty();
+ }
+
+ @Override
+ public void browseButtonSelected(SigilFormEntry form) {
+ NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper.createRequiredBundleDialog( getSection().getShell(), "Add Required Bundle", getProjectModel(), null, getBundle().getBundleInfo().getRequiredBundles() );
+
+ if (dialog.open() == Window.OK) {
+ IRequiredBundle required = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
+ required.setSymbolicName(dialog.getSelectedName());
+ required.setVersions(dialog.getSelectedVersions());
+ form.setValue(required);
+ }
+ }
+ });
+ fragmentHostEntry.setFreeText(false);
+ }
+
+ private static String nullIfEmpty(String value) {
+ if ( value.trim().length() == 0 ) {
+ return null;
+ }
+ return value;
+ }
+
+ private Shell getShell() {
+ return getSection().getShell();
+ }
+
+ @Override
+ public void commit(boolean onSave) {
+ getBundle().getBundleInfo().setSymbolicName( symbolicName );
+ getBundle().getBundleInfo().setName( name );
+ getBundle().getBundleInfo().setVersion( version );
+ getBundle().getBundleInfo().setDescription( description );
+ getBundle().getBundleInfo().setVendor( provider );
+ getBundle().getBundleInfo().setFragmentHost(fragmentHost);
+ getBundle().getBundleInfo().setActivator(activator);
+
+ super.commit(onSave);
+ }
+
+ @Override
+ public void refresh() {
+ symbolicName = getProjectModel().getBundle().getBundleInfo().getSymbolicName();
+ name = getProjectModel().getBundle().getBundleInfo().getName();
+ description = getProjectModel().getBundle().getBundleInfo().getDescription();
+ version = getProjectModel().getBundle().getBundleInfo().getVersion();
+ provider = getProjectModel().getBundle().getBundleInfo().getVendor();
+ fragmentHost = getProjectModel().getBundle().getBundleInfo().getFragmentHost();
+ activator = getProjectModel().getBundle().getBundleInfo().getActivator();
+
+ nameEntry.setValue(name);
+ symbolicNameEntry.setValue(symbolicName);
+ versionEntry.setValue(version);
+ descriptionEntry.setValue(description);
+ providerEntry.setValue(provider);
+ fragmentHostEntry.setValue(fragmentHost);
+ activatorEntry.setValue(activator);
+
+ super.refresh();
+ }
+
+ private void checkDirty() {
+ boolean dirty = different(symbolicName, getProjectModel().getBundle().getBundleInfo().getSymbolicName() ) ||
+ different(name, getProjectModel().getBundle().getBundleInfo().getName() ) ||
+ different(version, getProjectModel().getBundle().getBundleInfo().getVersion() ) ||
+ different(description, getProjectModel().getBundle().getBundleInfo().getDescription()) ||
+ different(provider, getProjectModel().getBundle().getBundleInfo().getVendor()) ||
+ different(fragmentHost, getProjectModel().getBundle().getBundleInfo().getFragmentHost()) ||
+ different(activator, getProjectModel().getBundle().getBundleInfo().getActivator());
+
+ if ( dirty ) markDirty();
+ }
+
+ private boolean different(Object val1, Object val2) {
+ return val1 == null ? val2 != null : !val1.equals( val2 );
+ }
+
+ private ISigilBundle getBundle() {
+ return getProjectModel().getBundle();
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/IDependencyChecker.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/IDependencyChecker.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/IDependencyChecker.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/IDependencyChecker.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import org.cauldron.sigil.model.osgi.IPackageImport;
+import org.cauldron.sigil.model.osgi.IRequiredBundle;
+
+public interface IDependencyChecker {
+ boolean isSatisfied(IPackageImport packageImport);
+ boolean isSatisfied(IRequiredBundle requiredBundle);
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/IElementDescriptor.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/IElementDescriptor.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/IElementDescriptor.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/IElementDescriptor.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+public interface IElementDescriptor<E> {
+ /**
+ * Return the short identifying name of the element.
+ */
+ String getName(E element);
+
+ /**
+ * Return a label for the element, including the name but possibly supplying
+ * additional information.
+ *
+ * @param element
+ * @return
+ */
+ String getLabel(E element);
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ImportPackagesSection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ImportPackagesSection.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ImportPackagesSection.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ImportPackagesSection.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.cauldron.sigil.model.IModelElement;
+import org.cauldron.sigil.model.ModelElementFactory;
+import org.cauldron.sigil.model.eclipse.ISigilBundle;
+import org.cauldron.sigil.model.osgi.IPackageImport;
+import org.cauldron.sigil.model.osgi.IPackageModelElement;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.cauldron.sigil.ui.util.DefaultTableProvider;
+import org.cauldron.sigil.ui.util.ResourcesDialogHelper;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class ImportPackagesSection extends BundleDependencySection {
+
+ public ImportPackagesSection(SigilPage page, Composite parent, ISigilProjectModel project, Set<IModelElement> unresolvedPackages) throws CoreException {
+ super( page, parent, project, unresolvedPackages );
+ }
+
+ @Override
+ protected String getTitle() {
+ return "Import Packages";
+ }
+
+ @Override
+ protected Label createLabel(Composite parent, FormToolkit toolkit) {
+ return toolkit.createLabel( parent, "Specify which packages this bundle imports from other bundles." );
+ }
+
+
+ @Override
+ protected IContentProvider getContentProvider() {
+ return new DefaultTableProvider() {
+ public Object[] getElements(Object inputElement) {
+ ArrayList<IPackageImport> imports = new ArrayList<IPackageImport>(getBundle().getBundleInfo().getImports());
+ Collections.sort(imports, new Comparator<IPackageImport>() {
+ public int compare(IPackageImport o1, IPackageImport o2) {
+ return o1.getPackageName().compareTo( o2.getPackageName() );
+ }
+ });
+ return imports.toArray();
+ }
+ };
+ }
+
+ protected ISigilBundle getBundle() {
+ return getProjectModel().getBundle();
+ }
+
+ @Override
+ protected void handleAdd() {
+ NewResourceSelectionDialog<? extends IPackageModelElement> dialog =
+ ResourcesDialogHelper.createImportDialog(
+ getSection().getShell(),
+ "Add Imported Package",
+ getProjectModel(),
+ null,
+ getBundle().getBundleInfo().getImports() );
+
+ if ( dialog.open() == Window.OK ) {
+ IPackageImport pi = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
+ pi.setPackageName(dialog.getSelectedName());
+ pi.setVersions(dialog.getSelectedVersions());
+ pi.setOptional(dialog.isOptional());
+
+ getBundle().getBundleInfo().addImport(pi);
+ refresh();
+ markDirty();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void handleRemoved() {
+ IStructuredSelection selection = (IStructuredSelection) getSelection();
+
+ if ( !selection.isEmpty() ) {
+ for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); ) {
+ getBundle().getBundleInfo().removeImport( i.next() );
+ }
+
+ refresh();
+ markDirty();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void handleEdit() {
+ IStructuredSelection selection = (IStructuredSelection) getSelection();
+
+ boolean changed = false;
+
+ if ( !selection.isEmpty() ) {
+ for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); ) {
+ IPackageImport packageImport = i.next();
+ NewResourceSelectionDialog<? extends IPackageModelElement> dialog =
+ ResourcesDialogHelper.createImportDialog(
+ getSection().getShell(),
+ "Edit Imported Package",
+ getProjectModel(),
+ packageImport,
+ getBundle().getBundleInfo().getImports() );
+ if ( dialog.open() == Window.OK ) {
+ changed = true;
+ IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
+ newImport.setPackageName(dialog.getSelectedName());
+ newImport.setVersions(dialog.getSelectedVersions());
+ newImport.setOptional(dialog.isOptional());
+
+ getBundle().getBundleInfo().removeImport( packageImport );
+ getBundle().getBundleInfo().addImport(newImport);
+ }
+ }
+ }
+
+ if ( changed ) {
+ refresh();
+ markDirty();
+ }
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/NewPackageExportDialog.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/NewPackageExportDialog.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/NewPackageExportDialog.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/NewPackageExportDialog.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import java.util.Comparator;
+
+import org.cauldron.sigil.ui.util.BackgroundLoadingSelectionDialog;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.osgi.framework.Version;
+
+public class NewPackageExportDialog extends BackgroundLoadingSelectionDialog<IPackageFragment> {
+
+ private static final IElementDescriptor<IPackageFragment> PKG_FRAGMENT_STRINGIFIER = new IElementDescriptor<IPackageFragment>() {
+ public String getLabel(IPackageFragment element) {
+ return getName(element);
+ }
+ public String getName(IPackageFragment element) {
+ return element.getElementName();
+ }
+ };
+
+ private static final Comparator<IPackageFragment> PKG_FRAGMENT_COMPARATOR = new Comparator<IPackageFragment>() {
+ public int compare(IPackageFragment o1, IPackageFragment o2) {
+ return o1.getElementName().compareTo(o2.getElementName());
+ }
+ };
+
+ private Version version = null;
+ private String error = null;
+ private Version projectVersion = new Version(0,0,0);
+
+ private Button btnInheritBundleVersion;
+ private Button btnExplicitVersion;
+ private Text txtVersion;
+
+
+ public NewPackageExportDialog(Shell parentShell, boolean multiSelect) {
+ super(parentShell, "Package:", multiSelect);
+ setDescriptor(PKG_FRAGMENT_STRINGIFIER);
+ setComparator(PKG_FRAGMENT_COMPARATOR);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ // Create controls
+ Composite container = (Composite) super.createDialogArea(parent);
+ Composite composite = new Composite(container, SWT.NONE);
+
+ Group grpVersion = new Group(composite, SWT.NONE);
+ grpVersion.setText("Version");
+
+ btnInheritBundleVersion = new Button(grpVersion, SWT.RADIO);
+ btnInheritBundleVersion.setText("Inherit bundle version");
+ new Label(grpVersion, SWT.NONE); // Spacer
+ btnExplicitVersion = new Button(grpVersion, SWT.RADIO);
+ btnExplicitVersion.setText("Fixed version:");
+ txtVersion = new Text(grpVersion, SWT.BORDER);
+
+ // Initialize
+ if(version == null) {
+ btnInheritBundleVersion.setSelection(true);
+ txtVersion.setEnabled(false);
+ txtVersion.setText(projectVersion.toString());
+ } else {
+ btnExplicitVersion.setSelection(true);
+ txtVersion.setEnabled(true);
+ txtVersion.setText(version.toString());
+ }
+ updateButtons();
+
+ // Listeners
+ Listener radioAndTextListener = new Listener() {
+ public void handleEvent(Event event) {
+ error = null;
+ if(btnInheritBundleVersion.getSelection()) {
+ version = null;
+ txtVersion.setEnabled(false);
+ } else {
+ txtVersion.setEnabled(true);
+ try {
+ version = new Version(txtVersion.getText());
+ } catch (IllegalArgumentException e) {
+ error = "Invalid version";
+ }
+ }
+ setErrorMessage(error);
+ updateButtons();
+ }
+ };
+ txtVersion.addListener(SWT.Modify, radioAndTextListener);
+ btnInheritBundleVersion.addListener(SWT.Selection, radioAndTextListener);
+ btnExplicitVersion.addListener(SWT.Selection, radioAndTextListener);
+
+
+ // Layout
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ composite.setLayout(new GridLayout(1, false));
+ grpVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ grpVersion.setLayout(new GridLayout(2, false));
+ txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ return container;
+ }
+
+ @Override
+ protected boolean canComplete() {
+ return super.canComplete() && error == null;
+ }
+
+ public void setProjectVersion(Version projectVersion) {
+ this.projectVersion = projectVersion;
+ }
+
+ public void setVersion(Version version) {
+ this.version = version;
+ }
+
+ public Version getVersion() {
+ return version;
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/NewResourceSelectionDialog.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/NewResourceSelectionDialog.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/NewResourceSelectionDialog.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/NewResourceSelectionDialog.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.common.VersionRange;
+import org.cauldron.sigil.model.common.VersionRangeBoundingRule;
+import org.cauldron.sigil.model.osgi.IVersionedModelElement;
+import org.cauldron.sigil.ui.util.BackgroundLoadingSelectionDialog;
+import org.cauldron.sigil.ui.util.IValidationListener;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.osgi.framework.Version;
+
+public class NewResourceSelectionDialog<E extends IVersionedModelElement> extends BackgroundLoadingSelectionDialog<E> {
+
+ private VersionRangeComponent pnlVersionRange;
+ private boolean optionalEnabled = true;
+ private Button btnOptional;
+
+ private VersionRange selectedVersions = null;
+ private boolean optional = false;
+
+ public NewResourceSelectionDialog(Shell parentShell, String selectionLabel, boolean multi) {
+ super(parentShell, selectionLabel, multi);
+ }
+
+ public void setOptionalEnabled(boolean enabled) {
+ optionalEnabled = enabled;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ // Create controls
+ Composite container = (Composite) super.createDialogArea(parent);
+ Composite composite = new Composite(container, SWT.NONE);
+
+ if ( optionalEnabled ) {
+ new Label(composite, SWT.NONE); //Spacer
+ btnOptional = new Button(composite, SWT.CHECK);
+ btnOptional.setText("Optional");
+ }
+
+ Label lblVersionRange = new Label(composite, SWT.NONE);
+ lblVersionRange.setText("Version Range:");
+ Group group = new Group(composite, SWT.BORDER);
+
+ pnlVersionRange = new VersionRangeComponent(group, SWT.NONE);
+
+ // Initialize
+ if (selectedVersions != null) {
+ pnlVersionRange.setVersions(selectedVersions);
+ }
+
+ if ( optionalEnabled ) {
+ btnOptional.setSelection(optional);
+ updateButtons();
+ }
+
+ // Hookup Listeners
+ pnlVersionRange.addVersionChangeListener(new VersionsChangeListener() {
+ public void versionsChanged(VersionRange range) {
+ selectedVersions = range;
+ updateButtons();
+ }
+ });
+ pnlVersionRange.addValidationListener(new IValidationListener() {
+ public void validationMessage(String message, int level) {
+ setMessage(message, level);
+ updateButtons();
+ }
+ });
+
+ if ( optionalEnabled ) {
+ btnOptional.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ optional = btnOptional.getSelection();
+ }
+ });
+ }
+
+ // Layout
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ GridLayout layout = new GridLayout(2, false);
+ layout.verticalSpacing = 10;
+ layout.horizontalSpacing = 10;
+ composite.setLayout(layout);
+
+ lblVersionRange.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ group.setLayout(new FillLayout());
+
+ return container;
+ }
+
+ @Override
+ protected void elementSelected(E selection) {
+ if(selection != null) {
+ IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
+ VersionRangeBoundingRule lowerBoundRule = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_LOWER_BOUND));
+ VersionRangeBoundingRule upperBoundRule = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_UPPER_BOUND));
+
+ Version version = selection.getVersion();
+ selectedVersions = VersionRange.newInstance(version, lowerBoundRule, upperBoundRule);
+ pnlVersionRange.setVersions(selectedVersions);
+ }
+ }
+
+ @Override
+ protected synchronized boolean canComplete() {
+ return super.canComplete() && selectedVersions != null;
+ }
+
+ public VersionRange getSelectedVersions() {
+ return selectedVersions;
+ }
+
+ public void setVersions(VersionRange versions) {
+ selectedVersions = versions;
+ if(pnlVersionRange != null && !pnlVersionRange.isDisposed()) {
+ pnlVersionRange.setVersions(versions);
+ updateButtons();
+ }
+ }
+
+ public boolean isOptional() {
+ return optional;
+ }
+
+ public void setOptional(boolean optional) {
+ this.optional = optional;
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/OverviewForm.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/OverviewForm.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/OverviewForm.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/OverviewForm.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+/**
+ * @author dave
+ *
+ */
+public class OverviewForm extends SigilPage {
+ public static final String PAGE_ID = "overview";
+ private ISigilProjectModel sigil;
+
+ public OverviewForm(SigilProjectEditorPart editor, ISigilProjectModel sigil) {
+ super(editor, PAGE_ID, "Overview");
+ this.sigil = sigil;
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ FormToolkit toolkit = managedForm.getToolkit();
+
+ ScrolledForm form = managedForm.getForm();
+ form.setText( "Overview" );
+
+ Composite body = form.getBody();
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.bottomMargin = 10;
+ layout.topMargin = 5;
+ layout.leftMargin = 10;
+ layout.rightMargin = 10;
+ layout.numColumns = 2;
+ layout.horizontalSpacing = 10;
+ body.setLayout(layout);
+ body.setLayoutData(new TableWrapData(TableWrapData.FILL));
+
+ Composite left = toolkit.createComposite(body);
+ layout = new TableWrapLayout();
+ layout.verticalSpacing = 20;
+ left.setLayout(layout);
+ left.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+
+ Composite right = toolkit.createComposite(body);
+ layout = new TableWrapLayout();
+ layout.verticalSpacing = 20;
+ right.setLayout(layout);
+ right.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB) );
+
+ try {
+ GeneralInfoSection general = new GeneralInfoSection(this, left, sigil);
+ managedForm.addPart( general );
+
+ ContentSummarySection content = new ContentSummarySection( this, right, sigil);
+ managedForm.addPart( content );
+
+ // XXX-FELIX
+ // commented out due to removal of runtime newton integration
+ // potential to bring back in medium term...
+ //TestingSection testing = new TestingSection(this, right, newton);
+ //managedForm.addPart(testing);
+
+ ToolsSection tools = new ToolsSection(this, right, sigil);
+ managedForm.addPart(tools);
+ }
+ catch (CoreException e) {
+ SigilCore.error( "Failed to create overview form", e );
+ }
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/PackageExportDialog.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/PackageExportDialog.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/PackageExportDialog.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/PackageExportDialog.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.osgi.framework.Version;
+
+public class PackageExportDialog extends ResourceSelectDialog {
+
+ private Text versionText;
+ private Version version;
+
+ public PackageExportDialog(Shell parentShell, String title, IContentProvider content, ViewerFilter filter, Object scope ) {
+ super(parentShell, content, filter, scope, title, "Package Name:", true);
+ }
+
+ @Override
+ protected void createCustom(Composite body) {
+ Label l = new Label( body, SWT.NONE );
+ l.setText( "Version:" );
+ versionText = new Text(body, SWT.BORDER);
+ versionText.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ try {
+ version = Version.parseVersion(versionText.getText());
+ setErrorMessage(null);
+ }
+ catch (IllegalArgumentException ex) {
+ setErrorMessage("Invalid version");
+ }
+ }
+ });
+ if ( version != null ) {
+ versionText.setText( version.toString() );
+ }
+ }
+
+ public Version getVersion() {
+ return version;
+ }
+
+ public void setVersion(Version version) {
+ this.version = version;
+ }
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ProjectLabelProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ProjectLabelProvider.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ProjectLabelProvider.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ProjectLabelProvider.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import java.io.InputStream;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.eclipse.ISigilBundle;
+import org.cauldron.sigil.model.osgi.IBundleModelElement;
+import org.cauldron.sigil.model.osgi.IPackageExport;
+import org.cauldron.sigil.model.osgi.IPackageImport;
+import org.cauldron.sigil.model.osgi.IRequiredBundle;
+import org.cauldron.sigil.ui.util.DefaultLabelProvider;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.widgets.Widget;
+
+public class ProjectLabelProvider extends DefaultLabelProvider implements IBaseLabelProvider {
+
+ private final Widget parent;
+ private final ImageRegistry registry;
+ private final IDependencyChecker checker;
+
+ public ProjectLabelProvider(Widget parent, ImageRegistry registry ) {
+ this(parent, registry, null);
+ }
+
+ public ProjectLabelProvider(Widget parent, ImageRegistry registry, IDependencyChecker checker) {
+ this.parent = parent;
+ this.registry = registry;
+ this.checker = checker;
+ }
+
+ public Image getImage(Object element) {
+ Image result = null;
+ if ( element instanceof ISigilBundle || element instanceof IRequiredBundle || element instanceof IBundleModelElement) {
+ result = findBundle();
+ }
+ else if (element instanceof IPackageImport) {
+ if(checker != null) {
+ result = checker.isSatisfied((IPackageImport) element) ? findPackage() : findPackageError();
+ } else {
+ result = findPackage();
+ }
+ }
+ else if (element instanceof IPackageExport) {
+ result = findPackage();
+ }
+ else if ( element instanceof IPackageFragmentRoot ) {
+ IPackageFragmentRoot root = (IPackageFragmentRoot) element;
+ try {
+ if ( root.getKind() == IPackageFragmentRoot.K_SOURCE ) {
+ result = findPackage();
+ }
+ else {
+ result = findBundle();
+ }
+ } catch (JavaModelException e) {
+ SigilCore.error( "Failed to inspect package fragment root", e );
+ }
+ }
+ else if ( element instanceof IClasspathEntry ) {
+ result = findPackage();
+ }
+
+ return result;
+ }
+
+ public String getText(Object element) {
+ if ( element instanceof ISigilBundle ) {
+ ISigilBundle bundle = (ISigilBundle) element;
+ return bundle.getBundleInfo().getSymbolicName();
+ }
+
+ if ( element instanceof IRequiredBundle ) {
+ IRequiredBundle req = (IRequiredBundle) element;
+ return req.getSymbolicName() + " " + req.getVersions();
+ }
+
+ if ( element instanceof IPackageImport ) {
+ IPackageImport req = (IPackageImport) element;
+ return req.getPackageName() + " " + req.getVersions();
+ }
+
+ if ( element instanceof IPackageExport ) {
+ IPackageExport pe = (IPackageExport) element;
+ return pe.getPackageName() + " " + pe.getVersion();
+ }
+
+ if ( element instanceof IResource ) {
+ IResource resource = (IResource) element;
+ return resource.getName();
+ }
+
+ if ( element instanceof IPackageFragment ) {
+ IPackageFragment f = (IPackageFragment) element;
+ return f.getElementName();
+ }
+
+ if ( element instanceof IPackageFragmentRoot ) {
+ IPackageFragmentRoot f = (IPackageFragmentRoot) element;
+ try {
+ return f.getUnderlyingResource().getName();
+ } catch (JavaModelException e) {
+ return "unknown";
+ }
+ }
+
+ if ( element instanceof IClasspathEntry ) {
+ IClasspathEntry cp = (IClasspathEntry) element;
+ return cp.getPath().toString();
+ }
+
+ return element.toString();
+ }
+
+ private Image findPackage() {
+ Image image = registry.get( "package" );
+
+ if ( image == null ) {
+ image = loadImage( "icons/package_obj.png" );
+ registry.put( "package", image);
+ }
+
+ return image;
+ }
+
+ private Image findPackageError() {
+ Image image = registry.get("package_error");
+ if(image == null) {
+ image = loadImage("icons/package_obj_error.gif");
+ registry.put("package_error", image);
+ }
+ return image;
+ }
+
+ private Image findBundle() {
+ Image image = registry.get( "bundle" );
+
+ if ( image == null ) {
+ image = loadImage( "icons/jar_obj.png" );
+ registry.put( "bundle", image);
+ }
+
+ return image;
+ }
+
+ private Image loadImage(String resource) {
+ InputStream in = ProjectLabelProvider.class.getClassLoader().getResourceAsStream( resource );
+ ImageData data = new ImageData( in );
+ return new Image( parent.getDisplay(), data );
+ }
+
+}
Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ProjectTableViewer.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ProjectTableViewer.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ProjectTableViewer.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ProjectTableViewer.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.ui.editors.project;
+
+import java.util.Set;
+
+import org.cauldron.sigil.model.IModelElement;
+import org.cauldron.sigil.ui.util.ModelLabelProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.widgets.Table;
+
+public class ProjectTableViewer extends TableViewer {
+
+ private ModelLabelProvider labelProvider;
+
+ public ProjectTableViewer(Table table) {
+ super(table);
+ labelProvider = new ModelLabelProvider();
+ setLabelProvider(labelProvider);
+ }
+
+ @Override
+ public void setContentProvider(IContentProvider provider) {
+ super.setContentProvider(provider);
+ setInput(getTable());
+ }
+
+ public void setUnresolvedElements(Set<? extends IModelElement> elements) {
+ labelProvider.setUnresolvedElements(elements);
+ }
+
+ @Override
+ public ModelLabelProvider getLabelProvider() {
+ return labelProvider;
+ }
+
+
+}
\ No newline at end of file