You are viewing a plain text version of this content. The canonical link for it is here.
Posted to easyant-commits@incubator.apache.org by hi...@apache.org on 2011/02/17 20:23:04 UTC
svn commit: r1071768 [5/7] - in /incubator/easyant/easyant4e: ./ trunk/
trunk/org.apache.easyant/ trunk/org.apache.easyant/META-INF/
trunk/org.apache.easyant/lib/ trunk/org.apache.easyant4e.feature/
trunk/org.apache.easyant4e.releng/ trunk/org.apache.e...
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleBlock.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleBlock.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleBlock.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleBlock.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,301 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.ivyde.extension.page;
+
+import org.apache.easyant.core.report.PhaseReport;
+import org.apache.easyant.core.report.TargetReport;
+import org.apache.easyant4e.EasyAntConstants;
+import org.apache.easyant4e.console.EasyAntConsole;
+import org.apache.easyant4e.providers.ImageProvider;
+import org.apache.easyant4e.services.EasyantProjectService;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.WorkspaceJob;
+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.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.internal.ui.callhierarchy.HistoryListAction;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.forms.DetailsPart;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.MasterDetailsBlock;
+import org.eclipse.ui.forms.SectionPart;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+import com.google.inject.Inject;
+
+//import com.google.inject.Inject;
+
+/**
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class BuildLifecycleBlock extends MasterDetailsBlock {
+ private FormPage page;
+
+ private BuildLifeCycleContentProvider buildLifeCycleContentProvider;
+ private BuildLifecycleLabelProvider buildLifecycleLabelProvider;
+ private EasyantProjectService easyantProjectService;
+ private PhaseDetailsPage phaseDetailsPage;
+ private TargetDetailsPage targetDetailsPage;
+ private EasyAntConsole console;
+ private ImageProvider imageProvider;
+ private boolean enableInfoLogLevel = false;
+ private boolean enableVerboseLogLevel = false;
+ private boolean enableDebugLogLevel = false;
+
+
+ public BuildLifecycleBlock() {}
+
+ @Inject
+ public void setImageProvider(ImageProvider imageProvider) {
+ this.imageProvider = imageProvider;
+ }
+
+ @Inject
+ public void setConsole(EasyAntConsole console) {
+ this.console = console;
+ }
+
+ @Inject
+ public void setPhaseDetailsPage(PhaseDetailsPage phaseDetailsPage) {
+ this.phaseDetailsPage = phaseDetailsPage;
+ }
+
+ @Inject
+ public void setTargetDetailsPage(TargetDetailsPage targetDetailsPage) {
+ this.targetDetailsPage = targetDetailsPage;
+ }
+
+ @Inject
+ public void setEasyantProjectService(EasyantProjectService easyantProjectService) {
+ this.easyantProjectService = easyantProjectService;
+ }
+
+ @Inject
+ public void setBuildLifecycleLabelProvider(BuildLifecycleLabelProvider buildLifecycleLabelProvider) {
+ this.buildLifecycleLabelProvider = buildLifecycleLabelProvider;
+ }
+
+ @Inject
+ public void setBuildLifeCycleContentProvider(BuildLifeCycleContentProvider buildLifeCycleContentProvider) {
+ this.buildLifeCycleContentProvider = buildLifeCycleContentProvider;
+ }
+
+ public void setPage(FormPage page) {
+ this.page = page;
+ }
+
+ @Override
+ protected void createMasterPart(final IManagedForm managedForm, final Composite parent) {
+ createBuildLifecyclePart(managedForm, parent);
+ }
+
+ protected void createBuildLifecyclePart(final IManagedForm managedForm, final Composite parent) {
+ FormToolkit toolkit = managedForm.getToolkit();
+ Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
+ section.setText("Build Lifecycle");
+ section.setDescription("The build lifecycle has the following build phases:");
+ section.marginWidth = 10;
+ section.marginHeight = 5;
+ Composite client = toolkit.createComposite(section, SWT.WRAP);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginWidth = 2;
+ layout.marginHeight = 2;
+ client.setLayout(layout);
+ toolkit.paintBordersFor(client);
+
+ section.setClient(client);
+ final SectionPart spart = new SectionPart(section);
+ managedForm.addPart(spart);
+ TreeViewer viewer = new TreeViewer(client);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 20;
+ gd.widthHint = 100;
+ viewer.getTree().setLayoutData(gd);
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ managedForm.fireSelectionChanged(spart, event.getSelection());
+ }
+ });
+ viewer.addDoubleClickListener(new IDoubleClickListener(){
+ public void doubleClick(DoubleClickEvent event) {
+ ISelection selection = event.getSelection();
+ if(selection instanceof StructuredSelection){
+ StructuredSelection structuredSelection = (StructuredSelection)selection;
+ if(!structuredSelection.isEmpty()){
+ Object o = structuredSelection.getFirstElement();
+ if(o instanceof PhaseReport){
+ runPhase((PhaseReport)o);
+ }else if(o instanceof TargetReport){
+ runTarget((TargetReport)o);
+ }
+ }
+ }
+ }
+ });
+ viewer.setContentProvider(buildLifeCycleContentProvider);
+ viewer.setLabelProvider(buildLifecycleLabelProvider);
+ viewer.setInput(page.getEditor().getEditorInput());
+ // viewer.expandAll();
+ }
+
+ private void runPhase(final PhaseReport phase){
+ Job job = new WorkspaceJob("Easyant running phase " + phase.getName() + "...") {
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ easyantProjectService.runBuild(getProject(), phase.getName(), getLogLevel(), monitor);
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+ }
+
+ private void runTarget(final TargetReport target){
+ Job job = new WorkspaceJob("Easyant running target " + target.getName() + "...") {
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ easyantProjectService.runBuild(getProject(), target.getName(), getLogLevel(), monitor);
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+ }
+
+ private int getLogLevel(){
+ int logLevel = EasyAntConstants.ANT_LOGLEVEL_WARN;
+ if(enableInfoLogLevel){
+ logLevel = EasyAntConstants.ANT_LOGLEVEL_INFO;
+ }
+ if(enableVerboseLogLevel){
+ logLevel = EasyAntConstants.ANT_LOGLEVEL_VERBOSE;
+ }
+ if(enableDebugLogLevel){
+ logLevel = EasyAntConstants.ANT_LOGLEVEL_DEBUG;
+ }
+ return logLevel;
+ }
+
+ protected void registerPages(DetailsPart detailsPart) {
+ phaseDetailsPage.setProject(getProject());
+ detailsPart.registerPage(PhaseReport.class, phaseDetailsPage);
+ targetDetailsPage.setProject(getProject());
+ detailsPart.registerPage(TargetReport.class, targetDetailsPage);
+ }
+
+ @Override
+ protected void createToolBarActions(IManagedForm managedForm) {
+ final ScrolledForm form = managedForm.getForm();
+ Action setLogLevelAction = new LogLevelDropDownAction();
+ form.getToolBarManager().add(setLogLevelAction);
+ }
+
+ private IProject getProject() {
+ if (page.getEditor().getEditorInput() instanceof IFileEditorInput) {
+ IFileEditorInput fileEditorInput = (IFileEditorInput) page.getEditor().getEditorInput();
+ IFile ivyFile = fileEditorInput.getFile();
+ return ivyFile.getProject();
+ }
+ return null;
+ }
+
+ private class LogLevelDropDownAction extends Action implements IMenuCreator {
+ private Menu menu;
+
+ public LogLevelDropDownAction(){
+ super("setDebugLogLevel", Action.AS_DROP_DOWN_MENU);
+ setMenuCreator(this);
+ setToolTipText("Set the log level in console view.");
+ setImageDescriptor(imageProvider.getDebugLogLevelImage());
+ }
+
+ public Menu getMenu(Menu parent) { return null; }
+ public Menu getMenu(Control parent) {
+ if (menu == null){
+ menu = new Menu(parent);
+ MenuItem info = new MenuItem(menu, SWT.CHECK);
+ info.setText("INFO");
+ info.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ enableInfoLogLevel=!enableInfoLogLevel;
+ phaseDetailsPage.setLogLevel(getLogLevel());
+ targetDetailsPage.setLogLevel(getLogLevel());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ });
+ MenuItem verbose = new MenuItem(menu, SWT.CHECK);
+ verbose.setText("VERBOSE");
+ verbose.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ enableVerboseLogLevel=!enableVerboseLogLevel;
+ phaseDetailsPage.setLogLevel(getLogLevel());
+ targetDetailsPage.setLogLevel(getLogLevel());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ });
+ MenuItem debug = new MenuItem(menu, SWT.CHECK);
+ debug.setText("DEBUG");
+ debug.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ enableDebugLogLevel=!enableDebugLogLevel;
+ phaseDetailsPage.setLogLevel(getLogLevel());
+ targetDetailsPage.setLogLevel(getLogLevel());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ });
+ }
+ return menu;
+ }
+
+ public void dispose() {
+ if (menu != null){
+ menu.dispose();
+ menu=null;
+ }
+ }
+
+ public void run() {}
+ }
+
+}
\ No newline at end of file
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleBlock.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleBlock.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleBlock.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleLabelProvider.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleLabelProvider.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleLabelProvider.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleLabelProvider.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.ivyde.extension.page;
+
+import org.apache.easyant.core.report.PhaseReport;
+import org.apache.easyant.core.report.TargetReport;
+import org.apache.easyant4e.providers.ImageProvider;
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+import com.google.inject.Inject;
+
+//import com.google.inject.Inject;
+
+/**
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class BuildLifecycleLabelProvider extends BaseLabelProvider implements ILabelProvider {
+
+ @Inject
+ private ImageProvider imageProvider;
+
+ public BuildLifecycleLabelProvider(){
+
+ }
+
+ public Image getImage(Object element) {
+ if (element instanceof PhaseReport) {
+ return imageProvider.getPhaseImage();
+ }
+ if (element instanceof TargetReport) {
+ return imageProvider.getTargetImage();
+ }
+ return null;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof PhaseReport) {
+ PhaseReport phaseReport = (PhaseReport) element;
+ return phaseReport.getName();
+ }
+ if (element instanceof TargetReport) {
+ TargetReport targetReport = (TargetReport) element;
+ return targetReport.getName();
+ }
+ return element.toString();
+ }
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleLabelProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleLabelProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildLifecycleLabelProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildPage.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildPage.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildPage.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildPage.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.ivyde.extension.page;
+
+import org.apache.easyant4e.Activator;
+import org.apache.easyant4e.console.EasyAntConsole;
+import org.apache.easyant4e.providers.ImageProvider;
+import org.apache.ivyde.eclipse.extension.IvyEditorPage;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+import com.google.inject.Inject;
+
+/**
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class BuildPage extends FormPage implements IvyEditorPage {
+
+ private static final String ID = "build";
+ private static final String NAME = "Build";
+ private BuildLifecycleBlock buildLifecycleBlock;
+ private ImageProvider imageProvider;
+ private EasyAntConsole console;
+
+ @Inject
+ public void setEasyAntConsole(EasyAntConsole console){
+ this.console = console;
+ }
+
+ @Inject
+ public void setBuildLifecycleBlock(BuildLifecycleBlock buildLifecycleBlock) {
+ this.buildLifecycleBlock = buildLifecycleBlock;
+ }
+
+ @Inject
+ public void setImageProvider(ImageProvider imageProvider) {
+ this.imageProvider = imageProvider;
+ }
+
+ public BuildPage() {
+ super(ID, NAME);
+ Activator.getEasyAntPlugin().injectMembers(this);
+ }
+
+ protected void createFormContent(IManagedForm managedForm) {
+ super.createFormContent(managedForm);
+ buildLifecycleBlock.setPage(this);
+
+ final ScrolledForm form = managedForm.getForm();
+ form.setText("EasyAnt Build");
+ form.setBackgroundImage(imageProvider.getFormBackgroundImage());
+ buildLifecycleBlock.createContent(managedForm);
+
+ console.show();
+ }
+
+ public String getPageName() {
+ return NAME;
+ }
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildPage.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/BuildPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/PhaseDetailsPage.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/PhaseDetailsPage.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/PhaseDetailsPage.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/PhaseDetailsPage.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,210 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.ivyde.extension.page;
+
+import org.apache.easyant.core.report.PhaseReport;
+import org.apache.easyant4e.EasyAntConstants;
+import org.apache.easyant4e.providers.ImageProvider;
+import org.apache.easyant4e.services.EasyantProjectService;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.WorkspaceJob;
+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.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.IDetailsPage;
+import org.eclipse.ui.forms.IFormPart;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+import com.google.inject.Inject;
+
+//import com.google.inject.Inject;
+
+/**
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class PhaseDetailsPage implements IDetailsPage {
+ private IManagedForm mform;
+ private PhaseReport phase;
+ private IProject project;
+
+ private Text description;
+ private Text depends;
+
+ private EasyantProjectService easyantProjectService;
+
+ private ImageProvider imageProvider;
+
+ private int logLevel=EasyAntConstants.ANT_LOGLEVEL_WARN;
+
+ public void setLogLevel(int logLevel){
+ this.logLevel=logLevel;
+ }
+
+ public PhaseDetailsPage() {
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ @Inject
+ public void setImageProvider(ImageProvider imageProvider) {
+ this.imageProvider = imageProvider;
+ }
+
+ @Inject
+ public void setEasyantProjectService(EasyantProjectService easyantProjectService) {
+ this.easyantProjectService = easyantProjectService;
+ }
+
+ public void initialize(IManagedForm mform) {
+ this.mform = mform;
+ }
+
+ public void createContents(Composite parent) {
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.topMargin = 5;
+ layout.leftMargin = 5;
+ layout.rightMargin = 2;
+ layout.bottomMargin = 2;
+ parent.setLayout(layout);
+
+ FormToolkit toolkit = mform.getToolkit();
+ Section section1 = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
+ section1.marginWidth = 10;
+ section1.setText("Phase Details");
+ section1
+ .setDescription("Phases define an ordered set of build phases. Build phases are responsible for the build choreography at macro level.");
+ TableWrapData td = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP);
+ td.grabHorizontal = true;
+ section1.setLayoutData(td);
+ Composite client = toolkit.createComposite(section1);
+ GridLayout glayout = new GridLayout();
+ glayout.marginWidth = glayout.marginHeight = 0;
+ client.setLayout(glayout);
+
+ createSpacer(toolkit, client, 2);
+
+ toolkit.createLabel(client, "Description:");
+ description = toolkit.createText(client, "", SWT.MULTI | SWT.WRAP);
+ GridData gdDescription = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ gdDescription.widthHint = 10;
+ description.setLayoutData(gdDescription);
+
+ createSpacer(toolkit, client, 2);
+
+ toolkit.createLabel(client, "Depends:");
+ depends = toolkit.createText(client, "", SWT.MULTI | SWT.WRAP);
+ GridData gdDepends = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ gdDepends.widthHint = 10;
+ depends.setLayoutData(gdDepends);
+
+ createSpacer(toolkit, client, 2);
+
+ ImageHyperlink buildLink = toolkit.createImageHyperlink(client, SWT.NULL);
+ buildLink.setText("Run this phase...");
+ buildLink.setForeground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_BLUE));
+ buildLink.setImage(imageProvider.getBuildImage());
+ buildLink.addHyperlinkListener(new HyperlinkAdapter() {
+ public void linkActivated(HyperlinkEvent e) {
+ Job job = new WorkspaceJob("Easyant running phase " + phase.getName() + "...") {
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ easyantProjectService.runBuild(project, phase.getName(), logLevel, monitor);
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+ }
+ });
+
+ section1.setClient(client);
+ }
+
+ private void createSpacer(FormToolkit toolkit, Composite parent, int span) {
+ Label spacer = toolkit.createLabel(parent, ""); //$NON-NLS-1$
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ spacer.setLayoutData(gd);
+ }
+
+ private void update() {
+ if (phase.getDescription() != null) {
+ description.setText(phase.getDescription());
+ }
+ if (phase.getDepends() != null) {
+ depends.setText(phase.getDepends());
+ }
+ }
+
+ public void selectionChanged(IFormPart part, ISelection selection) {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
+ if (ssel.size() == 1) {
+ phase = (PhaseReport) ssel.getFirstElement();
+ } else {
+ phase = null;
+ }
+ update();
+ }
+
+ public void commit(boolean onSave) {
+ }
+
+ public void setFocus() {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isDirty() {
+ return false;
+ }
+
+ public boolean isStale() {
+ return false;
+ }
+
+ public void refresh() {
+ update();
+ }
+
+ public boolean setFormInput(Object input) {
+ return false;
+ }
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/PhaseDetailsPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/PhaseDetailsPage.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/PhaseDetailsPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/TargetDetailsPage.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/TargetDetailsPage.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/TargetDetailsPage.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/TargetDetailsPage.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.ivyde.extension.page;
+
+import org.apache.easyant.core.report.TargetReport;
+import org.apache.easyant4e.EasyAntConstants;
+import org.apache.easyant4e.providers.ImageProvider;
+import org.apache.easyant4e.services.EasyantProjectService;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.WorkspaceJob;
+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.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.IDetailsPage;
+import org.eclipse.ui.forms.IFormPart;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+import com.google.inject.Inject;
+
+/**
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class TargetDetailsPage implements IDetailsPage {
+ private IManagedForm mform;
+ private TargetReport target;
+
+ private IProject project;
+
+ private Text description;
+ private Text depends;
+
+ private EasyantProjectService easyantProjectService;
+
+ private ImageProvider imageProvider;
+
+ private int logLevel=EasyAntConstants.ANT_LOGLEVEL_WARN;
+
+ public void setLogLevel(int logLevel){
+ this.logLevel=logLevel;
+ }
+
+ public TargetDetailsPage() {}
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ @Inject
+ public void setImageProvider(ImageProvider imageProvider) {
+ this.imageProvider = imageProvider;
+ }
+
+
+ @Inject
+ public void setEasyantProjectService(EasyantProjectService easyantProjectService) {
+ this.easyantProjectService = easyantProjectService;
+ }
+
+ public void createContents(Composite parent) {
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.topMargin = 5;
+ layout.leftMargin = 5;
+ layout.rightMargin = 2;
+ layout.bottomMargin = 2;
+ parent.setLayout(layout);
+
+ FormToolkit toolkit = mform.getToolkit();
+ Section section1 = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
+ section1.marginWidth = 10;
+ section1.setText("Target Details");
+ section1.setDescription("Targets define a build unit.");
+ TableWrapData td = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP);
+ td.grabHorizontal = true;
+ section1.setLayoutData(td);
+ Composite client = toolkit.createComposite(section1);
+ GridLayout glayout = new GridLayout();
+ glayout.marginWidth = glayout.marginHeight = 0;
+ client.setLayout(glayout);
+
+ createSpacer(toolkit, client, 2);
+
+ toolkit.createLabel(client, "Description:");
+ description = toolkit.createText(client, "", SWT.MULTI | SWT.WRAP);
+ GridData gdDescription = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ gdDescription.widthHint = 10;
+ description.setLayoutData(gdDescription);
+
+ createSpacer(toolkit, client, 2);
+
+ toolkit.createLabel(client, "Depends:");
+ depends = toolkit.createText(client, "", SWT.MULTI | SWT.WRAP);
+ GridData gdDepends = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ gdDepends.widthHint = 10;
+ depends.setLayoutData(gdDepends);
+
+ createSpacer(toolkit, client, 2);
+
+ ImageHyperlink buildLink = toolkit.createImageHyperlink(client, SWT.NULL);
+ buildLink.setText("Run this target...");
+ buildLink.setForeground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_BLUE));
+ buildLink.setImage(imageProvider.getBuildImage());
+ buildLink.addHyperlinkListener(new HyperlinkAdapter() {
+ public void linkActivated(HyperlinkEvent e) {
+ Job job = new WorkspaceJob("Easyant running target " + target.getName() + "...") {
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ easyantProjectService.runBuild(project, target.getName(), logLevel, monitor);
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+ }
+ });
+ section1.setClient(client);
+ }
+
+ private void createSpacer(FormToolkit toolkit, Composite parent, int span) {
+ Label spacer = toolkit.createLabel(parent, ""); //$NON-NLS-1$
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ spacer.setLayoutData(gd);
+ }
+
+ public void initialize(IManagedForm form) {
+ this.mform = form;
+ }
+
+ public void selectionChanged(IFormPart part, ISelection selection) {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
+ if (ssel.size() == 1) {
+ target = (TargetReport) ssel.getFirstElement();
+ } else {
+ target = null;
+ }
+ update();
+ }
+
+ private void update() {
+ if(target.getDescription()!=null){
+ description.setText(target.getDescription());
+ }
+ if(target.getDepends()!=null){
+ depends.setText(target.getDepends());
+ }
+ }
+
+
+ public void commit(boolean onSave) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isDirty() {
+ return false;
+ }
+
+ public boolean isStale() {
+ return false;
+ }
+
+ public void refresh() {
+ }
+
+ public void setFocus() {
+ }
+
+ public boolean setFormInput(Object input) {
+ return false;
+ }
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/TargetDetailsPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/TargetDetailsPage.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/ivyde/extension/page/TargetDetailsPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAnt4EclipseModule.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAnt4EclipseModule.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAnt4EclipseModule.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAnt4EclipseModule.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.modules;
+
+import org.apache.easyant4e.console.EasyAntConsole;
+import org.apache.easyant4e.console.EasyAntConsoleImpl;
+import org.apache.easyant4e.ivyde.extension.page.BuildLifeCycleContentProvider;
+import org.apache.easyant4e.ivyde.extension.page.BuildLifecycleBlock;
+import org.apache.easyant4e.ivyde.extension.page.BuildLifecycleLabelProvider;
+import org.apache.easyant4e.ivyde.extension.page.PhaseDetailsPage;
+import org.apache.easyant4e.ivyde.extension.page.TargetDetailsPage;
+import org.apache.easyant4e.providers.ImageProvider;
+import org.apache.easyant4e.providers.ImageProviderImpl;
+import org.apache.easyant4e.services.EasyantCoreService;
+import org.apache.easyant4e.services.EasyantCoreServiceImpl;
+import org.apache.easyant4e.services.EasyantProjectService;
+import org.apache.easyant4e.services.EasyantProjectServiceImpl;
+import org.apache.easyant4e.wizards.EasyAntImportWizardPage;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+
+
+/**
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class EasyAnt4EclipseModule extends AbstractModule{
+
+
+ @Override
+ protected void configure() {
+ bind(EasyAntConsole.class).to(EasyAntConsoleImpl.class).in(Singleton.class);
+ bind(ImageProvider.class).to(ImageProviderImpl.class).in(Singleton.class);
+ bind(EasyantCoreService.class).to(EasyantCoreServiceImpl.class).in(Singleton.class);
+ bind(EasyantProjectService.class).to(EasyantProjectServiceImpl.class).in(Singleton.class);
+
+ bind(BuildLifecycleBlock.class).in(Singleton.class);
+ bind(BuildLifeCycleContentProvider.class).in(Singleton.class);
+ bind(BuildLifecycleLabelProvider.class).in(Singleton.class);
+ bind(PhaseDetailsPage.class).in(Singleton.class);
+ bind(TargetDetailsPage.class).in(Singleton.class);
+
+ bind(EasyAntImportWizardPage.class);//.in(Singleton.class);
+
+ // Bind to instance
+ //binder.bind(Appendable.class).toInstance(System.out);
+
+ }
+
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAnt4EclipseModule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAnt4EclipseModule.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAnt4EclipseModule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAntCoreModule.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAntCoreModule.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAntCoreModule.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAntCoreModule.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.modules;
+
+import static org.apache.easyant4e.EasyAntConstants.PLUGINS_SETTINGS;
+
+import java.net.URL;
+
+import org.apache.easyant.core.EasyAntConfiguration;
+import org.apache.easyant.core.EasyAntEngine;
+import org.apache.easyant.core.factory.EasyantConfigurationFactory;
+import org.apache.easyant4e.Activator;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+
+/**
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class EasyAntCoreModule extends AbstractModule{
+
+ @Override
+ protected void configure() {
+ bind(EasyAntEngine.class).toProvider(new Provider<EasyAntEngine>() {
+ public EasyAntEngine get() {
+ URL url = Activator.getDefault().getBundle().getResource(PLUGINS_SETTINGS);
+ EasyAntConfiguration configuration= EasyantConfigurationFactory.getInstance().createDefaultConfiguration();
+ configuration.setEasyantIvySettingsUrl(url);
+ return new EasyAntEngine(configuration);
+ }
+
+ }).in(Singleton.class);
+ }
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAntCoreModule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAntCoreModule.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/modules/EasyAntCoreModule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureAction.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureAction.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureAction.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureAction.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.natures;
+
+import org.apache.easyant4e.Activator;
+import org.apache.easyant4e.services.EasyantProjectService;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import com.google.inject.Inject;
+
+//import com.google.inject.Inject;
+
+/**
+ * Add the EasyAnt nature to the project.
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class AddEasyAntNatureAction implements IObjectActionDelegate {
+
+ // The selected project
+ private IProject selectedProject;
+ private EasyantProjectService easyantProjectService;
+
+ public AddEasyAntNatureAction(){
+ Activator.getEasyAntPlugin().injectMembers(this);
+ }
+
+ @Inject
+ public void setEasyantProjectService(EasyantProjectService easyantProjectService) {
+ this.easyantProjectService = easyantProjectService;
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ public void run(IAction action) {
+ if (selectedProject != null) {
+ // Add the nature on the selected project
+ easyantProjectService.addNature(selectedProject);
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structuredSelection = (StructuredSelection) selection;
+ if (!structuredSelection.isEmpty() && structuredSelection.getFirstElement() instanceof IProject) {
+ IProject project = (IProject) structuredSelection.getFirstElement();
+ if (project.isAccessible()) {
+ this.selectedProject = project;
+ if (action != null) {
+ action.setEnabled(!easyantProjectService.hasEasyAntNature(project));
+ }
+ }
+
+ }
+ }
+ }
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureAction.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureOperation.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureOperation.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureOperation.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureOperation.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.natures;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.easyant4e.Activator;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+/**
+ * Add the EasyAnt nature to the project.
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class AddEasyAntNatureOperation implements IRunnableWithProgress {
+
+ private IProject project;
+
+ public AddEasyAntNatureOperation(IProject project) {
+ this.project = project;
+ }
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ if (project != null) {
+ try {
+ if (!project.hasNature(EasyAntNature.NATURE_ID)) {
+ monitor.subTask("Add the EasyAnt nature to the project " + project.getName());
+ IProjectDescription description = project.getDescription();
+ String[] oldNatures = description.getNatureIds();
+ String[] newNatures = new String[oldNatures.length + 1];
+ System.arraycopy(oldNatures, 0, newNatures, 1, oldNatures.length);
+ newNatures[0] = EasyAntNature.NATURE_ID;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, new SubProgressMonitor(monitor, 1));
+ }
+ } catch (CoreException e) {
+ Activator.getEasyAntPlugin().log(e);
+ }
+ monitor.done();
+ }
+
+ }
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureOperation.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/AddEasyAntNatureOperation.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/EasyAntNature.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/EasyAntNature.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/EasyAntNature.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/EasyAntNature.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,323 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.natures;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.easyant.core.descriptor.PropertyDescriptor;
+import org.apache.easyant4e.Activator;
+import org.apache.easyant4e.services.EasyantProjectService;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.launching.JavaRuntime;
+
+import com.google.inject.Inject;
+
+/**
+ * The EastAnt nature.
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class EasyAntNature implements IProjectNature {
+
+ public static final String NATURE_ID = "org.apache.easyant4e.EasyAntNature";
+
+ public static final String BUILDER_ID = "org.apache.easyant4e.EasyAntBuilder";
+
+ public EasyAntNature(){
+ Activator.getEasyAntPlugin().injectMembers(this);
+ }
+
+ /**
+ * The project to which this project nature applies.
+ */
+ private IProject project = null;
+
+ private EasyantProjectService easyantProjectService;
+
+ @Inject
+ public void setEasyantProjectService(EasyantProjectService easyantProjectService){
+ this.easyantProjectService = easyantProjectService;
+ }
+
+
+ public void configure() throws CoreException {
+ //TODO maybe add an extension point to delegate this step for java, scala, ...
+ //Configurer.configure(IProject, EasyAntModuleDescriptor);
+ //Add Java Nature
+ //TODO add checkbox or list of configurer (reuse by skeleton) in import and new project wizard to add JavaNature, ScalaNature, GroovyNature ...
+ //or use a dedicated eclipse plugin ?
+ if (!project.hasNature(JavaCore.NATURE_ID)) {
+ IProjectDescription desc = project.getDescription();
+ List<String> natures = new ArrayList<String>();
+ natures.addAll(Arrays.asList(desc.getNatureIds()));
+ natures.add(JavaCore.NATURE_ID);
+ desc.setNatureIds(natures.toArray(new String[natures.size()]));
+ project.setDescription(desc, null);
+ }
+
+ if (project.hasNature(JavaCore.NATURE_ID)) {
+ IJavaProject javaProject = (IJavaProject)project.getNature(JavaCore.NATURE_ID);
+ //flush classpath
+ javaProject.setRawClasspath(new IClasspathEntry[0], null);
+ addSourceFolders(javaProject);
+ addDefaultJREContainer(javaProject);
+ addIvyClasspathContainer();
+ addBuilder(BUILDER_ID);
+ }
+ }
+
+ private void addIvyClasspathContainer() {
+ /*
+ IPath projectRelativePath = new Path("module.ivy");
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry newEntry = JavaCore.newContainerEntry(new Path(
+ IvyClasspathContainer.CONTAINER_ID).append(projectRelativePath).append(confs));
+ */
+ IJavaProject javaProject = JavaCore.create(project);
+ //Configure project preferences
+ StringBuffer projectConf = new StringBuffer();
+ //TODO search *.ivy file
+ projectConf.append("?ivyXmlPath=module.ivy");
+ try {
+ appendConfProp(projectConf, "confs", "*");
+ appendConfProp(projectConf, "resolveInWorkspace", Boolean.TRUE.toString());
+ String projectIvySettings = easyantProjectService.getProperty(javaProject.getProject(), "project.ivy.settings.url").getValue();
+ if(projectIvySettings==null){
+ projectIvySettings = easyantProjectService.getProperty(javaProject.getProject(), "project.ivy.settings.file").getValue();
+ if(projectIvySettings!=null){
+ projectIvySettings = "file://"+resolveRelativePath(projectIvySettings);
+ }
+ }
+ if(projectIvySettings!=null){
+ appendConfProp(projectConf, "ivySettingsPath", projectIvySettings);
+ }
+ } catch (UnsupportedEncodingException e) {
+ Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage(), e);
+ }
+
+ // add the classpath entry
+ IPath path = new Path(IvyClasspathContainer.CONTAINER_ID).append(projectConf.toString());
+ IClasspathEntry newEntry = JavaCore.newContainerEntry(path);
+ addClassPathEntry(javaProject, newEntry);
+ }
+
+ private String resolveRelativePath(String path){
+ if(path!=null && path.startsWith(".")){
+ String projectPath = project.getLocation().toPortableString();
+ path= new File(projectPath+"/"+path).getAbsolutePath();
+ }
+ return path;
+ }
+
+ private void appendConfProp(StringBuffer path, String name, String value) throws UnsupportedEncodingException {
+ path.append('&');
+ path.append(name);
+ path.append('=');
+ path.append(URLEncoder.encode(value, "UTF-8"));
+ }
+
+ //FIXME with scala project or others
+ private void addSourceFolders(IJavaProject javaProject)throws CoreException {
+ PropertyDescriptor srcMainJavaProp = easyantProjectService.getProperty(project, "src.main.java");
+ String srcMainJava = removeBaseDirVar(srcMainJavaProp.getValue());
+ PropertyDescriptor srcMainResourcesProp = easyantProjectService.getProperty(project, "src.main.resources");
+ String srcMainResources = removeBaseDirVar(srcMainResourcesProp.getValue());
+ PropertyDescriptor srcTestJavaProp = easyantProjectService.getProperty(project, "src.test.java");
+ String srcTestJava = removeBaseDirVar(srcTestJavaProp.getValue());
+ PropertyDescriptor srcTestResourcesProp = easyantProjectService.getProperty(project, "src.test.resources");
+ String srcTestResources = removeBaseDirVar(srcTestResourcesProp.getValue());
+ addSourceFolders(javaProject, srcMainJava,srcMainResources, srcTestJava, srcTestResources);
+ }
+
+ private String removeBaseDirVar(String s){
+ String baseDirVar = "${basedir}";
+ if(s!=null && s.contains(baseDirVar)){
+ return s.substring(s.indexOf(baseDirVar)+baseDirVar.length()+1);
+ }else{
+ return s;
+ }
+ }
+
+ public void deconfigure() throws CoreException {
+ if (project.hasNature(JavaCore.NATURE_ID)) {
+ removeBuilder(BUILDER_ID);
+ removeIvyClasspathContainer();
+ }
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+
+ }
+
+ private void addDefaultJREContainer(IJavaProject javaProject) throws JavaModelException{
+ List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
+ entries.addAll(Arrays.asList(javaProject.getRawClasspath()));
+ entries.add(JavaRuntime.getDefaultJREContainerEntry());
+ javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
+
+ }
+
+ private void addSourceFolders(IJavaProject javaProject, String...path) throws JavaModelException{
+ List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
+ entries.addAll(Arrays.asList(javaProject.getRawClasspath()));
+ IResource outputLocation = javaProject.getProject().findMember("target");
+ if(outputLocation==null){
+ outputLocation = createSourceFolder(javaProject.getProject(), "target");
+ }
+ javaProject.setOutputLocation(outputLocation.getFullPath(), null);
+ for(String p : path){
+ IResource sourceFolder = javaProject.getProject().findMember(p);
+ if(sourceFolder==null){
+ sourceFolder = createSourceFolder(javaProject.getProject(), p);
+ }
+ if(sourceFolder!=null){
+ IPath[] exclusionPatterns = new IPath[] { outputLocation.getFullPath() };
+ IClasspathEntry srcEntry = JavaCore.newSourceEntry(sourceFolder.getFullPath(),exclusionPatterns, outputLocation.getFullPath());
+ entries.add(srcEntry);
+ }
+ }
+ javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
+ }
+
+ private IResource createSourceFolder( IProject project, String sourcefolder ){
+ IPath path = new Path(sourcefolder);
+ IContainer container = project;
+ try {
+ for (int i = 1; i <= path.segmentCount(); i++) {
+ IFolder newSourceFolder = project.getFolder( path.uptoSegment( i ) );
+ if (!newSourceFolder.exists()) {
+ newSourceFolder.create( true, true, null );
+ }
+ container = newSourceFolder;
+ }
+ return container;
+ } catch (CoreException e) {
+ Activator.getEasyAntPlugin().log(e);
+ return null;
+ }
+ }
+
+ private void addClassPathEntry(IJavaProject javaProject, IClasspathEntry newEntry){
+ try {
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ List newEntries = new ArrayList(Arrays.asList(entries));
+ newEntries.add(newEntry);
+ entries = (IClasspathEntry[]) newEntries.toArray(new IClasspathEntry[newEntries.size()]);
+
+ javaProject.setRawClasspath(entries, javaProject.getOutputLocation(), null);
+ } catch (CoreException e) {
+ // unless there are issues with the JDT, this should never happen
+ Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot add ClassPath entry", e);
+ }
+ }
+
+ private void removeIvyClasspathContainer() {
+ IJavaProject javaProject = JavaCore.create(project);
+ ArrayList<IClasspathEntry> newEntries = new ArrayList<IClasspathEntry>();
+ //FIXME call IvyDE command
+ try {
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ for (int i = 0; i < entries.length; i++) {
+ IClasspathEntry entry = entries[i];
+ if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
+ IPath path = entry.getPath();
+ if (IvyClasspathUtil.isIvyClasspathContainer(path)) {
+ continue;
+ }
+ }
+ newEntries.add(entry);
+ }
+ // TODO add progress monitor
+ IClasspathEntry[] newClasspathEntries = newEntries.toArray(new IClasspathEntry[newEntries.size()]);
+ javaProject.setRawClasspath(newClasspathEntries, null);
+ } catch (JavaModelException e) {
+ Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot remove Ivy ClassPath container", e);
+ }
+ }
+
+ private void addBuilder(String builderID) throws CoreException {
+ if (!isBuilderApplied(builderID)) {
+ IProjectDescription description = getProject().getDescription();
+ ICommand[] commands = description.getBuildSpec();
+ ICommand command = description.newCommand();
+ command.setBuilderName(builderID);
+ ICommand[] newCommands = new ICommand[commands.length + 1];
+ System.arraycopy(commands, 0, newCommands, 0, commands.length);
+ newCommands[commands.length] = command;
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ }
+ }
+
+ private void removeBuilder(String builderID) throws CoreException {
+ if (isBuilderApplied(builderID)) {
+ IProjectDescription description = getProject().getDescription();
+ ICommand[] commands = description.getBuildSpec();
+ ICommand[] newCommands = new ICommand[commands.length - 1];
+ int i = 0;
+ for (ICommand command : commands) {
+ if (command.getBuilderName().equals(builderID)) {
+ // Remove the given builder
+ } else {
+ newCommands[i] = command;
+ i++;
+ }
+ }
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ }
+ }
+
+ private boolean isBuilderApplied(String builderID) throws CoreException {
+ IProjectDescription description = getProject().getDescription();
+ for (ICommand cmd : description.getBuildSpec()) {
+ if (cmd.getBuilderName().equals(builderID)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/EasyAntNature.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/EasyAntNature.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/EasyAntNature.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureAction.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureAction.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureAction.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureAction.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.natures;
+
+import org.apache.easyant4e.Activator;
+import org.apache.easyant4e.services.EasyantProjectService;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import com.google.inject.Inject;
+
+//import com.google.inject.Inject;
+
+/**
+ * Remove the EasyAnt nature to the project.
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class RemoveEasyAntNatureAction implements IObjectActionDelegate {
+
+ // The selected project
+ private IProject selectedProject;
+ private EasyantProjectService easyantProjectService;
+
+ public RemoveEasyAntNatureAction(){
+ Activator.getEasyAntPlugin().injectMembers(this);
+ }
+
+ @Inject
+ public void setEasyantProjectService(EasyantProjectService easyantProjectService) {
+ this.easyantProjectService = easyantProjectService;
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ public void run(IAction action) {
+ if (selectedProject != null) {
+ // Remove the nature on the selected project
+ easyantProjectService.removeNature(selectedProject);
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structuredSelection = (StructuredSelection) selection;
+ if (!structuredSelection.isEmpty() && structuredSelection.getFirstElement() instanceof IProject) {
+ IProject project = (IProject) structuredSelection.getFirstElement();
+ if (project.isAccessible()) {
+ this.selectedProject = project;
+ if (action != null) {
+ action.setEnabled(easyantProjectService.hasEasyAntNature(project));
+ }
+ }
+
+ }
+ }
+ }
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureAction.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureOperation.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureOperation.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureOperation.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureOperation.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.natures;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import org.apache.easyant4e.Activator;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+/**
+ * Remove the EasyAnt nature to the project.
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class RemoveEasyAntNatureOperation implements IRunnableWithProgress {
+
+ private IProject project;
+
+ public RemoveEasyAntNatureOperation(IProject project) {
+ this.project = project;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ if (project != null) {
+ try {
+ if (project.getNature(EasyAntNature.NATURE_ID) != null) {
+ monitor.subTask("Remove the EasyAnt nature to the project " + project.getName());
+ IProjectDescription description = project.getDescription();
+ String[] oldNatures = description.getNatureIds();
+ ArrayList newNatures = new ArrayList();
+ for (int i = 0; i < oldNatures.length; i++) {
+ if (!oldNatures[i].equals(EasyAntNature.NATURE_ID)) {
+ newNatures.add(oldNatures[i]);
+ }
+ }
+ description.setNatureIds((String[]) newNatures.toArray(new String[newNatures.size()]));
+ project.setDescription(description, new SubProgressMonitor(monitor, 1));
+ }
+ } catch (CoreException e) {
+ Activator.getEasyAntPlugin().log(e);
+ }
+ monitor.done();
+ }
+
+ }
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureOperation.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/natures/RemoveEasyAntNatureOperation.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProvider.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProvider.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProvider.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProvider.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.providers;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public interface ImageProvider {
+
+ ImageDescriptor getConsoleImageDescriptor();
+
+ ImageDescriptor getLogoImageDescriptor();
+
+ Image getPhaseImage();
+
+ Image getTargetImage();
+
+ Image getFormBackgroundImage();
+
+ Image getBuildImage();
+
+ ImageDescriptor getInfoLogLevelImage();
+
+ ImageDescriptor getDebugLogLevelImage();
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProviderImpl.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProviderImpl.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProviderImpl.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.providers;
+
+import java.net.URL;
+
+import org.apache.easyant4e.Activator;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class ImageProviderImpl implements ImageProvider {
+
+ public static final String IMG_HORIZONTAL = "horizontal";
+
+ public static final String IMG_FORM_BG = "formBg";
+
+ public static final String IMG_PHASE = "phase";
+
+ public static final String IMG_TARGET = "target";
+
+ public static final String IMG_CONSOLE = "console";
+
+ public static final String IMG_BUILD = "build";
+
+ public static final String IMG_EASYANT_LOGO = "easyant-logo";
+
+ public static final String IMG_INFO_LOG_LEVEL = "info-log-level";
+
+ public static final String IMG_DEBUG_LOG_LEVEL = "debug-log-level";
+
+ public ImageProviderImpl() {
+ initializeImageRegistry(getImageRegistry());
+ }
+
+ public ImageDescriptor getConsoleImageDescriptor() {
+ return getImageDescriptor(IMG_CONSOLE);
+ }
+ public ImageDescriptor getLogoImageDescriptor() {
+ return getImageDescriptor(IMG_EASYANT_LOGO);
+ }
+
+ public Image getPhaseImage(){
+ return getImage(IMG_PHASE);
+ }
+
+ public Image getTargetImage(){
+ return getImage(IMG_TARGET);
+ }
+
+ public Image getFormBackgroundImage(){
+ return getImage(IMG_FORM_BG);
+ }
+
+ public Image getBuildImage(){
+ return getImage(IMG_BUILD);
+ }
+
+ public ImageDescriptor getInfoLogLevelImage(){
+ return getImageDescriptor(IMG_INFO_LOG_LEVEL);
+ }
+
+ public ImageDescriptor getDebugLogLevelImage(){
+ return getImageDescriptor(IMG_DEBUG_LOG_LEVEL);
+ }
+
+ private void initializeImageRegistry(ImageRegistry registry) {
+ registerImage(registry, IMG_FORM_BG, "form_banner.gif");
+ registerImage(registry, IMG_PHASE, "phase.gif");
+ registerImage(registry, IMG_TARGET, "target.gif");
+ registerImage(registry, IMG_CONSOLE, "console.png");
+ registerImage(registry, IMG_BUILD, "build.gif");
+ registerImage(registry, IMG_EASYANT_LOGO, "EasyAnt-logo.gif");
+ registerImage(registry, IMG_INFO_LOG_LEVEL, "info_loglevel.gif");
+ registerImage(registry, IMG_DEBUG_LOG_LEVEL, "debug_loglevel.gif");
+ }
+
+ private void registerImage(ImageRegistry registry, String key, String fileName) {
+ try {
+ Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
+ IPath path = new Path("icons/" + fileName);
+ URL url = FileLocator.find(bundle, path, null);
+ if (url != null) {
+ ImageDescriptor desc = ImageDescriptor.createFromURL(url);
+ registry.put(key, desc);
+ }
+ } catch (Exception e) {
+ Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage(), e);
+ }
+ }
+
+ private Image getImage(String key) {
+ return getImageRegistry().get(key);
+ }
+
+ private ImageDescriptor getImageDescriptor(String key) {
+ return getImageRegistry().getDescriptor(key);
+ }
+
+ private ImageRegistry getImageRegistry() {
+ return Activator.getDefault().getImageRegistry();
+ }
+
+
+
+
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProviderImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProviderImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/providers/ImageProviderImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreService.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreService.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreService.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreService.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2008-2009 the EasyAnt project
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.easyant4e.services;
+
+import java.util.List;
+
+import org.apache.easyant.core.descriptor.PropertyDescriptor;
+
+/**
+ *
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public interface EasyantCoreService {
+
+ String getPluginsRepositoryPath();
+
+ /**
+ * Install the local plugins repository
+ */
+ void installPluginsRepository();
+
+ String[] getAllCoreBuildTypes();
+
+ String[] getAllCorePlugins();
+
+ List<PropertyDescriptor> getPropertiesForBuildType(String buildTypeName);
+
+ String getBuildTypeDescription(String buildTypeName);
+
+ String getPluginDescription(String pluginName);
+}
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreService.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreService.java
------------------------------------------------------------------------------
svn:mime-type = text/plain