From 4fbea6ef7031d4299f89463dfce6bee1bbc6db77 Mon Sep 17 00:00:00 2001 From: eleogas Date: Mon, 28 Sep 2015 12:58:58 +0200 Subject: [PATCH 01/29] Custom nature and builder --- .../feature.xml | 135 ---------- .../META-INF/MANIFEST.MF | 6 +- eu.scasefp7.eclipse.core.ui/icons/sample.gif | Bin 0 -> 983 bytes eu.scasefp7.eclipse.core.ui/plugin.xml | 138 +++++++++- .../builder/AddRemoveSCaseNatureHandler.java | 77 ++++++ .../eclipse/core/ui/builder/SCaseBuilder.java | 231 +++++++++++++++++ .../eclipse/core/ui/builder/SCaseNature.java | 74 ++++++ .../preferences/DomainBoldLabelProvider.java | 2 +- .../eclipse/core/ui/views/Dashboard.java | 17 +- .../ui/wizards/ProjectDomainWizardPage.java | 240 ++++++++++++++++++ .../ui/wizards/ScaseProjectNewWizard.java | 93 +++++++ .../core/ui/wizards/ScaseProjectSupport.java | 108 ++++++++ eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF | 3 +- eu.scasefp7.eclipse.core/plugin.xml | 12 +- pom.xml | 31 ++- target-platform/target-platform.target | 8 +- 16 files changed, 1027 insertions(+), 148 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/icons/sample.gif create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/AddRemoveSCaseNatureHandler.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseNature.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ProjectDomainWizardPage.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectNewWizard.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectSupport.java diff --git a/eu.scasefp7.eclipse.core.dependencies.feature/feature.xml b/eu.scasefp7.eclipse.core.dependencies.feature/feature.xml index 0f300d6..2e83302 100644 --- a/eu.scasefp7.eclipse.core.dependencies.feature/feature.xml +++ b/eu.scasefp7.eclipse.core.dependencies.feature/feature.xml @@ -264,141 +264,6 @@ version="0.0.0" unpack="false"/> - - END OF TERMS AND CONDITIONS - - - - - - - - - - - - - - - - - - - - - - - - - - END OF TERMS AND CONDITIONS - - - - - - - - - - - - - - - - - - - - - - 9*?jxd%4aX0yzy`dymabz zw#(eg=y~&N&n)dZv2xzduG}5lraiApo3(c4*{Ylg5#|$JO_EEZ<^|a2`Z*=9ns7DV zy=TR&gYw*7f%auV?ip3tvjRPmcdoho{K?x$_vR?C#t5&<;~V}S*>OMCr>h}%%bLZ9 zmo3`hYEwTICo-TTCZwgTsC&VjZRgJ1eE#fBa^%9R zmmfWS@;bnyJ27HWY}kxYzv(Hl>yu;FCPlAEh+34Muq-8Rb6C)<8qA3{r2e5 z`$vyngh#H=FWlqqvnapfc5%(!sQ4v?r7J61-&eJNEN^;KTK}T7{#i-gJh%G*9vcYdwv_*~xdw!Gz4Va?T!sXyyF@8?w<>X`X=#j%uHV4GRvj@+tE@ zQ%F!a)GKcn^~8abN>4la1UNXVL;{ZWi)lEwyeatDu%Lr6;aASiLrXXW zQm# - + @@ -94,7 +94,7 @@ @@ -130,6 +130,10 @@ + + @@ -162,5 +166,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/AddRemoveSCaseNatureHandler.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/AddRemoveSCaseNatureHandler.java new file mode 100644 index 0000000..a592f68 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/AddRemoveSCaseNatureHandler.java @@ -0,0 +1,77 @@ +package eu.scasefp7.eclipse.core.ui.builder; + +import java.util.Iterator; + +import org.eclipse.core.commands.*; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.handlers.HandlerUtil; + + +public class AddRemoveSCaseNatureHandler extends AbstractHandler { + +public Object execute(ExecutionEvent event) throws ExecutionException { + + ISelection selection = HandlerUtil.getCurrentSelection(event); + // + if (selection instanceof IStructuredSelection) { + for (Iterator it = ((IStructuredSelection) selection).iterator(); it + .hasNext();) { + Object element = it.next(); + IProject project = null; + if (element instanceof IProject) { + project = (IProject) element; + } else if (element instanceof IAdaptable) { + project = (IProject) ((IAdaptable) element) + .getAdapter(IProject.class); + } + if (project != null) { + try { + toggleNature(project); + } catch (CoreException e) { + //TODO log something + throw new ExecutionException("Failed to toggle nature", + e); + } + } + } + } + + return null; + } + +/** + * Toggles sample nature on a project + * + * @param project + * to have sample nature added or removed + */ +private void toggleNature(IProject project) throws CoreException { + IProjectDescription description = project.getDescription(); + String[] natures = description.getNatureIds(); + + for (int i = 0; i < natures.length; ++i) { + if (SCaseNature.NATURE_ID.equals(natures[i])) { + // Remove the nature + String[] newNatures = new String[natures.length - 1]; + System.arraycopy(natures, 0, newNatures, 0, i); + System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1); + description.setNatureIds(newNatures); + project.setDescription(description, null); + return; + } + } + + // Add the nature + String[] newNatures = new String[natures.length + 1]; + System.arraycopy(natures, 0, newNatures, 0, natures.length); + newNatures[natures.length] = SCaseNature.NATURE_ID; + description.setNatureIds(newNatures); + project.setDescription(description, null); +} + +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java new file mode 100644 index 0000000..c785ef7 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java @@ -0,0 +1,231 @@ +package eu.scasefp7.eclipse.core.ui.builder; + + +import java.util.Map; +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.NotEnabledException; +import org.eclipse.core.commands.NotHandledException; +import org.eclipse.core.commands.Parameterization; +import org.eclipse.core.commands.ParameterizedCommand; +import org.eclipse.core.commands.common.NotDefinedException; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceDeltaVisitor; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.commands.ICommandService; +import org.eclipse.ui.handlers.IHandlerService; +import org.eclipse.ui.services.IServiceLocator; + + + + +public class SCaseBuilder extends IncrementalProjectBuilder { + + + class SampleDeltaVisitor implements IResourceDeltaVisitor { + + public boolean visit(IResourceDelta delta) throws CoreException { + //IResource resource = delta.getResource(); + switch (delta.getKind()) { + case IResourceDelta.ADDED: + break; + case IResourceDelta.REMOVED: + break; + case IResourceDelta.CHANGED: + break; + } + + return true; + } +} + + + + class SampleResourceVisitor implements IResourceVisitor { + boolean fileExsists = false; + int fileCount = 0; + IFile firstXmlFile; + public boolean visit(IResource resource) { + boolean other = checkXML(resource); + + if (resource instanceof IFile && resource.getName().endsWith(".rqs")) + executeCommand("eu.scasefp7.eclipse.reqeditor.commands.exportToOntology", resource.getFullPath().toString()); + + + if (resource instanceof IFile && resource.getName().endsWith(".sbd")) + executeCommand("eu.scasefp7.eclipse.storyboards.commands.exportToOntology", resource.getFullPath().toString()); + + + if(fileExsists && other){ + if(fileCount < 2) + addMarker(firstXmlFile, "The project must contain only one .xml file", 1, IMarker.SEVERITY_ERROR); + addMarker((IFile) resource, "The project must contain only one .xml file", 1, IMarker.SEVERITY_ERROR); + fileCount++; + } + + if(!fileExsists && other){ + fileCount++; + fileExsists = true; + firstXmlFile = (IFile)resource; + } + + + //return true to continue visiting children. + return true; + } + } + + boolean checkXML(IResource resource) { + if (resource instanceof IFile && resource.getName().endsWith(".xml")) { + return true; + } + return false; + } + + + + + + protected void executeCommand(String commandId) { + // Obtain IServiceLocator implementer, e.g. from PlatformUI.getWorkbench(): + IServiceLocator serviceLocator = PlatformUI.getWorkbench(); + // or a site from within a editor or view: + // IServiceLocator serviceLocator = getSite(); + + IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class); + try { + // Execute commmand via its ID + + handlerService.executeCommand(commandId, null); + } catch (ExecutionException | NotDefinedException | + NotEnabledException | NotHandledException ex) { + // Replace with real-world exception handling + ex.printStackTrace(); + } + } + + protected void executeCommand(String commandId, String fileName) { + IServiceLocator serviceLocator = PlatformUI.getWorkbench(); + + ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class); + IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class); + + + try { + Command command = commandService.getCommand(commandId); + + Parameterization[] params = new Parameterization[] { new Parameterization( + command.getParameter("fileName"), (String) fileName) }; + + ParameterizedCommand parametrizedCommand = new ParameterizedCommand(command , params); + + handlerService.executeCommand(parametrizedCommand, null); + + + } catch (ExecutionException | NotDefinedException | + NotEnabledException | NotHandledException ex) { + // Replace with real-world exception handling + ex.printStackTrace(); + } + + } + + void linkOnthologies(){ + + + + } + + + public static final String BUILDER_ID = "eu.scasefp7.eclipse.core.ui.scaseBuilder"; + + private static final String MARKER_TYPE = "eu.scasefp7.eclipse.core.ui.rqsProblem"; + + + private void addMarker(IFile file, String message, int lineNumber, + int severity) { + try { + IMarker marker = file.createMarker(MARKER_TYPE); + marker.setAttribute(IMarker.MESSAGE, message); + marker.setAttribute(IMarker.SEVERITY, severity); + if (lineNumber == -1) { + lineNumber = 1; + } + marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); + } catch (CoreException e) { + } + } + + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.internal.events.InternalBuilder#build(int, + * java.util.Map, org.eclipse.core.runtime.IProgressMonitor) + */ + protected IProject[] build(int kind, Map args, IProgressMonitor monitor) + throws CoreException { + if (kind == FULL_BUILD) { + fullBuild(monitor); + } else { + IResourceDelta delta = getDelta(getProject()); + if (delta == null) { + fullBuild(monitor); + } else { + incrementalBuild(delta, monitor); + } + } + return null; + } + + protected void clean(IProgressMonitor monitor) throws CoreException { + // delete markers set and files created + getProject().deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE); + } + + + + private void deleteMarkers(IFile file) { + try { + file.deleteMarkers(MARKER_TYPE, false, IResource.DEPTH_ZERO); + } catch (CoreException ce) { + } + } + + + + + protected void fullBuild(final IProgressMonitor monitor) + throws CoreException { + try { + clean(monitor); + getProject().accept(new SampleResourceVisitor()); + executeCommand("eu.scasefp7.eclipse.core.commands.linkOntologies"); + + } catch (CoreException e) { + } + } + + + + protected void incrementalBuild(IResourceDelta delta, + IProgressMonitor monitor) throws CoreException { + try { + clean(monitor); + //delta.accept(new SampleDeltaVisitor()); + getProject().accept(new SampleResourceVisitor()); + executeCommand("eu.scasefp7.eclipse.core.commands.linkOntologies"); + } catch (CoreException e) { + System.out.println(e); + } + } + +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseNature.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseNature.java new file mode 100644 index 0000000..835ae49 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseNature.java @@ -0,0 +1,74 @@ +package eu.scasefp7.eclipse.core.ui.builder; + +import org.eclipse.core.resources.ICommand; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.runtime.CoreException; + + +public class SCaseNature implements IProjectNature { + + public static final String NATURE_ID = "eu.scasefp7.eclipse.core.ui.scaseNature"; + + private IProject project; + + @Override + public void configure() throws CoreException { + IProjectDescription desc = project.getDescription(); + ICommand[] commands = desc.getBuildSpec(); + + for (int i = 0; i < commands.length; ++i) { + if (commands[i].getBuilderName().equals(SCaseBuilder.BUILDER_ID)) { + return; + } + } + + ICommand[] newCommands = new ICommand[commands.length + 1]; + System.arraycopy(commands, 0, newCommands, 0, commands.length); + ICommand command = desc.newCommand(); + command.setBuilderName(SCaseBuilder.BUILDER_ID); + newCommands[newCommands.length - 1] = command; + desc.setBuildSpec(newCommands); + project.setDescription(desc, null); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.resources.IProjectNature#deconfigure() + */ + public void deconfigure() throws CoreException { + IProjectDescription description = getProject().getDescription(); + ICommand[] commands = description.getBuildSpec(); + for (int i = 0; i < commands.length; ++i) { + if (commands[i].getBuilderName().equals(SCaseBuilder.BUILDER_ID)) { + ICommand[] newCommands = new ICommand[commands.length - 1]; + System.arraycopy(commands, 0, newCommands, 0, i); + System.arraycopy(commands, i + 1, newCommands, i, + commands.length - i - 1); + description.setBuildSpec(newCommands); + project.setDescription(description, null); + return; + } + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.resources.IProjectNature#getProject() + */ + public IProject getProject() { + return project; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject) + */ + public void setProject(IProject project) { + this.project = project; + } +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/DomainBoldLabelProvider.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/DomainBoldLabelProvider.java index 376fae1..aa156c7 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/DomainBoldLabelProvider.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/DomainBoldLabelProvider.java @@ -9,7 +9,7 @@ public class DomainBoldLabelProvider extends DomainLabelProvider implements IFon private FilteredTree filterTree; private PatternFilter filterForBoldElements; - DomainBoldLabelProvider(FilteredTree filterTree) { + public DomainBoldLabelProvider(FilteredTree filterTree) { this.filterTree = filterTree; filterForBoldElements = filterTree.getPatternFilter(); } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java index 0ba1a0e..f18f314 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java @@ -281,8 +281,21 @@ private void setupCommandListener(final Control control, String commandId) { ICommandListener listener = new ICommandListener() { @Override public void commandChanged(CommandEvent cmdEvent) { - if(cmdEvent.isDefinedChanged() || cmdEvent.isEnabledChanged()) { - control.setEnabled(command.isDefined() && command.isEnabled()); + if(cmdEvent.isDefinedChanged() || cmdEvent.isEnabledChanged() || cmdEvent.isHandledChanged()) { + Object handler = command.getHandler(); + boolean defined = command.isDefined(); + boolean enabled = command.isEnabled(); + boolean handled = command.isHandled(); + control.setEnabled(command.isDefined() && command.isEnabled() && command.isHandled()); + + System.out.println(">>>>>>>>>>> IN LISTENER"); + System.out.println(cmdEvent); + System.out.println("commandId " + command.getId()); + System.out.println("defined " + defined); + System.out.println("enabled " + enabled); + System.out.println("handled " + handled); + System.out.println("control on " + control.isEnabled()); + System.out.println(">>>>>>>>>>> OUT LISTENER"); } } }; diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ProjectDomainWizardPage.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ProjectDomainWizardPage.java new file mode 100644 index 0000000..1dffbcc --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ProjectDomainWizardPage.java @@ -0,0 +1,240 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + + + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.FilteredTree; +import org.eclipse.ui.dialogs.PatternFilter; + +import eu.scasefp7.eclipse.core.ui.preferences.DomainBoldLabelProvider; +import eu.scasefp7.eclipse.core.ui.preferences.DomainContentProvider; +import eu.scasefp7.eclipse.core.ui.preferences.internal.DomainEntry; +import eu.scasefp7.eclipse.core.ui.preferences.internal.IProjectDomains; +import eu.scasefp7.eclipse.core.ui.preferences.DomainBoldLabelProvider; + +public class ProjectDomainWizardPage extends WizardPage { + + private static final String DOMAIN_PROPERTY = "eu.scasefp7.eclipse.core.projectDomain"; + private static final int DOMAIN_DEFAULT = -1; + + private Label domainLabel; + + private boolean locked; + + private Composite composite; + private Composite cmpLabels; + + protected DomainFilteredTree filteredTree; + protected TreeViewer treeViewer; + + protected ProjectDomainWizardPage(String pageName) { + super(pageName); + + } + public Label getDomainLabel(){ + + return domainLabel; + + } + @Override + public void createControl(Composite parent) { + initializeDialogUnits(parent); + + composite = new Composite(parent, SWT.NONE); + GridLayout gl_composite = new GridLayout(); + gl_composite.marginWidth = 0; + gl_composite.marginHeight = 0; + composite.setLayout(gl_composite); + GridData data = new GridData(GridData.FILL); + data.grabExcessHorizontalSpace = true; + composite.setLayoutData(data); + + int domainId = DOMAIN_DEFAULT; + + // Add the domain label + createDomainLabel(composite, (domainId != DOMAIN_DEFAULT) ? domainId : null); + + // Add tree + treeViewer = createTreeViewer(composite); + + // Load the saved property + selectSavedItem(); + + setControl(composite); + + } + + private void createDomainLabel(Composite parent, Object data) { + cmpLabels = new Composite(parent, SWT.NONE); + GridLayout gl_cmpLabels = new GridLayout(2, false); + gl_cmpLabels.marginWidth = 0; + cmpLabels.setLayout(gl_cmpLabels); + cmpLabels.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + + // Add label + Label noteLabel = new Label(cmpLabels, SWT.NONE); + noteLabel.setText("Project do&main:"); + + domainLabel = new Label(cmpLabels, SWT.NONE); + domainLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + domainLabel.setText("(select a domain)"); + domainLabel.setData(data); + } + + + + protected class DomainFilteredTree extends FilteredTree { + private ViewerFilter viewerFilter; + + DomainFilteredTree(Composite parent, int treeStyle, PatternFilter filter) { + super(parent, treeStyle, filter, true); + } + + protected void addFilter(ViewerFilter filter) { + viewerFilter = filter; + getViewer().addFilter(filter); + + if (filterText != null) { + setFilterText("type filter text"); + textChanged(); + } + } + + protected void updateToolbar(boolean visible) { + super.updateToolbar((viewerFilter != null) || (visible)); + } + + protected void clearText() { + setFilterText(""); + + if ((!locked) && (viewerFilter != null)) { + getViewer().removeFilter(viewerFilter); + viewerFilter = null; + } + textChanged(); + } + } + + protected TreeViewer createTreeViewer(Composite parent) { + TreeViewer tree; + + filteredTree = new DomainFilteredTree(parent, SWT.FILL, new PatternFilter()); + filteredTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); +// horizontalIndent = 7; + filteredTree.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); + + tree = filteredTree.getViewer(); + + setContentAndLabelProviders(tree); + tree.setInput(IProjectDomains.PROJECT_DOMAINS); + + tree.addSelectionChangedListener(new ISelectionChangedListener() { + + public void selectionChanged(SelectionChangedEvent event) { + handleTreeSelectionChanged(event); + } + + }); + + //super.addListeners(tree); + return tree; + } + + private DomainEntry findDomainById(DomainEntry[] domains, int domainId) { + for (DomainEntry de : domains) { + if (de.getId() == domainId) { + return de; + } + if(de.hasChildren()) { + for (DomainEntry child : de.getChildren()) { + if(child.getId() == domainId) { + return child; + } + } + } + } + return null; + } + + protected DomainEntry getSingleSelection(ISelection selection) + { + if (!selection.isEmpty()) { + IStructuredSelection structured = (IStructuredSelection)selection; + if ((structured.getFirstElement() instanceof DomainEntry)) { + return (DomainEntry)structured.getFirstElement(); + } + } + return null; + } + + protected void handleTreeSelectionChanged(SelectionChangedEvent event) { + DomainEntry de = getSingleSelection(event.getSelection()); + updateDomainLabel(de); + } + + + + + protected void selectSavedItem() + { + DomainEntry[] domains = IProjectDomains.PROJECT_DOMAINS; + treeViewer.setInput(domains); + + int domainId = DOMAIN_DEFAULT; + + DomainEntry domain = findDomainById(domains, domainId); + if (domain != null) { + treeViewer.setSelection(new StructuredSelection(domain), true); + } + + // Set focus to tree or the filter control + if (treeViewer.getTree().getItemCount() > 1) { + Text filterText = filteredTree.getFilterControl(); + if (filterText != null) { + filterText.setFocus(); + } + } else { + treeViewer.getControl().setFocus(); + } + } + + protected void setContentAndLabelProviders(TreeViewer treeViewer) + { + treeViewer.setLabelProvider(new DomainBoldLabelProvider(filteredTree )); + treeViewer.setContentProvider(new DomainContentProvider()); + } + + private void updateDomainLabel(DomainEntry domain) { + if(domain == null) + return; + + DomainEntry parent = domain.getParent(); + + if(parent != null) { + String text = parent.getName() + "/" + domain.getName(); + + // Escape text for SWT + domainLabel.setText(text.replaceAll("&", "&&")); //$NON-NLS-1$ //$NON-NLS-2$ + domainLabel.setData(domain); + } + } + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectNewWizard.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectNewWizard.java new file mode 100644 index 0000000..83f2b8c --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectNewWizard.java @@ -0,0 +1,93 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + +import java.awt.Label; +import java.net.URI; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; + +import eu.scasefp7.eclipse.core.ui.preferences.ProjectDomainPropertyPage; +import eu.scasefp7.eclipse.core.ui.preferences.internal.DomainEntry; +import eu.scasefp7.eclipse.core.ui.wizards.ProjectDomainWizardPage; + +public class ScaseProjectNewWizard extends Wizard implements INewWizard, IExecutableExtension { + + private WizardNewProjectCreationPage _pageOne; + private ProjectDomainWizardPage _pageTwo; + private static final String PAGE_NAME = "Custom Plug-in Project Wizard"; + private static final String WIZARD_NAME = "New S-Case Project"; + //private static final String WIZARD_NAME = "New Custom Plug-in Project"; + + public ScaseProjectNewWizard() { + setWindowTitle(WIZARD_NAME); + } + + + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + // TODO Auto-generated method stub + + } + @Override + public void addPages() { + super.addPages(); + + _pageOne = new WizardNewProjectCreationPage(PAGE_NAME); + _pageOne.setTitle("Create a S-Case Project"); + _pageOne.setDescription("Enter project name."); + + _pageTwo = new ProjectDomainWizardPage("S-Case project domain"); + _pageTwo.setTitle("Select project domain"); + + addPage(_pageOne); + addPage(_pageTwo); + } + + @Override + public boolean performFinish() { + + String name = _pageOne.getProjectName(); + URI location = null; + if (!_pageOne.useDefaults()) { + location = _pageOne.getLocationURI(); + } // else location == null + + IResource res = ScaseProjectSupport.createProject(name, location); + int k; + org.eclipse.swt.widgets.Label domainLabel = _pageTwo.getDomainLabel(); + DomainEntry de = (DomainEntry) domainLabel.getData(); + if (de == null) + k = -1; + else + k = de.getId(); + try { + res.setPersistentProperty(new QualifiedName("", "eu.scasefp7.eclipse.core.projectDomain"), Integer.toString(k)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return true; + } + + + + + @Override + public void setInitializationData(IConfigurationElement config, + String propertyName, Object data) throws CoreException { + // TODO Auto-generated method stub + + } + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectSupport.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectSupport.java new file mode 100644 index 0000000..7a4781f --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectSupport.java @@ -0,0 +1,108 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + +import java.net.URI; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +import eu.scasefp7.eclipse.core.ui.builder.SCaseNature; + +public class ScaseProjectSupport { + + public static IProject createProject(String projectName, URI location) { + Assert.isNotNull(projectName); + Assert.isTrue(projectName.trim().length() > 0); + + + IProject project = createBaseProject(projectName, location); + try { + addNature(project); + //Addition of new folders to project + /* + String[] paths = { "parent/child1-1/child2", "parent/child1-2/child2/child3" }; //$NON-NLS-1$ //$NON-NLS-2$ + addToProjectStructure(project, paths);*/ + } catch (CoreException e) { + e.printStackTrace(); + project = null; + } + + return project; + } + + /** + * Create a basic project. + * + * @param location + * @param projectName + */ + private static IProject createBaseProject(String projectName, URI location) { + // it is acceptable to use the ResourcesPlugin class + IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + + if (!newProject.exists()) { + URI projectLocation = location; + IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName()); + if (location != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location)) { + projectLocation = null; + } + + desc.setLocationURI(projectLocation); + try { + newProject.create(desc, null); + if (!newProject.isOpen()) { + newProject.open(null); + } + } catch (CoreException e) { + e.printStackTrace(); + } + } + + return newProject; + } + + private static void createFolder(IFolder folder) throws CoreException { + IContainer parent = folder.getParent(); + if (parent instanceof IFolder) { + createFolder((IFolder) parent); + } + if (!folder.exists()) { + folder.create(false, true, null); + } + } + + /** + * Create a folder structure with a parent root, overlay, and a few child + * folders. + * + * @param newProject + * @param paths + * @throws CoreException + */ + private static void addToProjectStructure(IProject newProject, String[] paths) throws CoreException { + for (String path : paths) { + IFolder etcFolders = newProject.getFolder(path); + createFolder(etcFolders); + } + } + + private static void addNature(IProject project) throws CoreException { + if (!project.hasNature(SCaseNature.NATURE_ID)) { + IProjectDescription description = project.getDescription(); + String[] prevNatures = description.getNatureIds(); + String[] newNatures = new String[prevNatures.length + 1]; + System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); + newNatures[prevNatures.length] = SCaseNature.NATURE_ID; + description.setNatureIds(newNatures); + + IProgressMonitor monitor = null; + project.setDescription(description, monitor); + } + } + +} diff --git a/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF index 6b3bd8b..05f8246 100644 --- a/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF @@ -8,7 +8,8 @@ Require-Bundle: org.eclipse.ui.workbench, org.eclipse.core.runtime, org.eclipse.core.commands, org.eclipse.jface, - org.eclipse.core.resources + org.eclipse.core.resources, + org.eclipse.ui Bundle-ClassPath: . Export-Package: eu.scasefp7.eclipse.core, eu.scasefp7.eclipse.core.ontology diff --git a/eu.scasefp7.eclipse.core/plugin.xml b/eu.scasefp7.eclipse.core/plugin.xml index 5e5f381..3b8435b 100644 --- a/eu.scasefp7.eclipse.core/plugin.xml +++ b/eu.scasefp7.eclipse.core/plugin.xml @@ -5,6 +5,16 @@ + + + + - + diff --git a/pom.xml b/pom.xml index 8348e9f..2b5b76c 100755 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,36 @@ true - + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.jacoco + + jacoco-maven-plugin + + + [0.7.2.201409121644,) + + + prepare-agent + + + + + + + + + + + diff --git a/target-platform/target-platform.target b/target-platform/target-platform.target index 2c74791..85e340d 100644 --- a/target-platform/target-platform.target +++ b/target-platform/target-platform.target @@ -1,14 +1,14 @@ - + - - + + - + From b3896383e7619ee98e1dc2c5927a95cd8bd68d94 Mon Sep 17 00:00:00 2001 From: eleogas Date: Thu, 22 Oct 2015 09:43:43 +0200 Subject: [PATCH 02/29] Updated New project wizard --- .../preferences/ProjectDomainPropertyPage.java | 8 ++++++-- .../core/ui/wizards/ScaseProjectNewWizard.java | 17 ++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ProjectDomainPropertyPage.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ProjectDomainPropertyPage.java index 3c1afa3..66f7782 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ProjectDomainPropertyPage.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ProjectDomainPropertyPage.java @@ -150,7 +150,7 @@ private DomainEntry findDomainById(DomainEntry[] domains, int domainId) { } - private void createDomainLabel(Composite parent, Object data) { + protected void createDomainLabel(Composite parent, Object data) { cmpLabels = new Composite(parent, SWT.NONE); GridLayout gl_cmpLabels = new GridLayout(2, false); gl_cmpLabels.marginWidth = 0; @@ -218,7 +218,11 @@ public void selectionChanged(SelectionChangedEvent event) { //super.addListeners(tree); return tree; } - + public Label getDomainLabel(){ + + return domainLabel; + + } protected DomainEntry getSingleSelection(ISelection selection) { if (!selection.isEmpty()) { diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectNewWizard.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectNewWizard.java index 83f2b8c..ba32f14 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectNewWizard.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectNewWizard.java @@ -1,37 +1,34 @@ package eu.scasefp7.eclipse.core.ui.wizards; -import java.awt.Label; -import java.net.URI; +import java.net.URI; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExecutableExtension; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.Wizard; import org.eclipse.ui.INewWizard; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; -import eu.scasefp7.eclipse.core.ui.preferences.ProjectDomainPropertyPage; +import eu.scasefp7.eclipse.core.ui.preferences.PropertyWizardPage; import eu.scasefp7.eclipse.core.ui.preferences.internal.DomainEntry; -import eu.scasefp7.eclipse.core.ui.wizards.ProjectDomainWizardPage; + + public class ScaseProjectNewWizard extends Wizard implements INewWizard, IExecutableExtension { private WizardNewProjectCreationPage _pageOne; - private ProjectDomainWizardPage _pageTwo; + private PropertyWizardPage _pageTwo; private static final String PAGE_NAME = "Custom Plug-in Project Wizard"; private static final String WIZARD_NAME = "New S-Case Project"; - //private static final String WIZARD_NAME = "New Custom Plug-in Project"; public ScaseProjectNewWizard() { setWindowTitle(WIZARD_NAME); } - @Override public void init(IWorkbench workbench, IStructuredSelection selection) { @@ -46,7 +43,7 @@ public void addPages() { _pageOne.setTitle("Create a S-Case Project"); _pageOne.setDescription("Enter project name."); - _pageTwo = new ProjectDomainWizardPage("S-Case project domain"); + _pageTwo = new PropertyWizardPage("S-Case project domain"); _pageTwo.setTitle("Select project domain"); addPage(_pageOne); @@ -81,8 +78,6 @@ public boolean performFinish() { } - - @Override public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { From 1c0af227a19e491ab6241f7373e7a41123fa8c3f Mon Sep 17 00:00:00 2001 From: eleogas Date: Thu, 22 Oct 2015 09:47:51 +0200 Subject: [PATCH 03/29] New property wizard page --- .../ui/preferences/PropertyWizardPage.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PropertyWizardPage.java diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PropertyWizardPage.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PropertyWizardPage.java new file mode 100644 index 0000000..43d08b8 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PropertyWizardPage.java @@ -0,0 +1,52 @@ +package eu.scasefp7.eclipse.core.ui.preferences; + + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + + +public class PropertyWizardPage extends WizardPage { + ProjectDomainPropertyPage propPage; + Composite composite; + private static final int DOMAIN_DEFAULT = -1; + + + public PropertyWizardPage(String pageName) { + super(pageName); + propPage = new ProjectDomainPropertyPage(); + } + + +@Override + public void createControl(Composite parent) { + composite = new Composite(parent, SWT.NONE); + GridLayout gl_composite = new GridLayout(); + gl_composite.marginWidth = 0; + gl_composite.marginHeight = 0; + composite.setLayout(gl_composite); + GridData data = new GridData(GridData.FILL); + data.grabExcessHorizontalSpace = true; + composite.setLayoutData(data); + + int domainId = DOMAIN_DEFAULT; + + // Add the domain label + propPage.createDomainLabel(composite, (domainId != DOMAIN_DEFAULT) ? domainId : null); + + // Add tree + propPage.createTreeViewer(composite); + + setControl(composite); + } + + + public Label getDomainLabel(){ + return propPage.getDomainLabel(); + } + + +} From fa831668e167f6f4b5732bc6a2591f504743d26b Mon Sep 17 00:00:00 2001 From: eleogas Date: Mon, 2 Nov 2015 12:57:49 +0100 Subject: [PATCH 04/29] Navigator --- .../META-INF/MANIFEST.MF | 4 +- .../icons/artefact-text.png | Bin 0 -> 338 bytes .../icons/artefact.png | Bin 0 -> 384 bytes eu.scasefp7.eclipse.core.ui/icons/sample.gif | Bin 983 -> 0 bytes eu.scasefp7.eclipse.core.ui/plugin.xml | 100 ++++++ .../ui/navigator/ArtefactContentProvider.java | 200 +++++++++++ .../core/ui/navigator/ArtefactGroup.java | 43 +++ .../ui/navigator/ArtefactLabelProvider.java | 47 +++ .../core/ui/navigator/ArtefactSorter.java | 23 ++ .../core/ui/navigator/BaseArtefact.java | 34 ++ .../eclipse/core/ui/navigator/IArtefact.java | 9 + .../core/ui/navigator/IArtefactGroup.java | 13 + .../org/eclipse/wb/swt/ResourceManager.java | 316 ++++++++++++++++++ .../eclipse/wb/swt/SWTResourceManager.java | 304 +++++++++++++++++ 14 files changed, 1092 insertions(+), 1 deletion(-) create mode 100644 eu.scasefp7.eclipse.core.ui/icons/artefact-text.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/artefact.png delete mode 100644 eu.scasefp7.eclipse.core.ui/icons/sample.gif create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactContentProvider.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactGroup.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactLabelProvider.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactSorter.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/BaseArtefact.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefact.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefactGroup.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/org/eclipse/wb/swt/ResourceManager.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/org/eclipse/wb/swt/SWTResourceManager.java diff --git a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF index e40c1f3..e9c791a 100644 --- a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF @@ -11,7 +11,9 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui.intro.universal, org.eclipse.ui.ide, org.eclipse.core.expressions, - eu.scasefp7.eclipse.core;bundle-version="[1.0.2,2.0.0)" + eu.scasefp7.eclipse.core;bundle-version="[1.0.2,2.0.0)", + org.eclipse.ui.navigator, + org.eclipse.jdt.core;bundle-version="3.10.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: eu.scasefp7.eclipse.core.ui;version="1.0.2.qualifier" Bundle-Vendor: %Bundle-Vendor diff --git a/eu.scasefp7.eclipse.core.ui/icons/artefact-text.png b/eu.scasefp7.eclipse.core.ui/icons/artefact-text.png new file mode 100644 index 0000000000000000000000000000000000000000..ef7822f93c285953ede16121e454b199c640d5dd GIT binary patch literal 338 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6n2Mb|LpV4>-?)JUISV`@iy0W$ z-heQpT&aaAP*AeOHKHUqKdq!Zu_%?Hyu4g5GcUV1Ik6yBFTW^#_B$IXprVVOE{-7@ z6H_lP^m0y=Xn5#8;qZY4C!g?aN}7GvIzS-hpuxoyfn!}w3vv%CH5I%&`k*PXaDjM2 zfkK3s2n#RYk@F@0WXmgF-HtoB)c?NmyxbN6mi)G|-03p2cg$mx=WC9d#QMER_OgTe~DWM4facYIC literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/icons/artefact.png b/eu.scasefp7.eclipse.core.ui/icons/artefact.png new file mode 100644 index 0000000000000000000000000000000000000000..bcd8ccf5c6a1c60705639183423c83194f280ffd GIT binary patch literal 384 zcmeAS@N?(olHy`uVBq!ia0vp^0w6XA8<1SE`<)7qVkvg=4B-HR8jh3>AfL0qBeIx* zfhih<867LudjJI`OI#yLg7ec#$`gxH8OqDc^)mCai<1)zQuXqS(r3T3kpe3E>*?Yc zqA{`e;(qO;ffC0*URPYo!#0_<*^%vWtY&xTluaF*W~O{$-yq53HrqGS*Ncr!cqjKO zy)MCK6`N^~zkPjM_x|gZ<)0s0zCT}lt}@6)!`&-Wq83v!6#i z-(Y@p>CHt`=UX`VYd5zr-g&H|Bo^egcSWMi`W+n|ZDt$0(|NY7y5Jcraj440X4~o@ aQTtpWuD~N98he2O!QkoY=d#Wzp$P!R4whH| literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/icons/sample.gif b/eu.scasefp7.eclipse.core.ui/icons/sample.gif deleted file mode 100644 index 34fb3c9d8cb7d489681b7f7aee4bdcd7eaf53610..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 983 zcmZ?wbhEHb6krfw_|CxKYUg-n!?izO{@9*?jxd%4aX0yzy`dymabz zw#(eg=y~&N&n)dZv2xzduG}5lraiApo3(c4*{Ylg5#|$JO_EEZ<^|a2`Z*=9ns7DV zy=TR&gYw*7f%auV?ip3tvjRPmcdoho{K?x$_vR?C#t5&<;~V}S*>OMCr>h}%%bLZ9 zmo3`hYEwTICo-TTCZwgTsC&VjZRgJ1eE#fBa^%9R zmmfWS@;bnyJ27HWY}kxYzv(Hl>yu;FCPlAEh+34Muq-8Rb6C)<8qA3{r2e5 z`$vyngh#H=FWlqqvnapfc5%(!sQ4v?r7J61-&eJNEN^;KTK}T7{#i-gJh%G*9vcYdwv_*~xdw!Gz4Va?T!sXyyF@8?w<>X`X=#j%uHV4GRvj@+tE@ zQ%F!a)GKcn^~8abN>4la1UNXVL;{ZWi)lEwyeatDu%Lr6;aASiLrXXW zQm# + + @@ -296,5 +300,101 @@ project="true"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactContentProvider.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactContentProvider.java new file mode 100644 index 0000000..9948733 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactContentProvider.java @@ -0,0 +1,200 @@ +package eu.scasefp7.eclipse.core.ui.navigator; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +import eu.scasefp7.eclipse.core.ontology.DynamicOntologyAPI; +import eu.scasefp7.eclipse.core.ontology.StaticOntologyAPI; + + +public class ArtefactContentProvider implements ITreeContentProvider { + private static final Object[] EMPTY = new Object[0]; + + private Object[] parents = null; + ArtefactGroup[] rootGroup = new ArtefactGroup[1]; + + private String[] group_names = { "Requirements", "Objects", "Activities", "Transitions"}; + + public void dispose() {} + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} + + public Object[] getElements(Object inputElement) { + System.out.println("getElements: " + inputElement); + + return getChildren(inputElement); + } + + + public Object[] getChildren(Object parentElement) { + System.out.println("getChildren: " + parentElement); + + if ((parentElement instanceof IProject)) { + + initializeParents((IProject) parentElement); + initializeArtefacts((IProject) parentElement); + + return rootGroup; + } + + if ((parentElement instanceof IArtefact)) + return ((IArtefact)parentElement).getChildren(); + + if ((parentElement instanceof IArtefactGroup)) + return ((IArtefactGroup)parentElement).getChildren(); + + return EMPTY; + } + + + + + public Object getParent(Object element) { + System.out.print("getParent: " + element); + + if ((element instanceof IArtefact)) + return ((IArtefact)element).getParent(); + + return EMPTY; + } + + + public boolean hasChildren(Object element) { + System.out.println("hasChildren: " + element); + + + if ((element instanceof IFolder)) { + //.scase folders will be populated using initializeParent and initializeArtefacts + if (((IFolder)element).getName().endsWith(".scase")) + return true; + if (findParent(element) != null) + return true; + return false; + } + + if ((element instanceof IArtefact)) + return false; + + if (element instanceof IArtefactGroup && ((IArtefactGroup) element).getChildren()!= null) + return true; + + return false; + } + + + + private Object findParent(Object element) { + if (parents == null) + return null; + + Object[] arrayOfObject; + int j = (arrayOfObject = parents).length; + + for (int i = 0; i < j; i++) { + Object p = arrayOfObject[i]; + if (element == p) + return p; + } + return null; + } + + + private void initializeParents(IProject parent) { + parents = new Object[group_names.length]; + int ix = 0; + String[] arrayOfString; + int j = (arrayOfString = group_names).length; + + for (int i = 0; i < j; i++) { + String name = arrayOfString[i]; + ArtefactGroup artGroup = new ArtefactGroup(name, parent); + + parents[(ix++)] = artGroup; + } + rootGroup[0] = new ArtefactGroup("Root", parent, parents); + } + + + private void initializeArtefacts(IProject parent) { + IProject project = parent; + + Set Requirements = new HashSet(); + ArrayList Objects = new ArrayList(); + ArrayList Activities = new ArrayList(); + ArrayList Transitions = new ArrayList(); + + StaticOntologyAPI staticOntology = new StaticOntologyAPI(project); + DynamicOntologyAPI dynamicOntology = new DynamicOntologyAPI(project); + + for (String object : staticOntology.getObjects()) { + ArrayList obActions = staticOntology.getActionsOfObject(object); + ArrayList obProperty = staticOntology.getPropertiesOfObject(object); + String resultStr; + + if(obProperty.isEmpty()) + resultStr = "Object: " + object + ", actions: " + obActions; + else + resultStr = "Object: " + object + ", actions: " + obActions + ", properties: " + obProperty; + + IArtefact art = new BaseArtefact(resultStr, (ArtefactGroup) parents[1]); + Objects.add((BaseArtefact) art); + + + for (String requirement : staticOntology.getRequirementsOfConcept(object)) { + resultStr = "Requirement: " + requirement + ", concept: " + object; + IArtefact art2 = new BaseArtefact(resultStr, (ArtefactGroup) parents[0]); + Requirements.add((BaseArtefact) art2); + } + + } + + for (String activity : dynamicOntology.getActivities()) { + String action = dynamicOntology.getActionOfActivity(activity); + String acType = dynamicOntology.getActivityTypeOfActivity(activity); + ArrayList acProp = dynamicOntology.getPropertiesOfActivity(activity); + String resultStr; + if(acProp.isEmpty()) + resultStr = "Activity: " + action + ", type: " + acType; + else + resultStr = "Activity: " + action + ", type: " + acType + ", properties:" + acProp; + IArtefact art = new BaseArtefact(resultStr, (ArtefactGroup) parents[2]); + Activities.add((BaseArtefact) art); + } + + for (String transition : dynamicOntology.getTransitions()) { + + String condition = dynamicOntology.getConditionOfTransition(transition); + String sourcedynactivity = dynamicOntology.getSourceActivityOfTransition(transition); + String targetdynactivity = dynamicOntology.getTargetActivityOfTransition(transition); + String resultStr; + + if(condition == null) + resultStr = "from: " + sourcedynactivity + ", to: " + targetdynactivity; + else + resultStr = "from: " + sourcedynactivity + ", to: " + targetdynactivity +", condition: " + condition; + + IArtefact art = new BaseArtefact(resultStr, (ArtefactGroup) parents[3]); + Transitions.add((BaseArtefact) art); + + } + + BaseArtefact[] requirements = Requirements.stream().toArray(BaseArtefact[]::new); + BaseArtefact[] objects = Objects.stream().toArray(BaseArtefact[]::new); + BaseArtefact[] activities = Activities.stream().toArray(BaseArtefact[]::new); + BaseArtefact[] transitions = Transitions.stream().toArray(BaseArtefact[]::new); + + ((ArtefactGroup) parents[0]).setChildren(requirements); + ((ArtefactGroup) parents[1]).setChildren(objects); + ((ArtefactGroup) parents[2]).setChildren(activities); + ((ArtefactGroup) parents[3]).setChildren(transitions); + + + + } + } \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactGroup.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactGroup.java new file mode 100644 index 0000000..1731d0b --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactGroup.java @@ -0,0 +1,43 @@ +package eu.scasefp7.eclipse.core.ui.navigator; + +import org.eclipse.core.resources.IProject; + +public class ArtefactGroup implements IArtefactGroup { + + protected String name; + protected IProject parent; + protected Object[] children; + + ArtefactGroup(String name, IProject parent){ + this.name = name; + this.parent = parent; + this.children = null; + } + + ArtefactGroup(String name, IProject parent, Object[] children){ + this.name = name; + this.parent = parent; + this.children = children; + } + + @Override + public IProject getParent() { + return parent; + } + + @Override + public Object[] getChildren() { + return children; + } + + @Override + public String getName() { + return name; + } + + @Override + public void setChildren(Object[] children) { + this.children = children; + } + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactLabelProvider.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactLabelProvider.java new file mode 100644 index 0000000..41fc009 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactLabelProvider.java @@ -0,0 +1,47 @@ +package eu.scasefp7.eclipse.core.ui.navigator; + +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.wb.swt.ResourceManager; + +public class ArtefactLabelProvider implements ILabelProvider { + public void addListener(ILabelProviderListener listener) {} + + public void dispose() {} + + public boolean isLabelProperty(Object element, String property) { + return false; + } + + + public void removeListener(ILabelProviderListener listener) {} + + + public Image getImage(Object element) { + + if ((element instanceof IArtefact)) + return ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/artefact-text.png"); + + if ((element instanceof IArtefactGroup)) + return ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/artefact.png"); + + + return null; + } + + + + public String getText(Object element) { + System.out.println("Label for: " + element); + + if ((element instanceof IArtefact)) + return ((IArtefact)element).getName(); + + if ((element instanceof IArtefactGroup)) + return ((IArtefactGroup)element).getName(); + + + return null; + } + } \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactSorter.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactSorter.java new file mode 100644 index 0000000..f00dc07 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactSorter.java @@ -0,0 +1,23 @@ +package eu.scasefp7.eclipse.core.ui.navigator; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.jface.viewers.ViewerSorter; + +public class ArtefactSorter extends ViewerSorter +{ + public int category(Object element) + { + if ((element instanceof IFolder)) { + String name = ((IFolder)element).getName(); + String[] folders = { "Requirements", "Objects", "Activities", "Transitions"}; + + for (int ix = 0; ix < folders.length; ix++) { + if (folders[ix].equals(name)) + return ix; + } + return 0; + } + + return super.category(element); + } +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/BaseArtefact.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/BaseArtefact.java new file mode 100644 index 0000000..d2fbad8 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/BaseArtefact.java @@ -0,0 +1,34 @@ +package eu.scasefp7.eclipse.core.ui.navigator; + + +public class BaseArtefact implements IArtefact +{ + protected String name; + protected ArtefactGroup parent; + + public BaseArtefact(String name, ArtefactGroup parent) + { + this.name = name; + this.parent = parent; + } + + public String getName() + { + return name; + } + + public ArtefactGroup getParent() + { + return parent; + } + + public Object[] getChildren() + { + return null; + } + + public String toString() + { + return "BaseArtefact [name=" + name + ", parent=" + parent + "]"; + } +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefact.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefact.java new file mode 100644 index 0000000..fa77a23 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefact.java @@ -0,0 +1,9 @@ +package eu.scasefp7.eclipse.core.ui.navigator; + +public abstract interface IArtefact { + public abstract String getName(); + + public abstract ArtefactGroup getParent(); + + public abstract Object[] getChildren(); +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefactGroup.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefactGroup.java new file mode 100644 index 0000000..a97952a --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefactGroup.java @@ -0,0 +1,13 @@ +package eu.scasefp7.eclipse.core.ui.navigator; + +import org.eclipse.core.resources.IProject; + +public abstract interface IArtefactGroup { + public abstract String getName(); + + public abstract IProject getParent(); + + public abstract Object[] getChildren(); + + public abstract void setChildren(Object[] child); +} diff --git a/eu.scasefp7.eclipse.core.ui/src/org/eclipse/wb/swt/ResourceManager.java b/eu.scasefp7.eclipse.core.ui/src/org/eclipse/wb/swt/ResourceManager.java new file mode 100644 index 0000000..8776b7e --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/org/eclipse/wb/swt/ResourceManager.java @@ -0,0 +1,316 @@ +package org.eclipse.wb.swt; + + import java.io.File; + import java.io.InputStream; + import java.lang.reflect.Constructor; + import java.lang.reflect.Method; + import java.net.MalformedURLException; + import java.net.URL; + import java.util.HashMap; + import java.util.Iterator; + import java.util.Map; + + import org.eclipse.core.runtime.Platform; + import org.eclipse.jface.resource.CompositeImageDescriptor; + import org.eclipse.jface.resource.ImageDescriptor; + import org.eclipse.swt.graphics.Image; + import org.eclipse.swt.graphics.Point; + import org.eclipse.swt.graphics.Rectangle; + import org.osgi.framework.Bundle; + + public class ResourceManager extends SWTResourceManager + { + private static Map m_descriptorImageMap = new HashMap(); + + public static ImageDescriptor getImageDescriptor(Class clazz, String path) + { + return ImageDescriptor.createFromFile(clazz, path); + } + + public static ImageDescriptor getImageDescriptor(String path) + { + try + { + return ImageDescriptor.createFromURL(new File(path).toURI().toURL()); + } catch (MalformedURLException localMalformedURLException) {} + return null; + } + + public static Image getImage(ImageDescriptor descriptor) + { + if (descriptor == null) { + return null; + } + Image image = (Image)m_descriptorImageMap.get(descriptor); + if (image == null) { + image = descriptor.createImage(); + m_descriptorImageMap.put(descriptor, image); + } + return image; + } + + + private static Map>[] m_decoratedImageMap = new Map[5]; + + + public static Image decorateImage(Image baseImage, Image decorator) + { + return decorateImage(baseImage, decorator, 4); + } + + + + + public static Image decorateImage(Image baseImage, final Image decorator, final int corner) + { + if ((corner <= 0) || (corner >= 5)) { + throw new IllegalArgumentException("Wrong decorate corner"); + } + Map> cornerDecoratedImageMap = m_decoratedImageMap[corner]; + if (cornerDecoratedImageMap == null) { + cornerDecoratedImageMap = new HashMap>(); + m_decoratedImageMap[corner] = cornerDecoratedImageMap; + } + Map decoratedMap = (Map)cornerDecoratedImageMap.get(baseImage); + if (decoratedMap == null) { + decoratedMap = new HashMap(); + cornerDecoratedImageMap.put(baseImage, decoratedMap); + } + + Image result = (Image)decoratedMap.get(decorator); + + if (result == null) { + final Rectangle bib = baseImage.getBounds(); + final Rectangle dib = decorator.getBounds(); + + final Point baseImageSize = new Point(bib.width, bib.height); + CompositeImageDescriptor compositImageDesc = new CompositeImageDescriptor() + { + protected void drawCompositeImage(int width, int height) { + drawImage(getImageData(), 0, 0); + int bibwidth = bib.width; + int bibheight = bib.height; + int dibwidth = dib.width; + int dibheight = dib.height; + + if (corner == 1) { + drawImage(decorator.getImageData(), 0, 0); + } else if (corner == 2) { + drawImage(decorator.getImageData(), bibwidth - dibwidth, 0); + } else if (corner == 3) { + drawImage(decorator.getImageData(), 0, bibheight - dibheight); + } else if (corner == 4) { + drawImage(decorator.getImageData(), bibwidth - dibwidth, bibheight - dibheight); + } + } + + protected Point getSize() { + return baseImageSize; + } + + }; + result = compositImageDesc.createImage(); + decoratedMap.put(decorator, result); + } + return result; + } + + + + public static void disposeImages() + { + + + for (Iterator I = m_descriptorImageMap.values().iterator(); I.hasNext();) { + ((Image)I.next()).dispose(); + } + m_descriptorImageMap.clear(); + + + for (int i = 0; i < m_decoratedImageMap.length; i++) { + Map> cornerDecoratedImageMap = m_decoratedImageMap[i]; + if (cornerDecoratedImageMap != null) { + for (Map decoratedMap : cornerDecoratedImageMap.values()) { + for (Image image : decoratedMap.values()) { + image.dispose(); + } + decoratedMap.clear(); + } + cornerDecoratedImageMap.clear(); + } + } + + for (Iterator I = m_URLImageMap.values().iterator(); I.hasNext();) { + ((Image)I.next()).dispose(); + } + m_URLImageMap.clear(); + } + + private static Map m_URLImageMap = new HashMap(); + + + private static PluginResourceProvider m_designTimePluginResourceProvider = null; + + + @Deprecated + public static Image getPluginImage(Object plugin, String name) + { + try + { + URL url = getPluginImageURL(plugin, name); + if (url != null) { + return getPluginImageFromUrl(url); + } + } + catch (Throwable localThrowable) {} + + return null; + } + + + public static Image getPluginImage(String symbolicName, String path) + { + try + { + URL url = getPluginImageURL(symbolicName, path); + if (url != null) { + return getPluginImageFromUrl(url); + } + } + catch (Throwable localThrowable) {} + + return null; + } + + + private static Image getPluginImageFromUrl(URL url) + { + try { + try { + String key = url.toExternalForm(); + Image image = m_URLImageMap.get(key); + if (image == null) { + InputStream stream = url.openStream(); + try { + image = getImage(stream); + m_URLImageMap.put(key, image); + } finally { + stream.close(); + } + } + return image; + } catch (Throwable e) { + // Ignore any exceptions + } + } catch (Throwable e) { + // Ignore any exceptions + } + return null; + + } + + @Deprecated + public static ImageDescriptor getPluginImageDescriptor(Object plugin, String name) + { + try + { + URL url = getPluginImageURL(plugin, name); + return ImageDescriptor.createFromURL(url); + } + catch (Throwable localThrowable1) {} + + + + + return null; + } + + + + + public static ImageDescriptor getPluginImageDescriptor(String symbolicName, String path) + { + try + { + URL url = getPluginImageURL(symbolicName, path); + if (url != null) { + return ImageDescriptor.createFromURL(url); + } + } + catch (Throwable localThrowable) {} + + return null; + } + + + + + private static URL getPluginImageURL(String symbolicName, String path) + { + Bundle bundle = Platform.getBundle(symbolicName); + if (bundle != null) { + return bundle.getEntry(path); + } + + + if (m_designTimePluginResourceProvider != null) { + return m_designTimePluginResourceProvider.getEntry(symbolicName, path); + } + + return null; + } + + + private static URL getPluginImageURL(Object plugin, String name) + throws Exception + { + try + { + Class BundleClass = Class.forName("org.osgi.framework.Bundle"); + Class BundleContextClass = Class.forName("org.osgi.framework.BundleContext"); + if (BundleContextClass.isAssignableFrom(plugin.getClass())) { + Method getBundleMethod = BundleContextClass.getMethod("getBundle", new Class[0]); + Object bundle = getBundleMethod.invoke(plugin, new Object[0]); + + Class PathClass = Class.forName("org.eclipse.core.runtime.Path"); + Constructor pathConstructor = PathClass.getConstructor(new Class[] { String.class }); + Object path = pathConstructor.newInstance(new Object[] { name }); + + Class IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); + Class PlatformClass = Class.forName("org.eclipse.core.runtime.Platform"); + Method findMethod = PlatformClass.getMethod("find", new Class[] { BundleClass, IPathClass }); + return (URL)findMethod.invoke(null, new Object[] { bundle, path }); + } + + + } + catch (Throwable localThrowable) + { + Class PluginClass = Class.forName("org.eclipse.core.runtime.Plugin"); + if (PluginClass.isAssignableFrom(plugin.getClass())) { + Class PathClass = Class.forName("org.eclipse.core.runtime.Path"); + Constructor pathConstructor = PathClass.getConstructor(new Class[] { String.class }); + Object path = pathConstructor.newInstance(new Object[] { name }); + + Class IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); + Method findMethod = PluginClass.getMethod("find", new Class[] { IPathClass }); + return (URL)findMethod.invoke(plugin, new Object[] { path }); + } + } + return null; + } + + + + public static void dispose() + { + disposeColors(); + disposeFonts(); + disposeImages(); + } + + public static abstract interface PluginResourceProvider + { + public abstract URL getEntry(String paramString1, String paramString2); + } + } diff --git a/eu.scasefp7.eclipse.core.ui/src/org/eclipse/wb/swt/SWTResourceManager.java b/eu.scasefp7.eclipse.core.ui/src/org/eclipse/wb/swt/SWTResourceManager.java new file mode 100644 index 0000000..b3fb8b8 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/org/eclipse/wb/swt/SWTResourceManager.java @@ -0,0 +1,304 @@ +package org.eclipse.wb.swt; + +import java.io.FileInputStream; + import java.io.IOException; + import java.io.InputStream; + import java.util.HashMap; + import java.util.Map; + import org.eclipse.swt.graphics.Color; + import org.eclipse.swt.graphics.Cursor; + import org.eclipse.swt.graphics.Font; + import org.eclipse.swt.graphics.FontData; + import org.eclipse.swt.graphics.GC; + import org.eclipse.swt.graphics.Image; + import org.eclipse.swt.graphics.ImageData; + import org.eclipse.swt.graphics.RGB; + import org.eclipse.swt.graphics.Rectangle; + import org.eclipse.swt.widgets.Display; + + + public class SWTResourceManager { + private static Map m_colorMap = new HashMap(); + + public static Color getColor(int systemColorID) { + Display display = Display.getCurrent(); + return display.getSystemColor(systemColorID); + } + + public static Color getColor(int r, int g, int b) { + return getColor(new RGB(r, g, b)); + } + + + public static Color getColor(RGB rgb) { + Color color = (Color)m_colorMap.get(rgb); + if (color == null) { + Display display = Display.getCurrent(); + color = new Color(display, rgb); + m_colorMap.put(rgb, color); + } + return color; + } + + + public static void disposeColors() { + for (Color color : m_colorMap.values()) + color.dispose(); + + m_colorMap.clear(); + } + + + private static Map m_imageMap = new HashMap(); + public static final int TOP_LEFT = 1; + public static final int TOP_RIGHT = 2; + public static final int BOTTOM_LEFT = 3; + public static final int BOTTOM_RIGHT = 4; + protected static final int LAST_CORNER_KEY = 5; + + protected static Image getImage(InputStream stream) throws IOException { + try { + Display display = Display.getCurrent(); + ImageData data = new ImageData(stream); + //Image localImage; + if (data.transparentPixel > 0) { + return new Image(display, data, data.getTransparencyMask()); + } + return new Image(display, data); + } finally { + stream.close(); + } + } + + + + public static Image getImage(String path) { + Image image = (Image)m_imageMap.get(path); + if (image == null) { + try { + image = getImage(new FileInputStream(path)); + m_imageMap.put(path, image); + } catch (Exception localException) { + image = getMissingImage(); + m_imageMap.put(path, image); + } + } + return image; + } + + + + + + public static Image getImage(Class clazz, String path) { + String key = clazz.getName() + '|' + path; + Image image = (Image)m_imageMap.get(key); + if (image == null) { + try { + image = getImage(clazz.getResourceAsStream(path)); + m_imageMap.put(key, image); + } catch (Exception localException) { + image = getMissingImage(); + m_imageMap.put(key, image); + } + } + return image; + } + + + + private static Image getMissingImage() { + Image image = new Image(Display.getCurrent(), 10, 10); + + GC gc = new GC(image); + gc.setBackground(getColor(3)); + gc.fillRectangle(0, 0, 10, 10); + gc.dispose(); + + return image; + } + + + + private static Map>[] m_decoratedImageMap = new Map[5]; + + + public static Image decorateImage(Image baseImage, Image decorator) { + return decorateImage(baseImage, decorator, 4); + } + + + + public static Image decorateImage(Image baseImage, Image decorator, int corner) { + if ((corner <= 0) || (corner >= 5)) { + throw new IllegalArgumentException("Wrong decorate corner"); + } + Map> cornerDecoratedImageMap = m_decoratedImageMap[corner]; + if (cornerDecoratedImageMap == null) { + cornerDecoratedImageMap = new HashMap>(); + m_decoratedImageMap[corner] = cornerDecoratedImageMap; + } + Map decoratedMap = (Map)cornerDecoratedImageMap.get(baseImage); + if (decoratedMap == null) { + decoratedMap = new HashMap(); + cornerDecoratedImageMap.put(baseImage, decoratedMap); + } + + Image result = (Image)decoratedMap.get(decorator); + if (result == null) { + Rectangle bib = baseImage.getBounds(); + + int width = bib.width; + int height = bib.height; + + result = new Image(Display.getCurrent(), width, height); + + GC gc = new GC(result); + gc.drawImage(baseImage, 0, 0); + if (corner == 1) { + gc.drawImage(decorator, 0, 0); + } else if (corner == 2) { + gc.drawImage(decorator, width - width, 0); + } else if (corner == 3) { + gc.drawImage(decorator, 0, height - height); + } else if (corner == 4) { + gc.drawImage(decorator, width - width, height - height); + } + gc.dispose(); + + decoratedMap.put(decorator, result); + } + return result; + } + + + + + public static void disposeImages() + { + for (Image image : m_imageMap.values()) { + image.dispose(); + } + m_imageMap.clear(); + + + for (int i = 0; i < m_decoratedImageMap.length; i++) { + Map> cornerDecoratedImageMap = m_decoratedImageMap[i]; + if (cornerDecoratedImageMap != null) { + + + for (Map decoratedMap : cornerDecoratedImageMap.values()) { + for (Image image : decoratedMap.values()) { + image.dispose(); + } + decoratedMap.clear(); + } + cornerDecoratedImageMap.clear(); + } + } + } + + + private static Map m_fontMap = new HashMap(); + + + + private static Map m_fontToBoldFontMap = new HashMap(); + + + public static Font getFont(String name, int height, int style) + { + return getFont(name, height, style, false, false); + } + + + public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) + { + String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline; + Font font = (Font)m_fontMap.get(fontName); + if (font == null) { + FontData fontData = new FontData(name, size, style); + if ((strikeout) || (underline)) { + try { + Class logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); + Object logFont = FontData.class.getField("data").get(fontData); + if ((logFont != null) && (logFontClass != null)) { + if (strikeout) { + logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte)1)); + } + if (underline) { + logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte)1)); + } + } + } catch (Throwable e) { + System.err.println("Unable to set underline or strikeout (probably on a non-Windows platform). " + e); + } + } + font = new Font(Display.getCurrent(), fontData); + m_fontMap.put(fontName, font); + } + return font; + } + + + public static Font getBoldFont(Font baseFont) + { + Font font = (Font)m_fontToBoldFontMap.get(baseFont); + if (font == null) { + FontData[] fontDatas = baseFont.getFontData(); + FontData data = fontDatas[0]; + font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), 1); + m_fontToBoldFontMap.put(baseFont, font); + } + return font; + } + + + + public static void disposeFonts() + { + for (Font font : m_fontMap.values()) { + font.dispose(); + } + m_fontMap.clear(); + + for (Font font : m_fontToBoldFontMap.values()) { + font.dispose(); + } + m_fontToBoldFontMap.clear(); + } + + + private static Map m_idToCursorMap = new HashMap(); + + + public static Cursor getCursor(int id) + { + Integer key = Integer.valueOf(id); + Cursor cursor = (Cursor)m_idToCursorMap.get(key); + if (cursor == null) { + cursor = new Cursor(Display.getDefault(), id); + m_idToCursorMap.put(key, cursor); + } + return cursor; + } + + + public static void disposeCursors() + { + for (Cursor cursor : m_idToCursorMap.values()) { + cursor.dispose(); + } + m_idToCursorMap.clear(); + } + + + public static void dispose() + { + disposeColors(); + disposeImages(); + disposeFonts(); + disposeCursors(); + } + } + From 20de6e01256697630c745a10022729d95a339434 Mon Sep 17 00:00:00 2001 From: eleogas Date: Mon, 2 Nov 2015 13:25:11 +0100 Subject: [PATCH 05/29] Some minor changes --- .../eu/scasefp7/eclipse/core/ui/Activator.java | 2 ++ .../eclipse/core/ui/builder/SCaseBuilder.java | 18 ++++-------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java index 8e7fe08..78e0266 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java @@ -1,5 +1,6 @@ package eu.scasefp7.eclipse.core.ui; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -61,4 +62,5 @@ public static SharedImages getImages() { } return images; } + } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java index c785ef7..fe465d3 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java @@ -29,7 +29,6 @@ public class SCaseBuilder extends IncrementalProjectBuilder { - class SampleDeltaVisitor implements IResourceDeltaVisitor { public boolean visit(IResourceDelta delta) throws CoreException { @@ -45,10 +44,9 @@ public boolean visit(IResourceDelta delta) throws CoreException { return true; } -} + } - class SampleResourceVisitor implements IResourceVisitor { boolean fileExsists = false; int fileCount = 0; @@ -90,9 +88,7 @@ boolean checkXML(IResource resource) { return false; } - - - + protected void executeCommand(String commandId) { // Obtain IServiceLocator implementer, e.g. from PlatformUI.getWorkbench(): @@ -138,12 +134,6 @@ protected void executeCommand(String commandId, String fileName) { } - void linkOnthologies(){ - - - - } - public static final String BUILDER_ID = "eu.scasefp7.eclipse.core.ui.scaseBuilder"; @@ -208,7 +198,7 @@ protected void fullBuild(final IProgressMonitor monitor) try { clean(monitor); getProject().accept(new SampleResourceVisitor()); - executeCommand("eu.scasefp7.eclipse.core.commands.linkOntologies"); + //executeCommand("eu.scasefp7.eclipse.core.commands.linkOntologies"); } catch (CoreException e) { } @@ -222,7 +212,7 @@ protected void incrementalBuild(IResourceDelta delta, clean(monitor); //delta.accept(new SampleDeltaVisitor()); getProject().accept(new SampleResourceVisitor()); - executeCommand("eu.scasefp7.eclipse.core.commands.linkOntologies"); + // executeCommand("eu.scasefp7.eclipse.core.commands.linkOntologies"); } catch (CoreException e) { System.out.println(e); } From e3c481727480d391d016e3b5c399dd8897e30685 Mon Sep 17 00:00:00 2001 From: eleogas Date: Mon, 9 Nov 2015 12:39:03 +0100 Subject: [PATCH 06/29] Browser command --- eu.scasefp7.eclipse.core.ui/plugin.xml | 38 +++++++++++++++ .../core/ui/handlers/OpenBrowserHandler.java | 48 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/OpenBrowserHandler.java diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 0dd6d63..f9a74ac 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -412,4 +412,42 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/OpenBrowserHandler.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/OpenBrowserHandler.java new file mode 100644 index 0000000..ab378c7 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/OpenBrowserHandler.java @@ -0,0 +1,48 @@ +package eu.scasefp7.eclipse.core.ui.handlers; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.browser.IWebBrowser; +//import org.eclipse.ui.browser.IWorkbenchBrowserSupport; +//import org.eclipse.ui.internal.browser.WorkbenchBrowserSupport; + + +public class OpenBrowserHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + try { + String url = event.getParameter("eu.scasefp7.eclipse.core.ui.url"); + if(url.equals(null)) + url = "http://www.google.com"; + + final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser("browser"); + browser.openURL(new URL(url)); + } catch (PartInitException | MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + +// ALTERNATIVE: + +// try { +// int style = IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.STATUS; +// IWebBrowser browser = WorkbenchBrowserSupport.getInstance().createBrowser(style, "MyBrowserID", "MyBrowserName", "MyBrowser Tooltip"); +// browser.openURL(new URL("http://www.google.de")); +// } catch (PartInitException | MalformedURLException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + return null; + } + + + +} From d4f312d52fb06fa2a81be346990e6cceaf8bdf91 Mon Sep 17 00:00:00 2001 From: eleogas Date: Thu, 12 Nov 2015 10:56:16 +0100 Subject: [PATCH 07/29] Run external program command --- eu.scasefp7.eclipse.core.ui/plugin.xml | 39 +++++++ .../LaunchExternalProgramHandler.java | 104 ++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/LaunchExternalProgramHandler.java diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index f9a74ac..2ee1a9b 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -423,6 +423,25 @@ optional="true"> + + + + + + + + @@ -440,6 +459,22 @@ value="http://s-case.github.io/"> + + + + + + + + @@ -449,5 +484,9 @@ class="eu.scasefp7.eclipse.core.ui.handlers.OpenBrowserHandler" commandId="eu.scasefp7.eclipse.core.ui.commands.openBrowser"> + + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/LaunchExternalProgramHandler.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/LaunchExternalProgramHandler.java new file mode 100644 index 0000000..b224733 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/LaunchExternalProgramHandler.java @@ -0,0 +1,104 @@ +package eu.scasefp7.eclipse.core.ui.handlers; + + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.core.ILaunchesListener2; +import org.eclipse.swt.widgets.Display; + + + +public class LaunchExternalProgramHandler extends AbstractHandler implements ILaunchesListener2 { + + private Set allLaunches = new HashSet(); + ILaunchManager manager; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + try { + manager = DebugPlugin.getDefault().getLaunchManager(); + manager.addLaunchListener(this); + + ILaunchConfigurationType type = manager + .getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"); + + ILaunchConfiguration[] configurations = manager + .getLaunchConfigurations(type); + + for (int i = 0; i < configurations.length; i++) { + ILaunchConfiguration configuration = configurations[i]; + if (configuration.getName().equals("Gen doc")) { + configuration.delete(); + break; + } + } + + ILaunchConfigurationWorkingCopy workingCopy = type.newInstance( null, "Gen doc"); + String location = event.getParameter("eu.scasefp7.eclipse.core.ui.location"); + String arguments = event.getParameter("eu.scasefp7.eclipse.core.ui.arguments"); + String workingDir = event.getParameter("eu.scasefp7.eclipse.core.ui.workingDirectory"); + + + workingCopy.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", location); + workingCopy.setAttribute("org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS", arguments); + workingCopy.setAttribute("org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY", workingDir); + + ILaunch launch = workingCopy.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); + + allLaunches.add(launch); + + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + @Override + public void launchesRemoved(ILaunch[] launches) { + // TODO Auto-generated method stub + + } + + @Override + public void launchesAdded(ILaunch[] launches) { + // TODO Auto-generated method stub + + } + + + + @Override + public void launchesTerminated(ILaunch[] launches) { + for (ILaunch launch : launches) { + allLaunches.remove(launch); + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { } + }); + + } + } + + @Override + public void launchesChanged(ILaunch[] launches) { + // TODO Auto-generated method stub + + } + + +} From 54de15016c11b5e432b13c0772568a2524fa861b Mon Sep 17 00:00:00 2001 From: eleogas Date: Tue, 17 Nov 2015 14:01:30 +0100 Subject: [PATCH 08/29] Tracing --- eu.scasefp7.eclipse.core.ui/.options | 4 ++++ .../META-INF/MANIFEST.MF | 4 +++- eu.scasefp7.eclipse.core.ui/plugin.xml | 10 +++++++++ .../scasefp7/eclipse/core/ui/Activator.java | 22 +++++++++++++++++-- .../eclipse/core/ui/views/Dashboard.java | 5 +++++ 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/.options diff --git a/eu.scasefp7.eclipse.core.ui/.options b/eu.scasefp7.eclipse.core.ui/.options new file mode 100644 index 0000000..0a71650 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/.options @@ -0,0 +1,4 @@ +# Tracing options for the eu.scasefp7.eclipse.core.ui plug-in + +eu.scasefp7.eclipse.core.ui/debug=false +eu.scasefp7.eclipse.core.ui/debug/userActions=false diff --git a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF index 20f855c..074868e 100644 --- a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF @@ -11,7 +11,9 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui.ide, org.eclipse.mylyn.commons.notifications.ui, org.eclipse.mylyn.commons.workbench, - org.eclipse.ui.forms + org.eclipse.ui.forms, + org.eclipse.debug.core, + org.eclipse.ui.trace Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: eu.scasefp7.eclipse.core.ui Bundle-Vendor: %Bundle-Vendor diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 2ee1a9b..243932a 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -489,4 +489,14 @@ commandId="eu.scasefp7.eclipse.core.ui.commands.launchExternal"> + + + + + + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java index 78e0266..4af86ec 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java @@ -1,13 +1,18 @@ package eu.scasefp7.eclipse.core.ui; -import org.eclipse.jface.resource.ImageDescriptor; +import java.util.Dictionary; +import java.util.Hashtable; + +import org.eclipse.osgi.service.debug.DebugOptions; +import org.eclipse.osgi.service.debug.DebugOptionsListener; +import org.eclipse.osgi.service.debug.DebugTrace; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; /** * The activator class controls the plug-in life cycle */ -public class Activator extends AbstractUIPlugin { +public class Activator extends AbstractUIPlugin implements DebugOptionsListener { // The plug-in ID public static final String PLUGIN_ID = "eu.scasefp7.eclipse.core.ui"; //$NON-NLS-1$ @@ -18,6 +23,9 @@ public class Activator extends AbstractUIPlugin { // Images private static SharedImages images = null; + // fields to cache the debug flags + public static boolean DEBUG = false; + public static DebugTrace trace = null; /** * The constructor */ @@ -30,6 +38,9 @@ public Activator() { */ public void start(BundleContext context) throws Exception { super.start(context); + Dictionary props = new Hashtable(4); + props.put(DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID); + context.registerService(DebugOptionsListener.class.getName(), this, props); plugin = this; } @@ -62,5 +73,12 @@ public static SharedImages getImages() { } return images; } + + @Override + public void optionsChanged(DebugOptions options) { + DEBUG = options.getBooleanOption(PLUGIN_ID + "/debug", false); + trace = options.newDebugTrace(PLUGIN_ID); + + } } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java index 7b84f81..aa52bc3 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java @@ -51,6 +51,7 @@ import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.osgi.internal.debug.FrameworkDebugTraceEntry; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; @@ -79,6 +80,7 @@ import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.services.IServiceLocator; +import eu.scasefp7.eclipse.core.ui.Activator; import eu.scasefp7.eclipse.core.ui.ScaseUiConstants; import eu.scasefp7.eclipse.core.ui.preferences.internal.DomainEntry; import eu.scasefp7.eclipse.core.ui.preferences.internal.IProjectDomains; @@ -337,6 +339,8 @@ private void handleButton(Composite parent, IConfigurationElement elem) throws I @Override public void mouseDown(MouseEvent e) { try { + + Activator.trace.trace("/debug/userActions", "Button pressed: "+name); executeCommand(commandId); notifyUser(commandId, notificationSuccess); } catch (CommandException ex) { @@ -351,6 +355,7 @@ public void mouseDown(MouseEvent e) { @Override public void mouseDown(MouseEvent e) { try { + Activator.trace.trace("/debug/userActions", "Button pressed: "+name); executeCommand(commandId, params); notifyUser(commandId, notificationSuccess); } catch (CommandException ex) { From 6552b808470e8661a8d92c0a2e2b6c8d3069e010 Mon Sep 17 00:00:00 2001 From: eleogas Date: Fri, 4 Dec 2015 14:45:21 +0100 Subject: [PATCH 09/29] Dynamic variables, username, password preference page --- eu.scasefp7.eclipse.core.ui/plugin.xml | 51 ++ .../core/ui/DynamicVariableResolver.java | 23 + .../preferences/MultiLineTextFieldEditor.java | 567 ++++++++++++++++++ .../preferences/PreferenceConstantsPage.java | 51 ++ 4 files changed, 692 insertions(+) create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/DynamicVariableResolver.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/MultiLineTextFieldEditor.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 243932a..525013c 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -114,6 +114,21 @@ + + + + + + + + + + @@ -499,4 +527,27 @@ + + + + + + + + + + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/DynamicVariableResolver.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/DynamicVariableResolver.java new file mode 100644 index 0000000..32d597f --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/DynamicVariableResolver.java @@ -0,0 +1,23 @@ +package eu.scasefp7.eclipse.core.ui; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.variables.IDynamicVariable; +import org.eclipse.core.variables.IDynamicVariableResolver; +import org.eclipse.jface.preference.IPreferenceStore; + +public class DynamicVariableResolver implements IDynamicVariableResolver { + + @Override + public String resolveValue(IDynamicVariable variable, String argument) + throws CoreException { + + Activator plugin = Activator.getDefault(); + IPreferenceStore prefStore = plugin.getPreferenceStore(); + String value = prefStore.getString(argument); + + if (value != null && value.length() > 0) + return value; + return null; + } + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/MultiLineTextFieldEditor.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/MultiLineTextFieldEditor.java new file mode 100644 index 0000000..4ef5211 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/MultiLineTextFieldEditor.java @@ -0,0 +1,567 @@ +package eu.scasefp7.eclipse.core.ui.preferences; + +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.jface.util.Assert; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; + +/** + * MultiLineTextFieldEditor. Field editor that is same as string field editor + * but will have the multi line text field for user input. + */ + +public class MultiLineTextFieldEditor extends FieldEditor { + + private static final String ERROR_MESSAGE = "Multiline.error.message"; //$NON-NLS-1$ + + /** + * Validation strategy constant (value 0) indicating that the + * editor should perform validation after every key stroke. + * + * @see #setValidateStrategy + */ + public static final int VALIDATE_ON_KEY_STROKE = 0; + + /** + * Validation strategy constant (value 1) indicating that the + * editor should perform validation only when the text widget loses focus. + * + * @see #setValidateStrategy + */ + public static final int VALIDATE_ON_FOCUS_LOST = 1; + + /** + * Text limit constant (value -1) indicating unlimited text + * limit and width. + */ + public static int UNLIMITED = -1; + + /** + * Cached valid state. + */ + private boolean isValid; + + /** + * Old text value. + */ + private String oldValue; + + /** + * The text field, or null if none. + */ + private Text textField; + + /** + * Width of text field in characters; initially unlimited. + */ + private int widthInChars = UNLIMITED; + + /** + * Text limit of text field in characters; initially unlimited. + */ + private int textLimit = UNLIMITED; + + /** + * The error message, or null if none. + */ + private String errorMessage; + + /** + * Indicates whether the empty string is legal; true by + * default. + */ + private boolean emptyStringAllowed = true; + + /** + * The validation strategy; VALIDATE_ON_KEY_STROKE by default. + */ + private int validateStrategy = VALIDATE_ON_KEY_STROKE; + + /** + * Creates a new string field editor + */ + protected MultiLineTextFieldEditor() { + } + + /** + * Creates a string field editor. Use the method setTextLimit + * to limit the text. + * + * @param name + * the name of the preference this field editor works on + * @param labelText + * the label text of the field editor + * @param width + * the width of the text input field in characters, or + * UNLIMITED for no limit + * @param strategy + * either VALIDATE_ON_KEY_STROKE to perform on the + * fly checking (the default), or + * VALIDATE_ON_FOCUS_LOST to perform validation only + * after the text has been typed in + * @param parent + * the parent of the field editor's control + * @since 2.0 + */ + public MultiLineTextFieldEditor(String name, String labelText, int width, + int strategy, Composite parent) { + init(name, labelText); + widthInChars = width; + setValidateStrategy(strategy); + isValid = false; + errorMessage = "Field contains an invalid value"; + createControl(parent); + } + + /** + * Creates a string field editor. Use the method setTextLimit + * to limit the text. + * + * @param name + * the name of the preference this field editor works on + * @param labelText + * the label text of the field editor + * @param width + * the width of the text input field in characters, or + * UNLIMITED for no limit + * @param parent + * the parent of the field editor's control + */ + public MultiLineTextFieldEditor(String name, String labelText, int width, + Composite parent) { + this(name, labelText, width, VALIDATE_ON_KEY_STROKE, parent); + // this.compTitle = labelText; + } + + /** + * Creates a string field editor of unlimited width. Use the method + * setTextLimit to limit the text. + * + * @param name + * the name of the preference this field editor works on + * @param labelText + * the label text of the field editor + * @param parent + * the parent of the field editor's control + */ + public MultiLineTextFieldEditor(String name, String labelText, + Composite parent) { + this(name, labelText, UNLIMITED, parent); + } + + /** + * Adjusts the horizontal span of this field editor's basic controls + *

+ * Subclasses must implement this method to adjust the horizontal span of + * controls so they appear correct in the given number of columns. + *

+ *

+ * The number of columns will always be equal to or greater than the value + * returned by this editor's getNumberOfControls method. + * + * @param numColumns + * the number of columns + */ + protected void adjustForNumColumns(int numColumns) { + GridData gd = (GridData) textField.getLayoutData(); + gd.horizontalSpan = numColumns - 1; + // We only grab excess space if we have to + // If another field editor has more columns then + // we assume it is setting the width. + gd.grabExcessHorizontalSpace = gd.horizontalSpan == 1; + } + + /** + * Checks whether the text input field contains a valid value or not. + * + * @return true if the field value is valid, and + * false if invalid + */ + protected boolean checkState() { + boolean result = false; + if (emptyStringAllowed) + result = true; + + if (textField == null) + result = false; + + String txt = textField.getText(); + + if (txt == null) + result = false; + + result = (txt.trim().length() > 0) || emptyStringAllowed; + + // call hook for subclasses + result = result && doCheckState(); + + if (result) + clearErrorMessage(); + else + showErrorMessage(errorMessage); + + return result; + } + + /** + * Hook for subclasses to do specific state checks. + *

+ * The default implementation of this framework method does nothing and + * returns true. Subclasses should override this method to + * specific state checks. + *

+ * + * @return true if the field value is valid, and + * false if invalid + */ + protected boolean doCheckState() { + return true; + } + + /** + * Fills this field editor's basic controls into the given parent. + *

+ * The string field implementation of this FieldEditor + * framework method contributes the text field. Subclasses may override but + * must call super.doFillIntoGrid. + *

+ */ + protected void doFillIntoGrid(Composite parent, int numColumns) { + + getLabelControl(parent); + textField = getTextControl(parent); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint = 100; + gd.heightHint = 70; + textField.setLayoutData(gd); + + } + + /** + * Initializes this field editor with the preference value from the + * preference store. + *

+ * Subclasses must implement this method to properly initialize the field + * editor. + *

+ */ + protected void doLoad() { + if (textField != null) { + String value = getPreferenceStore().getString(getPreferenceName()); + textField.setText(value); + oldValue = value; + } + } + + /** + * Initializes this field editor with the default preference value from the + * preference store. + *

+ * Subclasses must implement this method to properly initialize the field + * editor. + *

+ */ + protected void doLoadDefault() { + if (textField != null) { + String value = getPreferenceStore().getDefaultString( + getPreferenceName()); + textField.setText(value); + } + valueChanged(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.preference.FieldEditor#doStore() + */ + protected void doStore() { + getPreferenceStore().setValue(getPreferenceName(), textField.getText()); + } + + /** + * Returns the error message that will be displayed when and if an error + * occurs. + * + * @return the error message, or null if none + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Returns the number of basic controls this field editor consists of. + * + * @return the number of controls + */ + public int getNumberOfControls() { + return 2; + } + + /** + * Returns the field editor's value. + * + * @return the current value + */ + public String getStringValue() { + if (textField != null) + return textField.getText(); + else + return getPreferenceStore().getString(getPreferenceName()); + } + + /** + * Returns this field editor's text control. + * + * @param parent + * the parent + * @return the text control, or null if no text field is + * created yet + */ + protected Text getTextControl() { + return textField; + } + + /** + * Returns this field editor's text control. + *

+ * The control is created if it does not yet exist + *

+ * + * @param parent + * the parent + * @return the text control + */ + public Text getTextControl(Composite parent) { + if (textField == null) { + textField = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER + | SWT.WRAP); + textField.setFont(parent.getFont()); + switch (validateStrategy) { + case VALIDATE_ON_KEY_STROKE: + textField.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + valueChanged(); + } + }); + + textField.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + refreshValidState(); + } + + public void focusLost(FocusEvent e) { + clearErrorMessage(); + } + }); + break; + case VALIDATE_ON_FOCUS_LOST: + textField.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + clearErrorMessage(); + } + }); + textField.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + refreshValidState(); + } + + public void focusLost(FocusEvent e) { + valueChanged(); + clearErrorMessage(); + } + }); + break; + default: + Assert.isTrue(false, "Unknown validate strategy"); //$NON-NLS-1$ + } + textField.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent event) { + textField = null; + } + }); + if (textLimit > 0) { // Only set limits above 0 - see SWT spec + textField.setTextLimit(textLimit); + } + } else { + checkParent(textField, parent); + } + return textField; + } + + /** + * Returns whether an empty string is a valid value. + * + * @return true if an empty string is a valid value, and + * false if an empty string is invalid + * @see #setEmptyStringAllowed + */ + public boolean isEmptyStringAllowed() { + return emptyStringAllowed; + } + + /** + * Returns whether this field editor contains a valid value. + *

+ * The default implementation of this framework method returns + * true. Subclasses wishing to perform validation should + * override both this method and refreshValidState. + *

+ * + * @return true if the field value is valid, and + * false if invalid + * @see #refreshValidState + */ + public boolean isValid() { + return isValid; + } + + /** + * Refreshes this field editor's valid state after a value change and fires + * an IS_VALID property change event if warranted. + *

+ * The default implementation of this framework method does nothing. + * Subclasses wishing to perform validation should override both this method + * and isValid. + *

+ * + * @see #isValid + */ + protected void refreshValidState() { + isValid = checkState(); + } + + @Override + public void setEnabled(boolean enabled, Composite parent) { + super.setEnabled(enabled, parent); + getTextControl(parent).setEnabled(enabled); + } + + /** + * Sets whether the empty string is a valid value or not. + * + * @param b + * true if the empty string is allowed, and + * false if it is considered invalid + */ + public void setEmptyStringAllowed(boolean b) { + emptyStringAllowed = b; + } + + /** + * Sets the error message that will be displayed when and if an error + * occurs. + * + * @param message + * the error message + */ + public void setErrorMessage(String message) { + errorMessage = message; + } + + /** + * Sets the focus to this field editor. + *

+ * The default implementation of this framework method does nothing. + * Subclasses may reimplement. + *

+ */ + public void setFocus() { + if (textField != null) { + textField.setFocus(); + } + } + + /** + * Sets this field editor's value. + * + * @param value + * the new value, or null meaning the empty string + */ + public void setStringValue(String value) { + if (textField != null) { + if (value == null) + value = ""; //$NON-NLS-1$ + oldValue = textField.getText(); + if (!oldValue.equals(value)) { + textField.setText(value); + valueChanged(); + } + } + } + + /** + * Sets this text field's text limit. + * + * @param limit + * the limit on the number of character in the text input field, + * or UNLIMITED for no limit + */ + public void setTextLimit(int limit) { + textLimit = limit; + if (textField != null) + textField.setTextLimit(limit); + } + + /** + * Sets the strategy for validating the text. + *

+ * Calling this method has no effect after createPartControl is + * called. Thus this method is really only useful for subclasses to call in + * their constructor. However, it has public visibility for backward + * compatibility. + *

+ * + * @param value + * either VALIDATE_ON_KEY_STROKE to perform on the + * fly checking (the default), or + * VALIDATE_ON_FOCUS_LOST to perform validation only + * after the text has been typed in + */ + + public void setValidateStrategy(int value) { + Assert.isTrue(value == VALIDATE_ON_FOCUS_LOST + || value == VALIDATE_ON_KEY_STROKE); + validateStrategy = value; + } + + /** + * Shows the error message set via setErrorMessage. + */ + public void showErrorMessage() { + showErrorMessage(errorMessage); + } + + /** + * Informs this field editor's listener, if it has one, about a change to + * the value (VALUE property) provided that the old and new + * values are different. + *

+ * This hook is not called when the text is initialized (or reset + * to the default value) from the preference store. + *

+ */ + protected void valueChanged() { + setPresentsDefaultValue(false); + boolean oldState = isValid; + refreshValidState(); + + if (isValid != oldState) + fireStateChanged(IS_VALID, oldState, isValid); + + String newValue = textField.getText(); + if (!newValue.equals(oldValue)) { + fireValueChanged(VALUE, oldValue, newValue); + oldValue = newValue; + } + } + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java new file mode 100644 index 0000000..1e7cee0 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java @@ -0,0 +1,51 @@ +package eu.scasefp7.eclipse.core.ui.preferences; + +import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +import eu.scasefp7.eclipse.core.ui.Activator; + +public class PreferenceConstantsPage extends FieldEditorOverlayPage implements + IWorkbenchPreferencePage { + + private static final String PAGE_ID = "eu.scasefp7.eclipse.core.ui.preferencePages.PreferenceConstantsPage"; + + public PreferenceConstantsPage() { + super(GRID); + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } + + @Override + public void createFieldEditors() { + addField(new StringFieldEditor("scase_fco_cust_uuid", "Customer UUID:", + getFieldEditorParent())); + + addField(new StringFieldEditor("scase_fco_cust_name", "Username:", + getFieldEditorParent())); + + addField(new StringFieldEditor("passwd", "Password", + getFieldEditorParent()) { + @Override + protected void doFillIntoGrid(Composite parent, int numColumns) { + super.doFillIntoGrid(parent, numColumns); + getTextControl().setEchoChar('*'); + } + }); + + addField(new MultiLineTextFieldEditor("scase_fco_ssh_key", "SSH key:", + getFieldEditorParent())); + + } + + @Override + public void init(IWorkbench workbench) { + setDescription("Preferences for arguments"); + } + + @Override + protected String getPageId() { + return PAGE_ID; + } +} \ No newline at end of file From 60809e41198612d11579dfe0d45738be70237c1a Mon Sep 17 00:00:00 2001 From: eleogas Date: Wed, 9 Dec 2015 14:14:56 +0100 Subject: [PATCH 10/29] Commands for running create and stop server scripts --- eu.scasefp7.eclipse.core.ui/plugin.xml | 33 ++++ .../core/ui/handlers/CreateServerHandler.java | 167 ++++++++++++++++++ .../core/ui/handlers/StopServerHandler.java | 135 ++++++++++++++ .../preferences/PreferenceConstantsPage.java | 7 +- 4 files changed, 341 insertions(+), 1 deletion(-) create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/CreateServerHandler.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/StopServerHandler.java diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 525013c..7743582 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -470,6 +470,14 @@ optional="true"> + + + + @@ -481,6 +489,7 @@ + + + + @@ -516,6 +536,14 @@ class="eu.scasefp7.eclipse.core.ui.handlers.LaunchExternalProgramHandler" commandId="eu.scasefp7.eclipse.core.ui.commands.launchExternal"> + + + + @@ -549,5 +577,10 @@ name="scase_fco_ssh_key" resolver="eu.scasefp7.eclipse.core.ui.DynamicVariableResolver"> + +
diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/CreateServerHandler.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/CreateServerHandler.java new file mode 100644 index 0000000..405bf1b --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/CreateServerHandler.java @@ -0,0 +1,167 @@ +package eu.scasefp7.eclipse.core.ui.handlers; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.variables.IDynamicVariable; +import org.eclipse.core.variables.IStringVariable; +import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.core.ILaunchesListener2; +import org.eclipse.debug.core.IStreamListener; +import org.eclipse.debug.core.model.IProcess; +import org.eclipse.debug.core.model.IStreamMonitor; +import org.eclipse.debug.core.model.IStreamsProxy; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.widgets.Display; + +import eu.scasefp7.eclipse.core.ui.Activator; +import eu.scasefp7.eclipse.core.ui.DynamicVariableResolver; + +public class CreateServerHandler extends AbstractHandler implements ILaunchesListener2, IStreamListener { + + private Set allLaunches = new HashSet(); + ILaunchManager manager; + String consoleOutput = ""; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + try { + manager = DebugPlugin.getDefault().getLaunchManager(); + manager.addLaunchListener(this); + + ILaunchConfigurationType type = manager + .getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"); + + ILaunchConfiguration[] configurations = manager + .getLaunchConfigurations(type); + + for (int i = 0; i < configurations.length; i++) { + ILaunchConfiguration configuration = configurations[i]; + if (configuration.getName().equals("Gen doc")) { + configuration.delete(); + break; + } + } + + String cust_uuid = null, username = null, password = null, ssh_key = null; + IStringVariable[] variables = VariablesPlugin.getDefault().getStringVariableManager().getVariables(); + + for (int i = 0; i < variables.length; i++) { + IDynamicVariable currVar = ((IDynamicVariable)variables[i]); + DynamicVariableResolver resolver = new DynamicVariableResolver(); + String name = currVar.getName(); + + if(name.equals("scase_fco_cust_uuid" ) ) + cust_uuid = resolver.resolveValue(currVar, name); + + if(name.equals( "scase_fco_cust_name")) + username = resolver.resolveValue(currVar, name); + + if(name.equals("scase_fco_cust_pwd" )) + password = resolver.resolveValue(currVar, name); + + if(name.equals("scase_fco_ssh_key" )) + ssh_key = resolver.resolveValue(currVar, name); + + } + + ILaunchConfigurationWorkingCopy workingCopy = type.newInstance( null, "Gen doc"); + + //replace with location of python.exe + String location ="C:\\Python27\\python.exe"; + + //replace with location of script + String arguments ="C:\\Users\\sc2015\\Desktop\\SCase\\YouREST-backend\\SCase-FCO\\createServer.py "; + + arguments += cust_uuid + " " + username + " " + password + " " + ssh_key; + String workingDir = ""; + + workingCopy.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", location); + workingCopy.setAttribute("org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS", arguments); + workingCopy.setAttribute("org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY", workingDir); + + ILaunch launch = workingCopy.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); + + allLaunches.add(launch); + + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + @Override + public void launchesRemoved(ILaunch[] launches) { + // TODO Auto-generated method stub + + } + + @Override + public void launchesAdded(ILaunch[] launches) { + // TODO Auto-generated method stub + + } + + + @Override + public void launchesTerminated(ILaunch[] launches) { + + //Fetching serverUUID from scripts' output + String serverUUID = ""; + int i = consoleOutput.indexOf("serverUUID"); + + while(consoleOutput.charAt(i) != '"') ++i; + ++i; + + while(consoleOutput.charAt(i) != '"') ++i; + ++i; + + while(consoleOutput.charAt(i) != '"') + { + serverUUID+=consoleOutput.charAt(i); + ++i; + } + + Activator plugin = Activator.getDefault(); + IPreferenceStore prefStore = plugin.getPreferenceStore(); + prefStore.setValue("scase_fco_server_uuid", serverUUID); + + for (ILaunch launch : launches) { + allLaunches.remove(launch); + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { } + }); + + } + } + + @Override + public void launchesChanged(ILaunch[] launches) { + + IProcess[] processes = launches[0].getProcesses(); + IStreamsProxy streams = processes[0].getStreamsProxy(); + + IStreamMonitor streamsOut = streams.getOutputStreamMonitor(); + streamsOut.addListener(this); + } + + @Override + public void streamAppended(String text, IStreamMonitor monitor) { + consoleOutput += text; + } +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/StopServerHandler.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/StopServerHandler.java new file mode 100644 index 0000000..4723a77 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/StopServerHandler.java @@ -0,0 +1,135 @@ +package eu.scasefp7.eclipse.core.ui.handlers; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.variables.IDynamicVariable; +import org.eclipse.core.variables.IStringVariable; +import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.core.ILaunchesListener2; +import org.eclipse.debug.core.model.IStreamMonitor; +import org.eclipse.swt.widgets.Display; + +import eu.scasefp7.eclipse.core.ui.DynamicVariableResolver; + +public class StopServerHandler extends AbstractHandler implements ILaunchesListener2 { + + private Set allLaunches = new HashSet(); + ILaunchManager manager; + IStreamMonitor streamsOut; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + try { + manager = DebugPlugin.getDefault().getLaunchManager(); + manager.addLaunchListener(this); + + ILaunchConfigurationType type = manager + .getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"); + + ILaunchConfiguration[] configurations = manager + .getLaunchConfigurations(type); + + for (int i = 0; i < configurations.length; i++) { + ILaunchConfiguration configuration = configurations[i]; + if (configuration.getName().equals("Gen doc")) { + configuration.delete(); + break; + } + } + + + String cust_uuid = null, username = null, password = null, server_uuid = null; + + IStringVariable[] variables = VariablesPlugin.getDefault().getStringVariableManager().getVariables(); + + for (int i = 0; i < variables.length; i++) { + IDynamicVariable currVar = ((IDynamicVariable)variables[i]); + DynamicVariableResolver resolver = new DynamicVariableResolver(); + String name = currVar.getName(); + + if(name.equals("scase_fco_cust_uuid" ) ) + cust_uuid = resolver.resolveValue(currVar, name); + + if(name.equals( "scase_fco_cust_name")) + username = resolver.resolveValue(currVar, name); + + if(name.equals("scase_fco_cust_pwd" )) + password = resolver.resolveValue(currVar, name); + + if(name.equals("scase_fco_server_uuid" )) + server_uuid = resolver.resolveValue(currVar, name); + + } + + + ILaunchConfigurationWorkingCopy workingCopy = type.newInstance( null, "Gen doc"); + + //replace with location of python.exe + String location ="C:\\Python27\\python.exe"; + + //replace with location of script + String arguments ="C:\\Users\\sc2015\\Desktop\\SCase\\YouREST-backend\\SCase-FCO\\stopServer.py "; + + arguments += cust_uuid + " " + username + " " + password + " " + server_uuid; + String workingDir = ""; + + workingCopy.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", location); + workingCopy.setAttribute("org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS", arguments); + workingCopy.setAttribute("org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY", workingDir); + + ILaunch launch = workingCopy.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); + allLaunches.add(launch); + + + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + @Override + public void launchesRemoved(ILaunch[] launches) { + // TODO Auto-generated method stub + + } + + @Override + public void launchesAdded(ILaunch[] launches) { + // TODO Auto-generated method stub + } + + + + @Override + public void launchesTerminated(ILaunch[] launches) { + for (ILaunch launch : launches) { + allLaunches.remove(launch); + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { } + }); + + } + } + + @Override + public void launchesChanged(ILaunch[] launches) { + // TODO Auto-generated method stub + + } +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java index 1e7cee0..d2ac402 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java @@ -2,6 +2,7 @@ import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; @@ -25,15 +26,19 @@ public void createFieldEditors() { addField(new StringFieldEditor("scase_fco_cust_name", "Username:", getFieldEditorParent())); - addField(new StringFieldEditor("passwd", "Password", + addField(new StringFieldEditor("scase_fco_cust_pwd", "Password", getFieldEditorParent()) { @Override protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns); + Text text = getTextControl(); + String value = text.toString(); getTextControl().setEchoChar('*'); + setStringValue(value); } }); + addField(new MultiLineTextFieldEditor("scase_fco_ssh_key", "SSH key:", getFieldEditorParent())); From 3a1237fb129f3e3474517c395169a8e6dede56c6 Mon Sep 17 00:00:00 2001 From: eleogas Date: Mon, 21 Dec 2015 16:24:34 +0100 Subject: [PATCH 11/29] Import Maven project command, encrypted FCO preferences --- eu.scasefp7.eclipse.core.ui/plugin.xml | 23 ++- .../core/ui/DynamicVariableResolver.java | 24 ++- .../handlers/ImportMavenProjectHandler.java | 57 ++++++++ .../ui/handlers/SecureIPreferenceStore.java | 137 ++++++++++++++++++ .../preferences/PreferenceConstantsPage.java | 7 +- 5 files changed, 240 insertions(+), 8 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/ImportMavenProjectHandler.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/SecureIPreferenceStore.java diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 7743582..a997027 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -478,6 +478,15 @@ id="eu.scasefp7.eclipse.core.ui.commands.stopServer" name="Stop server"> + + + + @@ -488,7 +497,6 @@ id="eu.scasefp7.eclipse.core.ui.toolbar1"> + + + + @@ -544,6 +561,10 @@ class="eu.scasefp7.eclipse.core.ui.handlers.StopServerHandler" commandId="eu.scasefp7.eclipse.core.ui.commands.stopServer"> + + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/DynamicVariableResolver.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/DynamicVariableResolver.java index 32d597f..00599f8 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/DynamicVariableResolver.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/DynamicVariableResolver.java @@ -3,6 +3,9 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.variables.IDynamicVariable; import org.eclipse.core.variables.IDynamicVariableResolver; +import org.eclipse.equinox.security.storage.ISecurePreferences; +import org.eclipse.equinox.security.storage.SecurePreferencesFactory; +import org.eclipse.equinox.security.storage.StorageException; import org.eclipse.jface.preference.IPreferenceStore; public class DynamicVariableResolver implements IDynamicVariableResolver { @@ -10,13 +13,28 @@ public class DynamicVariableResolver implements IDynamicVariableResolver { @Override public String resolveValue(IDynamicVariable variable, String argument) throws CoreException { + + String value = null; + + if(argument == "scase_fco_server_uuid"){ + Activator plugin = Activator.getDefault(); + IPreferenceStore prefStore = plugin.getPreferenceStore(); + value = prefStore.getString(argument); + + return value; + } + + ISecurePreferences prefStore = SecurePreferencesFactory.getDefault(); - Activator plugin = Activator.getDefault(); - IPreferenceStore prefStore = plugin.getPreferenceStore(); - String value = prefStore.getString(argument); + try { + value = prefStore.get(argument, ""); + } catch (StorageException e) { + e.printStackTrace(); + } if (value != null && value.length() > 0) return value; + return null; } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/ImportMavenProjectHandler.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/ImportMavenProjectHandler.java new file mode 100644 index 0000000..d3b9b92 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/ImportMavenProjectHandler.java @@ -0,0 +1,57 @@ +package eu.scasefp7.eclipse.core.ui.handlers; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.m2e.core.MavenPlugin; +import org.eclipse.m2e.core.project.MavenProjectInfo; +import org.eclipse.m2e.core.project.ProjectImportConfiguration; +import org.eclipse.m2e.core.project.IProjectConfigurationManager; +import org.apache.maven.model.Model; + + +public class ImportMavenProjectHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) { +// Get pom file location from parameter +// String directory = event.getParameter("eu.scasefp7.eclipse.core.ui.projectDirectory"); +// if (directory.equals(null) || directory.equals(" ")) +// directory = "C:\\Users\\sc2015\\Desktop\\SCase\\mde\\pom.xml"; + + File pomFile = new File("C:\\Users\\sc2015\\Desktop\\SCase\\mde\\eu.scasefp7.eclipse.mde.ui\\pom.xml"); + Model model = new Model(); + + IProgressMonitor monitor = new NullProgressMonitor(); + ProjectImportConfiguration config = new ProjectImportConfiguration(); + Collection infos = new ArrayList(); + IProjectConfigurationManager manager = MavenPlugin.getProjectConfigurationManager(); + + String version = "1.0.0"; + String groupId = "groupID"; + String artifactId = "eu.scasefp7.eclipse.mde.ui"; + String projectName = "eu.scasefp7.eclipse.mde.ui"; + + model.setGroupId(groupId); + model.setArtifactId(artifactId); + model.setVersion(version); + model.setPomFile(pomFile); + + MavenProjectInfo info = new MavenProjectInfo(projectName, pomFile, model, null); + infos.add(info); + + try { + manager.importProjects(infos, config , monitor); + } catch (CoreException e) { + e.printStackTrace(); + } + + return null; + } + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/SecureIPreferenceStore.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/SecureIPreferenceStore.java new file mode 100644 index 0000000..2efc8ba --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/SecureIPreferenceStore.java @@ -0,0 +1,137 @@ +package eu.scasefp7.eclipse.core.ui.handlers; + +import org.eclipse.core.runtime.preferences.IScopeContext; +import org.eclipse.equinox.security.storage.ISecurePreferences; +import org.eclipse.equinox.security.storage.SecurePreferencesFactory; +import org.eclipse.equinox.security.storage.StorageException; +import org.eclipse.ui.preferences.ScopedPreferenceStore; + +public class SecureIPreferenceStore extends ScopedPreferenceStore { + + private static final ISecurePreferences SECURE_PREFERENCES = SecurePreferencesFactory + .getDefault(); + + public SecureIPreferenceStore(IScopeContext context, String qualifier) { + super(context, qualifier); + } + + @Override + public void setValue(String name, boolean value) { + try { + SECURE_PREFERENCES.putBoolean(name, value, true); + } catch (StorageException e) { + e.printStackTrace(); + } + } + + @Override + public void setValue(String name, double value) { + try { + SECURE_PREFERENCES.putDouble(name, value, true); + } catch (StorageException e) { + e.printStackTrace(); + } + } + + @Override + public void setValue(String name, float value) { + try { + SECURE_PREFERENCES.putFloat(name, value, true); + } catch (StorageException e) { + e.printStackTrace(); + } + } + + @Override + public void setValue(String name, int value) { + try { + SECURE_PREFERENCES.putInt(name, value, true); + } catch (StorageException e) { + e.printStackTrace(); + } + } + + @Override + public void setValue(String name, long value) { + try { + SECURE_PREFERENCES.putLong(name, value, true); + } catch (StorageException e) { + e.printStackTrace(); + } + } + + @Override + public void setValue(String name, String value) { + try { + SECURE_PREFERENCES.put(name, value, true); + } catch (StorageException e) { + e.printStackTrace(); + } + } + + @Override + public boolean getBoolean(String name) { + Boolean result = false; + try { + result = SECURE_PREFERENCES.getBoolean(name, result); + } catch (StorageException e) { + e.printStackTrace(); + } + return result; + } + + @Override + public double getDouble(String name) { + Double result = 0.0; + try { + result = SECURE_PREFERENCES.getDouble(name, result); + } catch (StorageException e) { + e.printStackTrace(); + } + return result; + } + + @Override + public float getFloat(String name) { + Float result = 0.0f; + try { + result = SECURE_PREFERENCES.getFloat(name, result); + } catch (StorageException e) { + e.printStackTrace(); + } + return result; + } + + @Override + public int getInt(String name) { + int result = 0; + try { + result = SECURE_PREFERENCES.getInt(name, result); + } catch (StorageException e) { + e.printStackTrace(); + } + return result; + } + + @Override + public long getLong(String name) { + Long result = 0L; + try { + result = SECURE_PREFERENCES.getLong(name, result); + } catch (StorageException e) { + e.printStackTrace(); + } + return result; + } + + @Override + public String getString(String name) { + String result = ""; + try { + result = SECURE_PREFERENCES.get(name, ""); + } catch (StorageException e) { + e.printStackTrace(); + } + return result; + } +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java index d2ac402..994971f 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PreferenceConstantsPage.java @@ -1,12 +1,12 @@ package eu.scasefp7.eclipse.core.ui.preferences; +import org.eclipse.core.runtime.preferences.ConfigurationScope; import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; - -import eu.scasefp7.eclipse.core.ui.Activator; +import eu.scasefp7.eclipse.core.ui.handlers.SecureIPreferenceStore; public class PreferenceConstantsPage extends FieldEditorOverlayPage implements IWorkbenchPreferencePage { @@ -15,7 +15,7 @@ public class PreferenceConstantsPage extends FieldEditorOverlayPage implements public PreferenceConstantsPage() { super(GRID); - setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setPreferenceStore(new SecureIPreferenceStore(ConfigurationScope.INSTANCE,"eu.scasefp7.eclipse.core.ui.preferences.secure")); } @Override @@ -38,7 +38,6 @@ protected void doFillIntoGrid(Composite parent, int numColumns) { } }); - addField(new MultiLineTextFieldEditor("scase_fco_ssh_key", "SSH key:", getFieldEditorParent())); From eb01779fee1a2d225d25201aac4e3c4405049ed8 Mon Sep 17 00:00:00 2001 From: eleogas Date: Fri, 22 Jan 2016 10:33:58 +0100 Subject: [PATCH 12/29] Extension point for New S-Case project wizard --- eu.scasefp7.eclipse.core.ui/plugin.xml | 25 ++- ...eclipse.core.ui.newSCaseProjectWizard.exsd | 126 ++++++++++++++ .../eclipse/core/ui/ScaseUiConstants.java | 6 + .../ui/wizards/NewScaseProjectWizard2.java | 157 ++++++++++++++++++ eu.scasefp7.eclipse.core/pom.xml | 1 - target-platform/target-platform.target | 5 +- 6 files changed, 316 insertions(+), 4 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.newSCaseProjectWizard.exsd create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index e4cc017..b6158fb 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -2,6 +2,7 @@ + @@ -86,7 +87,14 @@ project="true"> Create a new S-CASE project to specify requirements for web services - + + + @@ -385,4 +393,19 @@ + + + + + +
diff --git a/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.newSCaseProjectWizard.exsd b/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.newSCaseProjectWizard.exsd new file mode 100644 index 0000000..b672c5e --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.newSCaseProjectWizard.exsd @@ -0,0 +1,126 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/ScaseUiConstants.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/ScaseUiConstants.java index 39ae311..2ae8afa 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/ScaseUiConstants.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/ScaseUiConstants.java @@ -37,12 +37,18 @@ private ScaseUiConstants() { /** New S-CASE project wizard ID. */ public static final String NEW_PROJECT_WIZARD = "eu.scasefp7.eclipse.core.ui.newProjectWizard"; //$NON-NLS-1$ + /** New S-CASE project wizard ID2. */ + public static final String NEW_PROJECT_WIZARD2 = "eu.scasefp7.eclipse.core.ui.wizards.NewScaseProjectWizard2"; //$NON-NLS-1$ + /** S-CASE Dashboard view ID. */ public static final String DASHBOARD_VIEW = "eu.scasefp7.eclipse.core.ui.views.Dashboard"; //$NON-NLS-1$ /** Extension point used to contribute dashboard items. */ public static final String DASHBOARD_EXTENSION = "eu.scasefp7.eclipse.core.ui.dashboardItem"; //$NON-NLS-1$ + /** Extension point for new project wizard */ + public static final String NEWPROJECT_EXTENSION = "eu.scasefp7.eclipse.core.ui.newSCaseProjectWizard"; //$NON-NLS-1$ + /** Link ontologies command ID. */ public static final String COMMAND_EXPORTONTOLOGY = "eu.scasefp7.eclipse.core.commands.linkOntologies"; //$NON-NLS-1$ diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java new file mode 100644 index 0000000..06785b9 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java @@ -0,0 +1,157 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + + +import java.lang.reflect.Array; +import java.net.URI; +import java.util.ArrayList; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IRegistryEventListener; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.RegistryFactory; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; + +import eu.scasefp7.eclipse.core.ui.ScaseUiConstants; +import eu.scasefp7.eclipse.core.ui.preferences.PropertyWizardPage; +import eu.scasefp7.eclipse.core.ui.preferences.internal.DomainEntry; + + + + +public class NewScaseProjectWizard2 extends Wizard implements INewWizard, IExecutableExtension, IRegistryEventListener { + + private WizardNewProjectCreationPage _pageOne; + private PropertyWizardPage _propertyPage; + private boolean propertyPageSet = false; + + private static final String PAGE_NAME = "Project name"; + private static final String WIZARD_NAME = "New S-CASE Project"; + private static final String CONTRIBUTION_PAGE = "page"; + + + /** + * + */ + public NewScaseProjectWizard2() { + setWindowTitle(WIZARD_NAME); + RegistryFactory.getRegistry().addListener(this, ScaseUiConstants.NEWPROJECT_EXTENSION); + } + + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + + } + + @Override + public void addPages() { + super.addPages(); + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] contributions = registry.getConfigurationElementsFor(ScaseUiConstants.NEWPROJECT_EXTENSION); + + // Create the configured items + for (IConfigurationElement elem : contributions) { + if(elem.getName().equals(CONTRIBUTION_PAGE)) { + String classAttr = elem.getAttribute("class"); + String description = elem.getAttribute("description"); + String title = elem.getAttribute("name"); + + if(classAttr.equals("org.eclipse.ui.dialogs.WizardNewProjectCreationPage")){ + _pageOne = new WizardNewProjectCreationPage(PAGE_NAME); + _pageOne.setTitle(title); + _pageOne.setDescription(description); + } + if(classAttr.equals("eu.scasefp7.eclipse.core.ui.preferences.PropertyWizardPage")){ + _propertyPage = new PropertyWizardPage(title); + _propertyPage.setTitle(description); + propertyPageSet = true; + } + + } + + } + + addPage(_pageOne); + + if(propertyPageSet) + addPage(_propertyPage); + } + + @Override + public boolean performFinish() { + + String name = _pageOne.getProjectName(); + URI location = null; + if (!_pageOne.useDefaults()) { + location = _pageOne.getLocationURI(); + } // else location == null + + IResource res = ScaseProjectSupport.createProject(name, location); + if(propertyPageSet){ + int k; + org.eclipse.swt.widgets.Label domainLabel = _propertyPage.getDomainLabel(); + DomainEntry de = (DomainEntry) domainLabel.getData(); + if (de == null) + k = -1; + else + k = de.getId(); + try { + res.setPersistentProperty(new QualifiedName("", ScaseUiConstants.PROP_PROJECT_DOMAIN), Integer.toString(k)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + return true; + } + + + @Override + public void setInitializationData(IConfigurationElement config, + String propertyName, Object data) throws CoreException { + // TODO Auto-generated method stub + + } + + + @Override + public void added(IExtension[] extensions) { + // TODO Auto-generated method stub + + } + + + @Override + public void removed(IExtension[] extensions) { + // TODO Auto-generated method stub + + } + + + @Override + public void added(IExtensionPoint[] extensionPoints) { + // TODO Auto-generated method stub + + } + + + @Override + public void removed(IExtensionPoint[] extensionPoints) { + // TODO Auto-generated method stub + + } + +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core/pom.xml b/eu.scasefp7.eclipse.core/pom.xml index 69134f3..d25bb15 100644 --- a/eu.scasefp7.eclipse.core/pom.xml +++ b/eu.scasefp7.eclipse.core/pom.xml @@ -2,7 +2,6 @@ 4.0.0 - eu.scasefp7.eclipse s-case-core diff --git a/target-platform/target-platform.target b/target-platform/target-platform.target index f8f2e8c..14af0a3 100644 --- a/target-platform/target-platform.target +++ b/target-platform/target-platform.target @@ -1,18 +1,19 @@ - + + - + From ccfe5844ce0f9e2d64c020e74875ea3bb7f246a9 Mon Sep 17 00:00:00 2001 From: eleogas Date: Wed, 27 Jan 2016 13:52:09 +0100 Subject: [PATCH 13/29] New project wizard interface --- eu.scasefp7.eclipse.core.ui/plugin.xml | 6 -- ...eclipse.core.ui.newSCaseProjectWizard.exsd | 2 +- .../ui/preferences/PropertyWizardPage.java | 28 ++++++- .../core/ui/wizards/IScaseWizardPage.java | 10 +++ .../ui/wizards/NewScaseProjectWizard2.java | 78 ++++++++----------- 5 files changed, 71 insertions(+), 53 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/IScaseWizardPage.java diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index eb24e08..c3acffc 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -392,12 +392,6 @@ - - - + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PropertyWizardPage.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PropertyWizardPage.java index 1e47c4a..8cef9f9 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PropertyWizardPage.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/PropertyWizardPage.java @@ -1,6 +1,9 @@ package eu.scasefp7.eclipse.core.ui.preferences; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -8,12 +11,16 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +import eu.scasefp7.eclipse.core.ui.ScaseUiConstants; +import eu.scasefp7.eclipse.core.ui.preferences.internal.DomainEntry; +import eu.scasefp7.eclipse.core.ui.wizards.IScaseWizardPage; + /** * @author emaorli * */ -public class PropertyWizardPage extends WizardPage { +public class PropertyWizardPage extends WizardPage implements IScaseWizardPage { ProjectDomainPropertyPage propPage; Composite composite; private static final int DOMAIN_DEFAULT = -1; @@ -57,6 +64,25 @@ public void createControl(Composite parent) { public Label getDomainLabel(){ return propPage.getDomainLabel(); } + + + @Override + public boolean performFinish(IResource resource) { + int k; + Label domainLabel = propPage.getDomainLabel(); + DomainEntry de = (DomainEntry) domainLabel.getData(); + if (de == null) + k = -1; + else + k = de.getId(); + try { + resource.setPersistentProperty(new QualifiedName("", ScaseUiConstants.PROP_PROJECT_DOMAIN), Integer.toString(k)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + } } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/IScaseWizardPage.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/IScaseWizardPage.java new file mode 100644 index 0000000..9121746 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/IScaseWizardPage.java @@ -0,0 +1,10 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.wizard.IWizardPage; + +public interface IScaseWizardPage extends IWizardPage { + + public boolean performFinish(IResource resource); + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java index 06785b9..b86fc67 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java @@ -1,9 +1,9 @@ package eu.scasefp7.eclipse.core.ui.wizards; -import java.lang.reflect.Array; import java.net.URI; import java.util.ArrayList; +import java.util.List; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -14,7 +14,6 @@ import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IRegistryEventListener; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.RegistryFactory; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; @@ -23,26 +22,20 @@ import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; import eu.scasefp7.eclipse.core.ui.ScaseUiConstants; -import eu.scasefp7.eclipse.core.ui.preferences.PropertyWizardPage; -import eu.scasefp7.eclipse.core.ui.preferences.internal.DomainEntry; - public class NewScaseProjectWizard2 extends Wizard implements INewWizard, IExecutableExtension, IRegistryEventListener { private WizardNewProjectCreationPage _pageOne; - private PropertyWizardPage _propertyPage; - private boolean propertyPageSet = false; + private List pages = new ArrayList(); private static final String PAGE_NAME = "Project name"; private static final String WIZARD_NAME = "New S-CASE Project"; private static final String CONTRIBUTION_PAGE = "page"; - /** - * - */ + public NewScaseProjectWizard2() { setWindowTitle(WIZARD_NAME); RegistryFactory.getRegistry().addListener(this, ScaseUiConstants.NEWPROJECT_EXTENSION); @@ -60,32 +53,40 @@ public void addPages() { IExtensionRegistry registry = Platform.getExtensionRegistry(); IConfigurationElement[] contributions = registry.getConfigurationElementsFor(ScaseUiConstants.NEWPROJECT_EXTENSION); - // Create the configured items + _pageOne = new WizardNewProjectCreationPage(PAGE_NAME); + _pageOne.setTitle("Create a S-Case Project"); + _pageOne.setDescription("Enter project name."); + addPage(_pageOne); + for (IConfigurationElement elem : contributions) { if(elem.getName().equals(CONTRIBUTION_PAGE)) { - String classAttr = elem.getAttribute("class"); + + String title = elem.getAttribute("name"); String description = elem.getAttribute("description"); - String title = elem.getAttribute("name"); - - if(classAttr.equals("org.eclipse.ui.dialogs.WizardNewProjectCreationPage")){ - _pageOne = new WizardNewProjectCreationPage(PAGE_NAME); - _pageOne.setTitle(title); - _pageOne.setDescription(description); - } - if(classAttr.equals("eu.scasefp7.eclipse.core.ui.preferences.PropertyWizardPage")){ - _propertyPage = new PropertyWizardPage(title); - _propertyPage.setTitle(description); - propertyPageSet = true; - } - + String qualifiedName = elem.getAttribute("class"); + + try { + Class c = Class.forName(qualifiedName).asSubclass (IScaseWizardPage.class); + IScaseWizardPage p = (IScaseWizardPage) c.getDeclaredConstructor(String.class).newInstance(title); + + p.setDescription(description); + p.setTitle(title); + //add pages to the list so we can call performFinish on them later + pages.add(p); + //add page to the wizard + addPage(p); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } + - addPage(_pageOne); - if(propertyPageSet) - addPage(_propertyPage); } @Override @@ -95,25 +96,12 @@ public boolean performFinish() { URI location = null; if (!_pageOne.useDefaults()) { location = _pageOne.getLocationURI(); - } // else location == null + } IResource res = ScaseProjectSupport.createProject(name, location); - if(propertyPageSet){ - int k; - org.eclipse.swt.widgets.Label domainLabel = _propertyPage.getDomainLabel(); - DomainEntry de = (DomainEntry) domainLabel.getData(); - if (de == null) - k = -1; - else - k = de.getId(); - try { - res.setPersistentProperty(new QualifiedName("", ScaseUiConstants.PROP_PROJECT_DOMAIN), Integer.toString(k)); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - + + for (IScaseWizardPage page : pages) + page.performFinish(res); return true; } From 4e50bca101cf712ec4e814bdc7d9da158f39abe0 Mon Sep 17 00:00:00 2001 From: eleogas Date: Wed, 10 Feb 2016 15:03:11 +0100 Subject: [PATCH 14/29] Wizard page for creation of project folders --- .../META-INF/MANIFEST.MF | 3 +- .../icons/s-case_8x8.png | Bin 0 -> 386 bytes eu.scasefp7.eclipse.core.ui/plugin.xml | 19 ++ .../eclipse/core/ui/ScaseUiConstants.java | 6 + .../eclipse/core/ui/navigator/ScaseLabel.java | 52 ++++ .../ui/wizards/NewScaseProjectWizard2.java | 2 +- .../ui/wizards/ScaseProjectWizardPageTwo.java | 291 ++++++++++++++++++ 7 files changed, 371 insertions(+), 2 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/icons/s-case_8x8.png create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ScaseLabel.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectWizardPageTwo.java diff --git a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF index 61e9c27..b55fc1a 100644 --- a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF @@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.variables, org.eclipse.equinox.security, org.eclipse.m2e.core, - org.eclipse.m2e.maven.runtime + org.eclipse.m2e.maven.runtime, + org.eclipse.jdt.ui Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: eu.scasefp7.eclipse.core.ui Bundle-Vendor: %Bundle-Vendor diff --git a/eu.scasefp7.eclipse.core.ui/icons/s-case_8x8.png b/eu.scasefp7.eclipse.core.ui/icons/s-case_8x8.png new file mode 100644 index 0000000000000000000000000000000000000000..db43d494b2369470068f34c2b6f92f43cd43035e GIT binary patch literal 386 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sDEfH31!Z9ZwBAbW|YuPggKc5z;19r@*NB!EIvC9V-A!TD(= z<%vb93;~Imc_n&&t|1C##(JiDhKBB+oy>u%?s>X6hG+!)_St$d2a2@rmwe{7Q*yC-{J^$lQ0fjT4=6ri4wYyg>aoM9M3;C^X<>v;)_k3XT z4s3ZR6xPJ>+V*?=w8puU(&n9i!~XcvqqhGXt$y#PB_>(ky7~B3?UALGPZMgJ1NK_h zzA0XQec`It{WFS%KR=V%ddlhLg2dy^a^}K^Pp@CRch8}R*UWmeV*k%bo}*S|C^vPL b!xMgY{}~p+j*m5fK4tK9^>bP0l+XkKkcO5N literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index c3acffc..17d57de 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -392,6 +392,12 @@ + + + + + +
diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/ScaseUiConstants.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/ScaseUiConstants.java index fcf6623..388fc3b 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/ScaseUiConstants.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/ScaseUiConstants.java @@ -52,6 +52,12 @@ private ScaseUiConstants() { /** Link ontologies command ID. */ public static final String COMMAND_EXPORTONTOLOGY = "eu.scasefp7.eclipse.core.commands.linkOntologies"; //$NON-NLS-1$ + /** Paths to project folders*/ + public static final String REQUIREMENTS_FOLDER = "eu.scasefp7.eclipse.core.ui.rqsFolder"; //$NON-NLS-1$ + public static final String COMPOSITIONS_FOLDER = "eu.scasefp7.eclipse.core.ui.compFolder"; //$NON-NLS-1$ + public static final String MODELS_FOLDER = "eu.scasefp7.eclipse.core.ui.modelsFolder"; //$NON-NLS-1$ + public static final String OUTPUT_FOLDER = "eu.scasefp7.eclipse.core.ui.outputFolder"; //$NON-NLS-1$ + /* These are external, included here for convenience */ diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ScaseLabel.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ScaseLabel.java new file mode 100644 index 0000000..3b6d9ba --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ScaseLabel.java @@ -0,0 +1,52 @@ +package eu.scasefp7.eclipse.core.ui.navigator; + +import java.net.URL; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.IDecoration; +import org.eclipse.jface.viewers.ILightweightLabelDecorator; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.ui.internal.util.BundleUtility; +import org.osgi.framework.Bundle; + +import eu.scasefp7.eclipse.core.ui.ScaseUiConstants; + +public class ScaseLabel extends LabelProvider implements ILightweightLabelDecorator { + + @Override + public void decorate(Object resource, IDecoration decoration) { + if(resource instanceof IFolder){ + IProject project = ((IFolder)resource).getProject(); + String modelsPath = ""; + String outputPath = ""; + String reqPath = ""; + String comPath = ""; + String resourcePath = ((IFolder) resource).getFullPath().toString(); + + Bundle bundle = Platform.getBundle("eu.scasefp7.eclipse.core.ui"); + URL fullPathString = BundleUtility.find(bundle, "icons/s-case_8x8.png"); + + try { + comPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER)); + reqPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER)); + modelsPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.MODELS_FOLDER)); + outputPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(resourcePath.equals(comPath) || resourcePath.equals(reqPath) || resourcePath.equals(modelsPath) || resourcePath.equals(outputPath) ){ + decoration.addOverlay(ImageDescriptor.createFromURL(fullPathString), IDecoration.TOP_RIGHT); + + } + } + + } + + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java index b86fc67..f3ff6b4 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/NewScaseProjectWizard2.java @@ -80,7 +80,7 @@ public void addPages() { // TODO Auto-generated catch block e.printStackTrace(); } - + } } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectWizardPageTwo.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectWizardPageTwo.java new file mode 100644 index 0000000..4fb66ed --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectWizardPageTwo.java @@ -0,0 +1,291 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowData; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; + +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; + +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; + +import eu.scasefp7.eclipse.core.ui.ScaseUiConstants; + +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.QualifiedName; + + +public class ScaseProjectWizardPageTwo extends WizardPage implements IScaseWizardPage{ + String modelsPath = ""; + String outputPath = ""; + String reqPath = ""; + String comPath = ""; + + protected ScaseProjectWizardPageTwo(String pageName) { + super(pageName); + // TODO Auto-generated constructor stub + } + + + @Override + public void createControl(Composite parent) { + initializeDialogUnits(parent); + + final Composite composite= new Composite(parent, SWT.NULL); + composite.setFont(parent.getFont()); + GridLayout layout = new GridLayout(); + layout.numColumns = 3; + composite.setLayout(layout); + composite.setLayoutData(new GridData(SWT.BEGINNING)); + + Label a = new Label(composite, SWT.NULL); + a.setText ("The models will be stored in folder:"); + GridData gridData1 = new GridData(); + gridData1.horizontalAlignment = GridData.FILL; + gridData1.horizontalSpan = 3; + a.setLayoutData(gridData1); + + Label label = new Label(composite, SWT.NULL); + Text models = new Text(composite, SWT.BORDER); + GridData gridData = new GridData(); + gridData.horizontalAlignment = SWT.FILL; + gridData.grabExcessHorizontalSpace = true; + + final Button button = new Button(composite, SWT.PUSH); + + label.setText("Models folder path: "); + models.setText("/models"); + button.setText("Browse..."); + models.setLayoutData(gridData); + + + IContainer root = ResourcesPlugin.getWorkspace().getRoot(); + button.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event e) { + Path resPath; + switch (e.type) { + case SWT.Selection: + + ContainerSelectionDialog dlg = new ContainerSelectionDialog (parent.getShell(), root, true, null); + dlg.setMessage("Select a directory"); + dlg.open(); + Object[] res = dlg.getResult(); + if(res != null) + { + resPath = (Path ) res[0]; + models.setText(resPath.toString()); + modelsPath = resPath.toString(); + } + + break; + } + } + + }); + + //Empty row + Label e1 = new Label(composite, SWT.NULL); + GridData gridData11 = new GridData(); + gridData11.horizontalAlignment = GridData.FILL; + gridData11.horizontalSpan = 3; + e1.setLayoutData(gridData11); + + Label a2 = new Label(composite, SWT.NULL); + a2.setText ("The generated code will be stored in folder:"); + GridData gridData2 = new GridData(); + gridData2.horizontalAlignment = GridData.FILL; + gridData2.horizontalSpan = 3; + a2.setLayoutData(gridData2); + + Label label2 = new Label(composite, SWT.NULL); + Text output = new Text(composite, SWT.BORDER); + final Button button2 = new Button(composite, SWT.PUSH); + + label2.setText("Output folder path: "); + output.setText("/output"); + button2.setText("Browse..."); + output.setLayoutData(gridData); + + button2.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event e) { + Path resPath; + switch (e.type) { + case SWT.Selection: + + ContainerSelectionDialog dlg = new ContainerSelectionDialog (parent.getShell(), root, true, null); + dlg.setMessage("Select a directory"); + dlg.open(); + Object[] res = dlg.getResult(); + if(res != null) + { + resPath = (Path ) res[0]; + output.setText(resPath.toString()); + outputPath = resPath.toString(); + } + + break; + } + } + + }); + + //Empty row + Label e2 = new Label(composite, SWT.NULL); + GridData gridData21 = new GridData(); + gridData21.horizontalAlignment = GridData.FILL; + gridData21.horizontalSpan = 3; + e2.setLayoutData(gridData21); + + Label a3 = new Label(composite, SWT.NULL); + a3.setText ("The requirements will be stored in folder:"); + GridData gridData3 = new GridData(); + gridData3.horizontalAlignment = GridData.FILL; + gridData3.horizontalSpan = 3; + a3.setLayoutData(gridData3); + + Label label3 = new Label(composite, SWT.NULL); + Text requirements = new Text(composite, SWT.BORDER); + final Button button3 = new Button(composite, SWT.PUSH); + + label3.setText("Requirements folder path: "); + requirements.setText("/requirements"); + button3.setText("Browse..."); + requirements.setLayoutData(gridData); + + button3.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event e) { + Path resPath; + switch (e.type) { + case SWT.Selection: + + ContainerSelectionDialog dlg = new ContainerSelectionDialog (parent.getShell(), root, true, null); + dlg.setMessage("Select a directory"); + dlg.open(); + Object[] res = dlg.getResult(); + if(res != null) + { + resPath = (Path ) res[0]; + requirements.setText(resPath.toString()); + reqPath = resPath.toString(); + } + + break; + } + } + + }); + + //Empty row + Label e3 = new Label(composite, SWT.NULL); + GridData gridData31 = new GridData(); + gridData31.horizontalAlignment = GridData.FILL; + gridData31.horizontalSpan = 3; + e3.setLayoutData(gridData31); + + Label a4 = new Label(composite, SWT.NULL); + a4.setText ("The storyboards used for composition will be in folder:"); + GridData gridData4 = new GridData(); + gridData4.horizontalAlignment = GridData.FILL; + gridData4.horizontalSpan = 3; + a4.setLayoutData(gridData4); + + Label label4 = new Label(composite, SWT.NULL); + Text compositions = new Text(composite, SWT.BORDER); + final Button button4 = new Button(composite, SWT.PUSH); + + label4.setText("Compositions folder path: "); + compositions.setText("/compositions"); + button4.setText("Browse..."); + compositions.setLayoutData(gridData); + + button4.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event e) { + Path resPath; + switch (e.type) { + case SWT.Selection: + + ContainerSelectionDialog dlg = new ContainerSelectionDialog (parent.getShell(), root, true, null); + dlg.setMessage("Select a directory"); + dlg.open(); + Object[] res = dlg.getResult(); + if(res != null) + { + resPath = (Path ) res[0]; + compositions.setText(resPath.toString()); + comPath = resPath.toString(); + } + + break; + } + } + + }); + + + + setControl(composite); + } + + + @Override + public boolean performFinish(IResource resource) { + IProject project = (IProject) resource; + IFolder models = project.getFolder("models"); + IFolder output = project.getFolder("output"); + IFolder requirements = project.getFolder("requirements"); + IFolder compositions = project.getFolder("compositions"); + + IProgressMonitor monitor = new NullProgressMonitor(); + try { + models.create(true, true, monitor); + output.create(true, true, monitor); + requirements.create(true, true, monitor); + compositions.create(true, true, monitor); + + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String projectName = project.getName(); + if(modelsPath.equals("")) + modelsPath = "/" + projectName + "/models"; + if(outputPath.equals("")) + outputPath = "/" + projectName + "/output"; + if(reqPath.equals("")) + reqPath = "/" + projectName + "/requirements"; + if(comPath.equals("")) + comPath = "/" + projectName + "/compositions"; + + try { + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.MODELS_FOLDER), modelsPath); + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER), outputPath); + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER), reqPath); + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER), comPath); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + +} From 1d54143facdbc69cc3ce8ace379bb30a898f54f5 Mon Sep 17 00:00:00 2001 From: eleogas Date: Fri, 12 Feb 2016 14:39:46 +0100 Subject: [PATCH 15/29] Dashboard logging and tracing --- eu.scasefp7.eclipse.core.ui/.options | 2 +- .../META-INF/MANIFEST.MF | 3 +- eu.scasefp7.eclipse.core.ui/plugin.xml | 9 ++ ...eclipse.core.ui.newSCaseProjectWizard.exsd | 126 ------------------ .../scasefp7/eclipse/core/ui/Activator.java | 10 +- .../eclipse/core/ui/views/Dashboard.java | 90 +++++++++++-- 6 files changed, 98 insertions(+), 142 deletions(-) delete mode 100644 eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.newSCaseProjectWizard.exsd diff --git a/eu.scasefp7.eclipse.core.ui/.options b/eu.scasefp7.eclipse.core.ui/.options index 0a71650..01b0d6c 100644 --- a/eu.scasefp7.eclipse.core.ui/.options +++ b/eu.scasefp7.eclipse.core.ui/.options @@ -1,4 +1,4 @@ # Tracing options for the eu.scasefp7.eclipse.core.ui plug-in eu.scasefp7.eclipse.core.ui/debug=false -eu.scasefp7.eclipse.core.ui/debug/userActions=false +eu.scasefp7.eclipse.core.ui/debug/userActions=false \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF index 7a16ac1..0659af8 100644 --- a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF @@ -17,8 +17,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.variables, org.eclipse.equinox.security, org.eclipse.m2e.core, - org.eclipse.m2e.maven.runtime, - org.eclipse.jdt.ui + org.eclipse.m2e.maven.runtime Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: eu.scasefp7.eclipse.core.ui Bundle-Vendor: %Bundle-Vendor diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 646630e..be0b6f3 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -394,4 +394,13 @@ state="true"> + + + + + +
diff --git a/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.newSCaseProjectWizard.exsd b/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.newSCaseProjectWizard.exsd deleted file mode 100644 index d62edf4..0000000 --- a/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.newSCaseProjectWizard.exsd +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java index 4af86ec..5f47635 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java @@ -1,6 +1,7 @@ package eu.scasefp7.eclipse.core.ui; import java.util.Dictionary; + import java.util.Hashtable; import org.eclipse.osgi.service.debug.DebugOptions; @@ -9,6 +10,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; + /** * The activator class controls the plug-in life cycle */ @@ -26,6 +28,8 @@ public class Activator extends AbstractUIPlugin implements DebugOptionsListener // fields to cache the debug flags public static boolean DEBUG = false; public static DebugTrace trace = null; + + /** * The constructor */ @@ -42,13 +46,15 @@ public void start(BundleContext context) throws Exception { props.put(DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID); context.registerService(DebugOptionsListener.class.getName(), this, props); plugin = this; + + } /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ - public void stop(BundleContext context) throws Exception { + public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); } @@ -62,6 +68,7 @@ public static Activator getDefault() { return plugin; } + /** * Returns the shared image registry * @@ -77,6 +84,7 @@ public static SharedImages getImages() { @Override public void optionsChanged(DebugOptions options) { DEBUG = options.getBooleanOption(PLUGIN_ID + "/debug", false); + //DEBUG = true; trace = options.newDebugTrace(PLUGIN_ID); } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java index 4b5dede..2279ab3 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java @@ -15,11 +15,16 @@ */ package eu.scasefp7.eclipse.core.ui.views; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.maven.plugin.logging.Log; import org.eclipse.core.commands.Command; import org.eclipse.core.commands.CommandEvent; import org.eclipse.core.commands.ExecutionException; @@ -38,11 +43,14 @@ import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IRegistryEventListener; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.InvalidRegistryObjectException; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.RegistryFactory; +import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; @@ -115,6 +123,8 @@ public class Dashboard extends ViewPart implements ISelectionListener, IRegistry private static final String CONTRIBUTION_COMMAND_NOTIFICATION_FAIL = "error"; protected HashMap registeredCommandListeners = new HashMap(); + + private static ILog pluginLog = Activator.getDefault().getLog(); /** * The currently selected project @@ -337,14 +347,18 @@ private void handleButton(Composite parent, IConfigurationElement elem) throws I btn.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { + String startTimestamp = ZonedDateTime.now( ZoneId.systemDefault() ).truncatedTo( ChronoUnit.SECONDS ) + .format( DateTimeFormatter.ISO_OFFSET_DATE_TIME ); try { - - Activator.trace.trace("/debug/userActions", "Button pressed: "+name); + Activator.trace.trace("/debug/userActions", "Button pressed: "+name); executeCommand(commandId); notifyUser(commandId, notificationSuccess); - } catch (CommandException ex) { + + } catch ( CommandException ex) { notifyUser(commandId, notificationFail, ex); ex.printStackTrace(); + String logEntry = failureFormater(name, startTimestamp, ex.getLocalizedMessage()); + pluginLog.log(new Status(IStatus.ERROR, ID, logEntry, ex)); } } }); @@ -353,13 +367,18 @@ public void mouseDown(MouseEvent e) { btn.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { + String startTimestamp = ZonedDateTime.now( ZoneId.systemDefault() ).truncatedTo( ChronoUnit.SECONDS ) + .format( DateTimeFormatter.ISO_OFFSET_DATE_TIME ); try { - Activator.trace.trace("/debug/userActions", "Button pressed: "+name); + + Activator.trace.trace("/debug/userActions", "Button pressed: "+name); executeCommand(commandId, params); - notifyUser(commandId, notificationSuccess); - } catch (CommandException ex) { + notifyUser(commandId, notificationSuccess); + } catch (CommandException ex) { notifyUser(commandId, notificationFail, ex); - ex.printStackTrace(); + + String logEntry = failureFormater(name, startTimestamp, ex.getLocalizedMessage()); + pluginLog.log(new Status(IStatus.ERROR, ID, logEntry, ex)); } } }); @@ -438,11 +457,20 @@ public void commandChanged(CommandEvent cmdEvent) { * @throws CommandException if the command execution fails */ protected void executeCommand(String commandId, Map parameters) throws CommandException { + String startTimestamp = ZonedDateTime.now( ZoneId.systemDefault() ).truncatedTo( ChronoUnit.SECONDS ) + .format( DateTimeFormatter.ISO_OFFSET_DATE_TIME ); // Obtain IServiceLocator implementer, e.g. from PlatformUI.getWorkbench(): IServiceLocator serviceLocator = getSite(); // or a site from within a editor or view: // IServiceLocator serviceLocator = getSite(); - + String par =""; + + for (String key : parameters.keySet()) { + System.out.println("Key = " + key); + parameters.get(key); + par+=key+" : " + parameters.get(key) + ", "; + } + Activator.trace.trace("/debug/userActions", "Command called: "+commandId+", parameters: " + par.substring(0,par.length()-2)); ICommandService commandService = (ICommandService)serviceLocator.getService(ICommandService.class); IHandlerService handlerService = (IHandlerService)serviceLocator.getService(IHandlerService.class); @@ -465,7 +493,9 @@ protected void executeCommand(String commandId, Map parameters) } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException ex) { - + String logEntry = failureFormater(commandId, startTimestamp, ex.getLocalizedMessage()); + pluginLog.log(new Status(IStatus.ERROR, ID, logEntry, ex)); + //pluginLog.log(new Status(IStatus.ERROR, ID, ex.getLocalizedMessage(), ex)); throw ex; } } @@ -478,11 +508,13 @@ protected void executeCommand(String commandId, Map parameters) * @throws CommandException if the command execution fails */ protected void executeCommand(String commandId) throws CommandException { + String startTimestamp = ZonedDateTime.now( ZoneId.systemDefault() ).truncatedTo( ChronoUnit.SECONDS ) + .format( DateTimeFormatter.ISO_DATE_TIME ); // Obtain IServiceLocator implementer, e.g. from PlatformUI.getWorkbench(): IServiceLocator serviceLocator = getSite(); // or a site from within a editor or view: // IServiceLocator serviceLocator = getSite(); - + Activator.trace.trace("/debug/userActions", "Command called: "+commandId); IHandlerService handlerService = (IHandlerService)serviceLocator.getService(IHandlerService.class); try { // Execute command via its ID @@ -490,7 +522,9 @@ protected void executeCommand(String commandId) throws CommandException { } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException ex) { - + String logEntry = failureFormater(commandId, startTimestamp, ex.getLocalizedMessage()); + pluginLog.log(new Status(IStatus.ERROR, ID, logEntry, ex)); + //pluginLog.log(new Status(IStatus.ERROR, ID, ex.getLocalizedMessage(), ex)); throw ex; } } @@ -624,13 +658,16 @@ private DomainEntry findDomainById(DomainEntry[] domains, int domainId) { } private static int getProjectDomainId(IProject project) { + String startTimestamp = ZonedDateTime.now( ZoneId.systemDefault() ).truncatedTo( ChronoUnit.MINUTES ) + .format( DateTimeFormatter.ISO_OFFSET_DATE_TIME ); try { String domain = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.PROP_PROJECT_DOMAIN)); if(domain != null) { return Integer.parseInt(domain); } } catch (CoreException | NumberFormatException e) { - + String logEntry = failureFormater("getProjectDomainId", startTimestamp, e.getLocalizedMessage()); + pluginLog.log(new Status(IStatus.ERROR, ID, logEntry, e)); } return ScaseUiConstants.PROP_PROJECT_DOMAIN_DEFAULT; } @@ -658,5 +695,34 @@ public void removed(IExtensionPoint[] extensionPoints) { // TODO Auto-generated method stub } + + private static String failureFormater(String name, String startTime, String message){ + + //incremental id in the form t0, t1, t2, t3,... + String Id = "t0"; + //the name of the service we are monitoring and logging + String serviceName = "svc"; + //the version of the released service under execution/test + String serviceVersion = "0.0"; + //the UTC date when the service operational execution (re)started + String startingServiceOperationalTestingTime = startTime; + //the component where the fault and error raise + String className = "Dashboard"; + //the component where the fault and error raise + String functionName = name; + //the UTC date when the failure happen + String failureTimestamp = ZonedDateTime.now( ZoneId.systemDefault() ).truncatedTo( ChronoUnit.SECONDS ) + .format( DateTimeFormatter.ISO_OFFSET_DATE_TIME ); + //a human-readable message about the detected error + String errorMsg = message; + return errorMsg + "\n" + + "Id: " + Id + "\n" + + "Service name: " + serviceName + "\n" + + "Service version: " + serviceVersion +"\n" + + "Starting service time: " + startingServiceOperationalTestingTime + "\n" + + "Class name: " + className + "\n" + + "Component name: " + functionName + "\n" + + "Service name: " + failureTimestamp ; + } } From 326e57e6e11900436bcca7b58cd77347d506f9ca Mon Sep 17 00:00:00 2001 From: eleogas Date: Wed, 24 Feb 2016 16:48:20 +0100 Subject: [PATCH 16/29] Builder extension point --- ...p7.eclipse.core.ui.projectWizardPages.exsd | 2 +- .../scasefp7/eclipse/core/ui/Activator.java | 1 - .../eclipse/core/ui/builder/SCaseBuilder.java | 221 ------- .../eclipse/core/ui/builder/SCaseNature.java | 58 +- .../eclipse/core/ui/views/Dashboard.java | 28 +- eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF | 3 +- eu.scasefp7.eclipse.core/plugin.xml | 54 +- .../eu.scasefp7.eclipse.core.builder.exsd | 278 ++++++++ .../core/builder/ScaseProjectBuilder.java | 623 ++++++++++++------ .../core/handlers/LinkOntologiesHandler.java | 12 + .../core/handlers/OntologyToYamlHandler.java | 11 + 11 files changed, 806 insertions(+), 485 deletions(-) delete mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java create mode 100644 eu.scasefp7.eclipse.core/schema/eu.scasefp7.eclipse.core.builder.exsd diff --git a/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.projectWizardPages.exsd b/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.projectWizardPages.exsd index 691672b..864e353 100644 --- a/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.projectWizardPages.exsd +++ b/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.projectWizardPages.exsd @@ -10,7 +10,7 @@ - + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java index 5f47635..32fbb6c 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java @@ -84,7 +84,6 @@ public static SharedImages getImages() { @Override public void optionsChanged(DebugOptions options) { DEBUG = options.getBooleanOption(PLUGIN_ID + "/debug", false); - //DEBUG = true; trace = options.newDebugTrace(PLUGIN_ID); } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java deleted file mode 100644 index 257a567..0000000 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseBuilder.java +++ /dev/null @@ -1,221 +0,0 @@ -package eu.scasefp7.eclipse.core.ui.builder; - - -import java.util.Map; -import org.eclipse.core.commands.Command; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.NotEnabledException; -import org.eclipse.core.commands.NotHandledException; -import org.eclipse.core.commands.Parameterization; -import org.eclipse.core.commands.ParameterizedCommand; -import org.eclipse.core.commands.common.NotDefinedException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.commands.ICommandService; -import org.eclipse.ui.handlers.IHandlerService; -import org.eclipse.ui.services.IServiceLocator; - - - - -public class SCaseBuilder extends IncrementalProjectBuilder { - - class SampleDeltaVisitor implements IResourceDeltaVisitor { - - public boolean visit(IResourceDelta delta) throws CoreException { - //IResource resource = delta.getResource(); - switch (delta.getKind()) { - case IResourceDelta.ADDED: - break; - case IResourceDelta.REMOVED: - break; - case IResourceDelta.CHANGED: - break; - } - - return true; - } - } - - - class SampleResourceVisitor implements IResourceVisitor { - boolean fileExsists = false; - int fileCount = 0; - IFile firstXmlFile; - public boolean visit(IResource resource) { - boolean other = checkXML(resource); - - if (resource instanceof IFile && resource.getName().endsWith(".rqs")) - executeCommand("eu.scasefp7.eclipse.reqeditor.commands.exportToOntology", resource.getFullPath().toString()); - - - if (resource instanceof IFile && resource.getName().endsWith(".sbd")) - executeCommand("eu.scasefp7.eclipse.storyboards.commands.exportToOntology", resource.getFullPath().toString()); - - - if(fileExsists && other){ - if(fileCount < 2) - addMarker(firstXmlFile, "The project must contain only one .xml file", 1, IMarker.SEVERITY_ERROR); - addMarker((IFile) resource, "The project must contain only one .xml file", 1, IMarker.SEVERITY_ERROR); - fileCount++; - } - - if(!fileExsists && other){ - fileCount++; - fileExsists = true; - firstXmlFile = (IFile)resource; - } - - - //return true to continue visiting children. - return true; - } - } - - boolean checkXML(IResource resource) { - if (resource instanceof IFile && resource.getName().endsWith(".xml")) { - return true; - } - return false; - } - - - - protected void executeCommand(String commandId) { - // Obtain IServiceLocator implementer, e.g. from PlatformUI.getWorkbench(): - IServiceLocator serviceLocator = PlatformUI.getWorkbench(); - // or a site from within a editor or view: - // IServiceLocator serviceLocator = getSite(); - - IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class); - try { - // Execute commmand via its ID - - handlerService.executeCommand(commandId, null); - } catch (ExecutionException | NotDefinedException | - NotEnabledException | NotHandledException ex) { - // Replace with real-world exception handling - ex.printStackTrace(); - } - } - - protected void executeCommand(String commandId, String fileName) { - IServiceLocator serviceLocator = PlatformUI.getWorkbench(); - - ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class); - IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class); - - - try { - Command command = commandService.getCommand(commandId); - - Parameterization[] params = new Parameterization[] { new Parameterization( - command.getParameter("fileName"), (String) fileName) }; - - ParameterizedCommand parametrizedCommand = new ParameterizedCommand(command , params); - - handlerService.executeCommand(parametrizedCommand, null); - - - } catch (ExecutionException | NotDefinedException | - NotEnabledException | NotHandledException ex) { - // Replace with real-world exception handling - ex.printStackTrace(); - } - - } - - - public static final String BUILDER_ID = "eu.scasefp7.eclipse.core.ui.scaseBuilder"; - - private static final String MARKER_TYPE = "eu.scasefp7.eclipse.core.ui.rqsProblem"; - - - private void addMarker(IFile file, String message, int lineNumber, - int severity) { - try { - IMarker marker = file.createMarker(MARKER_TYPE); - marker.setAttribute(IMarker.MESSAGE, message); - marker.setAttribute(IMarker.SEVERITY, severity); - if (lineNumber == -1) { - lineNumber = 1; - } - marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); - } catch (CoreException e) { - } - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.internal.events.InternalBuilder#build(int, - * java.util.Map, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IProject[] build(int kind, Map args, IProgressMonitor monitor) - throws CoreException { - if (kind == FULL_BUILD) { - fullBuild(monitor); - } else { - IResourceDelta delta = getDelta(getProject()); - if (delta == null) { - fullBuild(monitor); - } else { - incrementalBuild(delta, monitor); - } - } - return null; - } - - protected void clean(IProgressMonitor monitor) throws CoreException { - // delete markers set and files created - getProject().deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE); - } - - - - private void deleteMarkers(IFile file) { - try { - file.deleteMarkers(MARKER_TYPE, false, IResource.DEPTH_ZERO); - } catch (CoreException ce) { - } - } - - - - - protected void fullBuild(final IProgressMonitor monitor) - throws CoreException { - try { - clean(monitor); - getProject().accept(new SampleResourceVisitor()); - //executeCommand("eu.scasefp7.eclipse.core.commands.linkOntologies"); - - } catch (CoreException e) { - } - } - - - - protected void incrementalBuild(IResourceDelta delta, - IProgressMonitor monitor) throws CoreException { - try { - clean(monitor); - //delta.accept(new SampleDeltaVisitor()); - getProject().accept(new SampleResourceVisitor()); - // executeCommand("eu.scasefp7.eclipse.core.commands.linkOntologies"); - } catch (CoreException e) { - System.out.println(e); - } - } - -} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseNature.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseNature.java index 5c38426..6bbd5a4 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseNature.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/builder/SCaseNature.java @@ -15,22 +15,22 @@ public class SCaseNature implements IProjectNature { @Override public void configure() throws CoreException { - IProjectDescription desc = project.getDescription(); - ICommand[] commands = desc.getBuildSpec(); - - for (int i = 0; i < commands.length; ++i) { - if (commands[i].getBuilderName().equals(SCaseBuilder.BUILDER_ID)) { - return; - } - } - - ICommand[] newCommands = new ICommand[commands.length + 1]; - System.arraycopy(commands, 0, newCommands, 0, commands.length); - ICommand command = desc.newCommand(); - command.setBuilderName(SCaseBuilder.BUILDER_ID); - newCommands[newCommands.length - 1] = command; - desc.setBuildSpec(newCommands); - project.setDescription(desc, null); +// IProjectDescription desc = project.getDescription(); +// ICommand[] commands = desc.getBuildSpec(); +// +// for (int i = 0; i < commands.length; ++i) { +// if (commands[i].getBuilderName().equals(SCaseBuilder.BUILDER_ID)) { +// return; +// } +// } +// +// ICommand[] newCommands = new ICommand[commands.length + 1]; +// System.arraycopy(commands, 0, newCommands, 0, commands.length); +// ICommand command = desc.newCommand(); +// command.setBuilderName(SCaseBuilder.BUILDER_ID); +// newCommands[newCommands.length - 1] = command; +// desc.setBuildSpec(newCommands); +// project.setDescription(desc, null); } /* @@ -39,19 +39,19 @@ public void configure() throws CoreException { * @see org.eclipse.core.resources.IProjectNature#deconfigure() */ public void deconfigure() throws CoreException { - IProjectDescription description = getProject().getDescription(); - ICommand[] commands = description.getBuildSpec(); - for (int i = 0; i < commands.length; ++i) { - if (commands[i].getBuilderName().equals(SCaseBuilder.BUILDER_ID)) { - ICommand[] newCommands = new ICommand[commands.length - 1]; - System.arraycopy(commands, 0, newCommands, 0, i); - System.arraycopy(commands, i + 1, newCommands, i, - commands.length - i - 1); - description.setBuildSpec(newCommands); - project.setDescription(description, null); - return; - } - } +// IProjectDescription description = getProject().getDescription(); +// ICommand[] commands = description.getBuildSpec(); +// for (int i = 0; i < commands.length; ++i) { +// if (commands[i].getBuilderName().equals(SCaseBuilder.BUILDER_ID)) { +// ICommand[] newCommands = new ICommand[commands.length - 1]; +// System.arraycopy(commands, 0, newCommands, 0, i); +// System.arraycopy(commands, i + 1, newCommands, i, +// commands.length - i - 1); +// description.setBuildSpec(newCommands); +// project.setDescription(description, null); +// return; +// } +// } } /* diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java index 2279ab3..80bafc1 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java @@ -82,6 +82,7 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.handlers.IHandlerService; +import org.eclipse.ui.internal.registry.RegistryReader; import org.eclipse.ui.menus.CommandContributionItem; import org.eclipse.ui.menus.CommandContributionItemParameter; import org.eclipse.ui.part.ViewPart; @@ -125,6 +126,7 @@ public class Dashboard extends ViewPart implements ISelectionListener, IRegistry protected HashMap registeredCommandListeners = new HashMap(); private static ILog pluginLog = Activator.getDefault().getLog(); + static int incrementalId = 0; /** * The currently selected project @@ -379,6 +381,7 @@ public void mouseDown(MouseEvent e) { String logEntry = failureFormater(name, startTimestamp, ex.getLocalizedMessage()); pluginLog.log(new Status(IStatus.ERROR, ID, logEntry, ex)); + } } }); @@ -495,7 +498,7 @@ protected void executeCommand(String commandId, Map parameters) NotEnabledException | NotHandledException ex) { String logEntry = failureFormater(commandId, startTimestamp, ex.getLocalizedMessage()); pluginLog.log(new Status(IStatus.ERROR, ID, logEntry, ex)); - //pluginLog.log(new Status(IStatus.ERROR, ID, ex.getLocalizedMessage(), ex)); + throw ex; } } @@ -514,7 +517,7 @@ protected void executeCommand(String commandId) throws CommandException { IServiceLocator serviceLocator = getSite(); // or a site from within a editor or view: // IServiceLocator serviceLocator = getSite(); - Activator.trace.trace("/debug/userActions", "Command called: "+commandId); + Activator.trace.trace("/debug/userActions", "Command called: "+commandId); IHandlerService handlerService = (IHandlerService)serviceLocator.getService(IHandlerService.class); try { // Execute command via its ID @@ -699,11 +702,12 @@ public void removed(IExtensionPoint[] extensionPoints) { private static String failureFormater(String name, String startTime, String message){ //incremental id in the form t0, t1, t2, t3,... - String Id = "t0"; + String Id = "t" + incrementalId; + incrementalId++; //the name of the service we are monitoring and logging - String serviceName = "svc"; + String serviceName = "S-Case Dashboard"; //the version of the released service under execution/test - String serviceVersion = "0.0"; + String serviceVersion = "1.0.0-SNAPSHOT"; //the UTC date when the service operational execution (re)started String startingServiceOperationalTestingTime = startTime; //the component where the fault and error raise @@ -716,13 +720,13 @@ private static String failureFormater(String name, String startTime, String mess //a human-readable message about the detected error String errorMsg = message; return errorMsg + "\n" - + "Id: " + Id + "\n" - + "Service name: " + serviceName + "\n" - + "Service version: " + serviceVersion +"\n" - + "Starting service time: " + startingServiceOperationalTestingTime + "\n" - + "Class name: " + className + "\n" - + "Component name: " + functionName + "\n" - + "Service name: " + failureTimestamp ; + + "ERROR_ID t " + Id + "\n" + + "SERVICE_NAME " + serviceName + "\n" + + "SERVICE_VERSION " + serviceVersion +"\n" + + "STARTING_TIME: " + startingServiceOperationalTestingTime + "\n" + + "CLASS_NAME " + className + "\n" + + "FUNCTION_NAME " + functionName + "\n" + + "FAILURE_TIMESTAMP " + failureTimestamp ; } } diff --git a/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF index 58cda01..214b656 100644 --- a/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF @@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.ui.workbench, org.eclipse.core.commands, org.eclipse.jface, org.eclipse.core.resources, - org.eclipse.ui + org.eclipse.ui, + org.eclipse.core.variables Bundle-ClassPath: . Export-Package: eu.scasefp7.eclipse.core, eu.scasefp7.eclipse.core.builder, diff --git a/eu.scasefp7.eclipse.core/plugin.xml b/eu.scasefp7.eclipse.core/plugin.xml index 6fc6624..3cfcedf 100644 --- a/eu.scasefp7.eclipse.core/plugin.xml +++ b/eu.scasefp7.eclipse.core/plugin.xml @@ -1,7 +1,7 @@ - + @@ -19,11 +19,21 @@ categoryId="eu.scasefp7.eclipse.core.commands.category" id="eu.scasefp7.eclipse.core.commands.linkOntologies" name="Link Ontologies"> + + + + - \ No newline at end of file + + + + + + + + + + + + + + + + + + +
diff --git a/eu.scasefp7.eclipse.core/schema/eu.scasefp7.eclipse.core.builder.exsd b/eu.scasefp7.eclipse.core/schema/eu.scasefp7.eclipse.core.builder.exsd new file mode 100644 index 0000000..85d5f0f --- /dev/null +++ b/eu.scasefp7.eclipse.core/schema/eu.scasefp7.eclipse.core.builder.exsd @@ -0,0 +1,278 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/builder/ScaseProjectBuilder.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/builder/ScaseProjectBuilder.java index 2ab3ef2..3993cd6 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/builder/ScaseProjectBuilder.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/builder/ScaseProjectBuilder.java @@ -1,218 +1,405 @@ -package eu.scasefp7.eclipse.core.builder; - -import java.util.Map; - -import org.eclipse.core.commands.Command; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.NotEnabledException; -import org.eclipse.core.commands.NotHandledException; -import org.eclipse.core.commands.Parameterization; -import org.eclipse.core.commands.ParameterizedCommand; -import org.eclipse.core.commands.common.NotDefinedException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.commands.ICommandService; -import org.eclipse.ui.handlers.IHandlerService; -import org.eclipse.ui.services.IServiceLocator; - -/** - * Builder for S-CASE projects. - * - * @author Leonora Gašpar - * @author Marin Orlić - * - */ -public class ScaseProjectBuilder extends IncrementalProjectBuilder { - - /** - * Builder ID - */ - public static final String BUILDER_ID = "eu.scasefp7.eclipse.core.scaseBuilder"; - - /** - * Marker ID - */ - private static final String MARKER_TYPE = "eu.scasefp7.eclipse.core.problemMarker"; - - class SampleDeltaVisitor implements IResourceDeltaVisitor { - - public boolean visit(IResourceDelta delta) throws CoreException { - // IResource resource = delta.getResource(); - switch (delta.getKind()) { - case IResourceDelta.ADDED: - break; - case IResourceDelta.REMOVED: - break; - case IResourceDelta.CHANGED: - break; - } - - return true; - } - } - - class SampleResourceVisitor implements IResourceVisitor { - boolean fileExsists = false; - int fileCount = 0; - IFile firstXmlFile; - - public boolean visit(IResource resource) { -// boolean other = checkXML(resource); - -// if (resource instanceof IFile && resource.getName().endsWith(".rqs")) -// executeCommand("eu.scasefp7.eclipse.reqeditor.commands.exportToOntology", resource.getFullPath() -// .toString()); -// -// if (resource instanceof IFile && resource.getName().endsWith(".sbd")) -// executeCommand("eu.scasefp7.eclipse.storyboards.commands.exportToOntology", resource.getFullPath() -// .toString()); - - -// if (resource instanceof IFile && ( -// resource.getName().equals("StaticOntology.owl") -// || resource.getName().equals("DynamicOntology.owl"))) { -// executeCommand("eu.scasefp7.eclipse.core.commands.linkOntologies"); -// } - - - -// -// if (fileExsists && other) { -// if (fileCount < 2) -// addMarker(firstXmlFile, "The project must contain only one .xml file", 1, IMarker.SEVERITY_ERROR); -// addMarker((IFile) resource, "The project must contain only one .xml file", 1, IMarker.SEVERITY_ERROR); -// fileCount++; -// } -// -// if (!fileExsists && other) { -// fileCount++; -// fileExsists = true; -// firstXmlFile = (IFile) resource; -// } - - // return true to continue visiting children. - return true; - } - } - - boolean checkXML(IResource resource) { - if (resource instanceof IFile && resource.getName().endsWith(".xml")) { - return true; - } - return false; - } - - protected void executeCommand(String commandId) { - // Obtain IServiceLocator implementer, e.g. from PlatformUI.getWorkbench(): - IServiceLocator serviceLocator = PlatformUI.getWorkbench(); - // or a site from within a editor or view: - // IServiceLocator serviceLocator = getSite(); - - IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class); - try { - // Execute commmand via its ID - - handlerService.executeCommand(commandId, null); - } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException ex) { - // Replace with real-world exception handling - ex.printStackTrace(); - } - } - - protected void executeCommand(String commandId, String fileName) { - IServiceLocator serviceLocator = PlatformUI.getWorkbench(); - - ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class); - IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class); - - try { - Command command = commandService.getCommand(commandId); - - Parameterization[] params = new Parameterization[] { new Parameterization(command.getParameter("fileName"), - (String) fileName) }; - - ParameterizedCommand parametrizedCommand = new ParameterizedCommand(command, params); - - handlerService.executeCommand(parametrizedCommand, null); - - } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException ex) { - // Replace with real-world exception handling - ex.printStackTrace(); - } - - } - - -// private void addMarker(IFile file, String message, int lineNumber, int severity) { -// try { -// IMarker marker = file.createMarker(MARKER_TYPE); -// marker.setAttribute(IMarker.MESSAGE, message); -// marker.setAttribute(IMarker.SEVERITY, severity); -// if (lineNumber == -1) { -// lineNumber = 1; -// } -// marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); -// } catch (CoreException e) { -// } -// } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.internal.events.InternalBuilder#build(int, - * java.util.Map, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor) throws CoreException { - if (kind == FULL_BUILD) { - fullBuild(monitor); - } else { - IResourceDelta delta = getDelta(getProject()); - if (delta == null) { - fullBuild(monitor); - } else { - incrementalBuild(delta, monitor); - } - } - return null; - } - - protected void clean(IProgressMonitor monitor) throws CoreException { - // delete markers set and files created - getProject().deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE); - } - - protected void deleteMarkers(IFile file) { - try { - file.deleteMarkers(MARKER_TYPE, false, IResource.DEPTH_ZERO); - } catch (CoreException ce) { - } - } - - protected void fullBuild(final IProgressMonitor monitor) throws CoreException { - try { - clean(monitor); - getProject().accept(new SampleResourceVisitor()); - } catch (CoreException e) { - } - } - - protected void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) throws CoreException { - try { - clean(monitor); - // delta.accept(new SampleDeltaVisitor()); - getProject().accept(new SampleResourceVisitor()); - } catch (CoreException e) { - System.out.println(e); - } - } - -} - +package eu.scasefp7.eclipse.core.builder; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.NotEnabledException; +import org.eclipse.core.commands.NotHandledException; +import org.eclipse.core.commands.Parameterization; +import org.eclipse.core.commands.ParameterizedCommand; +import org.eclipse.core.commands.common.NotDefinedException; +import java.io.File; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceDeltaVisitor; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.resources.ProjectScope; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IRegistryEventListener; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.variables.IDynamicVariable; +import org.eclipse.core.variables.IDynamicVariableResolver; +import org.eclipse.core.variables.IStringVariable; +import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.commands.ICommandService; +import org.eclipse.ui.handlers.IHandlerService; +import org.eclipse.ui.preferences.ScopedPreferenceStore; +import org.eclipse.ui.services.IServiceLocator; + +/** + * Builder for S-CASE projects. + * + * @author Leonora Gašpar + * @author Marin Orlić + * + */ +public class ScaseProjectBuilder extends IncrementalProjectBuilder implements ISelectionListener, IRegistryEventListener { + + /** + * Builder ID + */ + public static final String BUILDER_ID = "eu.scasefp7.eclipse.core.scaseBuilder"; + + /** + * Marker ID + */ + private static final String MARKER_TYPE = "eu.scasefp7.eclipse.core.problemMarker"; + + private static final String CONTRIBUTION_STRING = "string"; + private static final String CONTRIBUTION_VARIABLE = "variable"; + private static final String CONTRIBUTION_PREFERENCE = "preference"; + + + class BuildDeltaVisitor implements IResourceDeltaVisitor { + + public boolean visit(IResourceDelta delta) throws CoreException { + switch (delta.getKind()) { + case IResourceDelta.ADDED: + case IResourceDelta.CHANGED: + IResource resource = delta.getResource(); + if (resource instanceof IFile) { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] contributions = registry.getConfigurationElementsFor("eu.scasefp7.eclipse.core.builder"); + if (contributions.length > 0) + for (IConfigurationElement elem : contributions) + if (elem.getName().equals("buildStep")) { + String commandId = elem.getAttribute("commandId"); + String regex = elem.getAttribute("condition"); + + IConfigurationElement[] elements = elem.getChildren("commandParameters"); + boolean hasParameters = elements.length > 0; + HashMap parameters = new HashMap(); + + if(hasParameters) + getParameters(resource, parameters, elements[0]); + + if(resource.getName().matches(regex)) { + if(!hasParameters) + executeCommand(commandId, resource.getFullPath().toString()); + else + executeCommand(commandId, resource.getFullPath().toString(), parameters); + System.out.println("Command: " + commandId+" on file: "+resource.getFullPath().toString()+" (d)"); + } + } + } + + break; + case IResourceDelta.REMOVED: + case IResourceDelta.NO_CHANGE: + break; + } + + return true; + } + } + + class BuildResourceVisitor implements IResourceVisitor { + public boolean visit(IResource resource) { + + if (resource instanceof IFile) { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] contributions = registry.getConfigurationElementsFor("eu.scasefp7.eclipse.core.builder"); + if (contributions.length > 0) + for (IConfigurationElement elem : contributions) + if (elem.getName().equals("buildStep")) { + String commandId = elem.getAttribute("commandId"); + String regex = elem.getAttribute("condition"); + IConfigurationElement[] elements = elem.getChildren("commandParameters"); + boolean hasParameters = elements.length > 0; + HashMap parameters = new HashMap(); + + if(hasParameters) + getParameters(resource, parameters, elements[0]); + + if(resource.getName().matches(regex)) { + if(!hasParameters) + executeCommand(commandId, resource.getFullPath().toString()); + else + executeCommand(commandId, resource.getFullPath().toString(), parameters); + System.out.println("Command: " + commandId+" on file: "+resource.getFullPath().toString()); + } + } + } + // return true to continue visiting children. + return true; + } + } + class CleanResourceVisitor implements IResourceVisitor { + public boolean visit(IResource resource) throws CoreException { + + if (resource instanceof IFile) { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] contributions = registry.getConfigurationElementsFor("eu.scasefp7.eclipse.core.builder"); + if (contributions.length > 0) + for (IConfigurationElement elem : contributions) + if (elem.getName().equals("cleanStep")) { + + IConfigurationElement[] removals = elem.getChildren("removal"); + if(removals.length>0) + for (IConfigurationElement removal : removals) { + String regex = removal.getAttribute("condition"); + if(resource.getName().matches(regex)) { + IPath path = resource.getRawLocation(); + File file = path.toFile(); + file.delete(); + String name = resource.getName(); + resource.delete(false, null); + System.out.println("Removal: "+name + " removed!"); + + } + + } + IConfigurationElement[] commands = elem.getChildren("command"); + + if(commands.length>0) + for (IConfigurationElement command : commands) { + String regex = command.getAttribute("condition"); + String commandId = command.getAttribute("commandId"); + if(resource.getName().matches(regex)) { + IConfigurationElement[] params = command.getChildren("commandParameters"); + boolean hasParameters = params.length > 0; + HashMap parameters = new HashMap(); + if(hasParameters) + getParameters(resource, parameters, params[0]); + + if(!hasParameters) + executeCommand(commandId, resource.getFullPath().toString()); + else + executeCommand(commandId, resource.getFullPath().toString(), parameters); + System.out.println("Cleaning command...: " + commandId); + } + + } + } + } + // return true to continue visiting children. + return true; + } + } + + private void getParameters(IResource resource, HashMap parameters, IConfigurationElement elements) { + for (IConfigurationElement element : elements.getChildren()) { + if (element.getName().equals(CONTRIBUTION_STRING)) { + String paramName = element.getAttribute("name"); + String value = element.getAttribute("value"); + parameters.put(paramName, value); + } + if (element.getName().equals(CONTRIBUTION_VARIABLE)) { + String className = element.getAttribute("variableResolver"); + String variableId = element.getAttribute("variableId"); + String paramName = element.getAttribute("name"); + IStringVariable[] variables = VariablesPlugin.getDefault().getStringVariableManager().getVariables(); + + Class clazz; + try { + clazz = Class.forName(className).asSubclass(IDynamicVariableResolver.class); + IDynamicVariableResolver resolver = (IDynamicVariableResolver) clazz.newInstance(); + for (int i = 0; i < variables.length; i++) { + IDynamicVariable currVar = ((IDynamicVariable)variables[i]); + String name = currVar.getName(); + String value = ""; + if(name.equals(variableId ) ){ + value = resolver.resolveValue(currVar, null); + parameters.put(paramName, value ); + } + } + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | SecurityException | CoreException e) { + e.printStackTrace(); + } + + } + if (element.getName().equals(CONTRIBUTION_PREFERENCE)) { + String preferenceId = element.getAttribute("preferenceId"); + String pluginId = element.getAttribute("pluginId"); + String paramName = element.getAttribute("name"); + + ProjectScope ps = new ProjectScope(resource.getProject()); + ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps, pluginId); + String value = scoped.getString(preferenceId); + parameters.put(paramName, value ); + } + } + } + + + protected void executeCommand(String commandId) { + IServiceLocator serviceLocator = PlatformUI.getWorkbench(); + IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class); + try { + handlerService.executeCommand(commandId, null); + } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException ex) { + ex.printStackTrace(); + } + } + + /** + * Execution of command without parameters on resource with given name. + * @param commandId + * @param name + */ + + protected void executeCommand(String commandId, String name) { + IServiceLocator serviceLocator = PlatformUI.getWorkbench(); + + ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class); + IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class); + Command command = commandService.getCommand(commandId); + + Parameterization[] params; + try { + params = new Parameterization[] { new Parameterization(command.getParameter("fileName"), (String) name) }; + ParameterizedCommand parametrizedCommand = new ParameterizedCommand(command, params); + + handlerService.executeCommand(parametrizedCommand, null); + } catch (NotDefinedException | ExecutionException | NotEnabledException | NotHandledException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /** + * Execution of command with parameters on file with given name. + * @param commandId + * @param name + * @param parameters + */ + protected void executeCommand(String commandId, String name, HashMap parameters) { + IServiceLocator serviceLocator = PlatformUI.getWorkbench(); + + ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class); + IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class); + Command command = commandService.getCommand(commandId); + try { + List par = new ArrayList(); + par.add(new Parameterization(command.getParameter("fileName"), (String) name)); + + for(Entry e : parameters.entrySet()) + par.add(new Parameterization(command.getParameter(e.getKey()), e.getValue() )); + + Parameterization[] params = (Parameterization[]) par.toArray(new Parameterization[par.size()]); + ParameterizedCommand parametrizedCommand = new ParameterizedCommand(command, params); + handlerService.executeCommand(parametrizedCommand, null); + } catch (NotDefinedException | ExecutionException | NotEnabledException | NotHandledException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.internal.events.InternalBuilder#build(int, + * java.util.Map, org.eclipse.core.runtime.IProgressMonitor) + */ + protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor) throws CoreException { + + if (kind == FULL_BUILD) + fullBuild(monitor); + else { + IResourceDelta delta = getDelta(getProject()); + if (delta == null) { + fullBuild(monitor); + } else { + incrementalBuild(delta, monitor); + } + } + return null; + } + + + + protected void clean(IProgressMonitor monitor) throws CoreException { + // delete markers set and files created + getProject().deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE); + cleanBuild(monitor); + } + + protected void deleteMarkers(IFile file) { + try { + file.deleteMarkers(MARKER_TYPE, false, IResource.DEPTH_ZERO); + } catch (CoreException ce) { + ce.printStackTrace(); + } + } + + private void cleanBuild(IProgressMonitor monitor) { + try { + //clean(monitor); + getProject().accept(new CleanResourceVisitor()); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + protected void fullBuild(final IProgressMonitor monitor) throws CoreException { + try { + //clean(monitor); + getProject().accept(new BuildResourceVisitor()); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + protected void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) throws CoreException { + try { + //clean(monitor); + delta.accept(new BuildDeltaVisitor()); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + @Override + public void added(IExtension[] extensions) { + // TODO Auto-generated method stub + + } + + @Override + public void removed(IExtension[] extensions) { + // TODO Auto-generated method stub + + } + + @Override + public void added(IExtensionPoint[] extensionPoints) { + // TODO Auto-generated method stub + + } + + @Override + public void removed(IExtensionPoint[] extensionPoints) { + // TODO Auto-generated method stub + + } + + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + // TODO Auto-generated method stub + + } + + + + + +} + diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java index 0d7fed3..e1f7403 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java @@ -2,7 +2,10 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; import eu.scasefp7.eclipse.core.ontology.DynamicOntologyAPI; import eu.scasefp7.eclipse.core.ontology.LinkedOntologyAPI; @@ -18,6 +21,15 @@ public class LinkOntologiesHandler extends ProjectAwareHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { IProject project = getProjectOfExecutionEvent(event); + //String projectName = event.getParameter("projectName"); + String fileName = event.getParameter("fileName"); + Path path = new Path(fileName); + //When handler is called from builder + if(fileName != null){ + IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); + project = file.getProject(); + //project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + } if (project != null) { // Load the two ontologies diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/OntologyToYamlHandler.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/OntologyToYamlHandler.java index 3d8db4b..9834349 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/OntologyToYamlHandler.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/OntologyToYamlHandler.java @@ -13,7 +13,9 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; import eu.scasefp7.eclipse.core.ontology.LinkedOntologyAPI; import eu.scasefp7.eclipse.core.ontologytoyamltools.Operation; @@ -35,6 +37,15 @@ public class OntologyToYamlHandler extends ProjectAwareHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { IProject project = getProjectOfExecutionEvent(event); + //String projectName = event.getParameter("projectName"); + String fileName = event.getParameter("fileName"); + Path path = new Path(fileName); + //When handler is called from builder + if(fileName != null){ + IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); + project = file.getProject(); + //project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + } if (project != null) { // Load the ontology LinkedOntologyAPI linkedOntology = new LinkedOntologyAPI(project); From 4610feddcfa787e0c7dc8acd1b86abdd19988485 Mon Sep 17 00:00:00 2001 From: eleogas Date: Thu, 25 Feb 2016 13:39:09 +0100 Subject: [PATCH 17/29] Fixed Class cast error --- .../core/ui/preferences/ProjectDomainPropertyPage.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ProjectDomainPropertyPage.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ProjectDomainPropertyPage.java index 10b2e29..25a6a94 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ProjectDomainPropertyPage.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ProjectDomainPropertyPage.java @@ -3,6 +3,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.viewers.ISelection; @@ -254,7 +255,14 @@ public boolean performOk() { try { DomainEntry de = (DomainEntry) domainLabel.getData(); if(de != null) { - ((IResource) getElement()).setPersistentProperty(new QualifiedName("", DOMAIN_PROPERTY), Integer.toString(de.getId())); + IAdaptable element = getElement(); + if (element instanceof IResource) + ((IResource) element).setPersistentProperty(new QualifiedName("", DOMAIN_PROPERTY), Integer.toString(de.getId())); + else { + Object resource = element.getAdapter(IResource.class); + if (resource instanceof IResource) + ((IResource) resource).setPersistentProperty(new QualifiedName("", DOMAIN_PROPERTY), Integer.toString(de.getId())); + } } } catch (CoreException e) { return false; From d5b5f4ae54491c356f2176323c1a14e514690dc9 Mon Sep 17 00:00:00 2001 From: eleogas Date: Mon, 29 Feb 2016 13:53:53 +0100 Subject: [PATCH 18/29] Conceptual deploy help wizard --- .../META-INF/MANIFEST.MF | 3 +- eu.scasefp7.eclipse.core.ui/plugin.xml | 10 +- .../ui/handlers/OpenDeployWizardHander.java | 51 ++++++++++ .../eclipse/core/ui/views/Dashboard.java | 2 + .../eclipse/core/ui/wizards/DeployWizard.java | 55 +++++++++++ .../core/ui/wizards/DeployWizardPageOne.java | 99 +++++++++++++++++++ .../ui/wizards/DeployWizardPageThree.java | 73 ++++++++++++++ .../core/ui/wizards/DeployWizardPageTwo.java | 84 ++++++++++++++++ .../ui/wizards/ScaseProjectWizardPageTwo.java | 12 +-- 9 files changed, 381 insertions(+), 8 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/OpenDeployWizardHander.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizard.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageOne.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageThree.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageTwo.java diff --git a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF index 0659af8..5cfc79a 100644 --- a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF @@ -25,4 +25,5 @@ Bundle-ClassPath: . Bundle-Activator: eu.scasefp7.eclipse.core.ui.Activator Bundle-ActivationPolicy: lazy Import-Package: eu.scasefp7.eclipse.core.builder, - eu.scasefp7.eclipse.core.ontology + eu.scasefp7.eclipse.core.ontology, + org.eclipse.debug.internal.ui diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index be0b6f3..18116ab 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -224,7 +224,7 @@ @@ -241,6 +241,10 @@ optional="true"> + + + + selectionList) { } } } + return project; } @@ -625,6 +626,7 @@ private void updateSelection(ISelection selection) { IProject project = getProjectOfSelectionList(sel.toList()); if (project != null) { this.currentProject = project; + System.out.println("Current project: " + project); } } } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizard.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizard.java new file mode 100644 index 0000000..85b4ca6 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizard.java @@ -0,0 +1,55 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.Wizard; + +public class DeployWizard extends Wizard { + protected DeployWizardPageOne one; + protected DeployWizardPageTwo two; + protected DeployWizardPageThree three; + + private static final String PAGE_ONE_NAME = "First page"; + private static final String PAGE_TWO_NAME = "Second page"; + private static final String PAGE_THREE_NAME = "Third page"; + private static final String WIZARD_NAME = "New S-CASE Project"; + + + public DeployWizard() { + super(); + setNeedsProgressMonitor(true); + } + + @Override + public String getWindowTitle() { + return WIZARD_NAME; + } + + + @Override + public void addPages() { + one = new DeployWizardPageOne(PAGE_ONE_NAME); + two = new DeployWizardPageTwo(PAGE_TWO_NAME); + three = new DeployWizardPageThree(PAGE_THREE_NAME); + addPage(one); + addPage(two); + addPage(three); + } + + + @Override + public boolean performFinish() { + // TODO Auto-generated method stub + return true; + } + @Override + public IWizardPage getNextPage(IWizardPage page) { + + if(one.getNextPageName() == "two") + return two; + if(one.getNextPageName() == "three") + return three; + + return super.getNextPage(page); + } + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageOne.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageOne.java new file mode 100644 index 0000000..3a80c84 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageOne.java @@ -0,0 +1,99 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; + +public class DeployWizardPageOne extends WizardPage { + private String nextPage = "two"; + protected DeployWizardPageOne(String pageName) { + super(pageName); + setTitle(pageName); + } + + @Override + public void createControl(Composite parent) { + final Composite composite = new Composite(parent, SWT.NONE); + composite.setFont(parent.getFont()); + GridLayout layout = new GridLayout(2, false); + composite.setLayout(layout); + composite.setLayoutData(new GridData(SWT.BEGINNING)); + + + new Label(composite, SWT.NONE); + new Label(composite, SWT.NONE); + new Label(composite, SWT.NONE); + + Label lblLabel = new Label(composite, SWT.NONE); + lblLabel.setText("Label1"); + new Label(composite, SWT.NONE); + + Button btnCompile = new Button(composite, SWT.NONE); + btnCompile.setText("Compile"); + btnCompile.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event e) { + switch (e.type) { + case SWT.Selection: + //TODO define what happens here + System.out.println("Compile button pressed"); + break; + } + } + + }); + new Label(composite, SWT.NONE); + + Button btnRadioButton = new Button(composite, SWT.RADIO); + btnRadioButton.setText("Radio Button1"); + btnRadioButton.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + boolean isSelected = ((Button)e.getSource()).getSelection(); + if(isSelected) + nextPage = "two"; + } + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + } + }); + new Label(composite, SWT.NONE); + + Button btnRadioButton_1 = new Button(composite, SWT.RADIO); + btnRadioButton_1.setText("Radio Button2"); + btnRadioButton_1.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + boolean isSelected = ((Button)e.getSource()).getSelection(); + if(isSelected) + nextPage = "three"; + + } + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + } + }); + + this.setControl(composite); + setPageComplete(false); + + } + public String getNextPageName() { + return nextPage; + } + @Override + public boolean canFlipToNextPage() { + return true; + } + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageThree.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageThree.java new file mode 100644 index 0000000..0ea100a --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageThree.java @@ -0,0 +1,73 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.browser.IWebBrowser; + +public class DeployWizardPageThree extends WizardPage{ + + protected DeployWizardPageThree(String pageName) { + super(pageName); + setTitle(pageName); + } + + @Override + public void createControl(Composite parent) { + final Composite composite = new Composite(parent, SWT.NULL); + composite.setFont(parent.getFont()); + GridLayout layout = new GridLayout(); + layout.numColumns = 3; + composite.setLayout(layout); + composite.setLayoutData(new GridData(SWT.BEGINNING)); + + + new Label(composite, SWT.NONE); + new Label(composite, SWT.NONE); + new Label(composite, SWT.NONE); + + Label lblLabel = new Label(composite, SWT.NONE); + lblLabel.setText("label1"); + new Label(composite, SWT.NONE); + + String url = "http://s-case.github.io/"; + Link link = new Link(composite, SWT.NONE); + link.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + link.setText("" + url + ""); //$NON-NLS-1$ //$NON-NLS-2$ + link.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + IWebBrowser browser; + try { + browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser("browser"); + browser.openURL(new URL(url)); + } catch (PartInitException | MalformedURLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + + this.setControl(composite); + setPageComplete(false); + + } + + @Override + public boolean canFlipToNextPage() { + return false; + } + + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageTwo.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageTwo.java new file mode 100644 index 0000000..656c08d --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/DeployWizardPageTwo.java @@ -0,0 +1,84 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.browser.IWebBrowser; +import org.eclipse.wb.swt.SWTResourceManager; + +public class DeployWizardPageTwo extends WizardPage { + + protected DeployWizardPageTwo(String pageName) { + super(pageName); + setTitle(pageName); + } + + @Override + public void createControl(Composite parent) { + final Composite composite = new Composite(parent, SWT.NONE); + initializeDialogUnits(parent); + composite.setFont(parent.getFont()); + + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginWidth = 0; + layout.marginHeight = 0; + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + + + new Label(composite, SWT.NONE); + new Label(composite, SWT.NONE); + + + StyledText styledText = new StyledText (composite, SWT.MULTI); + styledText.setEditable(false); + styledText.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); + styledText.setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n " + + "Sed at ante. Mauris eleifend, quam a vulputate dictum, massa quam dapibus leo,\n" + + "eget vulputate orci purus ut lorem. In fringilla mi in ligula.\n " + + "Pellentesque aliquam quam vel dolor. Nunc adipiscing.\n" + + "sagittis et, lacinia at, venenatis non, arcu. Nunc nec libero. In cursus dictum risus.\n" + + "Etiam tristique nisl a nulla. Ut a orci. Curabitur dolor nunc, egestas at, accumsan at,\n" + + "malesuada nec, magna.\n"); + + new Label(composite, SWT.NONE); + + String url = "https://github.com/s-case/s-case-core"; + Link link = new Link(composite, SWT.NONE); + link.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + link.setText("" + url + ""); //$NON-NLS-1$ //$NON-NLS-2$ + link.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + IWebBrowser browser; + try { + browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser("browser"); + browser.openURL(new URL(url)); + } catch (PartInitException | MalformedURLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + new Label(composite, SWT.NONE); + new Label(composite, SWT.NONE); + this.setControl(composite); + setPageComplete(false); + + } + +} diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectWizardPageTwo.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectWizardPageTwo.java index 4fb66ed..3e5ba40 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectWizardPageTwo.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ScaseProjectWizardPageTwo.java @@ -10,11 +10,8 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowData; -import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; @@ -39,15 +36,14 @@ public class ScaseProjectWizardPageTwo extends WizardPage implements IScaseWizar protected ScaseProjectWizardPageTwo(String pageName) { super(pageName); - // TODO Auto-generated constructor stub + setTitle(pageName); } @Override public void createControl(Composite parent) { - initializeDialogUnits(parent); - final Composite composite= new Composite(parent, SWT.NULL); + initializeDialogUnits(parent); composite.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.numColumns = 3; @@ -288,4 +284,8 @@ public boolean performFinish(IResource resource) { return false; } + @Override + public boolean canFlipToNextPage() { + return false; + } } From 4229fb018e05346f09a1670940af9bf1c4dee2a8 Mon Sep 17 00:00:00 2001 From: eleogas Date: Wed, 2 Mar 2016 14:25:31 +0100 Subject: [PATCH 19/29] Dashboard redesign --- .../icons/dashboardButton.png | Bin 0 -> 734 bytes .../icons/dashboardCode.png | Bin 0 -> 1302 bytes .../icons/dashboardCodeBackground.png | Bin 0 -> 1987 bytes .../icons/dashboardDesign.png | Bin 0 -> 501 bytes .../icons/dashboardDesignBackground.png | Bin 0 -> 1995 bytes .../icons/dashboardMashup.png | Bin 0 -> 467 bytes .../icons/dashboardMashupBackground.png | Bin 0 -> 1942 bytes .../icons/dashboardRun.png | Bin 0 -> 287 bytes .../icons/dashboardRunBackground.png | Bin 0 -> 1343 bytes eu.scasefp7.eclipse.core.ui/plugin.xml | 145 ++++++++---------- ...casefp7.eclipse.core.ui.dashboardItem.exsd | 10 ++ .../eclipse/core/ui/views/Dashboard.java | 32 ++-- .../eclipse/core/ui/views/ImageButton.java | 118 ++++++++++++++ 13 files changed, 213 insertions(+), 92 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardButton.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardCode.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardCodeBackground.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardDesign.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardDesignBackground.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardMashup.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardMashupBackground.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardRun.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardRunBackground.png create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/ImageButton.java diff --git a/eu.scasefp7.eclipse.core.ui/icons/dashboardButton.png b/eu.scasefp7.eclipse.core.ui/icons/dashboardButton.png new file mode 100644 index 0000000000000000000000000000000000000000..fc35a99375860baf91cf85a37b977fe7dfe05a98 GIT binary patch literal 734 zcmeAS@N?(olHy`uVBq!ia0y~yU={(guW_&eNe}NMn;96GmU_B4hE&{od(e;(D0pbW pSN~j2{{=wiC>RZa!4U!t{fs_742-8t7_NaF=3g6<7cO literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/icons/dashboardCode.png b/eu.scasefp7.eclipse.core.ui/icons/dashboardCode.png new file mode 100644 index 0000000000000000000000000000000000000000..5e63a0f36a87ae46613c0ac9318126d0a9c94d9e GIT binary patch literal 1302 zcmeAS@N?(olHy`uVBq!ia0vp^0w65F1|14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>PZ43uLgDc>21sKVW9$<+4uOV3)FTBE0Vw#3qvM_85PCr;d86gy>S&fIOyMekqF|0;D_>iDzY&+pCoeCP9==Qhuu zsjm4jWuK|Z`wnjpfom5d%W8{+bZ>b5bn%v&Y4;;C>y>!e*B-s6$9mn@9&csm;@Y)) z_wLGlYwoSx^`f_%`#gL9WZ}({k`l+f3yvR4V*Zy@YG}Ag*W0paZq(i&M-jg@IsP^8 zXFmS>cgm5tqvvPN{4rP7Y0J$s-x6HraI&0m)!Q`d>;=d6>E^kUv??FE9=jrtJ>Yo?CL6Rr^+>+(*_q_V<&D$cPKUcu}$CRCx zFBT-nySuLsnOHI@L;n&BW8AgwzLqHT-`UCHvaxTz4EWp>x7-Uy17$)Z>H)XN0H`{jRuuR(X?(VLCs}~p?s@1UmC@^Qvwu=iteiZ0GBHgDgC%fy( ziFGR$xCL#>S{>?T6XCR{`T2``8@&0AuzmC)&F$F# zR9@qa4141vZ_b-Gb@$!MUt3ZdTVC|++FIeaKHe>cNt|t7jr$A!sHDKC|=v{+Ph;eE|X$6q*Tl}?-1 zCbC%K`v*sbhO$-1TRS=H7ZyZJtoZ&eSz9xzpwzl%cbR0b-t_|v$(KF{Uq9&m`pd6^ zKhm$+rS;xL?%uZGz}lkKQ%-%@le3i9|oY~%UIj0{Wu zH2<&3di_u~{@$L>mF?GmOK)agROXa$<^nLEtCqM%l%yn#;;y$P|3&O>FVdQ&MBb@ E0D7%BR{#J2 literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/icons/dashboardCodeBackground.png b/eu.scasefp7.eclipse.core.ui/icons/dashboardCodeBackground.png new file mode 100644 index 0000000000000000000000000000000000000000..20a9b82abc8e6bb7e736b5634965eae3529ce6a4 GIT binary patch literal 1987 zcmeH|c~sI_8^?cYiCJmeXlkXFV&-e0l1yls3kvQFugj1PDoeN`XbPH|T4`=%spVE` zE;*%jatW!_$$f@Q!Z8=rCL@IuA(L^-!9VAZ`RD!nz2`jl^W6J=zUMjjo_o&C^mKRH zt*WgG0KjfE%E4Pso;*@il;tz6(`iMHZ6sSaTL5^Pw{tycyL_z|g7S6)00vlImkt1{ zTlKR55DNtWAr1f#cK|?>QrhNaEf;oBPysXmQ0v+Xg#r^b9r>nmu#1y}obs_^&rX&D z6oYm{f~J)ec5XW+=E}Ad!x*H03_d7^fC!-y@->g&{0XnLy{L3M719Ync?GgzQ97H3S#!|@uksMAyKp>Eq2nr-3h(rzv zGll;MhlPhyi1^r8G%@UwJvY;OUVeg0Xa`$N{Dt}P{;1o8LmiTzNi`OMb%DkQZe$$y z-llLBwLiNU6^zPGPBkk&2g_%?P0N(vUfk$R1AU}Qb2BwVQgMpjOyqvm6D7QqrZRJv zq5#p?1VP!DC!$Lb$5`87qDg|w2%}f@LOK@yvG1sB;SDNovCfr!PlCdz%_sU64v&ER zu2dWETVJ1Y&zsE0Cpib-%$P8qndzG4OshVL;lu0f9vYmMJs)3m@D++Gztdl4g~pqU z?kTwhaPB+S*5aq8_nxK*>(=vM%ukg>Z(dt4AW*)vsH3|@N2xu5y3R&~1x0D7rQ!8! zZ~B|V5%D0E*6lLSt5o!Ine|bh?n(!d&>-+c-(-2S`EBi6qS5SeNcRS{vEKirOUs?2 zA96U-fwr?O%bSI-;SDHq&41j67%LYO+8>c4cQ`72Xu^5YHT$q>HUkb%r(X{Rt(N!v z5Zfq9ji${Rk*UxWd}0l>@pSvDO)c75U8;^>jt8k`;E`{BoaGr~5q9i^E|Bie5mzh$!P7i5t>4@R zPp-jgK>Q1{pC+#pMx^DV)l+j%lV`B4q_$Ew_Ve?e2rHIk2vwFi+-`Jmdpee*CG-wG z-{65?4}UN`$Bm5e$=Ve@0p6emds`v=`o@#Mj1HvVsQuhG%vne~*vTXrk-3~Yqdds|RD9&F`clNLf*ej~-RA71X!@aVqI76hwr58)4><_=7IGzNVky8xgUbd3& zT2KC=m96yaW5KRd)~EHwFO*7t$!En zUZKzUE~@Q`+^PJHKQ%(A_ph5U{P5?{D6#%f={ifc)M2Y`Qm=mbu~-y)7@N~*=nMJz z!Ye&3c$z{`E6#JU(cd)lVwY|l>AXJ!0e=$BZfYZ3a3(!SIFwT>eaAf##UxFbi{16b zy|WB+pWj)Z6F1Wre_>tc+U#3j9bmrTJ##M?3YW!mvr`ryrShkUhxxH|>_S4_V0}7y zk%g~X)B+6#`iHR6Zrw;C)$H`Z2ag`_*kh}3O+^*z;F+SIs<>24GX8r&G literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/icons/dashboardDesign.png b/eu.scasefp7.eclipse.core.ui/icons/dashboardDesign.png new file mode 100644 index 0000000000000000000000000000000000000000..c99841f469c38c08bebe37494ddf6d752b3fa3e6 GIT binary patch literal 501 zcmVl;lEn4smb@;!yto0ZaHj}POf8;zczz*F3SC*b>ZuI+0Ms9MF<|BeI^x3ym^J2Ny zUE-ztyOHh3xk)37SlTUP!Qt^fIi)yU60sD#<=Her61M&B<{uVPi@s6q?nP$70e8?D ztHP?Ej}owtD^~~3y{h$;XVn)G$+sW$;S?vi5OMR(J(+Fz5c6VM0T!HIRYSzP_<=WY zN1%0XxBgGO4j=4~CkM}fWu>8)DCol(uGry4ef1Ny$KMWo&M3m9{c;lCKvB^dRhYE< rH-Tr=w~-UzRNQ{Vqu2sJ-(k30iPa2|9%Q{+00000NkvXXu0mjfg)HrO literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/icons/dashboardDesignBackground.png b/eu.scasefp7.eclipse.core.ui/icons/dashboardDesignBackground.png new file mode 100644 index 0000000000000000000000000000000000000000..1e08510ac73a41e9e27241d5e8156a12d43f0ec8 GIT binary patch literal 1995 zcmeH|dpOg39LIk{R&wc%6-5_>Y;LnPoP{#7VhYWSW-i&9lg+XkN;opsO|)D(C++c+Qx1|df1W?i|L2eMd7jVb_5EDl&-eL$|M}z`#O^cDgXjSO zV1V)U4$^R1+~3+5rIR=Kx?%Q%e5` z01PMqe2N4BWDx)uCln z@Bxo%gI4Nno$8xe>TIX`gwms<=wu}61X%;X5ejp)hdS9qVZksM66%a}anAxtp>gVY*ZRP_Bf;CBo0vnvw#IYIinL0%IN`}+mids87)Gnt~J5B zvSgRXA~WJfuP4!^Gbv??LZ;bQmbL+ojpxhE-twDP7T#)bHsflUtepMw zff_cIR^nMd9df&4D?%*Cs_z%&c+5AXq-D=OU5wRwGy(~FN%;N66nC?1Z~#1ZG4!`4 z_)LhW>y!xE&KFvlgP=oM>yjKjiMIW z#bjrGG9!zM^YTu@7+uoP0FNqwh3^ zXfEdmrv^<)h;_57;MUt!`G(YEZUS~*-lr95U!Rs`TVeb81xYS~JJzKIxRDbWW$@yfU1-(pcvm+b;M~M}@a7i6+fr)~p=R!QP`hy!qAm`}HigOiS#~&5fN96r>@;>Iue9EZWaCZBXjfPeVtVs$mte zUL9n(*&ra`dZnJyIH=NEJF%>c>?)aI|vVC}9uOz*QNpRzfzgaa_s;;;W4AdYL ztMe4kPu?zZQL5@5SW$Y#J#69RaeTMz9)n4E_RbYB3Dg!`+ubVaH_>V|QJYTR92=e< zBVx^@U2_ojpRd;P@X3?i{>eIvCl|5x0$#;n%)5w9h_ohm<~gH_2kh()2cpr=hLP{| z-5ibAZ!0g{Q&r`6JDXA}C=ygj_(QB_4|CJu?|0e|FY$%ozK>O-b86Z7Vux9@KH`36lEi4GO)%7t6nPKRn6kx!R|v6EURW*J?>a%ugg=rb}@OEA%nSZniZ z@x;Xy?|EUo{I~j(3H$y!KHj{*vr$1(2yc|KyWc1Tpn~*_mQElsMe24vWIx?zPW-i_ z+|nhP{&7%R-5B>nr=HMa*P5d{`nGklNSxCno}(+VP08f()ixz|{n`Fk6C!v-9}r2E z&%6gFwI}VuZVN6Z-stlV>Qwm_KkLa&<$xk7`nEBr9!uX!AEx>mftm9XvxLac`nD54 zRtegkGZ4iwitB{$@zwI$#714HYZgOH8EOcldWKXhCH;Tgw<$Q{Lf*U1IsGo|a}j8m vn8n~3jQ;d`nZC9|-wpjg{zG5TvSq<2|IPFa2>wB5X;ET)u-<|_k!Sw~KxB6} literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/icons/dashboardMashup.png b/eu.scasefp7.eclipse.core.ui/icons/dashboardMashup.png new file mode 100644 index 0000000000000000000000000000000000000000..5d193c69e722c2dfbaf98d95887fcf62c1c8d026 GIT binary patch literal 467 zcmV;^0WAKBP)|I`bedLBm9r=yYGKoB+|wg7kC8O7sHWuL7E_Yh9EbFOUt^0 z&sqYMWU>o6WHFvQACR_|$CJ7s?-J~t=NMz14M2_K1xQTkf>x3d%ZyfI4n7DFlvQrc zG!WiubvC~76;PKB{QF33KOunGO+p0_Fkc&w$rg3Wv79~3iB)4$x5Vz)4 zZm!hHPF0ue68FfP0~h8SH<2Z~LB)rkgd9x#*itUnD-{8033_3}#%?y93IsC2T9IR| zOMi^*bOP9rQ)u}fG-0iJqkDm^J4LoR-PQ|~wIXg#$*ub@_XnqNkkB|@pBn%G002ov JPDHLkV1kGD!j%93 literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/icons/dashboardMashupBackground.png b/eu.scasefp7.eclipse.core.ui/icons/dashboardMashupBackground.png new file mode 100644 index 0000000000000000000000000000000000000000..d8133d1070141def53fcaae54f327eb9cf43f3c0 GIT binary patch literal 1942 zcmeH|X*}E68pr<((gfWYT5Xl2Tw=*$>qMo^L@QAuHKD{ZmPEvoXoyOKT3W`qrM9S2 z)X>3bOO3XoQf<{JMJ?4*%bja!gUF}RYC{^6zML2H=Dxn?^LftqIp_EMKF{YlZ%z)G z|EJRdp8t zVB>53I{@G!0bnTv05Deoz%Z^tcvD&^*b*UA0(#=&x)so{o z&Z_`QAbK7L{pTAsZ4H=oG|7M6~)0h#we>V6Rri7~u$gdsZ6B(GW(0IBHm%{`im@#w=0)a?~jYGtS zGMM4fHcp3~>|>(hB4}JLF(NtwinVXTHypWAv`A8i`Qn9yi$2qR}HMkyS?H%_*5o&~v0tc>%@cFU(4t&mnLlk9B`|J5^(!3h`Ui0Ohoeh_$(D)R7IQhTY+TM~` z?C&#I><>+QiATsgEN-AJrM|U9C%hQ<)WZ>mZ_QT>ACtquOH$fnXWEOjpLfJY{n^rC zQc0;O`9Qn!Q?Mc>E^*S?7u4rZBp-0#&VX8tauj0xm*%}sz)Ak63g;h2pc(X z`?!K1Nqv|%8(;(!HxyP=$^+Ir+cv8!CeHh9XXnX>em-It%{^nS>0MjpGF_RwdAeUo z9OUsWI~yE>dWolFJIlqwg)sr?yau^){L7`FAg$D-g_^TEx3YB_?|Wh1#6RySyGuCw za3d`87^y9>7iCzJdhEG`P_MCX1ERP%yeyl$wo4k&?#?jPy@}ml;FVulm__L38`o2; z1j*48uU@PSkc3YWC%a`RdIvPjG5}2S#;5eyRrW8k&2c7F|1WYFXPLNLO;2 mX@^~^tE!I_0Eov)uD8Aq$@mLm?JEiZ literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/icons/dashboardRun.png b/eu.scasefp7.eclipse.core.ui/icons/dashboardRun.png new file mode 100644 index 0000000000000000000000000000000000000000..e83fd042efe8f5157b30ded4a5c262565eafe3b4 GIT binary patch literal 287 zcmV+)0pR|LP)v+0&3odtQl^|k)8KIF2i*0u~nRLhj*L}U64bZlK*bD&S*aO>q zF${=3yekx!1`Jmm-BpgFIp)ZY%(%ll?+|Ukk)02Lftm@i`N)m}Vl`rT<=~D2kO7a# zHUOxX0qC6XNn{1`6_P!I zd>I(3)PU+*7#Mzm)W2Y0C^cYUc$L7wU^Rn*LA+qju0R{01ZROqWHAE+-w_aIoT|+y z4HRTc@^*It(m?Rjd3QaKVlVOZb!C6R%*f56{QlB+kc?`HYeY#(Vo9o1a#1RfVlXl= zG}ARO)-^B;F*LL?FtIW=)iwY!3^dLky^o?HH$NpatrE9}$Vs)yKn(^U8;Z-)t&$Rp zQ*}#=G8xh`b5gDJ_4P|~3-ogn(=(H^b(jd(o#xGJ=3zwoG*3Syk%fu{^aT6 z7*Y}U_O@?+NT|&5kH-AE3IPWkf_fRB9z1g71)uQuyx18U(f8ZeA86(Ns=Gr$FCrmk zXMtnP4uLB!8*g1=cCC+H z4_-H9=2@-K{{CM>{@<6_nX8X~^jluywc4b)s`O4${!W>@=8^a8e|XJY(|9oL$rhroZOey4O1F*y~eQGPiqgx7&7QM_FI*bmP*izuw#liCj^5Fm2~hvtw)MZFi}SL3-^|VqKehdOz5JZki{Fpv-e0F*cMFQ;x}yRz=~uFhS*N}}Fwy7B(%;{u=mTW-9b8eVQ2ZCCO3#RHz6ZR+a+;?JC& z)@{0~^WBeAVe59fMMb&$^rmrJ6uGWRT4D4O-_-P)p>Z`Y>^Z7ba^-L>-K zp4~GqpRu;H4o!QvYgtkWFKg+eLq31sY!BNP?v?e-boJFv?#rvy6Ij;nbn3mz|Nq#v zrHNs+M2Ak6qi?Sce}b?+?IdZ^l;~j5a#Mr?w|jq`5C{z(Ww0N z#F2Ri>zgiae)c`!>`M8(IQ{t8y#dSK-_hd#wfE|7uK%IMulL^7Y*#OvzFqD6^y}Z> z-2ISS@x%W11%95!`r_&Qpd{7Qq~Pc{VS$22fPjhyhmZ&hCpe{z3S)$c;nF{x+4=mx Tu9gVh1r<)7u6{1-oD!M<{m&Zk literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 18116ab..7bc79e4 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -148,87 +148,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -411,4 +330,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.dashboardItem.exsd b/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.dashboardItem.exsd index 8b75ac2..f845482 100644 --- a/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.dashboardItem.exsd +++ b/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.dashboardItem.exsd @@ -65,6 +65,16 @@ + + + + + + + + + + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java index eac5e10..3029ac1 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Map; -import org.apache.maven.plugin.logging.Log; import org.eclipse.core.commands.Command; import org.eclipse.core.commands.CommandEvent; import org.eclipse.core.commands.ExecutionException; @@ -58,7 +57,6 @@ import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osgi.internal.debug.FrameworkDebugTraceEntry; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; @@ -67,7 +65,7 @@ import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; @@ -82,11 +80,11 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.handlers.IHandlerService; -import org.eclipse.ui.internal.registry.RegistryReader; import org.eclipse.ui.menus.CommandContributionItem; import org.eclipse.ui.menus.CommandContributionItemParameter; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.services.IServiceLocator; +import org.eclipse.wb.swt.ResourceManager; import eu.scasefp7.eclipse.core.ui.Activator; import eu.scasefp7.eclipse.core.ui.ScaseUiConstants; @@ -115,6 +113,7 @@ public class Dashboard extends ViewPart implements ISelectionListener, IRegistry private static final String CONTRIBUTION_GROUP_NAME = "name"; private static final String CONTRIBUTION_COMMAND = "command"; private static final String CONTRIBUTION_COMMAND_ID = "commandId"; + private static final String CONTRIBUTION_COMMAND_ICON = "icon"; private static final String CONTRIBUTION_COMMAND_LABEL = "label"; private static final String CONTRIBUTION_COMMAND_TOOLTIP = "tooltip"; private static final String CONTRIBUTION_COMMAND_PARAM = "parameter"; @@ -185,7 +184,7 @@ public void createPartControl(Composite parent) { handleGroup(parent, elem); } if(elem.getName().equals(CONTRIBUTION_COMMAND)) { - handleButton(parent, elem); + handleButton(parent, elem, ""); } } @@ -301,14 +300,19 @@ private void fillLocalToolBar(IToolBarManager manager) { * @throws InvalidRegistryObjectException */ private void handleGroup(Composite parent, IConfigurationElement elem) throws InvalidRegistryObjectException { - Group group = createGroup(parent, elem.getAttribute(CONTRIBUTION_GROUP_NAME)); - + Group group = createGroup(parent, " "+elem.getAttribute(CONTRIBUTION_GROUP_NAME)); + + String icon = elem.getAttribute(CONTRIBUTION_COMMAND_ICON); + if(icon == null) + icon = ""; + Image img = ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", icon); + group.setBackgroundImage(img); for (IConfigurationElement child : elem.getChildren()) { if(child.getName().equals(CONTRIBUTION_GROUP)) { handleGroup(group, child); } if(child.getName().equals(CONTRIBUTION_COMMAND)) { - handleButton(group, child); + handleButton(group, child, icon); } } } @@ -320,16 +324,22 @@ private void handleGroup(Composite parent, IConfigurationElement elem) throws In * @param elem configuration element describing the button * @throws InvalidRegistryObjectException */ - private void handleButton(Composite parent, IConfigurationElement elem) throws InvalidRegistryObjectException { + private void handleButton(Composite parent, IConfigurationElement elem, String icon) throws InvalidRegistryObjectException { String name = elem.getAttribute(CONTRIBUTION_COMMAND_LABEL); String tooltip = elem.getAttribute(CONTRIBUTION_COMMAND_TOOLTIP); + final String commandId = elem.getAttribute(CONTRIBUTION_COMMAND_ID); final String notificationSuccess = elem.getAttribute(CONTRIBUTION_COMMAND_NOTIFICATION_SUCCESS); final String notificationFail = elem.getAttribute(CONTRIBUTION_COMMAND_NOTIFICATION_FAIL); - Button btn = new Button(parent, SWT.NONE); - + ImageButton btn = new ImageButton(parent, SWT.NULL); + + + Image img = ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/dashboardButton.png"); + btn.setImage(img); + btn.setSize(150, 24); + if(name != null) { btn.setText(name); } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/ImageButton.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/ImageButton.java new file mode 100644 index 0000000..c1f0a8f --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/ImageButton.java @@ -0,0 +1,118 @@ +package eu.scasefp7.eclipse.core.ui.views; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; + +public class ImageButton extends Composite +{ + private Color textColor; + private Image image; + private String text; + private int width = 0; + private int height = 0; + private int imgWidth; + private int imgHeight; + + public ImageButton(Composite parent, int style) + { + super(parent, style); + + textColor = Display.getDefault().getSystemColor(SWT.COLOR_BLACK); + + addListener(SWT.Dispose, new Listener() + { + @Override + public void handleEvent(Event arg0) + { + if (image != null) + image.dispose(); + } + }); + + + addListener(SWT.Paint, new Listener() + { + @Override + public void handleEvent(Event e) + { + paintControl(e); + } + }); + + addListener(SWT.MouseDown, new Listener() + { + @Override + public void handleEvent(Event arg0) + { + System.out.println("Click"); + } + }); + } + + private void paintControl(Event event) + { + GC gc = event.gc; + + if (image != null) { + //draw image + gc.drawImage(image, 1, 1, imgWidth-1, imgHeight-1, 1, 1, width, height); + + //draw border + gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY)); + gc.drawRoundRectangle(1, 1, width, height, 5, 5); + + //draw text + gc.setForeground(textColor); + Point textSize = gc.textExtent(text); + gc.drawText(text, (width - textSize.x) / 2 + 1, (height - textSize.y) / 2 + 1, true); + } + } + + public void setImage(Image image) + { + this.image = new Image(Display.getDefault(), image, SWT.IMAGE_COPY); + width = image.getBounds().width; + height = image.getBounds().height; + imgWidth = width; + imgHeight = height; + redraw(); + } + + public void setText(String text) + { + this.text = text; + redraw(); + } + + @Override + public Point computeSize(int wHint, int hHint, boolean changed) + { + int overallWidth = width; + int overallHeight = height; + + if (wHint != SWT.DEFAULT && wHint < overallWidth) + overallWidth = wHint; + + if (hHint != SWT.DEFAULT && hHint < overallHeight) + overallHeight = hHint; + + return new Point(overallWidth + 2, overallHeight + 2); + } + @Override + public void setSize(int w, int h) { + width = w; + height = h; + redraw(); + } + @Override + public void setSize(Point size) { + setSize(size.x,size.y); + } +} \ No newline at end of file From 47f9249dd8044dde219de8908de03b86a140e6ec Mon Sep 17 00:00:00 2001 From: eleogas Date: Mon, 7 Mar 2016 11:01:37 +0100 Subject: [PATCH 20/29] Navigator with rqs text --- .../META-INF/MANIFEST.MF | 3 +- .../icons/navigatorAction.png | Bin 0 -> 429 bytes .../icons/navigatorObject.png | Bin 0 -> 278 bytes .../icons/navigatorRequirement.png | Bin 0 -> 427 bytes .../icons/navigatorRoot.png | Bin 0 -> 191 bytes .../icons/navigatorTransition.png | Bin 0 -> 275 bytes eu.scasefp7.eclipse.core.ui/plugin.xml | 102 +++++++++++ .../ui/navigator/ArtefactContentProvider.java | 172 ++++++++++-------- .../core/ui/navigator/ArtefactGroup.java | 12 +- .../ui/navigator/ArtefactLabelProvider.java | 26 ++- .../core/ui/navigator/BaseArtefact.java | 9 +- .../eclipse/core/ui/navigator/IArtefact.java | 2 + .../core/ui/navigator/IArtefactGroup.java | 2 + .../eu/scasefp7/eclipse/core/Activator.java | 92 ++++++++-- .../core/handlers/LinkOntologiesHandler.java | 16 +- .../core/ontology/DynamicOntologyAPI.java | 27 ++- .../core/ontology/LinkedOntologyAPI.java | 27 ++- .../core/ontology/OntologyJenaAPI.java | 40 +++- .../core/ontology/StaticOntologyAPI.java | 23 ++- 19 files changed, 430 insertions(+), 123 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/icons/navigatorAction.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/navigatorObject.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/navigatorRequirement.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/navigatorRoot.png create mode 100644 eu.scasefp7.eclipse.core.ui/icons/navigatorTransition.png diff --git a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF index 5cfc79a..7d46d1d 100644 --- a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF @@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.variables, org.eclipse.equinox.security, org.eclipse.m2e.core, - org.eclipse.m2e.maven.runtime + org.eclipse.m2e.maven.runtime, + org.eclipse.ui.navigator Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: eu.scasefp7.eclipse.core.ui Bundle-Vendor: %Bundle-Vendor diff --git a/eu.scasefp7.eclipse.core.ui/icons/navigatorAction.png b/eu.scasefp7.eclipse.core.ui/icons/navigatorAction.png new file mode 100644 index 0000000000000000000000000000000000000000..636850563113aca51aa5fb30e2d4c9b645d41aa6 GIT binary patch literal 429 zcmV;e0aE^nP)QSWv7!K&LJl970U)jY68-+fF`! zvpztVRvZL9CuuuKn~ZuP%L(7#IiI5Zo2Lbjt9ycNYC*6#nw5o9prN;=b=guTfg#yF zmHf3V*s)@1Gm2^E^tO8dvv(@ldFjQTPbDDIs~eJk!8gzayV|gB z$qi=|o|)c*h#z5*bjeS!L~3B>!0sUw?2UB5c2<$Jt~IywydSw|yI#Ql^#a%u(nDZEc>+>|3j>{gEpX>L cvB8xA0hgoes!~op8UO$Q07*qoM6N<$f?xiC^8f$< literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/icons/navigatorRequirement.png b/eu.scasefp7.eclipse.core.ui/icons/navigatorRequirement.png new file mode 100644 index 0000000000000000000000000000000000000000..aa22ee81b7f3098fbf68f85ce0d59838dea2d8d8 GIT binary patch literal 427 zcmV;c0aX5pP)>ycl%%L6Lu}60Ph&{aXL+rk-<|Jv3KDgZvq&e>J&UdljOnq?9rWKkhoqi05s$x(2)PY5bljV zygd|~W^ha#++mh*YO4gq75n$|z$79!E)xd^)D5s9M|S?hrWtI&-o4UMu(XkdWB}NZ zJsW|B?6`_cGYI5v+s2o>Z4x^J!~g$`QD~_Q1QJ)x6HVW-Rv%AlWdSoB_U~s&*|SHS zfm{G|3VXtSXkd^7>VeUiwtF{!$<9UG(LjII16`DMW+p2vGeMOx;>~$b|1gr{003A^ VzI2-9laT-b002ovPDHLkV1frj!-L1P+nfHmzkGcoSayYs+V7sKKq@G6i^XcfKQ0) z|NsA8TwIQS{rL(g!dMdI7tG-B>_!@pBj@Sj7{U>q{NsNkW1onGgU4U{=D+m1c(lbg7D1`g0fDBvNyiJLlTM5AFaYSOR#7?T!A92_|cqo6G=#>5DY`X%qu zq|f*CO%>%g#{kf5PWOW>D%~uqUegHDKka&$(XGfq#!bRP0B-c z1H_waZ3c4#M%r_+CWGPIi{_DbF(;lZOlW&3_Vrec3*G#&nXJG1KsF<}#mE?4VqN*4 ZxdQ~5jH-SqeKr69002ovPDHLkV1l!KaSH$d literal 0 HcmV?d00001 diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 7bc79e4..9f650ac 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -394,4 +394,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactContentProvider.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactContentProvider.java index e92fb50..256dfe0 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactContentProvider.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactContentProvider.java @@ -1,29 +1,42 @@ package eu.scasefp7.eclipse.core.ui.navigator; +import java.io.File; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.widgets.Display; import eu.scasefp7.eclipse.core.ontology.DynamicOntologyAPI; import eu.scasefp7.eclipse.core.ontology.StaticOntologyAPI; -public class ArtefactContentProvider implements ITreeContentProvider { +public class ArtefactContentProvider implements ITreeContentProvider, IResourceChangeListener { private static final Object[] EMPTY = new Object[0]; - - private Object[] parents = null; + private Viewer viewer; + private Object[] parents = null; //parents of artefacts ArtefactGroup[] rootGroup = new ArtefactGroup[1]; - - private String[] group_names = { "Requirements", "Objects", "Activities", "Transitions"}; + private String[] groupNames = { "Requirements", "Objects", "Activities", "Transitions"}; - public void dispose() {} + public ArtefactContentProvider() { + ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); +} + public void dispose() { + + ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); + } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + this.viewer = viewer; + } public Object[] getElements(Object inputElement) { System.out.println("getElements: " + inputElement); @@ -33,22 +46,29 @@ public Object[] getElements(Object inputElement) { public Object[] getChildren(Object parentElement) { - System.out.println("getChildren: " + parentElement); - + if ((parentElement instanceof IProject)) { - initializeParents((IProject) parentElement); - initializeArtefacts((IProject) parentElement); + + IPath projectPath = ((IProject)parentElement).getLocation(); + File file = new File( projectPath.toString() +"/StaticOntology.owl"); + if(file.exists()) + initializeStatic((IProject) parentElement); + + file = new File(projectPath.toString()+"/DynamicOntology.owl"); + if(file.exists()) + initializeDynamic((IProject) parentElement); return rootGroup; } - if ((parentElement instanceof IArtefact)) - return ((IArtefact)parentElement).getChildren(); + if (parentElement instanceof IArtefact) + return ((IArtefact)parentElement).getChildren(); - if ((parentElement instanceof IArtefactGroup)) - return ((IArtefactGroup)parentElement).getChildren(); + if ((parentElement instanceof IArtefactGroup)) + return ((IArtefactGroup)parentElement).getChildren(); + return EMPTY; } @@ -56,7 +76,7 @@ public Object[] getChildren(Object parentElement) { public Object getParent(Object element) { - System.out.print("getParent: " + element); + System.out.println("getParent: " + element); if ((element instanceof IArtefact)) return ((IArtefact)element).getParent(); @@ -66,24 +86,13 @@ public Object getParent(Object element) { public boolean hasChildren(Object element) { - System.out.println("hasChildren: " + element); - - if ((element instanceof IFolder)) { - //.scase folders will be populated using initializeParent and initializeArtefacts - if (((IFolder)element).getName().endsWith(".scase")) - return true; - if (findParent(element) != null) - return true; - return false; - } - - if ((element instanceof IArtefact)) - return false; - - if (element instanceof IArtefactGroup && ((IArtefactGroup) element).getChildren()!= null) + if ((element instanceof IFolder) && findParent(element) != null) + return true; + + if (element instanceof IArtefactGroup && ((IArtefactGroup) element).getChildren() != null && ((IArtefactGroup) element).getChildren().length!= 0) return true; - + return false; } @@ -104,35 +113,29 @@ private Object findParent(Object element) { return null; } - + //initializes the root and groups of artifacts private void initializeParents(IProject parent) { - parents = new Object[group_names.length]; + parents = new Object[groupNames.length]; int ix = 0; String[] arrayOfString; - int j = (arrayOfString = group_names).length; + int j = (arrayOfString = groupNames).length; for (int i = 0; i < j; i++) { String name = arrayOfString[i]; - ArtefactGroup artGroup = new ArtefactGroup(name, parent); + ArtefactGroup artGroup = new ArtefactGroup(name, name, parent); parents[(ix++)] = artGroup; } - rootGroup[0] = new ArtefactGroup("Root", parent, parents); + rootGroup[0] = new ArtefactGroup("Root", "Root", parent, parents); //the children of root are the parents of artefacts } - - private void initializeArtefacts(IProject parent) { - IProject project = parent; - - Set Requirements = new HashSet(); - ArrayList Objects = new ArrayList(); - ArrayList Activities = new ArrayList(); - ArrayList Transitions = new ArrayList(); - - StaticOntologyAPI staticOntology = new StaticOntologyAPI(project); - DynamicOntologyAPI dynamicOntology = new DynamicOntologyAPI(project); - - for (String object : staticOntology.getObjects()) { + //initializes artifacts found in static ontology + private void initializeStatic(IProject parent) { + Set Requirements = new HashSet(); + ArrayList Objects = new ArrayList(); + StaticOntologyAPI staticOntology = new StaticOntologyAPI(parent); + + for (String object : staticOntology.getObjects()) { ArrayList obActions = staticOntology.getActionsOfObject(object); ArrayList obProperty = staticOntology.getPropertiesOfObject(object); String resultStr; @@ -142,19 +145,33 @@ private void initializeArtefacts(IProject parent) { else resultStr = "Object: " + object + ", actions: " + obActions + ", properties: " + obProperty; - IArtefact art = new BaseArtefact(resultStr, (ArtefactGroup) parents[1]); + IArtefact art = new BaseArtefact(resultStr, "Object", (ArtefactGroup) parents[1]); Objects.add((BaseArtefact) art); for (String requirement : staticOntology.getRequirementsOfConcept(object)) { - resultStr = "Requirement: " + requirement + ", concept: " + object; - IArtefact art2 = new BaseArtefact(resultStr, (ArtefactGroup) parents[0]); + resultStr = "Requirement: " + requirement + ", concept: " + object + ", text: " + staticOntology.getTextOfRequirement(requirement); + IArtefact art2 = new BaseArtefact(resultStr, "Requirement", (ArtefactGroup) parents[0]); Requirements.add((BaseArtefact) art2); } } - - for (String activity : dynamicOntology.getActivities()) { + + BaseArtefact[] requirements = Requirements.stream().toArray(BaseArtefact[]::new); + BaseArtefact[] objects = Objects.stream().toArray(BaseArtefact[]::new); + + ((ArtefactGroup) parents[0]).setChildren(requirements); + ((ArtefactGroup) parents[1]).setChildren(objects); + } + + //initializes artifacts found in dynamic ontology + private void initializeDynamic(IProject parent) { + ArrayList Activities = new ArrayList(); + ArrayList Transitions = new ArrayList(); + + DynamicOntologyAPI dynamicOntology = new DynamicOntologyAPI(parent); + + for (String activity : dynamicOntology.getActivities()) { String action = dynamicOntology.getActionOfActivity(activity); String acType = dynamicOntology.getActivityTypeOfActivity(activity); ArrayList acProp = dynamicOntology.getPropertiesOfActivity(activity); @@ -163,38 +180,39 @@ private void initializeArtefacts(IProject parent) { resultStr = "Activity: " + action + ", type: " + acType; else resultStr = "Activity: " + action + ", type: " + acType + ", properties:" + acProp; - IArtefact art = new BaseArtefact(resultStr, (ArtefactGroup) parents[2]); + IArtefact art = new BaseArtefact(resultStr, "Activity", (ArtefactGroup) parents[2]); Activities.add((BaseArtefact) art); } for (String transition : dynamicOntology.getTransitions()) { - - String condition = dynamicOntology.getConditionOfTransition(transition); - String sourcedynactivity = dynamicOntology.getSourceActivityOfTransition(transition); - String targetdynactivity = dynamicOntology.getTargetActivityOfTransition(transition); - String resultStr; + String resultStr; + String condition = dynamicOntology.getConditionOfTransition(transition); + String sourceActivity = dynamicOntology.getSourceActivityOfTransition(transition); + String targetActivity = dynamicOntology.getTargetActivityOfTransition(transition); if(condition == null) - resultStr = "from: " + sourcedynactivity + ", to: " + targetdynactivity; + resultStr = "Transition from: " + sourceActivity + ", to: " + targetActivity; else - resultStr = "from: " + sourcedynactivity + ", to: " + targetdynactivity +", condition: " + condition; + resultStr = "Transition from: " + sourceActivity + ", to: " + targetActivity +", condition: " + condition; - IArtefact art = new BaseArtefact(resultStr, (ArtefactGroup) parents[3]); + IArtefact art = new BaseArtefact(resultStr, "Transition", (ArtefactGroup) parents[3]); Transitions.add((BaseArtefact) art); - + + BaseArtefact[] activities = Activities.stream().toArray(BaseArtefact[]::new); + BaseArtefact[] transitions = Transitions.stream().toArray(BaseArtefact[]::new); + + ((ArtefactGroup) parents[2]).setChildren(activities); + ((ArtefactGroup) parents[3]).setChildren(transitions); } - - BaseArtefact[] requirements = Requirements.stream().toArray(BaseArtefact[]::new); - BaseArtefact[] objects = Objects.stream().toArray(BaseArtefact[]::new); - BaseArtefact[] activities = Activities.stream().toArray(BaseArtefact[]::new); - BaseArtefact[] transitions = Transitions.stream().toArray(BaseArtefact[]::new); - - ((ArtefactGroup) parents[0]).setChildren(requirements); - ((ArtefactGroup) parents[1]).setChildren(objects); - ((ArtefactGroup) parents[2]).setChildren(activities); - ((ArtefactGroup) parents[3]).setChildren(transitions); - - } + +@Override +public void resourceChanged(IResourceChangeEvent event) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + viewer.refresh(); + } + }); +} } \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactGroup.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactGroup.java index d3e18d1..6bf7acf 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactGroup.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactGroup.java @@ -5,17 +5,20 @@ public class ArtefactGroup implements IArtefactGroup { protected String name; + protected String type; protected IProject parent; protected Object[] children; - ArtefactGroup(String name, IProject parent){ + ArtefactGroup(String name, String type, IProject parent){ this.name = name; + this.type = type; this.parent = parent; this.children = null; } - ArtefactGroup(String name, IProject parent, Object[] children){ + ArtefactGroup(String name, String type, IProject parent, Object[] children){ this.name = name; + this.type = type; this.parent = parent; this.children = children; } @@ -34,6 +37,11 @@ public Object[] getChildren() { public String getName() { return name; } + + @Override + public String getType() { + return type; + } @Override public void setChildren(Object[] children) { diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactLabelProvider.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactLabelProvider.java index b13bae2..3426bef 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactLabelProvider.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/ArtefactLabelProvider.java @@ -19,14 +19,26 @@ public void removeListener(ILabelProviderListener listener) {} public Image getImage(Object element) { - - if ((element instanceof IArtefact)) - return ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/artefact-text.png"); - - if ((element instanceof IArtefactGroup)) - return ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/artefact.png"); - + String type = ""; + + if (element instanceof IArtefact) + type = ((IArtefact)element).getType(); + if (element instanceof IArtefactGroup) + type = ((IArtefactGroup)element).getType(); + if(type.startsWith("Activit")) + return ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/navigatorAction.png"); + if(type.startsWith("Requirement")) + return ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/navigatorRequirement.png"); + if(type.startsWith("Object")) + return ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/navigatorObject.png"); + if(type.startsWith("Transition")) + return ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/navigatorTransition.png"); + if(type.startsWith("Root")) + return ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/navigatorRoot.png"); + if (element instanceof IArtefact) + return ResourceManager.getPluginImage("eu.scasefp7.eclipse.core.ui", "icons/artefact-text.png"); + return null; } diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/BaseArtefact.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/BaseArtefact.java index 0507026..7e09518 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/BaseArtefact.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/BaseArtefact.java @@ -4,11 +4,13 @@ public class BaseArtefact implements IArtefact { protected String name; + protected String type; protected ArtefactGroup parent; - public BaseArtefact(String name, ArtefactGroup parent) + public BaseArtefact(String name, String type, ArtefactGroup parent) { this.name = name; + this.type = type; this.parent = parent; } @@ -17,6 +19,11 @@ public String getName() return name; } + public String getType() + { + return type; + } + public ArtefactGroup getParent() { return parent; diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefact.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefact.java index 62915e9..7d70f48 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefact.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefact.java @@ -3,6 +3,8 @@ public abstract interface IArtefact { public abstract String getName(); + public abstract String getType(); + public abstract ArtefactGroup getParent(); public abstract Object[] getChildren(); diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefactGroup.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefactGroup.java index 43e6e3a..fed9f95 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefactGroup.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/navigator/IArtefactGroup.java @@ -4,6 +4,8 @@ public abstract interface IArtefactGroup { public abstract String getName(); + + public abstract String getType(); public abstract IProject getParent(); diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/Activator.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/Activator.java index 931cbf4..a862a44 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/Activator.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/Activator.java @@ -1,18 +1,30 @@ package eu.scasefp7.eclipse.core; -import org.eclipse.ui.plugin.AbstractUIPlugin; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; import org.osgi.framework.BundleContext; /** * The activator class controls the plug-in life cycle */ -public class Activator extends AbstractUIPlugin { +public class Activator extends Plugin { - // The plug-in ID + /** The plug-in ID */ public static final String PLUGIN_ID = "eu.scasefp7.eclipse.core"; //$NON-NLS-1$ - // The shared instance - private static Activator plugin; + /** The starting time of the current session for this plugin. */ + private static String STARTING_TIME; + + /** The current error ID for this session for this plugin. */ + private static int errorID; + + /** The shared instance */ + private static Activator plugin; /** * The constructor @@ -20,18 +32,20 @@ public class Activator extends AbstractUIPlugin { public Activator() { } - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } + /** + * Called when plugin starts. Marks the start time for logging. + * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + STARTING_TIME = this.oDateFormatter.format(new Date()); + errorID = 0; + } /* * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext context) throws Exception { plugin = null; @@ -47,4 +61,52 @@ public static Activator getDefault() { return plugin; } -} + /** + * Logs an exception to the Eclipse log file. This method detects the class and the method in which the exception + * was caught automatically using the current stack trace. If required, the user can override these values by + * calling {@link #log(String, String, String, Exception)} instead. + * + * @param message a human-readable message about the exception. + * @param exception the exception that will be logged. + */ + public static void log(String message, Exception exception) { + StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[2]; + log(stackTraceElement.getClassName(), stackTraceElement.getMethodName(), message, exception); + } + + /** + * Logs an exception to the Eclipse log file. Note that in most cases you can use the + * {@link #log(String, Exception)} method which automatically detects the class and the method in which the + * exception was caught, so it requires as parameters only a human-readable message and the exception. + * + * @param className the name of the class in which the exception was caught. + * @param methodName the name of the method in which the exception was caught. + * @param message a human-readable message about the exception. + * @param exception the exception that will be logged. + */ + public static void log(String className, String methodName, String message, Exception exception) { + StringBuilder msg = new StringBuilder(message); + msg.append("\n!ERROR_ID t" + errorID); + msg.append("\n!SERVICE_NAME MDE UI Plugin"); + msg.append("\n!SERVICE_VERSION 1.0.0-SNAPSHOT"); + msg.append("\n!STARTING_TIME ").append(STARTING_TIME); + msg.append("\n!CLASS_NAME ").append(className); + msg.append("\n!FUNCTION_NAME ").append(methodName); + msg.append("\n!FAILURE_TIMESTAMP ").append(oDateFormatter.format(new Date())); + errorID++; + if (plugin != null) + plugin.getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.OK, msg.toString(), exception)); + else + exception.printStackTrace(); + } + + /** + * A UTC ISO 8601 date formatter used to log the time of errors. + */ + private static final DateFormat oDateFormatter; + static { + oDateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); + oDateFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); + } + +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java index e1f7403..261246c 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java @@ -73,7 +73,7 @@ public void linkOntologies(StaticOntologyAPI staticOntology, DynamicOntologyAPI linkedOntology.addResource(relatedObject); linkedOntology.addRelatedResourceToResource(object, relatedObject); for (String requirement : staticOntology.getRequirementsOfConcept(relatedObject)) { - linkedOntology.addRequirement(requirement); + linkedOntology.addRequirement(requirement, staticOntology.getTextOfRequirement(requirement)); linkedOntology.connectRequirementToElement(requirement, relatedObject); } } @@ -82,7 +82,7 @@ public void linkOntologies(StaticOntologyAPI staticOntology, DynamicOntologyAPI for (String property : staticOntology.getPropertiesOfObject(object)) { linkedOntology.addPropertyToResource(object, property); for (String requirement : staticOntology.getRequirementsOfConcept(property)) { - linkedOntology.addRequirement(requirement); + linkedOntology.addRequirement(requirement, staticOntology.getTextOfRequirement(requirement)); linkedOntology.connectRequirementToElement(requirement, property); } } @@ -93,7 +93,7 @@ public void linkOntologies(StaticOntologyAPI staticOntology, DynamicOntologyAPI linkedOntology.addActivityToResource(object, activity); linkedOntology.addActionToActivity(activity, action); for (String requirement : staticOntology.getRequirementsOfOperation(action)) { - linkedOntology.addRequirement(requirement); + linkedOntology.addRequirement(requirement, staticOntology.getTextOfRequirement(requirement)); linkedOntology.connectRequirementToElement(requirement, activity); linkedOntology.connectRequirementToElement(requirement, action); } @@ -101,7 +101,7 @@ public void linkOntologies(StaticOntologyAPI staticOntology, DynamicOntologyAPI // Iterate over all requirements containing the object and add them to the linked ontology for (String requirement : staticOntology.getRequirementsOfConcept(object)) { - linkedOntology.addRequirement(requirement); + linkedOntology.addRequirement(requirement, staticOntology.getTextOfRequirement(requirement)); linkedOntology.connectRequirementToElement(requirement, object); } } @@ -114,7 +114,7 @@ public void linkOntologies(StaticOntologyAPI staticOntology, DynamicOntologyAPI if (object != null) { linkedOntology.addResource(object); for (String diagram : dynamicOntology.getDiagramsOfConcept(dynactivity)) { - linkedOntology.addActivityDiagram(diagram); + linkedOntology.addActivityDiagram(diagram, staticOntology.getTextOfRequirement(diagram)); linkedOntology.connectActivityDiagramToElement(diagram, object); } @@ -126,7 +126,7 @@ public void linkOntologies(StaticOntologyAPI staticOntology, DynamicOntologyAPI dynamicOntology.getActivityTypeOfActivity(dynactivity)); linkedOntology.addActionToActivity(activity, action); for (String diagram : dynamicOntology.getDiagramsOfConcept(dynactivity)) { - linkedOntology.addActivityDiagram(diagram); + linkedOntology.addActivityDiagram(diagram, staticOntology.getTextOfRequirement(diagram)); linkedOntology.connectActivityDiagramToElement(diagram, object); linkedOntology.connectActivityDiagramToElement(diagram, action); linkedOntology.connectActivityDiagramToElement(diagram, activity); @@ -137,7 +137,7 @@ public void linkOntologies(StaticOntologyAPI staticOntology, DynamicOntologyAPI for (String property : dynamicOntology.getPropertiesOfActivity(object)) { linkedOntology.addPropertyToResource(object, property); for (String diagram : dynamicOntology.getDiagramsOfConcept(property)) { - linkedOntology.addActivityDiagram(diagram); + linkedOntology.addActivityDiagram(diagram, staticOntology.getTextOfRequirement(diagram)); linkedOntology.connectActivityDiagramToElement(diagram, property); } } @@ -170,7 +170,7 @@ public void linkOntologies(StaticOntologyAPI staticOntology, DynamicOntologyAPI if (condition != null && taction != null && saction != null) { linkedOntology.addConditionToActivity(tactivity, condition); for (String diagram : dynamicOntology.getDiagramsOfConcept(condition)) { - linkedOntology.addActivityDiagram(diagram); + linkedOntology.addActivityDiagram(diagram, staticOntology.getTextOfRequirement(diagram)); linkedOntology.connectActivityDiagramToElement(diagram, condition); } } diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/DynamicOntologyAPI.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/DynamicOntologyAPI.java index abd458e..09d3687 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/DynamicOntologyAPI.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/DynamicOntologyAPI.java @@ -72,11 +72,10 @@ public DynamicOntologyAPI(String projectName, boolean forceDelete) { dynamicOntology.addIndividual("Project", projectName); } - /** * Adds an activity diagram in the ontology and connects it to the project. * - * @param activityDiagramName the requirement to be added. + * @param activityDiagramName the diagram to be added. */ public void addActivityDiagram(String activityDiagramName) { dynamicOntology.addIndividual("ActivityDiagram", activityDiagramName); @@ -84,6 +83,18 @@ public void addActivityDiagram(String activityDiagramName) { .addPropertyAndReverseBetweenIndividuals(projectName, "project_has_diagram", activityDiagramName); } + /** + * Adds an activity diagram in the ontology, including its text, and connects it to the project. + * + * @param activityDiagramName the diagram to be added. + * @param activityDiagramText the text of the diagram to be added. + */ + public void addActivityDiagram(String activityDiagramName, String activityDiagramText) { + dynamicOntology.addIndividual("ActivityDiagram", activityDiagramName, activityDiagramText); + dynamicOntology + .addPropertyAndReverseBetweenIndividuals(projectName, "project_has_diagram", activityDiagramName); + } + /** * Connects an activity diagram to an element of the ontology. * @@ -218,6 +229,16 @@ public ArrayList getDiagramsOfConcept(String concept) { return dynamicOntology.getIndividualNamesGivenIndividualAndProperty(concept, "is_of_diagram"); } + /** + * Returns the text of a specific activity diagram. + * + * @param diagram the activity diagram of which the text is returned. + * @return the text of the given activity diagram. + */ + public String getTextOfActivityDiagram(String diagram) { + return dynamicOntology.getIndividualComment(diagram); + } + /** * Returns the transitions of the ontology for the current project. * @@ -321,4 +342,4 @@ public void addConditionToTransition(String condition, String sourceActivity, St dynamicOntology.addPropertyAndReverseBetweenIndividuals(transitionName, "has_condition", condition); } -} +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/LinkedOntologyAPI.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/LinkedOntologyAPI.java index ecda588..50f8040 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/LinkedOntologyAPI.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/LinkedOntologyAPI.java @@ -92,6 +92,17 @@ public void addRequirement(String requirementName) { linkedOntology.addPropertyAndReverseBetweenIndividuals(projectName, "has_requirement", requirementName); } + /** + * Adds a requirement in the ontology, including its text, and connects it to the project. + * + * @param requirementName the requirement to be added. + * @param requirementsText the text of the requirement to be added. + */ + public void addRequirement(String requirementName, String requirementsText) { + linkedOntology.addIndividual("Requirement", requirementName, requirementsText); + linkedOntology.addPropertyAndReverseBetweenIndividuals(projectName, "has_requirement", requirementName); + } + /** * Connects a requirement to an element of the ontology. * @@ -106,7 +117,7 @@ public void connectRequirementToElement(String requirementName, String elementNa /** * Adds an activity diagram in the ontology and connects it to the project. * - * @param activityDiagramName the requirement to be added. + * @param activityDiagramName the activity diagram to be added. */ public void addActivityDiagram(String activityDiagramName) { linkedOntology.addIndividual("ActivityDiagram", activityDiagramName); @@ -114,6 +125,18 @@ public void addActivityDiagram(String activityDiagramName) { .addPropertyAndReverseBetweenIndividuals(projectName, "has_activity_diagram", activityDiagramName); } + /** + * Adds an activity diagram in the ontology, including its text, and connects it to the project. + * + * @param activityDiagramName the activity diagram to be added. + * @param activityDiagramText the text of the activity diagram to be added. + */ + public void addActivityDiagram(String activityDiagramName, String activityDiagramText) { + linkedOntology.addIndividual("ActivityDiagram", activityDiagramName, activityDiagramText); + linkedOntology + .addPropertyAndReverseBetweenIndividuals(projectName, "has_activity_diagram", activityDiagramName); + } + /** * Connects an activity diagram to an element of the ontology. * @@ -653,4 +676,4 @@ public ArrayList getParameterTypeElements(String parameterName) { public void close() { linkedOntology.close(); } -} +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/OntologyJenaAPI.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/OntologyJenaAPI.java index 2e48739..b6f01dd 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/OntologyJenaAPI.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/OntologyJenaAPI.java @@ -36,6 +36,7 @@ import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.util.iterator.ExtendedIterator; +import eu.scasefp7.eclipse.core.Activator; import eu.scasefp7.eclipse.core.ontology.OntologySource.OntologyType; /** @@ -86,7 +87,8 @@ public OntologyJenaAPI(IProject project, OntologyType ontologyType, String sourc ontologyContents.getBytes(StandardCharsets.UTF_8)); file.create(ontologyStream, IResource.FORCE, null); } catch (CoreException e) { - e.printStackTrace(); + Activator.log("Unable to force delete and recreate " + ontologyType.name().toLowerCase() + + " ontology file", e); } } else if (testfile != null && testfile.exists()) { try { @@ -177,14 +179,14 @@ private void initialize() { try { file.create(ontologyStream, IResource.FORCE, null); } catch (CoreException e) { - e.printStackTrace(); + Activator.log("Unable to create new " + ontologyType.name().toLowerCase() + " ontology file", e); } } try { InputStream in = file.getContents(); base.read(in, null); } catch (CoreException e) { - e.printStackTrace(); + Activator.log("Unable to read created " + ontologyType.name().toLowerCase() + " ontology file", e); } } @@ -231,6 +233,21 @@ public void addIndividual(String className, String individualName) { base.createIndividual(addNamespaceToInstance(individualName), ontClass); } + /** + * Adds a new individual in the ontology including a comment. + * + * @param className the OWL class that the new individual shall exist. + * @param individualName the name of the new individual to be added. + * @param commentText the text of the comment to be added. + */ + public void addIndividual(String className, String individualName, String commentText) { + OntClass ontClass = base.getOntClass(addNamespaceToInstance(className)); + if (commentText != null && !commentText.equals("")) + base.createIndividual(addNamespaceToInstance(individualName), ontClass).addComment(commentText, null); + else + base.createIndividual(addNamespaceToInstance(individualName), ontClass); + } + /** * Removes an individual of the ontology given its name. Note that this method removes also all the statements that * refer to this individual. @@ -277,6 +294,16 @@ private Individual getIndividual(String individualName) { return base.getIndividual(addNamespaceToInstance(individualName)); } + /** + * Returns the comment of an individual given its name. + * + * @param individualName the name of the individual of which the comment is returned. + * @return the comment of the given individual. + */ + public String getIndividualComment(String individualName) { + return base.getIndividual(addNamespaceToInstance(individualName)).getComment(null); + } + /** * Returns an ontology property class given its name. * @@ -513,7 +540,8 @@ public void close() { FileOutputStream out = null; try { out = new FileOutputStream(testfile); - } catch (FileNotFoundException e1) { + } catch (FileNotFoundException e) { + e.printStackTrace(); } base.write(out); } else { @@ -524,9 +552,9 @@ public void close() { try { file.setContents(originalInputStream, IResource.FORCE, null); } catch (CoreException e) { - e.printStackTrace(); + Activator.log("Unable to save the " + ontologyType.name().toLowerCase() + " ontology file", e); } } } -} +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/StaticOntologyAPI.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/StaticOntologyAPI.java index 9545b67..591821c 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/StaticOntologyAPI.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/StaticOntologyAPI.java @@ -82,6 +82,17 @@ public void addRequirement(String requirementName) { staticOntology.addPropertyAndReverseBetweenIndividuals(projectName, "project_has_requirement", requirementName); } + /** + * Adds a requirement in the ontology, including its text, and connects it to the project. + * + * @param requirementName the requirement to be added. + * @param requirementsText the text of the requirement to be added. + */ + public void addRequirement(String requirementName, String requirementsText) { + staticOntology.addIndividual("Requirement", requirementName, requirementsText); + staticOntology.addPropertyAndReverseBetweenIndividuals(projectName, "project_has_requirement", requirementName); + } + /** * Connects a requirement to a concept of the ontology. * @@ -160,6 +171,16 @@ public ArrayList getRequirementsOfConcept(String concept) { return staticOntology.getIndividualNamesGivenIndividualAndProperty(concept, "is_concept_of_requirement"); } + /** + * Returns the text of a specific requirement. + * + * @param requirement the requirement of which the text is returned. + * @return the text of the given requirement. + */ + public String getTextOfRequirement(String requirement) { + return staticOntology.getIndividualComment(requirement); + } + /** * Returns the requirements of a specific operation. * @@ -245,4 +266,4 @@ public void addProperty(String property) { public void connectElementToProperty(String element, String property) { staticOntology.addPropertyAndReverseBetweenIndividuals(element, "has_property", property); } -} +} \ No newline at end of file From 2c84029550509cb1bbd6c079cfc09f43d8ad94b3 Mon Sep 17 00:00:00 2001 From: eleogas Date: Mon, 14 Mar 2016 14:23:44 +0100 Subject: [PATCH 21/29] Navigator fix: enable only for S-Case projects --- .../icons/dashboardDesignBackground.png | Bin 1995 -> 0 bytes .../icons/dashboardMashupBackground.png | Bin 1942 -> 0 bytes eu.scasefp7.eclipse.core.ui/plugin.xml | 53 +++++++++++------- 3 files changed, 32 insertions(+), 21 deletions(-) delete mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardDesignBackground.png delete mode 100644 eu.scasefp7.eclipse.core.ui/icons/dashboardMashupBackground.png diff --git a/eu.scasefp7.eclipse.core.ui/icons/dashboardDesignBackground.png b/eu.scasefp7.eclipse.core.ui/icons/dashboardDesignBackground.png deleted file mode 100644 index 1e08510ac73a41e9e27241d5e8156a12d43f0ec8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1995 zcmeH|dpOg39LIk{R&wc%6-5_>Y;LnPoP{#7VhYWSW-i&9lg+XkN;opsO|)D(C++c+Qx1|df1W?i|L2eMd7jVb_5EDl&-eL$|M}z`#O^cDgXjSO zV1V)U4$^R1+~3+5rIR=Kx?%Q%e5` z01PMqe2N4BWDx)uCln z@Bxo%gI4Nno$8xe>TIX`gwms<=wu}61X%;X5ejp)hdS9qVZksM66%a}anAxtp>gVY*ZRP_Bf;CBo0vnvw#IYIinL0%IN`}+mids87)Gnt~J5B zvSgRXA~WJfuP4!^Gbv??LZ;bQmbL+ojpxhE-twDP7T#)bHsflUtepMw zff_cIR^nMd9df&4D?%*Cs_z%&c+5AXq-D=OU5wRwGy(~FN%;N66nC?1Z~#1ZG4!`4 z_)LhW>y!xE&KFvlgP=oM>yjKjiMIW z#bjrGG9!zM^YTu@7+uoP0FNqwh3^ zXfEdmrv^<)h;_57;MUt!`G(YEZUS~*-lr95U!Rs`TVeb81xYS~JJzKIxRDbWW$@yfU1-(pcvm+b;M~M}@a7i6+fr)~p=R!QP`hy!qAm`}HigOiS#~&5fN96r>@;>Iue9EZWaCZBXjfPeVtVs$mte zUL9n(*&ra`dZnJyIH=NEJF%>c>?)aI|vVC}9uOz*QNpRzfzgaa_s;;;W4AdYL ztMe4kPu?zZQL5@5SW$Y#J#69RaeTMz9)n4E_RbYB3Dg!`+ubVaH_>V|QJYTR92=e< zBVx^@U2_ojpRd;P@X3?i{>eIvCl|5x0$#;n%)5w9h_ohm<~gH_2kh()2cpr=hLP{| z-5ibAZ!0g{Q&r`6JDXA}C=ygj_(QB_4|CJu?|0e|FY$%ozK>O-b86Z7Vux9@KH`36lEi4GO)%7t6nPKRn6kx!R|v6EURW*J?>a%ugg=rb}@OEA%nSZniZ z@x;Xy?|EUo{I~j(3H$y!KHj{*vr$1(2yc|KyWc1Tpn~*_mQElsMe24vWIx?zPW-i_ z+|nhP{&7%R-5B>nr=HMa*P5d{`nGklNSxCno}(+VP08f()ixz|{n`Fk6C!v-9}r2E z&%6gFwI}VuZVN6Z-stlV>Qwm_KkLa&<$xk7`nEBr9!uX!AEx>mftm9XvxLac`nD54 zRtegkGZ4iwitB{$@zwI$#714HYZgOH8EOcldWKXhCH;Tgw<$Q{Lf*U1IsGo|a}j8m vn8n~3jQ;d`nZC9|-wpjg{zG5TvSq<2|IPFa2>wB5X;ET)u-<|_k!Sw~KxB6} diff --git a/eu.scasefp7.eclipse.core.ui/icons/dashboardMashupBackground.png b/eu.scasefp7.eclipse.core.ui/icons/dashboardMashupBackground.png deleted file mode 100644 index d8133d1070141def53fcaae54f327eb9cf43f3c0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1942 zcmeH|X*}E68pr<((gfWYT5Xl2Tw=*$>qMo^L@QAuHKD{ZmPEvoXoyOKT3W`qrM9S2 z)X>3bOO3XoQf<{JMJ?4*%bja!gUF}RYC{^6zML2H=Dxn?^LftqIp_EMKF{YlZ%z)G z|EJRdp8t zVB>53I{@G!0bnTv05Deoz%Z^tcvD&^*b*UA0(#=&x)so{o z&Z_`QAbK7L{pTAsZ4H=oG|7M6~)0h#we>V6Rri7~u$gdsZ6B(GW(0IBHm%{`im@#w=0)a?~jYGtS zGMM4fHcp3~>|>(hB4}JLF(NtwinVXTHypWAv`A8i`Qn9yi$2qR}HMkyS?H%_*5o&~v0tc>%@cFU(4t&mnLlk9B`|J5^(!3h`Ui0Ohoeh_$(D)R7IQhTY+TM~` z?C&#I><>+QiATsgEN-AJrM|U9C%hQ<)WZ>mZ_QT>ACtquOH$fnXWEOjpLfJY{n^rC zQc0;O`9Qn!Q?Mc>E^*S?7u4rZBp-0#&VX8tauj0xm*%}sz)Ak63g;h2pc(X z`?!K1Nqv|%8(;(!HxyP=$^+Ir+cv8!CeHh9XXnX>em-It%{^nS>0MjpGF_RwdAeUo z9OUsWI~yE>dWolFJIlqwg)sr?yau^){L7`FAg$D-g_^TEx3YB_?|Wh1#6RySyGuCw za3d`87^y9>7iCzJdhEG`P_MCX1ERP%yeyl$wo4k&?#?jPy@}ml;FVulm__L38`o2; z1j*48uU@PSkc3YWC%a`RdIvPjG5}2S#;5eyRrW8k&2c7F|1WYFXPLNLO;2 mX@^~^tE!I_0Eov)uD8Aq$@mLm?JEiZ diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 9f650ac..09fdc28 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -81,7 +81,7 @@ name="S-CASE Project" icon="icons/view16/s-case_16.png" category="eu.scasefp7.eclipse.category" - class="eu.scasefp7.eclipse.core.ui.wizards.NewScaseProjectWizard2" + class="eu.scasefp7.eclipse.core.ui.wizards.NewScaseProjectWizard" finalPerspective="eu.scasefp7.eclipse.core.ui.ScasePerspective" hasPages="true" id="eu.scasefp7.eclipse.core.ui.newProjectWizard" @@ -293,6 +293,7 @@ + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + Date: Tue, 15 Mar 2016 13:21:46 +0100 Subject: [PATCH 22/29] Project folders - rename and delete handled --- .../scasefp7/eclipse/core/ui/Activator.java | 211 +++++++++++++++--- 1 file changed, 185 insertions(+), 26 deletions(-) diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java index 32fbb6c..fda14ef 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/Activator.java @@ -1,9 +1,27 @@ package eu.scasefp7.eclipse.core.ui; -import java.util.Dictionary; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Dictionary; import java.util.Hashtable; +import java.util.TimeZone; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceDeltaVisitor; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.osgi.service.debug.DebugOptions; import org.eclipse.osgi.service.debug.DebugOptionsListener; import org.eclipse.osgi.service.debug.DebugTrace; @@ -16,46 +34,71 @@ */ public class Activator extends AbstractUIPlugin implements DebugOptionsListener { - // The plug-in ID + /** The plug-in ID. */ public static final String PLUGIN_ID = "eu.scasefp7.eclipse.core.ui"; //$NON-NLS-1$ - // The shared instance + /** The starting time of the current session for this plugin. */ + private static String STARTING_TIME; + + /** The current error ID for this session for this plugin. */ + private static int errorID; + + /** The shared instance. */ private static Activator plugin; - // Images + /** The shared images. */ private static SharedImages images = null; - // fields to cache the debug flags - public static boolean DEBUG = false; - public static DebugTrace trace = null; - - + /** Cached debug tracing flag. */ + public static boolean DEBUG = false; + + /** Cached debug trace output. */ + public static DebugTrace TRACE = null; + + IResourceChangeListener rcl; + /** - * The constructor + * The constructor. */ public Activator() { } - /* - * (non-Javadoc) + /** + * Called when plugin starts. Marks the start time for logging. * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { super.start(context); - Dictionary props = new Hashtable(4); - props.put(DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID); - context.registerService(DebugOptionsListener.class.getName(), this, props); plugin = this; - - + STARTING_TIME = Activator.oDateFormatter.format(new Date()); + errorID = 0; + + // Register for debug trace + Dictionary props = new Hashtable(4); + props.put(DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID); + context.registerService(DebugOptionsListener.class.getName(), this, props); + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + rcl = new IResourceChangeListener() { + public void resourceChanged(IResourceChangeEvent event) { + IResourceDelta delta = event.getDelta(); + try { + delta.accept(new BuildDeltaVisitor()); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }; + workspace.addResourceChangeListener(rcl); } /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ - public void stop(BundleContext context) throws Exception { + public void stop(BundleContext context) throws Exception { plugin = null; + ResourcesPlugin.getWorkspace().removeResourceChangeListener(rcl); super.stop(context); } @@ -68,7 +111,6 @@ public static Activator getDefault() { return plugin; } - /** * Returns the shared image registry * @@ -78,14 +120,131 @@ public static SharedImages getImages() { if(images == null) { images = new SharedImages(); } + return images; } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + /** + * Logs an exception to the Eclipse log file. This method detects the class and the method in which the exception + * was caught automatically using the current stack trace. If required, the user can override these values by + * calling {@link #log(String, String, String, Exception)} instead. + * + * @param message a human-readable message about the exception. + * @param exception the exception that will be logged. + */ + public static void log(String message, Exception exception) { + StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[2]; + log(stackTraceElement.getClassName(), stackTraceElement.getMethodName(), message, exception); + } - @Override - public void optionsChanged(DebugOptions options) { - DEBUG = options.getBooleanOption(PLUGIN_ID + "/debug", false); - trace = options.newDebugTrace(PLUGIN_ID); - - } + /** + * Logs an exception to the Eclipse log file. Note that in most cases you can use the + * {@link #log(String, Exception)} method which automatically detects the class and the method in which the + * exception was caught, so it requires as parameters only a human-readable message and the exception. + * + * @param className the name of the class in which the exception was caught. + * @param methodName the name of the method in which the exception was caught. + * @param message a human-readable message about the exception. + * @param exception the exception that will be logged. + */ + public static void log(String className, String methodName, String message, Exception exception) { + StringBuilder msg = new StringBuilder(message); + msg.append("\n!ERROR_ID t" + errorID); + msg.append("\n!SERVICE_NAME MDE UI Plugin"); + msg.append("\n!SERVICE_VERSION 1.0.0-SNAPSHOT"); + msg.append("\n!STARTING_TIME ").append(STARTING_TIME); + msg.append("\n!CLASS_NAME ").append(className); + msg.append("\n!FUNCTION_NAME ").append(methodName); + msg.append("\n!FAILURE_TIMESTAMP ").append(oDateFormatter.format(new Date())); + errorID++; + if (plugin != null) + plugin.getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.OK, msg.toString(), exception)); + else + exception.printStackTrace(); + } -} + /** + * A UTC ISO 8601 date formatter used to log the time of errors. + */ + private static final DateFormat oDateFormatter; + static { + oDateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); + oDateFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); + } + + /** + * Refreshes the debug trace sink when debug options have changed. + */ + @Override + public void optionsChanged(DebugOptions options) { + DEBUG = options.getBooleanOption(PLUGIN_ID + "/debug", false); + TRACE = options.newDebugTrace(PLUGIN_ID); + } + class BuildDeltaVisitor implements IResourceDeltaVisitor { + + public boolean visit(IResourceDelta delta) throws CoreException { + switch (delta.getKind()) { + case IResourceDelta.REMOVED: + IResource res = delta.getResource(); + if(res instanceof IFolder) { + IProject project = ((IFolder)res).getProject(); + String resPath = res.getFullPath().toString(); + try { + String projectPath = project.getFullPath().toPortableString(); //path of the project containing resource + String modelsPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.MODELS_FOLDER)); + String outputPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER)); + String reqPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER)); + String comPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER)); + IPath newPath = delta.getMovedToPath(); //path of the new (renamed) project, or null + + if(resPath.equals(modelsPath)) + if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) //folder renamed + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.MODELS_FOLDER), newPath.toPortableString()); + else //folder deleted + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.MODELS_FOLDER), projectPath); + + else if(resPath.equals(outputPath)) + if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER), newPath.toPortableString()); + else + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER), projectPath); + + else if(resPath.equals(reqPath)) + if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER), newPath.toPortableString()); + else + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER), projectPath); + + else if(resPath.equals(comPath)) + if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER), newPath.toPortableString()); + else + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER), projectPath); + + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + System.out.println("detected!"); + + break; + case IResourceDelta.NO_CHANGE: + break; + } + + return true; + } + } +} \ No newline at end of file From b22debad2aa0392df1f83a5085b4da930dc1cd53 Mon Sep 17 00:00:00 2001 From: eleogas Date: Thu, 17 Mar 2016 11:10:29 +0100 Subject: [PATCH 23/29] NPE fix --- .../core/handlers/OntologyToYamlHandler.java | 26 ++++++++++++++++--- .../core/ontology/OntologyJenaAPI.java | 23 ++++++++++++++-- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/OntologyToYamlHandler.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/OntologyToYamlHandler.java index 9834349..0f88b89 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/OntologyToYamlHandler.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/OntologyToYamlHandler.java @@ -10,13 +10,17 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.QualifiedName; +import eu.scasefp7.eclipse.core.Activator; import eu.scasefp7.eclipse.core.ontology.LinkedOntologyAPI; import eu.scasefp7.eclipse.core.ontologytoyamltools.Operation; import eu.scasefp7.eclipse.core.ontologytoyamltools.Property; @@ -39,9 +43,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException { IProject project = getProjectOfExecutionEvent(event); //String projectName = event.getParameter("projectName"); String fileName = event.getParameter("fileName"); - Path path = new Path(fileName); //When handler is called from builder if(fileName != null){ + Path path = new Path(fileName); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); project = file.getProject(); //project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); @@ -183,12 +187,26 @@ private Resources createResources(LinkedOntologyAPI linkedOntology) throws Execu */ private void writeYamlFile(IProject project, Resources resources) throws ExecutionException { // Open a new YAML file in the project - IFile file = project.getFile("service.yml"); + String modelsFolderLocation = null; + try { + modelsFolderLocation = project.getPersistentProperty(new QualifiedName("", + "eu.scasefp7.eclipse.core.ui.modelsFolder")); + } catch (CoreException e) { + Activator.log("Error retrieving project property (models folder location)", e); + } + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IContainer container = project; + String workspacePath = project.getFullPath().toPortableString()+"/"+ modelsFolderLocation; + if (workspacePath != null) { + if (root.findMember(new Path(workspacePath)) != null) + container = (IContainer) root.findMember(new Path(workspacePath)); + } + IFile file = container.getFile(new Path("service.yml")); if (file.exists()) { try { file.delete(IResource.FORCE, null); } catch (CoreException e) { - e.printStackTrace(); + Activator.log("Unable to delete YAML file (service.yml).", e); } } @@ -201,7 +219,7 @@ private void writeYamlFile(IProject project, Resources resources) throws Executi try { file.create(ymlStream, IResource.FORCE, null); } catch (CoreException e) { - e.printStackTrace(); + Activator.log("Unable to create YAML file (service.yml).", e); } } diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/OntologyJenaAPI.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/OntologyJenaAPI.java index b6f01dd..998aabd 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/OntologyJenaAPI.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/ontology/OntologyJenaAPI.java @@ -13,12 +13,15 @@ import java.util.ArrayList; import java.util.Iterator; +import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.QualifiedName; import com.hp.hpl.jena.ontology.Individual; import com.hp.hpl.jena.ontology.OntClass; @@ -128,8 +131,24 @@ private IFile getPathOfOntologyFile(IProject project, OntologyType ontologyType) IFile file = null; String filename = getFilenameForOntologyType(ontologyType); if (project != null) { - if (filename != null) - file = project.getFile(filename); + if (filename != null) { + String modelsFolderLocation = null; + try { + modelsFolderLocation = project.getPersistentProperty(new QualifiedName("", + "eu.scasefp7.eclipse.core.ui.modelsFolder")); + } catch (CoreException e) { + Activator.log("Error retrieving project property (models folder location)", e); + } + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IContainer container = project; + if (modelsFolderLocation != null) { + String workspacePath = project.getFullPath().toPortableString()+"/"+ modelsFolderLocation; + + if (root.findMember(new Path(workspacePath)) != null) + container = (IContainer) root.findMember(new Path(workspacePath)); + } + file = container.getFile(new Path(filename)); + } } else { if (filename != null) { filename = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + "/" + filename; From 918baac8a0461c9f4568c5bed1f3f6d36eeb5039 Mon Sep 17 00:00:00 2001 From: eleogas Date: Mon, 21 Mar 2016 15:00:38 +0100 Subject: [PATCH 24/29] Welcome page --- .../intropagecontent/introContent.xml | 27 ++++++++++++++++ .../intropagecontent/root.xhtml | 23 +++++++++++++ eu.scasefp7.eclipse.core.ui/plugin.xml | 32 ++++++++++++++++--- 3 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/intropagecontent/introContent.xml create mode 100644 eu.scasefp7.eclipse.core.ui/intropagecontent/root.xhtml diff --git a/eu.scasefp7.eclipse.core.ui/intropagecontent/introContent.xml b/eu.scasefp7.eclipse.core.ui/intropagecontent/introContent.xml new file mode 100644 index 0000000..58cbacc --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/intropagecontent/introContent.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/intropagecontent/root.xhtml b/eu.scasefp7.eclipse.core.ui/intropagecontent/root.xhtml new file mode 100644 index 0000000..0ddca58 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/intropagecontent/root.xhtml @@ -0,0 +1,23 @@ + + + + + root.xhtml + + + + +

Title

+ + First link + First item + + + + Second + Second item + + + + diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 09fdc28..cf2e2c0 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -368,9 +368,8 @@ - - @@ -507,4 +505,30 @@
+ + + + + + + + + + + + +
From 3c7b220b779593c1840432593c5bf70a728c4650 Mon Sep 17 00:00:00 2001 From: eleogas Date: Thu, 31 Mar 2016 09:09:41 +0200 Subject: [PATCH 25/29] Project folders - context menu, property pages --- .../icons/scaseFolder.png | Bin 0 -> 509 bytes eu.scasefp7.eclipse.core.ui/plugin.xml | 230 +++++++++++++ .../eclipse/core/ui/ScaseUiConstants.java | 64 ++-- .../eclipse/core/ui/SharedImages.java | 5 +- .../ConvertToProjectFolderHandler.java | 56 ++++ .../ui/handlers/OpenDeployWizardHander.java | 8 +- .../ui/navigator/ArtefactContentProvider.java | 4 +- .../ui/navigator/ArtefactLabelProvider.java | 2 +- .../ui/perspectives/ScasePerspective.java | 5 +- .../ui/preferences/GlobalPreferencePage.java | 8 +- .../InfrastructureServicesPreferencePage.java | 5 + .../ui/preferences/PreferenceConstants.java | 29 +- .../ui/preferences/PreferenceInitializer.java | 6 +- .../ProjectDomainPropertyPage.java | 34 +- .../ProjectFoldersPreferencePage.java | 309 ++++++++++++++++++ .../CompositionsFolderActive.java | 103 ++++++ .../ui/sourceprovider/ModelsFolderActive.java | 103 ++++++ .../ui/sourceprovider/OutputFolderActive.java | 103 ++++++ .../RequirementsFolderActive.java | 103 ++++++ .../ui/wizards/NewScaseProjectWizard.java | 44 ++- .../ui/wizards/NewScaseProjectWizard2.java | 2 +- 21 files changed, 1144 insertions(+), 79 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/icons/scaseFolder.png create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/handlers/ConvertToProjectFolderHandler.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ProjectFoldersPreferencePage.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/sourceprovider/CompositionsFolderActive.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/sourceprovider/ModelsFolderActive.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/sourceprovider/OutputFolderActive.java create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/sourceprovider/RequirementsFolderActive.java diff --git a/eu.scasefp7.eclipse.core.ui/icons/scaseFolder.png b/eu.scasefp7.eclipse.core.ui/icons/scaseFolder.png new file mode 100644 index 0000000000000000000000000000000000000000..723f6f128b75ead7f5cce34809db6ee53dfa198e GIT binary patch literal 509 zcmVnf`!Yi*7+C^!U7g8)p$-6L67$Vk1;0ObY5}_?o!LhMUq> z>v8Q#1zj<1<}(!MOWSn&c%B#L)PY|1J$(3{=f^qUa}Li>k}eQMT1{;;v;K>JM~8)) zbeVv}eu{zR2=5jb=v|a~tAv@`SR*gSxec<*MlqROju-M55%7bZOqvg|pL9pVM7K7{ z=g$OuAGL8-IkD(T$WQyX06{fD@6rMt;W?()V#W<#Kec1fLH4gx=OFfmr2L$?w@nYx zPU?z$}EkPev?=a~jk8l&rrk7$d~6)-o&1Fd4|`yJpfp8F?C;`9#81`qfLf~) z#Je@D4G!+tYdB3euxj35y7q0Z(*rDZ?_t?q;MTo9+`n@dQggT82&lL{0?{^|%Gx1@ zl{CXqfs!%ix)+nC^3Kpn4_v$90=b#;n=YLGl#U}HJYdW + + + + + + + + - - \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 40411b0..56ee199 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -760,5 +760,42 @@ priorityLevel="workbench"> - + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ScaseProjectPropertySection.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ScaseProjectPropertySection.java new file mode 100644 index 0000000..cec013f --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/preferences/ScaseProjectPropertySection.java @@ -0,0 +1,151 @@ +package eu.scasefp7.eclipse.core.ui.preferences; + +import java.util.ArrayList; +import java.util.Arrays; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.views.properties.IPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.ResourcePropertySource; +import org.eclipse.ui.views.properties.tabbed.AdvancedPropertySection; + +import eu.scasefp7.eclipse.core.ui.ScaseUiConstants; +import eu.scasefp7.eclipse.core.ui.preferences.internal.DomainEntry; +import eu.scasefp7.eclipse.core.ui.preferences.internal.IProjectDomains; + +public class ScaseProjectPropertySection extends AdvancedPropertySection { + IProject project; + + @Override + public void setInput(IWorkbenchPart part, ISelection selection) { + if (selection instanceof StructuredSelection) { + Object firstElement = ((StructuredSelection)selection).getFirstElement(); + + if (firstElement instanceof IResource && ! (firstElement instanceof IWorkspaceRoot)) { + project = ((IResource)firstElement).getProject(); + final IProject theProject = project; + ISelection selection2 = new StructuredSelection(new ResourcePropertySource(theProject) { + + @Override + public IPropertyDescriptor[] getPropertyDescriptors() { + ArrayList arrayList = new ArrayList(); + try { + if(project.hasNature("eu.scasefp7.eclipse.core.scaseNature")) { + PropertyDescriptor pd1 = new PropertyDescriptor("projectdomain", "Project domain"); + PropertyDescriptor pd2 = new PropertyDescriptor("compositionsfolder", "Compositions folder"); + PropertyDescriptor pd3 = new PropertyDescriptor("modelsfolder", "Models folder"); + PropertyDescriptor pd4 = new PropertyDescriptor("outputfolder", "Output folder"); + PropertyDescriptor pd5 = new PropertyDescriptor("requirementsfolder", "Requirements folder"); + + pd1.setCategory("Domain"); + pd2.setCategory("Folders"); + pd3.setCategory("Folders"); + pd4.setCategory("Folders"); + pd5.setCategory("Folders"); + IPropertyDescriptor[] array = {pd1,pd2,pd3,pd4,pd5}; + arrayList.addAll(Arrays.asList(array)); + } + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return arrayList.toArray(new IPropertyDescriptor[0]); + } + + @Override + public Object getPropertyValue(Object id) { + if(project.isAccessible()) { + if (id.equals("projectdomain")) { + String projDomain = null; + try { + String domainId = project.getPersistentProperty(new QualifiedName("",ScaseUiConstants.PROP_PROJECT_DOMAIN)); + if(domainId == null || domainId.equals("-1")) + projDomain = "domain unset"; + else{ + DomainEntry de = findDomainById(IProjectDomains.PROJECT_DOMAINS, Integer.parseInt(domainId)); + projDomain = de.getParent().getName() + "/" + de.getName(); + } + + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return projDomain; + } + if (id.equals("outputfolder")) { + String outFolder = null; + try { + outFolder = project.getPersistentProperty(new QualifiedName("",ScaseUiConstants.OUTPUT_FOLDER)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return outFolder; + } + if (id.equals("compositionsfolder")) { + String comFolder = null; + try { + comFolder = project.getPersistentProperty(new QualifiedName("",ScaseUiConstants.COMPOSITIONS_FOLDER)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return comFolder; + } + if (id.equals("modelsfolder")) { + String modFolder = null; + try { + modFolder = project.getPersistentProperty(new QualifiedName("",ScaseUiConstants.MODELS_FOLDER)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return modFolder; + } + if (id.equals("requirementsfolder")) { + String rqsFolder = null; + try { + rqsFolder = project.getPersistentProperty(new QualifiedName("",ScaseUiConstants.REQUIREMENTS_FOLDER)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return rqsFolder; + } + } + + return super.getPropertyValue(id); + + } + + }); + super.setInput(part, selection2); + } else { + super.setInput(part, selection); + } + } + } + private DomainEntry findDomainById(DomainEntry[] domains, int domainId) { + for (DomainEntry de : domains) { + if (de.getId() == domainId) { + return de; + } + if(de.hasChildren()) { + for (DomainEntry child : de.getChildren()) { + if(child.getId() == domainId) { + return child; + } + } + } + } + return null; + } +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/SCaseButtonRenderer.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/SCaseButtonRenderer.java new file mode 100644 index 0000000..51544f0 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/SCaseButtonRenderer.java @@ -0,0 +1,44 @@ +package eu.scasefp7.eclipse.core.ui.views; + + +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.widgets.Display; +import org.mihalis.opal.obutton.AbstractButtonRenderer; +import org.mihalis.opal.utils.SWTGraphicUtil; + +public class SCaseButtonRenderer + extends AbstractButtonRenderer +{ + private static SCaseButtonRenderer instance; + private static final Color FIRST_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(80, 184, 170); + private static final Color SECOND_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(115, 220, 215); + + protected Color getFontColor() + { + return Display.getDefault().getSystemColor(1); + } + + protected Color getFirstBackgroundColor() + { + return FIRST_BACKGROUND_COLOR; + } + + protected Color getSecondBackgroundColor() + { + return SECOND_BACKGROUND_COLOR; + } + + public static SCaseButtonRenderer getInstance() + { + if (instance == null) { + instance = new SCaseButtonRenderer(); + } + return instance; + } +} + +/* Location: C:\scaseWorkspace\Opal + * Qualified Name: org.mihalis.opal.obutton.GreenButtonRenderer + * Java Class Version: 6 (50.0) + * JD-Core Version: 0.7.1 + */ \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ProjectFoldersWizardPage.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ProjectFoldersWizardPage.java new file mode 100644 index 0000000..dbcdec7 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/wizards/ProjectFoldersWizardPage.java @@ -0,0 +1,307 @@ +package eu.scasefp7.eclipse.core.ui.wizards; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; + +import eu.scasefp7.eclipse.core.ui.Activator; +import eu.scasefp7.eclipse.core.ui.ScaseUiConstants; + + +/** + * Create project folders during project creation. + * + * @author Leonora Gaspar + * @author Marin Orlic + */ +public class ProjectFoldersWizardPage extends WizardPage implements IWizardPage{ + String modelsPath = ""; + String outputPath = ""; + String reqPath = ""; + String comPath = ""; + + protected ProjectFoldersWizardPage(String pageName) { + super(pageName); + // TODO Auto-generated constructor stub + } + + @Override + public void createControl(Composite parent) { + initializeDialogUnits(parent); + + final Composite composite= new Composite(parent, SWT.NULL); + composite.setFont(parent.getFont()); + GridLayout layout = new GridLayout(); + layout.numColumns = 3; + composite.setLayout(layout); + composite.setLayoutData(new GridData(SWT.BEGINNING)); + + Label a = new Label(composite, SWT.NULL); + a.setText ("The models will be stored in folder:"); + GridData gridData1 = new GridData(); + gridData1.horizontalAlignment = GridData.FILL; + gridData1.horizontalSpan = 3; + a.setLayoutData(gridData1); + + Label label = new Label(composite, SWT.NULL); + Text models = new Text(composite, SWT.BORDER); + GridData gridData = new GridData(); + gridData.horizontalAlignment = SWT.FILL; + gridData.grabExcessHorizontalSpace = true; + + final Button button = new Button(composite, SWT.PUSH); + + label.setText("Models folder path: "); + models.setText("models"); + models.setEnabled(false); + button.setText("Browse..."); + models.setLayoutData(gridData); + + + IContainer root = ResourcesPlugin.getWorkspace().getRoot(); + button.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event e) { + Path resPath; + switch (e.type) { + case SWT.Selection: + + ContainerSelectionDialog dlg = new ContainerSelectionDialog (parent.getShell(), root, true, null); + dlg.setMessage("Select a directory"); + dlg.open(); + Object[] res = dlg.getResult(); + if(res != null) + { + resPath = (Path ) res[0]; + models.setText(resPath.toString()); + modelsPath = resPath.toString(); + } + + break; + } + } + + }); + + //Empty row + Label e1 = new Label(composite, SWT.NULL); + GridData gridData11 = new GridData(); + gridData11.horizontalAlignment = GridData.FILL; + gridData11.horizontalSpan = 3; + e1.setLayoutData(gridData11); + + Label a2 = new Label(composite, SWT.NULL); + a2.setText ("The generated code will be stored in folder:"); + GridData gridData2 = new GridData(); + gridData2.horizontalAlignment = GridData.FILL; + gridData2.horizontalSpan = 3; + a2.setLayoutData(gridData2); + + GridData gridData3 = new GridData(); + gridData3.horizontalAlignment = SWT.FILL; + gridData3.grabExcessHorizontalSpace = true; + Label label2 = new Label(composite, SWT.NULL); + Text output = new Text(composite, SWT.BORDER); + final Button button2 = new Button(composite, SWT.PUSH); + + label2.setText("Output folder path: "); + output.setText("output"); + output.setEnabled(false); + button2.setText("Browse..."); + output.setLayoutData(gridData3); + + button2.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event e) { + Path resPath; + switch (e.type) { + case SWT.Selection: + + ContainerSelectionDialog dlg = new ContainerSelectionDialog (parent.getShell(), root, true, null); + dlg.setMessage("Select a directory"); + dlg.open(); + Object[] res = dlg.getResult(); + if(res != null) + { + resPath = (Path ) res[0]; + output.setText(resPath.toString()); + outputPath = resPath.toString(); + } + + break; + } + } + + }); + + //Empty row + Label e2 = new Label(composite, SWT.NULL); + GridData gridData21 = new GridData(); + gridData21.horizontalAlignment = GridData.FILL; + gridData21.horizontalSpan = 3; + e2.setLayoutData(gridData21); + + Label a3 = new Label(composite, SWT.NULL); + a3.setText ("The requirements will be stored in folder:"); + + GridData gridData31 = new GridData(); + gridData31.horizontalAlignment = GridData.FILL; + gridData31.horizontalSpan = 3; + a3.setLayoutData(gridData31); + + GridData gridData4 = new GridData(); + gridData4.horizontalAlignment = SWT.FILL; + gridData4.grabExcessHorizontalSpace = true; + Label label3 = new Label(composite, SWT.NULL); + Text requirements = new Text(composite, SWT.BORDER); + final Button button3 = new Button(composite, SWT.PUSH); + + label3.setText("Requirements folder path: "); + requirements.setText("requirements"); + requirements.setEnabled(false); + button3.setText("Browse..."); + requirements.setLayoutData(gridData4); + + button3.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event e) { + Path resPath; + switch (e.type) { + case SWT.Selection: + + ContainerSelectionDialog dlg = new ContainerSelectionDialog (parent.getShell(), root, true, null); + dlg.setMessage("Select a directory"); + dlg.open(); + Object[] res = dlg.getResult(); + if(res != null) + { + resPath = (Path ) res[0]; + requirements.setText(resPath.toString()); + reqPath = resPath.toString(); + } + + break; + } + } + + }); + + //Empty row + Label e3 = new Label(composite, SWT.NULL); + GridData gridData32 = new GridData(); + gridData32.horizontalAlignment = GridData.FILL; + gridData32.horizontalSpan = 3; + e3.setLayoutData(gridData32); + + Label a4 = new Label(composite, SWT.NULL); + a4.setText ("The storyboards used for composition will be in folder:"); + GridData gridData41 = new GridData(); + gridData41.horizontalAlignment = GridData.FILL; + gridData41.horizontalSpan = 3; + a4.setLayoutData(gridData41); + + Label label4 = new Label(composite, SWT.NULL); + Text compositions = new Text(composite, SWT.BORDER); + final Button button4 = new Button(composite, SWT.PUSH); + + GridData gridData6 = new GridData(); + gridData6.horizontalAlignment = SWT.FILL; + gridData6.grabExcessHorizontalSpace = true; + + label4.setText("Compositions folder path: "); + compositions.setText("compositions"); + compositions.setEnabled(false); + button4.setText("Browse..."); + compositions.setLayoutData(gridData6); + + button4.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event e) { + Path resPath; + switch (e.type) { + case SWT.Selection: + + ContainerSelectionDialog dlg = new ContainerSelectionDialog (parent.getShell(), root, true, null); + dlg.setMessage("Select a directory"); + dlg.open(); + Object[] res = dlg.getResult(); + if(res != null) + { + resPath = (Path ) res[0]; + compositions.setText(resPath.toString()); + comPath = resPath.toString(); + } + + break; + } + } + + }); + + + + setControl(composite); + } + + /** + * Creates the project folders. + * @param resource + * @return true if the folders were created successfully. + */ + public boolean performFinish(IResource resource) { + IProject project = (IProject) resource; + IFolder models = project.getFolder("models"); + IFolder output = project.getFolder("output"); + IFolder requirements = project.getFolder("requirements"); + IFolder compositions = project.getFolder("compositions"); + + IProgressMonitor monitor = new NullProgressMonitor(); + try { + models.create(true, true, monitor); + output.create(true, true, monitor); + requirements.create(true, true, monitor); + compositions.create(true, true, monitor); + } catch (CoreException e) { + Activator.log("Unable to create project folders.", e); + } + + if(modelsPath.equals("")) + modelsPath = models.getProjectRelativePath().toPortableString(); + if(outputPath.equals("")) + outputPath = output.getProjectRelativePath().toPortableString(); + if(reqPath.equals("")) + reqPath = requirements.getProjectRelativePath().toPortableString(); + if(comPath.equals("")) + comPath = compositions.getProjectRelativePath().toPortableString(); + + try { + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.MODELS_FOLDER), modelsPath); + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER), outputPath); + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER), reqPath); + project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER), comPath); + } catch (CoreException e) { + Activator.log("Unable to set project properties.", e); + } + return false; + } + +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF index 214b656..dfe1669 100644 --- a/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF @@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.ui.workbench, org.eclipse.jface, org.eclipse.core.resources, org.eclipse.ui, - org.eclipse.core.variables + org.eclipse.core.variables, + org.eclipse.swt Bundle-ClassPath: . Export-Package: eu.scasefp7.eclipse.core, eu.scasefp7.eclipse.core.builder, diff --git a/eu.scasefp7.eclipse.core/build.properties b/eu.scasefp7.eclipse.core/build.properties index 289e5c4..0a16292 100644 --- a/eu.scasefp7.eclipse.core/build.properties +++ b/eu.scasefp7.eclipse.core/build.properties @@ -1,5 +1,5 @@ source.. = src/ output.. = target/classes/ bin.includes = META-INF/,\ - plugin.xml,\ - . + plugin.xml,\ + .,\ diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/CompileDynamicRequirementsHandler.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/CompileDynamicRequirementsHandler.java index 5f5f4fc..22a3050 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/CompileDynamicRequirementsHandler.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/CompileDynamicRequirementsHandler.java @@ -20,7 +20,7 @@ public class CompileDynamicRequirementsHandler extends CommandExecutorHandler { public Object execute(ExecutionEvent event) throws ExecutionException { if (getProjectOfExecutionEvent(event) != null) { executeCommand("eu.scasefp7.eclipse.storyboards.commands.exportAllToOntology"); - executeCommand("eu.scasefp7.eclipse.umlrec.commands.exportActivityDiagramsToOntology"); + // executeCommand("eu.scasefp7.eclipse.umlrec.commands.exportActivityDiagramsToOntology"); return null; } else { throw new ExecutionException("No project selected"); diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/CompileStaticRequirementsHandler.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/CompileStaticRequirementsHandler.java index cf3b3c0..0e04da8 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/CompileStaticRequirementsHandler.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/CompileStaticRequirementsHandler.java @@ -20,7 +20,7 @@ public class CompileStaticRequirementsHandler extends CommandExecutorHandler { public Object execute(ExecutionEvent event) throws ExecutionException { if (getProjectOfExecutionEvent(event) != null) { executeCommand("eu.scasefp7.eclipse.reqeditor.commands.exportAllToOntology"); - executeCommand("eu.scasefp7.eclipse.umlrec.commands.exportUseCaseDiagramsToOntology"); + // executeCommand("eu.scasefp7.eclipse.umlrec.commands.exportUseCaseDiagramsToOntology"); return null; } else { throw new ExecutionException("No project selected"); diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java index 261246c..f994467 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/handlers/LinkOntologiesHandler.java @@ -23,9 +23,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException { IProject project = getProjectOfExecutionEvent(event); //String projectName = event.getParameter("projectName"); String fileName = event.getParameter("fileName"); - Path path = new Path(fileName); //When handler is called from builder if(fileName != null){ + Path path = new Path(fileName); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); project = file.getProject(); //project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/splashHandlers/InteractiveSplashHandler.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/splashHandlers/InteractiveSplashHandler.java new file mode 100644 index 0000000..603388c --- /dev/null +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/splashHandlers/InteractiveSplashHandler.java @@ -0,0 +1,293 @@ + +package eu.scasefp7.eclipse.core.splashHandlers; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.splash.AbstractSplashHandler; + +/** + * @since 3.3 + * + */ +public class InteractiveSplashHandler extends AbstractSplashHandler { + + private final static int F_LABEL_HORIZONTAL_INDENT = 175; + + private final static int F_BUTTON_WIDTH_HINT = 80; + + private final static int F_TEXT_WIDTH_HINT = 175; + + private final static int F_COLUMN_COUNT = 3; + + private Composite fCompositeLogin; + + private Text fTextUsername; + + private Text fTextPassword; + + private Button fButtonOK; + + private Button fButtonCancel; + + private boolean fAuthenticated; + + /** + * + */ + public InteractiveSplashHandler() { + fCompositeLogin = null; + fTextUsername = null; + fTextPassword = null; + fButtonOK = null; + fButtonCancel = null; + fAuthenticated = false; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.splash.AbstractSplashHandler#init(org.eclipse.swt.widgets.Shell) + */ + public void init(final Shell splash) { + // Store the shell + super.init(splash); + // Configure the shell layout + configureUISplash(); + // Create UI + createUI(); + // Create UI listeners + createUIListeners(); + // Force the splash screen to layout + splash.layout(true); + // Keep the splash screen visible and prevent the RCP application from + // loading until the close button is clicked. + doEventLoop(); + } + + /** + * + */ + private void doEventLoop() { + Shell splash = getSplash(); + while (fAuthenticated == false) { + if (splash.getDisplay().readAndDispatch() == false) { + splash.getDisplay().sleep(); + } + } + } + + /** + * + */ + private void createUIListeners() { + // Create the OK button listeners + createUIListenersButtonOK(); + // Create the cancel button listeners + createUIListenersButtonCancel(); + } + + /** + * + */ + private void createUIListenersButtonCancel() { + fButtonCancel.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + handleButtonCancelWidgetSelected(); + } + }); + } + + /** + * + */ + private void handleButtonCancelWidgetSelected() { + // Abort the loading of the RCP application + getSplash().getDisplay().close(); + System.exit(0); + } + + /** + * + */ + private void createUIListenersButtonOK() { + fButtonOK.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + handleButtonOKWidgetSelected(); + } + }); + } + + /** + * + */ + private void handleButtonOKWidgetSelected() { + String username = fTextUsername.getText(); + String password = fTextPassword.getText(); + // Aunthentication is successful if a user provides any username and + // any password + if ((username.length() > 0) && + (password.length() > 0)) { + fAuthenticated = true; + } else { + MessageDialog.openError( + getSplash(), + "Authentication Failed", //$NON-NLS-1$ + "A username and password must be specified to login."); //$NON-NLS-1$ + } + } + + /** + * + */ + private void createUI() { + // Create the login panel + createUICompositeLogin(); + // Create the blank spanner + createUICompositeBlank(); + // Create the user name label + createUILabelUserName(); + // Create the user name text widget + createUITextUserName(); + // Create the password label + createUILabelPassword(); + // Create the password text widget + createUITextPassword(); + // Create the blank label + createUILabelBlank(); + // Create the OK button + createUIButtonOK(); + // Create the cancel button + createUIButtonCancel(); + } + + /** + * + */ + private void createUIButtonCancel() { + // Create the button + fButtonCancel = new Button(fCompositeLogin, SWT.PUSH); + fButtonCancel.setText("Cancel"); //$NON-NLS-1$ + // Configure layout data + GridData data = new GridData(SWT.NONE, SWT.NONE, false, false); + data.widthHint = F_BUTTON_WIDTH_HINT; + data.verticalIndent = 10; + fButtonCancel.setLayoutData(data); + } + + /** + * + */ + private void createUIButtonOK() { + // Create the button + fButtonOK = new Button(fCompositeLogin, SWT.PUSH); + fButtonOK.setText("OK"); //$NON-NLS-1$ + // Configure layout data + GridData data = new GridData(SWT.NONE, SWT.NONE, false, false); + data.widthHint = F_BUTTON_WIDTH_HINT; + data.verticalIndent = 10; + fButtonOK.setLayoutData(data); + } + + /** + * + */ + private void createUILabelBlank() { + Label label = new Label(fCompositeLogin, SWT.NONE); + label.setVisible(false); + } + + /** + * + */ + private void createUITextPassword() { + // Create the text widget + int style = SWT.PASSWORD | SWT.BORDER; + fTextPassword = new Text(fCompositeLogin, style); + // Configure layout data + GridData data = new GridData(SWT.NONE, SWT.NONE, false, false); + data.widthHint = F_TEXT_WIDTH_HINT; + data.horizontalSpan = 2; + fTextPassword.setLayoutData(data); + } + + /** + * + */ + private void createUILabelPassword() { + // Create the label + Label label = new Label(fCompositeLogin, SWT.NONE); + label.setText("&Password:"); //$NON-NLS-1$ + // Configure layout data + GridData data = new GridData(); + data.horizontalIndent = F_LABEL_HORIZONTAL_INDENT; + label.setLayoutData(data); + } + + /** + * + */ + private void createUITextUserName() { + // Create the text widget + fTextUsername = new Text(fCompositeLogin, SWT.BORDER); + // Configure layout data + GridData data = new GridData(SWT.NONE, SWT.NONE, false, false); + data.widthHint = F_TEXT_WIDTH_HINT; + data.horizontalSpan = 2; + fTextUsername.setLayoutData(data); + } + + /** + * + */ + private void createUILabelUserName() { + // Create the label + Label label = new Label(fCompositeLogin, SWT.NONE); + label.setText("&User Name:"); //$NON-NLS-1$ + // Configure layout data + GridData data = new GridData(); + data.horizontalIndent = F_LABEL_HORIZONTAL_INDENT; + label.setLayoutData(data); + } + + /** + * + */ + private void createUICompositeBlank() { + Composite spanner = new Composite(fCompositeLogin, SWT.NONE); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.horizontalSpan = F_COLUMN_COUNT; + spanner.setLayoutData(data); + } + + /** + * + */ + private void createUICompositeLogin() { + // Create the composite + fCompositeLogin = new Composite(getSplash(), SWT.BORDER); + GridLayout layout = new GridLayout(F_COLUMN_COUNT, false); + fCompositeLogin.setLayout(layout); + } + + /** + * + */ + private void configureUISplash() { + // Configure layout + FillLayout layout = new FillLayout(); + getSplash().setLayout(layout); + // Force shell to inherit the splash background + getSplash().setBackgroundMode(SWT.INHERIT_DEFAULT); + } + +} From 56f5ddb7c55b229a2d48e6a68949cc7f6d7ea1d7 Mon Sep 17 00:00:00 2001 From: eleogas Date: Thu, 21 Apr 2016 10:35:46 +0200 Subject: [PATCH 27/29] About pages- current version --- .../feature.xml | 3 +- eu.scasefp7.eclipse.core.ui/.options | 8 +- .../META-INF/MANIFEST.MF | 4 +- eu.scasefp7.eclipse.core.ui/about.ini | 15 + eu.scasefp7.eclipse.core.ui/build.properties | 4 +- .../icons/s-case-feature.png | Bin 0 -> 2284 bytes eu.scasefp7.eclipse.core.ui/plugin.xml | 15 +- .../scasefp7/eclipse/core/ui/Activator.java | 259 +++++++----------- .../eclipse/core/ui/BuildDeltaVisitor.java | 160 +++++++++++ .../core/ui/views/SCaseButtonRenderer.java | 44 --- target-platform/target-platform.target | 32 ++- 11 files changed, 322 insertions(+), 222 deletions(-) create mode 100644 eu.scasefp7.eclipse.core.ui/about.ini create mode 100644 eu.scasefp7.eclipse.core.ui/icons/s-case-feature.png create mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/BuildDeltaVisitor.java delete mode 100644 eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/SCaseButtonRenderer.java diff --git a/eu.scasefp7.eclipse.core.dependencies.feature/feature.xml b/eu.scasefp7.eclipse.core.dependencies.feature/feature.xml index fe7c6d0..fd55902 100644 --- a/eu.scasefp7.eclipse.core.dependencies.feature/feature.xml +++ b/eu.scasefp7.eclipse.core.dependencies.feature/feature.xml @@ -3,7 +3,8 @@ id="eu.scasefp7.eclipse.core.dependencies.feature" label="S-CASE Core third-party dependencies" version="1.1.1.qualifier" - provider-name="S-CASE Consortium"> + provider-name="S-CASE Consortium" + plugin="eu.scasefp7.eclipse.core.ui"> The dependencies of the S-CASE Core module. diff --git a/eu.scasefp7.eclipse.core.ui/.options b/eu.scasefp7.eclipse.core.ui/.options index 01b0d6c..fe90043 100644 --- a/eu.scasefp7.eclipse.core.ui/.options +++ b/eu.scasefp7.eclipse.core.ui/.options @@ -1,4 +1,4 @@ -# Tracing options for the eu.scasefp7.eclipse.core.ui plug-in - -eu.scasefp7.eclipse.core.ui/debug=false -eu.scasefp7.eclipse.core.ui/debug/userActions=false \ No newline at end of file +eu.scasefp7.eclipse.core.ui/dashboard=false +eu.scasefp7.eclipse.core.ui/dashboard/executeCommand=false +eu.scasefp7.eclipse.core.ui/dashboard/userActions=false +eu.scasefp7.eclipse.core.ui/dashboard/selectedProjectChanged=false \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF index 1340ebb..c295ebd 100644 --- a/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core.ui/META-INF/MANIFEST.MF @@ -19,7 +19,6 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.m2e.core, org.eclipse.m2e.maven.runtime, org.eclipse.ui.navigator, - Opal, org.eclipse.ui.intro, org.eclipse.core.expressions, org.eclipse.ui.views.properties.tabbed, @@ -32,5 +31,4 @@ Bundle-Activator: eu.scasefp7.eclipse.core.ui.Activator Bundle-ActivationPolicy: lazy Import-Package: eu.scasefp7.eclipse.core.builder, eu.scasefp7.eclipse.core.ontology, - org.eclipse.debug.internal.ui, - org.mihalis.opal.obutton + org.eclipse.debug.internal.ui diff --git a/eu.scasefp7.eclipse.core.ui/about.ini b/eu.scasefp7.eclipse.core.ui/about.ini new file mode 100644 index 0000000..099d212 --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/about.ini @@ -0,0 +1,15 @@ +featureImage=icons/s-case-feature.png +aboutText=S-CASE UML recognizer image import wizard\n\ +\n\ +Frontend to UML recognizer module presented as an Eclipse import wizard. Image files of type JPG, JPEG2000, PNG and BMP are supported. Activity and use case diagrams can be detected. Result is stored in an XMI file and can be automatically opened in an associated editor.\n\ +\n\ +Please visit http://www.scasefp7.eu for more information on the S-CASE project.\n\ +\n\ +Please visit https://github.com/s-case/ for development information on the S-CASE project.\n\ +Please visit https://github.com/s-case/uml-extraction development information on this feature.\n\ +\n\ +(c) Copyright 2015 S-CASE Consortium\n\ +Licensed under the Apache License, Version 2.0\n\ +\n\ +This feature includes imgscalr software developed by the\n\ +The Buzz Media, LLC (https://github.com/thebuzzmedia/imgscalr)\n\ \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/build.properties b/eu.scasefp7.eclipse.core.ui/build.properties index c4bac2a..3b438a8 100644 --- a/eu.scasefp7.eclipse.core.ui/build.properties +++ b/eu.scasefp7.eclipse.core.ui/build.properties @@ -5,4 +5,6 @@ bin.includes = plugin.xml,\ .,\ OSGI-INF/,\ contexts.xml,\ - icons/ + icons/,\ + about.ini +src.includes = about.ini diff --git a/eu.scasefp7.eclipse.core.ui/icons/s-case-feature.png b/eu.scasefp7.eclipse.core.ui/icons/s-case-feature.png new file mode 100644 index 0000000000000000000000000000000000000000..d252fc2d15da7374de7b37e32999cd877b367345 GIT binary patch literal 2284 zcmVqShTX6sY2zg0F zK~z}7y_bD#mE{@6fA{mg=cA>i1uEar1ErNO0SoAaF@&iJZV}ydOGI6QBiTnxW;V&b zlFbaWEbzx%HWN|Q45t%AM6!t!m8q@3prw4Zg;Gijv_i2Tr|tQA-}kxqM^9;s!Z0y= zlXLz!InVQ6&vjk*b>9zs!RO$G^8oB^Z59A+x@Z8H3EF;!|I734+0!mSRol6x+nefZ z-)yMg0`OvOO}MhHS$Pjqy(BQoNVH)f}Kt z?X?-$efku4PM^U)8tR;Hmd*+)FEp2*?d*OvZKN#Mgb2ICF$dPt>v^9!goOr&T@bvpo~oKW%hQ?;)*c6C=}j45$I6M;uh+QYXN zxr|*tS6HKps)V|{V8bg7N1G<(j`+q{H$wj3Uy_=(76CZf*EM|gjuS^@b=gh&#_8kF z$E|(Xu@cs+xz`9I-3Y$5+7o0%^x8gh6g93^&B`Bj*Mf0VI(If4 zlc)}m9LGwaMjh49wXOn+s>yRgjdAOjnEwGlMXgZ-q9zuNu39#=^zGWti^C=85`St( zCX*8c7HiZ&g`rHF0mfCt744iB9r=}WiH_C1UIwdb1^J93(*IFG#27v)$uC^AY-;J- z0I9y@Z~$U0B0{hA==CyW2!?2l4Gs}A937}RiWEY(-(MHRYV5Y zWc5lEIOg#+rE@1OnJ}fQ>Rgina9rmK0LJP6ze1o&!t?0$JX8Qx@*UZEN33kLHD=S{ z*8Zdm)CK@9f~Ns-KSRRzP!R-7)OG&+(2Ut5AEv9HKY2KS5s?U3 zMThWcv2>=B+UNUK-B45Q##OWaTSQQ^P?C9@y9 zzv7?f%|-V+MK|R0@8-r~61l^jl68_O*^Hsj_eooo9@2|89NOC(%gb9k(q;Q)cN>%2 z?~CjfgX`TkFSGcW+Umr(Xn6Ii=`(i&)c1aR^&AjHtSF8O8Ec7qKB>T7-WJF?)6@4_ zO?Pj_j;8wC06f%H6(s968Q3W+rL{KPnoPa(Y+coRyBq7~{b0^5yimP21n}00V^>6R zI%qc*KJ`8Nf&kU582v?uDn?P#0k<6P`1IrF>Z*6-I-vqli-IyhoGP0ALBT=64_IEG zOdNjo#F5R*OG?84VZDNZoV0h`ah#_`14K<=<%;0GT+_ZW#<8u*)ar(gu5|?=_eBRW zK>BLkO;JY#+n!0U+tt#vO;t%4%rF3@W5#EGG^hM0YsSo+5^-#$YmFHsb%<2zAgabe z=&^p=BQqDQoi=Lxow=?g2P%I+l7Y2WgrpysPCu|-pw58hE(54+Jx@VVp}y02N~TR6 zb8h|o+m?^ab(iNj($b&&I`lLHs$_|WRTC$@`{>Mtql%)TwNVGu8blQ%LRyvHbed$~ zmTZ6k{;ny;+H66RDKHjyW z*UykqixK%;AbHUo-FKHY0(vl_a)3(qI}NZ9}*GBlR2J&I-2ND&GQBSK+9qEUcn zk007vaiR5ItC}Z>MF}g43S_L}d1=DplIMmLG5sYgW)Ogg;9u&^d8+x)k&|9xMik>& z6M!{huI$MQ9!hs6NxmDI^xNtR?|4tA8xj-HKb{#G5~>47PpQREr<`y!R3k=o+u;L) z5Rlr&lBP3(t$mZWKUNLIj#wYezA_{OK-Z|WqyUx_HDmIH3>S|a!YXKj$ z)`pLCB))ql*|Wu0$B0#AVE-vBy^UbWBR6M*2R>fukuwwdb02<<{;IX-jwr*No&k7t&n~vCSoOuP zW~*W)ynomCSQ(44wf-2@t?jbEv$bQx!rK>3i$orYIJ996Mm5Nw7-K0i(Jjw?^^U?P z<}G< - - + + name="eu.scasefp7.eclipse.*"> - - + + props = new Hashtable(4); - props.put(DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID); + Dictionary props = new Hashtable(4); + props.put(DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID); context.registerService(DebugOptionsListener.class.getName(), this, props); IWorkspace workspace = ResourcesPlugin.getWorkspace(); - rcl = new IResourceChangeListener() { - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta = event.getDelta(); - try { - delta.accept(new BuildDeltaVisitor()); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + resourceChangeListener = new IResourceChangeListener() { + public void resourceChanged(IResourceChangeEvent event) { + IResourceDelta delta = event.getDelta(); + if (delta != null) { + BuildDeltaVisitor deltaVisitor = new BuildDeltaVisitor(); + try { + delta.accept(deltaVisitor); + } catch (CoreException e) { + Activator.log("Error when handling rename or delete of project and/or project folders", e); + } + } + } }; - workspace.addResourceChangeListener(rcl); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - ResourcesPlugin.getWorkspace().removeResourceChangeListener(rcl); - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Returns the shared image registry - * - * @return the images - */ - public static SharedImages getImages() { - if(images == null) { - images = new SharedImages(); - } - - return images; - } - - /** + workspace.addResourceChangeListener(resourceChangeListener); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + workspace.removeResourceChangeListener(resourceChangeListener); + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns the shared image registry + * + * @return the images + */ + public static SharedImages getImages() { + if (images == null) { + images = new SharedImages(); + } + + return images; + } + + /** * Returns an image descriptor for the image file at the given * plug-in relative path * @@ -134,10 +132,12 @@ public static SharedImages getImages() { public static ImageDescriptor getImageDescriptor(String path) { return imageDescriptorFromPlugin(PLUGIN_ID, path); } - - /** - * Logs an exception to the Eclipse log file. This method detects the class and the method in which the exception - * was caught automatically using the current stack trace. If required, the user can override these values by + + /** + * Logs an exception to the Eclipse log file. + * + * This method detects the class and the method in which the exception was caught automatically using + * the current stack trace. If required, the user can override these values by * calling {@link #log(String, String, String, Exception)} instead. * * @param message a human-readable message about the exception. @@ -149,9 +149,11 @@ public static void log(String message, Exception exception) { } /** - * Logs an exception to the Eclipse log file. Note that in most cases you can use the - * {@link #log(String, Exception)} method which automatically detects the class and the method in which the - * exception was caught, so it requires as parameters only a human-readable message and the exception. + * Logs an exception to the Eclipse log file. + * + * Note that in most cases you can use the {@link #log(String, Exception)} method which automatically + * detects the class and the method in which the exception was caught, so it requires as parameters + * only a human-readable message and the exception. * * @param className the name of the class in which the exception was caught. * @param methodName the name of the method in which the exception was caught. @@ -166,15 +168,16 @@ public static void log(String className, String methodName, String message, Exce msg.append("\n!STARTING_TIME ").append(STARTING_TIME); msg.append("\n!CLASS_NAME ").append(className); msg.append("\n!FUNCTION_NAME ").append(methodName); - msg.append("\n!FAILURE_TIMESTAMP ").append(oDateFormatter.format(new Date())); + msg.append("\n!FAILURE_TIMESTAMP ").append(Activator.oDateFormatter.format(new Date())); errorID++; - if (plugin != null) + if (plugin != null) { plugin.getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.OK, msg.toString(), exception)); - else + } else { exception.printStackTrace(); + } } - - /** + + /** * A UTC ISO 8601 date formatter used to log the time of errors. */ private static final DateFormat oDateFormatter; @@ -182,7 +185,7 @@ public static void log(String className, String methodName, String message, Exce oDateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); oDateFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); } - + /** * Refreshes the debug trace sink when debug options have changed. */ @@ -191,60 +194,4 @@ public void optionsChanged(DebugOptions options) { DEBUG = options.getBooleanOption(PLUGIN_ID + "/debug", false); TRACE = options.newDebugTrace(PLUGIN_ID); } - class BuildDeltaVisitor implements IResourceDeltaVisitor { - - public boolean visit(IResourceDelta delta) throws CoreException { - switch (delta.getKind()) { - case IResourceDelta.REMOVED: - IResource res = delta.getResource(); - if(res instanceof IFolder) { - IProject project = ((IFolder)res).getProject(); - String resPath = res.getFullPath().toString(); - try { - String projectPath = project.getFullPath().toPortableString(); //path of the project containing resource - String modelsPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.MODELS_FOLDER)); - String outputPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER)); - String reqPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER)); - String comPath = project.getPersistentProperty(new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER)); - IPath newPath = delta.getMovedToPath(); //path of the new (renamed) project, or null - - if(resPath.equals(modelsPath)) - if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) //folder renamed - project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.MODELS_FOLDER), newPath.toPortableString()); - else //folder deleted - project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.MODELS_FOLDER), projectPath); - - else if(resPath.equals(outputPath)) - if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) - project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER), newPath.toPortableString()); - else - project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER), projectPath); - - else if(resPath.equals(reqPath)) - if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) - project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER), newPath.toPortableString()); - else - project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER), projectPath); - - else if(resPath.equals(comPath)) - if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) - project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER), newPath.toPortableString()); - else - project.setPersistentProperty(new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER), projectPath); - - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - System.out.println("detected!"); - - break; - case IResourceDelta.NO_CHANGE: - break; - } - - return true; - } - } } \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/BuildDeltaVisitor.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/BuildDeltaVisitor.java new file mode 100644 index 0000000..583450a --- /dev/null +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/BuildDeltaVisitor.java @@ -0,0 +1,160 @@ +package eu.scasefp7.eclipse.core.ui; + +import java.util.HashSet; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceDeltaVisitor; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; + +/** + * Visitor class used for checking whether a folder has been renamed or removed. + * + * @author themis + */ +public class BuildDeltaVisitor implements IResourceDeltaVisitor { + + /** + * Receives an {@code IResourceDelta} as a parameter and returns its kind as a string. This function is only used + * for debugging purposes. + * + * @param delta the {@code IResourceDelta} of a specific resource. + * @return the kind of delta. + */ + @SuppressWarnings("unused") + private String deltaToString(IResourceDelta delta) { + switch (delta.getKind()) { + case IResourceDelta.REMOVED: + return "REMOVED"; + case IResourceDelta.NO_CHANGE: + return "NO_CHANGE"; + case IResourceDelta.ADDED: + return "ADDED"; + case IResourceDelta.CHANGED: + return "CHANGED"; + case IResourceDelta.ADDED_PHANTOM: + return "ADDED_PHANTOM"; + case IResourceDelta.REMOVED_PHANTOM: + return "REMOVED_PHANTOM"; + case IResourceDelta.ALL_WITH_PHANTOMS: + return "ALL_WITH_PHANTOMS"; + case IResourceDelta.CONTENT: + return "CONTENT"; + case IResourceDelta.MOVED_FROM: + return "MOVED_FROM"; + case IResourceDelta.MOVED_TO: + return "MOVED_TO"; + case IResourceDelta.COPIED_FROM: + return "COPIED_FROM"; + case IResourceDelta.OPEN: + return "OPEN"; + case IResourceDelta.TYPE: + return "TYPE"; + case IResourceDelta.SYNC: + return "SYNC"; + case IResourceDelta.MARKERS: + return "MARKERS"; + case IResourceDelta.REPLACED: + return "REPLACED"; + case IResourceDelta.DESCRIPTION: + return "DESCRIPTION"; + case IResourceDelta.ENCODING: + return "ENCODING"; + case IResourceDelta.LOCAL_CHANGED: + return "LOCAL_CHANGED"; + case IResourceDelta.DERIVED_CHANGED: + return "DERIVED_CHANGED"; + default: + return "ERROR"; + } + } + + @Override + public boolean visit(IResourceDelta delta) throws CoreException { + IResource resource = delta.getResource(); + if (resource instanceof IProject) { + IProject project = (IProject) resource; + if (project.isOpen() && project.hasNature("eu.scasefp7.eclipse.core.scaseNature")) { + + // Set some variables + QualifiedName modelsFolder = new QualifiedName("", ScaseUiConstants.MODELS_FOLDER); + QualifiedName outputFolder = new QualifiedName("", ScaseUiConstants.OUTPUT_FOLDER); + QualifiedName requirementsFolder = new QualifiedName("", ScaseUiConstants.REQUIREMENTS_FOLDER); + QualifiedName compositionsFolder = new QualifiedName("", ScaseUiConstants.COMPOSITIONS_FOLDER); + String modelsPath = project.getPersistentProperty(modelsFolder); + String outputPath = project.getPersistentProperty(outputFolder); + String reqPath = project.getPersistentProperty(requirementsFolder); + String comPath = project.getPersistentProperty(compositionsFolder); + + // Check all possible cases + if (delta.getKind() == IResourceDelta.ADDED) { + // A new project was added + // Do nothing + } else if (delta.getKind() == IResourceDelta.REMOVED) { + // A project was removed + // Do nothing + } else if (delta.getKind() == IResourceDelta.CHANGED) { + // A child of a project has been added, removed, or renamed + IResourceDelta[] childrenDeltas = delta.getAffectedChildren(); + if (childrenDeltas != null && childrenDeltas.length > 0) { + // Get the folder(s) that have been changed and split them according to the typoe of change + HashSet addedFolders = new HashSet(); + HashSet removedFolders = new HashSet(); + HashSet changedFolders = new HashSet(); + for (IResourceDelta childDelta : childrenDeltas) { + IResource childResource = childDelta.getResource(); + if (childResource instanceof IFolder) { + if (childDelta.getKind() == IResourceDelta.ADDED) + addedFolders.add(childResource); + else if (childDelta.getKind() == IResourceDelta.REMOVED) + removedFolders.add(childResource); + else if (childDelta.getKind() == IResourceDelta.CHANGED) + changedFolders.add(childResource); + } + } + // If there are one removed folders and no added folders, then some folders have been deleted + if (removedFolders.size() > 0 && addedFolders.isEmpty()) { + for (IResource removedFolder : removedFolders) { + String removedFolderPath = removedFolder.getProjectRelativePath().toString(); + if (removedFolderPath.equals(modelsPath)) + project.setPersistentProperty(modelsFolder, ""); + else if (removedFolderPath.equals(outputPath)) + project.setPersistentProperty(outputFolder, ""); + else if (removedFolderPath.equals(reqPath)) + project.setPersistentProperty(requirementsFolder, ""); + else if (removedFolderPath.equals(comPath)) + project.setPersistentProperty(compositionsFolder, ""); + } + } + // If there is exactly one removed folder and one added folder, then a folder has been renamed + if (removedFolders.size() == 1 && addedFolders.size() == 1) { + IResource addedFolder = addedFolders.iterator().next(); + IResource removedFolder = removedFolders.iterator().next(); + String removedFolderPath = removedFolder.getProjectRelativePath().toString(); + String addedFolderPath = addedFolder.getProjectRelativePath().toString(); + if (removedFolderPath.equals(modelsPath)) + project.setPersistentProperty(modelsFolder, addedFolderPath); + else if (removedFolderPath.equals(outputPath)) + project.setPersistentProperty(outputFolder, addedFolderPath); + else if (removedFolderPath.equals(reqPath)) + project.setPersistentProperty(requirementsFolder, addedFolderPath); + else if (removedFolderPath.equals(comPath)) + project.setPersistentProperty(compositionsFolder, addedFolderPath); + } + + // For changed folders it means that a resource inside a folder has been added/deleted/changed + // So we do nothing + + // Return false to avoid visiting deeper deltas + return false; + } + } + } + } + return true; + } + +} \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/SCaseButtonRenderer.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/SCaseButtonRenderer.java deleted file mode 100644 index 51544f0..0000000 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/SCaseButtonRenderer.java +++ /dev/null @@ -1,44 +0,0 @@ -package eu.scasefp7.eclipse.core.ui.views; - - -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Display; -import org.mihalis.opal.obutton.AbstractButtonRenderer; -import org.mihalis.opal.utils.SWTGraphicUtil; - -public class SCaseButtonRenderer - extends AbstractButtonRenderer -{ - private static SCaseButtonRenderer instance; - private static final Color FIRST_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(80, 184, 170); - private static final Color SECOND_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(115, 220, 215); - - protected Color getFontColor() - { - return Display.getDefault().getSystemColor(1); - } - - protected Color getFirstBackgroundColor() - { - return FIRST_BACKGROUND_COLOR; - } - - protected Color getSecondBackgroundColor() - { - return SECOND_BACKGROUND_COLOR; - } - - public static SCaseButtonRenderer getInstance() - { - if (instance == null) { - instance = new SCaseButtonRenderer(); - } - return instance; - } -} - -/* Location: C:\scaseWorkspace\Opal - * Qualified Name: org.mihalis.opal.obutton.GreenButtonRenderer - * Java Class Version: 6 (50.0) - * JD-Core Version: 0.7.1 - */ \ No newline at end of file diff --git a/target-platform/target-platform.target b/target-platform/target-platform.target index e1ffdc0..e5bbba2 100644 --- a/target-platform/target-platform.target +++ b/target-platform/target-platform.target @@ -1,19 +1,37 @@ - + - + + + + + + + + + + + + + + + + + + - + - - - + + + + - + From 6ca8e181801a2bb1b311d719d50ca7202e3697e7 Mon Sep 17 00:00:00 2001 From: eleogas Date: Mon, 30 May 2016 15:11:17 +0200 Subject: [PATCH 28/29] Modified dashboard extension --- .../intropagecontent/introContent.xml | 2 +- eu.scasefp7.eclipse.core.ui/plugin.xml | 215 +++++---- .../eclipse/core/ui/views/Dashboard.java | 72 ++- eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF | 1 + eu.scasefp7.eclipse.core/plugin.xml | 1 + ....scasefp7.eclipse.core.dashboardItem2.exsd | 449 ++++++++++-------- 6 files changed, 434 insertions(+), 306 deletions(-) rename eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.dashboardItem.exsd => eu.scasefp7.eclipse.core/schema/eu.scasefp7.eclipse.core.dashboardItem2.exsd (79%) diff --git a/eu.scasefp7.eclipse.core.ui/intropagecontent/introContent.xml b/eu.scasefp7.eclipse.core.ui/intropagecontent/introContent.xml index 16d8690..e150912 100644 --- a/eu.scasefp7.eclipse.core.ui/intropagecontent/introContent.xml +++ b/eu.scasefp7.eclipse.core.ui/intropagecontent/introContent.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/eu.scasefp7.eclipse.core.ui/plugin.xml b/eu.scasefp7.eclipse.core.ui/plugin.xml index 8f46850..f0fb567 100644 --- a/eu.scasefp7.eclipse.core.ui/plugin.xml +++ b/eu.scasefp7.eclipse.core.ui/plugin.xml @@ -1,7 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -816,4 +725,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java index 33c6221..5c9c65e 100644 --- a/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java +++ b/eu.scasefp7.eclipse.core.ui/src/eu/scasefp7/eclipse/core/ui/views/Dashboard.java @@ -15,10 +15,12 @@ */ package eu.scasefp7.eclipse.core.ui.views; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.eclipse.core.commands.Command; import org.eclipse.core.commands.CommandEvent; @@ -123,11 +125,35 @@ public class Dashboard extends ViewPart implements ISelectionListener, IRegistry */ private ISelection currentSelection; + /** + * Name of the group and group of buttons + */ + private HashMap groups = new HashMap(); + + /** + * Button ID and buttons + */ + private HashMap buttons = new HashMap(); + + /** + * First button is above the button with given string ID + */ + private List> ordering = new ArrayList>(); + + /** + * New extension for dashboard + * TODO: change the current one in ScaseUiConstants.DASHBOARD_EXTENSION to this one + */ + private final String DASHBOARD_EXTENSION = "eu.scasefp7.eclipse.core.dashboardItem2"; + + private Composite _parent; + /** * The constructor. */ public Dashboard() { - RegistryFactory.getRegistry().addListener(this, ScaseUiConstants.DASHBOARD_EXTENSION); + //RegistryFactory.getRegistry().addListener(this, ScaseUiConstants.DASHBOARD_EXTENSION); + RegistryFactory.getRegistry().addListener(this, DASHBOARD_EXTENSION); } @Override @@ -162,8 +188,8 @@ public void createPartControl(Composite parent) { // Read the configuration of the dashboard IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] contributions = registry.getConfigurationElementsFor(ScaseUiConstants.DASHBOARD_EXTENSION); - + //IConfigurationElement[] contributions = registry.getConfigurationElementsFor(ScaseUiConstants.DASHBOARD_EXTENSION); + IConfigurationElement[] contributions = registry.getConfigurationElementsFor(DASHBOARD_EXTENSION); // Create the configured items for (IConfigurationElement elem : contributions) { if(elem.getName().equals(CONTRIBUTION_GROUP)) { @@ -173,7 +199,15 @@ public void createPartControl(Composite parent) { handleButton(parent, elem); } } - + if(!ordering.isEmpty()){ + for(Entry e : ordering){ + String id = e.getValue(); + Button first = e.getKey(); + Button second = buttons.get(id);; + first.moveAbove(second); + } + } + parent.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { @@ -181,6 +215,7 @@ public void controlResized(ControlEvent e) { } }); + _parent = parent; // Project setup /*int startR = 95, @@ -286,7 +321,7 @@ private void fillLocalToolBar(IToolBarManager manager) { */ private void handleGroup(Composite parent, IConfigurationElement elem) throws InvalidRegistryObjectException { Group group = createGroup(parent, elem.getAttribute(CONTRIBUTION_GROUP_NAME)); - + groups.put(elem.getAttribute(CONTRIBUTION_GROUP_NAME), group); for (IConfigurationElement child : elem.getChildren()) { if(child.getName().equals(CONTRIBUTION_GROUP)) { handleGroup(group, child); @@ -308,12 +343,21 @@ private void handleButton(Composite parent, IConfigurationElement elem) throws I String name = elem.getAttribute(CONTRIBUTION_COMMAND_LABEL); String tooltip = elem.getAttribute(CONTRIBUTION_COMMAND_TOOLTIP); + String groupName = elem.getAttribute("groupName"); + + if(groupName!=null && groupName!="") + parent = groups.get(groupName); + + String appearsBefore = elem.getAttribute("appearsBefore"); + String buttonId = elem.getAttribute("buttonId"); + final String commandId = elem.getAttribute(CONTRIBUTION_COMMAND_ID); final String notificationSuccess = elem.getAttribute(CONTRIBUTION_COMMAND_NOTIFICATION_SUCCESS); final String notificationFail = elem.getAttribute(CONTRIBUTION_COMMAND_NOTIFICATION_FAIL); - + Button btn = new Button(parent, SWT.NONE); + if(name != null) { btn.setText(name); } @@ -364,6 +408,14 @@ public void mouseDown(MouseEvent e) { }); } } + + buttons.put(buttonId, btn); + + if(appearsBefore!= null && appearsBefore != ""){ + Entry entry = + new AbstractMap.SimpleEntry(btn, appearsBefore); + ordering.add(entry); + } } /** @@ -643,25 +695,25 @@ private static int getProjectDomainId(IProject project) { @Override public void added(IExtension[] extensions) { - // TODO Auto-generated method stub + _parent.update(); } @Override public void removed(IExtension[] extensions) { - // TODO Auto-generated method stub + _parent.update(); } @Override public void added(IExtensionPoint[] extensionPoints) { - // TODO Auto-generated method stub + _parent.update(); } @Override public void removed(IExtensionPoint[] extensionPoints) { - // TODO Auto-generated method stub + _parent.update(); } diff --git a/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF b/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF index ad3e71b..6f6ada2 100644 --- a/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF +++ b/eu.scasefp7.eclipse.core/META-INF/MANIFEST.MF @@ -23,5 +23,6 @@ Import-Package: com.hp.hpl.jena.ontology;version="[2.13.0,3.0.0)", com.hp.hpl.jena.util;version="[2.13.0,3.0.0)", com.hp.hpl.jena.util.iterator;version="[2.13.0,3.0.0)", org.apache.log4j, + org.eclipse.emf.ecore, org.slf4j, org.yaml.snakeyaml;version="1.16.0" diff --git a/eu.scasefp7.eclipse.core/plugin.xml b/eu.scasefp7.eclipse.core/plugin.xml index ff17dcc..66d0c52 100644 --- a/eu.scasefp7.eclipse.core/plugin.xml +++ b/eu.scasefp7.eclipse.core/plugin.xml @@ -2,6 +2,7 @@ + diff --git a/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.dashboardItem.exsd b/eu.scasefp7.eclipse.core/schema/eu.scasefp7.eclipse.core.dashboardItem2.exsd similarity index 79% rename from eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.dashboardItem.exsd rename to eu.scasefp7.eclipse.core/schema/eu.scasefp7.eclipse.core.dashboardItem2.exsd index f845482..4c81b11 100644 --- a/eu.scasefp7.eclipse.core.ui/schema/eu.scasefp7.eclipse.core.ui.dashboardItem.exsd +++ b/eu.scasefp7.eclipse.core/schema/eu.scasefp7.eclipse.core.dashboardItem2.exsd @@ -1,203 +1,246 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The label to be displayed for this element. This value should be translatable. - - - - - - - - - - This is the id of the Command that is to be bound to this element. This is the hook into the Commands/Handlers/Key binding services that actually do the work should this item be selected. In many cases this command will have been defined in a previous extension declaration. - - - - - - - - - - The tooltip to be displayed for this element when it is placed in a toolbar. This value should be translatable. - - - - - - - - - - Notification text to display to user in a popup if the command succeeds. - - - - - - - - - - Notification text to display to user in a popup if the command fails. - - - - - - - - - - - - - A parameter to either an executable extension or a command -- depending on where it appears in the extension. - - - - - - - The name is either the name of the parameter to pass to the executable extension, or the identifier of the parameter for the command. - - - - - - - - - - The value to pass for this parameter. - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The label to be displayed for this element. This value should be translatable. + + + + + + + + + + This is the id of the Command that is to be bound to this element. This is the hook into the Commands/Handlers/Key binding services that actually do the work should this item be selected. In many cases this command will have been defined in a previous extension declaration. + + + + + + + + + + + + + + + + + + + + The tooltip to be displayed for this element when it is placed in a toolbar. This value should be translatable. + + + + + + + + + + Notification text to display to user in a popup if the command succeeds. + + + + + + + + + + Notification text to display to user in a popup if the command fails. + + + + + + + + + + Id of the group the button belongs to + + + + + + + + + + The button will be before the button with specified id + + + + + + + + + + + + + A parameter to either an executable extension or a command -- depending on where it appears in the extension. + + + + + + + The name is either the name of the parameter to pass to the executable extension, or the identifier of the parameter for the command. + + + + + + + + + + The value to pass for this parameter. + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + From f9dbb60193b1763ba48c66f123c5ea27228f732d Mon Sep 17 00:00:00 2001 From: eleogas Date: Tue, 31 May 2016 14:03:24 +0200 Subject: [PATCH 29/29] Builder - condition for folders --- eu.scasefp7.eclipse.core/plugin.xml | 1 + .../eu.scasefp7.eclipse.core.builder.exsd | 19 ++++++++ .../core/builder/ScaseProjectBuilder.java | 48 +++++++++++++++---- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/eu.scasefp7.eclipse.core/plugin.xml b/eu.scasefp7.eclipse.core/plugin.xml index 66d0c52..e090f82 100644 --- a/eu.scasefp7.eclipse.core/plugin.xml +++ b/eu.scasefp7.eclipse.core/plugin.xml @@ -119,6 +119,7 @@ + + + + + + + + + + + + + + + + + + + diff --git a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/builder/ScaseProjectBuilder.java b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/builder/ScaseProjectBuilder.java index 3993cd6..a4ea254 100644 --- a/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/builder/ScaseProjectBuilder.java +++ b/eu.scasefp7.eclipse.core/src/eu/scasefp7/eclipse/core/builder/ScaseProjectBuilder.java @@ -31,6 +31,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IRegistryEventListener; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.variables.IDynamicVariable; import org.eclipse.core.variables.IDynamicVariableResolver; import org.eclipse.core.variables.IStringVariable; @@ -67,6 +68,8 @@ public class ScaseProjectBuilder extends IncrementalProjectBuilder implements IS private static final String CONTRIBUTION_VARIABLE = "variable"; private static final String CONTRIBUTION_PREFERENCE = "preference"; + private Map projectFolders = new HashMap(); + class BuildDeltaVisitor implements IResourceDeltaVisitor { @@ -83,6 +86,14 @@ public boolean visit(IResourceDelta delta) throws CoreException { if (elem.getName().equals("buildStep")) { String commandId = elem.getAttribute("commandId"); String regex = elem.getAttribute("condition"); + String inFolder = elem.getAttribute("inFolder"); + String folderCondition = ""; + + if(inFolder != null && inFolder != "") { + String property = projectFolders.get(inFolder); + IProject project = ((IFile)resource).getProject(); + folderCondition = project.getPersistentProperty(new QualifiedName("", property)); + } IConfigurationElement[] elements = elem.getChildren("commandParameters"); boolean hasParameters = elements.length > 0; @@ -91,13 +102,15 @@ public boolean visit(IResourceDelta delta) throws CoreException { if(hasParameters) getParameters(resource, parameters, elements[0]); - if(resource.getName().matches(regex)) { - if(!hasParameters) - executeCommand(commandId, resource.getFullPath().toString()); - else - executeCommand(commandId, resource.getFullPath().toString(), parameters); - System.out.println("Command: " + commandId+" on file: "+resource.getFullPath().toString()+" (d)"); - } + if ((folderCondition == "" || resource.getFullPath().toString().contains(folderCondition)) + && resource.getName().matches(regex)) { + if (!hasParameters) + executeCommand(commandId, resource.getFullPath().toString()); + else + executeCommand(commandId, resource.getFullPath().toString(), parameters); + System.out.println("Command: " + commandId + " on file: " + + resource.getFullPath().toString() + " (d)"); + } } } @@ -122,6 +135,19 @@ public boolean visit(IResource resource) { if (elem.getName().equals("buildStep")) { String commandId = elem.getAttribute("commandId"); String regex = elem.getAttribute("condition"); + String inFolder = elem.getAttribute("inFolder"); + String folderCondition = ""; + + if(inFolder != null && inFolder != "") { + String property = projectFolders.get(inFolder); + IProject project = ((IFile)resource).getProject(); + try { + folderCondition = project.getPersistentProperty(new QualifiedName("", property)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } IConfigurationElement[] elements = elem.getChildren("commandParameters"); boolean hasParameters = elements.length > 0; HashMap parameters = new HashMap(); @@ -129,7 +155,8 @@ public boolean visit(IResource resource) { if(hasParameters) getParameters(resource, parameters, elements[0]); - if(resource.getName().matches(regex)) { + if((folderCondition == "" || resource.getFullPath().toString().contains(folderCondition)) + && resource.getName().matches(regex)) { if(!hasParameters) executeCommand(commandId, resource.getFullPath().toString()); else @@ -311,6 +338,11 @@ protected void executeCommand(String commandId, String name, HashMap