Author: adietish
Date: 2011-12-06 05:52:00 -0500 (Tue, 06 Dec 2011)
New Revision: 36986
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectEnablableProjectDialog.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/JavaProjectUtils.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
Log:
[JBIDE-10171] implementing UI to select project that shall be enabled (pushed to) for
OpenShift
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2011-12-06
10:07:34 UTC (rev 36985)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2011-12-06
10:52:00 UTC (rev 36986)
@@ -107,6 +107,21 @@
}
/**
+ * Returns <code>true</code> if the given project exists and has a .git
+ * folder in it.
+ *
+ * @param project
+ * @return
+ */
+ public static boolean hasDotGitFolder(IProject project) {
+ if (project == null
+ || !project.exists()) {
+ return false;
+ }
+ return new File(project.getLocation().toOSString(), Constants.DOT_GIT).exists();
+ }
+
+ /**
* Shares the given project. A repository is created within the given
* project and the project is connected to the freshly created repository.
*
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2011-12-06
10:07:34 UTC (rev 36985)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2011-12-06
10:52:00 UTC (rev 36986)
@@ -31,8 +31,8 @@
org.eclipse.wst.common.modulecore;bundle-version="1.2.100",
org.eclipse.team.ui;bundle-version="3.6.100",
org.eclipse.jdt.launching;bundle-version="3.6.0",
+ org.eclipse.jdt.core;bundle-version="3.7.1",
org.eclipse.debug.ui;bundle-version="3.7.0",
- com.jcraft.jsch.source;bundle-version="0.1.44";resolution:=optional,
org.eclipse.ui.navigator;bundle-version="3.5.100",
org.eclipse.ui.console;bundle-version="3.5.100",
org.eclipse.core.expressions;bundle-version="3.4.300"
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-12-06
10:07:34 UTC (rev 36985)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-12-06
10:52:00 UTC (rev 36986)
@@ -20,26 +20,22 @@
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.MultiValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.resources.IProject;
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.databinding.swt.WidgetProperties;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
@@ -54,7 +50,6 @@
import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
import org.jboss.tools.openshift.express.client.OpenShiftException;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.AdapterWizardPageModel.GitUri;
/**
* @author André Dietisheim
@@ -102,39 +97,62 @@
private Group createMergeGroup(Composite parent, DataBindingContext dbc) {
Group mergeGroup = new Group(parent, SWT.BORDER);
- mergeGroup.setText("Git Merge");
+ mergeGroup.setText("Enable Project");
GridDataFactory.fillDefaults()
.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(mergeGroup);
- GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(mergeGroup);
+ GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(3).applyTo(mergeGroup);
Button mergeEnabledButton = new Button(mergeGroup, SWT.CHECK);
- mergeEnabledButton.setText("merge with Git URI");
+ mergeEnabledButton.setText("Enable existing project");
GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(mergeEnabledButton);
- IObservableValue mergeEnabledButtonSelection =
WidgetProperties.selection().observe(mergeEnabledButton);
- mergeEnabledButtonSelection.setValue(false);
+ .align(SWT.LEFT, SWT.CENTER).applyTo(mergeEnabledButton);
+ IObservableValue enableProjectObservable =
+ BeanProperties.value(AdapterWizardPageModel.PROPERTY_ENABLE_PROJECT).observe(model);
+ ValueBindingBuilder
+ .bind(WidgetProperties.selection().observe(mergeEnabledButton))
+ .to(enableProjectObservable)
+ .in(dbc);
- Combo mergeUriCombo = new Combo(mergeGroup, SWT.NONE);
- ComboViewer mergeUriComboViewer = new ComboViewer(mergeUriCombo);
+ Text enabledProjText = new Text(mergeGroup, SWT.BORDER);
+ enabledProjText.setEditable(false);
GridDataFactory
- .fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(mergeUriCombo);
- mergeUriComboViewer.setContentProvider(new ArrayContentProvider());
- mergeUriComboViewer.setLabelProvider(new GitUriLabelProvider());
- mergeUriComboViewer.setInput(model.getMergeUris());
-// ValueBindingBuilder
-// .bind(WidgetProperties.text().observe(mergeUriCombo))
-// .validatingAfterGet(new MergeUriValidator())
-// .to(BeanProperties.value(AdapterWizardPageModel.PROPERTY_MERGE_URI).observe(model))
-// .in(dbc);
+ .fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(enabledProjText);
+ // mergeUriComboViewer.setContentProvider(new ArrayContentProvider());
+ // mergeUriComboViewer.setLabelProvider(new GitUriLabelProvider());
+ // mergeUriComboViewer.setInput(model.getMergeUris());
+ // ValueBindingBuilder
+ // .bind(WidgetProperties.text().observe(mergeUriCombo))
+ // .validatingAfterGet(new MergeUriValidator())
+ // .to(BeanProperties.value(AdapterWizardPageModel.PROPERTY_MERGE_URI).observe(model))
+ // .in(dbc);
+
+ // ValueBindingBuilder
+ // .bind(mergeEnabledButtonSelection)
+ // .to(WidgetProperties.enabled().observe(mergeUriCombo))
+ // .in(dbc);
+
ValueBindingBuilder
- .bind(WidgetProperties.text().observe(mergeUriCombo))
- .to(BeanProperties.value(AdapterWizardPageModel.PROPERTY_PROJECT_NAME).observe(model))
- .in(dbc);
+ .bind(WidgetProperties.text().observe(enabledProjText))
+ .to(BeanProperties.value(AdapterWizardPageModel.PROPERTY_PROJECT_NAME).observe(model))
+ .in(dbc);
+
ValueBindingBuilder
- .bind(mergeEnabledButtonSelection)
- .to(WidgetProperties.enabled().observe(mergeUriCombo))
+ .bind(enableProjectObservable)
+ .to(WidgetProperties.enabled().observe(enabledProjText))
.in(dbc);
+ Button browseProjectsButton = new Button(mergeGroup, SWT.NONE);
+ browseProjectsButton.setText("Browse");
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseProjectsButton);
+ browseProjectsButton.addSelectionListener(onBrowseProjects());
+ ValueBindingBuilder
+ .bind(enableProjectObservable)
+ .to(WidgetProperties.enabled().observe(browseProjectsButton))
+ .in(dbc);
+
+ enableProjectObservable.setValue(false);
+
return mergeGroup;
}
@@ -253,6 +271,23 @@
return cloneGroup;
}
+ private SelectionListener onBrowseProjects() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ SelectEnablableProjectDialog dialog = new SelectEnablableProjectDialog(getShell());
+ if (dialog.open() == Dialog.OK) {
+ Object selectedProject = dialog.getFirstResult();
+ if (selectedProject instanceof IProject) {
+ model.setProjectName(((IProject) selectedProject).getName());
+ }
+ }
+ }
+
+ };
+ }
+
private SelectionListener onDefaultRepoPath() {
return new SelectionAdapter() {
@@ -426,59 +461,59 @@
}
}
- private static class GitUriLabelProvider implements ILabelProvider {
+ // private static class GitUriLabelProvider implements ILabelProvider {
+ //
+ // @Override
+ // public void addListener(ILabelProviderListener listener) {
+ // }
+ //
+ // @Override
+ // public void dispose() {
+ // }
+ //
+ // @Override
+ // public boolean isLabelProperty(Object element, String property) {
+ // return true;
+ // }
+ //
+ // @Override
+ // public void removeListener(ILabelProviderListener listener) {
+ // }
+ //
+ // @Override
+ // public Image getImage(Object element) {
+ // return null;
+ // }
+ //
+ // @Override
+ // public String getText(Object element) {
+ // if (!(element instanceof GitUri)) {
+ // return null;
+ // }
+ // return ((GitUri) element).getLabel();
+ // }
+ // }
- @Override
- public void addListener(ILabelProviderListener listener) {
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return true;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- }
-
- @Override
- public Image getImage(Object element) {
- return null;
- }
-
- @Override
- public String getText(Object element) {
- if (!(element instanceof GitUri)) {
- return null;
- }
- return ((GitUri) element).getLabel();
- }
- }
-
-// private class MergeUriValidator implements IValidator {
-//
-// @Override
-// public IStatus validate(Object value) {
-// String mergeUri = (String) value;
-// if (mergeUri == null
-// || mergeUri.length() == 0) {
-// return ValidationStatus
-// .warning("You have to provide a git uri to merge with");
-// }
-// GitUri gitUri = model.getKnownMergeUri(mergeUri);
-// if (gitUri == null) {
-// return ValidationStatus
-// .warning("You are not merging with an official example. Things may go
wrong");
-// }
-// if (!model.isCompatibleToApplicationCartridge(gitUri.getCartridge())) {
-// return ValidationStatus
-// .warning("The example you've chosen is not compatible to your
application");
-// }
-// return ValidationStatus.ok();
-// }
-// }
+ // private class MergeUriValidator implements IValidator {
+ //
+ // @Override
+ // public IStatus validate(Object value) {
+ // String mergeUri = (String) value;
+ // if (mergeUri == null
+ // || mergeUri.length() == 0) {
+ // return ValidationStatus
+ // .warning("You have to provide a git uri to merge with");
+ // }
+ // GitUri gitUri = model.getKnownMergeUri(mergeUri);
+ // if (gitUri == null) {
+ // return ValidationStatus
+ // .warning("You are not merging with an official example. Things may go
wrong");
+ // }
+ // if (!model.isCompatibleToApplicationCartridge(gitUri.getCartridge())) {
+ // return ValidationStatus
+ // .warning("The example you've chosen is not compatible to your
application");
+ // }
+ // return ValidationStatus.ok();
+ // }
+ // }
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2011-12-06
10:07:34 UTC (rev 36985)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2011-12-06
10:52:00 UTC (rev 36986)
@@ -10,17 +10,11 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jgit.transport.URIish;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.egit.ui.util.EGitUIUtils;
import org.jboss.tools.openshift.express.client.IApplication;
import org.jboss.tools.openshift.express.client.ICartridge;
import org.jboss.tools.openshift.express.client.OpenShiftException;
-import org.jboss.tools.openshift.express.internal.client.Cartridge;
/**
* @author André Dietisheim
@@ -30,6 +24,7 @@
private static final String REMOTE_NAME_DEFAULT = "origin";
+ public static final String PROPERTY_ENABLE_PROJECT = "enableProject";
public static final String PROPERTY_CLONE_URI = "cloneUri";
// public static final String PROPERTY_MERGE_URI = "mergeUri";
public static final String PROPERTY_PROJECT_NAME = "projectName";
@@ -53,6 +48,14 @@
setRemoteName(REMOTE_NAME_DEFAULT);
}
+ public void setEnableProject(boolean enableProject) {
+ firePropertyChange(PROPERTY_ENABLE_PROJECT, wizardModel.isEnableProject(),
wizardModel.setEnableProject(enableProject));
+ }
+
+ public boolean isEnableProject() {
+ return wizardModel.isEnableProject();
+ }
+
public void setProjectName(String projectName) {
firePropertyChange(PROPERTY_PROJECT_NAME, wizardModel.getProjectName(),
wizardModel.setProjectName(projectName));
}
@@ -69,63 +72,63 @@
// return wizardModel.getMergeUri();
// }
- public GitUri getKnownMergeUri(String uriOrLabel) {
- GitUri gitUri = null;
- if (isGitUri(uriOrLabel)) {
- gitUri = getKnownMergeUriByUri(uriOrLabel);
- } else {
- gitUri = getKnownMergeUriByLabel(uriOrLabel);
- }
- return gitUri;
- }
+// public GitUri getKnownMergeUri(String uriOrLabel) {
+// GitUri gitUri = null;
+// if (isGitUri(uriOrLabel)) {
+// gitUri = getKnownMergeUriByUri(uriOrLabel);
+// } else {
+// gitUri = getKnownMergeUriByLabel(uriOrLabel);
+// }
+// return gitUri;
+// }
- private boolean isGitUri(String gitUriString) {
- try {
- URIish uriish = new URIish(gitUriString);
- return uriish.isRemote();
- } catch (URISyntaxException e) {
- return false;
- }
- }
+// private boolean isGitUri(String gitUriString) {
+// try {
+// URIish uriish = new URIish(gitUriString);
+// return uriish.isRemote();
+// } catch (URISyntaxException e) {
+// return false;
+// }
+// }
- private GitUri getKnownMergeUriByUri(String gitUriString) {
- GitUri matchingGitUri = null;
- for (GitUri gitUri : getMergeUris()) {
- if (gitUri.getGitUri().equals(gitUriString)) {
- matchingGitUri = gitUri;
- break;
- }
- }
- return matchingGitUri;
- }
+// private GitUri getKnownMergeUriByUri(String gitUriString) {
+// GitUri matchingGitUri = null;
+// for (GitUri gitUri : getMergeUris()) {
+// if (gitUri.getGitUri().equals(gitUriString)) {
+// matchingGitUri = gitUri;
+// break;
+// }
+// }
+// return matchingGitUri;
+// }
- private GitUri getKnownMergeUriByLabel(String label) {
- GitUri matchingGitUri = null;
- for (GitUri gitUri : getMergeUris()) {
- if (gitUri.getLabel().equals(label)) {
- matchingGitUri = gitUri;
- break;
- }
- }
- return matchingGitUri;
- }
+// private GitUri getKnownMergeUriByLabel(String label) {
+// GitUri matchingGitUri = null;
+// for (GitUri gitUri : getMergeUris()) {
+// if (gitUri.getLabel().equals(label)) {
+// matchingGitUri = gitUri;
+// break;
+// }
+// }
+// return matchingGitUri;
+// }
- public List<GitUri> getMergeUris() {
- ArrayList<GitUri> mergeUris = new ArrayList<GitUri>();
- mergeUris.add(new GitUri(
- "seambooking-example",
"git://github.com/openshift/seambooking-example.git",
- ICartridge.JBOSSAS_7));
- mergeUris.add(new GitUri(
- "tweetstream-example",
"git://github.com/openshift/tweetstream-example.git",
- ICartridge.JBOSSAS_7));
- mergeUris.add(new GitUri(
- "sinatra-example",
"git://github.com/openshift/sinatra-example.git",
- new Cartridge("rack-1.1")));
- mergeUris.add(new GitUri(
- "sugarcrm-example",
"git://github.com/openshift/sugarcrm-example.git",
- new Cartridge("php-5.3")));
- return mergeUris;
- }
+// public List<GitUri> getMergeUris() {
+// ArrayList<GitUri> mergeUris = new ArrayList<GitUri>();
+// mergeUris.add(new GitUri(
+// "seambooking-example",
"git://github.com/openshift/seambooking-example.git",
+// ICartridge.JBOSSAS_7));
+// mergeUris.add(new GitUri(
+// "tweetstream-example",
"git://github.com/openshift/tweetstream-example.git",
+// ICartridge.JBOSSAS_7));
+// mergeUris.add(new GitUri(
+// "sinatra-example",
"git://github.com/openshift/sinatra-example.git",
+// new Cartridge("rack-1.1")));
+// mergeUris.add(new GitUri(
+// "sugarcrm-example",
"git://github.com/openshift/sugarcrm-example.git",
+// new Cartridge("php-5.3")));
+// return mergeUris;
+// }
public void loadGitUri() throws OpenShiftException {
setLoading(true);
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java 2011-12-06
10:07:34 UTC (rev 36985)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java 2011-12-06
10:52:00 UTC (rev 36986)
@@ -68,6 +68,7 @@
private HashMap<String, Object> dataModel = new HashMap<String, Object>();
+ public static final String ENABLE_PROJECT = "enableProject";
public static final String USER = "user";
public static final String APPLICATION = "application";
public static final String REMOTE_NAME = "remoteName";
@@ -75,6 +76,10 @@
public static final String PROJECT_NAME = "projectName";
public static final String MERGE_URI = "mergeUri";
+ public ImportProjectWizardModel() {
+ dataModel.put(ENABLE_PROJECT, false);
+ }
+
public Object setProperty(String key, Object value) {
Object oldVal = dataModel.get(key);
dataModel.put(key, value);
@@ -146,6 +151,14 @@
return (String) getProperty(REPOSITORY_PATH);
}
+ public boolean isEnableProject() {
+ return (Boolean) getProperty(ENABLE_PROJECT);
+ }
+
+ public Boolean setEnableProject(boolean enableProject) {
+ return (Boolean) setProperty(ENABLE_PROJECT, enableProject);
+ }
+
public String setProjectName(String projectName) {
return (String) setProperty(PROJECT_NAME, projectName);
}
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectEnablableProjectDialog.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectEnablableProjectDialog.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectEnablableProjectDialog.java 2011-12-06
10:52:00 UTC (rev 36986)
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.ide.IDE.SharedImages;
+import org.jboss.tools.openshift.egit.core.EGitUtils;
+import org.jboss.tools.openshift.express.internal.utils.JavaProjectUtils;
+
+/**
+ * @author André Dietisheim
+ */
+public class SelectEnablableProjectDialog extends ElementListSelectionDialog {
+
+ public SelectEnablableProjectDialog(Shell shell) {
+ super(shell, new ProjectLabelProvider());
+ setTitle("Project Selection");
+ setMessage("Please select the project that shall be pushed to OpenShift");
+ setMultipleSelection(false);
+ setAllowDuplicates(false);
+ setElements(getProjects());
+ }
+
+ private Object[] getProjects() {
+ List<IProject> projects = new ArrayList<IProject>();
+ for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ if (isValid(project)) {
+ projects.add(project);
+ }
+ }
+ return projects.toArray();
+ }
+
+ private boolean isValid(IProject project) {
+ if (EGitUtils.isShared(project)) {
+ return false;
+ }
+
+ if (EGitUtils.hasDotGitFolder(project)) {
+ return false;
+ }
+
+ if (!JavaProjectUtils.isJavaProject(project)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ private static class ProjectLabelProvider extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ return
PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (!(element instanceof IProject)) {
+ return null;
+ }
+
+ return ((IProject) element).getName();
+ }
+
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectEnablableProjectDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/JavaProjectUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/JavaProjectUtils.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/JavaProjectUtils.java 2011-12-06
10:52:00 UTC (rev 36986)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.utils;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.JavaCore;
+
+/**
+ * @author André Dietisheim
+ */
+public class JavaProjectUtils {
+
+ public static boolean isJavaProject(IProject project) {
+ try {
+ if (!project.hasNature(JavaCore.NATURE_ID)) {
+ return false;
+ }
+ } catch (CoreException e) {
+ // project is not opened, does not exist, etc.
+ return false;
+ }
+ return true;
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/JavaProjectUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain