diff --git a/org.flowerplatform.codesync/src/org/flowerplatform/codesync/CodeSyncRemoveNodeController.java b/org.flowerplatform.codesync/src/org/flowerplatform/codesync/CodeSyncRemoveNodeController.java index d421f895..2ff303fe 100644 --- a/org.flowerplatform.codesync/src/org/flowerplatform/codesync/CodeSyncRemoveNodeController.java +++ b/org.flowerplatform.codesync/src/org/flowerplatform/codesync/CodeSyncRemoveNodeController.java @@ -3,15 +3,14 @@ import static org.flowerplatform.core.CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IRemoveNodeController; +import org.flowerplatform.core.node.controller.RemoveNodeController; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; /** * @author Sebastian Solomon */ -public class CodeSyncRemoveNodeController extends AbstractController implements IRemoveNodeController { +public class CodeSyncRemoveNodeController extends RemoveNodeController { public CodeSyncRemoveNodeController() { // must be executed before others. diff --git a/org.flowerplatform.codesync/src/org/flowerplatform/codesync/controller/CodeSyncAddNodeController.java b/org.flowerplatform.codesync/src/org/flowerplatform/codesync/controller/CodeSyncAddNodeController.java index acc76722..040fe166 100644 --- a/org.flowerplatform.codesync/src/org/flowerplatform/codesync/controller/CodeSyncAddNodeController.java +++ b/org.flowerplatform.codesync/src/org/flowerplatform/codesync/controller/CodeSyncAddNodeController.java @@ -20,16 +20,15 @@ import org.flowerplatform.codesync.CodeSyncConstants; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IAddNodeController; +import org.flowerplatform.core.node.controller.AddNodeController; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; /** * @author Mariana Gheorghe * @author Cristina Constantinescu */ -public class CodeSyncAddNodeController extends AbstractController implements IAddNodeController { +public class CodeSyncAddNodeController extends AddNodeController { public CodeSyncAddNodeController() { // must be invoked after the persistence controller diff --git a/org.flowerplatform.codesync/src/org/flowerplatform/codesync/controller/CodeSyncPropertySetter.java b/org.flowerplatform.codesync/src/org/flowerplatform/codesync/controller/CodeSyncPropertySetter.java index a020c4af..8906f996 100644 --- a/org.flowerplatform.codesync/src/org/flowerplatform/codesync/controller/CodeSyncPropertySetter.java +++ b/org.flowerplatform.codesync/src/org/flowerplatform/codesync/controller/CodeSyncPropertySetter.java @@ -27,18 +27,17 @@ import org.flowerplatform.codesync.feature_provider.FeatureProvider; import org.flowerplatform.core.CorePlugin; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertySetter; +import org.flowerplatform.core.node.controller.PropertySetter; import org.flowerplatform.core.node.controller.PropertyValueWrapper; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.util.Utils; -import org.flowerplatform.util.controller.AbstractController; import org.flowerplatform.util.controller.TypeDescriptor; /** * @author Mariana Gheorghe */ -public class CodeSyncPropertySetter extends AbstractController implements IPropertySetter { +public class CodeSyncPropertySetter extends PropertySetter { public CodeSyncPropertySetter() { // invoked before the persistence controllers diff --git a/org.flowerplatform.core/.classpath b/org.flowerplatform.core/.classpath index 878ef84c..e72574c1 100644 --- a/org.flowerplatform.core/.classpath +++ b/org.flowerplatform.core/.classpath @@ -2,9 +2,14 @@ - + + + + + + diff --git a/org.flowerplatform.core/.gitignore b/org.flowerplatform.core/.gitignore index 5e56e040..167fb2c0 100644 --- a/org.flowerplatform.core/.gitignore +++ b/org.flowerplatform.core/.gitignore @@ -1 +1,2 @@ /bin +/bin diff --git a/org.flowerplatform.core/.project b/org.flowerplatform.core/.project index 1a268b8e..5aa9df1e 100644 --- a/org.flowerplatform.core/.project +++ b/org.flowerplatform.core/.project @@ -5,6 +5,11 @@ + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.jdt.core.javabuilder @@ -19,10 +24,18 @@ org.eclipse.pde.SchemaBuilder - + + + org.eclipse.wst.validation.validationbuilder + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature diff --git a/org.flowerplatform.core/.settings/org.eclipse.jdt.core.prefs b/org.flowerplatform.core/.settings/org.eclipse.jdt.core.prefs index 11f6e462..e69de29b 100644 --- a/org.flowerplatform.core/.settings/org.eclipse.jdt.core.prefs +++ b/org.flowerplatform.core/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/org.flowerplatform.core/.settings/org.eclipse.wst.common.component b/org.flowerplatform.core/.settings/org.eclipse.wst.common.component new file mode 100644 index 00000000..0bc223f5 --- /dev/null +++ b/org.flowerplatform.core/.settings/org.eclipse.wst.common.component @@ -0,0 +1,5 @@ + + + + + diff --git a/org.flowerplatform.core/.settings/org.eclipse.wst.common.project.facet.core.xml b/org.flowerplatform.core/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 00000000..51caf299 --- /dev/null +++ b/org.flowerplatform.core/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.flowerplatform.core/src/META-INF/MANIFEST.MF b/org.flowerplatform.core/src/META-INF/MANIFEST.MF new file mode 100644 index 00000000..5e949512 --- /dev/null +++ b/org.flowerplatform.core/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/CoreConstants.java b/org.flowerplatform.core/src/org/flowerplatform/core/CoreConstants.java index 368d5c84..0e8f863b 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/CoreConstants.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/CoreConstants.java @@ -1,5 +1,6 @@ package org.flowerplatform.core; +import org.flowerplatform.core.node.update.controller.UpdatePropertySetterController; import org.flowerplatform.util.UtilConstants; public class CoreConstants { diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/CorePlugin.java b/org.flowerplatform.core/src/org/flowerplatform/core/CorePlugin.java index d421df8a..4f56888a 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/CorePlugin.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/CorePlugin.java @@ -41,7 +41,9 @@ import org.flowerplatform.core.node.resource.ResourceService; import org.flowerplatform.core.node.resource.ResourceUnsubscriber; import org.flowerplatform.core.node.resource.in_memory.InMemoryResourceDAO; -import org.flowerplatform.core.node.update.controller.UpdateController; +import org.flowerplatform.core.node.update.controller.UpdateAddNodeController; +import org.flowerplatform.core.node.update.controller.UpdatePropertySetterController; +import org.flowerplatform.core.node.update.controller.UpdateRemoveNodeController; import org.flowerplatform.core.repository.RepositoryChildrenProvider; import org.flowerplatform.core.repository.RepositoryPropertiesProvider; import org.flowerplatform.core.repository.RootChildrenProvider; @@ -213,13 +215,12 @@ public void start(BundleContext context) throws Exception { .addAdditiveController(CoreConstants.PROPERTIES_PROVIDER, new ConstantValuePropertyProvider(CoreConstants.IS_SUBSCRIBABLE, true)); getNodeTypeDescriptorRegistry().addDynamicCategoryProvider(new ResourceTypeDynamicCategoryProvider()); - - UpdateController updateController = new UpdateController(); + getNodeTypeDescriptorRegistry().getOrCreateCategoryTypeDescriptor(UtilConstants.CATEGORY_ALL) - .addAdditiveController(CoreConstants.ADD_NODE_CONTROLLER, updateController) - .addAdditiveController(CoreConstants.REMOVE_NODE_CONTROLLER, updateController) - .addAdditiveController(CoreConstants.PROPERTY_SETTER, updateController) + .addAdditiveController(CoreConstants.ADD_NODE_CONTROLLER, new UpdateAddNodeController()) .addAdditiveController(DEFAULT_PROPERTY_PROVIDER, new PropertyDescriptorDefaultPropertyValueProvider()) + .addAdditiveController(CoreConstants.REMOVE_NODE_CONTROLLER, new UpdateRemoveNodeController()) + .addAdditiveController(CoreConstants.PROPERTY_SETTER, new UpdatePropertySetterController()) .addSingleController(CoreConstants.PROPERTY_FOR_TITLE_DESCRIPTOR, new GenericValueDescriptor(CoreConstants.NAME)) .addSingleController(CoreConstants.PROPERTY_FOR_SIDE_DESCRIPTOR, new GenericValueDescriptor(CoreConstants.SIDE)) .addSingleController(CoreConstants.PROPERTY_FOR_ICON_DESCRIPTOR, new GenericValueDescriptor(CoreConstants.ICONS)); diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/file/FileAddNodeController.java b/org.flowerplatform.core/src/org/flowerplatform/core/file/FileAddNodeController.java new file mode 100644 index 00000000..f51b2233 --- /dev/null +++ b/org.flowerplatform.core/src/org/flowerplatform/core/file/FileAddNodeController.java @@ -0,0 +1,65 @@ +package org.flowerplatform.core.file; + +import static org.flowerplatform.core.CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS; +import static org.flowerplatform.core.CoreConstants.FILE_IS_DIRECTORY; +import static org.flowerplatform.core.CoreConstants.FILE_NODE_TYPE; +import static org.flowerplatform.core.CoreConstants.FILE_SYSTEM_NODE_TYPE; +import static org.flowerplatform.core.CoreConstants.NAME; + +import org.flowerplatform.core.CoreConstants; +import org.flowerplatform.core.CorePlugin; +import org.flowerplatform.core.node.NodeService; +import org.flowerplatform.core.node.controller.AddNodeController; +import org.flowerplatform.core.node.remote.Node; +import org.flowerplatform.core.node.remote.ServiceContext; + +/** + * @author Sebastian Solomon + */ +public class FileAddNodeController extends AddNodeController { + + @Override + public void addNode(Node parentNode, Node child, ServiceContext context) { + IFileAccessController fileAccessController = CorePlugin.getInstance() + .getFileAccessController(); + Object parentFile; + + try { + parentFile = fileAccessController.getFile(parentNode.getIdWithinResource()); + } catch (Exception e) { + throw new RuntimeException(e); + } + + if (!fileAccessController.isDirectory(parentFile)) { + parentFile = fileAccessController.getParentFile(parentFile); + String path = fileAccessController.getPath(parentFile); + Node fileParentNode; + + if (path.length() != 0) { // parent File is not the FileSystem node + fileParentNode = new Node(FILE_NODE_TYPE, parentNode.getResource(), path, null); + } else { + fileParentNode = new Node(FILE_SYSTEM_NODE_TYPE, CoreConstants.SELF_RESOURCE, null, null); + } + context.getService().addChild(fileParentNode, child, context); + context.add(DONT_PROCESS_OTHER_CONTROLLERS, true); + return; + } + + if (parentNode.getType().equals(FILE_SYSTEM_NODE_TYPE)) { + child.setResource(parentNode.getFullNodeId()); + } + + String name = (String) context.get(NAME); + Object fileToCreate = fileAccessController.getFile(parentFile, name); + child.setIdWithinResource(fileAccessController.getPath(fileToCreate)); + boolean isDir = (boolean) context.get(FILE_IS_DIRECTORY); + + if (fileAccessController.exists(fileToCreate)) { + throw new RuntimeException("There is already a file with the same name in this location."); + } else if (!fileAccessController.createFile(fileToCreate, isDir)) { + throw new RuntimeException("The filename, directory name, or volume label syntax is incorrect"); + } + child.getOrPopulateProperties(); + } + +} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/file/FileChildrenController.java b/org.flowerplatform.core/src/org/flowerplatform/core/file/FileChildrenController.java deleted file mode 100644 index b5732c73..00000000 --- a/org.flowerplatform.core/src/org/flowerplatform/core/file/FileChildrenController.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.flowerplatform.core.file; - -import static org.flowerplatform.core.CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS; -import static org.flowerplatform.core.CoreConstants.FILE_IS_DIRECTORY; -import static org.flowerplatform.core.CoreConstants.FILE_NODE_TYPE; -import static org.flowerplatform.core.CoreConstants.FILE_SYSTEM_NODE_TYPE; -import static org.flowerplatform.core.CoreConstants.NAME; - -import java.util.ArrayList; -import java.util.List; - -import org.flowerplatform.core.CoreConstants; -import org.flowerplatform.core.CorePlugin; -import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IAddNodeController; -import org.flowerplatform.core.node.controller.IChildrenProvider; -import org.flowerplatform.core.node.controller.IRemoveNodeController; -import org.flowerplatform.core.node.remote.Node; -import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; - -/** - * @author Sebastian Solomon - */ -public class FileChildrenController extends AbstractController - implements IChildrenProvider, IAddNodeController, IRemoveNodeController { - - private static IFileAccessController fileAccessController = CorePlugin - .getInstance().getFileAccessController(); - - @Override - public List getChildren(Node node, ServiceContext context) { - String path; - path = node.getIdWithinResource(); - - Object file = null; - try { - file = fileAccessController.getFile(path); - } catch (Exception e) { - throw new RuntimeException(e); - } - Object[] files = fileAccessController.listFiles(file); - List children = new ArrayList(); - for (Object object : files) { - if (CoreConstants.METADATA.equals(fileAccessController.getName(object)) && path == null) { - // don't show metadata directory from workspace - continue; - } - children.add(new Node(CoreConstants.FILE_NODE_TYPE, - node.getType().equals(CoreConstants.FILE_SYSTEM_NODE_TYPE) ? node.getFullNodeId() : node.getResource(), - fileAccessController.getPath(object), null)); - } - return children; - } - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - Object file = null; - try { - file = fileAccessController.getFile(node.getIdWithinResource()); - } catch (Exception e) { - throw new RuntimeException(e); - } - Object[] files = fileAccessController.listFiles(file); - if (files == null) { - return false; - } - if (files.length == 1 && CoreConstants.METADATA.equals(fileAccessController.getName(files[0]))) { - // calculate hasChildren without metadata directory - return false; - - } - return files.length > 0; - } - - @Override - public void addNode(Node parentNode, Node child, ServiceContext context) { - IFileAccessController fileAccessController = CorePlugin.getInstance() - .getFileAccessController(); - Object parentFile; - - try { - parentFile = fileAccessController.getFile(parentNode.getIdWithinResource()); - } catch (Exception e) { - throw new RuntimeException(e); - } - - if (!fileAccessController.isDirectory(parentFile)) { - parentFile = fileAccessController.getParentFile(parentFile); - String path = fileAccessController.getPath(parentFile); - Node fileParentNode; - - if (path.length() != 0) { // parent File is not the FileSystem node - fileParentNode = new Node(FILE_NODE_TYPE, parentNode.getResource(), path, null); - } else { - fileParentNode = new Node(FILE_SYSTEM_NODE_TYPE, CoreConstants.SELF_RESOURCE, null, null); - } - context.getService().addChild(fileParentNode, child, context); - context.add(DONT_PROCESS_OTHER_CONTROLLERS, true); - return; - } - - if (parentNode.getType().equals(FILE_SYSTEM_NODE_TYPE)) { - child.setResource(parentNode.getFullNodeId()); - } - - String name = (String) context.get(NAME); - Object fileToCreate = fileAccessController.getFile(parentFile, name); - child.setIdWithinResource(fileAccessController.getPath(fileToCreate)); - boolean isDir = (boolean) context.get(FILE_IS_DIRECTORY); - - if (fileAccessController.exists(fileToCreate)) { - throw new RuntimeException("There is already a file with the same name in this location."); - } else if (!fileAccessController.createFile(fileToCreate, isDir)) { - throw new RuntimeException("The filename, directory name, or volume label syntax is incorrect"); - } - child.getOrPopulateProperties(); - } - - @Override - public void removeNode(Node node, Node child, ServiceContext context) { - IFileAccessController fileAccessController = CorePlugin - .getInstance().getFileAccessController(); - try { - fileAccessController.delete(fileAccessController - .getFile(child.getIdWithinResource())); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - -} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/file/FileChildrenProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/file/FileChildrenProvider.java new file mode 100644 index 00000000..8c56b360 --- /dev/null +++ b/org.flowerplatform.core/src/org/flowerplatform/core/file/FileChildrenProvider.java @@ -0,0 +1,65 @@ +package org.flowerplatform.core.file; + +import java.util.ArrayList; +import java.util.List; + +import org.flowerplatform.core.CoreConstants; +import org.flowerplatform.core.CorePlugin; +import org.flowerplatform.core.node.NodeService; +import org.flowerplatform.core.node.controller.ChildrenProvider; +import org.flowerplatform.core.node.remote.Node; +import org.flowerplatform.core.node.remote.ServiceContext; + +/** + * @author Sebastian Solomon + */ +public class FileChildrenProvider extends ChildrenProvider { + private static IFileAccessController fileAccessController = CorePlugin + .getInstance().getFileAccessController(); + + @Override + public List getChildren(Node node, ServiceContext context) { + String path; + path = node.getIdWithinResource(); + + Object file = null; + try { + file = fileAccessController.getFile(path); + } catch (Exception e) { + throw new RuntimeException(e); + } + Object[] files = fileAccessController.listFiles(file); + List children = new ArrayList(); + for (Object object : files) { + if (CoreConstants.METADATA.equals(fileAccessController.getName(object)) && path == null) { + // don't show metadata directory from workspace + continue; + } + children.add(new Node(CoreConstants.FILE_NODE_TYPE, + node.getType().equals(CoreConstants.FILE_SYSTEM_NODE_TYPE) ? node.getFullNodeId() : node.getResource(), + fileAccessController.getPath(object), null)); + } + return children; + } + + @Override + public boolean hasChildren(Node node, ServiceContext context) { + Object file = null; + try { + file = fileAccessController.getFile(node.getIdWithinResource()); + } catch (Exception e) { + throw new RuntimeException(e); + } + Object[] files = fileAccessController.listFiles(file); + if (files == null) { + return false; + } + if (files.length == 1 && CoreConstants.METADATA.equals(fileAccessController.getName(files[0]))) { + // calculate hasChildren without metadata directory + return false; + + } + return files.length > 0; + } + +} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/file/FilePropertiesController.java b/org.flowerplatform.core/src/org/flowerplatform/core/file/FilePropertiesProvider.java similarity index 62% rename from org.flowerplatform.core/src/org/flowerplatform/core/file/FilePropertiesController.java rename to org.flowerplatform.core/src/org/flowerplatform/core/file/FilePropertiesProvider.java index 83229d66..60e17200 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/file/FilePropertiesController.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/file/FilePropertiesProvider.java @@ -18,18 +18,15 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.CorePlugin; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertiesProvider; -import org.flowerplatform.core.node.controller.IPropertySetter; -import org.flowerplatform.core.node.controller.PropertyValueWrapper; +import org.flowerplatform.core.node.controller.PropertiesProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.resources.ResourcesPlugin; -import org.flowerplatform.util.controller.AbstractController; /** * @author Sebastian Solomon */ -public class FilePropertiesController extends AbstractController implements IPropertiesProvider, IPropertySetter { +public class FilePropertiesProvider extends PropertiesProvider { @Override public void populateWithProperties(Node node, ServiceContext context) { @@ -89,36 +86,5 @@ private long getFolderSize(Object folder) { return length; } - @Override - public void setProperty(Node node, String property, PropertyValueWrapper value, ServiceContext context) { - IFileAccessController fileAccessController = CorePlugin.getInstance().getFileAccessController(); - if (CoreConstants.NAME.equals(property)) { - Object file; - if (!node.getOrPopulateProperties().get(CoreConstants.NAME).equals(value.getPropertyValue())) { - try { - throw new UnsupportedOperationException(); -// file = fileAccessController.getFile(node.getIdWithinResource()); -// String parentPath = fileAccessController.getParent(file); -// Object parent = fileAccessController.getFile(parentPath); -// Object dest = fileAccessController.getFile(parent, value.getPropertyValue().toString()); -// if (fileAccessController.exists(dest)) { -// throw new RuntimeException("There is already a file with the same name in this location."); -// } -// if (!fileAccessController.rename(file, dest)) { -// throw new RuntimeException("The filename, directory name, or volume label syntax is incorrect"); -// } -// node.getProperties().put(NAME, value.getPropertyValue()); -// node.setIdWithinResource(fileAccessController.getAbsolutePath(dest)); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - } - - @Override - public void unsetProperty(Node node, String property, ServiceContext context) { - node.getOrPopulateProperties().remove(property); - } } diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/file/FilePropertySetter.java b/org.flowerplatform.core/src/org/flowerplatform/core/file/FilePropertySetter.java new file mode 100644 index 00000000..098fedb0 --- /dev/null +++ b/org.flowerplatform.core/src/org/flowerplatform/core/file/FilePropertySetter.java @@ -0,0 +1,48 @@ +package org.flowerplatform.core.file; + +import org.flowerplatform.core.CoreConstants; +import org.flowerplatform.core.CorePlugin; +import org.flowerplatform.core.node.NodeService; +import org.flowerplatform.core.node.controller.PropertySetter; +import org.flowerplatform.core.node.controller.PropertyValueWrapper; +import org.flowerplatform.core.node.remote.Node; +import org.flowerplatform.core.node.remote.ServiceContext; + +/** + * @author Sebastian Solomon + */ +public class FilePropertySetter extends PropertySetter { + + @Override + public void setProperty(Node node, String property, PropertyValueWrapper value, ServiceContext context) { + IFileAccessController fileAccessController = CorePlugin.getInstance().getFileAccessController(); + if (CoreConstants.NAME.equals(property)) { + Object file; + if (!node.getOrPopulateProperties().get(CoreConstants.NAME).equals(value.getPropertyValue())) { + try { + throw new UnsupportedOperationException(); +// file = fileAccessController.getFile(node.getIdWithinResource()); +// String parentPath = fileAccessController.getParent(file); +// Object parent = fileAccessController.getFile(parentPath); +// Object dest = fileAccessController.getFile(parent, value.getPropertyValue().toString()); +// if (fileAccessController.exists(dest)) { +// throw new RuntimeException("There is already a file with the same name in this location."); +// } +// if (!fileAccessController.rename(file, dest)) { +// throw new RuntimeException("The filename, directory name, or volume label syntax is incorrect"); +// } +// node.getProperties().put(NAME, value.getPropertyValue()); +// node.setIdWithinResource(fileAccessController.getAbsolutePath(dest)); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + } + + @Override + public void unsetProperty(Node node, String property, ServiceContext context) { + node.getOrPopulateProperties().remove(property); + } + +} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/file/FileRemoveNodeController.java b/org.flowerplatform.core/src/org/flowerplatform/core/file/FileRemoveNodeController.java new file mode 100644 index 00000000..977c024d --- /dev/null +++ b/org.flowerplatform.core/src/org/flowerplatform/core/file/FileRemoveNodeController.java @@ -0,0 +1,26 @@ +package org.flowerplatform.core.file; + +import org.flowerplatform.core.CorePlugin; +import org.flowerplatform.core.node.NodeService; +import org.flowerplatform.core.node.controller.RemoveNodeController; +import org.flowerplatform.core.node.remote.Node; +import org.flowerplatform.core.node.remote.ServiceContext; + +/** + * @author Sebastian Solomon + */ +public class FileRemoveNodeController extends RemoveNodeController { + + @Override + public void removeNode(Node node, Node child, ServiceContext context) { + IFileAccessController fileAccessController = CorePlugin + .getInstance().getFileAccessController(); + try { + fileAccessController.delete(fileAccessController + .getFile(child.getIdWithinResource())); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/file/FileSystemControllers.java b/org.flowerplatform.core/src/org/flowerplatform/core/file/FileSystemControllers.java index 2c63233b..d038a067 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/file/FileSystemControllers.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/file/FileSystemControllers.java @@ -19,9 +19,13 @@ import static org.flowerplatform.core.CoreConstants.REMOVE_NODE_CONTROLLER; import org.flowerplatform.core.CorePlugin; +import org.flowerplatform.core.node.NodeService; import org.flowerplatform.core.node.controller.ConstantValuePropertyProvider; +import org.flowerplatform.core.node.controller.PropertiesProvider; import org.flowerplatform.core.node.remote.AddChildDescriptor; +import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.PropertyDescriptor; +import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.resources.ResourcesPlugin; /** @@ -30,22 +34,24 @@ public class FileSystemControllers { public void registerControllers() { - FileChildrenController fileChildrenController = new FileChildrenController(); CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateCategoryTypeDescriptor("category.fileContainer") - .addAdditiveController(CHILDREN_PROVIDER, fileChildrenController) - .addAdditiveController(REMOVE_NODE_CONTROLLER, fileChildrenController) - .addAdditiveController(ADD_NODE_CONTROLLER, fileChildrenController) + .addAdditiveController(CHILDREN_PROVIDER, new FileChildrenProvider()) + .addAdditiveController(REMOVE_NODE_CONTROLLER, new FileRemoveNodeController()) + .addAdditiveController(ADD_NODE_CONTROLLER, new FileAddNodeController()) .addAdditiveController(ADD_CHILD_DESCRIPTOR, new AddChildDescriptor().setChildTypeAs(FILE_NODE_TYPE).setLabelAs(ResourcesPlugin.getInstance().getMessage("file.folder")).setOrderIndexAs(10)); CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(FILE_SYSTEM_NODE_TYPE) - .addAdditiveController(PROPERTIES_PROVIDER, new FileSystemNodeController()) + .addAdditiveController(PROPERTIES_PROVIDER, new PropertiesProvider() { + public void populateWithProperties(Node node, ServiceContext context) { + node.getProperties().put(NAME, FILE_SYSTEM_NODE_TYPE); + } + }) .addAdditiveController(PROPERTIES_PROVIDER, new ConstantValuePropertyProvider(IS_SUBSCRIBABLE, true)) .addCategory("category.fileContainer"); - FilePropertiesController filePropertiesController = new FilePropertiesController(); CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(FILE_NODE_TYPE) - .addAdditiveController(PROPERTIES_PROVIDER, filePropertiesController) - .addAdditiveController(PROPERTY_SETTER, filePropertiesController) + .addAdditiveController(PROPERTIES_PROVIDER, new FilePropertiesProvider()) + .addAdditiveController(PROPERTY_SETTER, new FilePropertySetter()) .addAdditiveController(PROPERTY_DESCRIPTOR, new PropertyDescriptor().setNameAs(NAME).setTitleAs(ResourcesPlugin.getInstance().getMessage("file.name")).setContributesToCreationAs(true).setMandatoryAs(true).setOrderIndexAs(-10)) .addAdditiveController(PROPERTY_DESCRIPTOR, new PropertyDescriptor().setNameAs(FILE_SIZE).setTitleAs(ResourcesPlugin.getInstance().getMessage("file.size")).setTypeAs("FileSize")) .addAdditiveController(PROPERTY_DESCRIPTOR, new PropertyDescriptor().setNameAs(FILE_IS_DIRECTORY).setTitleAs(ResourcesPlugin.getInstance().getMessage("file.is.directory")).setReadOnlyAs(true).setContributesToCreationAs(true).setMandatoryAs(true).setTypeAs(PROPERTY_DESCRIPTOR_TYPE_BOOLEAN).setOrderIndexAs(-5)) diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/file/FileSystemNodeController.java b/org.flowerplatform.core/src/org/flowerplatform/core/file/FileSystemNodeController.java deleted file mode 100644 index cc2326f5..00000000 --- a/org.flowerplatform.core/src/org/flowerplatform/core/file/FileSystemNodeController.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.flowerplatform.core.file; - -import static org.flowerplatform.core.CoreConstants.FILE_SYSTEM_NODE_TYPE; -import static org.flowerplatform.core.CoreConstants.NAME; - -import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertiesProvider; -import org.flowerplatform.core.node.remote.Node; -import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; - -public class FileSystemNodeController extends AbstractController implements IPropertiesProvider { - - public void populateWithProperties(Node node, ServiceContext context) { - node.getProperties().put(NAME, FILE_SYSTEM_NODE_TYPE); - } - -} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/NodeService.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/NodeService.java index a2fa2d1b..5bedccb2 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/NodeService.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/NodeService.java @@ -22,15 +22,15 @@ import org.flowerplatform.core.CorePlugin; import org.flowerplatform.core.CoreUtils; -import org.flowerplatform.core.node.controller.IAddNodeController; -import org.flowerplatform.core.node.controller.IChildrenProvider; -import org.flowerplatform.core.node.controller.IDefaultPropertyValueProvider; -import org.flowerplatform.core.node.controller.IParentProvider; -import org.flowerplatform.core.node.controller.IPropertiesProvider; -import org.flowerplatform.core.node.controller.IPropertySetter; +import org.flowerplatform.core.node.controller.AddNodeController; +import org.flowerplatform.core.node.controller.ChildrenProvider; +import org.flowerplatform.core.node.controller.DefaultPropertyValueProvider; +import org.flowerplatform.core.node.controller.ParentProvider; +import org.flowerplatform.core.node.controller.PropertiesProvider; +import org.flowerplatform.core.node.controller.PropertySetter; import org.flowerplatform.core.node.controller.PropertyValueWrapper; -import org.flowerplatform.core.node.controller.IRawNodeDataProvider; -import org.flowerplatform.core.node.controller.IRemoveNodeController; +import org.flowerplatform.core.node.controller.RawNodeDataProvider; +import org.flowerplatform.core.node.controller.RemoveNodeController; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.NodeServiceRemote; import org.flowerplatform.core.node.remote.ServiceContext; @@ -73,11 +73,11 @@ public List getChildren(Node node, ServiceContext context) { return null; } - List providers = descriptor.getAdditiveControllers(CHILDREN_PROVIDER, node); + List providers = descriptor.getAdditiveControllers(CHILDREN_PROVIDER, node); // many times there will be no children; that's why we lazy init the list (if needed) List children = null; // we ask each registered provider for children - for (IChildrenProvider provider : providers) { + for (ChildrenProvider provider : providers) { // we take the children ... List childrenFromCurrentProvider = provider.getChildren(node, context); if (childrenFromCurrentProvider != null) { @@ -111,8 +111,8 @@ public boolean hasChildren(Node node, ServiceContext context) { if (descriptor == null) { return false; } - List childrenProviders = descriptor.getAdditiveControllers(CHILDREN_PROVIDER, node); - for (IChildrenProvider provider : childrenProviders) { + List childrenProviders = descriptor.getAdditiveControllers(CHILDREN_PROVIDER, node); + for (ChildrenProvider provider : childrenProviders) { if (provider.hasChildren(node, context)) { return true; } @@ -131,9 +131,9 @@ public Object getDefaultPropertyValue(Node node, String property, ServiceContext if (descriptor == null) { return null; } - List defaultPropertyProviders = descriptor.getAdditiveControllers(DEFAULT_PROPERTY_PROVIDER, node); + List defaultPropertyProviders = descriptor.getAdditiveControllers(DEFAULT_PROPERTY_PROVIDER, node); Object propertyValue = null; - for (IDefaultPropertyValueProvider provider : defaultPropertyProviders) { + for (DefaultPropertyValueProvider provider : defaultPropertyProviders) { propertyValue = provider.getDefaultValue(node, property, context); if (context.getBooleanValue(DONT_PROCESS_OTHER_CONTROLLERS)) { break; @@ -162,7 +162,7 @@ public Node getParent(Node node, ServiceContext context) { return null; } - IParentProvider provider = descriptor.getSingleController(PARENT_PROVIDER, node); + ParentProvider provider = descriptor.getSingleController(PARENT_PROVIDER, node); Node parent = provider.getParent(node, context); if (parent == null) { return null; @@ -182,9 +182,9 @@ public void setProperty(Node node, String property, Object value, ServiceContext ResourceService resourceService = CorePlugin.getInstance().getResourceService(); boolean oldDirty = resourceService.isDirty(resourceNode.getFullNodeId(), new ServiceContext(resourceService)); - List controllers = descriptor.getAdditiveControllers(PROPERTY_SETTER, node); + List controllers = descriptor.getAdditiveControllers(PROPERTY_SETTER, node); PropertyValueWrapper wrapper = new PropertyValueWrapper(value); - for (IPropertySetter controller : controllers) { + for (PropertySetter controller : controllers) { controller.setProperty(node, property, wrapper, context); if (context.getBooleanValue(DONT_PROCESS_OTHER_CONTROLLERS)) { break; @@ -213,8 +213,8 @@ public void unsetProperty(Node node, String property, ServiceContext(resourceService)); - List controllers = descriptor.getAdditiveControllers(PROPERTY_SETTER, node); - for (IPropertySetter controller : controllers) { + List controllers = descriptor.getAdditiveControllers(PROPERTY_SETTER, node); + for (PropertySetter controller : controllers) { controller.unsetProperty(node, property, context); if (context.getBooleanValue(DONT_PROCESS_OTHER_CONTROLLERS)) { break; @@ -240,8 +240,8 @@ public void addChild(Node node, Node child, ServiceContext context) ResourceService resourceService = CorePlugin.getInstance().getResourceService(); boolean oldDirty = resourceService.isDirty(resourceNode.getFullNodeId(), new ServiceContext(resourceService)); - List controllers = descriptor.getAdditiveControllers(ADD_NODE_CONTROLLER, node); - for (IAddNodeController controller : controllers) { + List controllers = descriptor.getAdditiveControllers(ADD_NODE_CONTROLLER, node); + for (AddNodeController controller : controllers) { controller.addNode(node, child, context); if (context.getBooleanValue(DONT_PROCESS_OTHER_CONTROLLERS)) { break; @@ -268,8 +268,8 @@ public void removeChild(Node node, Node child, ServiceContext conte ResourceService resourceService = CorePlugin.getInstance().getResourceService(); boolean oldDirty = resourceService.isDirty(resourceNode.getFullNodeId(), new ServiceContext(resourceService)); - List controllers = descriptor.getAdditiveControllers(REMOVE_NODE_CONTROLLER, node); - for (IRemoveNodeController controller : controllers) { + List controllers = descriptor.getAdditiveControllers(REMOVE_NODE_CONTROLLER, node); + for (RemoveNodeController controller : controllers) { controller.removeNode(node, child, context); if (context.getBooleanValue(DONT_PROCESS_OTHER_CONTROLLERS)) { break; @@ -294,8 +294,8 @@ public void populateNodeProperties(Node node, ServiceContext contex return; } - List providers = descriptor.getAdditiveControllers(PROPERTIES_PROVIDER, node); - for (IPropertiesProvider provider : providers) { + List providers = descriptor.getAdditiveControllers(PROPERTIES_PROVIDER, node); + for (PropertiesProvider provider : providers) { provider.populateWithProperties(node, context); if (context.getBooleanValue(DONT_PROCESS_OTHER_CONTROLLERS)) { break; @@ -319,7 +319,7 @@ public Object getRawNodeData(Node node, ServiceContext context) { return null; } - IRawNodeDataProvider rawNodeDataProvider = descriptor.getSingleController(RAW_NODE_DATA_PROVIDER, node); + RawNodeDataProvider rawNodeDataProvider = descriptor.getSingleController(RAW_NODE_DATA_PROVIDER, node); if (rawNodeDataProvider == null) { return null; } diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IRemoveNodeController.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/AddNodeController.java similarity index 51% rename from org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IRemoveNodeController.java rename to org.flowerplatform.core/src/org/flowerplatform/core/node/controller/AddNodeController.java index 42692cdb..09dd6194 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IRemoveNodeController.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/AddNodeController.java @@ -3,13 +3,13 @@ import org.flowerplatform.core.node.NodeService; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.IController; +import org.flowerplatform.util.controller.AbstractController; /** * @author Cristina Constantinescu */ -public interface IRemoveNodeController extends IController { +public abstract class AddNodeController extends AbstractController { - void removeNode(Node node, Node child, ServiceContext context); + public abstract void addNode(Node node, Node child, ServiceContext context); } diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ChildrenProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ChildrenProvider.java new file mode 100644 index 00000000..680bb2c1 --- /dev/null +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ChildrenProvider.java @@ -0,0 +1,22 @@ +package org.flowerplatform.core.node.controller; + +import java.util.List; + +import org.flowerplatform.core.node.NodeService; +import org.flowerplatform.core.node.remote.Node; +import org.flowerplatform.core.node.remote.ServiceContext; +import org.flowerplatform.util.controller.AbstractController; + +/** + * @author Cristian Spiescu + */ +public abstract class ChildrenProvider extends AbstractController { + + public abstract List getChildren(Node node, ServiceContext context); + + /** + * @author Cristina Constantinescu + */ + public abstract boolean hasChildren(Node node, ServiceContext context); + +} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ConstantValuePropertyProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ConstantValuePropertyProvider.java index bae1ae13..60100426 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ConstantValuePropertyProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ConstantValuePropertyProvider.java @@ -3,14 +3,13 @@ import org.flowerplatform.core.node.NodeService; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; /** * Adds a constant value for {@link #property} to the properties map of a node (e.g. icon). * * @author Mariana Gheorghe */ -public class ConstantValuePropertyProvider extends AbstractController implements IPropertiesProvider { +public class ConstantValuePropertyProvider extends PropertiesProvider { private String property; diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/DefaultPropertiesProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/DefaultPropertiesProvider.java index 0c419481..d99f752a 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/DefaultPropertiesProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/DefaultPropertiesProvider.java @@ -8,12 +8,11 @@ import org.flowerplatform.core.node.remote.PropertyDescriptor; import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.util.controller.AbstractController; -import org.flowerplatform.util.controller.IController; /** * @author Sebastian Solomon */ -public class DefaultPropertiesProvider extends AbstractController implements IPropertiesProvider { +public class DefaultPropertiesProvider extends PropertiesProvider { public DefaultPropertiesProvider() { super(); @@ -23,7 +22,7 @@ public DefaultPropertiesProvider() { @Override public void populateWithProperties(Node node, ServiceContext context) { List propDescriptors = context.getService().getPropertyDescriptors(node); - for (IController element : propDescriptors) { + for (AbstractController element : propDescriptors) { PropertyDescriptor propertyDescriptor = (PropertyDescriptor) element; if (propertyDescriptor.getHasChangeCheckbox()) { Object nodeDefaultPropertyValue = context.getService().getDefaultPropertyValue(node, propertyDescriptor.getName(), new ServiceContext(context.getService())); diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/DefaultPropertyValueProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/DefaultPropertyValueProvider.java new file mode 100644 index 00000000..428e1283 --- /dev/null +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/DefaultPropertyValueProvider.java @@ -0,0 +1,15 @@ +package org.flowerplatform.core.node.controller; + +import org.flowerplatform.core.node.NodeService; +import org.flowerplatform.core.node.remote.Node; +import org.flowerplatform.core.node.remote.ServiceContext; +import org.flowerplatform.util.controller.AbstractController; + +/** + * @author Sebastian Solomon + */ +public abstract class DefaultPropertyValueProvider extends AbstractController { + + public abstract Object getDefaultValue(Node node, String property, ServiceContext context); + +} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IAddNodeController.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IAddNodeController.java deleted file mode 100644 index aff9e447..00000000 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IAddNodeController.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.flowerplatform.core.node.controller; - -import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.remote.Node; -import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.IController; - -/** - * @author Cristina Constantinescu - */ -public interface IAddNodeController extends IController { - - void addNode(Node node, Node child, ServiceContext context); - -} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IChildrenProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IChildrenProvider.java deleted file mode 100644 index 362a4d83..00000000 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IChildrenProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.flowerplatform.core.node.controller; - -import java.util.List; - -import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.remote.Node; -import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.IController; - -/** - * @author Cristian Spiescu - */ -public interface IChildrenProvider extends IController { - - List getChildren(Node node, ServiceContext context); - - /** - * @author Cristina Constantinescu - */ - boolean hasChildren(Node node, ServiceContext context); - -} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IDefaultPropertyValueProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IDefaultPropertyValueProvider.java deleted file mode 100644 index d54da372..00000000 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IDefaultPropertyValueProvider.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.flowerplatform.core.node.controller; - -import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.remote.Node; -import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.IController; - -/** - * @author Sebastian Solomon - */ -public interface IDefaultPropertyValueProvider extends IController { - - Object getDefaultValue(Node node, String property, ServiceContext context); - -} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IParentProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ParentProvider.java similarity index 52% rename from org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IParentProvider.java rename to org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ParentProvider.java index fcaa3a7e..d70902bb 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IParentProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ParentProvider.java @@ -3,13 +3,13 @@ import org.flowerplatform.core.node.NodeService; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.IController; +import org.flowerplatform.util.controller.AbstractController; /** * @author Mariana Gheorghe */ -public interface IParentProvider extends IController { +public abstract class ParentProvider extends AbstractController { - Node getParent(Node node, ServiceContext context); + public abstract Node getParent(Node node, ServiceContext context); } diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IPropertiesProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertiesProvider.java similarity index 54% rename from org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IPropertiesProvider.java rename to org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertiesProvider.java index deb4bf84..91c48985 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IPropertiesProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertiesProvider.java @@ -3,14 +3,14 @@ import org.flowerplatform.core.node.NodeService; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.IController; +import org.flowerplatform.util.controller.AbstractController; /** * @author Cristian Spiescu * @author Cristina Constantinescu */ -public interface IPropertiesProvider extends IController { +public abstract class PropertiesProvider extends AbstractController { - void populateWithProperties(Node node, ServiceContext context); + public abstract void populateWithProperties(Node node, ServiceContext context); } diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertyDescriptorDefaultPropertyValueProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertyDescriptorDefaultPropertyValueProvider.java index 26113a93..b63e02dc 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertyDescriptorDefaultPropertyValueProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertyDescriptorDefaultPropertyValueProvider.java @@ -7,15 +7,14 @@ import org.flowerplatform.core.node.remote.PropertyDescriptor; import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.util.controller.AbstractController; -import org.flowerplatform.util.controller.IController; -public class PropertyDescriptorDefaultPropertyValueProvider extends AbstractController implements IDefaultPropertyValueProvider { +public class PropertyDescriptorDefaultPropertyValueProvider extends DefaultPropertyValueProvider { @Override public Object getDefaultValue(Node node, String property, ServiceContext context) { List propertyDescriptorList = context.getService().getPropertyDescriptors(node); - for (IController element : propertyDescriptorList) { + for (AbstractController element : propertyDescriptorList) { PropertyDescriptor propertyDescriptor = (PropertyDescriptor) element; if (propertyDescriptor.getName().equals(property)) { return propertyDescriptor.getDefaultValue(); diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IPropertySetter.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertySetter.java similarity index 77% rename from org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IPropertySetter.java rename to org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertySetter.java index 5a352097..31f0c122 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IPropertySetter.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertySetter.java @@ -3,12 +3,12 @@ import org.flowerplatform.core.node.NodeService; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.IController; +import org.flowerplatform.util.controller.AbstractController; /** * @author Cristina Constantinescu */ -public interface IPropertySetter extends IController { +public abstract class PropertySetter extends AbstractController { public abstract void setProperty(Node node, String property, PropertyValueWrapper value, ServiceContext context); diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertyValueWrapper.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertyValueWrapper.java index 28142e9f..134f564a 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertyValueWrapper.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/PropertyValueWrapper.java @@ -3,7 +3,7 @@ import org.flowerplatform.core.node.NodeService; /** - * The property value is wrapped to allow other {@link IPropertySetter} to modify it. + * The property value is wrapped to allow other {@link PropertySetter} to modify it. * * @see NodeService#setProperty(org.flowerplatform.core.node.remote.Node, String, Object) * @author Cristina Constantinescu diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/RawNodeDataProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/RawNodeDataProvider.java new file mode 100644 index 00000000..4c6c8547 --- /dev/null +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/RawNodeDataProvider.java @@ -0,0 +1,15 @@ +package org.flowerplatform.core.node.controller; + +import org.flowerplatform.core.node.NodeService; +import org.flowerplatform.core.node.remote.Node; +import org.flowerplatform.core.node.remote.ServiceContext; +import org.flowerplatform.util.controller.AbstractController; + +/** + * @author Cristina Constantinescu + */ +public abstract class RawNodeDataProvider extends AbstractController { + + public abstract RAW_NODE_DATA_TYPE getRawNodeData(Node node, ServiceContext context); + +} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IRawNodeDataProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/RemoveNodeController.java similarity index 51% rename from org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IRawNodeDataProvider.java rename to org.flowerplatform.core/src/org/flowerplatform/core/node/controller/RemoveNodeController.java index 45d93a03..fe09cb83 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/IRawNodeDataProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/RemoveNodeController.java @@ -3,13 +3,13 @@ import org.flowerplatform.core.node.NodeService; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.IController; +import org.flowerplatform.util.controller.AbstractController; /** * @author Cristina Constantinescu */ -public interface IRawNodeDataProvider extends IController { +public abstract class RemoveNodeController extends AbstractController { - RAW_NODE_DATA_TYPE getRawNodeData(Node node, ServiceContext context); + public abstract void removeNode(Node node, Node child, ServiceContext context); } diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ResourceTypeDynamicCategoryProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ResourceTypeDynamicCategoryProvider.java index 828069ff..22de005f 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ResourceTypeDynamicCategoryProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/ResourceTypeDynamicCategoryProvider.java @@ -15,7 +15,7 @@ * *

* This way we can easily implement plugins that are "persistence providers" for a certain type of resource. E.g. the - * FreePlane plugin would register various controllers ({@link IChildrenProvider}, {@link IPropertiesProvider}, etc.) directly + * FreePlane plugin would register various controllers ({@link ChildrenProvider}, {@link PropertiesProvider}, etc.) directly * on the category "category.resource.mm". Each node for a "mm" resource will belong to this category, no matter its node type * or the static categories assigned to the node type. * diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/TypeDescriptorRegistryDebugControllers.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/TypeDescriptorRegistryDebugControllers.java index 788215eb..87e61da5 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/TypeDescriptorRegistryDebugControllers.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/controller/TypeDescriptorRegistryDebugControllers.java @@ -18,7 +18,6 @@ import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.resources.ResourcesPlugin; import org.flowerplatform.util.controller.AbstractController; -import org.flowerplatform.util.controller.IController; import org.flowerplatform.util.controller.TypeDescriptor; import org.flowerplatform.util.controller.TypeDescriptorDebugWrapper; @@ -41,228 +40,56 @@ public class TypeDescriptorRegistryDebugControllers { private final String CONTROLLER_SINGLE = DEBUG + "JavaControllerSingle"; private final String CONTROLLER_ADDITIVE = DEBUG + "JavaControllerAdditive"; - class DebugController extends AbstractController implements IChildrenProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - return true; - } - - @Override - public List getChildren(Node node, ServiceContext context) { - return Collections.singletonList(new Node(TYPES, DEBUG, null, null)); - } - } - - class TypesDebugController extends AbstractController implements IChildrenProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - return true; - } - - @Override - public List getChildren(Node node, ServiceContext context) { - return Arrays.asList(new Node(TYPES_FLEX, TYPES, null, null), new Node(TYPES_JAVA, TYPES, null, null)); - } - } - - class FlexTypesDebugController extends AbstractController implements IChildrenProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - return true; - } - - @Override - public List getChildren(Node node, ServiceContext context) { - // should not be called from client - return Collections.emptyList(); - } - } - - class JavaTypesDebugController extends AbstractController implements IChildrenProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - return true; - } + public void registerControllers() { - @Override - public List getChildren(Node node, ServiceContext context) { - List children = new ArrayList(); - List types = CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getRegisteredTypes(); - Collections.sort(types); // show them in alphabetical order for better readability - for (String type : types) { - children.add(new Node(TYPE, TYPES_JAVA, type, null)); - } - return children; - } - } - - class TypeDebugController extends AbstractController implements IChildrenProvider, IPropertiesProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - return true; - } + /////////////////////////////////////////////////// + // add types + /////////////////////////////////////////////////// - @Override - public List getChildren(Node node, ServiceContext context) { - String type = node.getIdWithinResource(); - TypeDescriptor descriptor = CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getExpectedTypeDescriptor(type); - List children = new ArrayList(); - - // get categories - for (String category : descriptor.getCategories()) { - children.add(new Node(CATEGORY, type, category, null)); - } - - TypeDescriptorDebugWrapper wrapper = new TypeDescriptorDebugWrapper(descriptor); + CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(DEBUG) + .addAdditiveController(CHILDREN_PROVIDER, new ChildrenProvider() { - // get single controllers keys - for (String singleControllersKey : wrapper.getSingleControllersKeys()) { - children.add(new Node(CONTROLLER_KEY_SINGLE, type, singleControllersKey, null)); + @Override + public boolean hasChildren(Node node, ServiceContext context) { + return true; } - // get additive controllers keys - for (String additiveControllersKey : wrapper.getAdditiveControllersKeys()) { - children.add(new Node(CONTROLLER_KEY_ADDITIVE, type, additiveControllersKey, null)); + @Override + public List getChildren(Node node, ServiceContext context) { + return Collections.singletonList(new Node(TYPES, DEBUG, null, null)); } - - return children; - } - - @Override - public void populateWithProperties(Node node, ServiceContext context) { - node.getProperties().put(NAME, node.getIdWithinResource()); - node.getProperties().put(ICONS, ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/idea.png")); - } - } - - class SingleControllerKeyDebugController extends AbstractController implements IChildrenProvider, IPropertiesProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - return true; - } + }); - @Override - public List getChildren(Node node, ServiceContext context) { - // parent: CONTROLLER_KEY_SINGLE|type|controllerKey - List children = new ArrayList(); - TypeDescriptor descriptor = CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getExpectedTypeDescriptor(node.getResource()); - TypeDescriptorDebugWrapper wrapper = new TypeDescriptorDebugWrapper(descriptor); - - Object cachedController = wrapper.getCachedSingleController(node.getIdWithinResource()); - Object selfController = wrapper.getSelfSingleController(node.getIdWithinResource()); - - // add cached controller - if (cachedController != null) { - Node child = TypeDescriptorRegistryDebugControllers.this.createControllerNode(cachedController, CONTROLLER_SINGLE, node.getFullNodeId()); - String icons = (String) child.getOrPopulateProperties().get(ICONS); - if (cachedController != selfController) { - // override - icons += ICONS_SEPARATOR + ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/attach.png"); - child.getOrPopulateProperties().put(ICONS, icons); - } - children.add(child); - } + CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(TYPES) + .addAdditiveController(PROPERTIES_PROVIDER, new ConstantValuePropertyProvider(NAME, "Node Types")) + .addAdditiveController(CHILDREN_PROVIDER, new ChildrenProvider() { - // add self controller - only if different from cached - if (selfController != null && selfController != cachedController) { - Node child = TypeDescriptorRegistryDebugControllers.this.createControllerNode(selfController, CONTROLLER_SINGLE, node.getFullNodeId()); - // deleted - child.getOrPopulateProperties().put(ICONS, ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/button-cancel.png")); - children.add(child); + @Override + public boolean hasChildren(Node node, ServiceContext context) { + return true; } - return children; - } - - @Override - public void populateWithProperties(Node node, ServiceContext context) { - // node: CONTROLLER_KEY_SINGLE|descriptorType|controllerKey - node.getProperties().put(NAME, node.getIdWithinResource()); - String icons = ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/full-1.png"); - TypeDescriptorDebugWrapper wrapper = new TypeDescriptorDebugWrapper(CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getExpectedTypeDescriptor(node.getResource())); - if (wrapper.isCachedSingleController(node.getIdWithinResource())) { - icons += ICONS_SEPARATOR + ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/flag.png"); + @Override + public List getChildren(Node node, ServiceContext context) { + return Arrays.asList(new Node(TYPES_FLEX, TYPES, null, null), new Node(TYPES_JAVA, TYPES, null, null)); } - node.getProperties().put(ICONS, icons); - } - } - - class AdditiveControllerKeyDebugController extends AbstractController implements IChildrenProvider, IPropertiesProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - return true; - } + }); - @Override - public List getChildren(Node node, ServiceContext context) { - // parent: CONTROLLER_KEY_ADDITIVE|type|controllerKey - List children = new ArrayList(); - TypeDescriptor descriptor = CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getExpectedTypeDescriptor(node.getResource()); - TypeDescriptorDebugWrapper wrapper = new TypeDescriptorDebugWrapper(descriptor); - - List cachedControllers = wrapper.getCachedAdditiveControllers(node.getIdWithinResource()); - List selfControllers = wrapper.getSelfAdditiveControllers(node.getIdWithinResource()); + CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(TYPES_FLEX) + .addAdditiveController(PROPERTIES_PROVIDER, new ConstantValuePropertyProvider(NAME, "Flex")) + .addAdditiveController(CHILDREN_PROVIDER, new ChildrenProvider() { - // add controllers - for (IController cachedController : cachedControllers) { - Node child = TypeDescriptorRegistryDebugControllers.this.createControllerNode(cachedController, CONTROLLER_ADDITIVE, node.getFullNodeId()); - String icons = (String) child.getOrPopulateProperties().get(ICONS); - if (!selfControllers.contains(cachedController)) { - // contributed - icons += ICONS_SEPARATOR + ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/attach.png"); - child.getOrPopulateProperties().put(ICONS, icons); - } - children.add(child); + @Override + public boolean hasChildren(Node node, ServiceContext context) { + return true; } - return children; - } - - @Override - public void populateWithProperties(Node node, ServiceContext context) { - // node: CONTROLLER_KEY_ADDITIVE|descriptorType|controllerKey - node.getProperties().put(NAME, node.getIdWithinResource()); - String icons = ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/positive.png"); - TypeDescriptorDebugWrapper wrapper = new TypeDescriptorDebugWrapper(CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getExpectedTypeDescriptor(node.getResource())); - if (wrapper.isCachedAdditiveController(node.getIdWithinResource())) { - icons += ICONS_SEPARATOR + ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/flag.png"); + @Override + public List getChildren(Node node, ServiceContext context) { + // should not be called from client + return Collections.emptyList(); } - node.getProperties().put(ICONS, icons); - } - } - - class CategoryDebugController extends AbstractController implements IPropertiesProvider { - - @Override - public void populateWithProperties(Node node, ServiceContext context) { - node.getProperties().put(NAME, node.getIdWithinResource()); - node.getProperties().put(ICONS, ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/folder.png")); - } - } - - public void registerControllers() { - - /////////////////////////////////////////////////// - // add types - /////////////////////////////////////////////////// - - CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(DEBUG) - .addAdditiveController(CHILDREN_PROVIDER, new DebugController()); - - CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(TYPES) - .addAdditiveController(PROPERTIES_PROVIDER, new ConstantValuePropertyProvider(NAME, "Node Types")) - .addAdditiveController(CHILDREN_PROVIDER, new TypesDebugController()); - - CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(TYPES_FLEX) - .addAdditiveController(PROPERTIES_PROVIDER, new ConstantValuePropertyProvider(NAME, "Flex")) - .addAdditiveController(CHILDREN_PROVIDER, new FlexTypesDebugController()); + }); /////////////////////////////////////////////////// // add types to "Java Types" @@ -270,37 +97,193 @@ public void registerControllers() { CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(TYPES_JAVA) .addAdditiveController(PROPERTIES_PROVIDER, new ConstantValuePropertyProvider(NAME, "Java")) - .addAdditiveController(CHILDREN_PROVIDER, new JavaTypesDebugController()); + .addAdditiveController(CHILDREN_PROVIDER, new ChildrenProvider() { + + @Override + public boolean hasChildren(Node node, ServiceContext context) { + return true; + } + + @Override + public List getChildren(Node node, ServiceContext context) { + List children = new ArrayList(); + List types = CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getRegisteredTypes(); + Collections.sort(types); // show them in alphabetical order for better readability + for (String type : types) { + children.add(new Node(TYPE, TYPES_JAVA, type, null)); + } + return children; + } + }); /////////////////////////////////////////////////// // add categories and controller keys to type /////////////////////////////////////////////////// - TypeDebugController typeDebugController = new TypeDebugController(); CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(TYPE) - .addAdditiveController(CHILDREN_PROVIDER, typeDebugController) - .addAdditiveController(PROPERTIES_PROVIDER, typeDebugController); + .addAdditiveController(PROPERTIES_PROVIDER, new PropertiesProvider() { + + @Override + public void populateWithProperties(Node node, ServiceContext context) { + node.getProperties().put(NAME, node.getIdWithinResource()); + node.getProperties().put(ICONS, ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/idea.png")); + } + }) + .addAdditiveController(CHILDREN_PROVIDER, new ChildrenProvider() { + + @Override + public boolean hasChildren(Node node, ServiceContext context) { + return true; + } + + @Override + public List getChildren(Node node, ServiceContext context) { + String type = node.getIdWithinResource(); + TypeDescriptor descriptor = CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getExpectedTypeDescriptor(type); + List children = new ArrayList(); + + // get categories + for (String category : descriptor.getCategories()) { + children.add(new Node(CATEGORY, type, category, null)); + } + + TypeDescriptorDebugWrapper wrapper = new TypeDescriptorDebugWrapper(descriptor); + + // get single controllers keys + for (String singleControllersKey : wrapper.getSingleControllersKeys()) { + children.add(new Node(CONTROLLER_KEY_SINGLE, type, singleControllersKey, null)); + } + + // get additive controllers keys + for (String additiveControllersKey : wrapper.getAdditiveControllersKeys()) { + children.add(new Node(CONTROLLER_KEY_ADDITIVE, type, additiveControllersKey, null)); + } + + return children; + } + }); /////////////////////////////////////////////////// // set category name and icons /////////////////////////////////////////////////// CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(CATEGORY) - .addAdditiveController(PROPERTIES_PROVIDER, new CategoryDebugController()); + .addAdditiveController(PROPERTIES_PROVIDER, new PropertiesProvider() { + + @Override + public void populateWithProperties(Node node, ServiceContext context) { + node.getProperties().put(NAME, node.getIdWithinResource()); + node.getProperties().put(ICONS, ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/folder.png")); + } + }); /////////////////////////////////////////////////// // add controllers to controller key /////////////////////////////////////////////////// - SingleControllerKeyDebugController singleControllerKeyDebugController = new SingleControllerKeyDebugController(); CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(CONTROLLER_KEY_SINGLE) - .addAdditiveController(CHILDREN_PROVIDER, singleControllerKeyDebugController) - .addAdditiveController(PROPERTIES_PROVIDER, singleControllerKeyDebugController); + .addAdditiveController(PROPERTIES_PROVIDER, new PropertiesProvider() { + + @Override + public void populateWithProperties(Node node, ServiceContext context) { + // node: CONTROLLER_KEY_SINGLE|descriptorType|controllerKey + node.getProperties().put(NAME, node.getIdWithinResource()); + String icons = ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/full-1.png"); + TypeDescriptorDebugWrapper wrapper = new TypeDescriptorDebugWrapper(CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getExpectedTypeDescriptor(node.getResource())); + if (wrapper.isCachedSingleController(node.getIdWithinResource())) { + icons += ICONS_SEPARATOR + ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/flag.png"); + } + node.getProperties().put(ICONS, icons); + } + }) + .addAdditiveController(CHILDREN_PROVIDER, new ChildrenProvider() { + + @Override + public boolean hasChildren(Node node, ServiceContext context) { + return true; + } + + @Override + public List getChildren(Node node, ServiceContext context) { + // parent: CONTROLLER_KEY_SINGLE|type|controllerKey + List children = new ArrayList(); + TypeDescriptor descriptor = CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getExpectedTypeDescriptor(node.getResource()); + TypeDescriptorDebugWrapper wrapper = new TypeDescriptorDebugWrapper(descriptor); + + AbstractController cachedController = wrapper.getCachedSingleController(node.getIdWithinResource()); + AbstractController selfController = wrapper.getSelfSingleController(node.getIdWithinResource()); + + // add cached controller + if (cachedController != null) { + Node child = TypeDescriptorRegistryDebugControllers.this.createControllerNode(cachedController, CONTROLLER_SINGLE, node.getFullNodeId()); + String icons = (String) child.getOrPopulateProperties().get(ICONS); + if (cachedController != selfController) { + // override + icons += ICONS_SEPARATOR + ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/attach.png"); + child.getOrPopulateProperties().put(ICONS, icons); + } + children.add(child); + } + + // add self controller - only if different from cached + if (selfController != null && selfController != cachedController) { + Node child = TypeDescriptorRegistryDebugControllers.this.createControllerNode(selfController, CONTROLLER_SINGLE, node.getFullNodeId()); + // deleted + child.getOrPopulateProperties().put(ICONS, ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/button-cancel.png")); + children.add(child); + } + + return children; + } + }); - AdditiveControllerKeyDebugController additiveControllerKeyDebugController = new AdditiveControllerKeyDebugController(); CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(CONTROLLER_KEY_ADDITIVE) - .addAdditiveController(CHILDREN_PROVIDER, additiveControllerKeyDebugController) - .addAdditiveController(PROPERTIES_PROVIDER, additiveControllerKeyDebugController); + .addAdditiveController(PROPERTIES_PROVIDER, new PropertiesProvider() { + + @Override + public void populateWithProperties(Node node, ServiceContext context) { + // node: CONTROLLER_KEY_ADDITIVE|descriptorType|controllerKey + node.getProperties().put(NAME, node.getIdWithinResource()); + String icons = ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/positive.png"); + TypeDescriptorDebugWrapper wrapper = new TypeDescriptorDebugWrapper(CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getExpectedTypeDescriptor(node.getResource())); + if (wrapper.isCachedAdditiveController(node.getIdWithinResource())) { + icons += ICONS_SEPARATOR + ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/flag.png"); + } + node.getProperties().put(ICONS, icons); + } + }) + .addAdditiveController(CHILDREN_PROVIDER, new ChildrenProvider() { + + @Override + public boolean hasChildren(Node node, ServiceContext context) { + return true; + } + + @Override + public List getChildren(Node node, ServiceContext context) { + // parent: CONTROLLER_KEY_ADDITIVE|type|controllerKey + List children = new ArrayList(); + TypeDescriptor descriptor = CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getExpectedTypeDescriptor(node.getResource()); + TypeDescriptorDebugWrapper wrapper = new TypeDescriptorDebugWrapper(descriptor); + + List cachedControllers = wrapper.getCachedAdditiveControllers(node.getIdWithinResource()); + List selfControllers = wrapper.getSelfAdditiveControllers(node.getIdWithinResource()); + + // add controllers + for (AbstractController cachedController : cachedControllers) { + Node child = TypeDescriptorRegistryDebugControllers.this.createControllerNode(cachedController, CONTROLLER_ADDITIVE, node.getFullNodeId()); + String icons = (String) child.getOrPopulateProperties().get(ICONS); + if (!selfControllers.contains(cachedController)) { + // contributed + icons += ICONS_SEPARATOR + ResourcesPlugin.getInstance().getResourceUrl("/images/mindmap/icons/attach.png"); + child.getOrPopulateProperties().put(ICONS, icons); + } + children.add(child); + } + + return children; + } + }); /////////////////////////////////////////////////// // controller descriptors @@ -311,7 +294,7 @@ public void registerControllers() { } - private Node createControllerNode(Object controller, String type, String resource) { + private Node createControllerNode(AbstractController controller, String type, String resource) { String id = controller.toString(); Node node = new Node(type, resource, id, null); node.getOrPopulateProperties().put(NAME, id); diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/remote/Node.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/remote/Node.java index def5df90..ad1b3f2a 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/remote/Node.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/remote/Node.java @@ -7,7 +7,7 @@ import org.flowerplatform.core.CorePlugin; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertiesProvider; +import org.flowerplatform.core.node.controller.PropertiesProvider; import org.flowerplatform.util.Utils; /** @@ -94,7 +94,7 @@ public String getFullNodeId() { } /** - * Should be used for writing values in the map. Probably by {@link IPropertiesProvider}. + * Should be used for writing values in the map. Probably by {@link PropertiesProvider}. * * @return The properties map (lazy initialized in here), without any other processing. */ @@ -113,7 +113,7 @@ public void setProperties(Map properties) { * Populates the node (if not populated). Should be used for reading values from the map. * *

- * WARNING: shouldn't be used for writing values. E.g. if {@link IPropertiesProvider}'s try + * WARNING: shouldn't be used for writing values. E.g. if {@link PropertiesProvider}'s try * to use this method, an infinite call loop will be created ({@link StackOverflowError}). * * @return The properties map (populated if not already populated). diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/resource/ResourceDebugControllers.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/resource/ResourceDebugControllers.java index 87d953d2..be87cef5 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/resource/ResourceDebugControllers.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/resource/ResourceDebugControllers.java @@ -27,13 +27,12 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.CorePlugin; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IChildrenProvider; -import org.flowerplatform.core.node.controller.IPropertiesProvider; +import org.flowerplatform.core.node.controller.ChildrenProvider; +import org.flowerplatform.core.node.controller.PropertiesProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.PropertyDescriptor; import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.util.UtilConstants; -import org.flowerplatform.util.controller.AbstractController; /** * @author Mariana Gheorghe @@ -52,199 +51,163 @@ public class ResourceDebugControllers { private final String SESSION_CATEGORY = UtilConstants.CATEGORY_PREFIX + SESSION; private final String RESOURCE_NODE_INFO_CATEGORY = UtilConstants.CATEGORY_PREFIX + RESOURCE_NODE_INFO; - class RootDebugController extends AbstractController implements IChildrenProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - return true; - } - - @Override - public List getChildren(Node node, ServiceContext context) { - return Collections.singletonList(new Node(DEBUG, null, null, null)); - } - } - - class DebugController extends AbstractController implements IPropertiesProvider, IChildrenProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - return true; - } - - @Override - public List getChildren(Node node, ServiceContext context) { - return Collections.singletonList(new Node(RESOURCES, DEBUG, null, null)); - } + public void registerControllers() { - @Override - public void populateWithProperties(Node node, ServiceContext context) { - node.getProperties().put(CoreConstants.NAME, DEBUG); - } - } - - class ResourcesDebugController extends AbstractController implements IPropertiesProvider, IChildrenProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - return true; - } + // add _debug node to root - @Override - public List getChildren(Node node, ServiceContext context) { - List children = new ArrayList(); + CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(CoreConstants.ROOT_TYPE) + .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, new ChildrenProvider() { - // sessions - for (String sessionId : CorePlugin.getInstance().getResourceService().getSubscribedSessions()) { - Node session = new Node(SESSION, node.getResource(), sessionId, null); - children.add(session); + @Override + public boolean hasChildren(Node node, ServiceContext context) { + return true; } - // resources - for (String resourceId : CorePlugin.getInstance().getResourceService().getResources()) { - Node resource = new Node(RESOURCE_NODE_INFO, node.getResource(), resourceId.replace("|", "+"), null); - children.add(resource); + @Override + public List getChildren(Node node, ServiceContext context) { + return Collections.singletonList(new Node(DEBUG, null, null, null)); } - - return children; - } - - @Override - public void populateWithProperties(Node node, ServiceContext context) { - node.getProperties().put(CoreConstants.NAME, "Resources"); - } - } - - class SessionCategoryDebugController extends AbstractController implements IPropertiesProvider { + }.setOrderIndexAs(10000)); - @Override - public void populateWithProperties(Node node, ServiceContext context) { - String sessionId = node.getIdWithinResource().split(" ")[0]; - node.getProperties().put(CoreConstants.NAME, "Session " + sessionId); - node.getProperties().put("ip", CorePlugin.getInstance().getResourceService().getSessionProperty(sessionId, "ip")); - context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); - } - } - - class SessionDebugController extends AbstractController implements IChildrenProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); - return true; - } - - @Override - public List getChildren(Node node, ServiceContext context) { - context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); - List children = new ArrayList(); - String sessionId = node.getIdWithinResource().split(" ")[0]; - for (String resourceId : CorePlugin.getInstance().getResourceService().getResourcesSubscribedBySession(sessionId)) { - Node resource = new Node(RESOURCE_NODE_INFO2, node.getResource(), resourceId.replace("|", "+"), null); - children.add(resource); + CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(DEBUG) + .addAdditiveController(CoreConstants.PROPERTIES_PROVIDER, new PropertiesProvider() { + + @Override + public void populateWithProperties(Node node, ServiceContext context) { + node.getProperties().put(CoreConstants.NAME, DEBUG); } - return children; - } - } - - class ResourceNodeInfoCategoryDebugController extends AbstractController implements IPropertiesProvider { - - @Override - public void populateWithProperties(Node node, ServiceContext context) { - String resourceId = node.getIdWithinResource().replace("+", "|").split(" ")[0]; - node.getProperties().put(CoreConstants.NAME, "Resource " + resourceId); - long timestamp = CorePlugin.getInstance().getResourceService().getUpdateRequestedTimestamp(resourceId); - node.getProperties().put(CoreConstants.LAST_UPDATE_TIMESTAMP, timestamp); - context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); - } - } - - class ResourceNodeInfoDebugController extends AbstractController implements IChildrenProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); - return true; - } - - @Override - public List getChildren(Node node, ServiceContext context) { - context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); + }) + .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, new ChildrenProvider() { - List children = new ArrayList(); - String resourceId = node.getIdWithinResource().replace("+", "|"); - for (String sessionId : CorePlugin.getInstance().getResourceService().getSessionsSubscribedToResource(resourceId)) { - Node session = new Node(SESSION3, node.getResource(), sessionId, null); - children.add(session); + @Override + public boolean hasChildren(Node node, ServiceContext context) { + return true; } - return children; - } - } - - class ResourceNodeInfo2DebugController extends AbstractController implements IChildrenProvider { - - @Override - public boolean hasChildren(Node node, ServiceContext context) { - context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); - return true; - } - - @Override - public List getChildren(Node node, ServiceContext context) { - context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); - List children = new ArrayList(); - String resourceId = node.getIdWithinResource().replace("+", "|"); - for (String sessionId : CorePlugin.getInstance().getResourceService().getSessionsSubscribedToResource(resourceId)) { - Node session = new Node(SESSION2, node.getResource(), sessionId, null); - children.add(session); + @Override + public List getChildren(Node node, ServiceContext context) { + return Collections.singletonList(new Node(RESOURCES, DEBUG, null, null)); } - return children; - } - } - - public void registerControllers() { - - // add _debug node to root - - CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(CoreConstants.ROOT_TYPE) - .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, new RootDebugController().setOrderIndexAs(10000)); - - DebugController debugController = new DebugController(); - CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(DEBUG) - .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, debugController) - .addAdditiveController(CoreConstants.PROPERTIES_PROVIDER, debugController); + }); // _debug node - ResourcesDebugController resourcesDebugController = new ResourcesDebugController(); CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(RESOURCES) - .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, resourcesDebugController) - .addAdditiveController(CoreConstants.PROPERTIES_PROVIDER, resourcesDebugController); + .addAdditiveController(CoreConstants.PROPERTIES_PROVIDER, new PropertiesProvider() { + + @Override + public void populateWithProperties(Node node, ServiceContext context) { + node.getProperties().put(CoreConstants.NAME, "Resources"); + } + }) + .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, new ChildrenProvider() { + + @Override + public boolean hasChildren(Node node, ServiceContext context) { + return true; + } + + @Override + public List getChildren(Node node, ServiceContext context) { + List children = new ArrayList(); + + // sessions + for (String sessionId : CorePlugin.getInstance().getResourceService().getSubscribedSessions()) { + Node session = new Node(SESSION, node.getResource(), sessionId, null); + children.add(session); + } + + // resources + for (String resourceId : CorePlugin.getInstance().getResourceService().getResources()) { + Node resource = new Node(RESOURCE_NODE_INFO, node.getResource(), resourceId.replace("|", "+"), null); + children.add(resource); + } + + return children; + } + }); // properties for session CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateCategoryTypeDescriptor(SESSION_CATEGORY) - .addAdditiveController(CoreConstants.PROPERTIES_PROVIDER, new SessionCategoryDebugController().setOrderIndexAs(-500000)) + .addAdditiveController(CoreConstants.PROPERTIES_PROVIDER, new PropertiesProvider() { + + @Override + public void populateWithProperties(Node node, ServiceContext context) { + String sessionId = node.getIdWithinResource().split(" ")[0]; + node.getProperties().put(CoreConstants.NAME, "Session " + sessionId); + node.getProperties().put("ip", CorePlugin.getInstance().getResourceService().getSessionProperty(sessionId, "ip")); + context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); + } + }.setOrderIndexAs(-500000)) .addAdditiveController(CoreConstants.PROPERTY_DESCRIPTOR, new PropertyDescriptor().setNameAs("ip")); // session as child of _debug; children are resources CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(SESSION) .addCategory(SESSION_CATEGORY) - .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, new SessionDebugController()); + .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, new ChildrenProvider() { + + @Override + public boolean hasChildren(Node node, ServiceContext context) { + context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); + return true; + } + + @Override + public List getChildren(Node node, ServiceContext context) { + context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); + List children = new ArrayList(); + String sessionId = node.getIdWithinResource().split(" ")[0]; + for (String resourceId : CorePlugin.getInstance().getResourceService().getResourcesSubscribedBySession(sessionId)) { + Node resource = new Node(RESOURCE_NODE_INFO2, node.getResource(), resourceId.replace("|", "+"), null); + children.add(resource); + } + return children; + } + }); // properties for resource CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateCategoryTypeDescriptor(RESOURCE_NODE_INFO_CATEGORY) - .addAdditiveController(CoreConstants.PROPERTIES_PROVIDER, new ResourceNodeInfoCategoryDebugController().setOrderIndexAs(-500000)) + .addAdditiveController(CoreConstants.PROPERTIES_PROVIDER, new PropertiesProvider() { + + @Override + public void populateWithProperties(Node node, ServiceContext context) { + String resourceId = node.getIdWithinResource().replace("+", "|").split(" ")[0]; + node.getProperties().put(CoreConstants.NAME, "Resource " + resourceId); + long timestamp = CorePlugin.getInstance().getResourceService().getUpdateRequestedTimestamp(resourceId); + node.getProperties().put(CoreConstants.LAST_UPDATE_TIMESTAMP, timestamp); + context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); + } + }.setOrderIndexAs(-500000)) .addAdditiveController(CoreConstants.PROPERTY_DESCRIPTOR, new PropertyDescriptor().setNameAs(CoreConstants.LAST_UPDATE_TIMESTAMP)); // resource as child of session; children are sessions CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(RESOURCE_NODE_INFO2) .addCategory(RESOURCE_NODE_INFO_CATEGORY) - .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, new ResourceNodeInfo2DebugController()); + .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, new ChildrenProvider() { + + @Override + public boolean hasChildren(Node node, ServiceContext context) { + context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); + return true; + } + + @Override + public List getChildren(Node node, ServiceContext context) { + context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); + + List children = new ArrayList(); + String resourceId = node.getIdWithinResource().replace("+", "|"); + for (String sessionId : CorePlugin.getInstance().getResourceService().getSessionsSubscribedToResource(resourceId)) { + Node session = new Node(SESSION2, node.getResource(), sessionId, null); + children.add(session); + } + return children; + } + }); // session as child of resource @@ -254,7 +217,27 @@ public void registerControllers() { // resource as child of _debug; children are sessions CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(RESOURCE_NODE_INFO) .addCategory(RESOURCE_NODE_INFO_CATEGORY) - .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, new ResourceNodeInfoDebugController()); + .addAdditiveController(CoreConstants.CHILDREN_PROVIDER, new ChildrenProvider() { + + @Override + public boolean hasChildren(Node node, ServiceContext context) { + context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); + return true; + } + + @Override + public List getChildren(Node node, ServiceContext context) { + context.add(CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS, true); + + List children = new ArrayList(); + String resourceId = node.getIdWithinResource().replace("+", "|"); + for (String sessionId : CorePlugin.getInstance().getResourceService().getSessionsSubscribedToResource(resourceId)) { + Node session = new Node(SESSION3, node.getResource(), sessionId, null); + children.add(session); + } + return children; + } + }); // session as child of resource CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(SESSION3) diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdateAddNodeController.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdateAddNodeController.java new file mode 100644 index 00000000..9b48a428 --- /dev/null +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdateAddNodeController.java @@ -0,0 +1,37 @@ +package org.flowerplatform.core.node.update.controller; + +import static org.flowerplatform.core.CoreConstants.UPDATE_CHILD_ADDED; + +import org.flowerplatform.core.CoreConstants; +import org.flowerplatform.core.CorePlugin; +import org.flowerplatform.core.CoreUtils; +import org.flowerplatform.core.node.NodeService; +import org.flowerplatform.core.node.controller.AddNodeController; +import org.flowerplatform.core.node.remote.Node; +import org.flowerplatform.core.node.remote.ServiceContext; +import org.flowerplatform.core.node.update.remote.ChildrenUpdate; + +public class UpdateAddNodeController extends AddNodeController { + + public UpdateAddNodeController() { + // must be invoked last; otherwise the modification may not be fully/correctly recorded + setOrderIndex(100000); + } + + @Override + public void addNode(Node node, Node child, ServiceContext context) { + Node resourceNode = CoreUtils.getResourceNode(node); + String insertBeforeFullNodeId = (String) context.get(CoreConstants.INSERT_BEFORE_FULL_NODE_ID); + if (resourceNode != null) { + CorePlugin.getInstance().getResourceService() + .addUpdate(resourceNode.getFullNodeId(), + new ChildrenUpdate() + .setTypeAs(UPDATE_CHILD_ADDED) + .setTargetNodeAs(child) + .setFullTargetNodeAddedBeforeIdAs(insertBeforeFullNodeId) + .setFullNodeIdAs(node.getFullNodeId())); + + } + } + +} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdateController.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdateController.java deleted file mode 100644 index df0598e0..00000000 --- a/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdateController.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.flowerplatform.core.node.update.controller; - -import static org.flowerplatform.core.CoreConstants.NODE_IS_RESOURCE_NODE; -import static org.flowerplatform.core.CoreConstants.UPDATE_CHILD_ADDED; -import static org.flowerplatform.core.CoreConstants.UPDATE_CHILD_REMOVED; - -import org.flowerplatform.core.CoreConstants; -import org.flowerplatform.core.CorePlugin; -import org.flowerplatform.core.CoreUtils; -import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IAddNodeController; -import org.flowerplatform.core.node.controller.IPropertySetter; -import org.flowerplatform.core.node.controller.IRemoveNodeController; -import org.flowerplatform.core.node.controller.PropertyValueWrapper; -import org.flowerplatform.core.node.remote.Node; -import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.core.node.update.remote.ChildrenUpdate; -import org.flowerplatform.core.node.update.remote.PropertyUpdate; -import org.flowerplatform.util.controller.AbstractController; - -/** - * @author Cristina Constantinescu - */ -public class UpdateController extends AbstractController - implements IAddNodeController, IRemoveNodeController, IPropertySetter { - - public UpdateController() { - // must be invoked last; otherwise the modification may not be fully/correctly recorded - setOrderIndex(100000); - } - - @Override - public void addNode(Node node, Node child, ServiceContext context) { - Node resourceNode = CoreUtils.getResourceNode(node); - String insertBeforeFullNodeId = (String) context.get(CoreConstants.INSERT_BEFORE_FULL_NODE_ID); - if (resourceNode != null) { - CorePlugin.getInstance().getResourceService() - .addUpdate(resourceNode.getFullNodeId(), - new ChildrenUpdate() - .setTypeAs(UPDATE_CHILD_ADDED) - .setTargetNodeAs(child) - .setFullTargetNodeAddedBeforeIdAs(insertBeforeFullNodeId) - .setFullNodeIdAs(node.getFullNodeId())); - - } - } - - @Override - public void removeNode(Node node, Node child, ServiceContext context) { - Node resourceNode = CoreUtils.getResourceNode(node); - if (resourceNode != null) { - CorePlugin.getInstance().getResourceService() - .addUpdate(resourceNode.getFullNodeId(), - new ChildrenUpdate() - .setTypeAs(UPDATE_CHILD_REMOVED) - .setTargetNodeAs(child) - .setFullNodeIdAs(node.getFullNodeId())); - } - } - - @Override - public void setProperty(Node node, String key, PropertyValueWrapper wrapper, ServiceContext context) { - setUnsetProperty(node, key, wrapper.getPropertyValue(), false, context); - } - - @Override - public void unsetProperty(Node node, String key, ServiceContext context) { - setUnsetProperty(node, key, node.getOrPopulateProperties().get(key), false, context); - } - - private void setUnsetProperty(Node node, String key, Object value, boolean isUnset, ServiceContext context) { - Node resourceNode; - if (context.getBooleanValue(NODE_IS_RESOURCE_NODE)) { - resourceNode = node; - } else { - resourceNode = CoreUtils.getResourceNode(node); - if (resourceNode == null) { - return; - } - } - - CorePlugin.getInstance().getResourceService() - .addUpdate(resourceNode.getFullNodeId(), new PropertyUpdate().setKeyAs(key).setValueAs(value).setUnsetAs(isUnset).setFullNodeIdAs(node.getFullNodeId())); - } - -} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdatePropertySetterController.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdatePropertySetterController.java new file mode 100644 index 00000000..c593bd5e --- /dev/null +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdatePropertySetterController.java @@ -0,0 +1,49 @@ +package org.flowerplatform.core.node.update.controller; + +import static org.flowerplatform.core.CoreConstants.NODE_IS_RESOURCE_NODE; + +import org.flowerplatform.core.CorePlugin; +import org.flowerplatform.core.CoreUtils; +import org.flowerplatform.core.node.NodeService; +import org.flowerplatform.core.node.controller.PropertySetter; +import org.flowerplatform.core.node.controller.PropertyValueWrapper; +import org.flowerplatform.core.node.remote.Node; +import org.flowerplatform.core.node.remote.ServiceContext; +import org.flowerplatform.core.node.update.remote.PropertyUpdate; + +/** + * @author Cristina Constantinescu + */ +public class UpdatePropertySetterController extends PropertySetter { + + public UpdatePropertySetterController() { + // must be invoked last; otherwise the modification may not be fully/correctly recorded + setOrderIndex(100000); + } + + @Override + public void setProperty(Node node, String key, PropertyValueWrapper wrapper, ServiceContext context) { + setUnsetProperty(node, key, wrapper.getPropertyValue(), false, context); + } + + @Override + public void unsetProperty(Node node, String key, ServiceContext context) { + setUnsetProperty(node, key, node.getOrPopulateProperties().get(key), false, context); + } + + private void setUnsetProperty(Node node, String key, Object value, boolean isUnset, ServiceContext context) { + Node resourceNode; + if (context.getBooleanValue(NODE_IS_RESOURCE_NODE)) { + resourceNode = node; + } else { + resourceNode = CoreUtils.getResourceNode(node); + if (resourceNode == null) { + return; + } + } + + CorePlugin.getInstance().getResourceService() + .addUpdate(resourceNode.getFullNodeId(), new PropertyUpdate().setKeyAs(key).setValueAs(value).setUnsetAs(isUnset).setFullNodeIdAs(node.getFullNodeId())); + } + +} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdateRemoveNodeController.java b/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdateRemoveNodeController.java new file mode 100644 index 00000000..d4c44a35 --- /dev/null +++ b/org.flowerplatform.core/src/org/flowerplatform/core/node/update/controller/UpdateRemoveNodeController.java @@ -0,0 +1,36 @@ +package org.flowerplatform.core.node.update.controller; + +import static org.flowerplatform.core.CoreConstants.UPDATE_CHILD_REMOVED; + +import org.flowerplatform.core.CorePlugin; +import org.flowerplatform.core.CoreUtils; +import org.flowerplatform.core.node.NodeService; +import org.flowerplatform.core.node.controller.RemoveNodeController; +import org.flowerplatform.core.node.remote.Node; +import org.flowerplatform.core.node.remote.ServiceContext; +import org.flowerplatform.core.node.update.remote.ChildrenUpdate; + +/** + * @author Cristina Constantinescu + */ +public class UpdateRemoveNodeController extends RemoveNodeController { + + public UpdateRemoveNodeController() { + // must be invoked last; otherwise the modification may not be fully/correctly recorded + setOrderIndex(100000); + } + + @Override + public void removeNode(Node node, Node child, ServiceContext context) { + Node resourceNode = CoreUtils.getResourceNode(node); + if (resourceNode != null) { + CorePlugin.getInstance().getResourceService() + .addUpdate(resourceNode.getFullNodeId(), + new ChildrenUpdate() + .setTypeAs(UPDATE_CHILD_REMOVED) + .setTargetNodeAs(child) + .setFullNodeIdAs(node.getFullNodeId())); + } + } + +} diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/repository/RepositoryChildrenProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/repository/RepositoryChildrenProvider.java index e8477a90..caae5cbe 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/repository/RepositoryChildrenProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/repository/RepositoryChildrenProvider.java @@ -5,15 +5,14 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IChildrenProvider; +import org.flowerplatform.core.node.controller.ChildrenProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; /** * @author Sebastian Solomon */ -public class RepositoryChildrenProvider extends AbstractController implements IChildrenProvider { +public class RepositoryChildrenProvider extends ChildrenProvider { public RepositoryChildrenProvider() { setOrderIndex(200); diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/repository/RepositoryPropertiesProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/repository/RepositoryPropertiesProvider.java index 6b883463..1ee43f31 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/repository/RepositoryPropertiesProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/repository/RepositoryPropertiesProvider.java @@ -4,15 +4,14 @@ import org.flowerplatform.core.CorePlugin; import org.flowerplatform.core.file.IFileAccessController; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertiesProvider; +import org.flowerplatform.core.node.controller.PropertiesProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; /** * @author Sebastian Solomon */ -public class RepositoryPropertiesProvider extends AbstractController implements IPropertiesProvider { +public class RepositoryPropertiesProvider extends PropertiesProvider { @Override public void populateWithProperties(Node node, ServiceContext context) { diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/repository/RootChildrenProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/repository/RootChildrenProvider.java index 6251d992..bcbbcfb1 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/repository/RootChildrenProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/repository/RootChildrenProvider.java @@ -5,15 +5,14 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IChildrenProvider; +import org.flowerplatform.core.node.controller.ChildrenProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; /** * @author Sebastian Solomon */ -public class RootChildrenProvider extends AbstractController implements IChildrenProvider { +public class RootChildrenProvider extends ChildrenProvider { public RootChildrenProvider() { setOrderIndex(200); diff --git a/org.flowerplatform.core/src/org/flowerplatform/core/repository/RootPropertiesProvider.java b/org.flowerplatform.core/src/org/flowerplatform/core/repository/RootPropertiesProvider.java index b47d9958..d8ca882c 100644 --- a/org.flowerplatform.core/src/org/flowerplatform/core/repository/RootPropertiesProvider.java +++ b/org.flowerplatform.core/src/org/flowerplatform/core/repository/RootPropertiesProvider.java @@ -2,15 +2,14 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertiesProvider; +import org.flowerplatform.core.node.controller.PropertiesProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; /** * @author Sebastian Solomon */ -public class RootPropertiesProvider extends AbstractController implements IPropertiesProvider { +public class RootPropertiesProvider extends PropertiesProvider { @Override public void populateWithProperties(Node node, ServiceContext context) { diff --git a/org.flowerplatform.flex_client.core/.actionScriptProperties b/org.flowerplatform.flex_client.core/.actionScriptProperties index 457f4ff5..23039ae0 100644 --- a/org.flowerplatform.flex_client.core/.actionScriptProperties +++ b/org.flowerplatform.flex_client.core/.actionScriptProperties @@ -1,5 +1,5 @@ - + diff --git a/org.flowerplatform.flex_client.core/.flexLibProperties b/org.flowerplatform.flex_client.core/.flexLibProperties index 3043e14d..fe78c50d 100644 --- a/org.flowerplatform.flex_client.core/.flexLibProperties +++ b/org.flowerplatform.flex_client.core/.flexLibProperties @@ -7,6 +7,12 @@ + + + + + + diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/CorePlugin.as b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/CorePlugin.as index e1b044aa..21cac783 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/CorePlugin.as +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/CorePlugin.as @@ -194,39 +194,7 @@ package org.flowerplatform.flex_client.core { } ); - serviceLocator.invoke("nodeService.getRegisteredTypeDescriptors", null, - function(result:Object):void { - var list:ArrayCollection = ArrayCollection(result); - for (var i:int = 0; i < list.length; i++) { - var remote:TypeDescriptorRemote = TypeDescriptorRemote(list.getItemAt(i)); - - // create new type descriptor with remote type - var descriptor:TypeDescriptor = null; - if (Utils.beginsWith(remote.type, FlexUtilConstants.CATEGORY_PREFIX)) { - descriptor = nodeTypeDescriptorRegistry.getOrCreateCategoryTypeDescriptor(remote.type); - } else { - descriptor = nodeTypeDescriptorRegistry.getOrCreateTypeDescriptor(remote.type); - } - - // add static categories - for each (var category:String in remote.categories) { - descriptor.addCategory(category); - } - - // add single controllers - for (var singleControllerType:String in remote.singleControllers) { - descriptor.addSingleController(singleControllerType, remote.singleControllers[singleControllerType]); - } - - // add additive controllers - for (var additiveControllerType:String in remote.additiveControllers) { - for each (var additiveController:AbstractController in remote.additiveControllers[additiveControllerType]) { - descriptor.addAdditiveController(additiveControllerType, additiveController); - } - } - } - } - ); + serviceLocator.invoke("nodeService.getRegisteredTypeDescriptors", null, nodeTypeDescriptorRegistry.addTypeDescriptorsRemote); nodeTypeDescriptorRegistry.getOrCreateCategoryTypeDescriptor(FlexUtilConstants.CATEGORY_ALL) .addSingleController(CoreConstants.NODE_TITLE_PROVIDER, new GenericValueProviderFromDescriptor(CoreConstants.PROPERTY_FOR_TITLE_DESCRIPTOR)) @@ -259,8 +227,6 @@ package org.flowerplatform.flex_client.core { .setViewContent(new LinkView()) .setWidth(500) .setHeight(250) - .setTitle(Resources.getMessage("link.title")) - .setIcon(Resources.externalLinkIcon) .show(); }) ); @@ -276,10 +242,8 @@ package org.flowerplatform.flex_client.core { .setFunctionDelegate(function ():void { FlexUtilGlobals.getInstance().popupHandlerFactory.createPopupHandler() .setViewContent(new OpenNodeView()) - .setTitle(Resources.getMessage("open.node.action.label")) - .setIcon(Resources.openResourceIcon) .setWidth(400) - .setHeight(150) + .setHeight(110) .show(); }) ); @@ -310,8 +274,10 @@ package org.flowerplatform.flex_client.core { .show(); }) ); - - FlexUtilGlobals.getInstance().keyBindings.additionalActionProviders.actionProviders.push(globalMenuActionProvider); + + // initial filterShortcuts + // other filterShortcut must be added by corresponding keyboard action + FlexUtilGlobals.getInstance().keyBindings.filterShortcuts = [Keyboard.CONTROL, Keyboard.COMMAND, Keyboard.SHIFT, Keyboard.ALTERNATE]; } override protected function registerClassAliases():void { diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/EditorFrontend.as b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/EditorFrontend.as index ba7815fc..0f716ab5 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/EditorFrontend.as +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/EditorFrontend.as @@ -111,10 +111,5 @@ package org.flowerplatform.flex_client.core.editor { } return title; } - - public function additionalCloseHandler():void { - // nothing to do - } - } } diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/OpenInNewEditorDialog.mxml b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/OpenInNewEditorDialog.mxml index d1f36353..2749da20 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/OpenInNewEditorDialog.mxml +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/OpenInNewEditorDialog.mxml @@ -12,15 +12,22 @@ previously), and a new editor is opened directly. @author Mariana Gheorghe --> - - + implements="org.flowerplatform.flexutil.view_content_host.IViewContent,org.flowerplatform.flexutil.dialog.IDialog"> + + + + - + + + + + + { + return null; } - + private var _resultHandler:IDialogResultHandler; public function setResultHandler(resultHandler:IDialogResultHandler):void { _resultHandler = resultHandler; } - ]]> - + diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/action/RenameAction.as b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/action/RenameAction.as index 5382fd5e..9b577717 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/action/RenameAction.as +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/action/RenameAction.as @@ -84,8 +84,7 @@ package org.flowerplatform.flex_client.core.editor.action { .setViewContent(view) .setWidth(500) .setHeight(400) - .setTitle(label) - .setIcon(icon) + .setTitle(label) .show(); } diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/action/UploadAction.as b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/action/UploadAction.as index 43b354bc..1526b0ca 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/action/UploadAction.as +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/action/UploadAction.as @@ -40,8 +40,6 @@ package org.flowerplatform.flex_client.core.editor.action { .setViewContent(view) .setWidth(500) .setHeight(180) - .setTitle(label) - .setIcon(icon) .show(); } } diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/resource/ResourceNodesListView.mxml b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/resource/ResourceNodesListView.mxml index 4c31813b..bed2a573 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/resource/ResourceNodesListView.mxml +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/resource/ResourceNodesListView.mxml @@ -96,10 +96,6 @@ FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(this); } - public function additionalCloseHandler():void { - // nothing to do - } - ]]> diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/resource/ResourceNodesManager.as b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/resource/ResourceNodesManager.as index a407a894..efaee97b 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/resource/ResourceNodesManager.as +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/resource/ResourceNodesManager.as @@ -105,9 +105,6 @@ package org.flowerplatform.flex_client.core.editor.resource { } public function viewsRemovedHandler(e:ViewsRemovedEvent):void { - if (!e.canPreventDefault) { - return; - } var editors:Array = []; for each (var view:Object in e.removedViews) { var viewComponent:UIComponent = FlexUtilGlobals.getInstance().workbench.getEditorFromViewComponent(UIComponent(view)); diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/AboutView.mxml b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/AboutView.mxml index b2b0b09e..5116e1cc 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/AboutView.mxml +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/AboutView.mxml @@ -67,9 +67,6 @@ license-end UIComponent(apiVersionLabel.labelDisplay).setStyle('fontWeight','normal'); } - public function additionalCloseHandler():void { - // nothing to do - } ]]> diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/OpenNodeView.mxml b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/OpenNodeView.mxml index dd34953c..4a952836 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/OpenNodeView.mxml +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/OpenNodeView.mxml @@ -21,11 +21,12 @@ license-end - + creationComplete="creationCompleteHandler(event)"> { + return null; + } + + public function get viewHost():IViewHost { + return _viewHost; + } + + public function set viewHost(viewHost:IViewHost):void { + _viewHost = viewHost; + _viewHost.setLabel(Resources.getMessage("open.node.action.label")); + _viewHost.setIcon(Resources.openResourceIcon); + } + + protected function creationCompleteHandler(event:FlexEvent):void { focusManager.setFocus(link); } - override protected function okHandler(event:Event = null):void { + protected function okButtonHandler(event:MouseEvent):void { CorePlugin.getInstance().handleLinkForCommand(CoreConstants.OPEN_RESOURCES, link.text); - cancelHandler(); + cancel(); + } + + protected function cancel():void { + FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(this); } - + ]]> - + - + - - + + + + + + diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/RichTextWithRendererView.mxml b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/RichTextWithRendererView.mxml index 04223e09..78c25eeb 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/RichTextWithRendererView.mxml +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/RichTextWithRendererView.mxml @@ -2,33 +2,43 @@ - + implements="org.flowerplatform.flexutil.view_content_host.IViewContent" + width="100%" height="100%" initialize="initializeHandler(event)" + creationComplete="creationCompleteHandler(event)"> true, the node's renderer will be displayed at the bottom. *

@@ -41,9 +51,18 @@ public var resultHandler:Function; protected var renderer:AbstractMindMapModelRenderer; - - override protected function initializeHandler(event:FlexEvent):void { - super.initializeHandler(event); + protected var _viewhost:IViewHost; + + public function getActions(selection:IList):Vector. { + return null; + } + + public function set viewHost(viewHost:IViewHost):void { + _viewhost = viewHost; + _viewhost.setIcon(icon); + } + + protected function initializeHandler(event:FlexEvent):void { if (showRendererArea) { renderer.data = ObjectUtil.copy(node); } @@ -70,15 +89,18 @@ /** * @author Sebastian Solomon */ - override protected function creationCompleteHandler(event:FlexEvent):void { - super.creationCompleteHandler(event); + protected function creationCompleteHandler(flexvent:FlexEvent):void { focusManager.setFocus(textEditor); } - override protected function okHandler(event:Event = null):void { + protected function okButton_clickHandler(event:MouseEvent):void { resultHandler(textEditor.text); } - + + protected function cancelButton_clickHandler(event:MouseEvent = null):void { + FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(this); + } + public function textChangeHandler(event:TextOperationEvent):void { if (!showRendererArea) { return; @@ -90,10 +112,14 @@ // dispatch event to update preview renderer's text renderer.data.dispatchEvent(new NodeUpdatedEvent(Node(renderer.data), new ArrayList([titleProperty]))); } - + ]]> - + + + + + @@ -109,5 +135,10 @@ - - + + + + + + + diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/UploadView.mxml b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/UploadView.mxml index 0be98625..f102af09 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/UploadView.mxml +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/editor/ui/UploadView.mxml @@ -2,10 +2,10 @@ - + xmlns:mx="library://ns.adobe.com/flex/mx" implements="org.flowerplatform.flexutil.view_content_host.IViewContent" + creationComplete="creationCompleteHandler(event)"> { + return null; + } + + public function set viewHost(viewHost:IViewHost):void { + _viewhost = viewHost; + _viewhost.setLabel(Resources.getMessage("action.upload")); + _viewhost.setIcon(Resources.uploadIcon); + } + + protected function creationCompleteHandler(event:FlexEvent):void { fileReference = new FileReference(); fileReference.addEventListener(Event.SELECT, onSelectHandler); fileReference.addEventListener(ProgressEvent.PROGRESS, onProgressHandler); @@ -48,7 +57,7 @@ fileReference.browse(); } - override protected function okHandler(event:Event = null):void { + protected function upload_clickHandler(event:MouseEvent):void { if (Utils.endsWith(fileReference.name, ZIP_EXTENSION)) { FlexUtilGlobals.getInstance().messageBoxFactory.createMessageBox() .setText(Resources.getMessage("upload.make.archive")) @@ -75,7 +84,7 @@ fileReference.upload(request); progressArea.visible = true; - okButton.enabled = false; + uploadBtn.enabled = false; browseBtn.enabled = false; } } @@ -84,7 +93,7 @@ protected function onSelectHandler(event:Event):void { locationTxt.text = fileReference.name; - okButton.enabled = true; + uploadBtn.enabled = true; } protected function onIoErrorHandler(event:IOErrorEvent):void { @@ -92,7 +101,7 @@ .setTitle(Resources.getMessage("error")) .setText(event.text) .showMessageBox(); - cancelHandler(); + closeView(); } protected function onProgressHandler(event:ProgressEvent):void { @@ -113,27 +122,34 @@ } } - cancelHandler(); + closeView(); } - - override public function additionalCloseHandler():void { + + protected function closeView():void { fileReference.cancel(); + FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(this); } ]]> + + + - + - - - + - - + + + + + + + diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/link/LinkView.mxml b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/link/LinkView.mxml index 029a4d9d..3192a054 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/link/LinkView.mxml +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/link/LinkView.mxml @@ -58,6 +58,8 @@ license-end public function set viewHost(viewHost:IViewHost):void { _viewHost = viewHost; + _viewHost.setLabel(Resources.getMessage('link.title')); + _viewHost.setIcon(Resources.externalLinkIcon); } protected function creationCompleteHandler(event:FlexEvent):void { @@ -86,9 +88,6 @@ license-end return CorePlugin.getInstance().getAppUrl() + "?" + CoreConstants.OPEN_RESOURCES + "="; } - public function additionalCloseHandler():void { - // nothing to do - } ]]> diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/service/ReconnectingViewContent.mxml b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/service/ReconnectingViewContent.mxml index 3f5bd0d8..8d746643 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/service/ReconnectingViewContent.mxml +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/service/ReconnectingViewContent.mxml @@ -73,9 +73,6 @@ return null; } - public function additionalCloseHandler():void { - // nothing to do - } ]]> diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/shortcut/AssignHotKeyAction.as b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/shortcut/AssignHotKeyAction.as index d3824542..427abd1e 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/shortcut/AssignHotKeyAction.as +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/shortcut/AssignHotKeyAction.as @@ -15,17 +15,11 @@ package org.flowerplatform.flex_client.core.shortcut { */ public class AssignHotKeyAction extends ActionBase { - private var assignShortcutForActionViewClass:Class = AssignShorcutForActionView; - - public function AssignHotKeyAction(assignShortcutForActionViewClass:Class = null) { + public function AssignHotKeyAction() { super(); label = Resources.getMessage("asign.hotkey.action.label"); icon = Resources.keyboardIcon; parentId = CoreConstants.TOOLS_MENU_ID; - - if (assignShortcutForActionViewClass != null) { - this.assignShortcutForActionViewClass = assignShortcutForActionViewClass; - } } override public function run():void { @@ -34,13 +28,9 @@ package org.flowerplatform.flex_client.core.shortcut { var messageBox:IMessageBox = FlexUtilGlobals.getInstance().messageBoxFactory.createMessageBox() .setTitle(label) .setText(Resources.getMessage("shortcut.action.click")) - .setIcon(icon) .setWidth(300) .setHeight(100) - .addButton(FlexUtilAssets.INSTANCE.getMessage('dialog.cancel'), function():void { - FlexUtilGlobals.getInstance().keyBindings.learnShortcutOnNextActionInvocation = false; - UIComponent(FlexGlobals.topLevelApplication).stage.removeEventListener(AssignShortcutForActionEvent.ASSIGN_SHORTCUT_FOR_ACTION, afterSelectingAnActionHandler); - }, true); + .addButton(FlexUtilAssets.INSTANCE.getMessage('dialog.cancel'), function():void {FlexUtilGlobals.getInstance().keyBindings.learnShortcutOnNextActionInvocation = false;}); messageBox.showMessageBox(false); @@ -50,14 +40,12 @@ package org.flowerplatform.flex_client.core.shortcut { UIComponent(FlexGlobals.topLevelApplication).stage.removeEventListener(AssignShortcutForActionEvent.ASSIGN_SHORTCUT_FOR_ACTION, afterSelectingAnActionHandler); // show view to enter shortcut for selected actionId - var view:AssignShorcutForActionView = new assignShortcutForActionViewClass(); + var view:AssignShorcutForActionView = new AssignShorcutForActionView(); view.actionId = event.actionId; FlexUtilGlobals.getInstance().popupHandlerFactory.createPopupHandler() .setViewContent(view) .setWidth(450) .setHeight(130) - .setTitle(Resources.getMessage("shortcut.enter")) - .setIcon(icon) .show(); }; UIComponent(FlexGlobals.topLevelApplication).stage.addEventListener(AssignShortcutForActionEvent.ASSIGN_SHORTCUT_FOR_ACTION, afterSelectingAnActionHandler); diff --git a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/shortcut/AssignShorcutForActionView.mxml b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/shortcut/AssignShorcutForActionView.mxml index 877d0bec..28726317 100644 --- a/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/shortcut/AssignShorcutForActionView.mxml +++ b/org.flowerplatform.flex_client.core/src/org/flowerplatform/flex_client/core/shortcut/AssignShorcutForActionView.mxml @@ -2,11 +2,14 @@ - + xmlns:mx="library://ns.adobe.com/flex/mx" implements="org.flowerplatform.flexutil.view_content_host.IViewContent" + creationComplete="creationCompleteHandler(event)" > + + + { + return null; + } + + public function set viewHost(viewHost:IViewHost):void { + _viewhost = viewHost; + _viewhost.setLabel(Resources.getMessage("shortcut.enter")); + _viewhost.setIcon(Resources.keyboardIcon); + } + + protected function creationCompleteHandler(event:FlexEvent):void { // add listener with the biggest priority -> NO OTHER listeners must intercept key_down events - UIComponent(FlexGlobals.topLevelApplication).stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler1, true, int.MAX_VALUE); + UIComponent(FlexGlobals.topLevelApplication).stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler1, false, int.MAX_VALUE); Utils.makePseudoDisabled(txtShortcut); - - okButton.tabFocusEnabled = false; - cancelButton.tabFocusEnabled = false; } private function keyDownHandler1(event:KeyboardEvent):void { @@ -47,15 +59,6 @@ return; } - // shortcut must start with a key found in filterShortcuts - var filterShortcuts:Dictionary = FlexUtilGlobals.getInstance().keyBindings.filterShortcuts; - if (!(event.ctrlKey && (filterShortcuts.hasOwnProperty("CONTROL") || filterShortcuts.hasOwnProperty("COMMAND")) || - event.altKey && filterShortcuts.hasOwnProperty("ALTERNATE") || - event.shiftKey && filterShortcuts.hasOwnProperty("SHIFT") || - filterShortcuts.hasOwnProperty(Utils.getKeyNameFromKeyCode(event.keyCode)))) { - return; - } - shortcut = new Shortcut(event.ctrlKey, event.shiftKey, event.altKey, event.keyCode); var shortcutLabel:String = shortcut.toString(); if (shortcutLabel == null) { @@ -65,37 +68,29 @@ txtShortcut.text = shortcutLabel; } - override protected function okHandler(event:Event = null):void { - if (shortcut == null || shortcut.toString() == null) { - return; + protected function okButton_clickHandler(event:MouseEvent):void { + if (shortcut != null && shortcut.toString() != null) { + if (!FlexUtilGlobals.getInstance().keyBindings.registerBinding(shortcut, actionId)) { + FlexUtilGlobals.getInstance().messageBoxFactory.createMessageBox() + .setText(Resources.getMessage("shortcut.already.used")) + .setWidth(400) + .setHeight(200) + .showMessageBox(); + return; + } } - - var handler:Object = FlexUtilGlobals.getInstance().keyBindings.getRegisteredHandler(shortcut); - if (handler != null) { // shortcut already assign, ask user - FlexUtilGlobals.getInstance().messageBoxFactory.createMessageBox() - .setText(Resources.getMessage("shortcut.already.used", [handler.toString()])) - .setTitle(Resources.getMessage("info")) - .setWidth(400) - .setHeight(200) - .addButton(FlexUtilAssets.INSTANCE.getMessage('dialog.yes'), function():void {registerBinding(); cancelHandler();}) - .addButton(FlexUtilAssets.INSTANCE.getMessage('dialog.no')) - .showMessageBox(); - } else { - registerBinding(); - cancelHandler(); - } + cancelButton_clickHandler(); } - protected function registerBinding():void { - FlexUtilGlobals.getInstance().keyBindings.registerBinding(shortcut, actionId); - } - - override public function additionalCloseHandler():void { + protected function cancelButton_clickHandler(event:MouseEvent = null):void { // important to remove listener after using it -> otherwise BIG problems (no other key_down events will be dispatched) - UIComponent(FlexGlobals.topLevelApplication).stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler1, true); + UIComponent(FlexGlobals.topLevelApplication).stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler1); + + FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(this); + FlexUtilGlobals.getInstance().keyBindings.learnShortcutOnNextActionInvocation = false; } - + ]]> @@ -103,5 +98,10 @@ - - + + + + + + + diff --git a/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_content_host/WorkbenchMobileSplitViewHost.as b/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_content_host/WorkbenchMobileSplitViewHost.as index 3b3e1134..8bba17e8 100644 --- a/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_content_host/WorkbenchMobileSplitViewHost.as +++ b/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_content_host/WorkbenchMobileSplitViewHost.as @@ -80,14 +80,15 @@ package org.flowerplatform.flex_client.host_app.mobile.view_content_host { public function closeViews(views:ArrayCollection, shouldDispatchEvent:Boolean=true):void { var viewsRemovedEvent:ViewsRemovedEvent = new ViewsRemovedEvent(views); - viewsRemovedEvent.canPreventDefault = shouldDispatchEvent; - dispatchEvent(viewsRemovedEvent); - + if (shouldDispatchEvent) { + dispatchEvent(viewsRemovedEvent); + } for each (var view:UIComponent in views) { if (!viewsRemovedEvent.dontRemoveViews.contains(view)) { var viewRemovedEvent:ViewRemovedEvent = new ViewRemovedEvent(); - viewRemovedEvent.canPreventDefault = shouldDispatchEvent; - view.dispatchEvent(viewRemovedEvent); + if (shouldDispatchEvent) { + view.dispatchEvent(viewRemovedEvent); + } } } } diff --git a/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_edit_server_account/CommunicationErrorView.mxml b/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_edit_server_account/CommunicationErrorView.mxml index 9c8be718..3262bc93 100644 --- a/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_edit_server_account/CommunicationErrorView.mxml +++ b/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_edit_server_account/CommunicationErrorView.mxml @@ -51,9 +51,6 @@ .show(); } - public function additionalCloseHandler():void { - // nothing to do - } ]]> diff --git a/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_edit_server_account/EditServerAccountView.mxml b/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_edit_server_account/EditServerAccountView.mxml index 5b6c1ed0..8b7f5923 100644 --- a/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_edit_server_account/EditServerAccountView.mxml +++ b/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_edit_server_account/EditServerAccountView.mxml @@ -228,10 +228,6 @@ saveAccount(false, EDIT_ACCOUNT); } } - - public function additionalCloseHandler():void { - // nothing to do - } ]]> diff --git a/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_server_account/ServerAccountsView.mxml b/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_server_account/ServerAccountsView.mxml index 86c833d2..fbfc8cf2 100644 --- a/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_server_account/ServerAccountsView.mxml +++ b/org.flowerplatform.flex_client.host_app.mobile/src/org/flowerplatform/flex_client/host_app/mobile/view_server_account/ServerAccountsView.mxml @@ -111,10 +111,6 @@ public function closeView():void { FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(this); } - - public function additionalCloseHandler():void { - // nothing to do - } ]]> diff --git a/org.flowerplatform.flex_client.host_app/WebContent/main.jsp b/org.flowerplatform.flex_client.host_app/WebContent/main.jsp index de27a8ea..e5e7cb59 100644 --- a/org.flowerplatform.flex_client.host_app/WebContent/main.jsp +++ b/org.flowerplatform.flex_client.host_app/WebContent/main.jsp @@ -39,7 +39,7 @@ diff --git a/org.flowerplatform.flex_client.host_app/src/FlexHostApp.mxml b/org.flowerplatform.flex_client.host_app/src/FlexHostApp.mxml index 1a490f56..487d690f 100644 --- a/org.flowerplatform.flex_client.host_app/src/FlexHostApp.mxml +++ b/org.flowerplatform.flex_client.host_app/src/FlexHostApp.mxml @@ -21,7 +21,7 @@ license-end - @@ -48,6 +48,7 @@ license-end - - diff --git a/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/MindMapEditorDiagramShell.as b/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/MindMapEditorDiagramShell.as index dc29cd9f..e80b4df0 100644 --- a/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/MindMapEditorDiagramShell.as +++ b/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/MindMapEditorDiagramShell.as @@ -49,7 +49,6 @@ package org.flowerplatform.flex_client.mindmap { tools.push(InplaceEditorTool); } registerTools(tools); - } override public function getRootNodeX(context:DiagramShellContext, rootNode:Object):Number { diff --git a/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/action/AbstractEditNodePropertyInDialogAction.as b/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/action/AbstractEditNodePropertyInDialogAction.as index 8275aeb3..56b85d71 100644 --- a/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/action/AbstractEditNodePropertyInDialogAction.as +++ b/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/action/AbstractEditNodePropertyInDialogAction.as @@ -40,7 +40,8 @@ package org.flowerplatform.flex_client.mindmap.action { protected function editProperty(property:String, title:String):void { var selectedNode:Node = Node(selection.getItemAt(0)); - var richTextWithRendererView:RichTextWithRendererView = new RichTextWithRendererView(); + var richTextWithRendererView:RichTextWithRendererView = new RichTextWithRendererView(); + richTextWithRendererView.icon = icon; richTextWithRendererView.node = selectedNode; richTextWithRendererView.showRendererArea = false; richTextWithRendererView.text = selectedNode.properties[property]; @@ -58,7 +59,6 @@ package org.flowerplatform.flex_client.mindmap.action { .setViewContent(richTextWithRendererView) .setWidth(500) .setHeight(300) - .setIcon(icon) .show(); } diff --git a/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/renderer/NodeRenderer.mxml b/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/renderer/NodeRenderer.mxml index 3079a0a8..12540f81 100644 --- a/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/renderer/NodeRenderer.mxml +++ b/org.flowerplatform.flex_client.mindmap/src/org/flowerplatform/flex_client/mindmap/renderer/NodeRenderer.mxml @@ -6,11 +6,8 @@ diff --git a/org.flowerplatform.flex_client.properties/.actionScriptProperties b/org.flowerplatform.flex_client.properties/.actionScriptProperties index 9dcde00e..4ae0d400 100644 --- a/org.flowerplatform.flex_client.properties/.actionScriptProperties +++ b/org.flowerplatform.flex_client.properties/.actionScriptProperties @@ -1,5 +1,5 @@ - + diff --git a/org.flowerplatform.flex_client.properties/.flexLibProperties b/org.flowerplatform.flex_client.properties/.flexLibProperties index e2fb37ad..e4f19c76 100644 --- a/org.flowerplatform.flex_client.properties/.flexLibProperties +++ b/org.flowerplatform.flex_client.properties/.flexLibProperties @@ -1,11 +1,18 @@ - - + + + + + + + + + diff --git a/org.flowerplatform.flex_client.properties/public-resources/.gitignore b/org.flowerplatform.flex_client.properties/public-resources/.gitignore index 67e8ead1..8934b89f 100644 --- a/org.flowerplatform.flex_client.properties/public-resources/.gitignore +++ b/org.flowerplatform.flex_client.properties/public-resources/.gitignore @@ -1 +1,2 @@ /swc +/swc diff --git a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/CreateNodeView.mxml b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/CreateNodeView.mxml index 27ba60a6..8eb7c44c 100644 --- a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/CreateNodeView.mxml +++ b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/CreateNodeView.mxml @@ -2,20 +2,26 @@ - - + creationComplete="creationCompleteHandler(event)" + implements="org.flowerplatform.flexutil.view_content_host.IViewContent, mx.managers.IFocusManagerComponent"> + + + + { + return null; + } + + protected function okHandler(evt:MouseEvent = null):void { var propertiesToSetAfterAddingNode:ArrayList = new ArrayList(); var context:ServiceContext = new ServiceContext(); context.add("type", nodeType); @@ -143,17 +166,21 @@ }); } + protected function cancelHandler():void { + FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(this); + } + ]]> - + - - - - - + + + + + diff --git a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertiesPlugin.as b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertiesPlugin.as index 24b5491c..0da1a6ac 100644 --- a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertiesPlugin.as +++ b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertiesPlugin.as @@ -21,6 +21,7 @@ package org.flowerplatform.flex_client.properties { import org.flowerplatform.flexutil.FactoryWithInitialization; import org.flowerplatform.flexutil.FlexUtilGlobals; import org.flowerplatform.flexutil.Utils; + import org.flowerplatform.flexutil.controller.TypeDescriptorRegistry; /** * @author Razvan Tache @@ -32,6 +33,8 @@ package org.flowerplatform.flex_client.properties { public var propertyRendererClasses:Dictionary = new Dictionary(); public var currentSelection:IList; + + public var nodeTypeDescriptorRegistry:TypeDescriptorRegistry; public static function getInstance():PropertiesPlugin { return INSTANCE; @@ -44,10 +47,16 @@ package org.flowerplatform.flex_client.properties { } INSTANCE = this; + if (CorePlugin.getInstance() != null) { + nodeTypeDescriptorRegistry = CorePlugin.getInstance().nodeTypeDescriptorRegistry; + } + FlexUtilGlobals.getInstance().composedViewProvider.addViewProvider(new PropertiesViewProvider()); - CorePlugin.getInstance().editorClassFactoryActionProvider.addActionClass(ShowPropertiesAction); - CorePlugin.getInstance().getEditorClassFactoryActionProvider().addActionClass(NewComposedAction); + if (CorePlugin.getInstance() != null) { + CorePlugin.getInstance().editorClassFactoryActionProvider.addActionClass(ShowPropertiesAction); + CorePlugin.getInstance().getEditorClassFactoryActionProvider().addActionClass(NewComposedAction); + } } override public function start():void { diff --git a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertiesView.mxml b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertiesView.mxml index ef4e975e..a790dbe9 100644 --- a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertiesView.mxml +++ b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertiesView.mxml @@ -34,6 +34,10 @@ import org.flowerplatform.flexutil.view_content_host.IViewHost; protected var _viewHost:IViewHost; + + protected var _nodes:IList; + + protected var _commitEachPropertyAutomatically:Boolean = true; private var currentPropertyDescriptorsDisplayed:IList; @@ -67,8 +71,17 @@ public function getActions(selection:IList):Vector. { return null; } - - private function selectionChangedHandler(event:SelectionChangedEvent):void { + + public function set commitEachPropertyAutomatically(value:Boolean):void { + _commitEachPropertyAutomatically = value; + } + + public function get nodes():IList { + return _nodes; + } + + public function set nodes(nodeList:IList):void { + _nodes = nodeList; var i:int; // remove listeners from previous selection @@ -93,17 +106,17 @@ } (recycledRenderers[type] as Array).push(propertyItemRenderer); } - + label.text = ""; - - if (event.selection == null || event.selection.length == 0 || !(event.selection.getItemAt(0) is Node)) { // happens when changing active view + + if (nodeList == null || nodeList.length == 0 || !(nodeList.getItemAt(0) is Node)) { // happens when changing active view currentPropertyDescriptorsDisplayed = null; propertyForm.removeAllElements(); return; } // get new selected node - var node:Node = Node(event.selection.getItemAt(0)); + var node:Node = Node(nodeList.getItemAt(0)); if (node.parent == null && node.children == null) { // root node, don't populate with properties currentPropertyDescriptorsDisplayed = null; @@ -112,16 +125,16 @@ } // update label - var titleProvider:GenericValueProviderFromDescriptor = NodeControllerUtils.getTitleProvider(CorePlugin.getInstance().nodeTypeDescriptorRegistry, node); + /* var titleProvider:GenericValueProviderFromDescriptor = NodeControllerUtils.getTitleProvider(PropertiesPlugin.getInstance().nodeTypeDescriptorRegistry, node); label.text = String(titleProvider.getValue(node)); - label.maxWidth = UIComponent(this).width; - + label.maxWidth = UIComponent(this).width; */ + // store new selection - PropertiesPlugin.getInstance().currentSelection = new ArrayList(event.selection.toArray()); + PropertiesPlugin.getInstance().currentSelection = new ArrayList(nodeList.toArray()); // get properties to display - var newPropertyDescriptorsToDisplay:IList = CorePlugin.getInstance().nodeTypeDescriptorRegistry.getExpectedTypeDescriptor(node.type).getAdditiveControllers(PropertiesConstants.PROPERTY_DESCRIPTOR, node); - + var newPropertyDescriptorsToDisplay:IList = PropertiesPlugin.getInstance().nodeTypeDescriptorRegistry.getExpectedTypeDescriptor(node.type).getAdditiveControllers(PropertiesConstants.PROPERTY_DESCRIPTOR, node); + // if same descriptors -> no need to recalculate renderers, only set new node properties if (currentPropertyDescriptorsDisplayed != newPropertyDescriptorsToDisplay) { propertyForm.removeAllElements(); @@ -131,16 +144,16 @@ for (i = 0; i < newPropertyDescriptorsToDisplay.length; i++) { var propertyRenderer:PropertyItemRenderer; var propertyDescriptor:PropertyDescriptor = PropertyDescriptor(ObjectUtil.copy(newPropertyDescriptorsToDisplay.getItemAt(i))); - + if (propertyDescriptor.category != currentCategory) { // display category renderer var categoryItem:CategoryPropertyRenderer = new CategoryPropertyRenderer(); categoryItem.label = propertyDescriptor.category; propertyForm.addElement(categoryItem); - + currentCategory = propertyDescriptor.category; } - + var renderersToReuse:Array = recycledRenderers[propertyDescriptor.type] as Array; if (renderersToReuse != null && renderersToReuse.length > 0) { // there is already created a renderer for this type of property descriptor, reuse it @@ -151,6 +164,8 @@ } propertyForm.addElement(propertyRenderer); propertyRenderer.data = propertyDescriptor; + if (!_commitEachPropertyAutomatically) + propertyRenderer.node = nodes.getItemAt(0) as Node; } } @@ -159,7 +174,7 @@ // get values from node properties nodeUpdatedHandler(new NodeUpdatedEvent(node)); - + // add listeners to current selection var currentSelection:IList = PropertiesPlugin.getInstance().currentSelection; if (currentSelection != null) { @@ -168,6 +183,10 @@ } } } + + private function selectionChangedHandler(event:SelectionChangedEvent):void { + nodes = event.selection; + } private function nodeUpdatedHandler(event:NodeUpdatedEvent):void { var node:Node = event.node; @@ -189,10 +208,6 @@ } } - public function additionalCloseHandler():void { - // nothing to do - } - ]]> diff --git a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertyItemRenderer.mxml b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertyItemRenderer.mxml index 0a678d3f..f5770e6c 100644 --- a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertyItemRenderer.mxml +++ b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/PropertyItemRenderer.mxml @@ -12,6 +12,7 @@ import mx.core.UIComponent; import mx.events.FlexEvent; + import org.flowerplatform.flex_client.core.editor.remote.Node; import org.flowerplatform.flex_client.properties.property_renderer.BasicPropertyRenderer; import org.flowerplatform.flex_client.properties.remote.PropertyDescriptor; import org.flowerplatform.flexutil.FactoryWithInitialization; @@ -24,6 +25,10 @@ private var basicPropertyRenderer:BasicPropertyRenderer; + public function set node(_node:Node) { + basicPropertyRenderer._node = _node; + } + public function get data():Object { return _data; } diff --git a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/action/AddNodeAction.as b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/action/AddNodeAction.as index b3287af1..452a36dd 100644 --- a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/action/AddNodeAction.as +++ b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/action/AddNodeAction.as @@ -19,7 +19,6 @@ package org.flowerplatform.flex_client.properties.action { import mx.collections.IList; - import mx.utils.StringUtil; import org.flowerplatform.flex_client.core.CoreConstants; import org.flowerplatform.flex_client.core.CorePlugin; @@ -85,11 +84,8 @@ package org.flowerplatform.flex_client.properties.action { createNodeView.diagramShellContext = diagramShellContext; FlexUtilGlobals.getInstance().popupHandlerFactory.createPopupHandler() - .setTitle(Resources.getMessage("action.new.label", [label])) - .setIcon(Resources.addIcon) + .setTitle(Resources.getMessage("new.file.folder")) .setViewContent(createNodeView) - .setHeight(200) - .setWidth(400) .show(); } else { CorePlugin.getInstance().serviceLocator.invoke("nodeService.addChild", [parentNode.fullNodeId, context], diff --git a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/BasicPropertyRenderer.as b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/BasicPropertyRenderer.as index 639a9a73..b2859065 100644 --- a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/BasicPropertyRenderer.as +++ b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/BasicPropertyRenderer.as @@ -5,15 +5,15 @@ package org.flowerplatform.flex_client.properties.property_renderer { import mx.binding.utils.BindingUtils; - import spark.components.CheckBox; - import spark.components.DataRenderer; - import spark.layouts.HorizontalLayout; - import org.flowerplatform.flex_client.core.CorePlugin; import org.flowerplatform.flex_client.core.editor.remote.Node; import org.flowerplatform.flex_client.properties.PropertiesPlugin; import org.flowerplatform.flex_client.properties.remote.PropertyDescriptor; import org.flowerplatform.flex_client.resources.Resources; + + import spark.components.CheckBox; + import spark.components.DataRenderer; + import spark.layouts.HorizontalLayout; /** * @author Razvan Tache @@ -28,7 +28,9 @@ package org.flowerplatform.flex_client.properties.property_renderer { public var savePropertyEnabled:Boolean = true; public var changeCheckBox:CheckBox = new CheckBox(); - + + public var _node:Node; + public function BasicPropertyRenderer() { super(); layout = new HorizontalLayout; @@ -69,7 +71,11 @@ package org.flowerplatform.flex_client.properties.property_renderer { return true; } - protected function saveProperty():void { + protected function saveProperty():void { + if (_node != null) { + _node.properties[propertyDescriptor.name] = getValue(); + return; + } if (savePropertyEnabled && !propertyDescriptor.readOnly) { if (!validPropertyValue()) { return; diff --git a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/DatePropertyRenderer.as b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/DatePropertyRenderer.as index d2816660..1a104d6f 100644 --- a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/DatePropertyRenderer.as +++ b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/DatePropertyRenderer.as @@ -17,14 +17,12 @@ * license-end */ package org.flowerplatform.flex_client.properties.property_renderer { - import mx.binding.utils.BindingUtils; import mx.events.FlexEvent; import spark.formatters.DateTimeFormatter; /** * @author Sebastian Solomon - * @author Cristina Constantinescu */ public class DatePropertyRenderer extends StringPropertyRenderer { @@ -33,16 +31,11 @@ package org.flowerplatform.flex_client.properties.property_renderer { } override protected function creationCompleteHandler(event:FlexEvent):void { - BindingUtils.bindSetter(updateDate, data, "value"); - } - - private function updateDate(newValue:Object):void { - if (newValue is Date) { + if (data.value is Date) { var dtf:DateTimeFormatter = new DateTimeFormatter(); dtf.dateTimePattern = "yyyy-MM-dd HH:mm:ss"; - propertyValue.text = dtf.format(newValue); + propertyValue.text = dtf.format(data.value); } - } } diff --git a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/FileSizePropertyRenderer.mxml b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/FileSizePropertyRenderer.mxml index bfd254e0..7c4c7b6d 100644 --- a/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/FileSizePropertyRenderer.mxml +++ b/org.flowerplatform.flex_client.properties/src/org/flowerplatform/flex_client/properties/property_renderer/FileSizePropertyRenderer.mxml @@ -1,44 +1,39 @@ + xmlns:ns="org.flowerplatform.flex_client.properties.property_renderer.*" + creationComplete="creationCompleteHandler(event)"> - + + diff --git a/org.flowerplatform.flex_client.resources/.actionScriptProperties b/org.flowerplatform.flex_client.resources/.actionScriptProperties index d9e7e4c8..7140a28f 100644 --- a/org.flowerplatform.flex_client.resources/.actionScriptProperties +++ b/org.flowerplatform.flex_client.resources/.actionScriptProperties @@ -1,5 +1,5 @@ - + diff --git a/org.flowerplatform.flex_client.resources/.gitignore b/org.flowerplatform.flex_client.resources/.gitignore index 5e56e040..167fb2c0 100644 --- a/org.flowerplatform.flex_client.resources/.gitignore +++ b/org.flowerplatform.flex_client.resources/.gitignore @@ -1 +1,2 @@ /bin +/bin diff --git a/org.flowerplatform.flexdiagram/.actionScriptProperties b/org.flowerplatform.flexdiagram/.actionScriptProperties index 50d40e42..86d83608 100644 --- a/org.flowerplatform.flexdiagram/.actionScriptProperties +++ b/org.flowerplatform.flexdiagram/.actionScriptProperties @@ -1,6 +1,6 @@ - - + + @@ -21,6 +21,7 @@ + diff --git a/org.flowerplatform.flexdiagram/.gitignore b/org.flowerplatform.flexdiagram/.gitignore index 167fb2c0..bca9b393 100644 --- a/org.flowerplatform.flexdiagram/.gitignore +++ b/org.flowerplatform.flexdiagram/.gitignore @@ -1,2 +1,3 @@ /bin /bin +/bin diff --git a/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/controller/visual_children/AbsoluteLayoutVisualChildrenController.as b/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/controller/visual_children/AbsoluteLayoutVisualChildrenController.as index 458bb319..3a8245f0 100644 --- a/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/controller/visual_children/AbsoluteLayoutVisualChildrenController.as +++ b/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/controller/visual_children/AbsoluteLayoutVisualChildrenController.as @@ -59,11 +59,6 @@ package org.flowerplatform.flexdiagram.controller.visual_children { var scrollRect:Rectangle = IAbsoluteLayoutRenderer(parentRenderer).getViewportRect(); var noNeedToRefreshRect:Rectangle = IAbsoluteLayoutRenderer(parentRenderer).noNeedToRefreshRect; - - if (IVisualChildrenRefreshable(parentRenderer).shouldRefreshVisualChildren) { - refreshContentRect(context, parentModel); - } - if (!IVisualChildrenRefreshable(parentRenderer).shouldRefreshVisualChildren && noNeedToRefreshRect != null && noNeedToRefreshRect.containsRect(scrollRect)) { return; @@ -75,6 +70,13 @@ package org.flowerplatform.flexdiagram.controller.visual_children { var modelsToAdd:Vector. = new Vector.(); var visibleModelsCounter:int = 0; + // These values are computed based on the dimensions of all children + // (including those that are not displayed, because out of viewable area) + var horizontalScrollPositionMin:Number = int.MAX_VALUE; + var horizontalScrollPositionMax:Number = int.MIN_VALUE; + var verticalScrollPositionMin:Number = int.MAX_VALUE; + var verticalScrollPositionMax:Number = int.MIN_VALUE; + // These values are computed based on the children that are not visible var horizontalNoNeedToRefreshLeft:int = int.MIN_VALUE; var horizontalNoNeedToRefreshRight:int = int.MAX_VALUE; @@ -100,6 +102,20 @@ package org.flowerplatform.flexdiagram.controller.visual_children { // a child that participates to renderer recycling logic var crtRect:Rectangle = childAbsoluteLayoutRectangleController.getBounds(context, childModel); + // updates the new scroll bounds, based on the dimensions of the current child + if (crtRect.x + crtRect.width > horizontalScrollPositionMax) { + horizontalScrollPositionMax = crtRect.x + crtRect.width; + } + if (crtRect.x < horizontalScrollPositionMin) { + horizontalScrollPositionMin = crtRect.x; + } + if (crtRect.y + crtRect.height > verticalScrollPositionMax) { + verticalScrollPositionMax = crtRect.y + crtRect.height; + } + if (crtRect.y < verticalScrollPositionMin) { + verticalScrollPositionMin = crtRect.y; + } + if (scrollRect.intersects(crtRect)) { // the model should be visible visibleModelsCounter++; @@ -176,6 +192,14 @@ package org.flowerplatform.flexdiagram.controller.visual_children { // visualIndex ++; } } + + if (children.length == 0) { + horizontalScrollPositionMin = 0; + horizontalScrollPositionMax = 0; + verticalScrollPositionMin = 0; + verticalScrollPositionMax = 0; + } + IAbsoluteLayoutRenderer(parentRenderer).setContentRect(new Rectangle(horizontalScrollPositionMin, verticalScrollPositionMin, horizontalScrollPositionMax - horizontalScrollPositionMin, verticalScrollPositionMax - verticalScrollPositionMin)); var logTsModelIterationDone:Number = new Date().time; @@ -256,52 +280,6 @@ package org.flowerplatform.flexdiagram.controller.visual_children { ",newModels=" + logNewModels + ",renderersReused=" + logRenderersReused + ",reusableRenderersCreated=" + logReusableRenderersCreated + ",nonReusableRenderersCreated=" + logNonReusableRenderersCreated + ",reusableRenderersRemoved=" + logReusableRenderersRemoved); } - - public function refreshContentRect(context:DiagramShellContext, parentModel:Object):void { - var parentRenderer:IVisualElementContainer = IVisualElementContainer(ControllerUtils.getModelExtraInfoController(context, parentModel).getRenderer(context, context.diagramShell.modelToExtraInfoMap[parentModel])); - - var scrollRect:Rectangle = IAbsoluteLayoutRenderer(parentRenderer).getViewportRect(); - - // These values are computed based on the dimensions of all children - // (including those that are not displayed, because out of viewable area) - var horizontalScrollPositionMin:Number = int.MAX_VALUE; - var horizontalScrollPositionMax:Number = int.MIN_VALUE; - var verticalScrollPositionMin:Number = int.MAX_VALUE; - var verticalScrollPositionMax:Number = int.MIN_VALUE; - - var children:IList = ControllerUtils.getModelChildrenController(context, parentModel).getChildren(context, parentModel); - - for (var i:int = 0; i < children.length; i++) { - var childModel:Object = children.getItemAt(i); - var childAbsoluteLayoutRectangleController:AbsoluteLayoutRectangleController = ControllerUtils.getAbsoluteLayoutRectangleController(context, childModel); - if (childAbsoluteLayoutRectangleController != null) { - // a child that participates to renderer recycling logic - var crtRect:Rectangle = childAbsoluteLayoutRectangleController.getBounds(context, childModel); - - // updates the new scroll bounds, based on the dimensions of the current child - if (crtRect.x + crtRect.width > horizontalScrollPositionMax) { - horizontalScrollPositionMax = crtRect.x + crtRect.width; - } - if (crtRect.x < horizontalScrollPositionMin) { - horizontalScrollPositionMin = crtRect.x; - } - if (crtRect.y + crtRect.height > verticalScrollPositionMax) { - verticalScrollPositionMax = crtRect.y + crtRect.height; - } - if (crtRect.y < verticalScrollPositionMin) { - verticalScrollPositionMin = crtRect.y; - } - } - } - - if (children.length == 0) { - horizontalScrollPositionMin = 0; - horizontalScrollPositionMax = 0; - verticalScrollPositionMin = 0; - verticalScrollPositionMax = 0; - } - IAbsoluteLayoutRenderer(parentRenderer).setContentRect(new Rectangle(horizontalScrollPositionMin, verticalScrollPositionMin, horizontalScrollPositionMax - horizontalScrollPositionMin, verticalScrollPositionMax - verticalScrollPositionMin)); - } - } + } diff --git a/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/renderer/DiagramRenderer.as b/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/renderer/DiagramRenderer.as index ca5904f9..7b2b9dc2 100644 --- a/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/renderer/DiagramRenderer.as +++ b/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/renderer/DiagramRenderer.as @@ -31,8 +31,6 @@ package org.flowerplatform.flexdiagram.renderer { import org.flowerplatform.flexdiagram.util.RectangularGrid; import org.flowerplatform.flexdiagram.util.infinitegroup.InfiniteDataRenderer; - import spark.core.NavigationUnit; - /** * @author Cristian Spiescu */ @@ -59,11 +57,6 @@ package org.flowerplatform.flexdiagram.renderer { */ public var useGrid:Boolean = true; - /** - * @author Cristina Constantinescu - */ - public var verticalScrollBarStepSize:Number = 10; - public function get diagramShellContext():DiagramShellContext { return _context; } @@ -113,7 +106,7 @@ package org.flowerplatform.flexdiagram.renderer { return new Rectangle(horizontalScrollPosition - viewPortRectOffsetTowardOutside, verticalScrollPosition - viewPortRectOffsetTowardOutside, width + 2 * viewPortRectOffsetTowardOutside, height + 2 * viewPortRectOffsetTowardOutside); } - public function setContentRect(rect:Rectangle):void { + public function setContentRect(rect:Rectangle):void { contentRect = rect; } @@ -132,12 +125,13 @@ package org.flowerplatform.flexdiagram.renderer { super.updateDisplayList(unscaledWidth, unscaledHeight); - // draw a border around visible area + // draw a black border around visible area graphics.clear(); + graphics.lineStyle(1); graphics.beginFill(0xCCCCCC, 0); - graphics.drawRect(horizontalScrollPosition, verticalScrollPosition, width - 1, height - 1); + graphics.drawRect(horizontalScrollPosition, verticalScrollPosition, width - 1, height - 1); } - + /** * @author Cristina Constantinescu */ @@ -209,18 +203,6 @@ package org.flowerplatform.flexdiagram.renderer { } } } - - /** - * @author Cristina Constantinescu - */ - override public function getVerticalScrollPositionDelta(navigationUnit:uint):Number { - var n:Number = super.getVerticalScrollPositionDelta(navigationUnit); - if (navigationUnit == NavigationUnit.DOWN || navigationUnit == NavigationUnit.UP) { - return verticalScrollBarStepSize * n; - } - return n; - } - - + } } \ No newline at end of file diff --git a/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/util/infinitegroup/InfiniteScrollerLayout.as b/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/util/infinitegroup/InfiniteScrollerLayout.as index 1131360e..3246b7ad 100644 --- a/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/util/infinitegroup/InfiniteScrollerLayout.as +++ b/org.flowerplatform.flexdiagram/src/org/flowerplatform/flexdiagram/util/infinitegroup/InfiniteScrollerLayout.as @@ -716,12 +716,6 @@ package org.flowerplatform.flexdiagram.util.infinitegroup { } target.setContentSize(w, h); - - // draw scroller border - scroller.graphics.clear(); - scroller.graphics.lineStyle(1); - scroller.graphics.beginFill(0xCCCCCC, 0); - scroller.graphics.drawRect(0, 0, scroller.width, scroller.height); } } diff --git a/org.flowerplatform.flexutil.samples.web/src/org/flowerplatform/flexutil/samples/web/layout/NavigatorView.mxml b/org.flowerplatform.flexutil.samples.web/src/org/flowerplatform/flexutil/samples/web/layout/NavigatorView.mxml index 4e03054f..bad02f24 100644 --- a/org.flowerplatform.flexutil.samples.web/src/org/flowerplatform/flexutil/samples/web/layout/NavigatorView.mxml +++ b/org.flowerplatform.flexutil.samples.web/src/org/flowerplatform/flexutil/samples/web/layout/NavigatorView.mxml @@ -32,9 +32,6 @@ return new ArrayList(tree1.selectedItems); } - public function additionalCloseHandler():void { - // nothing to do - } ]]> diff --git a/org.flowerplatform.flexutil.samples.web/src/org/flowerplatform/flexutil/samples/web/layout/ViewDataGrid.mxml b/org.flowerplatform.flexutil.samples.web/src/org/flowerplatform/flexutil/samples/web/layout/ViewDataGrid.mxml index ae2b7933..6bc0f2d0 100644 --- a/org.flowerplatform.flexutil.samples.web/src/org/flowerplatform/flexutil/samples/web/layout/ViewDataGrid.mxml +++ b/org.flowerplatform.flexutil.samples.web/src/org/flowerplatform/flexutil/samples/web/layout/ViewDataGrid.mxml @@ -32,10 +32,6 @@ return new ArrayList(myDG.selectedItems); } - public function additionalCloseHandler():void { - // nothing to do - } - ]]> diff --git a/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/context_menu/ContextMenuSample.mxml b/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/context_menu/ContextMenuSample.mxml index 68625f67..6b2299cf 100644 --- a/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/context_menu/ContextMenuSample.mxml +++ b/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/context_menu/ContextMenuSample.mxml @@ -69,10 +69,6 @@ FlexUtilGlobals.getInstance().selectionManager.selectionChanged(viewHost, this); } - public function additionalCloseHandler():void { - // nothing to do - } - ]]> diff --git a/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/global_menu/GlobalMenuSample.mxml b/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/global_menu/GlobalMenuSample.mxml index 7c682340..81dad0b7 100644 --- a/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/global_menu/GlobalMenuSample.mxml +++ b/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/global_menu/GlobalMenuSample.mxml @@ -69,6 +69,12 @@ license-end action.parentId = "secondaction"; action.icon = MultipleIconItemRendererSample.defaultImage; actionProvider.getActions(null).push(action); + + // create a separator. + action = new SampleActionGlobalMenu1(); + action.label = GlobalMenuBar.MENU_LABEL_SEPARATOR; + action.parentId = "secondaction"; + actionProvider.getActions(null).push(action); action = new SampleActionGlobalMenu1(); action.label = "Third SubAction"; diff --git a/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/spinner/RemoveGlobalSpinnerViewContent.mxml b/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/spinner/RemoveGlobalSpinnerViewContent.mxml index d740d662..aaa17ee9 100644 --- a/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/spinner/RemoveGlobalSpinnerViewContent.mxml +++ b/org.flowerplatform.flexutil.samples/src/org/flowerplatform/flexutil/samples/spinner/RemoveGlobalSpinnerViewContent.mxml @@ -25,9 +25,6 @@ FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(this); } - public function additionalCloseHandler():void { - // nothing to do - } ]]> diff --git a/org.flowerplatform.flexutil/.actionScriptProperties b/org.flowerplatform.flexutil/.actionScriptProperties index 684e7b0b..fd6e2747 100644 --- a/org.flowerplatform.flexutil/.actionScriptProperties +++ b/org.flowerplatform.flexutil/.actionScriptProperties @@ -1,6 +1,6 @@ - - + + @@ -22,6 +22,7 @@ + diff --git a/org.flowerplatform.flexutil/.flexLibProperties b/org.flowerplatform.flexutil/.flexLibProperties index 6c3f8f63..6a8aed82 100644 --- a/org.flowerplatform.flexutil/.flexLibProperties +++ b/org.flowerplatform.flexutil/.flexLibProperties @@ -31,7 +31,6 @@ - diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/FlexUtilConstants.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/FlexUtilConstants.as index 44d0003e..b38ba105 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/FlexUtilConstants.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/FlexUtilConstants.as @@ -9,10 +9,5 @@ package org.flowerplatform.flexutil { public static const CATEGORY_PREFIX:String = "category."; public static const CATEGORY_ALL:String = CATEGORY_PREFIX + "all"; - public static const CONTROL:String = "CONTROL"; - public static const COMMAND:String = "COMMAND"; - public static const SHIFT:String = "SHIFT"; - public static const ALTERNATE:String = "ALTERNATE"; - } } \ No newline at end of file diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/FlexUtilGlobals.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/FlexUtilGlobals.as index 824a63e1..4d01c4c3 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/FlexUtilGlobals.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/FlexUtilGlobals.as @@ -19,7 +19,8 @@ package org.flowerplatform.flexutil { import mx.utils.LoaderUtil; - import org.flowerplatform.flexutil.action.ActionHelper; + import spark.core.ContentCache; + import org.flowerplatform.flexutil.context_menu.ContextMenuManager; import org.flowerplatform.flexutil.layout.ComposedViewProvider; import org.flowerplatform.flexutil.layout.IWorkbench; @@ -29,8 +30,6 @@ package org.flowerplatform.flexutil { import org.flowerplatform.flexutil.popup.IProgressMonitorFactory; import org.flowerplatform.flexutil.selection.SelectionManager; import org.flowerplatform.flexutil.shortcut.KeyBindings; - - import spark.core.ContentCache; public class FlexUtilGlobals { @@ -79,11 +78,6 @@ package org.flowerplatform.flexutil { public var flexPluginManager:FlexPluginManager = new FlexPluginManager(); - /** - * @author Cristina Contantinescu - */ - public var actionHelper:ActionHelper = new ActionHelper(); - /** * @author Cristina Contantinescu */ diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/action/ActionHelper.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/action/ActionUtil.as similarity index 82% rename from org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/action/ActionHelper.as rename to org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/action/ActionUtil.as index 48eafd22..de423fc9 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/action/ActionHelper.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/action/ActionUtil.as @@ -24,7 +24,7 @@ package org.flowerplatform.flexutil.action { /** * @author Cristian Spiescu */ - public class ActionHelper { + public class ActionUtil { /** * Selects all the visible actions from the actions list, for a give @@ -34,7 +34,7 @@ package org.flowerplatform.flexutil.action { * @author Cristian Spiescu * @author Cristina Constantinescu */ - public function processAndIterateActions(parentActionId:String, actions:Vector., selection:IList, context:Object, forEachCallbackObject:Object, forEachCallbackFunction:Function):void { + public static function processAndIterateActions(parentActionId:String, actions:Vector., selection:IList, context:Object, forEachCallbackObject:Object, forEachCallbackFunction:Function):void { if (actions == null) { return; } @@ -91,7 +91,7 @@ package org.flowerplatform.flexutil.action { * Note: this way, multi level actions visibility is calculated correctly. * @author Cristina Constantinescu */ - private function setChildActionsForActionIfNecessary(parentActionIdToActions:Dictionary, action:IAction):void { + private static function setChildActionsForActionIfNecessary(parentActionIdToActions:Dictionary, action:IAction):void { if (!isComposedAction(action)) { return; } @@ -103,19 +103,8 @@ package org.flowerplatform.flexutil.action { } } - public function isComposedAction(action:IAction):Boolean { + public static function isComposedAction(action:IAction):Boolean { return action is IComposedAction && !IComposedAction(action).actAsNormalAction; } - - public function runAction(action:IAction, selection:IList, context:Object):void { - try { - action.selection = selection; - action.context = context; - action.run(); - } finally { - action.selection = null; - action.context = null; - } - } } } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/action/ComposedAction.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/action/ComposedAction.as index 2f124727..a659f716 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/action/ComposedAction.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/action/ComposedAction.as @@ -17,7 +17,6 @@ * license-end */ package org.flowerplatform.flexutil.action { - import org.flowerplatform.flexutil.FlexUtilGlobals; /** * @see IComposedAction @@ -76,8 +75,16 @@ package org.flowerplatform.flexutil.action { override public function run():void { if (delegateIfSingleChild) { var visibleChildActions:Array = getVisibleChildActions(); - if (visibleChildActions.length == 1) { - FlexUtilGlobals.getInstance().actionHelper.runAction(visibleChildActions[0], selection, context); + if (visibleChildActions.length == 1) { + var singleVisibleChildAction:IAction = visibleChildActions[0]; + try { + singleVisibleChildAction.selection = selection; + singleVisibleChildAction.context = context; + singleVisibleChildAction.run(); + } finally { + singleVisibleChildAction.selection = null; + singleVisibleChildAction.context = null; + } return; } } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/content_assist/SearchView.mxml b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/content_assist/SearchView.mxml index 43788e57..6008f437 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/content_assist/SearchView.mxml +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/content_assist/SearchView.mxml @@ -167,9 +167,6 @@ license-end FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(this); } - public function additionalCloseHandler():void { - } - ]]> diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenu.mxml b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenu.mxml index 223e8d93..7c777dd0 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenu.mxml +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenu.mxml @@ -36,7 +36,7 @@ The graphical component that displays a list of actions, for one level. import mx.core.FlexGlobals; import mx.managers.PopUpManager; - import org.flowerplatform.flexutil.FlexUtilGlobals; + import org.flowerplatform.flexutil.action.ActionUtil; import org.flowerplatform.flexutil.action.IAction; import org.flowerplatform.flexutil.action.IComposedAction; import org.flowerplatform.flexutil.action.MenuClosedEvent; @@ -61,7 +61,7 @@ The graphical component that displays a list of actions, for one level. actions = actionsForCurrentLevelAreadyCalculated; } else { actions = new ArrayList(); - FlexUtilGlobals.getInstance().actionHelper.processAndIterateActions(parentActionId, contextMenuManager.allActions, contextMenuManager.selection, contextMenuManager.context, this, function (action:IAction):void { + ActionUtil.processAndIterateActions(parentActionId, contextMenuManager.allActions, contextMenuManager.selection, contextMenuManager.context, this, function (action:IAction):void { actions.addItem(action); }); } @@ -140,7 +140,7 @@ The graphical component that displays a list of actions, for one level. */ protected function listSelectionChangeHandler(event:IndexChangeEvent):void { closeContextMenuStack(indexInStack + 1); - if (FlexUtilGlobals.getInstance().actionHelper.isComposedAction(IAction(list.selectedItem))) { + if (ActionUtil.isComposedAction(IAction(list.selectedItem))) { new org.flowerplatform.flexutil.context_menu.ContextMenu().openContextMenu( contextMenuManager, x + width + GAP_BETWEEN_MENUS, diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenuItemRenderer.mxml b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenuItemRenderer.mxml index a423ed1e..812f1af6 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenuItemRenderer.mxml +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenuItemRenderer.mxml @@ -33,6 +33,7 @@ import org.flowerplatform.flexutil.FlexUtilAssets; import org.flowerplatform.flexutil.FlexUtilGlobals; + import org.flowerplatform.flexutil.action.ActionUtil; import org.flowerplatform.flexutil.action.IAction; import org.flowerplatform.flexutil.shortcut.AssignShortcutForActionEvent; import org.flowerplatform.flexutil.shortcut.Shortcut; @@ -50,7 +51,7 @@ // I do it here instead of binding, to avoid the runtime warning "cannot bind to..." labelComponent.text = IAction(value).label; iconComponent.source = IAction(value).icon; - if (FlexUtilGlobals.getInstance().actionHelper.isComposedAction(IAction(value))) { + if (ActionUtil.isComposedAction(IAction(value))) { if (!hasSubActions.visible) { hasSubActions.visible = true; hasSubActions.includeInLayout = true; @@ -79,7 +80,7 @@ } protected function clickHandler(event:MouseEvent):void { - if (!FlexUtilGlobals.getInstance().actionHelper.isComposedAction(IAction(data))) { + if (!ActionUtil.isComposedAction(IAction(data))) { if (FlexUtilGlobals.getInstance().keyBindings.learnShortcutOnNextActionInvocation) { // learning state -> just send event to notify listeners try { UIComponent(FlexGlobals.topLevelApplication).stage.dispatchEvent(new AssignShortcutForActionEvent(IAction(data).id)); @@ -89,8 +90,12 @@ } else { var contextMenu:org.flowerplatform.flexutil.context_menu.ContextMenu = getContextMenu(); try { - FlexUtilGlobals.getInstance().actionHelper.runAction(IAction(data), contextMenu.contextMenuManager.selection, contextMenu.contextMenuManager.context); - } finally { + IAction(data).selection = contextMenu.contextMenuManager.selection; + IAction(data).context = contextMenu.contextMenuManager.context; + IAction(data).run(); + } finally { + IAction(data).selection = null; + IAction(data).context = null; contextMenu.closeContextMenuStack(0); } } @@ -117,7 +122,7 @@ executeAftedHoverTimer.repeatCount = 1; executeAftedHoverTimer.addEventListener(TimerEvent.TIMER_COMPLETE, executeAftedHoverTimerHandler); } - if (FlexUtilGlobals.getInstance().actionHelper.isComposedAction(IAction(data))) { + if (ActionUtil.isComposedAction(IAction(data))) { executeAftedHoverTimer.delay = HOVER_DELAY_COMPOSED_ACTION; } else { executeAftedHoverTimer.delay = HOVER_DELAY_NORMAL_ACTION; @@ -136,7 +141,7 @@ return; } var contextMenu:org.flowerplatform.flexutil.context_menu.ContextMenu = getContextMenu(); - if (FlexUtilGlobals.getInstance().actionHelper.isComposedAction(IAction(data))) { + if (ActionUtil.isComposedAction(IAction(data))) { contextMenu.list.setSelectedIndex(contextMenu.actions.getItemIndex(data), true); } else { contextMenu.list.setSelectedIndex(-1, true); @@ -150,6 +155,6 @@ - + diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenuManager.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenuManager.as index a0e44869..49377f5b 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenuManager.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/context_menu/ContextMenuManager.as @@ -20,9 +20,12 @@ package org.flowerplatform.flexutil.context_menu { import flash.display.DisplayObject; import flash.events.MouseEvent; + import mx.collections.ArrayList; import mx.collections.IList; import mx.core.FlexGlobals; + import mx.managers.PopUpManager; + import org.flowerplatform.flexutil.action.ActionUtil; import org.flowerplatform.flexutil.action.IAction; /** diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/controller/TypeDescriptorRegistry.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/controller/TypeDescriptorRegistry.as index b0cbe0ac..1d0691a2 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/controller/TypeDescriptorRegistry.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/controller/TypeDescriptorRegistry.as @@ -1,6 +1,7 @@ package org.flowerplatform.flexutil.controller { import flash.utils.Dictionary; + import mx.collections.ArrayCollection; import mx.collections.IList; import mx.core.mx_internal; @@ -73,6 +74,37 @@ package org.flowerplatform.flexutil.controller { getDynamicCategoryProviders().addItem(provider); } + public function addTypeDescriptorsRemote(typeDescriptorRemoteList:ArrayCollection): void { + for (var i:int = 0; i < typeDescriptorRemoteList.length; i++) { + var remote:TypeDescriptorRemote = TypeDescriptorRemote(typeDescriptorRemoteList.getItemAt(i)); + + // create new type descriptor with remote type + var descriptor:TypeDescriptor = null; + if (Utils.beginsWith(remote.type, FlexUtilConstants.CATEGORY_PREFIX)) { + descriptor = this.getOrCreateCategoryTypeDescriptor(remote.type); + } else { + descriptor = this.getOrCreateTypeDescriptor(remote.type); + } + + // add static categories + for each (var category:String in remote.categories) { + descriptor.addCategory(category); + } + + // add single controllers + for (var singleControllerType:String in remote.singleControllers) { + descriptor.addSingleController(singleControllerType, remote.singleControllers[singleControllerType]); + } + + // add additive controllers + for (var additiveControllerType:String in remote.additiveControllers) { + for each (var additiveController:AbstractController in remote.additiveControllers[additiveControllerType]) { + descriptor.addAdditiveController(additiveControllerType, additiveController); + } + } + } + } + public function TypeDescriptorRegistry() { super(); addDynamicCategoryProvider(new AllDynamicCategoryProvider()); diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/global_menu/GlobalMenuBar.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/global_menu/GlobalMenuBar.as index 80d837fc..3a4f3642 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/global_menu/GlobalMenuBar.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/global_menu/GlobalMenuBar.as @@ -19,6 +19,7 @@ package org.flowerplatform.flexutil.global_menu { import flash.display.DisplayObject; import flash.events.Event; + import flash.events.EventDispatcher; import flash.events.IEventDispatcher; import flash.events.KeyboardEvent; import flash.geom.Point; @@ -38,9 +39,11 @@ package org.flowerplatform.flexutil.global_menu { import mx.core.LayoutDirection; import mx.events.MenuEvent; import mx.events.PropertyChangeEvent; + import mx.events.PropertyChangeEventKind; import mx.managers.ISystemManager; import org.flowerplatform.flexutil.FlexUtilGlobals; + import org.flowerplatform.flexutil.action.ActionUtil; import org.flowerplatform.flexutil.action.IAction; import org.flowerplatform.flexutil.action.IActionProvider; import org.flowerplatform.flexutil.selection.SelectionChangedEvent; @@ -74,6 +77,11 @@ package org.flowerplatform.flexutil.global_menu { */ protected var menuItemRender:IFactory; + /** + * Label for the action to be considered as separator + */ + public static const MENU_LABEL_SEPARATOR:String = "--"; + public function GlobalMenuBar(ap:IActionProvider = null):void { super(); @@ -184,7 +192,7 @@ package org.flowerplatform.flexutil.global_menu { if (actionProvider != null) { var listActions:ArrayCollection = new ArrayCollection(); - FlexUtilGlobals.getInstance().actionHelper.processAndIterateActions(parentId, + ActionUtil.processAndIterateActions(parentId, actionProvider.getActions(selection), selection, null, @@ -236,7 +244,7 @@ package org.flowerplatform.flexutil.global_menu { var menuBarAction:IAction = item.data as IAction; // Only a composed action can have children - if (FlexUtilGlobals.getInstance().actionHelper.isComposedAction(menuBarAction)) { + if (ActionUtil.isComposedAction(menuBarAction)) { // get the current selection var selection:IList = null; if (FlexUtilGlobals.getInstance().selectionManager.activeSelectionProvider != null) { @@ -390,7 +398,7 @@ package org.flowerplatform.flexutil.global_menu { // dont notify parent if RIGHT and we are on an expandable menu // so that the menu has a chance to expand itself if (!(keyCode == Keyboard.RIGHT - && FlexUtilGlobals.getInstance().actionHelper.isComposedAction(IAction(Menu(event.target).selectedItem)))) { + && ActionUtil.isComposedAction(IAction(Menu(event.target).selectedItem)))) { dispatchEvent(event); } } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/global_menu/GlobalMenuDataDescriptor.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/global_menu/GlobalMenuDataDescriptor.as index cdd5c623..7656624f 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/global_menu/GlobalMenuDataDescriptor.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/global_menu/GlobalMenuDataDescriptor.as @@ -22,7 +22,7 @@ package org.flowerplatform.flexutil.global_menu { import mx.collections.IList; import mx.controls.menuClasses.IMenuDataDescriptor; - import org.flowerplatform.flexutil.FlexUtilGlobals; + import org.flowerplatform.flexutil.action.ActionUtil; import org.flowerplatform.flexutil.action.IAction; import org.flowerplatform.flexutil.action.IActionProvider; @@ -87,7 +87,7 @@ package org.flowerplatform.flexutil.global_menu { var children:ArrayCollection = new ArrayCollection(); - FlexUtilGlobals.getInstance().actionHelper.processAndIterateActions(id, + ActionUtil.processAndIterateActions(id, actionProvider.getActions(selection), selection, null, @@ -113,7 +113,7 @@ package org.flowerplatform.flexutil.global_menu { */ public function hasChildren(node:Object, model:Object=null):Boolean { if (node is IAction) { - return (FlexUtilGlobals.getInstance().actionHelper.isComposedAction(IAction(node))); + return (ActionUtil.isComposedAction(IAction(node))); } return false; } @@ -127,15 +127,20 @@ package org.flowerplatform.flexutil.global_menu { */ public function isBranch(node:Object, model:Object=null):Boolean { if (node is IAction) { - return (FlexUtilGlobals.getInstance().actionHelper.isComposedAction(IAction(node))); + return (ActionUtil.isComposedAction(IAction(node))); } return false; } /** - * Normal menu (other possible types: separator, check or radio) + * Menu type (possible values: normal, separator, check or radio) */ public function getType(node:Object):String { + if (node is IAction) { + if (IAction(node).label == GlobalMenuBar.MENU_LABEL_SEPARATOR) { + return "separator"; + } + } return "normal"; } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/layout/event/ViewRemovedEvent.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/layout/event/ViewRemovedEvent.as index 3488c40e..afc59f3e 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/layout/event/ViewRemovedEvent.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/layout/event/ViewRemovedEvent.as @@ -32,15 +32,12 @@ package org.flowerplatform.flexutil.layout.event { public static const VIEW_REMOVED:String = "view_removed"; - public var canRemoveView:Boolean; - - public var canPreventDefault:Boolean; + public var dontRemoveView:Boolean; public function ViewRemovedEvent() { super(VIEW_REMOVED); - canRemoveView = true; - canPreventDefault = true; + dontRemoveView = false; } } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/layout/event/ViewsRemovedEvent.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/layout/event/ViewsRemovedEvent.as index 2f2ed076..8db68bb8 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/layout/event/ViewsRemovedEvent.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/layout/event/ViewsRemovedEvent.as @@ -35,14 +35,11 @@ package org.flowerplatform.flexutil.layout.event public var dontRemoveViews:ArrayCollection; /* of UIComponent */ - public var canPreventDefault:Boolean; - public function ViewsRemovedEvent(removedViews:ArrayCollection) { super(VIEWS_REMOVED); _removedViews = removedViews; dontRemoveViews = new ArrayCollection(); - canPreventDefault = true; } /** diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostBase.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostBase.as index b6059739..bff92a04 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostBase.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostBase.as @@ -26,6 +26,7 @@ package org.flowerplatform.flexutil.mobile.view_content_host { import mx.events.FlexEvent; import org.flowerplatform.flexutil.FlexUtilGlobals; + import org.flowerplatform.flexutil.action.ActionUtil; import org.flowerplatform.flexutil.action.IAction; import org.flowerplatform.flexutil.action.MenuClosedEvent; import org.flowerplatform.flexutil.mobile.spinner.MobileSpinner; @@ -37,6 +38,7 @@ package org.flowerplatform.flexutil.mobile.view_content_host { import spark.components.Label; import spark.components.View; import spark.components.ViewMenuItem; + import spark.components.ViewNavigator; import spark.components.supportClasses.ButtonBase; import spark.events.ViewNavigatorEvent; import spark.primitives.BitmapImage; @@ -235,7 +237,7 @@ package org.flowerplatform.flexutil.mobile.view_content_host { protected function populateViewWithActions(parentActionId:String = null):void { var newActionContent:Array = new Array(); var newViewMenuItems:Vector. = new Vector.(); - FlexUtilGlobals.getInstance().actionHelper.processAndIterateActions(parentActionId, allActionsForActiveViewContent, selectionForActiveViewContent, contextForActions, this, function (action:IAction):void { + ActionUtil.processAndIterateActions(parentActionId, allActionsForActiveViewContent, selectionForActiveViewContent, contextForActions, this, function (action:IAction):void { if (action.preferShowOnActionBar) { var button:ActionButton = new ActionButton(); populateButtonWithAction(button, action); @@ -260,7 +262,7 @@ package org.flowerplatform.flexutil.mobile.view_content_host { * The click handler for ActionButton and ActionViewMenuItem. */ public function actionClickHandler(action:IAction):void { - if (FlexUtilGlobals.getInstance().actionHelper.isComposedAction(action)) { + if (ActionUtil.isComposedAction(action)) { var runnable:Function = function (event:Event):void { removeEventListener("viewMenuClose", runnable); @@ -286,7 +288,14 @@ package org.flowerplatform.flexutil.mobile.view_content_host { runnable.call(null, null); } } else { - FlexUtilGlobals.getInstance().actionHelper.runAction(action, selectionForActiveViewContent, contextForActions); + try { + action.selection = selectionForActiveViewContent; + action.context = contextForActions; + action.run(); + } finally { + action.selection = null; + action.context = contextForActions; + } } } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostPopupHandler.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostPopupHandler.as index d7766686..4842d254 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostPopupHandler.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostPopupHandler.as @@ -42,10 +42,6 @@ package org.flowerplatform.flexutil.mobile.view_content_host { return this; } - public function setIcon(value:Object):IPopupHandler { - return this; - } - public function setWidth(value:Number):IPopupHandler { return this; } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostPopupHandlerFactory.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostPopupHandlerFactory.as index 2dbcd226..aafb216b 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostPopupHandlerFactory.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/MobileViewHostPopupHandlerFactory.as @@ -22,7 +22,6 @@ package org.flowerplatform.flexutil.mobile.view_content_host { import org.flowerplatform.flexutil.popup.IPopupHandler; import org.flowerplatform.flexutil.popup.IPopupHandlerFactory; - import org.flowerplatform.flexutil.view_content_host.IViewContent; import spark.components.Scroller; import spark.components.View; @@ -39,9 +38,6 @@ package org.flowerplatform.flexutil.mobile.view_content_host { var view:View = View(viewNavigator.activeView); // for MindMapIconsBar, because of the skin, (viewport != viewContent) if (view is MobileViewHost && view.numElements > 0 && (Scroller(view.getElementAt(0)).viewport == viewContent || Scroller(view.getElementAt(0)).viewport == viewContent.parent)) { - if (viewContent is IViewContent) { - IViewContent(viewContent).additionalCloseHandler(); - } viewNavigator.popView(); } } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/ProgressMonitorSpinner.mxml b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/ProgressMonitorSpinner.mxml index 48000d94..4f99ca9f 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/ProgressMonitorSpinner.mxml +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/mobile/view_content_host/ProgressMonitorSpinner.mxml @@ -111,8 +111,6 @@ return null; } - public function additionalCloseHandler():void { - } ]]> diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/plugin/FlexPluginLoadingSession.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/plugin/FlexPluginLoadingSession.as index 1b84d9e5..a738fecb 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/plugin/FlexPluginLoadingSession.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/plugin/FlexPluginLoadingSession.as @@ -243,16 +243,18 @@ package org.flowerplatform.flexutil.plugin { // setup extension points for each (var descriptor:FlexPluginDescriptor in descriptors) { if (descriptor.errorObject == null) { - try { - var className:String = getClassNameForFlexPluginEntry(descriptor.url); - var clazz:Class = Class(getDefinitionByName(className)); - descriptor.flexPlugin = new clazz(); - descriptor.flexPlugin.flexPluginDescriptor = descriptor; - descriptor.flexPlugin.preStart(); - - flexPluginManager.flexPluginEntries.addItem(descriptor); - } catch (e:Object) { - descriptor.errorObject = e; + if (getStartPlugin(descriptor.url)) { + try { + var className:String = getClassNameForFlexPluginEntry(descriptor.url); + var clazz:Class = Class(getDefinitionByName(className)); + descriptor.flexPlugin = new clazz(); + descriptor.flexPlugin.flexPluginDescriptor = descriptor; + descriptor.flexPlugin.preStart(); + + flexPluginManager.flexPluginEntries.addItem(descriptor); + } catch (e:Object) { + descriptor.errorObject = e; + } } } @@ -261,12 +263,14 @@ package org.flowerplatform.flexutil.plugin { // start plugins for each (descriptor in descriptors) { if (descriptor.errorObject == null) { - try { - className = getClassNameForFlexPluginEntry(descriptor.url); - clazz = Class(getDefinitionByName(className)); - descriptor.flexPlugin.start(); - } catch (e:Object) { - descriptor.errorObject = e; + if (getStartPlugin(descriptor.url)) { + try { + className = getClassNameForFlexPluginEntry(descriptor.url); + clazz = Class(getDefinitionByName(className)); + descriptor.flexPlugin.start(); + } catch (e:Object) { + descriptor.errorObject = e; + } } } @@ -307,6 +311,15 @@ package org.flowerplatform.flexutil.plugin { } } + protected function getStartPlugin(url:String):Boolean { + var startPluginRegEx:RegExp = new RegExp("[\\?&]startPlugin=(.*?)[\\z|&]"); + var startPluginRegExGroups:Array = startPluginRegEx.exec(url); + if (startPluginRegExGroups != null && startPluginRegExGroups.length == 2 && startPluginRegExGroups[1] == "false") { + return false; + } + return true; + } + protected function handlePluginsWithErrors(failedEntries:ArrayCollection):void { var text:String = ""; for each (var entry:FlexPluginDescriptor in failedEntries) { diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/plugin/FlexPluginManager.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/plugin/FlexPluginManager.as index 05b23d35..420d1961 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/plugin/FlexPluginManager.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/plugin/FlexPluginManager.as @@ -44,7 +44,7 @@ package org.flowerplatform.flexutil.plugin { currentLoadingSession = createLoadingSession(); currentLoadingSession.loadPlugins(pluginSwcUrls, callbackFunction, callbackObject); } - + /** * Append "version=..." to list of url's parameters. * @author Cristina Constantinescu diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/AlertPopup.mxml b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/AlertPopup.mxml index 86c84f5f..2ac007c8 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/AlertPopup.mxml +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/AlertPopup.mxml @@ -33,22 +33,20 @@ { return new Vector.(); } @@ -122,11 +118,6 @@ return this; } - public function setIcon(value:Object):IMessageBox { - _icon = value; - return this; - } - public function setWidth(value:int):IMessageBox { width = value; return this; @@ -135,7 +126,7 @@ /** * @author Cristina Constantinescu */ - public function addButton(title:String, handler:Function = null, useHandlerAtClosing:Boolean = false):IMessageBox { + public function addButton(title:String, handler:Function = null):IMessageBox { var newBtn:Button = new Button(); newBtn.label = title; @@ -148,10 +139,6 @@ } ); buttons.addItem(newBtn); - - if (useHandlerAtClosing) { - additionalHandlerToBeExecutedAtClosing = handler; - } return this; } @@ -190,7 +177,6 @@ FlexUtilGlobals.getInstance().popupHandlerFactory.createPopupHandler() .setViewContent(this) .setTitle(_title) - .setIcon(_icon) .setWidth(width) .setHeight(height) .show(modal); @@ -210,11 +196,6 @@ } } - public function additionalCloseHandler():void { - if (additionalHandlerToBeExecutedAtClosing != null) { - additionalHandlerToBeExecutedAtClosing(); - } - } ]]> diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/IMessageBox.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/IMessageBox.as index 62dcc442..b098b151 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/IMessageBox.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/IMessageBox.as @@ -19,7 +19,6 @@ package org.flowerplatform.flexutil.popup { public interface IMessageBox { function setTitle(value:String):IMessageBox; - function setIcon(value:Object):IMessageBox; function setText(value:String):IMessageBox; function setWidth(value:int):IMessageBox; function setHeight(value:int):IMessageBox; @@ -28,9 +27,9 @@ package org.flowerplatform.flexutil.popup { /** * @author Cristina Constantinescu */ - function addButton(title:String, handler:Function = null, useHandlerAtClosing:Boolean = false):IMessageBox; + function addButton(title:String, handler:Function = null):IMessageBox; function setSelectText(value:Boolean):IMessageBox; - function showMessageBox(modal:Boolean = true):void; + function showMessageBox(modal:Boolean = true):void; } } \ No newline at end of file diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/IPopupHandler.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/IPopupHandler.as index cc5b08b4..0f5e5152 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/IPopupHandler.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/IPopupHandler.as @@ -27,7 +27,6 @@ package org.flowerplatform.flexutil.popup { public interface IPopupHandler { function setTitle(value:String):IPopupHandler; - function setIcon(value:Object):IPopupHandler; /** * value is Number because we want to use the NaN in case width/height isn't set. diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/Wizard.mxml b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/Wizard.mxml index 11ead3dc..375e78aa 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/Wizard.mxml +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/popup/Wizard.mxml @@ -271,9 +271,6 @@ _viewHost = value; } - public function additionalCloseHandler():void { - } - ]]> diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/selection/SelectionManager.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/selection/SelectionManager.as index 43b762c1..f5546ca0 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/selection/SelectionManager.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/selection/SelectionManager.as @@ -88,9 +88,6 @@ package org.flowerplatform.flexutil.selection { * in handler, and the second via the selection changed handler. In this case, we want to optimize, and have only * one processing for the selection/actions. However, there are cases, when clicking on a VH doesn't trigger the * selection changed listener; so we need the focus in mechanism as well. - * - * @author Cristian Spiescu - * @author Cristina Constantinescu */ public function selectionChanged(viewHost:IViewHost, selectionProvider:IViewContent):void { if (timerAfterFocusIn.running) { @@ -105,22 +102,19 @@ package org.flowerplatform.flexutil.selection { var selection:IList = viewHost.selectionChanged(); } - var event:SelectionChangedEvent = new SelectionChangedEvent(); if (selectionProvider != null && activeSelectionProvider == selectionProvider) { // this "if" is intended for a case like the following: there are 2 ViewContent/SelectionProviders; // the user clicks on VC1 and selects/deselects. So VC1 is the activeSelectionProvider. // Meanwhile, the selection is changed programmatically in VC2. In this case, we don't need to dispatch, - // because the "global" selection still comes from VC1 + // because the "global" selection still comes from VC1 + var event:SelectionChangedEvent = new SelectionChangedEvent(); event.selectionProvider = activeSelectionProvider; event.selection = selection; if (selectionProvider is ISelectionForServerProvider) { event.selectionForServer = ISelectionForServerProvider(selectionProvider).convertSelectionToSelectionForServer(selection); - } + } + dispatchEvent(event); } - - // dispatch event even if selectionProvider == null -> it means that the last view was closed - - dispatchEvent(event); } } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/shortcut/KeyBindings.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/shortcut/KeyBindings.as index 1347df98..654c872f 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/shortcut/KeyBindings.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/shortcut/KeyBindings.as @@ -18,8 +18,6 @@ */ package org.flowerplatform.flexutil.shortcut { - import adobe.utils.CustomActions; - import flash.events.Event; import flash.events.KeyboardEvent; import flash.ui.Keyboard; @@ -29,12 +27,8 @@ package org.flowerplatform.flexutil.shortcut { import mx.core.FlexGlobals; import mx.core.UIComponent; - import org.flowerplatform.flexutil.FlexUtilConstants; import org.flowerplatform.flexutil.FlexUtilGlobals; - import org.flowerplatform.flexutil.Utils; - import org.flowerplatform.flexutil.action.ComposedActionProvider; import org.flowerplatform.flexutil.action.IAction; - import org.flowerplatform.flexutil.action.IActionProvider; import org.flowerplatform.flexutil.layout.IWorkbench; import org.flowerplatform.flexutil.view_content_host.IViewContent; import org.flowerplatform.flexutil.view_content_host.IViewHostAware; @@ -56,7 +50,7 @@ package org.flowerplatform.flexutil.shortcut { private var keyBindings:Dictionary = new Dictionary(); - public var filterShortcuts:Dictionary = new Dictionary(); + public var filterShortcuts:Array = []; public var actionIdsToShortcuts:Dictionary = new Dictionary(); @@ -64,20 +58,12 @@ package org.flowerplatform.flexutil.shortcut { public var learnShortcutOnNextActionInvocation:Boolean = false; - public var additionalActionProviders:ComposedActionProvider = new ComposedActionProvider(); - public function KeyBindings() { if (UIComponent(FlexGlobals.topLevelApplication).stage != null) { registerKeyListener(); } else { UIComponent(FlexGlobals.topLevelApplication).addEventListener(Event.ADDED_TO_STAGE, registerKeyListener); } - // initial filterShortcuts - // other filterShortcut must be added by corresponding keyboard action - filterShortcuts[FlexUtilConstants.CONTROL] = Keyboard.CONTROL; - filterShortcuts[FlexUtilConstants.COMMAND] = Keyboard.COMMAND; - filterShortcuts[FlexUtilConstants.SHIFT] = Keyboard.SHIFT; - filterShortcuts[FlexUtilConstants.ALTERNATE] = Keyboard.ALTERNATE; } protected function registerKeyListener(event:Event = null):void { @@ -85,18 +71,18 @@ package org.flowerplatform.flexutil.shortcut { UIComponent(FlexGlobals.topLevelApplication).stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp); } - public function registerBinding(shortcut:Shortcut, handler:Object, addToFilterShortcutsIfNecessary:Boolean = false):void { + public function registerBinding(shortcut:Shortcut, handler:Object):Boolean { if (!(handler is IAction) && !(handler is Function) && !(handler is String)) { // not what we expected throw new Error("The handler must be an action, an action id or a function!"); } // check if shortcut already exists - if (keyBindings.hasOwnProperty(shortcut.toString())) { - return; + if (getRegisteredShortcut(shortcut)) { + return false; } - keyBindings[shortcut.toString()] = handler; + keyBindings[shortcut] = handler; // register in actionIdsToShortcuts if string if (handler is String) { @@ -106,22 +92,24 @@ package org.flowerplatform.flexutil.shortcut { actionIdsToShortcuts[handler] = shortcut; } - if (addToFilterShortcutsIfNecessary && !shortcut.ctrlKey && !shortcut.altKey && !shortcut.shiftKey) { - filterShortcuts[Utils.getKeyNameFromKeyCode(shortcut.keyCode)] = shortcut.keyCode; + if (!shortcut.ctrlKey && !shortcut.altKey && !shortcut.shiftKey) { + filterShortcuts.push(shortcut.keyCode); } + + return true; } private function onKeyUp(event:KeyboardEvent):void { if (!canProcessEvent(event)) { return; } - var shortcut:Shortcut = new Shortcut(event.ctrlKey, event.shiftKey, event.altKey, event.keyCode); - if (!keyBindings.hasOwnProperty(shortcut.toString())) { // no shortcut registered for this event + var shortcut:Shortcut = getRegisteredShortcut(new Shortcut(event.ctrlKey, event.shiftKey, event.altKey, event.keyCode)); + if (shortcut == null) { // no shortcut registered for this event return; } var action:IAction; - var handler:Object = keyBindings[shortcut.toString()]; + var handler:Object = keyBindings[shortcut]; if (handler is IAction) { // check if visible & enabled, then run it @@ -132,52 +120,55 @@ package org.flowerplatform.flexutil.shortcut { } else if (handler is Function) { // execute function handler(); - } else { - var actions:Vector. = additionalActionProviders.getActions(null); - - // search actionId also in active's view list of available actions + } else { + // search actionId in active's view list of available actions; if found, run it var workbench:IWorkbench = FlexUtilGlobals.getInstance().workbench; var view:UIComponent = workbench.getEditorFromViewComponent(workbench.getActiveView()); + if (view != null && view is IViewContent) { var selection:IList = null; if (view is IViewHostAware) { selection = IViewHostAware(view).viewHost.getCachedSelection(); } - var viewActions:Vector. = IViewContent(view).getActions(selection); - for (i = 0; i < viewActions.length; i++) { - actions.push(viewActions[i]); + var actions:Vector. = IViewContent(view).getActions(selection); + if (actions != null) { + for (var i:int = 0; i < actions.length; i++) { + action = actions[i]; + if (action.id == handler) { + try { + action.selection = selection; + if (action.visible && action.enabled) { + action.run(); + } + } finally { + action.selection = null; + } + break; + } + } } } - - if (actions == null) { - return; + } + } + + private function getRegisteredShortcut(shortcut:Shortcut):Shortcut { + for (var obj:Object in keyBindings) { + if (shortcut.equals(obj)) { + return Shortcut(obj); } - for (var i:int = 0; i < actions.length; i++) { - action = actions[i]; - if (action.id == handler) { - try { - action.selection = selection; - if (action.visible && action.enabled) { - action.run(); - } - } finally { - action.selection = null; - } - break; - } - } } + return null; } - public function getRegisteredHandler(shortcut:Shortcut):Object { - return keyBindings[shortcut.toString()]; - } - private function canProcessEvent(event:KeyboardEvent):Boolean { - return !learnShortcutOnNextActionInvocation && allowKeyBindingsToProcessEvents && - (filterShortcuts.hasOwnProperty(FlexUtilConstants.CONTROL) || filterShortcuts.hasOwnProperty(FlexUtilConstants.COMMAND) || - filterShortcuts.hasOwnProperty(FlexUtilConstants.ALTERNATE) ||filterShortcuts.hasOwnProperty(FlexUtilConstants.SHIFT) || - filterShortcuts.hasOwnProperty(Utils.getKeyNameFromKeyCode(event.keyCode))); + if (!learnShortcutOnNextActionInvocation && allowKeyBindingsToProcessEvents && + (event.ctrlKey && (filterShortcuts.indexOf(Keyboard.CONTROL) != -1 || filterShortcuts.indexOf(Keyboard.COMMAND) != -1) || + event.altKey && (filterShortcuts.indexOf(Keyboard.ALTERNATE) != -1) || + event.shiftKey && (filterShortcuts.indexOf(Keyboard.SHIFT) != -1) || + event.keyCode && (filterShortcuts.indexOf(event.keyCode) != -1))) { + return true; + } + return false; } } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/spinner/LogoSpinner.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/spinner/LogoSpinner.as index c69919b9..ee782b16 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/spinner/LogoSpinner.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/spinner/LogoSpinner.as @@ -1,5 +1,7 @@ package org.flowerplatform.flexutil.spinner { import mx.controls.Image; + + import org.flowerplatform.flexutil.FlexUtilGlobals; /** * Spinner with logo. @@ -7,9 +9,9 @@ package org.flowerplatform.flexutil.spinner { */ public class LogoSpinner extends ModalSpinner { - private var logoIcon:Class; + private var logoIcon:Object; - public function LogoSpinner(logoIcon:Class) { + public function LogoSpinner(logoIcon:Object) { this.logoIcon = logoIcon; } @@ -19,7 +21,10 @@ package org.flowerplatform.flexutil.spinner { spinner.size = 46; var icon:Image = new Image(); - icon.source = logoIcon; + if (logoIcon is String) + icon.source = FlexUtilGlobals.getInstance().adjustImageBeforeDisplaying(logoIcon); + else + icon.source = logoIcon; addChildAt(icon, 0); } diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/view_content_host/BasicViewContent.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/view_content_host/BasicViewContent.as deleted file mode 100644 index 9c99fb7c..00000000 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/view_content_host/BasicViewContent.as +++ /dev/null @@ -1,100 +0,0 @@ -package org.flowerplatform.flexutil.view_content_host { - - import flash.events.Event; - import flash.events.MouseEvent; - import flash.net.drm.AddToDeviceGroupSetting; - - import mx.collections.IList; - import mx.events.FlexEvent; - import mx.managers.IFocusManagerComponent; - - import org.flowerplatform.flexutil.FlexUtilAssets; - import org.flowerplatform.flexutil.FlexUtilGlobals; - import org.flowerplatform.flexutil.action.IAction; - - import spark.components.Button; - import spark.components.Group; - import spark.components.HGroup; - import spark.layouts.VerticalLayout; - - /** - * Basic implementation of IViewContent. - * - * Adds ok, cancel buttons to control bar and sets vertical layout to group. - * - * @author Cristina Constantinescu - */ - public class BasicViewContent extends Group implements IViewContent, IFocusManagerComponent { - - protected var _viewHost:IViewHost; - - protected var okButton:Button; - protected var cancelButton:Button; - - protected var buttonBar:HGroup; - - public function BasicViewContent() { - super(); - addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler); - addEventListener(FlexEvent.INITIALIZE, initializeHandler); - } - - public function get viewHost():IViewHost { - return _viewHost; - } - - public function set viewHost(value:IViewHost):void { - _viewHost = value; - } - - public function getActions(selection:IList):Vector. { - return null; - } - - public function additionalCloseHandler():void { - } - - protected function initializeHandler(event:FlexEvent):void { - var layout:VerticalLayout = new VerticalLayout(); - layout.paddingTop = 10; - layout.paddingLeft = 5; - layout.paddingRight = 5; - layout.paddingBottom = 5; - - this.layout = layout; - } - - protected function creationCompleteHandler(event:FlexEvent):void { - } - - protected function okHandler(event:Event = null):void { - } - - protected function cancelHandler(event:Event = null):void { - FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(this); - } - - override protected function createChildren():void { - super.createChildren(); - - buttonBar = new HGroup(); - buttonBar.percentWidth = 100; - buttonBar.horizontalAlign = "right"; - buttonBar.verticalAlign = "middle"; - - okButton = new Button(); - okButton.label = FlexUtilAssets.INSTANCE.getMessage('dialog.ok'); - okButton.addEventListener(MouseEvent.CLICK, okHandler); - - cancelButton = new Button(); - cancelButton.label = FlexUtilAssets.INSTANCE.getMessage('dialog.cancel'); - cancelButton.addEventListener(MouseEvent.CLICK, cancelHandler); - - buttonBar.addElement(okButton); - buttonBar.addElement(cancelButton); - - viewHost.addToControlBar(buttonBar); - } - - } -} \ No newline at end of file diff --git a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/view_content_host/IViewContent.as b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/view_content_host/IViewContent.as index e58df0cd..8379dc20 100644 --- a/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/view_content_host/IViewContent.as +++ b/org.flowerplatform.flexutil/src/org/flowerplatform/flexutil/view_content_host/IViewContent.as @@ -26,17 +26,6 @@ package org.flowerplatform.flexutil.view_content_host { * @author Cristian Spiescu */ public interface IViewContent extends IVisualElement, IActionProvider { - function set viewHost(viewHost:IViewHost):void; - - /** - * This method provides additional code that will be executed before removing popup. - * - * @see IPopupHandlerFactory.removePopup() (PopupHandlerFactory & MobileViewHostPopupHandlerFactory) - * - * @author Cristina Constantinescu - */ - function additionalCloseHandler():void; - } } \ No newline at end of file diff --git a/org.flowerplatform.flexutil_legacy/.actionScriptProperties b/org.flowerplatform.flexutil_legacy/.actionScriptProperties index 1fea4c7e..205a982b 100644 --- a/org.flowerplatform.flexutil_legacy/.actionScriptProperties +++ b/org.flowerplatform.flexutil_legacy/.actionScriptProperties @@ -1,6 +1,6 @@ - - + + @@ -21,6 +21,7 @@ + diff --git a/org.flowerplatform.flexutil_legacy/.gitignore b/org.flowerplatform.flexutil_legacy/.gitignore index 291ea662..abfbf763 100644 --- a/org.flowerplatform.flexutil_legacy/.gitignore +++ b/org.flowerplatform.flexutil_legacy/.gitignore @@ -41,3 +41,4 @@ /bin /bin /bin +/bin diff --git a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/ActionButton.as b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/ActionButton.as index 913ae74a..15e07090 100644 --- a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/ActionButton.as +++ b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/ActionButton.as @@ -20,6 +20,7 @@ package com.crispico.flower.util.layout { import flash.events.MouseEvent; import org.flowerplatform.flexutil.FlexUtilGlobals; + import org.flowerplatform.flexutil.action.ActionUtil; import org.flowerplatform.flexutil.action.IAction; import spark.components.Button; @@ -36,10 +37,17 @@ package com.crispico.flower.util.layout { protected override function clickHandler(event:MouseEvent):void { super.clickHandler(event); - if (FlexUtilGlobals.getInstance().actionHelper.isComposedAction(action)) { + if (ActionUtil.isComposedAction(action)) { viewWrapper.openMenu(event.stageX, event.stageY, viewWrapper.contextForActions, action.id); } else { - FlexUtilGlobals.getInstance().actionHelper.runAction(action, viewWrapper.selection, viewWrapper.contextForActions); + try { + action.selection = viewWrapper.selection; + action.context = viewWrapper.contextForActions; + action.run(); + } finally { + action.selection = null; + action.context = null; + } } } diff --git a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/Workbench.as b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/Workbench.as index cf88e6a7..5a002061 100644 --- a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/Workbench.as +++ b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/Workbench.as @@ -38,14 +38,13 @@ package com.crispico.flower.util.layout { import com.crispico.flower.util.layout.view.activeview.ActiveViewList; import flash.display.DisplayObject; + import flash.events.Event; import flash.events.IEventDispatcher; import flash.events.MouseEvent; import flash.geom.Point; import flash.ui.Keyboard; import flash.utils.Dictionary; - import flexlib.containers.SuperTabNavigator; - import mx.collections.ArrayCollection; import mx.containers.BoxDirection; import mx.containers.Canvas; @@ -61,6 +60,10 @@ package com.crispico.flower.util.layout { import mx.core.UIComponent; import mx.core.mx_internal; import mx.events.FlexEvent; + import mx.events.ResizeEvent; + import mx.managers.PopUpManager; + + import flexlib.containers.SuperTabNavigator; import org.flowerplatform.flexutil.FlexUtilGlobals; import org.flowerplatform.flexutil.action.ActionBase; @@ -235,7 +238,8 @@ package com.crispico.flower.util.layout { addEventListener(FillContextMenuEvent.FILL_CONTEXT_MENU, fillContextMenuHandler); - // Adds CTRL+M as shortcut to maximize/minimize the active view layout data. + // Adds CTRL+M as shortcut to maximize/minimize the active view layout data. + //(new KeyBindings()).registerBinding(new Shortcut(true, false, "m"), maximizeRestoreActiveStackLayoutData); FlexUtilGlobals.getInstance().keyBindings.registerBinding(new Shortcut(true, false, false, Keyboard.M), maximizeRestoreActiveStackLayoutData); // CTRL + M // prepare default actions for the right click menu on a tab name @@ -2062,16 +2066,16 @@ package com.crispico.flower.util.layout { */ public function closeViews(views:ArrayCollection /* of UIComponent */, shouldDispatchEvent:Boolean = true):void { var viewsRemovedEvent:ViewsRemovedEvent = new ViewsRemovedEvent(views); - viewsRemovedEvent.canPreventDefault = shouldDispatchEvent; - dispatchEvent(viewsRemovedEvent); - + if (shouldDispatchEvent) { + dispatchEvent(viewsRemovedEvent); + } for each (var view:UIComponent in views) { if (!viewsRemovedEvent.dontRemoveViews.contains(view)) { var viewRemovedEvent:ViewRemovedEvent = new ViewRemovedEvent(); - viewRemovedEvent.canPreventDefault = shouldDispatchEvent; - view.dispatchEvent(viewRemovedEvent); - - if (viewRemovedEvent.canRemoveView) { + if (shouldDispatchEvent) { + view.dispatchEvent(viewRemovedEvent); + } + if (!viewRemovedEvent.dontRemoveView) { removeViewInternal(view); } } @@ -2249,7 +2253,7 @@ package com.crispico.flower.util.layout { * * @author Cristina */ - public function addViewInPopupWindow(view:Object, x:Number= NaN, y:Number=NaN, width:Number=NaN, height:Number=NaN, isModal:Boolean = false, existingComponent:UIComponent = null, existingViewPopupWindowInstance:ViewPopupWindow = null):ViewPopupWindow { + public function addViewInPopupWindow(view:Object, x:Number= NaN, y:Number=NaN, width:Number=NaN, height:Number=NaN, isModal:Boolean = false, existingComponent:UIComponent = null, existingViewPopupWindowInstance:ViewPopupWindow = null, parent:DisplayObject = null):ViewPopupWindow { // get viewLayoutData var viewLayoutData:ViewLayoutData; if (view is String) { @@ -2278,8 +2282,6 @@ package com.crispico.flower.util.layout { var component:UIComponent = existingComponent != null ? existingComponent : getNewViewComponentInstance(viewLayoutData); component.percentWidth = 100; component.percentHeight = 100; - popup.addChild(component); - if (viewLayoutData.dimensions.length != 0) { if (isNaN(x)) { @@ -2317,7 +2319,12 @@ package com.crispico.flower.util.layout { popup.viewLayoutData = viewLayoutData; popup.component = component; - popup.showPopup(width, height, null, isModal); + if (!component.initialized) { + popup.visible = false; + component.addEventListener(FlexEvent.CREATION_COMPLETE, function(e:Event):void {popup.visible = true; PopUpManager.centerPopUp(popup);}); + } + popup.showPopup(width, height, parent, isModal); + popup.addChild(component); // set coordonates if (!isNaN(x) && !isNaN(y)) { @@ -2332,7 +2339,7 @@ package com.crispico.flower.util.layout { return popup; } - + /** * Searches vertical for the first stack found below the first editor sash. * If not found, creates one. diff --git a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/WorkbenchViewHost.as b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/WorkbenchViewHost.as index 962e1b16..d821ee69 100644 --- a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/WorkbenchViewHost.as +++ b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/WorkbenchViewHost.as @@ -26,6 +26,7 @@ package com.crispico.flower.util.layout { import mx.core.UIComponent; import org.flowerplatform.flexutil.FlexUtilGlobals; + import org.flowerplatform.flexutil.action.ActionUtil; import org.flowerplatform.flexutil.action.IAction; import org.flowerplatform.flexutil.context_menu.FillContextMenuEvent; import org.flowerplatform.flexutil.layout.event.ActiveViewChangedEvent; @@ -152,7 +153,7 @@ package com.crispico.flower.util.layout { buttonBar.removeAllElements(); rootActionsAlreadyCalculated = new ArrayList(); - FlexUtilGlobals.getInstance().actionHelper.processAndIterateActions(null, allActions, selection, contextForActions, this, function (action:IAction):void { + ActionUtil.processAndIterateActions(null, allActions, selection, contextForActions, this, function (action:IAction):void { if (action.preferShowOnActionBar) { var actionButton:ActionButton = new ActionButton(); if (action.label == null) { diff --git a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/view/ViewPopupWindow.as b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/view/ViewPopupWindow.as index e7db9e9f..0a08459f 100644 --- a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/view/ViewPopupWindow.as +++ b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/view/ViewPopupWindow.as @@ -98,14 +98,16 @@ package com.crispico.flower.util.layout.view close(); } - public function close(dispatchLayoutDataChangedEvent:Boolean = true):void { + public function close(dispatchLayoutDataChangedEvent:Boolean = true, shouldDispatchRemoveEvent:Boolean = true):void { closeFormInternal(); - // dispatch remove events - var viewsRemovedEvent:ViewsRemovedEvent = new ViewsRemovedEvent(new ArrayCollection([component])); - workbench.dispatchEvent(viewsRemovedEvent); - - component.dispatchEvent(new ViewRemovedEvent()); + if (shouldDispatchRemoveEvent) { + // dispatch remove events + var viewsRemovedEvent:ViewsRemovedEvent = new ViewsRemovedEvent(new ArrayCollection([component])); + workbench.dispatchEvent(viewsRemovedEvent); + + component.dispatchEvent(new ViewRemovedEvent()); + } if (dispatchLayoutDataChangedEvent) { workbench.dispatchEvent(new LayoutDataChangedEvent()); } diff --git a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/view/activeview/ActiveViewList.as b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/view/activeview/ActiveViewList.as index cc31e88c..8867a4fe 100644 --- a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/view/activeview/ActiveViewList.as +++ b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/layout/view/activeview/ActiveViewList.as @@ -20,6 +20,7 @@ package com.crispico.flower.util.layout.view.activeview { import com.crispico.flower.util.layout.Workbench; import com.crispico.flower.util.layout.view.LayoutTabNavigator; + import com.crispico.flower.util.layout.view.ViewPopupWindow; import mx.collections.ArrayCollection; import mx.core.INavigatorContent; @@ -80,15 +81,15 @@ package com.crispico.flower.util.layout.view.activeview * Dispatches an event to notify about changes. */ public function setActiveView(newActiveView:UIComponent, setFocusOnNewView:Boolean = true, dispatchActiveViewChangedEvent:Boolean = true, restoreIfMinimized:Boolean = true):void { - if (newActiveView == null) { + if (newActiveView == null || newActiveView.parent is ViewPopupWindow) { return; } if (restoreIfMinimized) { // if minimized, restore it var viewLayoutData:ViewLayoutData = ViewLayoutData(workbench.componentToLayoutData[newActiveView]); - if (StackLayoutData(viewLayoutData.parent).mrmState == StackLayoutData.USER_MINIMIZED || - StackLayoutData(viewLayoutData.parent).mrmState == StackLayoutData.FORCED_MINIMIZED) { + if (viewLayoutData.parent != null && (StackLayoutData(viewLayoutData.parent).mrmState == StackLayoutData.USER_MINIMIZED || + StackLayoutData(viewLayoutData.parent).mrmState == StackLayoutData.FORCED_MINIMIZED)) { workbench.restore(StackLayoutData(viewLayoutData.parent)); } } diff --git a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/PopupHandler.as b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/PopupHandler.as index 221e0f6e..f9b5313d 100644 --- a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/PopupHandler.as +++ b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/PopupHandler.as @@ -21,7 +21,6 @@ package com.crispico.flower.util.popup { private var _height:Number; private var _width:Number; private var _title:String; - private var _icon:Object; private var _viewContent:IViewContent; private var _viewIdInWorkbench:String; @@ -40,11 +39,6 @@ package com.crispico.flower.util.popup { return this; } - public function setIcon(value:Object):IPopupHandler { - _icon = value; - return this; - } - public function setViewContent(value:IViewContent):IPopupHandler { _viewContent = value; return this; @@ -75,7 +69,6 @@ package com.crispico.flower.util.popup { var resizablePopup:ResizablePopupWindowViewHost = new ResizablePopupWindowViewHost(_viewContent); resizablePopup.title = _title; - resizablePopup.setIcon(_icon); if (!isNaN(_height)) { resizablePopup.height = _height; } diff --git a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/PopupHandlerFactory.as b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/PopupHandlerFactory.as index 94af5dde..12b54516 100644 --- a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/PopupHandlerFactory.as +++ b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/PopupHandlerFactory.as @@ -29,7 +29,6 @@ package com.crispico.flower.util.popup { import org.flowerplatform.flexutil.popup.IPopupHandler; import org.flowerplatform.flexutil.popup.IPopupHandlerFactory; import org.flowerplatform.flexutil.spinner.ModalSpinner; - import org.flowerplatform.flexutil.view_content_host.IViewContent; /** * @author Cristian Spiescu @@ -51,9 +50,6 @@ package com.crispico.flower.util.popup { popup = iteratePopups(FlexGlobals.topLevelApplication.systemManager.popUpChildren, viewContent); } if (popup != null) { - if (viewContent is IViewContent) { - IViewContent(viewContent).additionalCloseHandler(); - } PopUpManager.removePopUp(popup); } } diff --git a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/ResizablePopupWindowViewHost.as b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/ResizablePopupWindowViewHost.as index 7e0ed298..077ef91a 100644 --- a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/ResizablePopupWindowViewHost.as +++ b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/ResizablePopupWindowViewHost.as @@ -22,9 +22,7 @@ package com.crispico.flower.util.popup { import mx.collections.IList; import mx.containers.ControlBar; - import mx.events.EffectEvent; - import org.flowerplatform.flexutil.FlexUtilGlobals; import org.flowerplatform.flexutil.action.IAction; import org.flowerplatform.flexutil.spinner.ModalSpinner; import org.flowerplatform.flexutil.view_content_host.IViewContent; @@ -129,9 +127,5 @@ package com.crispico.flower.util.popup { addElement(activeViewContent); } - override protected function fadeOutEffectEndHandler(event:EffectEvent):void { - FlexUtilGlobals.getInstance().popupHandlerFactory.removePopup(activeViewContent); - } - } } \ No newline at end of file diff --git a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/TextAreaPopup.mxml b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/TextAreaPopup.mxml index 4e240662..c32e9b67 100644 --- a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/TextAreaPopup.mxml +++ b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/TextAreaPopup.mxml @@ -20,8 +20,6 @@ --> diff --git a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/TextAreaPopupMessageBoxFactory.as b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/TextAreaPopupMessageBoxFactory.as index e60a2f52..1c3ae7a1 100644 --- a/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/TextAreaPopupMessageBoxFactory.as +++ b/org.flowerplatform.flexutil_legacy/src/com/crispico/flower/util/popup/TextAreaPopupMessageBoxFactory.as @@ -20,7 +20,6 @@ package com.crispico.flower.util.popup { import org.flowerplatform.flexutil.popup.IMessageBox; import org.flowerplatform.flexutil.popup.IMessageBoxFactory; - // not used public class TextAreaPopupMessageBoxFactory implements IMessageBoxFactory { public function createMessageBox():IMessageBox { diff --git a/org.flowerplatform.freeplane/lib/freeplaneeditor_modified.jar b/org.flowerplatform.freeplane/lib/freeplaneeditor_modified.jar index e9ec4610..68ee4f08 100644 Binary files a/org.flowerplatform.freeplane/lib/freeplaneeditor_modified.jar and b/org.flowerplatform.freeplane/lib/freeplaneeditor_modified.jar differ diff --git a/org.flowerplatform.freeplane/lib/freeplaneviewer.jar b/org.flowerplatform.freeplane/lib/freeplaneviewer.jar index cb0e0d95..f717d480 100644 Binary files a/org.flowerplatform.freeplane/lib/freeplaneviewer.jar and b/org.flowerplatform.freeplane/lib/freeplaneviewer.jar differ diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/FreeplanePlugin.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/FreeplanePlugin.java index 9a7d9bb9..67336633 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/FreeplanePlugin.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/FreeplanePlugin.java @@ -3,7 +3,6 @@ import static org.flowerplatform.core.CoreConstants.ADD_NODE_CONTROLLER; import static org.flowerplatform.core.CoreConstants.CHILDREN_PROVIDER; import static org.flowerplatform.core.CoreConstants.DEFAULT_PROPERTY_PROVIDER; -import static org.flowerplatform.core.CoreConstants.FILE_SYSTEM_NODE_TYPE; import static org.flowerplatform.core.CoreConstants.PARENT_PROVIDER; import static org.flowerplatform.core.CoreConstants.PROPERTIES_PROVIDER; import static org.flowerplatform.core.CoreConstants.PROPERTY_SETTER; @@ -106,9 +105,6 @@ public void start(BundleContext bundleContext) throws Exception { .addAdditiveController(PROPERTIES_PROVIDER, new MindMapFileContentTypeProvider()) .addAdditiveController(ADD_NODE_CONTROLLER, new MindMapFileAddNodeController()); - CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(CoreConstants.FILE_SYSTEM_NODE_TYPE) - .addAdditiveController(ADD_NODE_CONTROLLER, new MindMapFileAddNodeController()); - CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(CoreConstants.CODE_TYPE) .addAdditiveController(RESOURCE_ACCESS_CONTROLLER, new FreeplaneResourceAccessController(FREEPLANE_PERSISTENCE_CATEGORY)) .addAdditiveController(CHILDREN_PROVIDER, new FreeplaneResourceChildrenProvider()) diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneIsSubscribablePropertyProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneIsSubscribablePropertyProvider.java index 8caecf06..a08e5f87 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneIsSubscribablePropertyProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneIsSubscribablePropertyProvider.java @@ -1,23 +1,22 @@ package org.flowerplatform.freeplane.controller; import org.flowerplatform.core.CoreConstants; -import org.flowerplatform.core.file.FilePropertiesController; +import org.flowerplatform.core.file.FilePropertiesProvider; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertiesProvider; +import org.flowerplatform.core.node.controller.PropertiesProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.url.UrlManager; /** * Sets the IS_SUBSCRIBABLE property to true * if the node is a file with the .mm extension. Needs to be invoked after - * the {@link FilePropertiesController} responsible with setting the NAME + * the {@link FilePropertiesProvider} responsible with setting the NAME * and IS_DIRECTORY properties for the node. * * @author Mariana Gheorghe */ -public class FreeplaneIsSubscribablePropertyProvider extends AbstractController implements IPropertiesProvider { +public class FreeplaneIsSubscribablePropertyProvider extends PropertiesProvider { public FreeplaneIsSubscribablePropertyProvider() { super(); diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneResourceChildrenProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneResourceChildrenProvider.java index fe53adcc..45732f92 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneResourceChildrenProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneResourceChildrenProvider.java @@ -5,12 +5,12 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.CoreUtils; +import org.flowerplatform.core.file.FileChildrenProvider; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IChildrenProvider; +import org.flowerplatform.core.node.controller.ChildrenProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.freeplane.FreeplanePlugin; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.map.NodeModel; /** @@ -21,7 +21,7 @@ * * @author Mariana Gheorghe */ -public class FreeplaneResourceChildrenProvider extends AbstractController implements IChildrenProvider { +public class FreeplaneResourceChildrenProvider extends ChildrenProvider { public FreeplaneResourceChildrenProvider() { super(); diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneResourceRawNodeDataProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneResourceRawNodeDataProvider.java index a5fc3e60..dc650e07 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneResourceRawNodeDataProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/FreeplaneResourceRawNodeDataProvider.java @@ -2,17 +2,16 @@ import org.flowerplatform.core.CorePlugin; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IRawNodeDataProvider; +import org.flowerplatform.core.node.controller.RawNodeDataProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.map.MapModel; import org.freeplane.features.map.NodeModel; /** * @author Mariana Gheorghe */ -public class FreeplaneResourceRawNodeDataProvider extends AbstractController implements IRawNodeDataProvider { +public class FreeplaneResourceRawNodeDataProvider extends RawNodeDataProvider { @Override public NodeModel getRawNodeData(Node node, ServiceContext context) { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapAddNodeController.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapAddNodeController.java index f49db8ff..db76bd21 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapAddNodeController.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapAddNodeController.java @@ -2,16 +2,15 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IAddNodeController; +import org.flowerplatform.core.node.controller.AddNodeController; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.map.NodeModel; /** * @author Cristina Constantinescu */ -public class MindMapAddNodeController extends AbstractController implements IAddNodeController { +public class MindMapAddNodeController extends AddNodeController { @Override public void addNode(Node node, Node child, ServiceContext context) { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapChildrenProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapChildrenProvider.java index 654935b8..aa703660 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapChildrenProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapChildrenProvider.java @@ -4,17 +4,16 @@ import java.util.List; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IChildrenProvider; +import org.flowerplatform.core.node.controller.ChildrenProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.freeplane.FreeplanePlugin; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.map.NodeModel; /** * @author Cristina Constantinescu */ -public class MindMapChildrenProvider extends AbstractController implements IChildrenProvider { +public class MindMapChildrenProvider extends ChildrenProvider { @Override public List getChildren(Node node, ServiceContext context) { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapDefaultPropertyValueProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapDefaultPropertyValueProvider.java index 1cf1d972..c1adb19d 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapDefaultPropertyValueProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapDefaultPropertyValueProvider.java @@ -23,10 +23,9 @@ import java.util.Enumeration; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IDefaultPropertyValueProvider; +import org.flowerplatform.core.node.controller.DefaultPropertyValueProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.core.util.ColorUtils; import org.freeplane.features.cloud.CloudController; import org.freeplane.features.cloud.CloudModel; @@ -43,7 +42,7 @@ /** * @author Sebastian Solomon */ -public class MindMapDefaultPropertyValueProvider extends AbstractController implements IDefaultPropertyValueProvider { +public class MindMapDefaultPropertyValueProvider extends DefaultPropertyValueProvider { public final static String DEFAULT_STYLE = "Default"; diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapFileAddNodeController.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapFileAddNodeController.java index 5677dd0d..a2bcd878 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapFileAddNodeController.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapFileAddNodeController.java @@ -5,10 +5,9 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.CorePlugin; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IAddNodeController; +import org.flowerplatform.core.node.controller.AddNodeController; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.map.MapModel; import org.freeplane.features.mode.Controller; import org.freeplane.features.url.UrlManager; @@ -17,7 +16,7 @@ /** * @author Mariana Gheorghe */ -public class MindMapFileAddNodeController extends AbstractController implements IAddNodeController { +public class MindMapFileAddNodeController extends AddNodeController { public MindMapFileAddNodeController() { // higher order index, to make sure it's invoked after the file was created diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapFileContentTypeProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapFileContentTypeProvider.java index 144eaf38..9a1cf224 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapFileContentTypeProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapFileContentTypeProvider.java @@ -5,23 +5,22 @@ import static org.flowerplatform.mindmap.MindMapConstants.MINDMAP_CONTENT_TYPE; import org.flowerplatform.core.CoreConstants; -import org.flowerplatform.core.file.FilePropertiesController; +import org.flowerplatform.core.file.FilePropertiesProvider; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertiesProvider; +import org.flowerplatform.core.node.controller.PropertiesProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.url.UrlManager; /** * Sets the CONTENT_TYPE property to {@link #MINDMAP_CONTENT_TYPE} * if the node is a file with the .mm extension. Needs to be invoked after - * the {@link FilePropertiesController} responsible with setting the NAME + * the {@link FilePropertiesProvider} responsible with setting the NAME * and IS_DIRECTORY properties for the node. * * @author Mariana Gheorghe */ -public class MindMapFileContentTypeProvider extends AbstractController implements IPropertiesProvider { +public class MindMapFileContentTypeProvider extends PropertiesProvider { public MindMapFileContentTypeProvider() { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapParentProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapParentProvider.java index d5386e73..b75c6c43 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapParentProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapParentProvider.java @@ -1,17 +1,16 @@ package org.flowerplatform.freeplane.controller; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IParentProvider; +import org.flowerplatform.core.node.controller.ParentProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.freeplane.FreeplanePlugin; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.map.NodeModel; /** * @author Mariana Gheorghe */ -public class MindMapParentProvider extends AbstractController implements IParentProvider { +public class MindMapParentProvider extends ParentProvider { @Override public Node getParent(Node node, ServiceContext context) { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapPropertySetter.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapPropertySetter.java index 3002c53d..0d828bcf 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapPropertySetter.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapPropertySetter.java @@ -117,19 +117,15 @@ public void setProperty(Node node, String property, PropertyValueWrapper wrapper break; case NOTE: String note = (String) wrapper.getPropertyValue(); - NoteModel.createNote(rawNodeData).setXml(note); - - isPropertySet = true; + NoteModel.createNote(rawNodeData).setHtml(note); if (addAdditionalSetPropertyUpdatesFor == null) { addAdditionalSetPropertyUpdatesFor = new ArrayList(); - } + } addAdditionalSetPropertyUpdatesFor.add(CoreConstants.ICONS); break; case NODE_DETAILS: String nodeDetails = (String) wrapper.getPropertyValue(); - DetailTextModel.createDetailText(rawNodeData).setXml(nodeDetails); - isPropertySet = true; - break; + DetailTextModel.createDetailText(rawNodeData).setHtml(nodeDetails); case FONT_FAMILY: String fontFamily = (String) wrapper.getPropertyValue(); NodeStyleModel.createNodeStyleModel(rawNodeData).setFontFamilyName(fontFamily); diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapRawNodeDataProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapRawNodeDataProvider.java index bfaacf93..69eaf169 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapRawNodeDataProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapRawNodeDataProvider.java @@ -3,10 +3,9 @@ import org.flowerplatform.core.CorePlugin; import org.flowerplatform.core.CoreUtils; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IRawNodeDataProvider; +import org.flowerplatform.core.node.controller.RawNodeDataProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.map.MapModel; import org.freeplane.features.map.NodeModel; @@ -14,7 +13,7 @@ * @author Cristina Constantinescu * @author Mariana Gheorghe */ -public class MindMapRawNodeDataProvider extends AbstractController implements IRawNodeDataProvider { +public class MindMapRawNodeDataProvider extends RawNodeDataProvider { @Override public NodeModel getRawNodeData(Node node, ServiceContext context) { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapRemoveNodeController.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapRemoveNodeController.java index baaec0c6..e5da9137 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapRemoveNodeController.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/MindMapRemoveNodeController.java @@ -1,16 +1,15 @@ package org.flowerplatform.freeplane.controller; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IRemoveNodeController; +import org.flowerplatform.core.node.controller.RemoveNodeController; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.map.NodeModel; /** * @author Cristina Constantinescu */ -public class MindMapRemoveNodeController extends AbstractController implements IRemoveNodeController { +public class MindMapRemoveNodeController extends RemoveNodeController { @Override public void removeNode(Node node, Node child, ServiceContext context) { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/PersistencePropertiesProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/PersistencePropertiesProvider.java index 9bced165..4289a263 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/PersistencePropertiesProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/PersistencePropertiesProvider.java @@ -1,10 +1,9 @@ package org.flowerplatform.freeplane.controller; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertiesProvider; +import org.flowerplatform.core.node.controller.PropertiesProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.attribute.Attribute; import org.freeplane.features.attribute.NodeAttributeTableModel; import org.freeplane.features.map.NodeModel; @@ -12,7 +11,7 @@ /** * @author Cristina Constantinescu */ -public class PersistencePropertiesProvider extends AbstractController implements IPropertiesProvider { +public class PersistencePropertiesProvider extends PropertiesProvider { @Override public void populateWithProperties(Node node, ServiceContext context) { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/PersistencePropertySetter.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/PersistencePropertySetter.java index 4d7a710c..eead776c 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/PersistencePropertySetter.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/controller/PersistencePropertySetter.java @@ -2,12 +2,11 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertySetter; +import org.flowerplatform.core.node.controller.PropertySetter; import org.flowerplatform.core.node.controller.PropertyValueWrapper; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.mindmap.MindMapConstants; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.attribute.Attribute; import org.freeplane.features.attribute.NodeAttributeTableModel; import org.freeplane.features.map.NodeModel; @@ -15,7 +14,7 @@ /** * @author Cristina Constantinescu */ -public class PersistencePropertySetter extends AbstractController implements IPropertySetter { +public class PersistencePropertySetter extends PropertySetter { @Override public void setProperty(Node node, String property, PropertyValueWrapper wrapper, ServiceContext context) { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/MindMapStyleChildrenProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/MindMapStyleChildrenProvider.java index cc286212..f22a7b5e 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/MindMapStyleChildrenProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/MindMapStyleChildrenProvider.java @@ -9,11 +9,10 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.CorePlugin; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IChildrenProvider; +import org.flowerplatform.core.node.controller.ChildrenProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; import org.flowerplatform.mindmap.MindMapConstants; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.map.MapModel; import org.freeplane.features.map.NodeModel; import org.freeplane.features.styles.MapStyleModel; @@ -22,7 +21,7 @@ /** * @author Sebastian Solomon */ -public class MindMapStyleChildrenProvider extends AbstractController implements IChildrenProvider { +public class MindMapStyleChildrenProvider extends ChildrenProvider { @Override public List getChildren(Node node, ServiceContext serviceContext) { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/StyleRootChildrenProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/StyleRootChildrenProvider.java index ab6f8b6f..d7fc38cd 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/StyleRootChildrenProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/StyleRootChildrenProvider.java @@ -6,16 +6,15 @@ import java.util.List; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IChildrenProvider; +import org.flowerplatform.core.node.controller.ChildrenProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.freeplane.features.map.NodeModel; /** * @author Sebastian Solomon */ -public class StyleRootChildrenProvider extends AbstractController implements IChildrenProvider { +public class StyleRootChildrenProvider extends ChildrenProvider { @Override public List getChildren(Node node, ServiceContext context) { diff --git a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/StyleRootPropertiesProvider.java b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/StyleRootPropertiesProvider.java index bdafa921..bedb3974 100644 --- a/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/StyleRootPropertiesProvider.java +++ b/org.flowerplatform.freeplane/src/org/flowerplatform/freeplane/style/controller/StyleRootPropertiesProvider.java @@ -2,15 +2,14 @@ import org.flowerplatform.core.CoreConstants; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IPropertiesProvider; +import org.flowerplatform.core.node.controller.PropertiesProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; /** * @author Sebastian Solomon */ -public class StyleRootPropertiesProvider extends AbstractController implements IPropertiesProvider { +public class StyleRootPropertiesProvider extends PropertiesProvider { @Override public void populateWithProperties(Node node, ServiceContext context) { diff --git a/org.flowerplatform.host.web_app/src/org/eclipse/equinox/servletbridge/BridgeServlet.java b/org.flowerplatform.host.web_app/src/org/eclipse/equinox/servletbridge/BridgeServlet.java index a232091f..adb42583 100644 --- a/org.flowerplatform.host.web_app/src/org/eclipse/equinox/servletbridge/BridgeServlet.java +++ b/org.flowerplatform.host.web_app/src/org/eclipse/equinox/servletbridge/BridgeServlet.java @@ -40,16 +40,6 @@ */ public class BridgeServlet extends HttpServlet { - /** - * Set headless property here, programmatically. - * Fewer steps for users that want to deploy our app on their PCs. - * - * @author Cristina Constantinescu - */ - static { - System.setProperty("java.awt.headless", "true"); - } - static final String INCLUDE_REQUEST_URI_ATTRIBUTE = "javax.servlet.include.request_uri"; //$NON-NLS-1$ static final String INCLUDE_SERVLET_PATH_ATTRIBUTE = "javax.servlet.include.servlet_path"; //$NON-NLS-1$ static final String INCLUDE_PATH_INFO_ATTRIBUTE = "javax.servlet.include.path_info"; //$NON-NLS-1$ diff --git a/org.flowerplatform.resources/.classpath b/org.flowerplatform.resources/.classpath index b1dabee3..000104da 100644 --- a/org.flowerplatform.resources/.classpath +++ b/org.flowerplatform.resources/.classpath @@ -3,5 +3,6 @@ + diff --git a/org.flowerplatform.resources/.gitignore b/org.flowerplatform.resources/.gitignore index 5e56e040..bca9b393 100644 --- a/org.flowerplatform.resources/.gitignore +++ b/org.flowerplatform.resources/.gitignore @@ -1 +1,3 @@ /bin +/bin +/bin diff --git a/org.flowerplatform.resources/.project b/org.flowerplatform.resources/.project index f4d548f9..0b3be501 100644 --- a/org.flowerplatform.resources/.project +++ b/org.flowerplatform.resources/.project @@ -5,6 +5,11 @@ + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.jdt.core.javabuilder @@ -20,9 +25,17 @@ + + org.eclipse.wst.validation.validationbuilder + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature diff --git a/org.flowerplatform.resources/.settings/org.eclipse.jdt.core.prefs b/org.flowerplatform.resources/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f287d53c --- /dev/null +++ b/org.flowerplatform.resources/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.flowerplatform.resources/.settings/org.eclipse.wst.common.component b/org.flowerplatform.resources/.settings/org.eclipse.wst.common.component new file mode 100644 index 00000000..10b14158 --- /dev/null +++ b/org.flowerplatform.resources/.settings/org.eclipse.wst.common.component @@ -0,0 +1,5 @@ + + + + + diff --git a/org.flowerplatform.resources/.settings/org.eclipse.wst.common.project.facet.core.xml b/org.flowerplatform.resources/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 00000000..7ba6051d --- /dev/null +++ b/org.flowerplatform.resources/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.flowerplatform.resources/public-resources/messages/org_flowerplatform_resources.properties b/org.flowerplatform.resources/public-resources/messages/org_flowerplatform_resources.properties index b4e0f694..1fbf9fd6 100644 --- a/org.flowerplatform.resources/public-resources/messages/org_flowerplatform_resources.properties +++ b/org.flowerplatform.resources/public-resources/messages/org_flowerplatform_resources.properties @@ -10,8 +10,6 @@ deselect.all = Deselect All info = Info error = Error -action.new.label = New {0} - action.remove = Remove action.rename = Rename @@ -30,8 +28,8 @@ menu.debug = Debug menu.tools = Tools menu.help = Help -asign.hotkey.action.label = Assign hot key -shortcut.already.used = This shortcut is currently assigned to\n {0}\nReplace this assignment? +asign.hotkey.action.label = Asign kot key +shortcut.already.used = Shortcut is already used! shortcut.action.click = Click on any action to assign shortcut. shortcut.enter = Enter new shortcut @@ -75,7 +73,7 @@ file.creation.time = Created file.modified.time = Modified file.accessed.time = Accessed file.folder = File/Folder - +new.file.folder = new File/Folder action.download = Download download.zip = A Zip archive will be created containing selected resources! @@ -168,8 +166,6 @@ mindmap.navigate.action.append = {0} (+) mindmap.edit.node.core = Edit node core in dialog -mindmap.create.note = Note: Add .mm extension to create a Freeplane mind map. - ####################################### # codesync ####################################### diff --git a/org.flowerplatform.resources/src/META-INF/MANIFEST.MF b/org.flowerplatform.resources/src/META-INF/MANIFEST.MF new file mode 100644 index 00000000..5e949512 --- /dev/null +++ b/org.flowerplatform.resources/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/org.flowerplatform.tests/src/org/flowerplatform/tests/core/NodeServiceTest.java b/org.flowerplatform.tests/src/org/flowerplatform/tests/core/NodeServiceTest.java index 230c9c34..406961ab 100644 --- a/org.flowerplatform.tests/src/org/flowerplatform/tests/core/NodeServiceTest.java +++ b/org.flowerplatform.tests/src/org/flowerplatform/tests/core/NodeServiceTest.java @@ -11,10 +11,9 @@ import java.util.List; import org.flowerplatform.core.node.NodeService; -import org.flowerplatform.core.node.controller.IChildrenProvider; +import org.flowerplatform.core.node.controller.ChildrenProvider; import org.flowerplatform.core.node.remote.Node; import org.flowerplatform.core.node.remote.ServiceContext; -import org.flowerplatform.util.controller.AbstractController; import org.flowerplatform.util.controller.TypeDescriptor; import org.flowerplatform.util.controller.TypeDescriptorRegistry; import org.junit.BeforeClass; @@ -29,7 +28,7 @@ public class NodeServiceTest { @BeforeClass public static void setUpBeforeClass() throws Exception { - class MockChildProvider extends AbstractController implements IChildrenProvider { + class MockChildProvider extends ChildrenProvider { @Override public List getChildren(Node node, ServiceContext context) { return null; @@ -41,11 +40,11 @@ public boolean hasChildren(Node node, ServiceContext context) { } } - IChildrenProvider spyProviderForTypeA = spy(new MockChildProvider()); - IChildrenProvider spyProviderForTypeB = spy(new MockChildProvider()); - IChildrenProvider spyProviderForTypeC = spy(new MockChildProvider()); - IChildrenProvider spyProviderForTypeFileSystem = spy(new MockChildProvider()); - IChildrenProvider spyProviderAll = spy(new MockChildProvider()); + ChildrenProvider spyProviderForTypeA = spy(new MockChildProvider()); + ChildrenProvider spyProviderForTypeB = spy(new MockChildProvider()); + ChildrenProvider spyProviderForTypeC = spy(new MockChildProvider()); + ChildrenProvider spyProviderForTypeFileSystem = spy(new MockChildProvider()); + ChildrenProvider spyProviderAll = spy(new MockChildProvider()); // setPrioritys spyProviderForTypeA.setOrderIndex(-100); diff --git a/org.flowerplatform.util/.classpath b/org.flowerplatform.util/.classpath index fb9061a6..d971c0a4 100644 --- a/org.flowerplatform.util/.classpath +++ b/org.flowerplatform.util/.classpath @@ -8,5 +8,6 @@ + diff --git a/org.flowerplatform.util/.gitignore b/org.flowerplatform.util/.gitignore index 5e56e040..bca9b393 100644 --- a/org.flowerplatform.util/.gitignore +++ b/org.flowerplatform.util/.gitignore @@ -1 +1,3 @@ /bin +/bin +/bin diff --git a/org.flowerplatform.util/.project b/org.flowerplatform.util/.project index 2e7ba81a..5a6b2b6f 100644 --- a/org.flowerplatform.util/.project +++ b/org.flowerplatform.util/.project @@ -5,6 +5,11 @@ + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.jdt.core.javabuilder @@ -20,9 +25,17 @@ + + org.eclipse.wst.validation.validationbuilder + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature diff --git a/org.flowerplatform.util/.settings/org.eclipse.jdt.core.prefs b/org.flowerplatform.util/.settings/org.eclipse.jdt.core.prefs index 11f6e462..f287d53c 100644 --- a/org.flowerplatform.util/.settings/org.eclipse.jdt.core.prefs +++ b/org.flowerplatform.util/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.flowerplatform.util/.settings/org.eclipse.wst.common.component b/org.flowerplatform.util/.settings/org.eclipse.wst.common.component new file mode 100644 index 00000000..59d34069 --- /dev/null +++ b/org.flowerplatform.util/.settings/org.eclipse.wst.common.component @@ -0,0 +1,5 @@ + + + + + diff --git a/org.flowerplatform.util/.settings/org.eclipse.wst.common.project.facet.core.xml b/org.flowerplatform.util/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 00000000..7ba6051d --- /dev/null +++ b/org.flowerplatform.util/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.flowerplatform.util/src/META-INF/MANIFEST.MF b/org.flowerplatform.util/src/META-INF/MANIFEST.MF new file mode 100644 index 00000000..5e949512 --- /dev/null +++ b/org.flowerplatform.util/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/org.flowerplatform.util/src/org/flowerplatform/util/controller/AbstractController.java b/org.flowerplatform.util/src/org/flowerplatform/util/controller/AbstractController.java index 323c87ab..58f96fed 100644 --- a/org.flowerplatform.util/src/org/flowerplatform/util/controller/AbstractController.java +++ b/org.flowerplatform.util/src/org/flowerplatform/util/controller/AbstractController.java @@ -31,30 +31,32 @@ * * @author Cristian Spiescu */ -public abstract class AbstractController implements IController { +public abstract class AbstractController implements Comparable { /** * @see #getOrderIndex() */ private int orderIndex; - /* (non-Javadoc) - * @see org.flowerplatform.util.controller.IOrderedController#getOrderIndex() + /** + * For additive controllers, specifies the order. Lower values are invoked first. + * + *

+ * It's recommended to use big values e.g. 50 000, -100 000. So that new indexes can be + * added in the future. */ - @Override public int getOrderIndex() { return orderIndex; } - /* (non-Javadoc) - * @see org.flowerplatform.util.controller.IOrderedController#setOrderIndex(int) + /** + * @see #getOrderIndex() */ - @Override public void setOrderIndex(int orderIndex) { this.orderIndex = orderIndex; } - public IController setOrderIndexAs(int orderIndex) { + public AbstractController setOrderIndexAs(int orderIndex) { setOrderIndex(orderIndex); return this; } @@ -63,7 +65,7 @@ public IController setOrderIndexAs(int orderIndex) { * Needed to know how to sort the list of controllers. For additive controllers. */ @Override - public int compareTo(IController o) { + public int compareTo(AbstractController o) { return Integer.compare(getOrderIndex(), o.getOrderIndex()); } diff --git a/org.flowerplatform.util/src/org/flowerplatform/util/controller/IController.java b/org.flowerplatform.util/src/org/flowerplatform/util/controller/IController.java deleted file mode 100644 index e5e45840..00000000 --- a/org.flowerplatform.util/src/org/flowerplatform/util/controller/IController.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.flowerplatform.util.controller; - -public interface IController extends Comparable { - - /** - * For additive controllers, specifies the order. Lower values are invoked first. - * - *

- * It's recommended to use big values e.g. 50 000, -100 000. So that new indexes can be - * added in the future. - */ - int getOrderIndex(); - - /** - * @see #getOrderIndex() - */ - void setOrderIndex(int orderIndex); - -} \ No newline at end of file diff --git a/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptor.java b/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptor.java index 03542e84..72ffac76 100644 --- a/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptor.java +++ b/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptor.java @@ -104,13 +104,13 @@ public TypeDescriptor addCategory(String category) { * * @see #additiveControllers */ - protected Map> singleControllers = new HashMap>(); + protected Map> singleControllers = new HashMap>(); /** * @return For a given controller type, the single controller * (collected from this node type, as well as its categories OR from object's dynamic category providers). */ - public T getSingleController(String controllerType, Object object) { + public T getSingleController(String controllerType, Object object) { return getCachedSingleController(controllerType, object, true, true); } @@ -118,10 +118,10 @@ public T getSingleController(String controllerType, Obje * @return For a given controller type, the single controller (collected from this node type, as well as its categories). */ @SuppressWarnings("unchecked") - protected T getCachedSingleController(String controllerType, Object object, boolean includeDynamicCategoryProviders, boolean keepCached) { + protected T getCachedSingleController(String controllerType, Object object, boolean includeDynamicCategoryProviders, boolean keepCached) { getRegistry().configurable = false; - ControllerEntry entry = getSingleControllerEntry(controllerType); + ControllerEntry entry = getSingleControllerEntry(controllerType); if (entry.wasCached()) { // categories were processed before; return the controller return (T) entry.getCachedValue(); @@ -178,19 +178,19 @@ protected T getCachedSingleController(String controllerT * * @return this, cf. builder pattern. */ - public TypeDescriptor addSingleController(String type, IController controller) { + public TypeDescriptor addSingleController(String type, AbstractController controller) { if (!getRegistry().isConfigurable()) { throw new IllegalStateException("Trying to add a new single controller to a non-configurable registry"); } - ControllerEntry entry = getSingleControllerEntry(type); + ControllerEntry entry = getSingleControllerEntry(type); entry.setSelfValue(controller); return this; } - private ControllerEntry getSingleControllerEntry(String type) { - ControllerEntry entry = singleControllers.get(type); + private ControllerEntry getSingleControllerEntry(String type) { + ControllerEntry entry = singleControllers.get(type); if (entry == null) { - entry = new ControllerEntry(); + entry = new ControllerEntry(); singleControllers.put(type, entry); } return entry; @@ -214,10 +214,10 @@ private ControllerEntry getSingleControllerEntry(String type) { * * @see #singleControllers */ - protected Map>> additiveControllers = new HashMap>>(); + protected Map>> additiveControllers = new HashMap>>(); - public List getAdditiveControllers(String controllerType, Object object) { - return getCachedAdditiveControllers(controllerType, object, true, true); + public List getAdditiveControllers(String controllerType, Object object) { + return getCachedAdditiveControllers(controllerType, object, true, true); } /** @@ -225,10 +225,10 @@ public List getAdditiveControllers(String controllerT * (collected from this node type, as well as its categories AND from object's dynamic category providers). */ @SuppressWarnings("unchecked") - protected List getCachedAdditiveControllers(String controllerType, Object object, boolean includeDynamicCategoryProviders, boolean keepCached) { + protected List getCachedAdditiveControllers(String controllerType, Object object, boolean includeDynamicCategoryProviders, boolean keepCached) { getRegistry().configurable = false; - ControllerEntry> entry = getAdditiveControllersEntry(controllerType); + ControllerEntry> entry = getAdditiveControllersEntry(controllerType); if (entry.wasCached()) { // categories were processed before; return the controllers return (List) entry.getCachedValue(); @@ -276,20 +276,20 @@ protected List getCachedAdditiveControllers(String co * @return this, cf. builder pattern. */ @SuppressWarnings("unchecked") - public TypeDescriptor addAdditiveController(String type, IController controller) { + public TypeDescriptor addAdditiveController(String type, AbstractController controller) { if (!getRegistry().isConfigurable()) { throw new IllegalStateException("Trying to add a new additive controller to a non-configurable registry"); } - ControllerEntry> entry = getAdditiveControllersEntry(type); - ((List) entry.getSelfValue()).add(controller); + ControllerEntry> entry = getAdditiveControllersEntry(type); + ((List) entry.getSelfValue()).add(controller); return this; } - private ControllerEntry> getAdditiveControllersEntry(String type) { - ControllerEntry> entry = additiveControllers.get(type); + private ControllerEntry> getAdditiveControllersEntry(String type) { + ControllerEntry> entry = additiveControllers.get(type); if (entry == null) { - entry = new ControllerEntry>(); - entry.setSelfValue(new ArrayList()); + entry = new ControllerEntry>(); + entry.setSelfValue(new ArrayList()); additiveControllers.put(type, entry); } return entry; diff --git a/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptorDebugWrapper.java b/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptorDebugWrapper.java index efe8526d..901c4112 100644 --- a/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptorDebugWrapper.java +++ b/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptorDebugWrapper.java @@ -29,11 +29,11 @@ public boolean isCachedSingleController(String type) { return descriptor.singleControllers.get(type).wasCached(); } - public Object getSelfSingleController(String type) { + public AbstractController getSelfSingleController(String type) { return descriptor.singleControllers.get(type).getSelfValue(); } - public Object getCachedSingleController(String type) { + public AbstractController getCachedSingleController(String type) { return descriptor.getCachedSingleController(type, null, false, false); } @@ -45,11 +45,11 @@ public boolean isCachedAdditiveController(String type) { return descriptor.additiveControllers.get(type).wasCached(); } - public List getSelfAdditiveControllers(String type) { + public List getSelfAdditiveControllers(String type) { return descriptor.additiveControllers.get(type).getSelfValue(); } - public List getCachedAdditiveControllers(String type) { + public List getCachedAdditiveControllers(String type) { return descriptor.getCachedAdditiveControllers(type, null, false, false); } diff --git a/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptorRegistry.java b/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptorRegistry.java index 749d4b6c..7f42c511 100644 --- a/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptorRegistry.java +++ b/org.flowerplatform.util/src/org/flowerplatform/util/controller/TypeDescriptorRegistry.java @@ -124,16 +124,16 @@ public List getTypeDescriptorsRemote() { TypeDescriptorRemote remote = new TypeDescriptorRemote(descriptor.getType(), descriptor.getCategories()); // filter the single controllers map - for (Entry> entry : descriptor.singleControllers.entrySet()) { + for (Entry> entry : descriptor.singleControllers.entrySet()) { if (entry.getValue().getSelfValue() instanceof IDescriptor) { remote.getSingleControllers().put(entry.getKey(), (IDescriptor) entry.getValue().getSelfValue()); } } // filter the additive controlers map - for (Entry>> entry : descriptor.additiveControllers.entrySet()) { + for (Entry>> entry : descriptor.additiveControllers.entrySet()) { List additiveControllers = new ArrayList(); - for (IController abstractController : entry.getValue().getSelfValue()) { + for (AbstractController abstractController : entry.getValue().getSelfValue()) { if (abstractController instanceof IDescriptor) { additiveControllers.add((IDescriptor) abstractController); } diff --git a/org.flowerplatform.util/src/org/flowerplatform/util/servlet/PublicResourcesServlet.java b/org.flowerplatform.util/src/org/flowerplatform/util/servlet/PublicResourcesServlet.java index 866a2795..01b69565 100644 --- a/org.flowerplatform.util/src/org/flowerplatform/util/servlet/PublicResourcesServlet.java +++ b/org.flowerplatform.util/src/org/flowerplatform/util/servlet/PublicResourcesServlet.java @@ -20,6 +20,7 @@ import java.io.BufferedInputStream; import java.io.Closeable; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -55,7 +56,7 @@ public class PublicResourcesServlet extends ResourcesServlet { private static final long serialVersionUID = 1L; private static final int DEFAULT_BUFFER_SIZE = 10240; // 10KB. - + private static void close(Closeable resource) { if (resource != null) { try { @@ -192,7 +193,12 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t } } - requestedFile = "platform:/plugin" + plugin + "/" + UtilConstants.PUBLIC_RESOURCES_DIR + file; +// requestedFile = "platform:/plugin" + plugin + "/" + UtilConstants.PUBLIC_RESOURCES_DIR + file; + requestedFile = plugin + "/" + prefix + file; + if (useRealPath) { + requestedFile = getServletContext().getRealPath(requestedFile); + } + requestedFile = protocol + requestedFile; // Get content type by filename from the file or file inside zip String contentType = getServletContext().getMimeType(fileInsideZipArchive != null ? fileInsideZipArchive : file); diff --git a/org.flowerplatform.util/src/org/flowerplatform/util/servlet/ResourcesServlet.java b/org.flowerplatform.util/src/org/flowerplatform/util/servlet/ResourcesServlet.java index ed2e0a9e..f170e7f4 100644 --- a/org.flowerplatform.util/src/org/flowerplatform/util/servlet/ResourcesServlet.java +++ b/org.flowerplatform.util/src/org/flowerplatform/util/servlet/ResourcesServlet.java @@ -26,6 +26,18 @@ public abstract class ResourcesServlet extends HttpServlet { private static final Logger logger = LoggerFactory.getLogger(ResourcesServlet.class); protected boolean useFilesFromTemporaryDirectory = false; + + protected static final String PROTOCOL = "protocol"; + + protected static final String PREFIX = "prefix"; + + protected static final String USE_REAL_PATH = "useRealPath"; + + protected String protocol; + + protected String prefix; + + protected boolean useRealPath; /** * @author Cristina Constantinescu @@ -36,6 +48,10 @@ public void init(ServletConfig config) throws ServletException { ServletUtils.addAllAdditionalAttributesToServletContext(getServletContext()); useFilesFromTemporaryDirectory = Boolean.valueOf((String) getServletContext().getAttribute(ServletUtils.PROP_USE_FILES_FROM_TEMPORARY_DIRECTORY)); + + protocol = config.getInitParameter(PROTOCOL); + prefix = config.getInitParameter(PREFIX); + useRealPath = Boolean.parseBoolean(config.getInitParameter(USE_REAL_PATH)); } protected void send404(HttpServletRequest request, HttpServletResponse response) {