This repository has been archived by the owner on Apr 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LANG: Refactor-add a basic BundleModel
- Loading branch information
1 parent
9a8c199
commit 3f23825
Showing
13 changed files
with
350 additions
and
20 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
68 changes: 68 additions & 0 deletions
68
...e.core/src-lang/melnorme/lang/ide/core/project_model/view/AbstractBundleModelElement.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,68 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2015 Bruno Medeiros and other Contributors. | |||
* 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: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.lang.ide.core.project_model.view; | |||
|
|||
import static melnorme.utilbox.core.CoreUtil.areEqual; | |||
|
|||
import melnorme.utilbox.misc.MiscUtil; | |||
|
|||
public abstract class AbstractBundleModelElement<PARENT> implements IBundleModelElement { | |||
|
|||
protected final PARENT parent; | |||
|
|||
public AbstractBundleModelElement(PARENT parent) { | |||
this.parent = parent; | |||
} | |||
|
|||
@Override | |||
public boolean equals(Object other) { | |||
if(this == other) { | |||
return true; | |||
} | |||
if(!(other instanceof IBundleModelElement)) { | |||
return false; | |||
} | |||
IBundleModelElement otherElement = (IBundleModelElement) other; | |||
|
|||
if(this.getElementType() != otherElement.getElementType()) { | |||
return false; | |||
} | |||
if(!areEqual(this.getElementName(), otherElement.getElementName())) { | |||
return false; | |||
} | |||
|
|||
return areEqual(this.getParent(), otherElement.getParent()); | |||
} | |||
|
|||
@Override | |||
public int hashCode() { | |||
return MiscUtil.combineHashCodes(getParent().hashCode(), getElementName().hashCode()); | |||
} | |||
|
|||
@Override | |||
public String toString() { | |||
return getPathString() + " #" + getClass().getSimpleName(); | |||
} | |||
@Override | |||
public PARENT getParent() { | |||
return parent; | |||
} | |||
|
|||
@Override | |||
public boolean hasChildren() { | |||
return false; | |||
} | |||
@Override | |||
public Object[] getChildren() { | |||
return null; | |||
} | |||
|
|||
} |
66 changes: 66 additions & 0 deletions
66
...ore/src-lang/melnorme/lang/ide/core/project_model/view/AbstractDependenciesContainer.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,66 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2015 Bruno Medeiros and other Contributors. | |||
* 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: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.lang.ide.core.project_model.view; | |||
|
|||
|
|||
import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull; | |||
|
|||
import org.eclipse.core.resources.IProject; | |||
|
|||
import melnorme.lang.ide.core.BundleModelElementKind; | |||
|
|||
public abstract class AbstractDependenciesContainer<BUNDLEINFO> extends AbstractBundleModelElement<IProject> { | |||
|
|||
protected final BUNDLEINFO bundleInfo; | |||
protected final IBundleModelElement[] depElements; | |||
|
|||
public AbstractDependenciesContainer(BUNDLEINFO bundleInfo, IProject project) { | |||
super(project); | |||
this.bundleInfo = assertNotNull(bundleInfo); | |||
depElements = createChildren(); | |||
} | |||
|
|||
protected abstract IBundleModelElement[] createChildren(); | |||
|
|||
@Override | |||
public BundleModelElementKind getElementType() { | |||
return BundleModelElementKind.DEP_CONTAINER; | |||
} | |||
|
|||
public BUNDLEINFO getBundleInfo() { | |||
return bundleInfo; | |||
} | |||
|
|||
public IProject getProject() { | |||
return getParent(); | |||
} | |||
|
|||
@Override | |||
public String getElementName() { | |||
return "{Dependencies}"; | |||
} | |||
|
|||
@Override | |||
public String getPathString() { | |||
return getProject().getFullPath().toPortableString() + "/" + getElementName(); | |||
} | |||
|
|||
@Override | |||
public boolean hasChildren() { | |||
return depElements.length > 0; | |||
} | |||
|
|||
@Override | |||
public IBundleModelElement[] getChildren() { | |||
return depElements; | |||
} | |||
|
|||
} |
46 changes: 46 additions & 0 deletions
46
...core/src-lang/melnorme/lang/ide/core/project_model/view/AbstractRawDependencyElement.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,46 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2015 Bruno Medeiros and other Contributors. | |||
* 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: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.lang.ide.core.project_model.view; | |||
|
|||
|
|||
import melnorme.lang.ide.core.BundleModelElementKind; | |||
import melnorme.lang.tooling.bundle.DependencyRef; | |||
|
|||
public abstract class AbstractRawDependencyElement<PARENT extends IBundleModelElement> | |||
extends AbstractBundleModelElement<PARENT> { | |||
|
|||
protected final DependencyRef dependencyRef; | |||
|
|||
public AbstractRawDependencyElement(PARENT parent, DependencyRef dependencyRef) { | |||
super(parent); | |||
this.dependencyRef = dependencyRef; | |||
} | |||
|
|||
public String getBundleName() { | |||
return dependencyRef.bundleName; | |||
} | |||
|
|||
@Override | |||
public BundleModelElementKind getElementType() { | |||
return BundleModelElementKind.DEP_REFERENCE; | |||
} | |||
|
|||
@Override | |||
public String getElementName() { | |||
return getBundleName(); | |||
} | |||
|
|||
@Override | |||
public String getPathString() { | |||
return getParent().getPathString() + "/@" + getElementName(); | |||
} | |||
|
|||
} |
40 changes: 40 additions & 0 deletions
40
plugin_ide.core/src-lang/melnorme/lang/ide/core/project_model/view/BundleErrorElement.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2014 Bruno Medeiros and other Contributors. | |||
* 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: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.lang.ide.core.project_model.view; | |||
|
|||
import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull; | |||
|
|||
import melnorme.lang.ide.core.BundleModelElementKind; | |||
|
|||
public class BundleErrorElement extends AbstractBundleModelElement<IBundleModelElement> { | |||
|
|||
public final String errorDescription; | |||
|
|||
public BundleErrorElement(IBundleModelElement parent, String errorDescription) { | |||
super(parent); | |||
this.errorDescription = assertNotNull(errorDescription); | |||
} | |||
|
|||
@Override | |||
public BundleModelElementKind getElementType() { | |||
return BundleModelElementKind.ERROR_ELEMENT; | |||
} | |||
|
|||
@Override | |||
public String getElementName() { | |||
return "<error>"; | |||
} | |||
|
|||
@Override | |||
public String getPathString() { | |||
return getParent().getPathString() + "/" + getElementName(); | |||
} | |||
} |
31 changes: 31 additions & 0 deletions
31
plugin_ide.core/src-lang/melnorme/lang/ide/core/project_model/view/IBundleModelElement.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2015 Bruno Medeiros and other Contributors. | |||
* 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: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.lang.ide.core.project_model.view; | |||
|
|||
import melnorme.lang.ide.core.BundleModelElementKind; | |||
import melnorme.lang.ide.core.INavigatorElement_Actual; | |||
|
|||
public interface IBundleModelElement extends INavigatorElement_Actual { | |||
|
|||
Object getParent(); | |||
|
|||
boolean hasChildren(); | |||
|
|||
/** Returns the node's children. */ | |||
Object[] getChildren(); | |||
|
|||
public String getElementName(); | |||
|
|||
public BundleModelElementKind getElementType(); | |||
|
|||
public String getPathString(); | |||
|
|||
} |
26 changes: 26 additions & 0 deletions
26
plugin_ide.core/src/melnorme/lang/ide/core/BundleModelElementKind.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,26 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2015 Bruno Medeiros and other Contributors. | |||
* 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: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.lang.ide.core; | |||
|
|||
import melnorme.lang.tooling.LANG_SPECIFIC; | |||
|
|||
@LANG_SPECIFIC | |||
public enum BundleModelElementKind { | |||
DEP_CONTAINER, | |||
DEP_REFERENCE, | |||
|
|||
RESOLVED_DEP, | |||
STANDARD_LIB, | |||
|
|||
ERROR_ELEMENT, | |||
|
|||
DEP_SRC_FOLDER, | |||
} |
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
Oops, something went wrong.