mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Fix for 190697, allow for customized binary container content.
This commit is contained in:
parent
82ae9e5b14
commit
1737387d1f
7 changed files with 93 additions and 9 deletions
|
@ -0,0 +1,54 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||
|
||||
/**
|
||||
* Allows to configure the presentation of binaries.
|
||||
*
|
||||
* <p> Clients may create subclasses. </p>
|
||||
* @since 4.0.1.
|
||||
*/
|
||||
public abstract class BinaryFilePresentation {
|
||||
|
||||
final protected IBinaryFile fBinaryFile;
|
||||
|
||||
/**
|
||||
* Constructs the presentation object for a binary file.
|
||||
*/
|
||||
public BinaryFilePresentation(IBinaryFile binFile) {
|
||||
fBinaryFile= binFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation for showing binaries as part of the binary container.
|
||||
* It is used whenever a IBinaryFile is not adaptable to BinaryFilePresentation.
|
||||
*/
|
||||
public static boolean showInBinaryContainer(IBinaryFile bin) {
|
||||
switch(bin.getType()) {
|
||||
case IBinaryFile.EXECUTABLE:
|
||||
case IBinaryFile.SHARED:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether a binary is to be shown as part of the binary container.
|
||||
* The default implementation returns <code>true</code> for executables and
|
||||
* dynamic libraries.
|
||||
*/
|
||||
public boolean showInBinaryContainer() {
|
||||
return showInBinaryContainer(fBinaryFile);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2007 QNX Software Systems 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
|
||||
|
@ -7,13 +7,18 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a Binary file, for example an ELF excutable.
|
||||
* Represents a Binary file, for example an ELF executable.
|
||||
* An ELF parser will inspect the binary.
|
||||
*
|
||||
* <p>
|
||||
* This interface is not intended to be implemented by clients.
|
||||
* </p>
|
||||
*/
|
||||
public interface IBinary extends ICElement, IParent, IOpenable {
|
||||
/**
|
||||
|
@ -43,6 +48,12 @@ public interface IBinary extends ICElement, IParent, IOpenable {
|
|||
|
||||
public boolean isLittleEndian();
|
||||
|
||||
/**
|
||||
* Determines whether this binary is part of the binary container. The binary container collects
|
||||
* binaries from a project. This is typically used to presents the executables of a project under
|
||||
* a common node in the CView or ProjectNavigator.
|
||||
*/
|
||||
public boolean showInBinaryContainer();
|
||||
//public IAddressFactory getAddressFactory();
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
@ -26,6 +27,7 @@ import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
|||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryShared;
|
||||
import org.eclipse.cdt.core.IBinaryParser.ISymbol;
|
||||
import org.eclipse.cdt.core.model.BinaryFilePresentation;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IBinary;
|
||||
|
@ -53,16 +55,27 @@ public class Binary extends Openable implements IBinary {
|
|||
|
||||
private long fLastModification;
|
||||
|
||||
IBinaryObject binaryObject;
|
||||
private IBinaryObject binaryObject;
|
||||
private boolean showInBinaryContainer;
|
||||
|
||||
public Binary(ICElement parent, IFile file, IBinaryObject bin) {
|
||||
super(parent, file, ICElement.C_BINARY);
|
||||
binaryObject = bin;
|
||||
showInBinaryContainer= determineShowInBinaryContainer(bin);
|
||||
}
|
||||
|
||||
private boolean determineShowInBinaryContainer(IBinaryObject bin) {
|
||||
BinaryFilePresentation presentation= (BinaryFilePresentation) bin.getAdapter(BinaryFilePresentation.class);
|
||||
if (presentation != null) {
|
||||
return presentation.showInBinaryContainer();
|
||||
}
|
||||
return BinaryFilePresentation.showInBinaryContainer(bin);
|
||||
}
|
||||
|
||||
public Binary(ICElement parent, IPath path, IBinaryObject bin) {
|
||||
super (parent, path, ICElement.C_BINARY);
|
||||
binaryObject = bin;
|
||||
showInBinaryContainer= determineShowInBinaryContainer(bin);
|
||||
}
|
||||
|
||||
public boolean isSharedLib() {
|
||||
|
@ -496,4 +509,8 @@ public class Binary extends Openable implements IBinary {
|
|||
}
|
||||
super.closing(info);
|
||||
}
|
||||
|
||||
public boolean showInBinaryContainer() {
|
||||
return showInBinaryContainer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2007 QNX Software Systems 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
@ -41,7 +42,7 @@ public class BinaryContainer extends Openable implements IBinaryContainer {
|
|||
for (int i = 0; i < e.length; i++) {
|
||||
if (e[i] instanceof IBinary) {
|
||||
IBinary bin = (IBinary)e[i];
|
||||
if (bin.isExecutable() || bin.isSharedLib()) {
|
||||
if (bin.showInBinaryContainer()) {
|
||||
list.add(bin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,8 +249,9 @@ public class CContainer extends Openable implements ICContainer {
|
|||
ArchiveContainer vlib = (ArchiveContainer) cproject.getArchiveContainer();
|
||||
vlib.addChild(celement);
|
||||
} else {
|
||||
celement = new Binary(this, file, (IBinaryObject) bin);
|
||||
if (bin.getType() == IBinaryFile.EXECUTABLE || bin.getType() == IBinaryFile.SHARED) {
|
||||
final Binary binElement= new Binary(this, file, (IBinaryObject) bin);
|
||||
celement= binElement;
|
||||
if (binElement.showInBinaryContainer()) {
|
||||
BinaryContainer vbin = (BinaryContainer) cproject.getBinaryContainer();
|
||||
vbin.addChild(celement);
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ public class CViewContentProvider extends CElementContentProvider {
|
|||
for (int i = 0; i < celements.length; i++) {
|
||||
if (celements[i] instanceof IBinary) {
|
||||
IBinary bin = (IBinary)celements[i];
|
||||
if (bin.isExecutable() || bin.isSharedLib()) {
|
||||
if (bin.showInBinaryContainer()) {
|
||||
list.add(bin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
|||
ICProject cproject = null;
|
||||
if (cfile instanceof IBinary) {
|
||||
IBinary bin = (IBinary)cfile;
|
||||
if (bin.isExecutable() || bin.isSharedLib()) {
|
||||
if (bin.showInBinaryContainer()) {
|
||||
cproject = bin.getCProject();
|
||||
container = cproject.getBinaryContainer();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue