Skip to content

Commit

Permalink
Merge pull request #271 from phantomjinx/master
Browse files Browse the repository at this point in the history
Stop quitting deletion of closed projects
  • Loading branch information
blafond committed Dec 4, 2013
2 parents 3cbe5e4 + 37be784 commit 572a251
Show file tree
Hide file tree
Showing 22 changed files with 159 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.teiid.designer.core.ModelerCore;
Expand All @@ -27,6 +28,9 @@ public class RelatedResourceFinder {

private static final ModelResourceFilter RESOURCE_FILTER = new ModelResourceFilter();

/**
* Types of relationship used in this finder
*/
public enum Relationship {
/**
* The relationship where resource A is imported by resource B
Expand All @@ -48,10 +52,21 @@ public enum Relationship {

private final IResource sourceResource;

/**
* @param sourceResource
*/
public RelatedResourceFinder(IResource sourceResource) {
this.sourceResource = sourceResource;
}

private boolean isClosedProject(IResource resource) {
if (resource instanceof IProject && !((IProject) resource).isOpen()) {
return true;
}

return false;
}

/**
* Recursive dependent find method on the given resource
*
Expand All @@ -63,7 +78,13 @@ private Collection<IFile> findDependentResources(IResource resource) {
Collection<IFile> dependentResources = Collections.emptyList();

try {
if (resource instanceof IContainer) {
if (isClosedProject(resource)) {
/*
* If the project is closed then it has no dependents since the members
* are impossible to reach.
*/
return dependentResources;
} else if (resource instanceof IContainer) {
// sometimes this is getting called with a nonexistent resource...
// see defect 18558 for more details
if (resource.exists()) {
Expand Down Expand Up @@ -117,7 +138,13 @@ private Collection<IFile> findDependencyResources(IResource resource) {
Collection<IFile> dependencyResources = new HashSet<IFile>();

try {
if (resource instanceof IContainer) {
if (isClosedProject(resource)) {
/*
* If the project is closed then it has no dependencies since the members
* are impossible to reach.
*/
return dependencyResources;
} else if (resource instanceof IContainer) {
IContainer folder = (IContainer)resource;
IResource[] resources = folder.members();

Expand Down Expand Up @@ -151,6 +178,12 @@ private Collection<IFile> findDependencyResources() {
return findDependencyResources(sourceResource);
}

/**
* Find related resources associated by the given type of relationship
*
* @param typeOfRelationship
* @return collection of related resources
*/
public Collection<IFile> findRelatedResources(Relationship typeOfRelationship) {
switch (typeOfRelationship) {
case DEPENDENT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.net.URL;
import java.util.List;
import java.util.Properties;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand All @@ -26,10 +25,8 @@
import org.eclipse.datatools.connectivity.ui.wizards.NewConnectionProfileWizard;
import org.eclipse.datatools.enablement.oda.xml.util.XMLSourceFromPath;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -73,10 +70,8 @@ public FlatFileUrlProfileDetailsWizardPage( String pageName ) {
public void createCustomControl(Composite parent) {
GridData gd;

Group group = new Group(parent, SWT.BORDER);
group.setText(UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$
group.setLayout(new FillLayout());
group.setFont(JFaceResources.getBannerFont());
Group group = WidgetFactory.createSimpleGroup(parent,
UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$;

scrolled = new Composite(group, SWT.SCROLL_PAGE);
GridLayout gridLayout = new GridLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package org.teiid.designer.datatools.profiles.file;

import java.util.Properties;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand All @@ -25,7 +24,6 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand All @@ -38,6 +36,7 @@
import org.teiid.designer.datatools.profiles.flatfile.IFlatFileProfileConstants;
import org.teiid.designer.datatools.ui.DatatoolsUiConstants;
import org.teiid.designer.datatools.ui.DatatoolsUiPlugin;
import org.teiid.designer.ui.common.util.WidgetFactory;

public class FlatFileUrlProfilePropertyPage extends ProfileDetailsPropertyPage implements
IContextProvider, DatatoolsUiConstants {
Expand Down Expand Up @@ -80,11 +79,8 @@ protected Control createContents(Composite parent) {
protected void createCustomContents(Composite parent) {
GridData gd;

Group group = new Group(parent, SWT.BORDER);
group.setText(UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$
FillLayout fl = new FillLayout();
fl.type = SWT.HORIZONTAL;
group.setLayout(new FillLayout());
Group group = WidgetFactory.createSimpleGroup(parent,
UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$;

scrolled = new Composite(group, SWT.NONE);
GridLayout gridLayout = new GridLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.eclipse.datatools.connectivity.ui.wizards.NewConnectionProfileWizard;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -65,9 +64,7 @@ public LdapProfileDetailsWizardPage( String pageName ) {
public void createCustomControl( Composite parent ) {
GridData gd;

Group group = new Group(parent, SWT.BORDER);
group.setText(UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$
group.setLayout(new FillLayout());
Group group = WidgetFactory.createSimpleGroup(parent, UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$

scrolled = new Composite(group, SWT.NONE);
GridLayout gridLayout = new GridLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand All @@ -19,6 +18,7 @@
import org.eclipse.swt.widgets.Text;
import org.teiid.designer.datatools.ui.DatatoolsUiConstants;
import org.teiid.designer.datatools.ui.DatatoolsUiPlugin;
import org.teiid.designer.ui.common.util.WidgetFactory;

public class PropertyPage extends ProfileDetailsPropertyPage implements IContextProvider, DatatoolsUiConstants {

Expand Down Expand Up @@ -68,11 +68,8 @@ protected Control createContents(Composite parent) {
protected void createCustomContents( Composite parent ) {
GridData gd;

Group group = new Group(parent, SWT.BORDER);
group.setText(UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$
FillLayout fl = new FillLayout();
fl.type = SWT.HORIZONTAL;
group.setLayout(new FillLayout());
Group group = WidgetFactory.createSimpleGroup(parent,
UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$;

scrolled = new Composite(group, SWT.NONE);
GridLayout gridLayout = new GridLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.net.URL;
import java.util.List;
import java.util.Properties;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand All @@ -26,7 +25,6 @@
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -70,9 +68,8 @@ public ODataProfileDetailsWizardPage( String pageName ) {
public void createCustomControl(Composite parent) {
GridData gd;

Group group = new Group(parent, SWT.BORDER);
group.setText(UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$
group.setLayout(new FillLayout());
Group group = WidgetFactory.createSimpleGroup(parent,
UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$;

scrolled = new Composite(group, SWT.NONE);
GridLayout gridLayout = new GridLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand All @@ -29,6 +28,7 @@
import org.teiid.designer.datatools.ui.DatatoolsUiPlugin;
import org.teiid.designer.ui.common.ICredentialsCommon;
import org.teiid.designer.ui.common.ICredentialsCommon.SecurityType;
import org.teiid.designer.ui.common.util.WidgetFactory;

public class ODataPropertyPage extends ProfileDetailsPropertyPage implements
IContextProvider, DatatoolsUiConstants {
Expand Down Expand Up @@ -78,11 +78,8 @@ protected Control createContents(Composite parent) {
protected void createCustomContents( Composite parent ) {
GridData gd;

Group group = new Group(parent, SWT.BORDER);
group.setText(UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$
FillLayout fl = new FillLayout();
fl.type = SWT.HORIZONTAL;
group.setLayout(new FillLayout());
Group group = WidgetFactory.createSimpleGroup(parent,
UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$;

scrolled = new Composite(group, SWT.NONE);
GridLayout gridLayout = new GridLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand All @@ -29,6 +28,7 @@
import org.teiid.designer.datatools.ui.DatatoolsUiPlugin;
import org.teiid.designer.ui.common.ICredentialsCommon;
import org.teiid.designer.ui.common.ICredentialsCommon.SecurityType;
import org.teiid.designer.ui.common.util.WidgetFactory;

public class PropertyPage extends ProfileDetailsPropertyPage implements
IContextProvider, DatatoolsUiConstants {
Expand Down Expand Up @@ -78,11 +78,8 @@ protected Control createContents(Composite parent) {
protected void createCustomContents( Composite parent ) {
GridData gd;

Group group = new Group(parent, SWT.BORDER);
group.setText(UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$
FillLayout fl = new FillLayout();
fl.type = SWT.HORIZONTAL;
group.setLayout(new FillLayout());
Group group = WidgetFactory.createSimpleGroup(parent,
UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$;

scrolled = new Composite(group, SWT.NONE);
GridLayout gridLayout = new GridLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.net.URL;
import java.util.List;
import java.util.Properties;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand All @@ -26,7 +25,6 @@
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -70,9 +68,8 @@ public WSProfileDetailsWizardPage( String pageName ) {
public void createCustomControl(Composite parent) {
GridData gd;

Group group = new Group(parent, SWT.BORDER);
group.setText(UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$
group.setLayout(new FillLayout());
Group group = WidgetFactory.createSimpleGroup(parent,
UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$;

scrolled = new Composite(group, SWT.NONE);
GridLayout gridLayout = new GridLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
Expand Down Expand Up @@ -77,8 +76,7 @@ public void createCustomControl(Composite parent) {
wizard = (WSSoapConnectionProfileWizard)getWizard();
profileProperties = wizard.getProfileProperties();

Group group = new Group(parent, SWT.BORDER);
group.setLayout(new FillLayout());
Group group = WidgetFactory.createSimpleGroup(parent, null);

scrolled = new Composite(group, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).applyTo(scrolled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -89,8 +88,7 @@ public void createCustomControl(Composite parent) {
wizard = (WSSoapConnectionProfileWizard) getWizard();
profileProperties = wizard.getProfileProperties();

Group group = new Group(parent, SWT.BORDER);
group.setLayout(new FillLayout());
Group group = WidgetFactory.createSimpleGroup(parent, null);

scrolled = new Composite(group, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).applyTo(scrolled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.eclipse.help.IContextProvider;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand All @@ -29,6 +28,7 @@
import org.teiid.designer.datatools.ui.DatatoolsUiConstants;
import org.teiid.designer.datatools.ui.DatatoolsUiPlugin;
import org.teiid.designer.ui.common.ICredentialsCommon;
import org.teiid.designer.ui.common.util.WidgetFactory;
import org.teiid.designer.ui.common.widget.CredentialsComposite;

/**
Expand Down Expand Up @@ -92,11 +92,8 @@ protected Control createContents(Composite parent) {
protected void createCustomContents(Composite parent) {
GridData gd;

Group group = new Group(parent, SWT.BORDER);
group.setText(UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$
FillLayout fl = new FillLayout();
fl.type = SWT.HORIZONTAL;
group.setLayout(new FillLayout());
Group group = WidgetFactory.createSimpleGroup(parent,
UTIL.getString("Common.Properties.Label")); //$NON-NLS-1$;

scrolled = new Composite(group, SWT.NONE);
GridLayout gridLayout = new GridLayout();
Expand Down

0 comments on commit 572a251

Please sign in to comment.