Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java226
1 files changed, 0 insertions, 226 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java
deleted file mode 100644
index 82e5419297..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaNamedColumn;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Column;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaNamedColumn<T extends NamedColumnAnnotation>
- extends AbstractJavaJpaContextNode
- implements JavaNamedColumn
-{
-
- protected Owner owner;
-
- protected String specifiedName;
-
- protected String defaultName;
-
- protected String columnDefinition;
-
- protected T resourceColumn;
-
- protected AbstractJavaNamedColumn(JavaJpaContextNode parent, Owner owner) {
- super(parent);
- this.owner = owner;
- }
-
- // ******************* initialization from java resource model ********************
-
- protected void initialize(T column) {
- this.resourceColumn = column;
- this.specifiedName = column.getName();
- this.defaultName = this.buildDefaultName();
- this.columnDefinition = column.getColumnDefinition();
- }
-
- protected void update(T column) {
- this.resourceColumn = column;
- this.setSpecifiedName_(column.getName());
- this.setDefaultName(this.buildDefaultName());
- this.setColumnDefinition_(column.getColumnDefinition());
- }
-
- protected T getResourceColumn() {
- return this.resourceColumn;
- }
-
-
- //************** NamedColumn implementation *****************
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- getResourceColumn().setName(newSpecifiedName);
- firePropertyChanged(NamedColumn.SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedName_(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- firePropertyChanged(NamedColumn.SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- public String getDefaultName() {
- return this.defaultName;
- }
-
- protected void setDefaultName(String newDefaultName) {
- String oldDefaultName = this.defaultName;
- this.defaultName = newDefaultName;
- firePropertyChanged(NamedColumn.DEFAULT_NAME_PROPERTY, oldDefaultName, newDefaultName);
- }
-
- /**
- * Return the default column name.
- */
- protected String buildDefaultName() {
- return this.getOwner().getDefaultColumnName();
- }
-
- public String getColumnDefinition() {
- return this.columnDefinition;
- }
-
- public void setColumnDefinition(String newColumnDefinition) {
- String oldColumnDefinition = this.columnDefinition;
- this.columnDefinition = newColumnDefinition;
- getResourceColumn().setColumnDefinition(newColumnDefinition);
- firePropertyChanged(NamedColumn.COLUMN_DEFINITION_PROPERTY, oldColumnDefinition, newColumnDefinition);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setColumnDefinition_(String newColumnDefinition) {
- String oldColumnDefinition = this.columnDefinition;
- this.columnDefinition = newColumnDefinition;
- firePropertyChanged(NamedColumn.COLUMN_DEFINITION_PROPERTY, oldColumnDefinition, newColumnDefinition);
- }
-
- public Owner getOwner() {
- return this.owner;
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getResourceColumn().getNameTextRange(astRoot);
- return (textRange != null) ? textRange : this.getOwner().getValidationTextRange(astRoot);
- }
-
- public boolean nameTouches(int pos, CompilationUnit astRoot) {
- return this.getResourceColumn().nameTouches(pos, astRoot);
- }
-
- public Column getDbColumn() {
- Table table = this.getDbTable();
- return (table == null) ? null : table.getColumnForIdentifier(this.getName());
- }
-
- public Table getDbTable() {
- return getOwner().getDbTable(this.getTable());
- }
-
- /**
- * Return the name of the column's table. This is overridden
- * in AbstractJavaBaseColumn where a table can be defined.
- */
- public String getTable() {
- return this.getOwner().getTypeMapping().getPrimaryTableName();
- }
-
- public boolean isResolved() {
- return this.getDbColumn() != null;
- }
-
- @Override
- public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.nameTouches(pos, astRoot)) {
- return this.getJavaCandidateNames(filter).iterator();
- }
- return null;
- }
-
- private Iterable<String> getJavaCandidateNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateNames(filter));
- }
-
- private Iterable<String> getCandidateNames(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateNames(), filter);
- }
-
- private Iterable<String> getCandidateNames() {
- Table dbTable = this.getDbTable();
- return (dbTable != null) ? dbTable.getSortedColumnIdentifiers() : EmptyIterable.<String> instance();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ****************** validation ****************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = getResourceColumn().getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getOwner().getValidationTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.buildColumnValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildColumnValidator(CompilationUnit astRoot) {
- return this.getOwner().buildColumnValidator(this, buildTextRangeResolver(astRoot));
- }
-
- protected NamedColumnTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaNamedColumnTextRangeResolver(this, astRoot);
- }
-}

Back to the top