mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
API from cdt.ui for option pages and console
This commit is contained in:
parent
7104c92f7f
commit
a650dd13d8
9 changed files with 135 additions and 93 deletions
|
@ -11,12 +11,9 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers;
|
package org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
|
|
||||||
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
|
||||||
import org.eclipse.cdt.internal.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
|
|
||||||
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector;
|
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector;
|
||||||
|
import org.eclipse.cdt.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
import org.eclipse.core.runtime.Assert;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -65,7 +62,7 @@ public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettin
|
||||||
composite.setLayoutData(gd);
|
composite.setLayoutData(gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractBuiltinSpecsDetector provider = getRawProvider();
|
AbstractBuiltinSpecsDetector provider = (AbstractBuiltinSpecsDetector) getProvider();
|
||||||
|
|
||||||
// Compiler specs command
|
// Compiler specs command
|
||||||
{
|
{
|
||||||
|
@ -85,11 +82,11 @@ public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettin
|
||||||
@Override
|
@Override
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
String text = inputCommand.getText();
|
String text = inputCommand.getText();
|
||||||
AbstractBuiltinSpecsDetector provider = getRawProvider();
|
AbstractBuiltinSpecsDetector provider = (AbstractBuiltinSpecsDetector) getProvider();
|
||||||
if (!text.equals(provider.getCommand())) {
|
if (!text.equals(provider.getCommand())) {
|
||||||
AbstractBuiltinSpecsDetector selectedProvider = getWorkingCopy(providerId);
|
AbstractBuiltinSpecsDetector selectedProvider = (AbstractBuiltinSpecsDetector) getProviderWorkingCopy();
|
||||||
selectedProvider.setCommand(text);
|
selectedProvider.setCommand(text);
|
||||||
providerTab.refreshItem(selectedProvider);
|
refreshItem(selectedProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -128,11 +125,11 @@ public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettin
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
boolean enabled = allocateConsoleCheckBox.getSelection();
|
boolean enabled = allocateConsoleCheckBox.getSelection();
|
||||||
AbstractBuiltinSpecsDetector provider = getRawProvider();
|
AbstractBuiltinSpecsDetector provider = (AbstractBuiltinSpecsDetector) getProvider();
|
||||||
if (enabled != provider.isConsoleEnabled()) {
|
if (enabled != provider.isConsoleEnabled()) {
|
||||||
AbstractBuiltinSpecsDetector selectedProvider = getWorkingCopy(providerId);
|
AbstractBuiltinSpecsDetector selectedProvider = (AbstractBuiltinSpecsDetector) getProviderWorkingCopy();
|
||||||
selectedProvider.setConsoleEnabled(enabled);
|
selectedProvider.setConsoleEnabled(enabled);
|
||||||
providerTab.refreshItem(selectedProvider);
|
refreshItem(selectedProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,18 +145,6 @@ public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettin
|
||||||
setControl(composite);
|
setControl(composite);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractBuiltinSpecsDetector getRawProvider() {
|
|
||||||
ILanguageSettingsProvider provider = LanguageSettingsManager.getRawProvider(providerTab.getProvider(providerId));
|
|
||||||
Assert.isTrue(provider instanceof AbstractBuiltinSpecsDetector);
|
|
||||||
return (AbstractBuiltinSpecsDetector) provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AbstractBuiltinSpecsDetector getWorkingCopy(String providerId) {
|
|
||||||
ILanguageSettingsProvider provider = providerTab.getWorkingCopy(providerId);
|
|
||||||
Assert.isTrue(provider instanceof AbstractBuiltinSpecsDetector);
|
|
||||||
return (AbstractBuiltinSpecsDetector) provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
// handled by LanguageSettingsProviderTab
|
// handled by LanguageSettingsProviderTab
|
||||||
|
|
|
@ -11,12 +11,9 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers;
|
package org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
|
|
||||||
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
|
||||||
import org.eclipse.cdt.internal.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
|
|
||||||
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildCommandParser;
|
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildCommandParser;
|
||||||
|
import org.eclipse.cdt.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
import org.eclipse.core.runtime.Assert;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
|
@ -69,7 +66,7 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
|
||||||
composite.setLayoutData(gd);
|
composite.setLayoutData(gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractBuildCommandParser provider = getRawProvider();
|
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
|
||||||
|
|
||||||
// Compiler specs command
|
// Compiler specs command
|
||||||
{
|
{
|
||||||
|
@ -96,11 +93,11 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
|
||||||
@Override
|
@Override
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
String text = inputCommand.getText();
|
String text = inputCommand.getText();
|
||||||
AbstractBuildCommandParser provider = getRawProvider();
|
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
|
||||||
if (!text.equals(provider.getCompilerPattern())) {
|
if (!text.equals(provider.getCompilerPattern())) {
|
||||||
AbstractBuildCommandParser selectedProvider = getWorkingCopy(providerId);
|
AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) getProviderWorkingCopy();
|
||||||
selectedProvider.setCompilerPattern(text);
|
selectedProvider.setCompilerPattern(text);
|
||||||
providerTab.refreshItem(selectedProvider);
|
refreshItem(selectedProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -119,11 +116,11 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
boolean enabled = expandRelativePathCheckBox.getSelection();
|
boolean enabled = expandRelativePathCheckBox.getSelection();
|
||||||
AbstractBuildCommandParser provider = getRawProvider();
|
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
|
||||||
if (enabled != provider.isResolvingPaths()) {
|
if (enabled != provider.isResolvingPaths()) {
|
||||||
AbstractBuildCommandParser selectedProvider = getWorkingCopy(providerId);
|
AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) getProviderWorkingCopy();
|
||||||
selectedProvider.setResolvingPaths(enabled);
|
selectedProvider.setResolvingPaths(enabled);
|
||||||
providerTab.refreshItem(selectedProvider);
|
refreshItem(selectedProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,11 +158,11 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
boolean enabled = scopeFileRadioButton.getSelection();
|
boolean enabled = scopeFileRadioButton.getSelection();
|
||||||
AbstractBuildCommandParser provider = getRawProvider();
|
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
|
||||||
if (enabled != (provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.FILE)) {
|
if (enabled != (provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.FILE)) {
|
||||||
AbstractBuildCommandParser selectedProvider = getWorkingCopy(providerId);
|
AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) getProviderWorkingCopy();
|
||||||
selectedProvider.setResourceScope(AbstractBuildCommandParser.ResourceScope.FILE);
|
selectedProvider.setResourceScope(AbstractBuildCommandParser.ResourceScope.FILE);
|
||||||
providerTab.refreshItem(selectedProvider);
|
refreshItem(selectedProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,11 +189,11 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
boolean enabled = scopeFolderRadioButton.getSelection();
|
boolean enabled = scopeFolderRadioButton.getSelection();
|
||||||
AbstractBuildCommandParser provider = getRawProvider();
|
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
|
||||||
if (enabled != (provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.FOLDER)) {
|
if (enabled != (provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.FOLDER)) {
|
||||||
AbstractBuildCommandParser selectedProvider = getWorkingCopy(providerId);
|
AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) getProviderWorkingCopy();
|
||||||
selectedProvider.setResourceScope(AbstractBuildCommandParser.ResourceScope.FOLDER);
|
selectedProvider.setResourceScope(AbstractBuildCommandParser.ResourceScope.FOLDER);
|
||||||
providerTab.refreshItem(selectedProvider);
|
refreshItem(selectedProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,11 +220,11 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
boolean enabled = scopeProjectRadioButton.getSelection();
|
boolean enabled = scopeProjectRadioButton.getSelection();
|
||||||
AbstractBuildCommandParser provider = getRawProvider();
|
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
|
||||||
if (enabled != (provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.PROJECT)) {
|
if (enabled != (provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.PROJECT)) {
|
||||||
AbstractBuildCommandParser selectedProvider = getWorkingCopy(providerId);
|
AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) getProviderWorkingCopy();
|
||||||
selectedProvider.setResourceScope(AbstractBuildCommandParser.ResourceScope.PROJECT);
|
selectedProvider.setResourceScope(AbstractBuildCommandParser.ResourceScope.PROJECT);
|
||||||
providerTab.refreshItem(selectedProvider);
|
refreshItem(selectedProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,18 +240,6 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
|
||||||
setControl(composite);
|
setControl(composite);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractBuildCommandParser getRawProvider() {
|
|
||||||
ILanguageSettingsProvider provider = LanguageSettingsManager.getRawProvider(providerTab.getProvider(providerId));
|
|
||||||
Assert.isTrue(provider instanceof AbstractBuildCommandParser);
|
|
||||||
return (AbstractBuildCommandParser) provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AbstractBuildCommandParser getWorkingCopy(String providerId) {
|
|
||||||
ILanguageSettingsProvider provider = providerTab.getWorkingCopy(providerId);
|
|
||||||
Assert.isTrue(provider instanceof AbstractBuildCommandParser);
|
|
||||||
return (AbstractBuildCommandParser) provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
// handled by LanguageSettingsProviderTab
|
// handled by LanguageSettingsProviderTab
|
||||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.buildconsole.CBuildConsole;
|
import org.eclipse.cdt.internal.ui.buildconsole.CBuildConsole;
|
||||||
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderAssociationManager;
|
import org.eclipse.cdt.ui.language.settings.providers.LanguageSettingsProvidersImages;
|
||||||
|
|
||||||
public class ScannerDiscoveryConsole extends CBuildConsole {
|
public class ScannerDiscoveryConsole extends CBuildConsole {
|
||||||
|
|
||||||
|
@ -23,15 +23,15 @@ public class ScannerDiscoveryConsole extends CBuildConsole {
|
||||||
* @param consoleId - a console ID is expected here which then is used as menu context ID.
|
* @param consoleId - a console ID is expected here which then is used as menu context ID.
|
||||||
* @param defaultIconUrl - if {@code LanguageSettingsProviderAssociation} extension point
|
* @param defaultIconUrl - if {@code LanguageSettingsProviderAssociation} extension point
|
||||||
* defines URL by provider id, {@code defaultIconUrl} will be ignored and the URL from the extension
|
* defines URL by provider id, {@code defaultIconUrl} will be ignored and the URL from the extension
|
||||||
* point will be used. If not, supplied {@code defaultIconUrl} will be used.
|
* point will be used. If not, supplied {@code defaultIconUrl} will be used.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void init(String consoleId, String name, URL defaultIconUrl) {
|
public void init(String consoleId, String name, URL defaultIconUrl) {
|
||||||
URL iconUrl = LanguageSettingsProviderAssociationManager.getImageUrl(consoleId);
|
URL iconUrl = LanguageSettingsProvidersImages.getImageUrl(consoleId);
|
||||||
if (iconUrl==null) {
|
if (iconUrl==null) {
|
||||||
iconUrl = defaultIconUrl;
|
iconUrl = defaultIconUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.init(consoleId, name, iconUrl);
|
super.init(consoleId, name, iconUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@ import java.net.URL;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.ConsoleOutputStream;
|
import org.eclipse.cdt.core.ConsoleOutputStream;
|
||||||
import org.eclipse.cdt.internal.core.ICConsole;
|
import org.eclipse.cdt.internal.core.ICConsole;
|
||||||
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderAssociationManager;
|
|
||||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||||
|
import org.eclipse.cdt.ui.language.settings.providers.LanguageSettingsProvidersImages;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -102,7 +102,7 @@ public class ScannerDiscoveryGlobalConsole implements ICConsole {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (console==null) {
|
if (console==null) {
|
||||||
URL iconUrl = LanguageSettingsProviderAssociationManager.getImageUrl(consoleId);
|
URL iconUrl = LanguageSettingsProvidersImages.getImageUrl(consoleId);
|
||||||
if (iconUrl == null) {
|
if (iconUrl == null) {
|
||||||
iconUrl = defaultIconUrl;
|
iconUrl = defaultIconUrl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
|
||||||
org.eclipse.cdt.ui.browser.typeinfo,
|
org.eclipse.cdt.ui.browser.typeinfo,
|
||||||
org.eclipse.cdt.ui.dialogs,
|
org.eclipse.cdt.ui.dialogs,
|
||||||
org.eclipse.cdt.ui.internal.templateengine.wizard;x-internal:=true,
|
org.eclipse.cdt.ui.internal.templateengine.wizard;x-internal:=true,
|
||||||
|
org.eclipse.cdt.ui.language.settings.providers,
|
||||||
org.eclipse.cdt.ui.newui,
|
org.eclipse.cdt.ui.newui,
|
||||||
org.eclipse.cdt.ui.refactoring,
|
org.eclipse.cdt.ui.refactoring,
|
||||||
org.eclipse.cdt.ui.refactoring.actions,
|
org.eclipse.cdt.ui.refactoring.actions,
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2010, 2012 Andrew Gvozdev and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Andrew Gvozdev - Initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.ui.language.settings.providers;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract class to implement language settings providers Options page.
|
|
||||||
*/
|
|
||||||
public abstract class AbstractLanguageSettingProviderOptionPage extends AbstractCOptionPage {
|
|
||||||
protected LanguageSettingsProviderTab providerTab;
|
|
||||||
protected String providerId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the options page with the owning tab and provider ID.
|
|
||||||
*
|
|
||||||
* @param providerTab - provider tab which owns the options page.
|
|
||||||
* @param providerId - ID of the provider the options page is for.
|
|
||||||
*/
|
|
||||||
protected void init(LanguageSettingsProviderTab providerTab, String providerId) {
|
|
||||||
this.providerTab = providerTab;
|
|
||||||
this.providerId = providerId;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -57,6 +57,7 @@ import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
|
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
|
||||||
|
import org.eclipse.cdt.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
|
||||||
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
|
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
|
||||||
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
||||||
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
|
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2010, 2012 Andrew Gvozdev and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Gvozdev - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.ui.language.settings.providers;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
|
||||||
|
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
||||||
|
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
|
||||||
|
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderTab;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class to implement language settings providers Options page.
|
||||||
|
*
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public abstract class AbstractLanguageSettingProviderOptionPage extends AbstractCOptionPage {
|
||||||
|
private LanguageSettingsProviderTab providerTab;
|
||||||
|
private String providerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the options page with the owning tab and provider ID.
|
||||||
|
*
|
||||||
|
* @param providerTab - provider tab which owns the options page.
|
||||||
|
* @param providerId - ID of the provider the options page is for.
|
||||||
|
*/
|
||||||
|
public void init(AbstractCPropertyTab providerTab, String providerId) {
|
||||||
|
Assert.isTrue(providerTab instanceof LanguageSettingsProviderTab);
|
||||||
|
this.providerTab = (LanguageSettingsProviderTab) providerTab;
|
||||||
|
this.providerId = providerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get provider being displayed on this Options Page.
|
||||||
|
* @return provider.
|
||||||
|
*/
|
||||||
|
public ILanguageSettingsProvider getProvider() {
|
||||||
|
return LanguageSettingsManager.getRawProvider(providerTab.getProvider(providerId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get working copy of the provider to allow its options to be modified.
|
||||||
|
* @return working copy of the provider.
|
||||||
|
*/
|
||||||
|
public ILanguageSettingsProvider getProviderWorkingCopy() {
|
||||||
|
return providerTab.getWorkingCopy(providerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh provider item in the table and update buttons.
|
||||||
|
* This method is intended for use by an Options Page of the provider.
|
||||||
|
*
|
||||||
|
* @param provider - provider item in the table to refresh.
|
||||||
|
*/
|
||||||
|
public void refreshItem(ILanguageSettingsProvider provider) {
|
||||||
|
providerTab.refreshItem(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012, 2012 Andrew Gvozdev and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Andrew Gvozdev - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.ui.language.settings.providers;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderAssociationManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class to provide API for language settings providers images.
|
||||||
|
*
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public class LanguageSettingsProvidersImages {
|
||||||
|
/**
|
||||||
|
* Get image URL for language settings provider with the given ID.
|
||||||
|
*
|
||||||
|
* @param providerId - ID of language settings provider.
|
||||||
|
* @return image URL or {@code null}.
|
||||||
|
*/
|
||||||
|
public static URL getImageUrl(String providerId) {
|
||||||
|
return LanguageSettingsProviderAssociationManager.getImageUrl(providerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue