mirror of
https://github.com/Minres/RDL-Editor.git
synced 2025-06-13 22:02:23 +02:00
Migrated to XText 2.14 and Photon for RDL Editor RCP
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* generated by Xtext 2.13.0
|
||||
* generated by Xtext 2.14.0
|
||||
*/
|
||||
package com.minres.rdl.ui;
|
||||
|
||||
@ -14,6 +14,8 @@ import com.minres.rdl.ui.labeling.RDLDescriptionLabelProvider;
|
||||
import com.minres.rdl.ui.labeling.RDLLabelProvider;
|
||||
import com.minres.rdl.ui.outline.RDLOutlineTreeProvider;
|
||||
import com.minres.rdl.ui.quickfix.RDLQuickfixProvider;
|
||||
import com.minres.rdl.ui.wizard.RDLProjectCreator;
|
||||
import com.minres.rdl.validation.RDLValidatorConfigurationBlock;
|
||||
import org.eclipse.compare.IViewerCreator;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
@ -76,6 +78,8 @@ import org.eclipse.xtext.ui.refactoring.ui.IRenameSupport;
|
||||
import org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferences;
|
||||
import org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider;
|
||||
import org.eclipse.xtext.ui.shared.Access;
|
||||
import org.eclipse.xtext.ui.validation.AbstractValidatorConfigurationBlock;
|
||||
import org.eclipse.xtext.ui.wizard.IProjectCreator;
|
||||
|
||||
/**
|
||||
* Manual modifications go to {@link RDLUiModule}.
|
||||
@ -133,6 +137,11 @@ public abstract class AbstractRDLUiModule extends DefaultUiModule {
|
||||
binder.bind(InternalRDLLexer.class).toProvider(LexerProvider.create(InternalRDLLexer.class));
|
||||
}
|
||||
|
||||
// contributed by org.eclipse.xtext.xtext.generator.validation.ValidatorFragment2
|
||||
public Class<? extends AbstractValidatorConfigurationBlock> bindAbstractValidatorConfigurationBlock() {
|
||||
return RDLValidatorConfigurationBlock.class;
|
||||
}
|
||||
|
||||
// contributed by org.eclipse.xtext.xtext.generator.exporting.QualifiedNamesFragment2
|
||||
public Class<? extends PrefixMatcher> bindPrefixMatcher() {
|
||||
return FQNPrefixMatcher.class;
|
||||
@ -278,6 +287,11 @@ public abstract class AbstractRDLUiModule extends DefaultUiModule {
|
||||
binder.bind(String.class).annotatedWith(Names.named(UIBindings.COMPARE_VIEWER_TITLE)).toInstance("RDL Compare");
|
||||
}
|
||||
|
||||
// contributed by org.eclipse.xtext.xtext.generator.ui.projectWizard.SimpleProjectWizardFragment2
|
||||
public Class<? extends IProjectCreator> bindIProjectCreator() {
|
||||
return RDLProjectCreator.class;
|
||||
}
|
||||
|
||||
// contributed by org.eclipse.xtext.xtext.generator.exporting.SimpleNamesFragment2
|
||||
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
|
||||
return DefaultDependentElementsCalculator.class;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* generated by Xtext 2.13.0
|
||||
* generated by Xtext 2.14.0
|
||||
*/
|
||||
package com.minres.rdl.ui;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* generated by Xtext 2.13.0
|
||||
* generated by Xtext 2.14.0
|
||||
*/
|
||||
package com.minres.rdl.ui.contentassist;
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
/*
|
||||
* generated by Xtext 2.13.0
|
||||
* generated by Xtext 2.14.0
|
||||
*/
|
||||
package com.minres.rdl.ui.internal;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import com.minres.rdl.RDLRuntimeModule;
|
||||
import com.minres.rdl.ui.RDLUiModule;
|
||||
import java.util.Collections;
|
||||
@ -61,10 +60,10 @@ public class RdlActivator extends AbstractUIPlugin {
|
||||
|
||||
protected Injector createInjector(String language) {
|
||||
try {
|
||||
Module runtimeModule = getRuntimeModule(language);
|
||||
Module sharedStateModule = getSharedStateModule();
|
||||
Module uiModule = getUiModule(language);
|
||||
Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
|
||||
com.google.inject.Module runtimeModule = getRuntimeModule(language);
|
||||
com.google.inject.Module sharedStateModule = getSharedStateModule();
|
||||
com.google.inject.Module uiModule = getUiModule(language);
|
||||
com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
|
||||
return Guice.createInjector(mergedModule);
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to create injector for " + language);
|
||||
@ -73,21 +72,21 @@ public class RdlActivator extends AbstractUIPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
protected Module getRuntimeModule(String grammar) {
|
||||
protected com.google.inject.Module getRuntimeModule(String grammar) {
|
||||
if (COM_MINRES_RDL_RDL.equals(grammar)) {
|
||||
return new RDLRuntimeModule();
|
||||
}
|
||||
throw new IllegalArgumentException(grammar);
|
||||
}
|
||||
|
||||
protected Module getUiModule(String grammar) {
|
||||
protected com.google.inject.Module getUiModule(String grammar) {
|
||||
if (COM_MINRES_RDL_RDL.equals(grammar)) {
|
||||
return new RDLUiModule(this);
|
||||
}
|
||||
throw new IllegalArgumentException(grammar);
|
||||
}
|
||||
|
||||
protected Module getSharedStateModule() {
|
||||
protected com.google.inject.Module getSharedStateModule() {
|
||||
return new SharedStateModule();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* generated by Xtext 2.14.0
|
||||
*/
|
||||
package com.minres.rdl.ui.wizard;
|
||||
|
||||
import org.eclipse.xtext.ui.wizard.XtextNewProjectWizard;
|
||||
|
||||
import org.eclipse.xtext.ui.wizard.IExtendedProjectInfo;
|
||||
import org.eclipse.xtext.ui.wizard.IProjectCreator;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
public class RDLNewProjectWizard extends XtextNewProjectWizard {
|
||||
|
||||
private RDLWizardNewProjectCreationPage mainPage;
|
||||
|
||||
@Inject
|
||||
public RDLNewProjectWizard(IProjectCreator projectCreator) {
|
||||
super(projectCreator);
|
||||
setWindowTitle("New RDL Project");
|
||||
}
|
||||
|
||||
protected RDLWizardNewProjectCreationPage getMainPage() {
|
||||
return mainPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to add pages to the wizard.
|
||||
* The one-time generated version of this class will add a default new project page to the wizard.
|
||||
*/
|
||||
@Override
|
||||
public void addPages() {
|
||||
mainPage = createMainPage("basicNewProjectPage");
|
||||
mainPage.setTitle("RDL Project");
|
||||
mainPage.setDescription("Create a new RDL project.");
|
||||
addPage(mainPage);
|
||||
}
|
||||
|
||||
protected RDLWizardNewProjectCreationPage createMainPage(String pageName) {
|
||||
return new RDLWizardNewProjectCreationPage(pageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to read the project settings from the wizard pages and feed them into the project info class.
|
||||
*/
|
||||
@Override
|
||||
protected IExtendedProjectInfo getProjectInfo() {
|
||||
RDLProjectInfo projectInfo = new RDLProjectInfo();
|
||||
projectInfo.setProjectName(mainPage.getProjectName());
|
||||
if (!mainPage.useDefaults()) {
|
||||
projectInfo.setLocationPath(mainPage.getLocationPath());
|
||||
}
|
||||
return projectInfo;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* generated by Xtext 2.14.0
|
||||
*/
|
||||
package com.minres.rdl.ui.wizard;
|
||||
|
||||
import org.eclipse.xtext.ui.wizard.AbstractPluginProjectCreator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2;
|
||||
import org.eclipse.xtext.generator.IFileSystemAccess;
|
||||
import org.eclipse.xtext.generator.IFileSystemAccess2;
|
||||
import org.eclipse.xtext.generator.IOutputConfigurationProvider;
|
||||
import org.eclipse.xtext.generator.OutputConfiguration;
|
||||
import org.eclipse.xtext.ui.util.PluginProjectFactory;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
public class RDLProjectCreator extends AbstractPluginProjectCreator {
|
||||
protected static final String DSL_PROJECT_NAME = "com.minres.rdl";
|
||||
|
||||
@Inject
|
||||
private RDLNewProjectWizardInitialContents initialContents;
|
||||
|
||||
@Inject
|
||||
private Provider<EclipseResourceFileSystemAccess2> fileSystemAccessProvider;
|
||||
|
||||
@Inject
|
||||
private IOutputConfigurationProvider outputConfigurationProvider;
|
||||
|
||||
@Override
|
||||
protected PluginProjectFactory createProjectFactory() {
|
||||
PluginProjectFactory projectFactory = super.createProjectFactory();
|
||||
projectFactory.setWithPluginXml(false);
|
||||
return projectFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RDLProjectInfo getProjectInfo() {
|
||||
return (RDLProjectInfo) super.getProjectInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModelFolderName() {
|
||||
return "src";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getAllFolders() {
|
||||
Set<OutputConfiguration> outputConfigurations = outputConfigurationProvider.getOutputConfigurations();
|
||||
String outputFolder = "src-gen";
|
||||
for (OutputConfiguration outputConfiguration : outputConfigurations) {
|
||||
if (IFileSystemAccess.DEFAULT_OUTPUT.equals(outputConfiguration.getName())) {
|
||||
outputFolder = outputConfiguration.getOutputDirectory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ImmutableList.of(getModelFolderName(), outputFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getRequiredBundles() {
|
||||
return Lists.newArrayList(DSL_PROJECT_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enhanceProject(final IProject project, final IProgressMonitor monitor) throws CoreException {
|
||||
IFileSystemAccess2 access = getFileSystemAccess(project, monitor);
|
||||
initialContents.generateInitialContents(access);
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||
}
|
||||
|
||||
protected IFileSystemAccess2 getFileSystemAccess(final IProject project, final IProgressMonitor monitor) {
|
||||
EclipseResourceFileSystemAccess2 access = fileSystemAccessProvider.get();
|
||||
access.setContext(project);
|
||||
access.setMonitor(monitor);
|
||||
OutputConfiguration defaultOutput = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
|
||||
defaultOutput.setDescription("Output Folder");
|
||||
defaultOutput.setOutputDirectory("./");
|
||||
defaultOutput.setOverrideExistingResources(true);
|
||||
defaultOutput.setCreateOutputDirectory(true);
|
||||
defaultOutput.setCleanUpDerivedResources(false);
|
||||
defaultOutput.setSetDerivedProperty(false);
|
||||
defaultOutput.setKeepLocalHistory(false);
|
||||
HashMap<String, OutputConfiguration> outputConfigurations = new HashMap<String, OutputConfiguration>();
|
||||
outputConfigurations.put(IFileSystemAccess.DEFAULT_OUTPUT, defaultOutput);
|
||||
access.setOutputConfigurations(outputConfigurations);
|
||||
return access;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* generated by Xtext 2.14.0
|
||||
*/
|
||||
package com.minres.rdl.validation;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.xtext.ui.preferences.OptionsConfigurationBlock;
|
||||
import org.eclipse.xtext.ui.validation.AbstractValidatorConfigurationBlock;
|
||||
import org.eclipse.xtext.validation.SeverityConverter;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class RDLValidatorConfigurationBlock extends AbstractValidatorConfigurationBlock {
|
||||
|
||||
@Override
|
||||
protected void fillSettingsPage(Composite composite, int nColumns, int defaultIndent) {
|
||||
addComboBox(RDLConfigurableIssueCodesProvider.DEPRECATED_MODEL_PART, "Deprecated Model Part", composite, defaultIndent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Job getBuildJob(IProject project) {
|
||||
Job buildJob = new OptionsConfigurationBlock.BuildJob("Validation Settings Changed", project);
|
||||
buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
|
||||
buildJob.setUser(true);
|
||||
return buildJob;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
|
||||
return new String[] { "Validation Settings Changed",
|
||||
"Validation settings have changed. A full rebuild is required for changes to take effect. Do the full build now?" };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateSettings(String changedKey, String oldValue, String newValue) {
|
||||
}
|
||||
|
||||
protected Combo addComboBox(String prefKey, String label, Composite parent, int indent) {
|
||||
String[] values = new String[] { SeverityConverter.SEVERITY_ERROR, SeverityConverter.SEVERITY_WARNING,
|
||||
SeverityConverter.SEVERITY_INFO, SeverityConverter.SEVERITY_IGNORE };
|
||||
String[] valueLabels = new String[] { "Error", "Warning", "Info", "Ignore" };
|
||||
Combo comboBox = addComboBox(parent, label, prefKey, indent, values, valueLabels);
|
||||
return comboBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
storeSectionExpansionStates(getDialogSettings());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IDialogSettings getDialogSettings() {
|
||||
IDialogSettings dialogSettings = super.getDialogSettings();
|
||||
IDialogSettings section = dialogSettings.getSection("RDL");
|
||||
if (section == null) {
|
||||
return dialogSettings.addNewSection("RDL");
|
||||
}
|
||||
return section;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user