diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/.ratings b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/.ratings deleted file mode 100644 index 40dcb92327fab72cb3e5347977de8809b455b912..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/.ratings +++ /dev/null @@ -1,11 +0,0 @@ -LoadACCExampleAction.java fd88330c3685e1b0aea6efab9231ecc122e0d932 GREEN -LoadECarExampleAction.java 3b6bdac54a65878a58a6443616403ea8fa3bd702 GREEN -LoadEmergencyStopExampleAction.java 181729c59bcb64d5fa3790482613b3cfc1a10522 GREEN -LoadEmergencyStopWeaklyCausalExampleAction.java 5ceb5396ecf202312956158c6bef06f383a05402 GREEN -LoadExampleActionBase.java e96dab785e50a85e5f7ca00fc4e16c85b8ecea3b GREEN -LoadMotorManagementExampleAction.java 6ff16ff5ae315aa0b777448ffb69a0471f0b7e04 GREEN -LoadOperatorPanelExampleAction.java f77d32db422df0a9d913ad09f537ca8a99ee4cef GREEN -LoadSimpleTrafficLightsAF3TourExampleAction.java 849f1009f041a2edbdbc03db8e8db5e2f2eb9963 GREEN -LoadSimpleTrafficLightsCodeGenerationExampleAction.java 36e9f1ed5f035c336efe01a60809867abe77c339 GREEN -LoadSimpleTrafficLightsExampleAction.java 8f7461217a7030cf32cf575472a150593c73575d GREEN -LoadSimpleTrafficLightsModesExampleAction.java 28760780aa3112e3dba39da5a618f66ee0baad1a GREEN diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadACCExampleAction.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadACCExampleAction.java deleted file mode 100644 index fd88330c3685e1b0aea6efab9231ecc122e0d932..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadACCExampleAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import org.fortiss.af3.rcp.application.AF3ApplicationActivator; - -/** - * Action to load the initial ACC example. - * - * @author wenwenchen - */ -public class LoadACCExampleAction extends LoadExampleActionBase { - - /** {@inheritDoc} */ - @Override - protected void loadExample(String suffix) { - - loadExistingModel(AF3ApplicationActivator.PLUGIN_ID, "test-data/ACC.af3_23", "ACC", suffix); - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadECarExampleAction.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadECarExampleAction.java deleted file mode 100644 index 3b6bdac54a65878a58a6443616403ea8fa3bd702..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadECarExampleAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import org.fortiss.af3.rcp.application.AF3ApplicationActivator; - -/** - * Action to load the eCar example. - * - * @author wenwenchen - */ -public class LoadECarExampleAction extends LoadExampleActionBase { - - /** {@inheritDoc} */ - @Override - protected void loadExample(String suffix) { - loadExistingModel(AF3ApplicationActivator.PLUGIN_ID, "test-data/eCar.af3_23", "eCar", - suffix); - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadEmergencyStopExampleAction.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadEmergencyStopExampleAction.java deleted file mode 100644 index 181729c59bcb64d5fa3790482613b3cfc1a10522..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadEmergencyStopExampleAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import org.fortiss.af3.rcp.application.AF3ApplicationActivator; - -/** - * Action to load the initial version of the emergency stop module example. - * - * @author wenwenchen - */ -public class LoadEmergencyStopExampleAction extends LoadExampleActionBase { - - /** {@inheritDoc} */ - @Override - protected void loadExample(String suffix) { - loadExistingModel(AF3ApplicationActivator.PLUGIN_ID, - "test-data/Emergency-Stop-Module.af3_23", "Emergency-Stop-Module", suffix); - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadEmergencyStopWeaklyCausalExampleAction.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadEmergencyStopWeaklyCausalExampleAction.java deleted file mode 100644 index 5ceb5396ecf202312956158c6bef06f383a05402..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadEmergencyStopWeaklyCausalExampleAction.java +++ /dev/null @@ -1,34 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import org.fortiss.af3.rcp.application.AF3ApplicationActivator; - -/** - * Action to load the weakly causal version of the emergency stop module example. - * - * @author wenwenchen - */ -public class LoadEmergencyStopWeaklyCausalExampleAction extends LoadExampleActionBase { - - /** {@inheritDoc} */ - @Override - protected void loadExample(String suffix) { - loadExistingModel(AF3ApplicationActivator.PLUGIN_ID, - "test-data/Emergency-Stop-Module-Weakly-Causal.af3_23", - "Emergency-Stop-Module-Weakly-Causal", suffix); - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadExampleActionBase.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadExampleActionBase.java deleted file mode 100644 index e96dab785e50a85e5f7ca00fc4e16c85b8ecea3b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadExampleActionBase.java +++ /dev/null @@ -1,105 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import static org.fortiss.af3.project.storage.LocationProvider.CURRENT_AF3_PROJECT_FILES_EXTENSION; -import static org.fortiss.af3.project.ui.utils.NewProjectUtils.createNewGeneralProject; -import static org.fortiss.af3.project.ui.utils.NewProjectUtils.generalProjectExists; -import static org.fortiss.af3.rcp.application.utils.ApplicationUtils.refreshWorkspace; -import static org.fortiss.af3.rcp.application.utils.ApplicationUtils.saveProject; - -import java.util.Properties; - -import org.eclipse.core.resources.IFile; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.intro.IIntroPart; -import org.eclipse.ui.intro.IIntroSite; -import org.eclipse.ui.intro.config.IIntroAction; -import org.fortiss.af3.project.model.FileProject; -import org.fortiss.af3.project.utils.ProjectUtils; -import org.fortiss.af3.rcp.application.utils.ApplicationUtils; - -/** - * Base class for loading standard examples. - * - * @author wenwenchen - */ -public abstract class LoadExampleActionBase implements IIntroAction { - - /** The current AF3 model file extension. */ - private static final String CURRENT_AF3_FILE_EXTENSION = - "." + CURRENT_AF3_PROJECT_FILES_EXTENSION; - - /** {@inheritDoc} */ - @Override - public void run(IIntroSite site, Properties params) { - final IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro(); - PlatformUI.getWorkbench().getIntroManager().setIntroStandby(introPart, true); - - startup(); - - loadExample(CURRENT_AF3_FILE_EXTENSION); - } - - /** - * Method that is used by multiple command handlers to ensure that the - * Project exists that contains the *.af3_2x files and that the - * AF3-Perspective is activated. - */ - private void startup() { - // start up - if(!generalProjectExists()) { - // Create a generic project. - createNewGeneralProject(); - } - // Enable the AF3 Perspective. - ApplicationUtils.switchToAF3Perspective(); - } - - /** load example according to example name */ - protected abstract void loadExample(String suffix); - - /** - * Loads an existing *.af3_2x Example file from a given path and adds it to - * the Model-Navigator. - * - * @param pluginID - * the plugin ID - * @param relativePath - * the relative path to the file - * @param projectName - * the name of the file - * @param suffix - * the suffix of the file - */ - protected synchronized static void loadExistingModel(String pluginID, String relativePath, - String projectName, String suffix) { - - // Load file of the Example (do not create dummy, because - // otherwise the Example is shown twice). - FileProject project = ProjectUtils.loadProjectFromPlugin(pluginID, relativePath, false); - - // Check if file name not already exists. - IFile targetProjectFile = ApplicationUtils.validateProjectName(projectName, suffix); - - if(targetProjectFile != null) { - project.setName(targetProjectFile.getName().replace(suffix, "")); - // Save the project to workspace. - saveProject(project, targetProjectFile.getFullPath().toString()); - refreshWorkspace(); - } - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadMotorManagementExampleAction.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadMotorManagementExampleAction.java deleted file mode 100644 index 6ff16ff5ae315aa0b777448ffb69a0471f0b7e04..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadMotorManagementExampleAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import org.fortiss.af3.mode.AF3ModeActivator; - -/** - * Action to load the motor management example. - * - * @author wenwenchen - */ -public class LoadMotorManagementExampleAction extends LoadExampleActionBase { - - /** {@inheritDoc} */ - @Override - protected void loadExample(String suffix) { - loadExistingModel(AF3ModeActivator.PLUGIN_ID, "test-data/MotorManagement.af3_23", - "MotorManagement", suffix); - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadOperatorPanelExampleAction.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadOperatorPanelExampleAction.java deleted file mode 100644 index f77d32db422df0a9d913ad09f537ca8a99ee4cef..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadOperatorPanelExampleAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import org.fortiss.af3.rcp.application.AF3ApplicationActivator; - -/** - * Action to load the OperatorPanel example. - * - * @author wenwenchen - */ -public class LoadOperatorPanelExampleAction extends LoadExampleActionBase { - - /** {@inheritDoc} */ - @Override - protected void loadExample(String suffix) { - loadExistingModel(AF3ApplicationActivator.PLUGIN_ID, - "test-data/operator_panel_tutorial.af3_23", "OperatorPanel", suffix); - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsAF3TourExampleAction.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsAF3TourExampleAction.java deleted file mode 100644 index 849f1009f041a2edbdbc03db8e8db5e2f2eb9963..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsAF3TourExampleAction.java +++ /dev/null @@ -1,34 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import org.fortiss.af3.rcp.application.AF3ApplicationActivator; - -/** - * Action to load the SimpleTrafficLights_AF3Tour example. - * - * @author wenwenchen - */ -public class LoadSimpleTrafficLightsAF3TourExampleAction extends LoadExampleActionBase { - - /** {@inheritDoc} */ - @Override - protected void loadExample(String suffix) { - loadExistingModel(AF3ApplicationActivator.PLUGIN_ID, - "test-data/SimpleTrafficLights_AF3Tour.af3_23", "SimpleTrafficLights_AF3Tour", - suffix); - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsCodeGenerationExampleAction.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsCodeGenerationExampleAction.java deleted file mode 100644 index 36e9f1ed5f035c336efe01a60809867abe77c339..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsCodeGenerationExampleAction.java +++ /dev/null @@ -1,34 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import org.fortiss.af3.rcp.application.example.SimpleTrafficLightsCodeGenerationExample; -import org.fortiss.af3.rcp.application.utils.ApplicationUtils; - -/** - * Action to load the TLC example for code generation example. - * - * @author wenwenchen - */ -public class LoadSimpleTrafficLightsCodeGenerationExampleAction extends LoadExampleActionBase { - - /** {@inheritDoc} */ - @Override - protected void loadExample(String suffix) { - ApplicationUtils.createAndSaveProject("SimpleTrafficLightsCodeGenerationExample", suffix, - SimpleTrafficLightsCodeGenerationExample.INSTANCE); - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsExampleAction.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsExampleAction.java deleted file mode 100644 index 8f7461217a7030cf32cf575472a150593c73575d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsExampleAction.java +++ /dev/null @@ -1,34 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import org.fortiss.af3.rcp.application.AF3ApplicationActivator; - -/** - * Action to load the basic TLC example. - * - * @author wenwenchen - */ -public class LoadSimpleTrafficLightsExampleAction extends LoadExampleActionBase { - - /** {@inheritDoc} */ - @Override - protected void loadExample(String suffix) { - loadExistingModel(AF3ApplicationActivator.PLUGIN_ID, - "test-data/SimpleTrafficLightsExample.af3_23", "SimpleTrafficLightsExample", - suffix); - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsModesExampleAction.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsModesExampleAction.java deleted file mode 100644 index 28760780aa3112e3dba39da5a618f66ee0baad1a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/actions/LoadSimpleTrafficLightsModesExampleAction.java +++ /dev/null @@ -1,35 +0,0 @@ -/*-------------------------------------------------------------------------+ -| Copyright 2013 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.rcp.application.actions; - -import static org.fortiss.af3.rcp.application.utils.ApplicationUtils.createAndSaveProject; - -import org.fortiss.af3.mode.ui.examples.SimpleTrafficLightsModesExample; - -/** - * Action to load the TLC with modes example. - * - * @author wenwenchen - */ -public class LoadSimpleTrafficLightsModesExampleAction extends LoadExampleActionBase { - - /** {@inheritDoc} */ - @Override - protected void loadExample(String suffix) { - createAndSaveProject("SimpleTrafficLightsModesExample", suffix, - SimpleTrafficLightsModesExample.INSTANCE); - } -} diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/.ratings b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/.ratings index 35cead4142f4f593572f80d4ef53a36c09607892..dcc50030252b63a9c7fbebcc5e3113c0ff04e035 100644 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/.ratings +++ b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/.ratings @@ -1,3 +1,3 @@ -ApplicationActionBarAdvisor.java 3fe306058f621c9939d86984199522e47b3c1cbd GREEN -ApplicationWorkbenchAdvisor.java 5d1792809c752bedc08b6d9d993ecbf70b40982c GREEN +ApplicationActionBarAdvisor.java 881198ff05ab14110efef1673f0914725348442b GREEN +ApplicationWorkbenchAdvisor.java 587d7efc234d68e8bac6540c8cafabca113757d8 GREEN ApplicationWorkbenchWindowAdvisor.java da5cb38300b384579532c678fbc9faa961c2ca6b GREEN diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/ApplicationActionBarAdvisor.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/ApplicationActionBarAdvisor.java index 3fe306058f621c9939d86984199522e47b3c1cbd..881198ff05ab14110efef1673f0914725348442b 100644 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/ApplicationActionBarAdvisor.java +++ b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/ApplicationActionBarAdvisor.java @@ -16,19 +16,12 @@ package org.fortiss.af3.rcp.application.advisors; -import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX; import static org.eclipse.wb.swt.ResourceManager.getPluginImageDescriptor; import static org.fortiss.tooling.kernel.ui.util.TutorialUIServiceUtils.createTutorialMenu; -import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Map; import org.eclipse.core.commands.IHandler; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Platform; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.ICoolBarManager; import org.eclipse.jface.action.IMenuManager; @@ -37,18 +30,13 @@ import org.eclipse.jface.action.Separator; import org.eclipse.jface.action.ToolBarManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkbenchCommandConstants; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; import org.eclipse.ui.application.ActionBarAdvisor; import org.eclipse.ui.application.IActionBarConfigurer; -import org.eclipse.ui.browser.IWebBrowser; import org.eclipse.ui.internal.actions.CommandAction; -import org.eclipse.ui.internal.actions.HelpContentsAction; import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; -import org.fortiss.af3.rcp.help.AF3HelpActivator; /** * Action bar advisor for AF3 RCP. @@ -331,70 +319,13 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { * Registers the "AF3 Help" action and attaches it to the corresponding button. */ private void registerHelpContentsAction(IWorkbenchWindow window) { - if(IS_OS_LINUX) { - // Closing the help browser freezes the application. - // See https://af3-developer.fortiss.org/issues/3989 - // Note: eclipse upstream issues exist with firefox: - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=187332 - helpContentsAction = createHelpInBrowserAction(window).create(window); - } else { - helpContentsAction = ActionFactory.HELP_CONTENTS.create(window); - } + helpContentsAction = ActionFactory.HELP_CONTENTS.create(window); helpContentsAction.setId("helpContentsAction"); helpContentsAction.setToolTipText("AF3 Help"); helpContentsAction.setText("AF3 &Help"); register(helpContentsAction); } - /** Creates an action that launches the external browser to display the help pages. */ - private ActionFactory createHelpInBrowserAction(IWorkbenchWindow window) { - if(window == null) { - throw new IllegalArgumentException(); - } - - // A non-anonymous class would just increase the code size. - @SuppressWarnings("restriction") IWorkbenchAction openExtHelpAction = - new HelpContentsAction(window) { - @Override - public void run() { - - String errMsg = null; - try { - URL helpPluginURL = FileLocator.toFileURL( - Platform.getBundle(AF3HelpActivator.PLUGIN_ID).getEntry("/")); - URL helpIndexURL = new URL("file:/" + helpPluginURL.getPath() + - "html/getting_started.html"); - - final IWebBrowser browser = window.getWorkbench().getBrowserSupport() - .createBrowser("dummyID"); - browser.openURL(helpIndexURL); - } catch(PartInitException e) { - errMsg = "Could not open browser.\n\n" + e.getLocalizedMessage(); - } catch(MalformedURLException e) { - errMsg = "URL to user documentation is not correct.\n\n" + - e.getLocalizedMessage(); - } catch(IOException e) { - errMsg = "I/O error: Could not access the user documentation.\n\n" + - e.getLocalizedMessage(); - } finally { - if(errMsg != null) { - showError(errMsg); - } - } - } - }; - - return new ActionFactory("helpContents", //$NON-NLS-1$ - IWorkbenchCommandConstants.HELP_HELP_CONTENTS) { - @Override - public IWorkbenchAction create(IWorkbenchWindow window) { - IWorkbenchAction action = openExtHelpAction; - action.setId(getId()); - return action; - } - }; - } - /** * Registers the "New AF3 Project" action and attaches it to the corresponding button. */ diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/ApplicationWorkbenchAdvisor.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/ApplicationWorkbenchAdvisor.java index 5d1792809c752bedc08b6d9d993ecbf70b40982c..587d7efc234d68e8bac6540c8cafabca113757d8 100644 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/ApplicationWorkbenchAdvisor.java +++ b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/advisors/ApplicationWorkbenchAdvisor.java @@ -33,6 +33,7 @@ import org.fortiss.af3.project.AF3Project; import org.fortiss.af3.timing.ITimingSpecificationService; import org.fortiss.tooling.base.ToolingBase; import org.fortiss.tooling.kernel.ToolingKernel; +import org.fortiss.tooling.kernel.service.ICommandLineInterfaceService; import org.fortiss.tooling.kernel.ui.ToolingKernelUI; /** @@ -71,6 +72,9 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { IAllocationService.getInstance().startService(); ITimingSpecificationService.getInstance().startService(); IDSEBackendService.getInstance().startService(); + + // The CLI handlers must be executed last such that all services are available. + ICommandLineInterfaceService.getInstance().executeHandlers(); } /** {@inheritDoc} */ diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/handler/.ratings b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/handler/.ratings index 832ac7abb8672ad09d71b7fa7c16f75f1cce833e..b38a88a620052638f11dd2bb0890f53c3cb0a2fa 100644 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/handler/.ratings +++ b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/handler/.ratings @@ -1 +1 @@ -ApplicationCommandHandler.java 579327ec9cf27f09bfcfc110afde4d25503e8b6c GREEN +ApplicationCommandHandler.java 904ca1f838304623fd102a4ee9e26479f4070b64 GREEN diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/handler/ApplicationCommandHandler.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/handler/ApplicationCommandHandler.java index 579327ec9cf27f09bfcfc110afde4d25503e8b6c..904ca1f838304623fd102a4ee9e26479f4070b64 100644 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/handler/ApplicationCommandHandler.java +++ b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/handler/ApplicationCommandHandler.java @@ -16,39 +16,34 @@ package org.fortiss.af3.rcp.application.handler; +import static org.conqat.ide.commons.ui.logging.LoggingUtils.logAndShowError; import static org.conqat.ide.commons.ui.ui.WorkbenchUtils.getActiveWorkbenchWindow; import static org.eclipse.emf.common.util.URI.createFileURI; +import static org.eclipse.emf.common.util.URI.createPlatformPluginURI; import static org.eclipse.jface.dialogs.ErrorDialog.openError; import static org.eclipse.jface.dialogs.MessageDialog.openError; -import static org.eclipse.jface.dialogs.MessageDialog.openWarning; import static org.eclipse.ui.PlatformUI.getWorkbench; import static org.eclipse.ui.internal.about.AboutUtils.openErrorLogBrowser; -import static org.fortiss.af3.project.storage.LocationProvider.CURRENT_AF3_PROJECT_FILES_EXTENSION; +import static org.fortiss.af3.project.AF3Project.AF3_PRJ_SUFFIX; import static org.fortiss.af3.project.ui.utils.ExportProjectUtils.exportProject; import static org.fortiss.af3.project.ui.utils.ExportProjectUtils.fileSelectionDialog; import static org.fortiss.af3.project.ui.utils.ExportProjectUtils.getSelectedFileProject; import static org.fortiss.af3.project.ui.utils.ImportProjectUtils.fileSelectionDialog; -import static org.fortiss.af3.project.ui.utils.ImportProjectUtils.importFileCopy; -import static org.fortiss.af3.project.ui.utils.NewProjectUtils.createNewGeneralProject; -import static org.fortiss.af3.project.ui.utils.NewProjectUtils.generalProjectExists; -import static org.fortiss.af3.project.utils.FileUtils.saveFileLibrary; +import static org.fortiss.af3.project.ui.utils.ImportProjectUtils.importUISelectedFile; import static org.fortiss.af3.project.utils.LibraryModelElementFactory.createFileLibrary; -import static org.fortiss.af3.project.utils.ProjectUtils.loadProjectFromPlugin; -import static org.fortiss.af3.rcp.application.utils.ApplicationUtils.refreshWorkspace; -import static org.fortiss.af3.rcp.application.utils.ApplicationUtils.saveProject; import static org.fortiss.af3.rcp.application.utils.ApplicationUtils.switchToAF3Perspective; -import static org.fortiss.tooling.kernel.ToolingKernelActivator.getDefault; +import static org.fortiss.tooling.kernel.utils.EMFResourceUtils.refreshWorkspace; import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy; -import static org.fortiss.tooling.kernel.utils.LoggingUtils.error; +import java.io.File; import java.util.List; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.emf.common.util.URI; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Display; @@ -59,6 +54,7 @@ import org.fortiss.af3.project.example.IExample; import org.fortiss.af3.project.model.FileLibrary; import org.fortiss.af3.project.model.FileProject; import org.fortiss.af3.project.ui.utils.FileNameValidatorUtil; +import org.fortiss.af3.project.utils.ProjectUtils; import org.fortiss.af3.rcp.application.AF3ApplicationActivator; import org.fortiss.af3.rcp.application.example.SimpleTrafficLightsCodeGenerationExample; import org.fortiss.af3.rcp.application.utils.ApplicationUtils; @@ -76,24 +72,9 @@ import org.fortiss.tooling.kernel.ui.service.INavigatorService; public class ApplicationCommandHandler { - /** The current AF3 model file extension. */ - private static final String CURRENT_AF3_FILE_EXTENSION = - "." + CURRENT_AF3_PROJECT_FILES_EXTENSION; - /** Creates a project (per code) and stores it. */ private static boolean createAndSaveProject(String projectName, IExample builder) { - return ApplicationUtils.createAndSaveProject(projectName, CURRENT_AF3_FILE_EXTENSION, - builder); - } - - /** - * Checks if a file with the given project name already exists in the - * GeneralProject-Directory. If not, an IFile with the same name is - * returned. If yes, the user is asked for another project name. After the - * user inserted a valid unused name, an IFile with this name is returned. - */ - private static IFile validateProjectName(String projectName) { - return ApplicationUtils.validateProjectName(projectName, CURRENT_AF3_FILE_EXTENSION); + return ApplicationUtils.createAndSaveProject(projectName, AF3_PRJ_SUFFIX, builder); } /** @@ -109,52 +90,17 @@ public class ApplicationCommandHandler { */ private synchronized static void loadExistingModel(String pluginID, String relativePath, String projectName) { - // Ensure existence of generic project and enable AF3 Perspective. - startup(); + // Enable AF3 Perspective. + switchToAF3Perspective(); + + URI fileURI = createPlatformPluginURI(pluginID + File.separator + relativePath, true); - // Load file of the Example (do not create dummy, because - // otherwise the Example is shown twice). - FileProject project = null; try { - project = loadProjectFromPlugin(pluginID, relativePath, false); + importUISelectedFile(fileURI); } catch(Exception e) { - error(getDefault(), "Failed to load model from " + relativePath); - } finally { - if(project == null) { - return; - } + logAndShowError(AF3ApplicationActivator.getDefault(), "The project cannot be loaded.", + e); } - - // Check if file name not already exists. - IFile targetProjectFile = validateProjectName(projectName); - - if(targetProjectFile != null) { - try { - project.setName( - targetProjectFile.getName().replace(CURRENT_AF3_FILE_EXTENSION, "")); - // Save the project to workspace. - saveProject(project, targetProjectFile.getFullPath().toString()); - refreshWorkspace(); - } catch(Exception e) { - Display.getDefault().asyncExec(() -> openWarning(null, "Open AF3 Example", - "The project cannot be loaded.")); - } - } - } - - /** - * Method that is used by multiple command handlers to ensure that the - * Project exists that contains the *.af3_2x files and that the - * AF3-Perspective is activated. - */ - public static void startup() { - if(!generalProjectExists()) { - // Create a generic project. - createNewGeneralProject(); - } - - // Enable the AF3 Perspective. - switchToAF3Perspective(); } /** Command to exit the application. */ @@ -178,7 +124,7 @@ public class ApplicationCommandHandler { @Override public Object execute(ExecutionEvent event) { // Ensure existence of generic project and enable AF3 Perspective. - startup(); + switchToAF3Perspective(); // Create a new AF3 project. createAndSaveProject("AF3-Project", ConfiguredExpressionExample.INSTANCE); @@ -208,7 +154,7 @@ public class ApplicationCommandHandler { FileLibrary library = createFileLibrary(dlg.getValue()); // If a file with this name already exists. - if(!saveFileLibrary(library)) { + if(!ProjectUtils.saveFileLibrary(library)) { openError(getActiveWorkbenchWindow().getShell(), "Error While Saving the Library", "A library with name " + dlg.getValue() + " already exists"); @@ -252,7 +198,7 @@ public class ApplicationCommandHandler { @Override public Object execute(ExecutionEvent event) { // Ensure existence of generic project and enable AF3 Perspective. - startup(); + switchToAF3Perspective(); // Load SimpleTrafficLightsExample. createAndSaveProject("SimpleTrafficLightsModesExample", @@ -277,7 +223,7 @@ public class ApplicationCommandHandler { @Override public Object execute(ExecutionEvent event) { // Ensure existence of generic project and enable AF3 Perspective. - startup(); + switchToAF3Perspective(); // Load SimpleTrafficLightsCodeGenerationExample. createAndSaveProject("SimpleTrafficLightsCodeGenerationExample", @@ -415,15 +361,14 @@ public class ApplicationCommandHandler { @Override public Object execute(ExecutionEvent event) { // Ensure existence of generic project and enable AF3 Perspective. - startup(); + switchToAF3Perspective(); // Open file selection dialog to select the file to be imported. String importFile = fileSelectionDialog(); if(importFile != null) { // Copy selected file into workspace. - importFileCopy(createFileURI(importFile)); - refreshWorkspace(); + importUISelectedFile(createFileURI(importFile)); } return null; @@ -462,7 +407,7 @@ public class ApplicationCommandHandler { public static final class ShowErrorLogCommandHandler extends AbstractHandler { /** Opens the error log. */ - // TODO(#3367): Avoid the necessity of this warning if possible. + // TODO(#3367): Avoid the necessity of this warning if possible (won't fix). @Override public Object execute(ExecutionEvent event) { openErrorLogBrowser(Display.getCurrent().getActiveShell()); diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/utils/.ratings b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/utils/.ratings index 63041c328b96d39a728d37a191b7abbcfa389684..e8c0c8d7d310f92631e0ad3c37f2c20af30937f7 100644 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/utils/.ratings +++ b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/utils/.ratings @@ -1 +1 @@ -ApplicationUtils.java 199658a271076d94f1eb9710ea07744e48a5b62f GREEN +ApplicationUtils.java a597594f3f6736c56f4bf7f2eb03a9ede71d916f GREEN diff --git a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/utils/ApplicationUtils.java b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/utils/ApplicationUtils.java index 199658a271076d94f1eb9710ea07744e48a5b62f..a597594f3f6736c56f4bf7f2eb03a9ede71d916f 100644 --- a/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/utils/ApplicationUtils.java +++ b/org.fortiss.af3.rcp.application/src/org/fortiss/af3/rcp/application/utils/ApplicationUtils.java @@ -15,25 +15,23 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.rcp.application.utils; +import static org.fortiss.af3.project.ui.utils.ImportProjectUtils.determineTargetFileLocation; +import static org.fortiss.af3.project.utils.ProjectUtils.ensureEclipseContainerProjectExists; +import static org.fortiss.af3.project.utils.ProjectUtils.saveProject; +import static org.fortiss.tooling.kernel.utils.EMFResourceUtils.refreshWorkspace; +import static org.fortiss.tooling.kernel.utils.LoggingUtils.error; +import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError; + import java.io.IOException; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; +import org.eclipse.emf.common.util.URI; import org.eclipse.ui.IPerspectiveDescriptor; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; -import org.fortiss.af3.project.AF3ProjectActivator; import org.fortiss.af3.project.example.IExample; import org.fortiss.af3.project.model.FileProject; import org.fortiss.af3.project.ui.perspective.ModelingPerspectiveFactory; -import org.fortiss.af3.project.ui.utils.NewProjectUtils; -import org.fortiss.af3.project.utils.ProjectUtils; -import org.fortiss.tooling.kernel.utils.LoggingUtils; +import org.fortiss.af3.rcp.application.AF3ApplicationActivator; /** * Utility methods for dealing with the UI. @@ -61,56 +59,6 @@ public class ApplicationUtils { refreshWorkspace(); } - /** Refresh the workspace. */ - public static void refreshWorkspace() { - try { - // refresh the workspace - ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null); - } catch(Exception e) { - LoggingUtils.error(AF3ProjectActivator.getDefault(), "Cannot refresh workspace!", e); - e.printStackTrace(); - MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", - "Cannot refresh workspace!\n" + e.toString()); - } - } - - /** - * Checks if a file with the given project name already exists in the - * GeneralProject-Directory. If not, an {@link IFile} with the same name is - * returned. If yes, the user is asked for another project name. After the - * user inserted a valid unused name, an {@link IFile} with this name is returned. - * - * @param projectName - * The default project name. - * @param suffix - * The current AF3 project files extension. - * @return The {@link IFile} with this projectName and suffix. - */ - public static IFile validateProjectName(String projectName, String suffix) { - // Get the general project that contains the AF3-Projects. - final IResource resource = ResourcesPlugin.getWorkspace().getRoot() - .findMember(NewProjectUtils.getDefaultGeneralProjectName()); - - // If project name was given with file extension, remove this first. - projectName = projectName.replace(suffix, ""); - - // Create project file object. - IFile projectFile = ((IContainer)resource).getFile(new Path(projectName + suffix)); - - // If a file with this name already exists. - if(projectFile.exists()) { - String newProjectPath = - NewProjectUtils.requestFileNameDialog(projectFile.getLocation().toFile()); - if(newProjectPath == null) { - return null; - } - - projectFile = ((IContainer)resource).getFile(new Path(newProjectPath)); - } - - return projectFile; - } - /** * Creates a project (per code) and stores it. * @@ -124,31 +72,20 @@ public class ApplicationUtils { */ public static boolean createAndSaveProject(String projectName, String suffix, IExample builder) { - IFile projectFile = validateProjectName(projectName, suffix); - if(projectFile != null) { - // Save the project to workspace. - return saveProject(builder.createProject(projectFile.getName().replace(suffix, "")), - projectFile.getFullPath().toString()); - } - return false; - } + ensureEclipseContainerProjectExists(); - /** - * Saves given project to given path. - * - * @param project - * the given project to save - * @param fullPath - * to saving path - * @return whether the given project is saved to workspace - */ - public static boolean saveProject(FileProject project, String fullPath) { - try { - ProjectUtils.saveProject(project, fullPath); - return true; - } catch(final IOException e) { - MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", e.getMessage()); - return false; + URI projectURI = determineTargetFileLocation(projectName); + if(projectURI != null) { + projectName = projectURI.lastSegment().replace("." + suffix, ""); + FileProject project = builder.createProject(projectName); + try { + saveProject(project, projectURI); + refreshWorkspace(); + } catch(final IOException e) { + error(AF3ApplicationActivator.getDefault(), e.getMessage(), e); + showError(e.getMessage()); + } } + return false; } }