diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/Activator.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/Activator.java index c5e4adc45469b0a379a900486084d7a6375f03c5..64fbde31c5148ffd84746ec114bf8eaa2d5c34f8 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/Activator.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/Activator.java @@ -59,23 +59,29 @@ public class Activator extends AbstractUIPlugin { * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ - public void start(BundleContext context) throws Exception { - - super.start(context); - plugin = this; - - tempDir = Configurator.local.getTempFolder(); - - File outputDir = Configurator.local.getLogFolder(); - if ( outputDir != null ) { - System.out.println("*** [Application Packager] - The log file is available at "+outputDir+" ***"); - System.setOut(new PrintStream(new File(outputDir+"/log.txt"))); - System.setErr(new PrintStream(new File(outputDir+"/errlog.txt"))); - } else if ( Configurator.local.isConsoleLog() == false ) { - System.out.println("*** [Application Packager] - The log file is available at "+tempDir+" ***"); - System.setOut(new PrintStream(new File(tempDir+"/log.txt"))); - System.setErr(new PrintStream(new File(tempDir+"/errlog.txt"))); + public void start(BundleContext context){ + + try { + super.start(context); + plugin = this; + + tempDir = Configurator.local.getTempFolder(); + + File outputDir = Configurator.local.getLogFolder(); + if ( outputDir != null ) { + System.out.println("*** [Application Packager] - The log file is available at "+outputDir+" ***"); + System.setOut(new PrintStream(new File(outputDir+"/log.txt"))); + System.setErr(new PrintStream(new File(outputDir+"/errlog.txt"))); + } else if ( Configurator.local.isConsoleLog() == false ) { + System.out.println("*** [Application Packager] - The log file is available at "+tempDir+" ***"); + System.setOut(new PrintStream(new File(tempDir+"/log.txt"))); + System.setErr(new PrintStream(new File(tempDir+"/errlog.txt"))); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } + } /* diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/actions/MPAaction.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/actions/MPAaction.java index fc86d31d68a2dca252539d51e0398f393b64706e..66045c1c4526b150b78df173de51a5d311947f27 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/actions/MPAaction.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/actions/MPAaction.java @@ -47,6 +47,7 @@ import org.universaal.tools.packaging.tool.api.WizardDialogMod; import org.universaal.tools.packaging.tool.gui.GUI; import org.universaal.tools.packaging.tool.util.Configurator; import org.universaal.tools.packaging.tool.util.Dialog; +import org.universaal.tools.packaging.tool.util.EffectivePOMContainer; /** * Our sample action implements workbench action delegate. diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/GUI.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/GUI.java index e4e97b2a81e3a8a376f8320374665efbb476d7dc..f102b8d9be0869e992c1bee26bda518f2a02b11a 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/GUI.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/GUI.java @@ -203,9 +203,8 @@ public class GUI extends WizardMod { LicenseSet aLicenseSet = new LicenseSet(); aLicenseSet.setLicenseList(licenseList); - List<LicenseSet> ls = app.getApplication().getLicenses(); - ls.add(aLicenseSet); - app.getApplication().setLicenses(ls); + app.getApplication().setLicenses(aLicenseSet); + } // Bundle, Artifact Id and Version per part @@ -340,7 +339,7 @@ public class GUI extends WizardMod { ppPR.setPercentage((double)getPageNumber(getPage(Page.PAGE_PART_PR+partName))/(double)getPageCount()); } - p_end.setPercentage(100); + p_end.setPercentage(1); } @@ -388,24 +387,26 @@ public class GUI extends WizardMod { for(int i = 0; i < parts.size(); i++) jar.create(parts.get(i), i+1); + // copy SLA and licenses (if possible) - for(int i = 0; i < mpa.getAAL_UAPP().getApplication().getLicenses().size(); i++){ + //for(int i = 0; i < mpa.getAAL_UAPP().getApplication().getLicenses().size(); i++){ - if(mpa.getAAL_UAPP().getApplication().getLicenses().get(i).getSla().getLink().getScheme() != null && - mpa.getAAL_UAPP().getApplication().getLicenses().get(i).getSla().getLink().getScheme().equalsIgnoreCase("file")){ // copy files - File sla = new File(mpa.getAAL_UAPP().getApplication().getLicenses().get(i).getSla().getLink()); + if(mpa.getAAL_UAPP().getApplication().getLicenses().getSla().getLink().getScheme() != null && + mpa.getAAL_UAPP().getApplication().getLicenses().getSla().getLink().getScheme().equalsIgnoreCase("file")){ // copy files + File sla = new File(mpa.getAAL_UAPP().getApplication().getLicenses().getSla().getLink()); copyFile(sla, new File(tempDir+"/license/"+sla.getName())); } - for(int j = 0; j < mpa.getAAL_UAPP().getApplication().getLicenses().get(i).getLicenseList().size(); j++){ + for(int j = 0; j < mpa.getAAL_UAPP().getApplication().getLicenses().getLicenseList().size(); j++){ - if(mpa.getAAL_UAPP().getApplication().getLicenses().get(i).getLicenseList().get(j).getLink().getScheme() != null && - mpa.getAAL_UAPP().getApplication().getLicenses().get(i).getLicenseList().get(j).getLink().getScheme().equalsIgnoreCase("file")){ // copy files - File license = new File(mpa.getAAL_UAPP().getApplication().getLicenses().get(i).getLicenseList().get(j).getLink()); + if(!mpa.getAAL_UAPP().getApplication().getLicenses().getLicenseList().get(j).getLink().toASCIIString().trim().isEmpty() && + mpa.getAAL_UAPP().getApplication().getLicenses().getLicenseList().get(j).getLink().getScheme() != null && + mpa.getAAL_UAPP().getApplication().getLicenses().getLicenseList().get(j).getLink().getScheme().equalsIgnoreCase("file")){ // copy files + File license = new File(mpa.getAAL_UAPP().getApplication().getLicenses().getLicenseList().get(j).getLink()); copyFile(license, new File(tempDir+"/license/"+license.getName())); } } - } + //} // copy config files files and folders for(int i = 0; i < mpa.getAAL_UAPP().getAppParts().size(); i++){ @@ -441,8 +442,14 @@ public class GUI extends WizardMod { File tmpFile = new File(tempDir+"/img.png"); if(tmpFile.exists()) tmpFile.delete(); + tmpFile = new File(tempDir+"/.recovery"); + if(tmpFile.exists()) tmpFile.delete(); + + tmpFile = new File(tempDir+"/.parts"); + if(tmpFile.exists()) tmpFile.delete(); + if(iconFile != null && iconFile.exists()){ - if (mpa.getAAL_UAPP().getApplication().getMenuEntry().getIconScale()){ + if (mpa.getAAL_UAPP().getApplication().getMenuEntry().getIconScale()){ try { BufferedImage img = ImageIO.read(iconFile); Image scaled = img.getScaledInstance(512, 512, Image.SCALE_AREA_AVERAGING); @@ -693,7 +700,8 @@ public class GUI extends WizardMod { maven.execute(request, null); //System.out.println("Done."); EffectivePOMContainer.addDocument(partName, mavenTempDir+"/"+partName+".epom.xml"); - EffectivePOMContainer.getDependencies(); + //EffectivePOMContainer.addDocument(partName, "/home/federico/nutritional.pom.epom.xml"); + EffectivePOMContainer.setDocument(partName); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page2.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page2.java index 96a7376fe70bde58ba14d8395dfac671ac848472..70872938290c88bdc42e545cfc737f6a3c194047 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page2.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page2.java @@ -74,10 +74,12 @@ public class Page2 extends PageImpl { .p12 � PKCS#12, may contain certificate(s) (public) and private keys (password protected) .pfx � PFX, predecessor of PKCS#12 (usually contains data in PKCS#12 format, e.g., with PFX files generated in IIS) */ - try { - certificate.setText(sc.toURI().toURL()+""); - } catch (MalformedURLException e1) { - e1.printStackTrace(); + if(sc != null) { + try { + certificate.setText(sc.toURI().toURL()+""); + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } } } diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page3.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page3.java index daaededb2dd511eef6689973677b24e4e7484242..ee8b7a9a1be980eeb2a14300c55caf0112f8b358 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page3.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page3.java @@ -247,7 +247,8 @@ public class Page3 extends PageImpl { */ setPageComplete(validate()); } - + + /* @Override public IWizardPage getPreviousPage() { @@ -256,7 +257,7 @@ public class Page3 extends PageImpl { return super.getPreviousPage().getPreviousPage(); } - + */ @Override public IWizardPage getNextPage(){ if (ckbMoreReqs.getSelection()){ diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PageDU.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PageDU.java index b012187923bf91f3dbf6a0befab819f038746f09..452763abbb308e3c94ac29806424bfced018d434 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PageDU.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PageDU.java @@ -71,12 +71,7 @@ public class PageDU extends PageImpl { ckbOS1.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { - ckbPL1.setSelection(false); - ckbOS1.setSelection(true); - ckbCU1.setSelection(false); - - enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); - disableControls(new ArrayList<Control>(Arrays.asList(platform1, cu1, emb1, andN, ckbKar, andD, andURI))); + enableOS(); } public void widgetDefaultSelected(SelectionEvent e) { @@ -89,12 +84,7 @@ public class PageDU extends PageImpl { ckbPL1.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { - ckbPL1.setSelection(true); - ckbOS1.setSelection(false); - ckbCU1.setSelection(false); - - enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); - disableControls(new ArrayList<Control>(Arrays.asList(os1, cu1, emb1, ckbKar, andN, andD, andURI))); + enablePlatform(); } public void widgetDefaultSelected(SelectionEvent e) { @@ -107,18 +97,13 @@ public class PageDU extends PageImpl { ckbCU1.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { - ckbPL1.setSelection(false); - ckbOS1.setSelection(false); - ckbCU1.setSelection(true); - - enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); - disableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, andN, /*ckbKar,*/ andD, andURI))); + enableCU(); } public void widgetDefaultSelected(SelectionEvent e) { } }); - + Label label1 = new Label(container, SWT.NULL); os1 = new Combo(container, SWT.READ_ONLY); //mandatory.add(os1); @@ -301,6 +286,32 @@ public class PageDU extends PageImpl { if(!app.getAppRequirements().embedding.isEmpty()) emb1.setText(app.getAppRequirements().embedding); } + protected void enableCU() { + ckbPL1.setSelection(false); + ckbOS1.setSelection(false); + ckbCU1.setSelection(true); + + enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); + disableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, andN, /*ckbKar,*/ andD, andURI))); + } + + protected void enablePlatform() { + ckbPL1.setSelection(true); + ckbOS1.setSelection(false); + ckbCU1.setSelection(false); + + enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); + disableControls(new ArrayList<Control>(Arrays.asList(os1, cu1, emb1, ckbKar, andN, andD, andURI))); + } + + private void enableOS() { + ckbPL1.setSelection(false); + ckbOS1.setSelection(true); + ckbCU1.setSelection(false); + + enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); + disableControls(new ArrayList<Control>(Arrays.asList(platform1, cu1, emb1, andN, ckbKar, andD, andURI))); + } public void setArtifact(IProject part){ } diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PageLicenses.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PageLicenses.java index 6b3da00aec387949a3149fefe62194211b0c3b98..28d9346cbdd43e7514f23b3b6b1a3135484d7db8 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PageLicenses.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PageLicenses.java @@ -3,12 +3,16 @@ package org.universaal.tools.packaging.tool.gui; import java.io.File; import java.net.MalformedURLException; import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -29,17 +33,18 @@ import org.universaal.tools.packaging.tool.validators.UriV; public class PageLicenses extends PageImpl { - private TextExt slaLink, slaName, licLink, licName; - private Combo licCategory; - - private SLA sla; - private License lic; - private boolean addLicense = false, onlyLicense = false; - - private File f1, f2; + private TextExt slaLink, slaName; + private List<TextExt> licLink = new ArrayList<TextExt>(), licName = new ArrayList<TextExt>(); + private List<Combo> licCategory = new ArrayList<Combo>(); + private List<Button> buttons = new ArrayList<Button>(); + private ScrolledComposite sc1; + private LicenseSet ls; + private GridData gd2, gd3; + private boolean addLicense = false/*, onlyLicense = false*/; + private File slaFile, licFile; private final String ERROR_MESSAGE = "Unrecognized value!"; - + protected PageLicenses(String pageName) { super(pageName, "Add SLA and license(s) for your Application - each artifact should be licensed under different license."); } @@ -47,39 +52,46 @@ public class PageLicenses extends PageImpl { protected PageLicenses(String pageName, boolean onlyLicense) { super(pageName, "Add SLA and license(s) for you Application"); - this.onlyLicense = onlyLicense; + //this.onlyLicense = onlyLicense; } public void createControl(final Composite parent) { // XSDParser XSDtooltip = XSDParser.get(XSD); + sc1 = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.BORDER); + + container = new Composite(sc1, SWT.NONE); + setControl(sc1); + + sc1.setExpandVertical(true); + sc1.setExpandHorizontal(true); - container = new Composite(parent, SWT.NULL); - setControl(container); - GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 3; gd = new GridData(GridData.FILL, GridData.CENTER, true, false); //gd.horizontalSpan = 2; - - List<LicenseSet> ls = app.getApplication().getLicenses(); - LicenseSet l = new LicenseSet(); - - lic = new License(); - - l.getLicenseList().add(lic); - ls.add(l); - - if(!onlyLicense){ - sla = new SLA(); - + + gd2 = new GridData(GridData.FILL, GridData.CENTER, true, false); + gd2.horizontalSpan = 2; + + gd3 = new GridData(GridData.FILL, GridData.CENTER, true, false); + gd3.horizontalSpan = 3; + + ls = app.getApplication().getLicenses(); + + if(ls.getLicenseList().size() == 0){ + System.out.println("Adding empty license"); + ls.getLicenseList().add(new License()); + } + + //if(!onlyLicense){ Label l1 = new Label(container, SWT.NULL); - slaLink = new TextExt(container, SWT.BORDER | SWT.SINGLE); + slaLink = new TextExt(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); //mandatory.add(slaLink); //l1.setText("* SLA link"); l1.setText("SLA file"); - slaLink.setText(sla.getLink().toString()); + slaLink.setText(ls.getSla().getLink().toString()); slaLink.addVerifyListener(new UriV()); slaLink.setLayoutData(gd); //System.out.println(sla.getLink().toString()); @@ -90,11 +102,11 @@ public class PageLicenses extends PageImpl { public void widgetSelected(SelectionEvent e) { Dialog d = new Dialog(); - f1 = d.open(parent.getShell(), new String[]{"*.*"}, true, "Select a SLA file..."); + slaFile = d.open(parent.getShell(), new String[]{"*.*"}, true, "Select a SLA file..."); try { - slaLink.setText(f1.toURI().toURL()+""); - } catch (MalformedURLException e1) { - e1.printStackTrace(); + slaLink.setText(slaFile.toURI().toURL()+""); + } catch (Exception e1) { + //e1.printStackTrace(); } } @@ -107,7 +119,7 @@ public class PageLicenses extends PageImpl { //mandatory.add(slaName); //l2.setText("* SLA name"); l2.setText("SLA name"); - slaName.setText(sla.getName()); + slaName.setText(ls.getSla().getName()); slaName.addVerifyListener(new AlphabeticV()); slaName.setLayoutData(gd); @@ -115,17 +127,171 @@ public class PageLicenses extends PageImpl { empty1.setText(""); slaLink.addKeyListener(new FullListener()); - slaName.addKeyListener(new QL() { + + Label shadow_sep_h2 = new Label(container, SWT.SEPARATOR | SWT.SHADOW_OUT | SWT.HORIZONTAL); + shadow_sep_h2.setLayoutData(gd3); + //} + + for(int i=0; i < ls.getLicenseList().size(); i++){ + Label catLabel = new Label(container, SWT.NULL); + catLabel.setText("License category"); + + try{ + licCategory.get(i); + } catch(Exception e){ + licCategory.add(i, new Combo (container, SWT.READ_ONLY)); + LicenseCategory[] licCat = LicenseCategory.values(); + for(int j = 0; j < licCat.length; j++){ + licCategory.get(i).add(licCat[j].toString()); + } + } + + licCategory.get(i).setLayoutData(gd2); + licCategory.get(i).setText(ls.getLicenseList().get(i).getCategory().toString()); + + Label licLinkLabel = new Label(container, SWT.NULL); + licLinkLabel.setText("License Link"); + + try{ + licLink.get(i); + } catch(Exception e) { + licLink.add(i, new TextExt (container, SWT.BORDER | SWT.SINGLE)); + + } + licLink.get(i).setText(ls.getLicenseList().get(i).getLink().toASCIIString()); + licLink.get(i).addKeyListener(new QL() { @Override public void keyReleased(KeyEvent e) { - sla.setName(slaName.getText()); + TextExt tmp = (TextExt) e.widget; + int key = licLink.indexOf(tmp); + try{ + ls.getLicenseList().get(key).setLink(new URI(licLink.get(key).getText())); + } catch (URISyntaxException e1) { + // TODO Auto-generated catch block + } + } }); - l.setSla(sla); + licLink.get(i).setLayoutData(gd); + + try{ + buttons.get(i); + } catch(Exception e) { + buttons.add(i, new Button (container, SWT.PUSH)); + } + buttons.get(i).setText("Browse"); + buttons.get(i).addSelectionListener(new SelectionListener() { + + public void widgetSelected(SelectionEvent e) { + Button tmp = (Button) e.widget; + int key = buttons.indexOf(tmp); + Dialog d = new Dialog(); + licFile = d.open(parent.getShell(), new String[]{"*.*"}, true, "Select a license file..."); + if(licFile!=null) + try { + licLink.get(key).setText(licFile.toURI().toURL()+""); + ls.getLicenseList().get(key).setLink(licFile.toURI()); + } catch (Exception e1) { + // TODO Auto-generated catch block + //e1.printStackTrace(); + } + } + + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + + Label shadow_sep_3 = new Label(container, SWT.SEPARATOR | SWT.SHADOW_OUT | SWT.HORIZONTAL); + shadow_sep_3.setLayoutData(gd3); } + + final Button b = new Button(container, SWT.PUSH); + b.setText("Add another license"); + b.setLayoutData(gd); + + Label empty2 =new Label(container, SWT.NULL); + empty2.setText(""); + empty2.setLayoutData(gd2); + // t.setText("License "+app.getApplication().getLicenses().size()); + b.addSelectionListener(new SelectionListener() { + + public void widgetSelected(SelectionEvent e) { + if(!licLink.get(licLink.size()-1).getText().isEmpty()){ + ls.getLicenseList().add(new License()); + + Label catLabel = new Label(container, SWT.NULL); + catLabel.setText("License category"); + + licCategory.add(new Combo (container, SWT.READ_ONLY)); + LicenseCategory[] licCat = LicenseCategory.values(); + for(int j = 0; j < licCat.length; j++){ + licCategory.get(licCategory.size()-1).add(licCat[j].toString()); + } + + + licCategory.get(licCategory.size()-1).setLayoutData(gd2); + licCategory.get(licCategory.size()-1).setText(ls.getLicenseList().get(licCategory.size()-1).getCategory().toString()); + + + Label licLinkLabel = new Label(container, SWT.NULL); + licLinkLabel.setLayoutData(gd); + licLinkLabel.setText("License Link"); + licLink.add(new TextExt (container, SWT.BORDER | SWT.SINGLE)); + licLink.get(licLink.size()-1).setLayoutData(gd); + licLink.get(licLink.size()-1).addKeyListener(new QL() { + + @Override + public void keyReleased(KeyEvent e) { + TextExt tmp = (TextExt) e.widget; + int key = licLink.indexOf(tmp); + try{ + ls.getLicenseList().get(key).setLink(new URI(licLink.get(key).getText())); + } catch (URISyntaxException e1) { + // TODO Auto-generated catch block + } + + } + }); + buttons.add(new Button (container, SWT.PUSH)); + buttons.get(buttons.size()-1).setText("Browse"); + buttons.get(buttons.size()-1).addSelectionListener(new SelectionListener() { + + public void widgetSelected(SelectionEvent e) { + Button tmp = (Button) e.widget; + int key = buttons.indexOf(tmp); + Dialog d = new Dialog(); + licFile = d.open(parent.getShell(), new String[]{"*.*"}, true, "Select a license file..."); + try { + licLink.get(key).setText(licFile.toURI().toURL()+""); + ls.getLicenseList().get(key).setLink(licFile.toURI()); + } catch (Exception e1) { + // TODO Auto-generated catch block + //e1.printStackTrace(); + } + } + + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + + Label shadow_sep = new Label(container, SWT.SEPARATOR | SWT.SHADOW_OUT | SWT.HORIZONTAL); + shadow_sep.setLayoutData(gd3); + + container.layout(true); + sc1.setContent(container); + sc1.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + } + } - Label l3 = new Label(container, SWT.NULL); + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + + sc1.setContent(container); + sc1.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + + /* licCategory = new Combo (container, SWT.READ_ONLY); LicenseCategory[] licCat = LicenseCategory.values(); for(int i = 0; i < licCat.length; i++){ @@ -155,9 +321,9 @@ public class PageLicenses extends PageImpl { public void widgetSelected(SelectionEvent e) { Dialog d = new Dialog(); - f2 = d.open(parent.getShell(), new String[]{"*.*"}, true, "Select a license file..."); + licFile = d.open(parent.getShell(), new String[]{"*.*"}, true, "Select a license file..."); try { - licLink.setText(f2.toURI().toURL()+""); + licLink.setText(licFile.toURI().toURL()+""); } catch (MalformedURLException e1) { e1.printStackTrace(); } @@ -226,50 +392,35 @@ public class PageLicenses extends PageImpl { empty5.setText(""); Label empty6 = new Label(container, SWT.NULL); empty6.setText(""); - + */ setPageComplete(validate()); } @Override public boolean nextPressed() { - - if(!onlyLicense && slaLink.getText() != null && !slaLink.getText().isEmpty()){ - URI link = null; - try{ - link = URI.create(removeBlanks(slaLink.getText())); - } - catch(Exception ex){ - ex.printStackTrace(); - slaLink.setText(ERROR_MESSAGE); - - return false; - } - if(link != null) - sla.setLink(link); + URI link = null; + try{ + link = URI.create(removeBlanks(slaLink.getText())); } - if(licLink.getText() != null && !licLink.getText().isEmpty()){ - URI link = null; - try{ - link = URI.create(removeBlanks(licLink.getText())); - } - catch(Exception ex){ - ex.printStackTrace(); - licLink.setText(ERROR_MESSAGE); + catch(Exception ex){ + //ex.printStackTrace(); + slaLink.setText(ERROR_MESSAGE); - return false; - } - if(link != null) - lic.setLink(URI.create(removeBlanks(licLink.getText()))); + return false; } - - if(addLicense){ - PageLicenses pl = new PageLicenses(Page.PAGE_LICENSE+PageImpl.otherLicenses++, true); - pl.setMPA(multipartApplication); - //pl.setPageComplete(false); - addPageCustom(this, pl); + if(link != null){ + if(!slaName.getText().isEmpty()) + ls.getSla().setName(slaName.getText()); + + ls.getSla().setLink(link); } - - //serializeMPA(); return true; } + /* + @Override + public void setVisible(boolean visible){ + sc1.setVisible(visible); + super.setVisible(visible); + } + */ } \ No newline at end of file diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PagePartDU.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PagePartDU.java index 70431b7917f6a223d806e16d3b259310f8179385..71cd7e744d79c8fab932b771a05bc3d99005275d 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PagePartDU.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/PagePartDU.java @@ -84,12 +84,7 @@ public class PagePartDU extends PageImpl { ckbOS1.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { - ckbPL1.setSelection(false); - ckbOS1.setSelection(true); - ckbCU1.setSelection(false); - - enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); - disableControls(new ArrayList<Control>(Arrays.asList(platform1, cu1, emb1, andN, ckbKar, andD, andURI))); + enableOS(); } public void widgetDefaultSelected(SelectionEvent e) { @@ -102,12 +97,7 @@ public class PagePartDU extends PageImpl { ckbPL1.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { - ckbPL1.setSelection(true); - ckbOS1.setSelection(false); - ckbCU1.setSelection(false); - - enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); - disableControls(new ArrayList<Control>(Arrays.asList(os1, cu1, emb1, ckbKar, andN, andD, andURI))); + enablePlatform(); } public void widgetDefaultSelected(SelectionEvent e) { @@ -120,12 +110,7 @@ public class PagePartDU extends PageImpl { ckbCU1.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { - ckbPL1.setSelection(false); - ckbOS1.setSelection(false); - ckbCU1.setSelection(true); - - enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); - disableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, andN, /*ckbKar,*/ andD, andURI))); + enableCU(); } public void widgetDefaultSelected(SelectionEvent e) { @@ -298,6 +283,33 @@ public class PagePartDU extends PageImpl { setPageComplete(validate()); } + protected void enableCU() { + ckbPL1.setSelection(false); + ckbOS1.setSelection(false); + ckbCU1.setSelection(true); + + enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); + disableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, andN, /*ckbKar,*/ andD, andURI))); + } + + protected void enablePlatform() { + ckbPL1.setSelection(true); + ckbOS1.setSelection(false); + ckbCU1.setSelection(false); + + enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); + disableControls(new ArrayList<Control>(Arrays.asList(os1, cu1, emb1, ckbKar, andN, andD, andURI))); + } + + private void enableOS() { + ckbPL1.setSelection(false); + ckbOS1.setSelection(true); + ckbCU1.setSelection(false); + + enableControls(new ArrayList<Control>(Arrays.asList(os1, platform1, cu1, emb1, ckbKar, andN, andD, andURI))); + disableControls(new ArrayList<Control>(Arrays.asList(platform1, cu1, emb1, andN, ckbKar, andD, andURI))); + } + public void setArtifact(IProject part){ this.part = part; //p = new POMParser(new File(part.getFile("pom.xml").getLocation()+"")); @@ -316,18 +328,12 @@ public class PagePartDU extends PageImpl { String id = "_"+numb+alph; if(ckbOS1.getSelection()){ - try{ - app.getAppParts().get(partNumber).getDeploymentUnits().get(partNumber).setDeploymentUnit(id, os1.getText(),DeploymentUnit.OS); - } catch (IndexOutOfBoundsException e) { - app.getAppParts().get(partNumber).getDeploymentUnits().add(partNumber, new DeploymentUnit(id, os1.getText(),DeploymentUnit.OS)); - } + app.getAppParts().get(partNumber).getDeploymentUnit().setDeploymentUnit(id, os1.getText(),DeploymentUnit.OS); + } else if(ckbPL1.getSelection()){ - try{ - app.getAppParts().get(partNumber).getDeploymentUnits().get(partNumber).setDeploymentUnit(id, platform1.getText(),DeploymentUnit.PLATFORM); - } catch (IndexOutOfBoundsException e) { - app.getAppParts().get(partNumber).getDeploymentUnits().add(partNumber, new DeploymentUnit(id, platform1.getText(),DeploymentUnit.PLATFORM)); - } + app.getAppParts().get(partNumber).getDeploymentUnit().setDeploymentUnit(id, platform1.getText(),DeploymentUnit.PLATFORM); + } else if(ckbCU1.getSelection()){ ContainerUnit cu = null; @@ -350,15 +356,11 @@ public class PagePartDU extends PageImpl { } cu = new ContainerUnit(new Android(andN.getText(), andD.getText(), URI.create(removeBlanks(andURI.getText())))); } - else if(!cu1.getText().equals(Container.KARAF.toString()) && !cu1.getText().equals(Container.ANDROID)){ + else if(!cu1.getText().equals(Container.KARAF) && !cu1.getText().equals(Container.ANDROID)){ cu = new ContainerUnit(cu1.getText()); } - try{ - app.getAppParts().get(partNumber).getDeploymentUnits().get(partNumber).setDeploymentUnit(id, cu); - } catch (IndexOutOfBoundsException e){ - app.getAppParts().get(partNumber).getDeploymentUnits().add(partNumber, new DeploymentUnit(id, cu)); - } - + app.getAppParts().get(partNumber).getDeploymentUnit().setDeploymentUnit(id, cu); + } getShell().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW)); @@ -374,59 +376,59 @@ public class PagePartDU extends PageImpl { private void loadData(){ - List<DeploymentUnit> DUs = app.getAppParts().get(partNumber).getDeploymentUnits(); + DeploymentUnit DU = app.getAppParts().get(partNumber).getDeploymentUnit(); try{ - if(DUs.get(partNumber).getType().equals(DeploymentUnit.OS)) ckbOS1.notifyListeners(SWT.Selection, new Event()); - else if(DUs.get(partNumber).getType().equals(DeploymentUnit.PLATFORM)) ckbPL1.notifyListeners(SWT.Selection, new Event()); - else if(DUs.get(partNumber).getType().equals(DeploymentUnit.CONTAINER)) ckbCU1.notifyListeners(SWT.Selection, new Event()); + if(DU.getType().equals(DeploymentUnit.OS)) enableOS(); + else if(DU.getType().equals(DeploymentUnit.PLATFORM)) enablePlatform(); + else if(DU.getType().equals(DeploymentUnit.CONTAINER)) enableCU(); } catch (Exception e){ - if(app.getAppRequirements().deploymentUnitType.equals(DeploymentUnit.OS)) ckbOS1.notifyListeners(SWT.Selection, new Event()); - else if(app.getAppRequirements().deploymentUnitType.equals(DeploymentUnit.PLATFORM)) ckbPL1.notifyListeners(SWT.Selection, new Event()); - else if(app.getAppRequirements().deploymentUnitType.equals(DeploymentUnit.CONTAINER)) ckbCU1.notifyListeners(SWT.Selection, new Event()); + if(app.getAppRequirements().deploymentUnitType.equals(DeploymentUnit.OS)) enableOS(); + else if(app.getAppRequirements().deploymentUnitType.equals(DeploymentUnit.PLATFORM)) enablePlatform(); + else if(app.getAppRequirements().deploymentUnitType.equals(DeploymentUnit.CONTAINER)) enableCU(); } try{ - os1.setText(DUs.get(partNumber).getUnit()); + os1.setText(DU.getUnit()); } catch (Exception e) { if(!app.getAppRequirements().OS_Requirements.isEmpty()) os1.setText(app.getAppRequirements().OS_Requirements); } try{ - platform1.setText(DUs.get(partNumber).getUnit()); + platform1.setText(DU.getUnit()); } catch (Exception e) { if(!app.getAppRequirements().Platform_Requirement.isEmpty()) platform1.setText(app.getAppRequirements().Platform_Requirement); } try{ - cu1.setText(DUs.get(partNumber).getCu().getContainer().toString()); + cu1.setText(DU.getCu().getContainer().toString()); } catch (Exception e) { cu1.setText(app.getAppRequirements().Container_Name); if(!app.getAppRequirements().Container_Name.isEmpty()) enableControl(ckbKar); } try{ - emb1.setText(DUs.get(partNumber).getCu().getEmbedding().toString()); + emb1.setText(DU.getCu().getEmbedding().toString()); } catch (Exception e) { emb1.setText(app.getAppRequirements().embedding); } try{ - andN.setText(DUs.get(partNumber).getCu().getAndroidPart().getName()); + andN.setText(DU.getCu().getAndroidPart().getName()); } catch (Exception e) { andN.setText(app.getAppRequirements().android.getName()); } try{ - andD.setText(DUs.get(partNumber).getCu().getAndroidPart().getDescription()); + andD.setText(DU.getCu().getAndroidPart().getDescription()); } catch (Exception e) { andD.setText(app.getAppRequirements().android.getDescription()); } try{ - andURI.setText(DUs.get(partNumber).getCu().getAndroidPart().getLocation().toASCIIString()); + andURI.setText(DU.getCu().getAndroidPart().getLocation().toASCIIString()); } catch (Exception e) { andURI.setText(app.getAppRequirements().android.getLocation().toASCIIString()); } diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/App.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/App.java index 0a26dfbdece8aba7daf231bae0510890cc58a589..b1f98ab6178d60d6743702b83cd585709b64512d 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/App.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/App.java @@ -37,7 +37,8 @@ public class App implements Serializable { private boolean multipart; private String tags; private Contact applicationProvider; - private List<LicenseSet> licenses; + //private List<LicenseSet> licenses; + private LicenseSet licenses; private MenuEntry menuEntry; public App(){ @@ -111,6 +112,7 @@ public class App implements Serializable { return menuEntry; } + /* public List<LicenseSet> getLicenses() { if(licenses == null) licenses = new ArrayList<LicenseSet>(); @@ -120,7 +122,18 @@ public class App implements Serializable { public void setLicenses(List<LicenseSet> licenses) { this.licenses = licenses; } - + */ + + public LicenseSet getLicenses() { + if(licenses == null) + licenses = new LicenseSet(); + return licenses; + } + + public void setLicenses(LicenseSet licenses) { + this.licenses = licenses; + } + public String getXML(){ String r = ""; @@ -132,8 +145,10 @@ public class App implements Serializable { r = r.concat("<multipart>"+multipart+"</multipart>"); r = r.concat("<tags>"+tags+"</tags>"); r = r.concat("<applicationProvider>"+applicationProvider.getXML()+"</applicationProvider>"); - for(int i = 0; i < getLicenses().size(); i++) + /*for(int i = 0; i < getLicenses().size(); i++) r = r.concat(licenses.get(i).getXML()); + */ + r = r.concat(licenses.getXML()); r = r.concat("<applicationProfile>"+applicationProfile+"</applicationProfile>"); if(menuEntry.getMenuName().trim().length() > 0) r = r.concat("<menuEntry>"+menuEntry.getXML()+"</menuEntry>"); //r = r.concat("</app>"); diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/DeploymentUnit.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/DeploymentUnit.java index d64a3e7e431baae2f9ae7d3170d88f2155b03824..e6e7c3f3d3e6408c47f4fe60a8396880ab779c8e 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/DeploymentUnit.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/DeploymentUnit.java @@ -41,6 +41,13 @@ public class DeploymentUnit implements Serializable { private String type; private ContainerUnit cu; + public DeploymentUnit(){ + this.id = null; + this.type = null; + this.unit = null; + this.cu = null; + } + public DeploymentUnit(String id, String unit, String type){ this.id = id; diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/LicenseSet.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/LicenseSet.java index 3dcbccd551a103709e2f2e147f06df86f6af057d..8f9af17f65f395d7fb043fe8e5c84696513f1e7a 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/LicenseSet.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/LicenseSet.java @@ -60,8 +60,10 @@ public class LicenseSet implements Serializable{ String r = ""; r = r.concat("<licenses>"); - for(int i = 0; i< licenseList.size(); i++) - r = r.concat("<license>"+licenseList.get(i).getXML()+"</license>"); + for(int i = 0; i< licenseList.size(); i++){ + if(!licenseList.get(i).getLink().toASCIIString().trim().isEmpty()) + r = r.concat("<license>"+licenseList.get(i).getXML()+"</license>"); + } r = r.concat(sla.getXML()); r = r.concat("</licenses>"); diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/Part.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/Part.java index 3b2082d853afce3bd4c0b056ebe90d72bf8002b7..2024e44233566bfc101db7f0462aa9a4d6ac800e 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/Part.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/Part.java @@ -41,7 +41,8 @@ public class Part implements Serializable { private String bundleVersion = ""; private Properties partCapabilities; private List<Requirement> partRequirements; - private List<DeploymentUnit> deploymentUnits; + //private List<DeploymentUnit> deploymentUnits; + private DeploymentUnit deploymentUnit; //private List<ExecutionUnit> executionUnits; private ExecutionUnit executionUnit = null; @@ -110,10 +111,10 @@ public class Part implements Serializable { partRequirements = new ArrayList<Requirement>(); return partRequirements; } - public List<DeploymentUnit> getDeploymentUnits() { - if(deploymentUnits == null) - deploymentUnits = new ArrayList<DeploymentUnit>(); - return deploymentUnits; + public DeploymentUnit getDeploymentUnit() { + if(deploymentUnit == null) + deploymentUnit = new DeploymentUnit(); + return deploymentUnit; } /* @@ -160,8 +161,11 @@ public class Part implements Serializable { r = r.concat("<requirement>"+partRequirements.get(i).getXML()+"</requirement>"); r = r.concat("</partRequirements>"); - for(int i = 0; i < getDeploymentUnits().size(); i++) - r = r.concat(deploymentUnits.get(i).getXML()); + try{ + r = r.concat(deploymentUnit.getXML()); + } catch (Exception e){ + + } /* for(int i = 0; i < getExecutionUnits().size(); i++) r = r.concat(executionUnits.get(i).getXML()); diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/EffectivePOMContainer.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/EffectivePOMContainer.java index 4196c2f946c1904cc9f1b235512c6a004bdfb51c..a2903f631ee590d49e5dbfa80db03f22ee9d4979 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/EffectivePOMContainer.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/EffectivePOMContainer.java @@ -116,10 +116,10 @@ public class EffectivePOMContainer{ } public static List<POM_License> getLicenses(){ List<POM_License> returnList = new ArrayList<POM_License>(); - NodeList nodes = getValues("//project/licenses/license"); + NodeList nodes = getValues("/projects/project[1]/licenses/license|/project/licenses/license"); if (nodes != null){ - //System.out.println("Num Licenses: "+nodes.getLength()); + //System.out.println("Num Nodes Licenses: "+nodes.getLength()); for (int i = 0; i < nodes.getLength(); i++) { Element el = (Element) nodes.item(i); diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/KarafFeaturesGenerator.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/KarafFeaturesGenerator.java index 8b4153ed12e49f406e3ff65ce66fb0b9bf9444bf..73556aa825a061335fd76d9aa52c0351bd920285 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/KarafFeaturesGenerator.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/KarafFeaturesGenerator.java @@ -228,6 +228,7 @@ public class KarafFeaturesGenerator { IMaven maven = MavenPlugin.getMaven(); if(pomResource != null && projectFacade != null){ MavenExecutionRequest request = projectManager.createExecutionRequest(pomResource, projectFacade.getResolverConfiguration(), null); + System.out.println( "Preparing to run maven, the log level was:" + request.getLoggingLevel() + " but we increased to "+MavenExecutionRequest.LOGGING_LEVEL_DEBUG @@ -256,6 +257,7 @@ public class KarafFeaturesGenerator { ExecutionEventLogger execLogger = new ExecutionEventLogger(logger); request.setExecutionListener(execLogger); + List<String> goals = new ArrayList<String>(); Properties props = new Properties(); @@ -273,7 +275,9 @@ public class KarafFeaturesGenerator { System.out.println("[Application Packager] - Generating Karaf features file..."); goals.clear(); - props = new Properties(); + /*goals.add("eclipse:eclipse"); + props.setProperty("eclipse.useProjectReferences","false"); + */ goals.add(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION + ":" + GOAL_FEATURE); request.setGoals(goals); request.setUserProperties(props);