JBoss Tools SVN: r34235 - in trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test: util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-08-24 13:43:31 -0400 (Wed, 24 Aug 2011)
New Revision: 34235
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/EGitUtilsTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/util/TestRepository.java
Log:
[JBIDE-9575] test for "push to remote by name" implemented and successful.
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/EGitUtilsTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/EGitUtilsTest.java 2011-08-24 17:32:31 UTC (rev 34234)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/EGitUtilsTest.java 2011-08-24 17:43:31 UTC (rev 34235)
@@ -8,8 +8,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.egit.core.Activator;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.lib.Repository;
import org.jboss.ide.eclipse.as.egit.core.EGitUtils;
import org.jboss.ide.eclipse.as.egit.internal.test.util.TestProject;
import org.jboss.ide.eclipse.as.egit.internal.test.util.TestRepository;
@@ -26,7 +24,6 @@
protected final TestUtils testUtils = new TestUtils();
- private File gitDir;
private TestRepository testRepository;
private TestProject testProject;
private TestRepository clonedTestRepository;
@@ -37,8 +34,7 @@
this.testProject = new TestProject(true);
- this.gitDir = TestUtils.createGitDir(testProject);
- this.testRepository = new TestRepository(gitDir);
+ this.testRepository = new TestRepository(TestUtils.createGitDir(testProject));
testRepository.createMockSystemReader(ResourcesPlugin.getWorkspace().getRoot().getLocation());
testRepository.setUserAndEmail(GIT_USER, GIT_EMAIL);
testRepository.connect(testProject.getProject());
@@ -46,7 +42,8 @@
this.clonedTestRepository = cloneRepository(testRepository);
}
- private TestRepository cloneRepository(TestRepository repository) throws URISyntaxException, InvocationTargetException, InterruptedException, IOException {
+ private TestRepository cloneRepository(TestRepository repository) throws URISyntaxException,
+ InvocationTargetException, InterruptedException, IOException {
File workspaceDir = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile();
File clonedRepositoryFile =
new File(workspaceDir, "clonedRepository-" + String.valueOf(System.currentTimeMillis()));
@@ -66,10 +63,10 @@
public void canCommitFileInProject() throws Exception {
String fileName = "a.txt";
String fileContent = "adietish(a)redhat.com";
-
+
IFile file = testUtils.addFileToProject(
testProject.getProject(),
- fileName,
+ fileName,
fileContent);
testRepository.track(file);
@@ -84,19 +81,50 @@
public void fileAddedToCloneIsInOriginAfterPush() throws Exception {
String fileName = "b.txt";
String fileContent = "adietish(a)redhat.com";
-
- clonedTestRepository.createFile(fileName, fileContent);
- Repository clonedRepository = clonedTestRepository.getRepository();
- Git git = new Git(clonedRepository);
- git.add().addFilepattern(fileName).call();
- git.commit().setCommitter(GIT_USER, GIT_EMAIL).setMessage("adding a new file").call();
- EGitUtils.push(clonedRepository, null);
+ File file = clonedTestRepository.createFile(fileName, fileContent);
+ clonedTestRepository.addAndCommit(file, "adding a file");
+ EGitUtils.push(clonedTestRepository.getRepository(), null);
+
// does origin contain file added to clone?
testUtils.assertRepositoryContainsFilesWithContent(
- clonedRepository,
+ clonedTestRepository.getRepository(),
fileName,
fileContent);
}
+
+ @Test
+ public void fileAddedToCloneIsInRemoteAfterPush() throws Exception {
+ TestProject testProject2 = null;
+ TestRepository testRepository2 = null;
+ String fileName = "c.txt";
+ String fileContent = "adietish(a)redhat.com";
+ String remoteRepoName = "openshift";
+
+ try {
+ testProject2 = new TestProject(true);
+ File gitDir = TestUtils.createGitDir(testProject2);
+ testRepository2 = new TestRepository(gitDir);
+ clonedTestRepository.addRemoteTo(remoteRepoName, testRepository2.getRepository());
+
+ File file = clonedTestRepository.createFile(fileName, fileContent);
+ clonedTestRepository.addAndCommit(file, "adding a file");
+
+ EGitUtils.push(remoteRepoName, clonedTestRepository.getRepository(), null);
+
+ // does origin contain file added to clone?
+ testUtils.assertRepositoryContainsFilesWithContent(
+ clonedTestRepository.getRepository(),
+ fileName,
+ fileContent);
+ } finally {
+ if (testProject2 != null) {
+ testProject2.dispose();
+ }
+ if (testRepository2 != null) {
+ testRepository2.dispose();
+ }
+ }
+ }
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/util/TestRepository.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/util/TestRepository.java 2011-08-24 17:32:31 UTC (rev 34234)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/util/TestRepository.java 2011-08-24 17:43:31 UTC (rev 34235)
@@ -16,6 +16,7 @@
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Collections;
@@ -53,6 +54,7 @@
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.util.FileUtils;
@@ -170,9 +172,10 @@
return file;
}
- public void createFile(String name, String data) throws IOException {
+ public File createFile(String name, String data) throws IOException {
File file = new File(repository.getWorkTree(), name);
write(file, data);
+ return file;
}
private void write(final File file, final String data) throws IOException {
@@ -202,6 +205,14 @@
return commit(commitMessage);
}
+ public RevCommit addAndCommit(File file, String commitMessage)
+ throws Exception {
+ track(file);
+ addToIndex(file);
+
+ return commit(commitMessage);
+ }
+
/**
* Appends file content to given file, then track, add to index and finally
* commit it.
@@ -363,6 +374,15 @@
}
}
+ public void addToIndex(File file) throws CoreException, IOException {
+ String repoPath = getRepoRelativePath(file.getAbsolutePath());
+ try {
+ new Git(repository).add().addFilepattern(repoPath).call();
+ } catch (NoFilepatternException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
/**
* Appends content to end of given file.
*
@@ -573,4 +593,16 @@
public File getGitDir() {
return gitDir;
}
+
+ public void addRemoteTo(String remoteName, Repository remoteRepository)
+ throws URISyntaxException, MalformedURLException,
+ IOException {
+ StoredConfig config = repository.getConfig();
+ RemoteConfig remoteConfig = new RemoteConfig(config, remoteName);
+ URIish uri = new URIish(remoteRepository.getDirectory().toURI().toURL());
+ remoteConfig.addURI(uri);
+ remoteConfig.update(config);
+ config.save();
+ }
+
}
14 years, 7 months
JBoss Tools SVN: r34234 - trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils.
by jbosstools-commits@lists.jboss.org
Author: bfitzpat
Date: 2011-08-24 13:32:31 -0400 (Wed, 24 Aug 2011)
New Revision: 34234
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java
Log:
JBIDE-9516 - fixing issue with resteasy jar detection for jax-rs sample wizard
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java 2011-08-24 17:27:51 UTC (rev 34233)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java 2011-08-24 17:32:31 UTC (rev 34234)
@@ -38,7 +38,8 @@
public class RestEasyLibUtils {
private static final String REST_EASY = "RestEasy"; //$NON-NLS-1$
- private static final String JAXRS_API_JAR = "jaxrs-api.jar"; //$NON-NLS-1$
+ private static final String JAXRS_API_PREFIX = "jaxrs-api"; //$NON-NLS-1$
+ private static final String JAXRS_API_POSTFIX = ".jar"; //$NON-NLS-1$
private static final String LIB = "lib"; //$NON-NLS-1$
/**
@@ -104,7 +105,7 @@
if (libDir.exists() && libDir.isDirectory()) {
File[] jars = libDir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
- if (name.equalsIgnoreCase(JAXRS_API_JAR)) {
+ if (name.startsWith(JAXRS_API_PREFIX) && name.endsWith(JAXRS_API_POSTFIX)) {
return true;
}
return false;
14 years, 7 months
JBoss Tools SVN: r34233 - branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils.
by jbosstools-commits@lists.jboss.org
Author: bfitzpat
Date: 2011-08-24 13:27:51 -0400 (Wed, 24 Aug 2011)
New Revision: 34233
Modified:
branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java
Log:
JBIDE-9516 - worked around jar detection issue with the jaxrs-api jar
Modified: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java 2011-08-24 16:56:36 UTC (rev 34232)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java 2011-08-24 17:27:51 UTC (rev 34233)
@@ -29,7 +29,6 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.jboss.tools.ws.core.utils.StatusUtils;
-import org.jboss.tools.ws.creation.core.JBossWSCreationCorePlugin;
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
/**
@@ -39,7 +38,8 @@
public class RestEasyLibUtils {
private static final String REST_EASY = "RestEasy"; //$NON-NLS-1$
- private static final String JAXRS_API_JAR = "jaxrs-api.jar"; //$NON-NLS-1$
+ private static final String JAXRS_API_PREFIX = "jaxrs-api"; //$NON-NLS-1$
+ private static final String JAXRS_API_POSTFIX = ".jar"; //$NON-NLS-1$
private static final String LIB = "lib"; //$NON-NLS-1$
/**
@@ -105,7 +105,7 @@
if (libDir.exists() && libDir.isDirectory()) {
File[] jars = libDir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
- if (name.equalsIgnoreCase(JAXRS_API_JAR)) {
+ if (name.startsWith(JAXRS_API_PREFIX) && name.endsWith(JAXRS_API_POSTFIX)) {
return true;
}
return false;
14 years, 7 months
JBoss Tools SVN: r34230 - trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-08-24 12:27:46 -0400 (Wed, 24 Aug 2011)
New Revision: 34230
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaClassEntity.java
Log:
Fix for build compilation errors:
JavaClassEntity classEntity = new JavaClassEntity();
[ERROR] ^^^^^^^^^^^^^^^^^^^^^
[ERROR] The constructor JavaClassEntity() is undefined
Empty constructor restored for JavaClassEntity.
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaClassEntity.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaClassEntity.java 2011-08-24 15:13:39 UTC (rev 34229)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaClassEntity.java 2011-08-24 16:27:46 UTC (rev 34230)
@@ -20,6 +20,9 @@
private String className = "";
private String packageName = "";
+ public JavaClassEntity() {
+ }
+
public JavaClassEntity(String packageName, String className) {
this.className = className;
this.packageName = packageName;
14 years, 7 months
JBoss Tools SVN: r34229 - trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/util.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-08-24 11:13:39 -0400 (Wed, 24 Aug 2011)
New Revision: 34229
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/util/TestRepository.java
Log:
[JBIDE-9575] implementing test for push to remote by name
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/util/TestRepository.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/util/TestRepository.java 2011-08-24 15:08:34 UTC (rev 34228)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.egit.test/src/org/jboss/ide/eclipse/as/egit/internal/test/util/TestRepository.java 2011-08-24 15:13:39 UTC (rev 34229)
@@ -68,6 +68,8 @@
String workdirPrefix;
+ private File gitDir;
+
/**
* Creates a new test repository
*
@@ -79,15 +81,22 @@
tmpRepository.create();
tmpRepository.close();
// use repository instance from RepositoryCache!
- repository = Activator.getDefault().getRepositoryCache().lookupRepository(gitDir);
+ this.gitDir = gitDir;
+ this.repository = Activator.getDefault().getRepositoryCache().lookupRepository(gitDir);
+ this.workdirPrefix = getWorkdirPrefix(repository);
+ workdirPrefix = workdirPrefix.replace('\\', '/');
+ if (!workdirPrefix.endsWith("/")) //$NON-NLS-1$
+ workdirPrefix += "/"; //$NON-NLS-1$
+ }
+
+ private String getWorkdirPrefix(Repository repository) {
+ String workdirPrefix = repository.getWorkTree().getAbsolutePath();
try {
workdirPrefix = repository.getWorkTree().getCanonicalPath();
} catch (IOException err) {
- workdirPrefix = repository.getWorkTree().getAbsolutePath();
+ // ignore;
}
- workdirPrefix = workdirPrefix.replace('\\', '/');
- if (!workdirPrefix.endsWith("/")) //$NON-NLS-1$
- workdirPrefix += "/"; //$NON-NLS-1$
+ return workdirPrefix;
}
/**
@@ -560,4 +569,8 @@
SystemReader.setInstance(mockSystemReader);
mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY, ceilingPath.toOSString());
}
+
+ public File getGitDir() {
+ return gitDir;
+ }
}
14 years, 7 months
JBoss Tools SVN: r34228 - trunk/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-08-24 11:08:34 -0400 (Wed, 24 Aug 2011)
New Revision: 34228
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java
Log:
[JBIDE-9575] using default remote name if there's no current branch or no remote configured to the current branch.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java 2011-08-24 14:18:12 UTC (rev 34227)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java 2011-08-24 15:08:34 UTC (rev 34228)
@@ -366,7 +366,9 @@
}
/**
- * Returns the name of the remote repository of the given branch.
+ * Returns the name of the remote repository of the given branch. If there's
+ * no current branch or no remote configured to it, the default remote is
+ * returned ("origin").
*
* @param branch
* the branch
@@ -383,6 +385,11 @@
ConfigConstants.CONFIG_BRANCH_SECTION, branch,
ConfigConstants.CONFIG_REMOTE_SECTION);
}
+
+ if (remoteName == null) {
+ remoteName = Constants.DEFAULT_REMOTE_NAME;
+ }
+
return remoteName;
}
14 years, 7 months
JBoss Tools SVN: r34227 - trunk/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-08-24 10:18:12 -0400 (Wed, 24 Aug 2011)
New Revision: 34227
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java
Log:
[JBIDE-9575] added #push(String remote, Repository repository) to be able to push to a given remote
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java 2011-08-24 13:35:52 UTC (rev 34226)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.egit.core/src/org/jboss/ide/eclipse/as/egit/core/EGitUtils.java 2011-08-24 14:18:12 UTC (rev 34227)
@@ -67,7 +67,8 @@
*/
Repository repository = getRepository(project);
if (repository == null) {
- throw new CoreException(createStatus(null, "Could not commit. Project \"{0}\" is not attached to a git repo", project.getName()));
+ throw new CoreException(createStatus(null,
+ "Could not commit. Project \"{0}\" is not attached to a git repo", project.getName()));
}
UserConfig userConfig = getUserConfig(repository);
CommitOperation op = new CommitOperation(
@@ -83,24 +84,25 @@
}
/**
- * Pushes the given repository to it's configured remote.
+ * Pushes the given repository to the remote repository it's current branch
+ * originates from.
*
* @param repository
- * the source repository
+ * the repository that shall be pushed
* @param monitor
- * the monitor
+ * the monitor to report progress to
* @throws CoreException
- * the core exception
+ * core exception is thrown if the push could not be executed
*/
public static void push(Repository repository, IProgressMonitor monitor)
throws CoreException {
try {
RemoteConfig remoteConfig = getRemoteConfig(repository);
if (remoteConfig == null) {
- throw new CoreException(createStatus(null, "Repository \"{0}\" has no remote repository configured", repository.toString()));
+ throw new CoreException(createStatus(null, "Repository \"{0}\" has no remote repository configured",
+ repository.toString()));
}
- PushOperation pop = createPushOperation(repository, remoteConfig);
- pop.run(monitor);
+ createPushOperation(remoteConfig, repository).run(monitor);
} catch (CoreException e) {
throw e;
} catch (Exception e) {
@@ -108,11 +110,38 @@
}
}
+ /**
+ * Pushes the given repository to the remote repo with the given name.
+ *
+ * @param remote
+ * @param repository
+ * @param monitor
+ * @throws CoreException
+ *
+ * @see git config file: "[remote..."
+ * @see #getAllRemoteConfigs(Repository)
+ * @see RemoteConfig#getName()
+ */
+ public static void push(String remote, Repository repository, IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ RemoteConfig remoteConfig = getRemoteConfig(remote, repository);
+ if (remoteConfig == null) {
+ throw new CoreException(createStatus(null,
+ "Repository \"{0}\" has no remote repository with the name \"{1}\"",
+ repository.toString(), remote));
+ }
+ createPushOperation(remote, repository).run(monitor);
+ } catch (Exception e) {
+ throw new CoreException(createStatus(e, "Could not push repo {0}", repository.toString()));
+ }
+ }
+
private static PushOperation createPushOperation(String remoteName, Repository repository) {
return new PushOperation(repository, remoteName, false, PUSH_TIMEOUT);
}
- private static PushOperation createPushOperation(Repository repository, RemoteConfig remoteConfig)
+ private static PushOperation createPushOperation(RemoteConfig remoteConfig, Repository repository)
throws CoreException {
PushOperationSpecification spec = new PushOperationSpecification();
@@ -144,9 +173,11 @@
spec.addURIRefUpdates(uri,
Transport.open(repository, uri).findRemoteRefUpdatesFor(pushRefSpecs));
} catch (NotSupportedException e) {
- throw new CoreException(createStatus(e, "Could not connect repository \"{0}\" to a remote", repository.toString()));
+ throw new CoreException(createStatus(e, "Could not connect repository \"{0}\" to a remote",
+ repository.toString()));
} catch (IOException e) {
- throw new CoreException(createStatus(e, "Could not convert remote specifications for repository \"{0}\" to a remote",
+ throw new CoreException(createStatus(e,
+ "Could not convert remote specifications for repository \"{0}\" to a remote",
repository.toString()));
}
}
@@ -194,7 +225,7 @@
*/
public static Repository getRepository(IProject project) {
Assert.isLegal(project != null, "Could not get repository. No project provided");
-
+
RepositoryMapping repositoryMapping = RepositoryMapping.getMapping(project);
if (repositoryMapping == null) {
return null;
@@ -208,7 +239,7 @@
*
* @param repository
* the repository
- * @return the user configuration
+ * @return the user configuration
* @throws CoreException
*
* @see PersonIdent(Repository)
@@ -218,8 +249,9 @@
Assert.isLegal(repository != null, "Could not get user configuration. No repository provided.");
if (repository.getConfig() == null) {
- throw new CoreException(createStatus(null, "no user configuration (author, committer) are present in repository \"{0}\"",
- repository.toString()));
+ throw new CoreException(createStatus(null,
+ "no user configuration (author, committer) are present in repository \"{0}\"",
+ repository.toString()));
}
return repository.getConfig().get(UserConfig.KEY);
}
@@ -241,26 +273,41 @@
*/
private static RemoteConfig getRemoteConfig(Repository repository) throws CoreException {
Assert.isLegal(repository != null, "Could not get configuration. No repository provided.");
-
- String branch = getBranch(repository);
- String remoteName = getRemoteName(repository, branch);
+
+ String currentBranch = getCurrentBranch(repository);
+ String remote = getRemoteName(currentBranch, repository);
+ return getRemoteConfig(remote, repository);
+ }
+
+ /**
+ * Returns the remote config for the given remote in the given repository
+ *
+ * @param remote
+ * @param repository
+ * @return
+ * @throws CoreException
+ */
+ private static RemoteConfig getRemoteConfig(String remote, Repository repository) throws CoreException {
+ Assert.isLegal(repository != null, "Could not get configuration. No repository provided.");
+
List<RemoteConfig> allRemotes = getAllRemoteConfigs(repository);
- return getRemoteConfig(remoteName, allRemotes);
+ return getRemoteConfig(remote, allRemotes);
}
- private static String getBranch(Repository repository) throws CoreException {
+ private static String getCurrentBranch(Repository repository) throws CoreException {
String branch = null;
try {
branch = repository.getBranch();
} catch (IOException e) {
- throw new CoreException(createStatus(e, "Could not get branch on repository \"{0}\"", repository.toString()));
+ throw new CoreException(createStatus(e, "Could not get current branch on repository \"{0}\"",
+ repository.toString()));
}
return branch;
}
/**
* Gets the remote config with the given name from the list of remote
- * repositories. Return the origin if none with the given name was found.
+ * repositories. Returns <code>null</code> if it was not found.
*
* @param remoteName
* the remote name
@@ -272,8 +319,8 @@
RemoteConfig defaultConfig = null;
RemoteConfig configuredConfig = null;
for (RemoteConfig config : remoteRepositories) {
- if (config.getName().equals(Constants.DEFAULT_REMOTE_NAME))
- defaultConfig = config;
+ // if (config.getName().equals(Constants.DEFAULT_REMOTE_NAME))
+ // defaultConfig = config;
if (remoteName != null && config.getName().equals(remoteName))
configuredConfig = config;
}
@@ -285,35 +332,49 @@
}
/**
- * Gets the remote configs from the given repository.
+ * Returns all the remote configs from the given repository.
*
* @param repository
- * the repository
- * @return the remote configs
- * @throws CoreException
+ * the repository to retrieve the remote configs of
+ * @return the remote configs that are available on the repository
+ * @throws CoreException
*/
public static List<RemoteConfig> getAllRemoteConfigs(Repository repository) throws CoreException {
try {
return RemoteConfig.getAllRemoteConfigs(repository.getConfig());
} catch (URISyntaxException e) {
- throw new CoreException(createStatus(e, "Could not get all remote repositories for repository \"{0}\"", repository.toString()));
+ throw new CoreException(createStatus(e, "Could not get all remote repositories for repository \"{0}\"",
+ repository.toString()));
}
}
- public static boolean hasMultipleRemoteConfigs(Repository repository) throws CoreException {
+ /**
+ * Returns <code>true</code> if the given repository has several configured
+ * remotes
+ *
+ * @param repository
+ * @return
+ * @throws CoreException
+ *
+ * @see git config file: "[remote..."
+ * @see #getAllRemoteConfigs
+ * @see RemoteConfig#getAllRemoteConfigs
+ *
+ */
+ public static boolean hasMultipleRemotes(Repository repository) throws CoreException {
return getAllRemoteConfigs(repository).size() > 1;
}
-
+
/**
- * Gets the name of the remote repository for a given repository and branch.
+ * Returns the name of the remote repository of the given branch.
*
+ * @param branch
+ * the branch
* @param repository
* the repository
- * @param branch
- * the branch
* @return the remote name
*/
- private static String getRemoteName(Repository repository, String branch) {
+ private static String getRemoteName(String branch, Repository repository) {
String remoteName = null;
if (ObjectId.isId(branch)) {
remoteName = Constants.DEFAULT_REMOTE_NAME;
@@ -324,7 +385,7 @@
}
return remoteName;
}
-
+
private static IStatus createStatus(Exception e, String message, String... arguments) throws CoreException {
IStatus status = null;
if (e == null) {
14 years, 7 months
JBoss Tools SVN: r34226 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal: details and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-08-24 09:35:52 -0400 (Wed, 24 Aug 2011)
New Revision: 34226
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/Messages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/PackageInfoDetailsPage.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/java/JavaPackageInfoDetailsProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/messages.properties
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/java/PackageInfoResourceUIDefinition.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/HibernateJpa2_0PlatformUiProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/HibernateJpaPlatformUiProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java
Log:
https://issues.jboss.org/browse/JBIDE-9436
create ui for package-info.java annotations in JPA Details view
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/HibernateJpa2_0PlatformUiProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/HibernateJpa2_0PlatformUiProvider.java 2011-08-24 13:13:46 UTC (rev 34225)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/HibernateJpa2_0PlatformUiProvider.java 2011-08-24 13:35:52 UTC (rev 34226)
@@ -22,8 +22,10 @@
import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmPersistentAttributeDetailsProvider;
import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmPersistentTypeDetailsProvider;
import org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm.EntityMappings2_0DetailsProvider;
+import org.jboss.tools.hibernate.jpt.ui.internal.details.java.JavaPackageInfoDetailsProvider;
import org.jboss.tools.hibernate.jpt.ui.internal.jpa2.mapping.details.orm.Hibernate2_0OrmXmlUiDefinition;
import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.java.Hibernate2_0JavaResourceUiDefinition;
+import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.java.PackageInfoResourceUIDefinition;
import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.orm.HibernateOrmXmlUiDefinition;
import org.jboss.tools.hibernate.jpt.ui.internal.persistence.details.HibernatePersistenceXmlUiDefinition;
import org.jboss.tools.hibernate.jpt.ui.internal.persistence.details.jpa2.HibernatePersistenceXml2_0UiDefinition;
@@ -56,6 +58,7 @@
@Override
protected void addDetailsProvidersTo(List<JpaDetailsProvider> providers) {
+ providers.add(JavaPackageInfoDetailsProvider.instance());
providers.add(JavaPersistentTypeDetailsProvider.instance());
providers.add(JavaPersistentAttributeDetailsProvider.instance());
providers.add(EntityMappingsDetailsProvider.instance());
@@ -69,6 +72,7 @@
@Override
protected void addResourceUiDefinitionsTo(
List<ResourceUiDefinition> definitions) {
+ definitions.add(PackageInfoResourceUIDefinition.instance());
definitions.add(Hibernate2_0JavaResourceUiDefinition.instance());
definitions.add(HibernateOrmXmlUiDefinition.instance());
definitions.add(Hibernate2_0OrmXmlUiDefinition.instance());
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/HibernateJpaPlatformUiProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/HibernateJpaPlatformUiProvider.java 2011-08-24 13:13:46 UTC (rev 34225)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/HibernateJpaPlatformUiProvider.java 2011-08-24 13:35:52 UTC (rev 34226)
@@ -23,7 +23,9 @@
import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmPersistentAttributeDetailsProvider;
import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmPersistentTypeDetailsProvider;
import org.eclipse.jpt.jpa.ui.internal.platform.generic.GenericNavigatorProvider;
+import org.jboss.tools.hibernate.jpt.ui.internal.details.java.JavaPackageInfoDetailsProvider;
import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.java.HibernateJavaResourceUiDefinition;
+import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.java.PackageInfoResourceUIDefinition;
import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.orm.HibernateOrmXmlUiDefinition;
import org.jboss.tools.hibernate.jpt.ui.internal.persistence.details.HibernatePersistenceXmlUiDefinition;
import org.jboss.tools.hibernate.jpt.ui.internal.platform.HibernateJpaPlatformUi;
@@ -64,6 +66,7 @@
@Override
protected void addDetailsProvidersTo(List<JpaDetailsProvider> providers) {
+ providers.add(JavaPackageInfoDetailsProvider.instance());
providers.add(JavaPersistentTypeDetailsProvider.instance());
providers.add(JavaPersistentAttributeDetailsProvider.instance());
providers.add(EntityMappingsDetailsProvider.instance());
@@ -75,10 +78,11 @@
// ********** resource ui definitions **********
@Override
- protected void addResourceUiDefinitionsTo(List<ResourceUiDefinition> defintions) {
- defintions.add(HibernateJavaResourceUiDefinition.instance());
- defintions.add(HibernateOrmXmlUiDefinition.instance());
- defintions.add(HibernatePersistenceXmlUiDefinition.instance());
+ protected void addResourceUiDefinitionsTo(List<ResourceUiDefinition> definitions) {
+ definitions.add(PackageInfoResourceUIDefinition.instance());
+ definitions.add(HibernateJavaResourceUiDefinition.instance());
+ definitions.add(HibernateOrmXmlUiDefinition.instance());
+ definitions.add(HibernatePersistenceXmlUiDefinition.instance());
}
}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/Messages.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/Messages.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/Messages.java 2011-08-24 13:35:52 UTC (rev 34226)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.details;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.jboss.tools.hibernate.jpt.ui.internal.details.messages"; //$NON-NLS-1$
+ public static String PackageInfoDetailsPage_GenericGeneratorsSection;
+ public static String PackageInfoDetailsPage_QueriesSection;
+ public static String PackageInfoDetailsPage_TypeDefinitionsSection;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/PackageInfoDetailsPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/PackageInfoDetailsPage.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/PackageInfoDetailsPage.java 2011-08-24 13:35:52 UTC (rev 34226)
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.details;
+
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.ui.internal.util.PaneEnabler;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.jpt.jpa.ui.internal.details.AbstractJpaDetailsPage;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateGeneratorContainer;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaQueryContainer;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaTypeDefContainer;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernatePackageInfo;
+import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.GenericGeneratorsComposite;
+import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateQueriesComposite;
+import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.TypeDefsComposite;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class PackageInfoDetailsPage extends AbstractJpaDetailsPage<HibernatePackageInfo> {
+
+ /**
+ * @param parent
+ * @param widgetFactory
+ */
+ public PackageInfoDetailsPage(Composite parent,
+ WidgetFactory widgetFactory) {
+ super(parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ this.initializeQueriesCollapsibleSection(container);
+ this.initializeGenericGeneratorsCollapsibleSection(container);
+ this.initializeTypeDefCollapsibleSection(container);
+ new PaneEnabler(buildWidgetsEnabledHolder(), this);
+ }
+
+ protected WritablePropertyValueModel<Boolean> buildWidgetsEnabledHolder() {
+ return new PropertyAspectAdapter<HibernatePackageInfo, Boolean>(getSubjectHolder()) {
+ @Override
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(this.subject != null);
+ }
+ };
+ }
+
+ protected void initializeGenericGeneratorsCollapsibleSection(Composite container) {
+ container = addCollapsibleSection(
+ container,
+ Messages.PackageInfoDetailsPage_GenericGeneratorsSection);
+ this.initializeGenericGeneratorsSection(container, buildGeneratorContainerHolder());
+ }
+
+ private PropertyValueModel<HibernateGeneratorContainer> buildGeneratorContainerHolder() {
+ return new PropertyAspectAdapter<HibernatePackageInfo, HibernateGeneratorContainer>(getSubjectHolder()) {
+ @Override
+ protected HibernateGeneratorContainer buildValue_() {
+ return (HibernateGeneratorContainer)this.subject.getGeneratorContainer();
+ }
+ };
+ }
+
+ protected void initializeGenericGeneratorsSection(Composite container, PropertyValueModel<HibernateGeneratorContainer> generatorContainerHolder) {
+ new GenericGeneratorsComposite(this, generatorContainerHolder, container);
+ }
+
+ protected void initializeQueriesCollapsibleSection(Composite container) {
+ container = addCollapsibleSection(
+ container,
+ Messages.PackageInfoDetailsPage_QueriesSection);
+ this.initializeQueriesSection(container, buildQueryContainerHolder());
+ }
+
+ private PropertyValueModel<HibernateJavaQueryContainer> buildQueryContainerHolder() {
+ return new PropertyAspectAdapter<HibernatePackageInfo, HibernateJavaQueryContainer>(getSubjectHolder()) {
+ @Override
+ protected HibernateJavaQueryContainer buildValue_() {
+ return (HibernateJavaQueryContainer)this.subject.getQueryContainer();
+ }
+ };
+ }
+
+ protected void initializeQueriesSection(Composite container, PropertyValueModel<HibernateJavaQueryContainer> queryContainerHolder) {
+ new HibernateQueriesComposite(this, queryContainerHolder, container);
+ }
+
+ protected void initializeTypeDefCollapsibleSection(Composite container) {
+ container = addCollapsibleSection(
+ container,
+ Messages.PackageInfoDetailsPage_TypeDefinitionsSection);
+ this.initializeTypeDefsSection(container, buildTypeDefContainerHolder());
+ }
+
+ protected void initializeTypeDefsSection(
+ Composite container,
+ PropertyValueModel<HibernateJavaTypeDefContainer> typeDefContainerHolder) {
+ new TypeDefsComposite(this, typeDefContainerHolder, container);
+ }
+
+ private PropertyValueModel<HibernateJavaTypeDefContainer> buildTypeDefContainerHolder() {
+ return new PropertyAspectAdapter<HibernatePackageInfo, HibernateJavaTypeDefContainer>(getSubjectHolder()) {
+
+ @Override
+ protected HibernateJavaTypeDefContainer buildValue_() {
+ return this.subject.getTypeDefContainer();
+ }
+ };
+ }
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/java/JavaPackageInfoDetailsProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/java/JavaPackageInfoDetailsProvider.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/java/JavaPackageInfoDetailsProvider.java 2011-08-24 13:35:52 UTC (rev 34226)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.details.java;
+
+import org.eclipse.jpt.common.core.JptCommonCorePlugin;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.Tools;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.java.JavaStructureNodes;
+import org.eclipse.jpt.jpa.ui.details.JpaDetailsPage;
+import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernatePackageInfo;
+import org.jboss.tools.hibernate.jpt.ui.internal.details.PackageInfoDetailsPage;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class JavaPackageInfoDetailsProvider implements JpaDetailsProvider {
+
+ // singleton
+ private static final JpaDetailsProvider INSTANCE = new JavaPackageInfoDetailsProvider();
+
+
+ /**
+ * Return the singleton
+ */
+ public static JpaDetailsProvider instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaPackageInfoDetailsProvider() {
+ super();
+ }
+
+
+ public boolean providesDetails(JpaStructureNode structureNode) {
+ return Tools.valuesAreEqual(structureNode.getId(), JavaStructureNodes.COMPILATION_UNIT_ID)
+ && structureNode.getResourceType().getContentType().equals(JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE);
+ }
+
+ public JpaDetailsPage<HibernatePackageInfo> buildDetailsPage(
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ return new PackageInfoDetailsPage(parent, widgetFactory);
+ }
+
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/messages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/messages.properties (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/details/messages.properties 2011-08-24 13:35:52 UTC (rev 34226)
@@ -0,0 +1,3 @@
+PackageInfoDetailsPage_GenericGeneratorsSection=Generic Generators
+PackageInfoDetailsPage_QueriesSection=Queries
+PackageInfoDetailsPage_TypeDefinitionsSection=Type Definitions
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java 2011-08-24 13:13:46 UTC (rev 34225)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java 2011-08-24 13:35:52 UTC (rev 34226)
@@ -43,6 +43,8 @@
public static final String NAMED_QUERY = "namedQuery"; //$NON-NLS-1$
public static final String NAMED_NATIVE_QUERY = "namedNativeQuery"; //$NON-NLS-1$
+
+ private boolean hibernateOnly;
/**
@@ -53,10 +55,14 @@
/**
* Use this constructor to edit an existing conversion value
+ * @param hibernateOnly shows that only @org.hibernate.annotations.NamedQuery
+ * and @org.hibernate.annotations.NamedNativeQuery
+ * could be added.
*/
- public HibernateAddQueryDialog(Shell parent, PersistenceUnit pUnit) {
+ public HibernateAddQueryDialog(Shell parent, PersistenceUnit pUnit, boolean hibernateOnly) {
super(parent);
this.pUnit = pUnit;
+ this.hibernateOnly = hibernateOnly;
}
@Override
@@ -146,8 +152,10 @@
protected ListValueModel<String> buildQueryTypeListHolder() {
List<String> queryTypes = new ArrayList<String>();
- queryTypes.add(NAMED_QUERY);
- queryTypes.add(NAMED_NATIVE_QUERY);
+ if (!hibernateOnly){
+ queryTypes.add(NAMED_QUERY);
+ queryTypes.add(NAMED_NATIVE_QUERY);
+ }
queryTypes.add(HibernateNamedQuery.HIBERNATE_NAMED_QUERY);
queryTypes.add(HibernateNamedNativeQuery.HIBERNATE_NAMED_NATIVE_QUERY);
return new StaticListValueModel<String>(queryTypes);
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java 2011-08-24 13:13:46 UTC (rev 34225)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java 2011-08-24 13:35:52 UTC (rev 34226)
@@ -51,6 +51,7 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaNamedNativeQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaNamedQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaQueryContainer;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernatePackageInfo;
/**
* @author Dmitry Geraskov
@@ -83,7 +84,8 @@
}
protected HibernateAddQueryDialog buildAddQueryDialog() {
- return new HibernateAddQueryDialog(getControl().getShell(), this.getSubject().getPersistenceUnit());
+ boolean hibernateOnly = (getSubject().getParent() instanceof HibernatePackageInfo);
+ return new HibernateAddQueryDialog(getControl().getShell(), this.getSubject().getPersistenceUnit(), hibernateOnly);
}
protected void addQueryFromDialog(HibernateAddQueryDialog hibernateAddQueryDialog) {
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/java/PackageInfoResourceUIDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/java/PackageInfoResourceUIDefinition.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/java/PackageInfoResourceUIDefinition.java 2011-08-24 13:35:52 UTC (rev 34226)
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.java;
+
+import java.util.Iterator;
+
+import org.eclipse.jpt.common.core.JptCommonCorePlugin;
+import org.eclipse.jpt.common.core.JptResourceType;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.TypeMapping;
+import org.eclipse.jpt.jpa.ui.MappingResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition;
+import org.eclipse.jpt.jpa.ui.details.JpaComposite;
+import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition;
+import org.eclipse.jpt.jpa.ui.structure.JpaStructureProvider;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Dmitry Geraskov
+ * The provider provides empty ui for Structure view for package-info.java
+ */
+public class PackageInfoResourceUIDefinition implements
+ MappingResourceUiDefinition {
+
+ private static final JpaStructureProvider EMPTY = null;
+
+ // singleton
+ private static final ResourceUiDefinition INSTANCE = new PackageInfoResourceUIDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static ResourceUiDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Enforce singleton usage
+ */
+ private PackageInfoResourceUIDefinition() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.jpa.ui.ResourceUiDefinition#providesUi(org.eclipse.jpt.common.core.JptResourceType)
+ */
+ @Override
+ public boolean providesUi(JptResourceType resourceType) {
+ return resourceType.equals(JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.jpa.ui.ResourceUiDefinition#getStructureProvider()
+ */
+ @Override
+ public JpaStructureProvider getStructureProvider() {
+ return EMPTY;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.jpa.ui.MappingResourceUiDefinition#buildAttributeMappingComposite(java.lang.String, org.eclipse.jpt.common.utility.model.value.PropertyValueModel, org.eclipse.swt.widgets.Composite, org.eclipse.jpt.common.ui.WidgetFactory)
+ */
+ @Override
+ public JpaComposite buildAttributeMappingComposite(String key,
+ PropertyValueModel<AttributeMapping> mappingHolder,
+ Composite parent, WidgetFactory widgetFactory) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.jpa.ui.MappingResourceUiDefinition#attributeMappingUiDefinitions()
+ */
+ @Override
+ public Iterator<MappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping>> attributeMappingUiDefinitions() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.jpa.ui.MappingResourceUiDefinition#getDefaultAttributeMappingUiDefinition(java.lang.String)
+ */
+ @Override
+ public DefaultMappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping> getDefaultAttributeMappingUiDefinition(
+ String key) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.jpa.ui.MappingResourceUiDefinition#buildTypeMappingComposite(java.lang.String, org.eclipse.jpt.common.utility.model.value.PropertyValueModel, org.eclipse.swt.widgets.Composite, org.eclipse.jpt.common.ui.WidgetFactory)
+ */
+ @Override
+ public JpaComposite buildTypeMappingComposite(String key,
+ PropertyValueModel<TypeMapping> mappingHolder, Composite parent,
+ WidgetFactory widgetFactory) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.jpa.ui.MappingResourceUiDefinition#typeMappingUiDefinitions()
+ */
+ @Override
+ public Iterator<MappingUiDefinition<PersistentType, ? extends TypeMapping>> typeMappingUiDefinitions() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jpt.jpa.ui.MappingResourceUiDefinition#getDefaultTypeMappingUiDefinition()
+ */
+ @Override
+ public DefaultMappingUiDefinition<PersistentType, ? extends TypeMapping> getDefaultTypeMappingUiDefinition() {
+ return null;
+ }
+
+}
14 years, 7 months