JBoss Tools SVN: r27287 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/internal/deltacloud/ui/wizards and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-09 13:27:14 -0500 (Thu, 09 Dec 2010)
New Revision: 27287
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
Log:
[JBIDE-7818] replaced threads by jobs (so that I can implement proper job scheduling rules across deltacloud tools),
cleaned code - split code in several methods, removed profile combo initialization that was done in parallel to the
fetch-profiles thread
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-09 17:51:02 UTC (rev 27286)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-09 18:27:14 UTC (rev 27287)
@@ -1,5 +1,9 @@
2010-12-09 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java (asyncGetProfiles):
+ [JBIDE-7818] replaced threads by jobs (so that I can implement proper job scheduling rules across deltacloud tools),
+ cleaned code - split code in several methods, removed profile combo initialization that was done in parallel to the
+ fetch-profiles thread
* src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java (inputChanged):
[JBIDE-7848] refreshing viewer before adding new items
* src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
@@ -12,7 +16,8 @@
* src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryItem.java
(getChildren):
(asyncAddCloudElements):
- [JBIDE-7848] separated the usecases: actively getting images/instances and passive updates. You now get the images and dont need to trigger getting and get the update of it.
+ [JBIDE-7848] separated the usecases: actively getting images/instances and passive updates. You now get the images and
+ dont need to trigger getting and get the update of it.
* src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java (.selectionChanged):
[JBIDE-7849] only change selected cloud if a new cloud has been selected
* src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java (dispose):
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-09 17:51:02 UTC (rev 27286)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-09 18:27:14 UTC (rev 27287)
@@ -13,6 +13,7 @@
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -29,7 +30,9 @@
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.databinding.wizard.WizardPageSupport;
@@ -60,6 +63,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudHardwareProfile;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.DeltaCloudRealm;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.MandatoryStringValidator;
@@ -218,45 +222,21 @@
hardware.addModifyListener(comboListener);
}
- private DeltaCloudHardwareProfile[] getProfiles() {
- List<DeltaCloudHardwareProfile> profiles = new ArrayList<DeltaCloudHardwareProfile>();
- try {
- DeltaCloudHardwareProfile[] allProfiles = cloud.getProfiles();
- for (DeltaCloudHardwareProfile p : allProfiles) {
- profiles.add(p);
- }
- } catch (DeltaCloudException e) {
- // TODO internationalize strings
- ErrorUtils.handleError("Error",
- MessageFormat.format("Could not get profiles from cloud {0}", cloud.getName()), e, getShell());
+ private List<DeltaCloudHardwareProfile> filterProfiles(DeltaCloudHardwareProfile[] profiles) {
+ if (profiles == null) {
+ return Collections.emptyList();
}
- return profiles.toArray(new DeltaCloudHardwareProfile[profiles.size()]);
- }
- public void filterProfiles() {
- if (allProfiles == null)
- return;
-
- ArrayList<DeltaCloudHardwareProfile> profiles = new ArrayList<DeltaCloudHardwareProfile>();
- for (DeltaCloudHardwareProfile p : allProfiles) {
- if (p.getArchitecture() == null || image == null || image.getArchitecture().equals(p.getArchitecture())) {
- profiles.add(p);
+ List<DeltaCloudHardwareProfile> filteredProfiles = new ArrayList<DeltaCloudHardwareProfile>();
+ for (DeltaCloudHardwareProfile p : profiles) {
+ if (p.getArchitecture() == null
+ || image == null
+ || image.getArchitecture().equals(p.getArchitecture())) {
+ filteredProfiles.add(p);
}
}
- String[] ids = new String[profiles.size()];
- for (int i = 0; i < profiles.size(); ++i) {
- DeltaCloudHardwareProfile p = profiles.get(i);
- ids[i] = p.getId();
- }
- if (ids.length > 0) {
- hardware.removeModifyListener(comboListener);
- hardware.setItems(ids);
- hardware.setText(ids[0]);
- currPage = profilePages.get(ids[0]);
- currPage.setVisible(true);
- hardware.setEnabled(true);
- hardware.addModifyListener(comboListener);
- }
+
+ return filteredProfiles;
}
@Override
@@ -266,8 +246,8 @@
Composite control = createWidgets(parent);
bindWidgets(dbc);
- launchFetchRealms();
- launchFetchProfiles();
+ asyncGetRealms();
+ asyncGetProfiles();
// We have to set the imageObservable id here instead of in the
// constructor of the model because the imageObservable id triggers
@@ -280,10 +260,9 @@
}
setControl(control);
- // lastly, if there's already an imageObservable set, use it
+ // lastly, if there's already an image set, use it
if (image != null) {
imageText.setText(image.getId());
- filterProfiles();
}
}
@@ -547,39 +526,83 @@
}
}
- private void launchFetchRealms() {
- Thread t = new Thread() {
- public void run() {
+ private void asyncGetRealms() {
+ // TODO: internationalize strings
+ new AbstractCloudJob("Get realms", cloud) {
+
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
realms = getRealms();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
updateRealmCombo();
}
});
+ return Status.OK_STATUS;
}
- };
- t.start();
+ }.schedule();
}
- private void launchFetchProfiles() {
- Thread t = new Thread() {
- public void run() {
+ private void asyncGetProfiles() {
+ // TODO: internationalize strings
+ new AbstractCloudJob("Get Profiles", cloud) {
+
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
allProfiles = getProfiles();
profilePages = new HashMap<String, ProfileComposite>();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
createProfileComposites();
clearProfiles();
- if (allProfiles.length > 0)
+ if (allProfiles.length > 0) {
hardware.setEnabled(true);
- filterProfiles();
+ }
+ List<DeltaCloudHardwareProfile> filteredProfiles = filterProfiles(allProfiles);
+ updateWidgets(getProfileIds(filteredProfiles));
}
});
+ return Status.OK_STATUS;
}
- };
- t.start();
+ }.schedule();
}
+ private DeltaCloudHardwareProfile[] getProfiles() {
+ List<DeltaCloudHardwareProfile> profiles = new ArrayList<DeltaCloudHardwareProfile>();
+ try {
+ DeltaCloudHardwareProfile[] allProfiles = cloud.getProfiles();
+ for (DeltaCloudHardwareProfile p : allProfiles) {
+ profiles.add(p);
+ }
+ } catch (DeltaCloudException e) {
+ // TODO internationalize strings
+ ErrorUtils.handleError("Error",
+ MessageFormat.format("Could not get profiles from cloud {0}", cloud.getName()), e, getShell());
+ }
+ return profiles.toArray(new DeltaCloudHardwareProfile[profiles.size()]);
+ }
+
+ private void updateWidgets(String[] ids) {
+ if (ids.length > 0) {
+ hardware.removeModifyListener(comboListener);
+ hardware.setItems(ids);
+ hardware.setText(ids[0]);
+ currPage = profilePages.get(ids[0]);
+ currPage.setVisible(true);
+ hardware.setEnabled(true);
+ hardware.addModifyListener(comboListener);
+ }
+ }
+
+ private String[] getProfileIds(List<DeltaCloudHardwareProfile> filteredProfiles) {
+ String[] ids = new String[filteredProfiles.size()];
+ for (int i = 0; i < filteredProfiles.size(); ++i) {
+ DeltaCloudHardwareProfile p = filteredProfiles.get(i);
+ ids[i] = p.getId();
+ }
+ return ids;
+ }
+
private List<String> getRealmNames(List<DeltaCloudRealm> realms) {
List<String> realmNames = new ArrayList<String>();
for (DeltaCloudRealm realm : realms) {
14 years
JBoss Tools SVN: r27286 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/deltacloud/ui/views/cloudelements and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-09 12:51:02 -0500 (Thu, 09 Dec 2010)
New Revision: 27286
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java
Log:
[JBIDE-7848] refreshing viewer before adding new items
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-09 17:34:28 UTC (rev 27285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-09 17:51:02 UTC (rev 27286)
@@ -1,5 +1,7 @@
2010-12-09 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java (inputChanged):
+ [JBIDE-7848] refreshing viewer before adding new items
* src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
(.modifyText):
(asyncSetImagesToViewer):
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java 2010-12-09 17:34:28 UTC (rev 27285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java 2010-12-09 17:51:02 UTC (rev 27286)
@@ -34,10 +34,16 @@
private DeltaCloud currentCloud;
private ICloudElementFilter<CLOUDELEMENT> localFilter;
private TableViewer viewer;
-
+
@Override
public Object[] getElements(Object input) {
- return new Object[] {};
+ /*
+ * items are added in asynchronous manner.
+ *
+ * @see #inputChanged
+ * @see #asyncAddCloudElements
+ */
+ return new Object[]{};
}
public void setFilter(ICloudElementFilter<CLOUDELEMENT> filter) {
@@ -49,7 +55,7 @@
if (!(newInput instanceof DeltaCloud)) {
return;
}
- Assert.isTrue(viewer instanceof TableViewer);
+ Assert.isLegal(viewer instanceof TableViewer);
this.viewer = (TableViewer) viewer;
removeListener(currentCloud);
this.currentCloud = (DeltaCloud) newInput;
@@ -75,13 +81,13 @@
@Override
public void run() {
try {
+ viewer.refresh();
Object[] elements = filter(getFilter(currentCloud), cloudElements);
viewer.add(elements);
} catch (DeltaCloudException e) {
// TODO: internationalize strings
ErrorUtils.handleError(
- "Error",
- "Could not get elements of clouds " + currentCloud.getName(),
+ "Error", "Could not filter the elements for cloud " + currentCloud.getName(),
e, Display.getDefault().getActiveShell());
}
14 years
JBoss Tools SVN: r27285 - trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-12-09 12:34:28 -0500 (Thu, 09 Dec 2010)
New Revision: 27285
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/.project
Log:
https://issues.jboss.org/browse/JBIDE-7748 Fixed JSF tests
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/.project
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/.project 2010-12-09 16:23:01 UTC (rev 27284)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/.project 2010-12-09 17:34:28 UTC (rev 27285)
@@ -16,6 +16,11 @@
</arguments>
</buildCommand>
<buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.jboss.tools.jst.web.kb.kbbuilder</name>
<arguments>
</arguments>
14 years
JBoss Tools SVN: r27282 - in trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui: marker and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2010-12-09 10:28:29 -0500 (Thu, 09 Dec 2010)
New Revision: 27282
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java
Log:
https://jira.jboss.org/browse/JBIDE-7669
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2010-12-09 14:43:42 UTC (rev 27281)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2010-12-09 15:28:29 UTC (rev 27282)
@@ -64,6 +64,7 @@
public static String MAKE_FIELD_STATIC_MARKER_RESOLUTION_TITLE;
public static String MAKE_METHOD_PUBLIC_MARKER_RESOLUTION_TITLE;
public static String MAKE_METHOD_BUSINESS_MARKER_RESOLUTION_TITLE;
+ public static String ADD_LOCAL_BEAN_MARKER_RESOLUTION_TITLE;
public static String CDI_GENERATE_BEANS_XML;
public static String CDI_INSTALL_WIZARD_PAGE_FACET;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2010-12-09 14:43:42 UTC (rev 27281)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2010-12-09 15:28:29 UTC (rev 27282)
@@ -52,7 +52,8 @@
MAKE_FIELD_STATIC_MARKER_RESOLUTION_TITLE=Make ''{0}'' field static
MAKE_METHOD_PUBLIC_MARKER_RESOLUTION_TITLE=Make ''{0}'' method public
-MAKE_METHOD_BUSINESS_MARKER_RESOLUTION_TITLE=Make ''{0}'' method business method of the session bean and add it to ''{1}'' interface
+MAKE_METHOD_BUSINESS_MARKER_RESOLUTION_TITLE=Add ''{0}'' method to ''{1}'' interface
+ADD_LOCAL_BEAN_MARKER_RESOLUTION_TITLE=Add @LocalBean annotation to ''{0}'' class
CDI_GENERATE_BEANS_XML=Generate beans.xml file:
CDI_INSTALL_WIZARD_PAGE_FACET=Context and Dependency Injection (CDI) Facet
Added: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java 2010-12-09 15:28:29 UTC (rev 27282)
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.cdi.ui.marker;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IBuffer;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IImportDeclaration;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMarkerResolution2;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+
+/**
+ * @author Daniel Azarov
+ */
+public class AddLocalBeanMarkerResolution implements IMarkerResolution2 {
+ private static final String PUBLIC = "public"; //$NON-NLS-1$
+ private static final String PRIVATE = "private"; //$NON-NLS-1$
+ private static final String PROTECTED = "protected"; //$NON-NLS-1$
+ private static final String SPACE = " "; //$NON-NLS-1$
+
+ private String label;
+ private IMethod method;
+ private IFile file;
+
+ public AddLocalBeanMarkerResolution(IMethod method, IFile file){
+ this.label = MessageFormat.format(CDIUIMessages.ADD_LOCAL_BEAN_MARKER_RESOLUTION_TITLE, new Object[]{method.getDeclaringType().getElementName()});
+ this.method = method;
+ this.file = file;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void run(IMarker marker) {
+ try{
+ ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
+ ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+
+ IBuffer buffer = compilationUnit.getBuffer();
+
+ int flag = method.getFlags();
+
+ String text = buffer.getText(method.getSourceRange().getOffset(), method.getSourceRange().getLength());
+
+ // make method public
+ int position = method.getSourceRange().getOffset();
+ if((flag & Flags.AccPublic) != 0){
+ // do nothing
+ }else if((flag & Flags.AccPrivate) != 0){
+ position += text.indexOf(PRIVATE);
+ buffer.replace(position, PRIVATE.length(), PUBLIC);
+ }else if((flag & Flags.AccProtected) != 0){
+ position += text.indexOf(PROTECTED);
+ buffer.replace(position, PROTECTED.length(), PUBLIC);
+ }else{
+ String type = Signature.getSignatureSimpleName(method.getReturnType());
+ position += text.indexOf(type);
+ buffer.replace(position, 0, PUBLIC+SPACE);
+ }
+
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
+
+ // add @LocalBean annotation
+ IType type = compilationUnit.getType(method.getDeclaringType().getElementName());
+
+ IAnnotation localAnnotation = EclipseJavaUtil.findAnnotation(type, type, CDIConstants.LOCAL_BEAN_ANNOTATION_TYPE_NAME);
+ if(localAnnotation == null){
+ addImport(CDIConstants.LOCAL_BEAN_ANNOTATION_TYPE_NAME, compilationUnit);
+
+ final String lineDelim= compilationUnit.findRecommendedLineSeparator();
+
+ buffer = compilationUnit.getBuffer();
+
+ buffer.replace(type.getSourceRange().getOffset(), 0, "@"+CDIConstants.LOCAL_BEAN_SIMPLE_NAME+lineDelim);
+ }
+
+ // add method to interface
+
+ compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ compilationUnit.discardWorkingCopy();
+
+ }catch(CoreException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ }
+
+ private void addImport(String qualifiedName, ICompilationUnit compilationUnit) throws JavaModelException{
+ if(qualifiedName != null){
+ IImportDeclaration importDeclaration = compilationUnit.getImport(qualifiedName);
+ if(importDeclaration == null || !importDeclaration.exists())
+ compilationUnit.createImport(qualifiedName, null, new NullProgressMonitor());
+ }
+
+ }
+
+ public String getDescription() {
+ return null;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+
+}
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2010-12-09 14:43:42 UTC (rev 27281)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2010-12-09 15:28:29 UTC (rev 27282)
@@ -66,11 +66,6 @@
return new IMarkerResolution[] {};
int start = attribute.intValue();
- attribute = ((Integer) marker.getAttribute(IMarker.CHAR_END));
- if (attribute == null)
- return new IMarkerResolution[] {};
- int end = attribute.intValue();
-
if (JAVA_EXTENSION.equals(file.getFileExtension())) {
if (messageId == CDIValidationErrorManager.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN_ID) {
IField field = findNonStaticField(file, start);
@@ -88,10 +83,11 @@
new MakeMethodPublicMarkerResolution(method, file)
};
}else{
- IMarkerResolution[] resolutions = new IMarkerResolution[types.size()];
+ IMarkerResolution[] resolutions = new IMarkerResolution[types.size()+1];
for(int i = 0; i < types.size(); i++){
resolutions[i] = new MakeMethodBusinessMarkerResolution(method, types.get(i), file);
}
+ resolutions[types.size()] = new AddLocalBeanMarkerResolution(method, file);
return resolutions;
}
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java 2010-12-09 14:43:42 UTC (rev 27281)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java 2010-12-09 15:28:29 UTC (rev 27282)
@@ -18,7 +18,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IImportDeclaration;
@@ -29,7 +28,6 @@
import org.eclipse.jdt.core.Signature;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IMarkerResolution2;
-import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.common.EclipseUtil;
@@ -109,29 +107,11 @@
buffer.replace(position, 0, PUBLIC+SPACE);
}
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
- }
-
- // add @LocalBean annotation
- IType type = compilationUnit.getType(method.getDeclaringType().getElementName());
-
- IAnnotation localAnnotation = EclipseJavaUtil.findAnnotation(type, type, CDIConstants.LOCAL_BEAN_ANNOTATION_TYPE_NAME);
- if(localAnnotation == null){
- addImport(CDIConstants.LOCAL_BEAN_ANNOTATION_TYPE_NAME, compilationUnit);
-
- final String lineDelim= compilationUnit.findRecommendedLineSeparator();
-
- buffer = compilationUnit.getBuffer();
-
- buffer.replace(type.getSourceRange().getOffset(), 0, "@"+CDIConstants.LOCAL_BEAN_SIMPLE_NAME+lineDelim);
- }
-
- // add method to interface
-
compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
compilationUnit.discardWorkingCopy();
+ // add method to interface
+
original = localInterface.getCompilationUnit();
compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
14 years
JBoss Tools SVN: r27281 - in trunk/jsf/tests/org.jboss.tools.jsf.ui.test: src/org/jboss/tools/jsf/ui/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-12-09 09:43:42 -0500 (Thu, 09 Dec 2010)
New Revision: 27281
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/hello2.jsp
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/TestPalette.java
Log:
JBIDE-5661
https://issues.jboss.org/browse/JBIDE-5661
Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/hello2.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/hello2.jsp (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/hello2.jsp 2010-12-09 14:43:42 UTC (rev 27281)
@@ -0,0 +1,21 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn2"%>
+
+<f:loadBundle var="Message" basename="demo.Messages" />
+
+<html>
+ <head>
+ <title>Hello!</title>
+ </head>
+
+ <body>
+ <f:view>
+ <h3>
+ <h:outputText value="#{Message.hello_message}" />,
+ <h:outputText value="#{user.name}" />!
+ </h3>
+ </f:view>
+ </body>
+
+</html>
\ No newline at end of file
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/hello2.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/TestPalette.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/TestPalette.java 2010-12-09 14:41:47 UTC (rev 27280)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/TestPalette.java 2010-12-09 14:43:42 UTC (rev 27281)
@@ -12,7 +12,10 @@
package org.jboss.tools.jsf.ui.test;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Properties;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -25,6 +28,10 @@
import org.eclipse.gef.ui.palette.editparts.PaletteEditPart;
import org.eclipse.gef.ui.views.palette.PalettePage;
import org.eclipse.gef.ui.views.palette.PaletteView;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewPart;
@@ -32,10 +39,16 @@
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.IPage;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.ui.views.palette.IPaletteAdapter;
+import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jsf.ui.JsfUiPlugin;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.PalettePageImpl;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
+import org.jboss.tools.jst.web.tld.model.helpers.TLDToPaletteHelper;
import org.jboss.tools.jst.web.ui.WebDevelopmentPerspectiveFactory;
import org.jboss.tools.test.util.ProjectImportTestSetup;
import org.jboss.tools.vpe.ui.palette.PaletteAdapter;
@@ -130,4 +143,69 @@
}
+ public void testTLDTagImport() throws Exception {
+ XModel model = EclipseResourceUtil.getModelNature(jsfProject).getModel();
+
+ XModelObject tld = model.getByPath("/META-INF/fmt.tld");
+ assertNotNull("Taglib /META-INF/fmt.tld is not found.", tld);
+ XModelObject g = new TLDToPaletteHelper().createGroupByTLD(tld, model);
+ assertNotNull(g);
+ XModelObject m = g.getChildByPath("timeZone");
+ assertNotNull("Macros timeZone was not created.", m);
+ assertEquals("Text of macros timeZone is not correct.", "<timeZone value=\"|\">", m.getAttributeValue("start text"));
+ }
+
+ public void testTLDFunctionImport() throws Exception {
+ XModel model = EclipseResourceUtil.getModelNature(jsfProject).getModel();
+
+ XModelObject tld = model.getByPath("/META-INF/fn.tld");
+ assertNotNull("Taglib /META-INF/fn.tld is not found.", tld);
+ XModelObject g = new TLDToPaletteHelper().createGroupByTLD(tld, model);
+ assertNotNull(g);
+ assertEquals("Library uri is not set correctly to the palette group.", "http://java.sun.com/jsp/jstl/functions", g.getAttributeValue("library uri"));
+ System.out.println(g.getAttributeValue("library uri"));
+ XModelObject m = g.getChildByPath("containsIgnoreCase");
+ assertNotNull("Macros containsIgnoreCase was not created.", m);
+ assertEquals("Text of macros containsIgnoreCase is not correct.", "${containsIgnoreCase('', '')}", m.getAttributeValue("start text"));
+ }
+
+ public void testPaletteInsertHelper() throws Exception {
+ IWorkbench w = JsfUiPlugin.getDefault().getWorkbench();
+ IWorkbenchWindow window = w.getActiveWorkbenchWindow();
+
+ //open Web Development perspective
+ w.showPerspective(WebDevelopmentPerspectiveFactory.PERSPECTIVE_ID, window);
+
+ //open file
+ IFile f = jsfProject.getFile(new Path("WebContent/pages/hello2.jsp"));
+ assertNotNull(f);
+ IEditorPart editor = IDE.openEditor(window.getActivePage(), f);
+ assertNotNull(editor);
+ assertTrue(editor instanceof JSPMultiPageEditor);
+ JSPMultiPageEditor jspEditor = (JSPMultiPageEditor)editor;
+
+ //Test applying prefix
+ String[] text = {"${containsIgnoreCase('', '')}"};
+ JSPPaletteInsertHelper.applyPrefix(text, jspEditor.getSourceEditor(), "containsIgnoreCase", "http://java.sun.com/jsp/jstl/functions", "fn");
+ assertEquals("Prefix is not substituted correctly.", "${fn2:containsIgnoreCase('', '')}", text[0]);
+
+ //Set selection in text editor.
+ int offset = 306;
+ ISelectionProvider selProvider = jspEditor.getSourceEditor().getSelectionProvider();
+ selProvider.setSelection(new TextSelection(offset, 0));
+
+ //Prepare parameters
+ ISourceViewer v = (ISourceViewer)jspEditor.getSourceEditor().getAdapter(ISourceViewer.class);
+ assertNotNull(v);
+ Properties p = new Properties();
+ p.setProperty(PaletteInsertHelper.PROPOPERTY_TAG_NAME, "containsIgnoreCase");
+ p.setProperty(PaletteInsertHelper.PROPOPERTY_START_TEXT, "${containsIgnoreCase('', '')}");
+ p.setProperty(JSPPaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI, "http://java.sun.com/jsp/jstl/functions");
+
+ //Execute insert into editor.
+ JSPPaletteInsertHelper.getInstance().insertIntoEditor(v, p);
+ IDocument doc = jspEditor.getSourceEditor().getDocumentProvider().getDocument(editor.getEditorInput());
+ assertTrue(doc.get().indexOf("${fn2:containsIgnoreCase('', '')}") >= 0);
+ }
+
}
14 years
JBoss Tools SVN: r27280 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-12-09 09:41:47 -0500 (Thu, 09 Dec 2010)
New Revision: 27280
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java
Log:
JBIDE-5661
https://issues.jboss.org/browse/JBIDE-5661
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java 2010-12-09 14:41:00 UTC (rev 27279)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPPaletteInsertHelper.java 2010-12-09 14:41:47 UTC (rev 27280)
@@ -113,6 +113,10 @@
if(k >= 0) {
return text.substring(0, k + 2) + prefix + ":" + text.substring(k + 2); //$NON-NLS-1$
}
+ k = text.toLowerCase().indexOf("${" + tagname.toLowerCase()); //$NON-NLS-1$
+ if(k >= 0) {
+ return text.substring(0, k + 2) + prefix + ":" + text.substring(k + 2); //$NON-NLS-1$
+ }
return text;
}
14 years
JBoss Tools SVN: r27279 - in trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model: helpers and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-12-09 09:41:00 -0500 (Thu, 09 Dec 2010)
New Revision: 27279
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/JSPAdopt.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/helpers/TLDToPaletteHelper.java
Log:
JBIDE-5661
https://issues.jboss.org/browse/JBIDE-5661
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/JSPAdopt.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/JSPAdopt.java 2010-12-09 14:30:23 UTC (rev 27278)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/JSPAdopt.java 2010-12-09 14:41:00 UTC (rev 27279)
@@ -126,6 +126,7 @@
if(!Character.isJavaIdentifierPart(c) && c != '.' && c != ':') return false;
}
int q = s.indexOf('<');
+ if(q < 0) q = s.indexOf("${");
if(q < 0) return false;
if(s.indexOf(n, q) < 0) return false;
return true;
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/helpers/TLDToPaletteHelper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/helpers/TLDToPaletteHelper.java 2010-12-09 14:30:23 UTC (rev 27278)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/helpers/TLDToPaletteHelper.java 2010-12-09 14:41:00 UTC (rev 27279)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.web.tld.model.helpers;
import java.util.*;
+
import org.jboss.tools.common.model.*;
import org.jboss.tools.jst.web.tld.URIConstants;
import org.jboss.tools.jst.web.tld.model.TLDUtil;
@@ -167,6 +168,13 @@
if(TLDUtil.isTag(tags[i])) tab.addChild(createMacroByTag(tags[i], model));
if(TLDUtil.isFaceletTag(tags[i])) tab.addChild(createMacroByFaceletTag(tags[i], model));
}
+ XModelObject f = tld.getChildByPath("Functions"); //$NON-NLS-1$
+ if(f != null) {
+ XModelObject[] fs = f.getChildren();
+ for (int i = 0; i < fs.length; i++) {
+ tab.addChild(createMacroByFunction(fs[i], model));
+ }
+ }
return tab;
}
@@ -174,5 +182,43 @@
return (s.length() == 0) ? s : Character.toUpperCase(s.charAt(0)) + s.substring(1);
}
+ public XModelObject createMacroByFunction(XModelObject tag, XModel model) {
+ Properties p = new Properties();
+// String parentname = getTldName(tag.getParent());
+// String prefix = (parentname.length() == 0) ? "" : parentname + ":"; //$NON-NLS-1$ //$NON-NLS-2$
+ String shortname = tag.getAttributeValue("name"); //$NON-NLS-1$
+ p.setProperty("name", shortname); //$NON-NLS-1$
+ String signature = tag.getAttributeValue("function-signature"); //$NON-NLS-1$
+ int i = signature.indexOf("("); //$NON-NLS-1$
+ int j = signature.indexOf(")"); //$NON-NLS-1$
+ List<String> paramTypes = new ArrayList<String>();
+ if(i >= 0 && j > i) {
+ String params = signature.substring(i + 1, j);
+ StringTokenizer st = new StringTokenizer(params, ","); //$NON-NLS-1$
+ while(st.hasMoreTokens()) {
+ String param = st.nextToken().trim();
+ paramTypes.add(param);
+ }
+ }
+
+ StringBuffer sb = new StringBuffer();
+ sb.append("${"); //$NON-NLS-1$
+ sb.append(shortname);
+ sb.append("("); //$NON-NLS-1$
+ for (int k = 0; k < paramTypes.size(); k++) {
+ if(k > 0) sb.append(", "); //$NON-NLS-1$
+ sb.append("''"); //$NON-NLS-1$
+ }
+ sb.append(")"); //$NON-NLS-1$
+ sb.append("}"); //$NON-NLS-1$
+ p.setProperty(START_TEXT, sb.toString());
+
+ sb = new StringBuffer();
+ sb.append("<b>").append(shortname).append("</b><br>"); //$NON-NLS-1$ //$NON-NLS-2$
+ sb.append(signature);
+ p.setProperty(DESCRIPTION, sb.toString());
+ return model.createModelObject("SharableMacroHTML", p); //$NON-NLS-1$
+ }
+
}
14 years