Author: rob.stryker(a)jboss.com
Date: 2011-12-22 09:03:51 -0500 (Thu, 22 Dec 2011)
New Revision: 37526
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressMessages.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/expressMessages.properties
Removed:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitBehaviourDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitPublishMethod.java
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitPublisher.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
Log:
JBIDE-10541 Cleanup, string externalize, allow possibility of server-based or
workspace-global preferences for what should get added during a publish
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2011-12-22
13:54:34 UTC (rev 37525)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2011-12-22
14:03:51 UTC (rev 37526)
@@ -19,7 +19,9 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
@@ -59,6 +61,7 @@
import org.eclipse.jgit.transport.URIish;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.wst.server.core.IServer;
import org.jboss.tools.openshift.egit.core.internal.EGitCoreActivator;
/**
@@ -684,26 +687,70 @@
return status;
}
- public static int countCommitableChanges(IProject project, IProgressMonitor monitor) {
+ public static int countCommitableChanges(IProject project, IServer server,
IProgressMonitor monitor) {
try {
- Repository repo = getRepository(project);
-
- EclipseGitProgressTransformer jgitMonitor = new
EclipseGitProgressTransformer(monitor);
- IndexDiff indexDiff = new IndexDiff(repo, Constants.HEAD,
- IteratorService.createInitialIterator(repo));
- indexDiff.diff(jgitMonitor, 0, 0, NLS.bind(
- UIText.CommitActionHandler_repository, repo.getDirectory().getPath()));
- // System.out.println(indexDiff.getAdded().size());
- // System.out.println(indexDiff.getChanged().size());
- // System.out.println(indexDiff.getConflicting().size());
- // System.out.println(indexDiff.getMissing().size());
- // System.out.println(indexDiff.getModified().size());
- // System.out.println(indexDiff.getRemoved().size());
- // System.out.println(indexDiff.getUntracked().size());
-
- return indexDiff.getModified().size();
+ Set<String> commitable = getCommitableChanges(project, server, monitor);
+ return commitable.size();
} catch (IOException ioe) {
}
return -1;
}
+
+ private static Set<String> getCommitableChanges(IProject project, IServer server,
IProgressMonitor monitor) throws IOException {
+ Repository repo = getRepository(project);
+
+ EclipseGitProgressTransformer jgitMonitor = new
EclipseGitProgressTransformer(monitor);
+ IndexDiff indexDiff = new IndexDiff(repo, Constants.HEAD,
+ IteratorService.createInitialIterator(repo));
+ indexDiff.diff(jgitMonitor, 0, 0, NLS.bind(
+ UIText.CommitActionHandler_repository, repo.getDirectory().getPath()));
+ Set<String> set = new HashSet<String>();
+ if( commitAddedResources(server))
+ set.addAll(indexDiff.getAdded());
+ if( commitChangedResources(server))
+ set.addAll(indexDiff.getChanged());
+ if( commitConflictingResources(server))
+ set.addAll(indexDiff.getConflicting());
+ if( commitMissingResources(server))
+ set.addAll(indexDiff.getMissing());
+ if( commitModifiedResources(server))
+ set.addAll(indexDiff.getModified());
+ if( commitRemovedResources(server))
+ set.addAll(indexDiff.getRemoved());
+ if( commitUntrackedResources(server))
+ set.addAll(indexDiff.getUntracked());
+
+ return set;
+ }
+
+ /*
+ * Current behaviour is to commit only:
+ * added, changed, modified, removed
+ *
+ * These can be customized as properties on the server one day, if we wish,
+ * such that each server can have custom settings, or, they can be global settings
+ */
+ public static boolean commitAddedResources(IServer server) {
+ return true;
+ }
+ public static boolean commitChangedResources(IServer server) {
+ return true;
+ }
+ public static boolean commitConflictingResources(IServer server) {
+ return false;
+ }
+ public static boolean commitMissingResources(IServer server) {
+ return false;
+ }
+ public static boolean commitModifiedResources(IServer server) {
+ return true;
+ }
+ public static boolean commitRemovedResources(IServer server) {
+ return true;
+ }
+ public static boolean commitUntrackedResources(IServer server) {
+ return false;
+ }
+
+
}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitBehaviourDelegate.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitBehaviourDelegate.java 2011-12-22
13:54:34 UTC (rev 37525)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitBehaviourDelegate.java 2011-12-22
14:03:51 UTC (rev 37526)
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.openshift.egit.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
-import org.jboss.ide.eclipse.as.core.server.internal.IJBossBehaviourDelegate;
-
-public class EgitBehaviourDelegate implements IJBossBehaviourDelegate {
-
- public static final String ID = "egit";
-
- @Override
- public String getBehaviourTypeId() {
- return ID;
- }
-
- @Override
- public void setActualBehaviour(DelegatingServerBehavior actualBehaviour) {
- }
-
- @Override
- public void stop(boolean force) {
- }
-
- @Override
- public void publishStart(IProgressMonitor monitor) throws CoreException {
- }
-
- @Override
- public void publishFinish(IProgressMonitor monitor) throws CoreException {
- }
-
- @Override
- public void onServerStarting() {
- // do nothing
- }
-
- @Override
- public void onServerStopping() {
- // do nothing
- }
-
- @Override
- public IStatus canChangeState(String launchMode) {
- // do nothing
- return Status.OK_STATUS;
- }
-
- /**
- * remove from interface
- */
- @Override
- public String getDefaultStopArguments() throws CoreException {
- return null;
- }
-
- @Override
- public void dispose() {
- // do nothing
- }
-
- @Override
- public void onServerStarted() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onServerStopped() {
- // TODO Auto-generated method stub
-
- }
-
-}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitPublishMethod.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitPublishMethod.java 2011-12-22
13:54:34 UTC (rev 37525)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitPublishMethod.java 2011-12-22
14:03:51 UTC (rev 37526)
@@ -1,49 +0,0 @@
-package org.jboss.tools.openshift.egit.core;
-
-
-public class EgitPublishMethod { /*
- implements IJBossServerPublishMethod {
-
- public String getPublishMethodId() {
- return EgitBehaviourDelegate.ID;
- }
-
- @Override
- public void publishStart(DeployableServerBehavior behaviour,
- IProgressMonitor monitor) throws CoreException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public int publishFinish(DeployableServerBehavior behaviour,
- IProgressMonitor monitor) throws CoreException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public int publishModule(DeployableServerBehavior behaviour, int kind,
- int deltaKind, IModule[] module, IProgressMonitor monitor)
- throws CoreException {
- // TODO Auto-generated method stub
- IProject project = module[0].getProject();
- EGitUtils.commit(project, monitor);
- EGitUtils.push(EGitUtils.getRepository(project), monitor);
- return IServer.PUBLISH_STATE_NONE;
- }
-
- @Override
- public IPublishCopyCallbackHandler getCallbackHandler(IPath path,
- IServer server) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getPublishDefaultRootFolder(IServer server) {
- // TODO Auto-generated method stub
- return null;
- }
- */
-}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitPublisher.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitPublisher.java 2011-12-22
13:54:34 UTC (rev 37525)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EgitPublisher.java 2011-12-22
14:03:51 UTC (rev 37526)
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.openshift.egit.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
-
-public class EgitPublisher implements IJBossServerPublisher {
-
- @Override
- public boolean accepts(String method, IServer server, IModule[] module) {
- return false;
- }
-
- @Override
- public int getPublishState() {
- return 0;
- }
-
- @Override
- public IStatus publishModule(IJBossServerPublishMethod method, IServer server, IModule[]
module, int publishType,
- IModuleResourceDelta[] delta, IProgressMonitor monitor) throws CoreException {
- return null;
- }
-
-}
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressMessages.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressMessages.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressMessages.java 2011-12-22
14:03:51 UTC (rev 37526)
@@ -0,0 +1,17 @@
+package org.jboss.tools.openshift.express.internal.core.behaviour;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ExpressMessages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.openshift.express.internal.core.behaviour.expressMessages";
//$NON-NLS-1$
+
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, ExpressMessages.class);
+ }
+ public static String requestCommitAndPushTitle;
+ public static String requestCommitAndPushMsg;
+ public static String requestPushTitle;
+ public static String requestPushMsg;
+
+}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2011-12-22
13:54:34 UTC (rev 37525)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2011-12-22
14:03:51 UTC (rev 37526)
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;
@@ -93,7 +94,7 @@
return IServer.PUBLISH_STATE_UNKNOWN;
}
- int changed = EGitUtils.countCommitableChanges(p, new NullProgressMonitor() );
+ int changed = EGitUtils.countCommitableChanges(p, behaviour.getServer(), new
NullProgressMonitor() );
if( changed != 0 && requestCommitAndPushApproval(module, changed)) {
monitor.beginTask("Publishing " + p.getName(), 200);
EGitUtils.commit(p, new SubProgressMonitor(monitor, 100));
@@ -129,17 +130,15 @@
private boolean requestCommitAndPushApproval(final IModule[] module, int changed) {
String projName = module[module.length-1].getProject().getName();
- String msg = "There are " + changed + " local changes in \"" +
projName + "\". " +
- "Do you want to publish to OpenShift by commiting the changes and pushing its
Git repository?";
- String title = "Publish " + projName + "?";
+ String msg = NLS.bind(ExpressMessages.requestCommitAndPushMsg, changed, projName);
+ String title = NLS.bind(ExpressMessages.requestCommitAndPushTitle, projName);
return requestApproval(msg, title);
}
private boolean requestPushApproval(final IModule[] module) {
String projName = module[module.length-1].getProject().getName();
- String msg = "The are no local changes in \"" + projName +
"\". " +
- "Do you want to publish to OpenShift by pushing its Git repository?";
- String title = "Publish " + projName + "?";
+ String msg = NLS.bind(ExpressMessages.requestPushMsg, projName);
+ String title = NLS.bind(ExpressMessages.requestPushTitle, projName);
return requestApproval(msg, title);
}
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/expressMessages.properties
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/expressMessages.properties
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/expressMessages.properties 2011-12-22
14:03:51 UTC (rev 37526)
@@ -0,0 +1,4 @@
+requestCommitAndPushTitle=Publish {0}?
+requestCommitAndPushMsg=There are {0} local changes in "{1}". Do you want to
publish to OpenShift by commiting the changes and pushing its Git repository?
+requestPushTitle=Publish {0}?
+requestPushMsg=The are no local changes in "{0}". Do you want to publish to
OpenShift by pushing its Git repository?