Skip to content

Commit 791f814

Browse files
committed
ST6RI-682 Updates Eclipse UI contributions
- Introduces a new SysMLv2 menu for all contributions - Renames repository upload feature - Command framework should check for the existence of repository descriptor for showing the command
1 parent 60a04a7 commit 791f814

4 files changed

Lines changed: 91 additions & 19 deletions

File tree

org.omg.sysml.xtext.ui/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Require-Bundle: org.omg.sysml;bundle-version="0.2.0",
2323
org.omg.kerml.expressions.xtext.ide,
2424
org.omg.kerml.expressions.xtext.ui,
2525
com.google.gson,
26-
org.eclipse.emf.ecore.editor
26+
org.eclipse.emf.ecore.editor,
27+
org.eclipse.core.expressions
2728
Import-Package: org.apache.log4j
2829
Export-Package: org.omg.sysml.xtext.ui,
2930
org.omg.sysml.xtext.ui.internal

org.omg.sysml.xtext.ui/plugin.xml

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
</command>
159159
<command
160160
id="org.omg.sysml.xtext.ui.PullRepositoryProject"
161-
name="Pull remote">
161+
name="Pull Model from API">
162162
</command>
163163
</extension>
164164
<extension point="org.eclipse.ui.menus">
@@ -355,10 +355,29 @@
355355
<menuContribution
356356
allPopups="false"
357357
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
358-
<command
359-
commandId="org.omg.sysml.xtext.ui.GenerateLibraryIndex"
360-
label="Generate Library Index"
361-
style="push">
358+
<menu
359+
label="SysMLv2">
360+
<command
361+
commandId="org.omg.sysml.xtext.ui.PullRepositoryProject"
362+
label="Pull Model from API"
363+
style="push">
364+
<visibleWhen
365+
checkEnabled="false">
366+
<iterate>
367+
<adapt
368+
type="org.eclipse.core.resources.IProject">
369+
<test
370+
property="org.omg.sysml.xtext.ui.repository_descriptor">
371+
</test>
372+
</adapt>
373+
</iterate>
374+
</visibleWhen>
375+
</command>
376+
<command
377+
commandId="org.omg.sysml.xtext.ui.GenerateLibraryIndex"
378+
label="Generate Library Index"
379+
style="push">
380+
</command>
362381
<visibleWhen
363382
checkEnabled="false">
364383
<and>
@@ -372,16 +391,7 @@
372391
</iterate>
373392
</and>
374393
</visibleWhen>
375-
</command>
376-
</menuContribution>
377-
<menuContribution
378-
allPopups="false"
379-
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
380-
<command
381-
commandId="org.omg.sysml.xtext.ui.PullRepositoryProject"
382-
label="Pull remote"
383-
style="push">
384-
</command>
394+
</menu>
385395
</menuContribution>
386396
</extension>
387397
<extension point="org.eclipse.compare.contentViewers">
@@ -421,4 +431,14 @@
421431
uriExtension="sysmlx">
422432
</resourceServiceProvider>
423433
</extension>
434+
<extension
435+
point="org.eclipse.core.expressions.propertyTesters">
436+
<propertyTester
437+
class="org.omg.sysml.xtext.ui.utilities.RemoteRepositoryPropertyTester"
438+
id="org.omg.sysml.xtext.ui.remoterepositoryproperties"
439+
namespace="org.omg.sysml.xtext.ui"
440+
properties="repository_descriptor"
441+
type="org.eclipse.core.resources.IProject">
442+
</propertyTester>
443+
</extension>
424444
</plugin>

org.omg.sysml.xtext.ui/src/org/omg/sysml/xtext/ui/handlers/PullRepositoryProject.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public class PullRepositoryProject extends AbstractHandler {
6060

6161
private static final Set<String> FILE_EXTENSIONS = Set.of("sysml", "kerml", "sysmlx", "kermlx");
6262

63+
public static final String REPOSITORY_CONFIGURATION_FILE = ".settings/org.omg.sysml.remote.properties";
64+
private static final String REPOSITORY_PROJECT_ID_PROPERTY = "remote.projectId";
65+
private static final String REPOSITORY_BASE_URL_PROPERTY = "base.url";
66+
6367
@Inject
6468
private IResourceSetProvider resourceSetProvider;
6569

@@ -102,12 +106,12 @@ private void tryPullRemoteFor(IProject project, IProgressMonitor monitor) {
102106

103107
if (libraryProject.isPresent()) {
104108
Properties properties = new Properties();
105-
IFile repositoryPropertiesFile = project.getFile(".settings/org.omg.sysml.remote.properties");
109+
IFile repositoryPropertiesFile = project.getFile(REPOSITORY_CONFIGURATION_FILE);
106110

107111
properties.load(repositoryPropertiesFile.getContents());
108112

109-
String repositoryUrl = properties.getProperty("base.url");
110-
String projectName = properties.getProperty("remote.projectId");
113+
String repositoryUrl = properties.getProperty(REPOSITORY_BASE_URL_PROPERTY);
114+
String projectName = properties.getProperty(REPOSITORY_PROJECT_ID_PROPERTY);
111115
String targetPath = project.getFullPath().toString();
112116

113117
Set<IFile> libraryResources = new HashSet<>();
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* SysML 2 Pilot Implementation
3+
* Copyright (C) 2025 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
* Contributors:
21+
* Laszlo Gati, MDS
22+
* Zoltan Ujhelyi, MDS
23+
*/
24+
package org.omg.sysml.xtext.ui.utilities;
25+
26+
import java.util.Objects;
27+
28+
import org.eclipse.core.expressions.PropertyTester;
29+
import org.eclipse.core.resources.IProject;
30+
import org.omg.sysml.xtext.ui.handlers.PullRepositoryProject;
31+
32+
public class RemoteRepositoryPropertyTester extends PropertyTester {
33+
34+
private static final String REPOSITORY_DESCRIPTOR_TESTER = "repository_descriptor";
35+
36+
public RemoteRepositoryPropertyTester() {
37+
}
38+
39+
@Override
40+
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
41+
if (Objects.equals(REPOSITORY_DESCRIPTOR_TESTER, REPOSITORY_DESCRIPTOR_TESTER) && receiver instanceof IProject project && project.isAccessible()) {
42+
return project.getFile(PullRepositoryProject.REPOSITORY_CONFIGURATION_FILE).exists();
43+
}
44+
return false;
45+
}
46+
47+
}

0 commit comments

Comments
 (0)