JBoss Tools SVN: r37973 - in trunk: common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-01-19 15:56:33 -0500 (Thu, 19 Jan 2012)
New Revision: 37973
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
Log:
Add the code which is supposed to be inserted by the Quick Fix into its description https://issues.jboss.org/browse/JBIDE-10636
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java 2012-01-19 20:41:24 UTC (rev 37972)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java 2012-01-19 20:56:33 UTC (rev 37973)
@@ -21,6 +21,7 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
+import org.eclipse.ltk.core.refactoring.TextChange;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.text.edits.MultiTextEdit;
@@ -29,12 +30,15 @@
import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.common.ui.CommonUIPlugin;
public class AddAnnotationMarkerResolution implements
IMarkerResolution2 {
private IJavaElement element;
private String qualifiedName;
private String label;
+ private String description;
public AddAnnotationMarkerResolution(IJavaElement element, String qualifiedName){
this.element = element;
@@ -63,6 +67,7 @@
}
label = NLS.bind(CDIUIMessages.ADD_ANNOTATION_MARKER_RESOLUTION_TITLE, new String[]{shortName, element.getElementName(), type});
+ description = getPreview();
}
@Override
@@ -76,15 +81,9 @@
ICompilationUnit original = CDIMarkerResolutionUtils.getJavaMember(element).getCompilationUnit();
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
- CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
+ CompilationUnitChange change = getChange(compilationUnit);
- MultiTextEdit edit = new MultiTextEdit();
-
- change.setEdit(edit);
-
- CDIMarkerResolutionUtils.addAnnotation(qualifiedName, compilationUnit, element, "", edit);
-
- if(edit.hasChildren()){
+ if(change.getEdit().hasChildren()){
change.perform(new NullProgressMonitor());
original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
}
@@ -94,9 +93,43 @@
}
}
+ private CompilationUnitChange getChange(ICompilationUnit compilationUnit) throws JavaModelException{
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
+
+ MultiTextEdit edit = new MultiTextEdit();
+
+ change.setEdit(edit);
+
+ CDIMarkerResolutionUtils.addAnnotation(qualifiedName, compilationUnit, element, "", edit);
+
+ return change;
+ }
+
+ private CompilationUnitChange getPreviewChange(){
+ try{
+ ICompilationUnit original = CDIMarkerResolutionUtils.getJavaMember(element).getCompilationUnit();
+
+ return getChange(original);
+ }catch(CoreException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ return null;
+ }
+
+ private String getPreview(){
+ TextChange previewChange = getPreviewChange();
+
+ try {
+ return MarkerResolutionUtils.getPreview(previewChange);
+ } catch (CoreException e) {
+ CommonUIPlugin.getDefault().logError(e);
+ }
+ return label;
+ }
+
@Override
public String getDescription() {
- return label;
+ return description;
}
@Override
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2012-01-19 20:41:24 UTC (rev 37972)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2012-01-19 20:56:33 UTC (rev 37973)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.refactoring;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -579,59 +580,171 @@
}
public static String getPreview(TextChange previewChange) throws CoreException{
+ if(previewChange == null)
+ return null;
+
String preview = previewChange.getPreviewContent(new NullProgressMonitor());
+
TextEdit edit = previewChange.getEdit();
- String text = null;
- if(edit instanceof InsertEdit){
- text = ((InsertEdit) edit).getText();
- }else if(edit instanceof ReplaceEdit){
- text = ((ReplaceEdit) edit).getText();
+
+ EditSet editSet = new EditSet(edit);
+
+ // select
+ preview = editSet.select(preview);
+
+ // cut
+ preview = editSet.cut(preview);
+
+ // format
+ preview = preview.replaceAll(NEW_LINE, LINE_BREAK);
+
+ return preview;
+ }
+
+ static class EditSet{
+ private ArrayList<TextEdit> edits = new ArrayList<TextEdit>();
+ private ArrayList<Region> regions = new ArrayList<Region>();
+
+ private int lastOffset = 0;
+
+ public EditSet(TextEdit edit){
+ addEdits(edit);
+ sort();
}
- if(edit != null && text != null){
- int offset = edit.getOffset();
- int length = text.length();
+
+ private void addEdits(TextEdit edit){
+ edits.add(edit);
+ for(TextEdit child : edit.getChildren()){
+ addEdits(child);
+ }
+ }
+
+ private void sort(){
+ }
+
+ private int getFirstOffset(){
+ if(edits.size() > 0){
+ return edits.get(0).getOffset();
+ }else{
+ return 0;
+ }
+ }
+
+ private int getLastOffset(){
+ return lastOffset;
+ }
+
+ public String select(String preview){
+ int delta = 0;
+ for(TextEdit edit : edits){
+ String text = null;
+ int addings = 0;
+ if(edit instanceof InsertEdit){
+ text = ((InsertEdit) edit).getText();
+ addings = text.length();
+ }else if(edit instanceof ReplaceEdit){
+ text = ((ReplaceEdit) edit).getText();
+ addings = text.length()-edit.getLength();
+ }
+ if(text != null){
+ int offset = edit.getOffset()+delta;
+ int length = text.length();
+ regions.add(new Region(offset, length));
+ lastOffset = offset+length;
+
+ // select
+ String before = preview.substring(0, offset);
+ String after = preview.substring(offset+length);
+ preview = before+OPEN_BOLD+text+CLOSE_BOLD+after;
+
+ delta += OPEN_BOLD.length()+CLOSE_BOLD.length()+addings;
+ }
+ }
+ return preview;
+ }
+
+ public String cut(String preview){
+ // process regions
+ Region prevRegion = null;
+ for(Region region : regions){
+ int position = region.offset;
+ int count = NUMBER_OF_STRINGS;
+ int lowLimit = 0;
+ if(prevRegion != null){
+ lowLimit = prevRegion.offset+prevRegion.length;
+ }
+ while(position >= lowLimit){
+ char c = preview.charAt(position);
+ if(c == C_NEW_LINE){
+ count--;
+ if(count == 0){
+ position++;
+ break;
+ }
+ }
+ position--;
+ }
+ if(prevRegion != null && position == prevRegion.offset+prevRegion.length){
+ prevRegion.active = false;
+ int shift = region.offset - prevRegion.offset;
+ region.offset = prevRegion.offset;
+ region.length += shift;
+ }else{
+ int shift = region.offset-position;
+ region.offset = position;
+ region.length += shift;
+
+ }
+
+ position = region.offset+region.length;
+ count = NUMBER_OF_STRINGS;
+ while(position < preview.length()-1){
+ char c = preview.charAt(position);
+ if(c == C_NEW_LINE){
+ count--;
+ if(count == 0){
+ break;
+ }
+ }
+ position++;
+ }
+ region.length += position - (region.offset + region.length);
+ prevRegion = region;
+ }
- // select
- String before = preview.substring(0, offset);
- String after = preview.substring(offset+length);
- preview = before+OPEN_BOLD+text+CLOSE_BOLD+after;
// cut
- int position = offset;
- int count = NUMBER_OF_STRINGS;
- String startText = NEW_LINE;
- while(position >= 0){
- char c = preview.charAt(position);
- if(c == C_NEW_LINE){
- count--;
- if(count == 0){
- position++;
- startText = DOTS+startText;
- break;
- }
+ StringBuffer buffer = new StringBuffer();
+ int index = 0;
+ for(Region region : regions){
+ if(!region.active){
+ continue;
}
- position--;
- }
- int start = position;
- String endText = NEW_LINE;
- position = offset+length;
- count = NUMBER_OF_STRINGS;
- while(position < preview.length()-1){
- char c = preview.charAt(position);
- if(c == C_NEW_LINE){
- count--;
- if(count == 0){
- endText += DOTS;
- break;
+ if(index == 0 && region.offset != 0){
+ buffer.append(DOTS+NEW_LINE);
+ }
+ buffer.append(preview.substring(region.offset, region.offset + region.length));
+ if((region.offset + region.length) < (preview.length()-1)){
+ if(index == regions.size()-1){
+ buffer.append(NEW_LINE+DOTS);
+ }else{
+ buffer.append(NEW_LINE+DOTS+NEW_LINE);
}
}
- position++;
+ index++;
}
- preview = startText+preview.substring(start, position)+endText;
-
- // format
- preview = preview.replaceAll(NEW_LINE, LINE_BREAK);
+ return buffer.toString();
}
- return preview;
}
+
+ static class Region{
+ public int offset;
+ public int length;
+ public boolean active = true;
+
+ public Region(int offset, int length){
+ this.offset = offset;
+ this.length = length;
+ }
+ }
}
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java 2012-01-19 20:41:24 UTC (rev 37972)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java 2012-01-19 20:56:33 UTC (rev 37973)
@@ -121,7 +121,6 @@
private TextChange getPreviewChange(){
if(element != null && preferenceKey != null){
- disablePreference();
try {
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
if(original == null) {
12 years, 9 months
JBoss Tools SVN: r37972 - trunk/openshift/plugins/org.jboss.tools.openshift.express.client.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-01-19 15:41:24 -0500 (Thu, 19 Jan 2012)
New Revision: 37972
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/openshift-java-client-1.0.1-SNAPSHOT.jar
Log:
[JBIDE-10675] fixed NPE in client, built new jar and embedded into our client bundle
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath 2012-01-19 16:58:12 UTC (rev 37971)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath 2012-01-19 20:41:24 UTC (rev 37972)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib" path="openshift-java-client-1.0.1-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="openshift-java-client-1.0.1-SNAPSHOT.jar" sourcepath="/openshift-java-client"/>
<classpathentry exported="true" kind="lib" path="jboss-dmr-1.0.0.Final.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.client/openshift-java-client-1.0.1-SNAPSHOT.jar
===================================================================
(Binary files differ)
12 years, 9 months
JBoss Tools SVN: r37971 - trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2012-01-19 11:58:12 -0500 (Thu, 19 Jan 2012)
New Revision: 37971
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse/plugin.xml
Log:
https://issues.jboss.org/browse/JBIDE-10552 : use consistent naming of BrowserSim
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse/plugin.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse/plugin.xml 2012-01-19 15:51:27 UTC (rev 37970)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.eclipse/plugin.xml 2012-01-19 16:58:12 UTC (rev 37971)
@@ -8,7 +8,7 @@
id="org.jboss.tools.vpe.browsersim.eclipse.commands.category">
</category>
<command
- name="Run Mobile Browser Simulator"
+ name="Run BrowserSim"
categoryId="org.jboss.tools.vpe.browsersim.eclipse.commands.category"
id="org.jboss.tools.vpe.browsersim.eclipse.commands.runBrowserSim">
</command>
@@ -26,13 +26,13 @@
point="org.eclipse.ui.actionSets">
<actionSet
id="org.jboss.tools.vpe.browsersim.eclipse.actionSet"
- label="Mobile Browser Simulator"
+ label="BrowserSim"
visible="false">
<action
id="org.jboss.tools.vpe.browsersim.eclipse.runBrowserSim"
definitionId="org.jboss.tools.vpe.browsersim.eclipse.commands.runBrowserSim"
toolbarPath="browserSim"
- label="Run Mobile Browser Simulator"
+ label="Run BrowserSim"
class="org.jboss.tools.vpe.browsersim.eclipse.actions.RunBrowserSimAction"
icon="icons/sample.gif">
</action>
@@ -53,7 +53,7 @@
executable=""
factoryclass="org.jboss.tools.vpe.browsersim.eclipse.BrowserSimFactory"
id="org.jboss.tools.vpe.browsersim.eclipse"
- name="Mobile Browser Simulator"
+ name="BrowserSim"
os="Win32,linux,MacOSX">
<location>
.
12 years, 9 months
JBoss Tools SVN: r37970 - in trunk/build/aggregate: soa-site and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2012-01-19 10:51:27 -0500 (Thu, 19 Jan 2012)
New Revision: 37970
Modified:
trunk/build/aggregate/site/README.building.txt
trunk/build/aggregate/soa-site/README.building.txt
Log:
fix typo and add note about semi-optional nature of parent pom rebuilding
Modified: trunk/build/aggregate/site/README.building.txt
===================================================================
--- trunk/build/aggregate/site/README.building.txt 2012-01-19 14:18:53 UTC (rev 37969)
+++ trunk/build/aggregate/site/README.building.txt 2012-01-19 15:51:27 UTC (rev 37970)
@@ -4,7 +4,7 @@
http://anonsvn.jboss.org/repos/jbosstools/trunk/
-2. Next, ensure the paret pom in ../../parent/pom.xml has been built w/ `mvn clean install`
+2. Next, ensure the parent pom in ../../parent/pom.xml has been built w/ `mvn clean install` (this may not be required as the next step should resolve/build it automatically)
3. Build this folder w/ `mvn clean install`
Modified: trunk/build/aggregate/soa-site/README.building.txt
===================================================================
--- trunk/build/aggregate/soa-site/README.building.txt 2012-01-19 14:18:53 UTC (rev 37969)
+++ trunk/build/aggregate/soa-site/README.building.txt 2012-01-19 15:51:27 UTC (rev 37970)
@@ -22,7 +22,7 @@
BPEL: http://git.eclipse.org/c/bpel/org.eclipse.bpel.git/ AND http://anonsvn.jboss.org/repos/jbosstools/trunk/bpel/
-2. Next, ensure the paret pom in ../../parent/pom.xml has been built w/ `mvn clean install`
+2. Next, ensure the parent pom in ../../parent/pom.xml has been built w/ `mvn clean install` (this may not be required as the next step should resolve/build it automatically)
3. Build this folder w/ `mvn clean install`
12 years, 9 months
JBoss Tools SVN: r37969 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-01-19 09:18:53 -0500 (Thu, 19 Jan 2012)
New Revision: 37969
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java
Log:
[JBIDE-10479] corrected javadoc
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java 2012-01-19 14:06:04 UTC (rev 37968)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java 2012-01-19 14:18:53 UTC (rev 37969)
@@ -96,7 +96,6 @@
Assert.isTrue(EGitUtils.isSharedWithGit(project));
addToModified(copyOpenshiftConfigurations(getApplication(), getRemoteName(), project, monitor));
- project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
addToModified(setupGitIgnore(project, monitor));
addToModified(setupOpenShiftMavenProfile(project));
@@ -104,6 +103,7 @@
getRemoteName(),
getApplication().getGitUri(),
EGitUtils.getRepository(project));
+
addAndCommitModifiedResource(project, monitor);
return Collections.singletonList(project);
@@ -126,14 +126,14 @@
}
/**
- * Copies the openshift configuration from the given source folder to the
- * given project. Copies
+ * Copies the openshift configuration from the given application to the
+ * given project. Clones the application to a tmp-folder, copies
* <ul>
* <li>.openshift</li>
* <li>deployments</li>
- * <li>pom.xml</li>
* </ul>
- * to the project in the workspace
+ * to the project in the workspace. Deployments and .openshift and kept
+ * as-is if they already exist in the project.
*
* @param sourceFolder
* the source to copy the openshift config from
@@ -141,17 +141,19 @@
* the project to copy the configuration to.
* @param monitor
* the monitor to report progress to
- * @return
* @return
+ * @return
* @throws IOException
* @throws CoreException
- * @throws URISyntaxException
- * @throws InterruptedException
- * @throws InvocationTargetException
- * @throws OpenShiftException
+ * @throws URISyntaxException
+ * @throws InterruptedException
+ * @throws InvocationTargetException
+ * @throws OpenShiftException
*/
- private Collection<IResource> copyOpenshiftConfigurations(IApplication application, String remoteName, IProject project, IProgressMonitor monitor)
- throws IOException, CoreException, OpenShiftException, InvocationTargetException, InterruptedException, URISyntaxException {
+ private Collection<IResource> copyOpenshiftConfigurations(IApplication application, String remoteName,
+ IProject project, IProgressMonitor monitor)
+ throws IOException, CoreException, OpenShiftException, InvocationTargetException, InterruptedException,
+ URISyntaxException {
Assert.isLegal(project != null);
monitor.subTask(NLS.bind("Copying openshift configuration to project {0}...", project.getName()));
@@ -161,6 +163,7 @@
Collection<IResource> copiedResources =
copyResources(tmpFolder, new String[] { ".openshift", "deployments" }, project);
FileUtil.safeDelete(tmpFolder);
+ project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
return copiedResources;
}
@@ -193,9 +196,9 @@
*
* @param project
* the project to which the .gitignore shall be configured
- * @return
+ * @return
* @throws IOException
- * @throws CoreException
+ * @throws CoreException
*/
private IFile setupGitIgnore(IProject project, IProgressMonitor monitor) throws IOException, CoreException {
GitIgnore gitIgnore = new GitIgnore(project);
12 years, 9 months
JBoss Tools SVN: r37968 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-01-19 09:06:04 -0500 (Thu, 19 Jan 2012)
New Revision: 37968
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java
Log:
[JBIDE-10479] corrected text when choosing an exisiting project since one can now choose a git shared project
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java 2012-01-19 13:52:26 UTC (rev 37967)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java 2012-01-19 14:06:04 UTC (rev 37968)
@@ -35,7 +35,7 @@
super(shell, new ProjectLabelProvider());
setTitle("Select Existing Project");
setMessage(NLS.bind(
- "Select an existing project for {0}.\nOnly java projects which are not Team shared can be used.",
+ "Select an existing project for {0}.\nOnly java projects can be used.",
openShiftAppName));
setMultipleSelection(false);
setAllowDuplicates(false);
12 years, 9 months
JBoss Tools SVN: r37967 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-01-19 08:52:26 -0500 (Thu, 19 Jan 2012)
New Revision: 37967
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureUnsharedProject.java
Log:
[JBIDE-10479] switched GitIgnore to acces .gitignore-file by the resource API (was: java.io.File)
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java 2012-01-19 13:51:31 UTC (rev 37966)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java 2012-01-19 13:52:26 UTC (rev 37967)
@@ -95,16 +95,15 @@
IProject project = getProject();
Assert.isTrue(EGitUtils.isSharedWithGit(project));
- copyOpenshiftConfigurations(getApplication(), getRemoteName(), project, monitor);
-
- setupGitIgnore(project);
+ addToModified(copyOpenshiftConfigurations(getApplication(), getRemoteName(), project, monitor));
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ addToModified(setupGitIgnore(project, monitor));
+ addToModified(setupOpenShiftMavenProfile(project));
EGitUtils.addRemoteTo(
getRemoteName(),
getApplication().getGitUri(),
EGitUtils.getRepository(project));
- setupOpenShiftMavenProfile(project);
addAndCommitModifiedResource(project, monitor);
return Collections.singletonList(project);
@@ -115,16 +114,15 @@
EGitUtils.commit(project, monitor);
}
- private void setupOpenShiftMavenProfile(IProject project) throws CoreException {
+ private IResource setupOpenShiftMavenProfile(IProject project) throws CoreException {
Assert.isLegal(OpenShiftMavenProfile.isMavenProject(project));
OpenShiftMavenProfile profile = new OpenShiftMavenProfile(project, OpenShiftUIActivator.PLUGIN_ID);
if (profile.existsInPom()) {
- return;
+ return null;
}
profile.addToPom(project.getName());
- IFile pomFile = profile.savePom();
- modifiedResources.add(pomFile);
+ return profile.savePom();
}
/**
@@ -143,6 +141,7 @@
* the project to copy the configuration to.
* @param monitor
* the monitor to report progress to
+ * @return
* @return
* @throws IOException
* @throws CoreException
@@ -151,7 +150,7 @@
* @throws InvocationTargetException
* @throws OpenShiftException
*/
- private void copyOpenshiftConfigurations(IApplication application, String remoteName, IProject project, IProgressMonitor monitor)
+ private Collection<IResource> copyOpenshiftConfigurations(IApplication application, String remoteName, IProject project, IProgressMonitor monitor)
throws IOException, CoreException, OpenShiftException, InvocationTargetException, InterruptedException, URISyntaxException {
Assert.isLegal(project != null);
monitor.subTask(NLS.bind("Copying openshift configuration to project {0}...", project.getName()));
@@ -161,8 +160,8 @@
Collection<IResource> copiedResources =
copyResources(tmpFolder, new String[] { ".openshift", "deployments" }, project);
- modifiedResources.addAll(copiedResources);
FileUtil.safeDelete(tmpFolder);
+ return copiedResources;
}
private Collection<IResource> copyResources(File sourceFolder, String[] sourcePaths, IProject project)
@@ -194,17 +193,32 @@
*
* @param project
* the project to which the .gitignore shall be configured
+ * @return
* @throws IOException
+ * @throws CoreException
*/
- private void setupGitIgnore(IProject project) throws IOException {
+ private IFile setupGitIgnore(IProject project, IProgressMonitor monitor) throws IOException, CoreException {
GitIgnore gitIgnore = new GitIgnore(project);
gitIgnore.add("target")
.add(".settings")
.add(".project")
.add(".classpath")
.add(".factorypath");
- File file = gitIgnore.write(false);
- IFile gitIgnoreFile = project.getFile(file.getName());
- modifiedResources.add(gitIgnoreFile);
+ return gitIgnore.write(monitor);
}
+
+ private void addToModified(Collection<IResource> resources) {
+ if (resources == null) {
+ return;
+ }
+ modifiedResources.addAll(resources);
+ }
+
+ private void addToModified(IResource resource) {
+ if (resource == null) {
+ return;
+ }
+ modifiedResources.add(resource);
+ }
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureUnsharedProject.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureUnsharedProject.java 2012-01-19 13:51:31 UTC (rev 37966)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureUnsharedProject.java 2012-01-19 13:52:26 UTC (rev 37967)
@@ -92,7 +92,7 @@
IProject project = getProject();
copyOpenshiftConfigurations(getApplication(), getRemoteName(), project, monitor);
- createGitIgnore(project);
+ createGitIgnore(project, monitor);
shareProject(project, monitor);
return Collections.singletonList(project);
@@ -151,15 +151,16 @@
* @param project
* the project to which the .gitignore shall be configured
* @throws IOException
+ * @throws CoreException
*/
- private void createGitIgnore(IProject project) throws IOException {
+ private void createGitIgnore(IProject project, IProgressMonitor monitor) throws IOException, CoreException {
GitIgnore gitIgnore = new GitIgnore(project);
gitIgnore.add("target")
.add(".settings")
.add(".project")
.add(".classpath")
.add(".factorypath");
- gitIgnore.write(false);
+ gitIgnore.write(monitor);
}
// private void mergeWithApplicationRepository(Repository repository,
12 years, 9 months
JBoss Tools SVN: r37966 - in trunk/openshift: tests/org.jboss.tools.openshift.egit.test/src/org/jboss/tools/openshift/egit/internal/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-01-19 08:51:31 -0500 (Thu, 19 Jan 2012)
New Revision: 37966
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java
trunk/openshift/tests/org.jboss.tools.openshift.egit.test/src/org/jboss/tools/openshift/egit/internal/test/GitIgnoreTest.java
Log:
[JBIDE-10479] switched GitIgnore to acces .gitignore-file by the resource API (was: java.io.File)
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java 2012-01-19 11:05:53 UTC (rev 37965)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java 2012-01-19 13:51:31 UTC (rev 37966)
@@ -11,16 +11,18 @@
package org.jboss.tools.openshift.egit.core;
import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jgit.lib.Constants;
/**
@@ -29,28 +31,29 @@
public class GitIgnore {
public static final String NL = System.getProperty("line.separator");
-
+
private Set<String> entries;
- private File file;
+ private IFile file;
- public GitIgnore(IProject project) throws IOException {
- this(new File(project.getLocation().toFile(), Constants.GITIGNORE_FILENAME));
+ public GitIgnore(IProject project) throws IOException, CoreException {
+ this(project.getFile(Constants.GITIGNORE_FILENAME));
}
- public GitIgnore(File gitIgnoreFile) throws IOException {
+ public GitIgnore(IFile gitIgnoreFile) throws IOException, CoreException {
this.file = gitIgnoreFile;
initEntries(gitIgnoreFile);
}
- private void initEntries(File gitIgnore) throws IOException {
+ private void initEntries(IFile gitIgnore) throws IOException, CoreException {
this.entries = new HashSet<String>();
if (gitIgnore == null
- || !gitIgnore.canRead()) {
+ || !gitIgnore.isAccessible()) {
return;
}
BufferedReader reader = null;
try {
- reader = new BufferedReader(new FileReader(gitIgnore));
+
+ reader = new BufferedReader(new InputStreamReader(gitIgnore.getContents()));
for (String line = null; (line = reader.readLine()) != null;) {
if (line != null) {
entries.add(line);
@@ -69,33 +72,26 @@
public boolean contains(String entry) {
return entries.contains(entry);
}
-
+
public int size() {
return entries.size();
}
/**
* Writes the entries in this instance to the .gitignore file. Overwrites
- * and existing file if the given overwrite is set to <code>true</code>,
- * appends otherwise.
+ * and existing file
*
- * @param overwrite
- * overwrites an existing file if <code>true</code>, appends
- * otherwise
* @throws IOException
+ * @throws CoreException
*/
- public File write(boolean overwrite) throws IOException {
- BufferedWriter writer = new BufferedWriter(new FileWriter(file, !overwrite));
- try {
- for (String entry : entries) {
- writer.write(entry);
- writer.write(NL);
- }
- writer.flush();
- return file;
- } finally {
- writer.close();
+ public IFile write(IProgressMonitor monitor) throws CoreException {
+ StringBuilder builder = new StringBuilder();
+ for (String entry : entries) {
+ builder.append(entry);
+ builder.append(NL);
}
+ file.setContents(new ByteArrayInputStream(builder.toString().getBytes()), IResource.FORCE, monitor);
+ return file;
}
public boolean exists() {
Modified: trunk/openshift/tests/org.jboss.tools.openshift.egit.test/src/org/jboss/tools/openshift/egit/internal/test/GitIgnoreTest.java
===================================================================
--- trunk/openshift/tests/org.jboss.tools.openshift.egit.test/src/org/jboss/tools/openshift/egit/internal/test/GitIgnoreTest.java 2012-01-19 11:05:53 UTC (rev 37965)
+++ trunk/openshift/tests/org.jboss.tools.openshift.egit.test/src/org/jboss/tools/openshift/egit/internal/test/GitIgnoreTest.java 2012-01-19 13:51:31 UTC (rev 37966)
@@ -12,11 +12,14 @@
import static org.junit.Assert.assertTrue;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jgit.lib.Constants;
import org.jboss.tools.openshift.egit.core.GitIgnore;
import org.junit.Test;
@@ -27,19 +30,22 @@
public class GitIgnoreTest {
public static final String NL = System.getProperty("line.separator");
-
- private File gitIgnoreFile;
- public void setUp() throws IOException {
- this.gitIgnoreFile = createGitFile("");
+ private IFile gitIgnoreFile;
+
+ private IProject project;
+
+ public void setUp() throws CoreException {
+ this.project = createRandomProject();
+ this.gitIgnoreFile = createGitFile(project, "");
}
public void tearDown() {
- gitIgnoreFile.delete();
+ silentlyDelete(project);
}
@Test
- public void canAddEntries() throws IOException {
+ public void canAddEntries() throws CoreException, IOException {
GitIgnore gitIgnore = new GitIgnore(gitIgnoreFile);
assertTrue(gitIgnore.size() == 0);
String entry = "dummy";
@@ -49,62 +55,68 @@
}
@Test
- public void canParseExistingEntries() throws IOException {
- File gitIgnoreFile = null;
+ public void canParseExistingEntries() throws CoreException, IOException {
+ IFile gitIgnoreFile = null;
+ IProject project = null;
try {
- gitIgnoreFile = createGitFile("redhat", "jboss", "tools");
+ project = createRandomProject();
+ gitIgnoreFile = createGitFile(project, "redhat", "jboss", "tools");
GitIgnore gitIgnore = new GitIgnore(gitIgnoreFile);
assertTrue(gitIgnore.size() == 3);
assertTrue(gitIgnore.contains("redhat"));
assertTrue(gitIgnore.contains("jboss"));
assertTrue(gitIgnore.contains("tools"));
} finally {
- if (gitIgnoreFile != null) {
- gitIgnoreFile.delete();
- }
+ silentlyDelete(project);
}
}
@Test
- public void entryIsNotAddedTwice() throws IOException {
- File gitIgnoreFile = null;
+ public void entryIsNotAddedTwice() throws CoreException, IOException {
+ IFile gitIgnoreFile = null;
+ IProject project = null;
try {
- gitIgnoreFile = createGitFile("redhat");
+ project = createRandomProject();
+ gitIgnoreFile = createGitFile(project, "redhat");
GitIgnore gitIgnore = new GitIgnore(gitIgnoreFile);
assertTrue(gitIgnore.size() == 1);
assertTrue(gitIgnore.contains("redhat"));
gitIgnore.add("redhat");
assertTrue(gitIgnore.size() == 1);
} finally {
- gitIgnoreFile.delete();
+ silentlyDelete(project);
}
}
- private File createTmpFolder() throws IOException {
- String tmpFolder = System.getProperty("java.io.tmpdir");
- String currentTime = String.valueOf(System.currentTimeMillis());
- File randomTmpFolder = new File(tmpFolder, currentTime);
- randomTmpFolder.mkdir();
- return randomTmpFolder;
+ private IFile createGitFile(IProject project, String... gitIgnoreEntries) throws CoreException {
+ IFile gitFile = project.getFile(Constants.GITIGNORE_FILENAME);
+ StringBuilder builder = new StringBuilder();
+ for (String entry : gitIgnoreEntries) {
+ builder.append(entry);
+ builder.append(NL);
+ }
+ gitFile.create(new ByteArrayInputStream(builder.toString().getBytes()), IResource.FORCE, null);
+ return gitFile;
+ }
+ private IProject createRandomProject() throws CoreException {
+ String projectName = String.valueOf(System.currentTimeMillis());
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ project.create(null);
+ project.open(null);
+ return project;
}
- private File createGitFile(String... gitIgnoreEntries) throws IOException {
- File gitFile = new File(createTmpFolder(), Constants.GITIGNORE_FILENAME);
- BufferedWriter writer = null;
+ private void silentlyDelete(IProject project) {
+ if (project == null
+ || !project.isAccessible()) {
+ return;
+ }
try {
- writer = new BufferedWriter(new FileWriter(gitFile));
- for (String entry : gitIgnoreEntries) {
- writer.write(entry);
- writer.write(NL);
- }
- writer.flush();
- } finally {
- if (writer != null) {
- writer.close();
- }
+ project.close(null);
+ project.delete(true, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
}
-
- return gitFile;
}
}
12 years, 9 months
JBoss Tools SVN: r37965 - trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-01-19 06:05:53 -0500 (Thu, 19 Jan 2012)
New Revision: 37965
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java
Log:
[JBIDE-10479] now adding and committing modified/created files to local git repo
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java 2012-01-19 09:55:49 UTC (rev 37964)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java 2012-01-19 11:05:53 UTC (rev 37965)
@@ -84,7 +84,7 @@
* otherwise
* @throws IOException
*/
- public void write(boolean overwrite) throws IOException {
+ public File write(boolean overwrite) throws IOException {
BufferedWriter writer = new BufferedWriter(new FileWriter(file, !overwrite));
try {
for (String entry : entries) {
@@ -92,6 +92,7 @@
writer.write(NL);
}
writer.flush();
+ return file;
} finally {
writer.close();
}
12 years, 9 months
JBoss Tools SVN: r37964 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2012-01-19 04:55:49 -0500 (Thu, 19 Jan 2012)
New Revision: 37964
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePropertiesComposite.java
Log:
https://issues.jboss.org/browse/JBIDE-10470
Get project relative path from source folder relative. This allow correctly show previously selected file in Browse dialog.
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePropertiesComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePropertiesComposite.java 2012-01-19 01:33:40 UTC (rev 37963)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/persistence/details/HibernatePropertiesComposite.java 2012-01-19 09:55:49 UTC (rev 37964)
@@ -14,6 +14,7 @@
import java.util.Arrays;
import java.util.List;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -53,7 +54,6 @@
import org.hibernate.eclipse.console.utils.DriverClassHelpers;
import org.hibernate.eclipse.console.wizards.NewConfigurationWizard;
import org.hibernate.eclipse.console.wizards.NewConfigurationWizardPage;
-import org.hibernate.eclipse.launch.PathHelper;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
import org.jboss.tools.hibernate.jpt.ui.wizard.Messages;
@@ -190,7 +190,31 @@
}
private IPath getConfigurationFilePath() {
- return PathHelper.pathOrNull(this.cfgFile.getText());
+ BasicHibernateProperties props = getSubject();
+ String filePath = cfgFile.getText().trim();
+ if (props != null && filePath.length() > 0 ){
+ IProject project = props.getJpaProject().getProject();
+ IJavaProject jProject = JavaCore.create(project);
+ if (jProject != null){
+ try {
+ IPackageFragmentRoot[] allPackageFragmentRoots = jProject.getAllPackageFragmentRoots();
+ for (IPackageFragmentRoot iPackageFragmentRoot : allPackageFragmentRoots) {
+ if (!iPackageFragmentRoot.isArchive()){
+ IResource sourceFolder = iPackageFragmentRoot.getResource();
+ if (sourceFolder instanceof IContainer) {
+ IContainer folder = (IContainer) sourceFolder;
+ if (folder.findMember(filePath) != null){
+ return folder.findMember(filePath).getFullPath();
+ }
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ //ignore
+ }
+ }
+ }
+ return null;
}
private Runnable createSetupAction() {
@@ -258,7 +282,7 @@
}
return null;
}
-
+
private IPath handleConfigurationFileCreate() {
NewConfigurationWizard wizard = new NewConfigurationWizard();
wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY );
12 years, 9 months