forked from eclipse-cdt/cdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eclipse-cdt#484] Add extension point for custom icons of C/C++ sourc…
…e files (eclipse-cdt#485) * [eclipse-cdt#484] Add extension point for custom icons of C/C++ source files fixes eclipse-cdt#484
- Loading branch information
1 parent
9920d7a
commit c2d0a66
Showing
6 changed files
with
256 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!-- Schema file written by PDE --> | ||
<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema"> | ||
<annotation> | ||
<appInfo> | ||
<meta.schema plugin="org.eclipse.cdt.ui" id="CFileImageProvider" name="Image Provider for C/C++ Source Files"/> | ||
</appInfo> | ||
<documentation> | ||
This extension point is meant to be used by the LSP based editor to provide custom icons for C/C++ source files. | ||
</documentation> | ||
</annotation> | ||
|
||
<element name="extension"> | ||
<annotation> | ||
<appInfo> | ||
<meta.element /> | ||
</appInfo> | ||
</annotation> | ||
<complexType> | ||
<sequence> | ||
<element ref="imageDescriptor"/> | ||
</sequence> | ||
<attribute name="point" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="id" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="name" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
<appInfo> | ||
<meta.attribute translatable="true"/> | ||
</appInfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<element name="imageDescriptor"> | ||
<complexType> | ||
<attribute name="class" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
Class which implements ICFileImageDescriptor interface. | ||
</documentation> | ||
<appInfo> | ||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.lsp.ICFileImageDescriptor"/> | ||
</appInfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="since"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter the first release in which this extension point appears.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="examples"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter extension point usage example here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="apiinfo"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter API information here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="implementation"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter information about supplied implementation of this extension point.] | ||
</documentation> | ||
</annotation> | ||
|
||
|
||
</schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...lipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DefaultCFileImageDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* See git history | ||
*******************************************************************************/ | ||
package org.eclipse.cdt.internal.ui.viewsupport; | ||
|
||
import org.eclipse.cdt.ui.CDTSharedImages; | ||
import org.eclipse.cdt.ui.CUIPlugin; | ||
import org.eclipse.cdt.ui.SharedImagesFactory; | ||
import org.eclipse.cdt.ui.lsp.ICFileImageDescriptor; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.jface.resource.ImageDescriptor; | ||
|
||
public class DefaultCFileImageDescriptor implements ICFileImageDescriptor { | ||
private SharedImagesFactory imagesFactory = new SharedImagesFactory(CUIPlugin.getDefault()); | ||
|
||
@Override | ||
public ImageDescriptor getCImageDescriptor() { | ||
return imagesFactory.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT); | ||
} | ||
|
||
@Override | ||
public ImageDescriptor getCXXImageDescriptor() { | ||
return imagesFactory.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT); | ||
} | ||
|
||
@Override | ||
public ImageDescriptor getHeaderImageDescriptor() { | ||
return imagesFactory.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled(IProject project) { | ||
return true; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/lsp/ICFileImageDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* See git history | ||
*******************************************************************************/ | ||
package org.eclipse.cdt.ui.lsp; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.jface.resource.ImageDescriptor; | ||
|
||
/** | ||
* C Image Descriptor Provider | ||
* @since 8.1 | ||
*/ | ||
public interface ICFileImageDescriptor { | ||
|
||
/** | ||
* @return ImageDescriptor for a C source file | ||
*/ | ||
public ImageDescriptor getCImageDescriptor(); | ||
|
||
/** | ||
* @return ImageDescriptor for a C++ source file | ||
*/ | ||
public ImageDescriptor getCXXImageDescriptor(); | ||
|
||
/** | ||
* @return ImageDescriptor for a C/C++ header file | ||
*/ | ||
public ImageDescriptor getHeaderImageDescriptor(); | ||
|
||
/** | ||
* Checks whether the descriptor can be used for the given project. | ||
* @param project | ||
* @return true if the descriptor can be used for the given project. | ||
*/ | ||
public boolean isEnabled(IProject project); | ||
|
||
} |