diff --git a/mpa/org.universaal.tools.packaging.tool/build.properties b/mpa/org.universaal.tools.packaging.tool/build.properties index b458bb1c0f5f8c048b5c75320390f7a5753ebda6..7e65dccb4ef35c5b6a9fda9437b5f77516a0678c 100644 --- a/mpa/org.universaal.tools.packaging.tool/build.properties +++ b/mpa/org.universaal.tools.packaging.tool/build.properties @@ -4,4 +4,6 @@ bin.includes = plugin.xml,\ META-INF/,\ .,\ icons/,\ - lib/ + lib/,\ + lib/ui.handler.gui.swing-2.0.0-sources.jar +jars.compile.order = . diff --git a/mpa/org.universaal.tools.packaging.tool/lib/ui.handler.gui.swing-2.0.0-sources.jar b/mpa/org.universaal.tools.packaging.tool/lib/ui.handler.gui.swing-2.0.0-sources.jar new file mode 100644 index 0000000000000000000000000000000000000000..0fe1d7a2c70c4283c51478a3e67f659ffcebda02 Binary files /dev/null and b/mpa/org.universaal.tools.packaging.tool/lib/ui.handler.gui.swing-2.0.0-sources.jar differ 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 eed534fdaf52fe94304d64c38411cb94ff46572a..c5e4adc45469b0a379a900486084d7a6375f03c5 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 @@ -65,8 +65,7 @@ public class Activator extends AbstractUIPlugin { 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+" ***"); 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 2999b648c7ab83b3eae41f147634203e129599b9..9de98dff01f6ac1ed3508aec67fe0d07928fbb5e 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 @@ -1,5 +1,15 @@ package org.universaal.tools.packaging.tool.actions; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -17,6 +27,8 @@ import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; import org.eclipse.ui.handlers.HandlerUtil; import org.universaal.tools.packaging.tool.api.WizardDialogMod; import org.universaal.tools.packaging.tool.gui.GUI; +import org.universaal.tools.packaging.tool.util.ConfigProperties; +import org.universaal.tools.packaging.tool.util.Configurator; /** * Our sample action implements workbench action delegate. @@ -29,34 +41,99 @@ import org.universaal.tools.packaging.tool.gui.GUI; public class MPAaction extends AbstractHandler { public GUI gui; - + private Boolean recovered = false; + public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow w = HandlerUtil.getActiveWorkbenchWindow(event); List<IProject> parts = new ArrayList<IProject>(); - - FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(w.getShell(), true, ResourcesPlugin.getWorkspace().getRoot(), IResource.PROJECT); - dialog.setTitle("Resources Selection"); - dialog.setMessage("Please select the universAAL projects you want to include in the UAPP container"); - dialog.setInitialPattern("?"); - dialog.open(); - - if(dialog.getResult() != null){ - for(int i = 0; i < dialog.getResult().length; i++){ - String[] segments = dialog.getResult()[i].toString().split("/"); - IContainer container = ResourcesPlugin.getWorkspace().getRoot().getProject(segments[segments.length-1]); - parts.add(container.getProject()); + String recFile = org.universaal.tools.packaging.tool.Activator.tempDir + Configurator.local.getRecoveryFileName(); + String recParts = org.universaal.tools.packaging.tool.Activator.tempDir + Configurator.local.getRecoveryPartsName(); + + if ( Configurator.local.isPersistanceEnabled()) { + System.out.println("Searching for recovery file "+ recFile); + File recovery = new File(recFile); + if(recovery.exists()){ + System.out.println("Found It"); + System.out.println("Searching for recovery parts file "+ recParts); + File recoveryParts = new File(recParts); + if(recoveryParts.exists()){ + System.out.println("Found It"); + Boolean tryRecover = MessageDialog.openConfirm(w.getShell(), + "Recovery", "A previous operation has been cancelled.\n\nWould you like to recover it ?"); + if(tryRecover){ + + try{ + String content = readFile(recParts, StandardCharsets.UTF_8); + String[] segments = content.split(System.getProperty("line.separator")); + //System.out.println(segments[segments.length-1]); + for(int i = 0; i < segments.length; i++){ + if(!segments[i].trim().isEmpty()){ + System.out.println("Importing part "+segments[i]); + IContainer container = ResourcesPlugin.getWorkspace().getRoot().getProject(segments[i]); + parts.add(container.getProject()); + } + } + this.recovered = true; + } catch (IOException e){ + e.printStackTrace(); + } + } else { + this.recovered = false; + } + } } - gui = new GUI(parts); + } + + if(!this.recovered){ + FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(w.getShell(), true, ResourcesPlugin.getWorkspace().getRoot(), IResource.PROJECT); + dialog.setTitle("Resources Selection"); + dialog.setMessage("Please select the universAAL projects you want to include in the UAPP container"); + dialog.setInitialPattern("?"); + dialog.open(); + + String partsFileContent = ""; + + if(dialog.getResult() != null){ + for(int i = 0; i < dialog.getResult().length; i++){ + String[] segments = dialog.getResult()[i].toString().split("/"); + //System.out.println(segments[segments.length-1]); + IContainer container = ResourcesPlugin.getWorkspace().getRoot().getProject(segments[segments.length-1]); + parts.add(container.getProject()); + partsFileContent = partsFileContent + segments[segments.length-1] + System.getProperty("line.separator"); + } + + if(Configurator.local.isPersistanceEnabled()){ + try { + File f = new File(org.universaal.tools.packaging.tool.Activator.tempDir); + if(!f.exists()) f.mkdir(); + BufferedWriter bw = new BufferedWriter(new FileWriter(recParts)); + bw.write(partsFileContent); + bw.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } else{ + MessageDialog.openInformation(w.getShell(), + "Application Packager", "Please verify the selection of parts."); + } + } + + if(parts.size()>0){ + gui = new GUI(parts, this.recovered); WizardDialogMod wizardDialog = new WizardDialogMod(w.getShell(), gui); wizardDialog.open(); } - else{ - MessageDialog.openInformation(w.getShell(), - "Application Packager", "Please verify the selection of parts."); - } - + return null; } + + private static String readFile(String path, Charset encoding) throws IOException { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return encoding.decode(ByteBuffer.wrap(encoded)).toString(); + } + } \ No newline at end of file diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/api/Page.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/api/Page.java index 9b0fcedcf6d74c9af452f8e9e6617ba8ebeec825..9ba1f478e23c728b776d6e11e57359e8f1d432f9 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/api/Page.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/api/Page.java @@ -20,7 +20,7 @@ public interface Page { public final String KARAF_NAMESPACE = "krf"; - public final String XSD = "'http://www.universaal.org/aal-uapp/v1.0.1'"; // "'http://www.universaal.org/aal-uapp/v1.0.0'" - //"http://www.universaal.org/aal-uapp/v1.0.0/AAL-UAPP.xsd"; + public final String XSD = "'http://www.universaal.org/aal-uapp/v1.0.2'"; // "'http://www.universaal.org/aal-uapp/v1.0.0'" - //"http://www.universaal.org/aal-uapp/v1.0.0/AAL-UAPP.xsd"; public final String Karaf = "'http://karaf.apache.org/xmlns/features/v1.0.0'"; public final String w3c = "'http://www.w3.org/2001/XMLSchema'"; diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/api/WizardMod.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/api/WizardMod.java index f2600ce5dfff059f956c86c580ea70dbd90ff5b6..9d66af649530ae0022c4dc0e7b2d630624f3d41d 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/api/WizardMod.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/api/WizardMod.java @@ -29,6 +29,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; +import org.universaal.tools.packaging.tool.parts.MPA; /** * An abstract base implementation of a wizard. A typical client subclasses @@ -169,6 +170,10 @@ public abstract class WizardMod implements IWizard { return -1; } + public void resetPages(){ + pages.clear(); + } + /** * The <code>Wizard</code> implementation of this <code>IWizard</code> * method does nothing. Subclasses should extend if extra pages need to be @@ -302,10 +307,16 @@ public abstract class WizardMod implements IWizard { } public void setPages(List<IWizardPage> pp){ - pages = pp; - for(int i = 0; i < pages.size(); i++) - if(pages.get(i) == null) - pages.remove(i); + System.out.println("Old Pages count:"+pages.size()); + pages.clear(); + for(int i = 0; i < pp.size(); i++){ + if(pp.get(i) != null){ + System.out.println(pp.get(i).getName()); + addPage(pp.get(i)); + } + } + System.out.println("New Pages count:"+pages.size()); + } /* 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 09c21205f969c930898716fd3fa2659cc995c337..9193d6fa5330c79b05897024bd3a357aa665f936 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 @@ -30,8 +30,8 @@ import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; +import java.io.ObjectInputStream; import java.io.OutputStream; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,7 +43,6 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ParameterizedCommand; import org.eclipse.core.resources.IProject; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.swt.widgets.Event; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; @@ -51,7 +50,6 @@ import org.eclipse.ui.handlers.IHandlerService; import org.universaal.tools.packaging.tool.api.Page; import org.universaal.tools.packaging.tool.api.WizardMod; import org.universaal.tools.packaging.tool.impl.PageImpl; -import org.universaal.tools.packaging.tool.impl.PersistencePageDecorator; import org.universaal.tools.packaging.tool.parts.MPA; import org.universaal.tools.packaging.tool.parts.Part; import org.universaal.tools.packaging.tool.util.ConfigProperties; @@ -71,20 +69,55 @@ public class GUI extends WizardMod { private PageImpl p0, p1, p2, pl, p3, p4, p5, ppB, ppDU, ppEU, ppPC, ppPR, p, p_end; private List<IProject> parts; + private static GUI instance; private String destination; private String tempDir = org.universaal.tools.packaging.tool.Activator.tempDir; public File recoveryStorage = null; - public GUI(List<IProject> parts) { + public GUI(List<IProject> parts, Boolean recovered) { super(); setNeedsProgressMonitor(true); - - mpa = new MPA(); + + checkPersistence(recovered); + + if(mpa == null){ + mpa = new MPA(); + } + instance = this; this.parts = parts; + + } + + private void checkPersistence(Boolean recovered) { + if ( Configurator.local.isPersistanceEnabled() ) { + //File tmpDir = new File(tempDir); + File recovery = new File(tempDir + ConfigProperties.RECOVERY_FILE_NAME_DEFAULT); + recoveryStorage = recovery; + + //if ( tmpDir.exists() ) { + if ( recovery.exists() && recovered) { + + try { + ObjectInputStream ois = new ObjectInputStream( new FileInputStream( recovery ) ); + MPA recoveredStatus = (MPA) ois.readObject(); + //multipartApplication.setApplication(recoveredStatus.getAAL_UAPP()); + if (recoveredStatus != null){ + System.out.println("Loading recovered data from "+recovery.getAbsolutePath()); + mpa = recoveredStatus; + } else { + System.out.println("[WARNING] Unable to load data from recovery file"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + //} + } // else System.out.println("Recovering not enabled"); } public static synchronized GUI getInstance(){ @@ -94,11 +127,11 @@ public class GUI extends WizardMod { @Override public void addPages() { if(this.parts != null){ - + p0 = new StartPage(Page.PAGE_START); addPage(p0); p0.setMPA(mpa); - + p1 = new Page1(Page.PAGE1); addPage(p1); p1.setMPA(mpa); @@ -110,7 +143,7 @@ public class GUI extends WizardMod { pl = new PageLicenses(Page.PAGE_LICENSE); addPage(pl); pl.setMPA(mpa); - + p3 = new Page3(Page.PAGE3); addPage(p3); p3.setMPA(mpa); @@ -173,7 +206,7 @@ public class GUI extends WizardMod { createTempContainer(); } - private void addingPermanentStorageDecorator() { + private void addingPermanentStorageDecorator() {/* if ( ! Configurator.local.isPersistanceEnabled() ) return; IWizardPage[] phases = getPages(); ArrayList<IWizardPage> decoratedPhases = new ArrayList<IWizardPage>(); @@ -184,7 +217,7 @@ public class GUI extends WizardMod { decoratedPhases.add( phases[i] ); } } - setPages(decoratedPhases); + setPages(decoratedPhases);*/ } @Override diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page1.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page1.java index 8300f782a521a3ecbb6375135d21e86f155bc3c1..cf316d041fcd50fc78e11d00dbace197fa2f59d5 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page1.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/Page1.java @@ -20,30 +20,59 @@ */ package org.universaal.tools.packaging.tool.gui; +import java.awt.BorderLayout; +import java.awt.Graphics2D; import java.awt.image.BufferedImage; +import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.net.URI; +import java.net.URL; +import java.util.Enumeration; import java.util.Iterator; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import javax.imageio.stream.ImageInputStream; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; +import org.eclipse.ui.handlers.HandlerUtil; import org.universaal.tools.packaging.tool.impl.PageImpl; + +import org.universaal.tools.packaging.tool.parts.Capability; import org.universaal.tools.packaging.tool.util.Dialog; import org.universaal.tools.packaging.tool.util.XSDParser; import org.universaal.tools.packaging.tool.validators.AlphabeticV; @@ -61,8 +90,9 @@ import org.universaal.tools.packaging.tool.validators.UriV; public class Page1 extends PageImpl { private TextExt name, id, description, tags, version_major, version_minor, version_micro, version_build, app_profile, menuName, serviceUri, iconFile; + private Combo customIcon; private File sourcePNG; - private Button b1; + private Button b1, b2; private String iconFormat = "png", formatName; protected Page1(String pageName) { @@ -175,7 +205,7 @@ public class Page1 extends PageImpl { menuName.setText(app.getApplication().getMenuEntry().getMenuName()); menuName.addVerifyListener(new AlphabeticV()); menuName.setLayoutData(gd); - menuName.addTooltip(XSDtooltip.find("app.menuEntry.menuName")); + menuName.addTooltip(XSDtooltip.find("menuEntry.menuName")); Label label12 = new Label(container, SWT.NULL); label12.setText("* Service URI"); @@ -184,7 +214,7 @@ public class Page1 extends PageImpl { serviceUri.setText(app.getApplication().getMenuEntry().getServiceUri().toASCIIString()); serviceUri.setLayoutData(gd); serviceUri.addVerifyListener(new UriV()); - serviceUri.addTooltip(XSDtooltip.find("app.menuEntry.serviceUri")); + serviceUri.addTooltip(XSDtooltip.find("menuEntry.serviceUri")); Label label13 = new Label(container, SWT.NULL); label13.setText("Menu Entry Icon (PNG 512x512 px A/R 1:1)"); @@ -192,13 +222,13 @@ public class Page1 extends PageImpl { iconFile = new TextExt(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); iconFile.setLayoutData(gd); iconFile.addVerifyListener(new FileV()); - iconFile.addTooltip(XSDtooltip.find("app.menuEntry.iconPath")); + iconFile.addTooltip(XSDtooltip.find("icon.path")); Label label133 = new Label(container, SWT.NULL); label133.setText(""); b1 = new Button(container, SWT.PUSH); - b1.setText("Browse"); + b1.setText("Browse from files"); b1.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { @@ -231,8 +261,7 @@ public class Page1 extends PageImpl { image = ImageIO.read(sourcePNG); if(image != null && formatName.equalsIgnoreCase(iconFormat)){ - iconFile.setText(sourcePNG.getAbsolutePath()); - + double width = image.getWidth(); double height = image.getHeight(); double aspect_ratio = width/height; @@ -250,7 +279,10 @@ public class Page1 extends PageImpl { else MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Invalid size and aspect ratio", "The selected image will be scaled and stretched due to invalid pixel size and aspect ratio.\n\nThe optimal size is 512x512 pixels (A/R 1:1)"); } - + + app.getApplication().getMenuEntry().setIsCustomIcon(false); + customIcon.deselectAll(); + iconFile.setText(sourcePNG.getAbsolutePath()); } else MessageDialog.openError(null, "Invalid format", "The selected file is not a valid PNG file"); @@ -265,7 +297,114 @@ public class Page1 extends PageImpl { } }); - name.addKeyListener(new FullListener()); + + Label void1 = new Label(container, SWT.NULL); + void1.setText(""); + + Label b2l = new Label(container, SWT.NULL); + b2l.setText("or select from custom icons:"); + + Label void2 = new Label(container, SWT.NULL); + void2.setText(""); + + customIcon = new Combo(container, SWT.READ_ONLY); + + InputStream is = getClass().getResourceAsStream("/lib/ui.handler.gui.swing-2.0.0-sources.jar"); + + try { + ZipInputStream zis = new ZipInputStream(is); + ZipEntry ze; + + while ((ze = zis.getNextEntry()) != null) { + if (ze.getName().contains("icons") && ze.getName().contains(".png")) { + customIcon.add(ze.getName()); + } + } + is.close(); + } catch (Exception e1) { + e1.printStackTrace(); + } + + customIcon.addModifyListener(new ModifyListener(){ + + public void modifyText(ModifyEvent e) { + + app.getApplication().getMenuEntry().setIsCustomIcon(true); + if(customIcon.getText().trim().length() > 0) iconFile.setText(""); + setPageComplete(validate()); + } + }); + + /* + InputStream imgs = getClass().getResourceAsStream("/icons/app/Health.png"); + System.out.println("-- img stream:"+imgs.toString()); + BufferedImage image = null; + try { + image = ImageIO.read(imgs); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if(image!=null){ + + double width = image.getWidth(); + double height = image.getHeight(); + double aspect_ratio = width/height; + System.out.println("Height : "+ height); + System.out.println("Width : "+ width); + System.out.println("A/R : "+ aspect_ratio); + } + + Image simpleImg = new Image(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay(), imgs); + + /* + + b2 = new Button(container, SWT.PUSH); + b2.setText("Browse from custom icons"); + b2.addSelectionListener(new SelectionListener() { + + public void widgetSelected(SelectionEvent e) { + + InputStream is = getClass().getResourceAsStream("/lib/ui.handler.gui.swing-2.0.0-sources.jar"); + + try { + ZipInputStream zis = new ZipInputStream(is); + ZipEntry ze; + + boolean imgLoaded = false; + while ((ze = zis.getNextEntry()) != null) { + if (ze.getName().contains("icons") && ze.getName().contains(".png")) { + System.out.print("File : " + ze.getName()); + + String path = "/"+ze.getName(); + URL url = getClass().getResource(path); + System.out.println(" - url: "+url); + InputStream imgs = getClass().getResourceAsStream(path); + System.out.println("-- img stream:"+imgs.toString()); + BufferedImage image = ImageIO.read(imgs); + Image simpleImg = new Image(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay(), imgs); + if(image!=null){ + double width = image.getWidth(); + double height = image.getHeight(); + double aspect_ratio = width/height; + System.out.println("Height : "+ height); + System.out.println("Width : "+ width); + System.out.println("A/R : "+ aspect_ratio); + } + } + } + is.close(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + */ + + + name.addKeyListener(new FullListener()); id.addKeyListener(new FullListener()); description.addKeyListener(new FullListener()); version_major.addKeyListener(new FullListener()); @@ -286,6 +425,8 @@ public class Page1 extends PageImpl { checkMenuEntry(); loadDefaultValues(); + setPageComplete(validate()); + } @@ -299,6 +440,8 @@ public class Page1 extends PageImpl { iconFile.setEnabled(false); b1.setEnabled(false); + customIcon.setEnabled(false); + } else { serviceUri.setEnabled(true); mandatory.add(serviceUri); @@ -306,12 +449,14 @@ public class Page1 extends PageImpl { iconFile.setEnabled(true); b1.setEnabled(true); + customIcon.setEnabled(true); + } } private void loadDefaultValues() { if ( app.getApplication() != null ) { - name.setText( app.getApplication().getName() ); + name.setText( app.getApplication().getName() ); id.setText( app.getApplication().getAppID() ); description.setText( app.getApplication().getDescription() ); version_minor.setText( app.getApplication().getVersion().getMajor() ); @@ -338,11 +483,20 @@ public class Page1 extends PageImpl { app.getApplication().getMenuEntry().setServiceUri(URI.create(serviceUri.getText())); if(iconFile.getText().trim().length()>0) app.getApplication().getMenuEntry().setIconFile(sourcePNG); + else if(customIcon.getText().trim().length()>0){ + app.getApplication().getMenuEntry().setIconPath(new URI(customIcon.getText().trim().toString().replaceAll("/", "."))); + } + + } + + serializeMPA(); + } catch(Exception ex){ ex.printStackTrace(); } return true; } + } \ No newline at end of file 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 78f6d9a56c7842aec94646308a177ddc3c644cf2..02a43cffafbf5805d311d36d48120795009a0b7b 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 @@ -3,6 +3,8 @@ package org.universaal.tools.packaging.tool.gui; import java.io.File; import java.net.MalformedURLException; import java.net.URI; +import java.util.Iterator; +import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; @@ -17,6 +19,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.universaal.tools.packaging.tool.impl.PageImpl; import org.universaal.tools.packaging.tool.parts.OtherChannel; +import org.universaal.tools.packaging.tool.util.Configurator; import org.universaal.tools.packaging.tool.util.XSDParser; import org.universaal.tools.packaging.tool.validators.AlphabeticV; import org.universaal.tools.packaging.tool.validators.PhoneV; @@ -94,7 +97,7 @@ public class Page2 extends PageImpl { email = new TextExt(container, SWT.BORDER | SWT.SINGLE); mandatory.add(email); l3.setText("* Contact e-mail"); - email.setText(app.getApplication().getApplicationProvider().getContactPerson()); + email.setText(app.getApplication().getApplicationProvider().getEmail()); //email.addVerifyListener(new MailV()); //TODO not working email.setLayoutData(gd); email.addTooltip(XSDtooltip.find("contactType.email")); @@ -139,8 +142,8 @@ public class Page2 extends PageImpl { othChNm1 = new TextExt(container, SWT.BORDER | SWT.SINGLE); //mandatory.add(web); l8.setText("Other contact #1 - Identifier (tel., e-mail, ...)"); - othChNm1.setText(""); - othChNm1.addVerifyListener(new AlphabeticV()); + //othChNm1.setText(""); + //othChNm1.addVerifyListener(new AlphabeticV()); othChNm1.setLayoutData(gd); othChNm1.addTooltip(XSDtooltip.find("otherChannel.channelName")); @@ -148,8 +151,8 @@ public class Page2 extends PageImpl { othChnDtl1 = new TextExt(container, SWT.BORDER | SWT.SINGLE); //mandatory.add(web); l9.setText("Other contact #1 - Details (tel. number, e-mail address, ...)"); - othChnDtl1.setText(""); - othChnDtl1.addVerifyListener(new AlphabeticV()); + //othChnDtl1.setText(""); + //othChnDtl1.addVerifyListener(new AlphabeticV()); othChnDtl1.setLayoutData(gd); othChnDtl1.addTooltip(XSDtooltip.find("otherChannel.channelDetails")); @@ -157,8 +160,8 @@ public class Page2 extends PageImpl { othChNm2 = new TextExt(container, SWT.BORDER | SWT.SINGLE); //mandatory.add(web); l10.setText("Other contact #2 - Identifier (fax, other...)"); - othChNm2.setText(""); - othChNm2.addVerifyListener(new AlphabeticV()); + //othChNm2.setText(""); + //othChNm2.addVerifyListener(new AlphabeticV()); othChNm2.setLayoutData(gd); othChNm2.addTooltip(XSDtooltip.find("otherChannel.channelName")); @@ -166,8 +169,8 @@ public class Page2 extends PageImpl { othChnDtl2 = new TextExt(container, SWT.BORDER | SWT.SINGLE); //mandatory.add(web); l11.setText("Other contact #2 - Details (fax number, other...)"); - othChnDtl2.setText(""); - othChnDtl2.addVerifyListener(new AlphabeticV()); + //othChnDtl2.setText(""); + //othChnDtl2.addVerifyListener(new AlphabeticV()); othChnDtl2.setLayoutData(gd); othChnDtl2.addTooltip(XSDtooltip.find("otherChannel.channelDetails")); @@ -194,7 +197,7 @@ public class Page2 extends PageImpl { @Override public void keyReleased(KeyEvent e) { - app.getApplication().getApplicationProvider().setEmail(email.getText()); + app.getApplication().getApplicationProvider().setEmail(email.getText()); } }); organization.addKeyListener(new QL() { @@ -258,6 +261,10 @@ public class Page2 extends PageImpl { otherContacts(4); } }); + + if ( Configurator.local.isPersistanceEnabled() ) setPageComplete(validate()); + loadDefaultValues(); + } private void otherContacts(int choose){ @@ -322,7 +329,7 @@ public class Page2 extends PageImpl { default: break; } - + setPageComplete(validate()); } @@ -334,6 +341,30 @@ public class Page2 extends PageImpl { return true; } + private void loadDefaultValues() { + if ( app.getApplication() != null ) { + //System.out.println("Othere channels size:"+app.getApplication().getApplicationProvider().getOtherChannels().size()); + + if(app.getApplication().getApplicationProvider().getOtherChannels().size() > 0){ + OtherChannel och = app.getApplication().getApplicationProvider().getOtherChannels().get(0); + othChNm1.setText(och.getChannelName()); + othChnDtl1.setText(och.getChannelDetails()); + /* System.out.println(och.toString()); + System.out.println(och.getChannelName()); + System.out.println(och.getChannelDetails());*/ + } + + if(app.getApplication().getApplicationProvider().getOtherChannels().size() > 1){ + OtherChannel och = app.getApplication().getApplicationProvider().getOtherChannels().get(1); + othChNm2.setText(och.getChannelName()); + othChnDtl2.setText(och.getChannelDetails()); + /* System.out.println(och.toString()); + System.out.println(och.getChannelName()); + System.out.println(och.getChannelDetails());*/ + } + } + } + @Override public boolean nextPressed(){ @@ -348,11 +379,28 @@ public class Page2 extends PageImpl { return false; } - if(!othChNm1.getText().isEmpty() && !othChnDtl1.getText().isEmpty()) - app.getApplication().getApplicationProvider().getOtherChannels().add(new OtherChannel(othChNm1.getText(), othChnDtl1.getText())); + OtherChannel oc = null; + if(!othChNm1.getText().isEmpty() && !othChnDtl1.getText().isEmpty()) { + if ( app.getApplication().getApplicationProvider().getOtherChannels().size() > 0 ) { + oc = app.getApplication().getApplicationProvider().getOtherChannels().get(0); + } else { + oc = new OtherChannel(); + app.getApplication().getApplicationProvider().getOtherChannels().add(oc); + } + oc.setChannelName(othChNm1.getText()); + oc.setChannelDetails(othChnDtl1.getText()); + } - if(!othChNm2.getText().isEmpty() && !othChnDtl2.getText().isEmpty()) - app.getApplication().getApplicationProvider().getOtherChannels().add(new OtherChannel(othChNm2.getText(), othChnDtl2.getText())); + if(!othChNm2.getText().isEmpty() && !othChnDtl2.getText().isEmpty()) { + if ( app.getApplication().getApplicationProvider().getOtherChannels().size() > 1 ) { + oc = app.getApplication().getApplicationProvider().getOtherChannels().get(1); + } else { + oc = new OtherChannel(); + app.getApplication().getApplicationProvider().getOtherChannels().add(oc); + } + oc.setChannelName(othChNm2.getText()); + oc.setChannelDetails(othChnDtl2.getText()); + } if(!certificate.getText().isEmpty()){ app.getApplication().getApplicationProvider().setCertificate(URI.create(removeBlanks(certificate.getText()))); @@ -360,6 +408,8 @@ public class Page2 extends PageImpl { if(web.getText() != null && !web.getText().isEmpty()) app.getApplication().getApplicationProvider().setWebAddress(URI.create(removeBlanks(web.getText()))); + + serializeMPA(); } catch(Exception ex){ ex.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 752b741a3546ae2ee631cbaff773007f2601581b..dcdabaff36aa447b56653e37b9cf51a4674e124f 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 @@ -204,5 +204,11 @@ public class Page3 extends PageImpl { return super.getPreviousPage().getPreviousPage(); } + + @Override + public boolean nextPressed(){ + serializeMPA(); + return true; + } } \ No newline at end of file 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 31bfde00be256501b7e8fb174a69bcf8af327aea..6dbc3a7bb428f3ce675f2ccf2b769555e84f564a 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 @@ -82,7 +82,8 @@ public class PageLicenses extends PageImpl { slaLink.setText(sla.getLink().toString()); slaLink.addVerifyListener(new UriV()); slaLink.setLayoutData(gd); - + System.out.println(sla.getLink().toString()); + Button b1 = new Button(container, SWT.PUSH); b1.setText("Browse"); b1.addSelectionListener(new SelectionListener() { @@ -268,6 +269,7 @@ public class PageLicenses extends PageImpl { addPageCustom(this, pl); } + serializeMPA(); return true; } } \ No newline at end of file diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/StartPage.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/StartPage.java index 513cd0a1323750ea3058b7e1fe0ce0464b1ca923..5e7743a81784ebb6d837b6c98282f624a7f079f9 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/StartPage.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/gui/StartPage.java @@ -42,6 +42,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.universaal.tools.packaging.tool.impl.PageImpl; +import org.universaal.tools.packaging.tool.parts.Application; import org.universaal.tools.packaging.tool.parts.MPA; import org.universaal.tools.packaging.tool.util.Configurator; import org.universaal.tools.packaging.tool.util.Dialog; @@ -143,7 +144,6 @@ public class StartPage extends PageImpl { label70.setText(""); name = new Text(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); - name.setText(app.getApplication().getName()); name.setLayoutData(gd); name.addVerifyListener(new FileV()); @@ -159,9 +159,10 @@ public class StartPage extends PageImpl { destination = new File(destination+".uapp"); name.setText(destination.getAbsolutePath()); - - if(destination.isAbsolute() && parts.size() > 0) + + if(destination.isAbsolute() && parts.size() > 0){ setPageComplete(true); + } } } @@ -192,27 +193,32 @@ public class StartPage extends PageImpl { public boolean nextPressed() { g.setDestination(destination.getAbsolutePath()); - if ( ! Configurator.local.isPersistanceEnabled() ) { - return true; - } + /* if ( destination.exists() ) { + System.out.println("Recovery enabled"); File parent = destination.getParentFile(); File recovery = new File( parent, ".org.uAAL.tool.packager.recovery"); GUI.getInstance().recoveryStorage = recovery; if ( recovery.exists() ) { - try { - ObjectInputStream ois = new ObjectInputStream( new FileInputStream( recovery ) ); - MPA recoveredStatus = (MPA) ois.readObject(); - multipartApplication.setApplication(recoveredStatus.getAAL_UAPP()); - } catch (Exception e) { - e.printStackTrace(); - } + try { + ObjectInputStream ois = new ObjectInputStream( new FileInputStream( recovery ) ); + MPA recoveredStatus = (MPA) ois.readObject(); + multipartApplication.setApplication(recoveredStatus.getAAL_UAPP()); + } catch (Exception e) { + e.printStackTrace(); + } } else { - System.out.println("[WARNING] No recovery data found even if package exists"); + System.out.println("[WARNING] No recovery data found even if package exists"); } + } else try { + System.out.println(destination.getCanonicalPath()+" non esiste!!"); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } + */ return true; } diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/impl/PageImpl.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/impl/PageImpl.java index 6b5fe075cd95a6d5253b2df492f663a7f53ffc27..3e6c672a1dcc705ddaa06d4c30aef36fde8a9a5f 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/impl/PageImpl.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/impl/PageImpl.java @@ -20,6 +20,9 @@ */ package org.universaal.tools.packaging.tool.impl; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.List; @@ -37,6 +40,7 @@ import org.universaal.tools.packaging.tool.api.WizardPageMod; import org.universaal.tools.packaging.tool.gui.GUI; import org.universaal.tools.packaging.tool.parts.Application; import org.universaal.tools.packaging.tool.parts.MPA; +import org.universaal.tools.packaging.tool.util.Configurator; /** * @@ -75,13 +79,13 @@ public abstract class PageImpl extends WizardPageMod implements Page { } public boolean validate(){ - + for(int i = 0; i < mandatory.size(); i++){ if(mandatory.get(i) instanceof Text) - if(((Text)mandatory.get(i)).getText().isEmpty()) + if(((Text)mandatory.get(i)).getText().trim().isEmpty()) return false; if(mandatory.get(i) instanceof Combo) - if(((Combo)mandatory.get(i)).getText().isEmpty()) + if(((Combo)mandatory.get(i)).getText().trim().isEmpty()) return false; } return true; @@ -167,4 +171,25 @@ public abstract class PageImpl extends WizardPageMod implements Page { public void keyReleased(KeyEvent e) { setPageComplete(validate()); }} + + // Added By Federico VOlpini from PersistencePageDecorator + protected void serializeMPA(){ + if ( ! Configurator.local.isPersistanceEnabled() ) { + return; + } + if(GUI.getInstance().recoveryStorage != null){ + + try { + System.out.println("writing recovery file"); + FileOutputStream fos = new FileOutputStream( GUI.getInstance().recoveryStorage, false ); + ObjectOutputStream oos = new ObjectOutputStream( fos ); + oos.writeObject(this.multipartApplication); + oos.flush(); + oos.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } } \ No newline at end of file diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/impl/PersistencePageDecorator.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/impl/PersistencePageDecorator.java index 01844aed609e0914347e985ddbd5d3d3e0f3f294..7922abf018ca8e60436b483ad6b7867c5081060a 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/impl/PersistencePageDecorator.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/impl/PersistencePageDecorator.java @@ -49,26 +49,30 @@ public class PersistencePageDecorator extends PageImpl { public PersistencePageDecorator(PageImpl page) { super(page.getName(), null); - this.localPage = page; + localPage = page; setDescription(page.getDescription()); setTitle(page.getTitle()); setPageComplete(false); } public boolean nextPressed() { - final boolean flag; - try{ - flag = localPage.nextPressed(); - if ( flag ) serializeMPA(); - }catch(Exception ex) { - ex.printStackTrace(); - return false; - } - return flag; + System.out.println(localPage.getName()+" NextPressed"); + final boolean flag; + try{ + flag = localPage.nextPressed(); + if ( flag ) serializeMPA(); + }catch(Exception ex) { + ex.printStackTrace(); + return false; + } + return flag; } public void setPageComplete(boolean complete) { + if ( localPage == null ) return; + + System.out.println(localPage.getName()+" SetComplete "); localPage.setPageComplete(complete); } @@ -82,17 +86,23 @@ public class PersistencePageDecorator extends PageImpl { localPage.setTitle(title); } + /* + private void serializeMPA() throws Exception { if ( ! Configurator.local.isPersistanceEnabled() ) { return; } + System.out.println("writing recovery file"); FileOutputStream fos = new FileOutputStream( GUI.getInstance().recoveryStorage, false ); ObjectOutputStream oos = new ObjectOutputStream( fos ); oos.writeObject(this.multipartApplication); oos.flush(); oos.close(); } - + + */ + + /* * START OF DELEGATOR METHODS */ diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/MPA.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/MPA.java index 77941a1c6a22ee163760cd8aae5dca292abf9483..8cd1aa935fc6ed6254b3169c4aefd5fcecde281e 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/MPA.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/MPA.java @@ -22,10 +22,12 @@ package org.universaal.tools.packaging.tool.parts; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import org.eclipse.core.resources.IProject; import org.universaal.tools.packaging.tool.api.Page; - /** * * @author <a href="mailto:manlio.bacco@isti.cnr.it">Manlio Bacco</a> @@ -35,7 +37,7 @@ import org.universaal.tools.packaging.tool.api.Page; public class MPA implements Serializable { private Application aal_uapp; - + public MPA(){ aal_uapp = new Application(); } @@ -63,4 +65,5 @@ public class MPA implements Serializable { public void setAAL_UAPP(Application application) { this.aal_uapp = application; } + } \ No newline at end of file diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/MenuEntry.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/MenuEntry.java index c1e156581c572b713bc9c3f95f620dfb004177b3..5d035100a3c6ab9d198982632fbd04c0b85080c6 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/MenuEntry.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/parts/MenuEntry.java @@ -40,7 +40,7 @@ public class MenuEntry implements Serializable { private String menuName; private URI serviceUri, iconPath; private File iconFile; - private boolean iconScale = false; + private boolean iconScale = false, isCustomIcon = false; public MenuEntry(){ @@ -96,8 +96,10 @@ public class MenuEntry implements Serializable { } public void setIconPath(URI iconPath) { - if(iconPath.toASCIIString().trim().length() > 0) + if(iconPath.toASCIIString().trim().length() > 0){ this.iconPath = iconPath; + //System.out.println(iconPath); + } } public File getIconFile() { @@ -118,14 +120,26 @@ public class MenuEntry implements Serializable { this.iconScale = iconScale; } + public boolean isCustomIcon(){ + return isCustomIcon; + } + + public void setIsCustomIcon(boolean isCustom){ + this.isCustomIcon = isCustom; + } public String getXML(){ String r = ""; r = r.concat("<menuName>"+menuName+"</menuName>"); r = r.concat("<serviceUri>"+serviceUri.toASCIIString()+"</serviceUri>"); - if(iconPath.toASCIIString().trim().length() > 0) r = r.concat("<iconPath>"+iconPath.toASCIIString().trim()+"</iconPath>"); - + if(iconPath.toASCIIString().trim().length() > 0){ + if(!isCustomIcon){ + r = r.concat("<icon><path>"+iconPath.toASCIIString().trim()+"</path></icon>"); + } else { + r = r.concat("<icon><name>"+iconPath.toASCIIString().trim()+"</name></icon>"); + } + } return r; } diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/ConfigProperties.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/ConfigProperties.java index a62b1ac59ae67f43e30b41c1ddcc12c99ef7cb26..e58a48603f62362179cb648fb0aced3533c26a31 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/ConfigProperties.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/ConfigProperties.java @@ -38,6 +38,10 @@ public interface ConfigProperties { public static final String RECOVERY_MODE_KEY = "org.uAAL.packager.recovery"; public static final String RECOVERY_MODE_KEY_DEFAULT = "false"; + public static final String RECOVERY_FILE_NAME_KEY = "org.uAAL.packager.recovery.filename"; + public static final String RECOVERY_FILE_NAME_DEFAULT = "/.recovery"; + public static final String RECOVERY_PARTS_NAME_KEY = "org.uAAL.packager.recovery.partsname"; + public static final String RECOVERY_PARTS_NAME_DEFAULT = "/.parts"; public static final String ENABLE_CONSOLE_LOG_KEY = "org.uAAL.packager.log.console"; public static final String ENABLE_CONSOLE_LOG_DEFAULT = "true"; @@ -59,7 +63,5 @@ public interface ConfigProperties { public static final String OFFLINE_MODE_KEY = "org.uAAL.packager.offline"; public static final String OFFLINE_MODE_DEFAULT = "false"; - - - + } diff --git a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/Configurator.java b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/Configurator.java index 7001b1f50c08bc8d8434284626b8d3355b3fa1c1..886416a4dc64381cac5f4c33ad6ca535ec7412a8 100644 --- a/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/Configurator.java +++ b/mpa/org.universaal.tools.packaging.tool/src/org/universaal/tools/packaging/tool/util/Configurator.java @@ -41,41 +41,49 @@ public class Configurator { } public boolean isPersistanceEnabled() { - return Boolean.valueOf(System.getProperty( - ConfigProperties.RECOVERY_MODE_KEY, - ConfigProperties.RECOVERY_MODE_KEY_DEFAULT)); + return Boolean.valueOf(System.getProperty( + ConfigProperties.RECOVERY_MODE_KEY, + ConfigProperties.RECOVERY_MODE_KEY_DEFAULT)); } - public String getTempFolder() { - String paths[] = new String[] { - System.getProperty(ConfigProperties.TMP_DIR_KEY, ConfigProperties.TMP_DIR_DEFAULT), - System.getenv("tmp") + File.separatorChar + UUID.randomUUID(), - System.getenv("temp") + File.separatorChar + UUID.randomUUID(), - System.getenv("TMP") + File.separatorChar + UUID.randomUUID(), - System.getenv("TEMP") + File.separatorChar + UUID.randomUUID(), - "." + File.separatorChar + UUID.randomUUID(), - }; - for (int i = 0; i < paths.length; i++) { - final String path = paths[i]; - File folder = getFolder(path); - if (folder != null && folder.canWrite()) { - return path; - } + public String getRecoveryFileName(){ + return System.getProperty(ConfigProperties.RECOVERY_FILE_NAME_KEY, ConfigProperties.RECOVERY_FILE_NAME_DEFAULT); + } + + public String getRecoveryPartsName(){ + return System.getProperty(ConfigProperties.RECOVERY_PARTS_NAME_KEY, ConfigProperties.RECOVERY_PARTS_NAME_DEFAULT); } + + public String getTempFolder() { + String paths[] = new String[] { + System.getProperty(ConfigProperties.TMP_DIR_KEY, ConfigProperties.TMP_DIR_DEFAULT), + System.getenv("tmp") + File.separatorChar + UUID.randomUUID(), + System.getenv("temp") + File.separatorChar + UUID.randomUUID(), + System.getenv("TMP") + File.separatorChar + UUID.randomUUID(), + System.getenv("TEMP") + File.separatorChar + UUID.randomUUID(), + "." + File.separatorChar + UUID.randomUUID(), + }; + for (int i = 0; i < paths.length; i++) { + final String path = paths[i]; + File folder = getFolder(path); + if (folder != null && folder.canWrite()) { + return path; + } + } return null; } private File getFolder(String path) { - if ( path == null ) - return null; - File dir = new File(path); - if ( dir == null || ( dir.exists() && !dir.isDirectory() )) - return null; - if ( ! dir.exists() ) { - if (dir.mkdirs() == false) - return null; - } - return dir; + if ( path == null ) + return null; + File dir = new File(path); + if ( dir == null || ( dir.exists() && !dir.isDirectory() )) + return null; + if ( ! dir.exists() ) { + if (dir.mkdirs() == false) + return null; + } + return dir; } public File getLogFolder() {