Skip to content

Commit

Permalink
TEIIDDES-1611 Added Quick Fixes for extracting models in VDBs that ar…
Browse files Browse the repository at this point in the history
…e missing in workspace
  • Loading branch information
blafond committed Mar 5, 2013
1 parent 4479cd0 commit 59da275
Show file tree
Hide file tree
Showing 13 changed files with 584 additions and 91 deletions.
7 changes: 7 additions & 0 deletions plugins/org.teiid.designer.vdb.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
class="org.teiid.designer.vdb.ui.build.VdbMissingUuidMarkerResolutionGenerator"
markerType="org.teiid.designer.vdb.ui.vdbMarker">
<attribute name="missingUuid" value="true"/>
</markerResolutionGenerator>
</extension>
<extension point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
class="org.teiid.designer.vdb.ui.build.VdbModelNotInProjectMarkerResolutionGenerator"
markerType="org.teiid.designer.vdb.ui.vdbMarker">
<attribute name="missingModel" value="true"/>
</markerResolutionGenerator>
</extension>
<extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Messages extends NLS {
public static String fixVdbPath_OpenEditorMessage;

public static String synchronizeVdbLabel;
public static String extractMissingModelsLabel;
public static String extractMissingModelsAndSyncLabel;

static {
NLS.initializeMessages("org.teiid.designer.vdb.ui.messages", Messages.class); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ private void createMarker( IFile file,
attributes.put(NAME_CHANGED, true);
} else if (markerType == MarkerType.MISSING_UUID) {
attributes.put(MISSING_UUID, true);
} else if (markerType == MarkerType.MISSING_MODEL) {
attributes.put(MISSING_MODEL, true);
}

attributes.put(IMarker.LOCATION, file.getName());

try {
MarkerUtilities.createMarker(file, attributes, markerId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* JBoss, Home of Professional Open Source.
*
* See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
*
* See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
*/
package org.teiid.designer.vdb.ui.build;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IMarkerResolution;
import org.teiid.designer.ui.common.viewsupport.UiBusyIndicator;
import org.teiid.designer.vdb.VdbConstants;
import org.teiid.designer.vdb.ui.Messages;
import org.teiid.designer.vdb.ui.util.VdbUiUtil;

/**
*
*/
public class VdbExtractModelsSyncVdbMarkerResolution implements IMarkerResolution {

/**
* {@inheritDoc}
*
* @see org.eclipse.ui.IMarkerResolution#getLabel()
*/
@Override
public String getLabel() {
return Messages.extractMissingModelsAndSyncLabel;
}

/**
* {@inheritDoc}
*
* @see org.eclipse.ui.IMarkerResolution#run(org.eclipse.core.resources.IMarker)
*/
@Override
public void run(IMarker marker) {
IResource resource = marker.getResource();

// Fix the Marked Model Resource
if (isVdbFile(resource)) {
final IFile theVdbFile = (IFile) resource;

// Add the selected Med
UiBusyIndicator.showWhile(Display.getDefault(), new Runnable() {
@Override
public void run() {
fixVdb(theVdbFile);
}
});

}
}

void fixVdb(IFile theVdb) {
VdbUiUtil.synchronizeVdb(theVdb, true);
}

/**
* @param resource
* the resource being checked (never <code>null</code>)
* @return <code>true</code> if resource is a VDB file
*/
private boolean isVdbFile(IResource resource) {
return ((resource.getType() == IResource.FILE)
&& VdbConstants.VDB_FILE_EXTENSION.equals(resource
.getFileExtension()) && resource.exists());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ public class VdbMarkerResolutionGenerator implements IMarkerResolutionGenerator
@Override
public IMarkerResolution[] getResolutions(IMarker marker) {
Collection<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();

if( marker.getAttribute(VdbBuilder.WRONG_PATH, false) ||
marker.getAttribute(VdbBuilder.OUT_OF_SYNC, false) ||
marker.getAttribute(VdbBuilder.MISSING_UUID, false)) {
resolutions.add(new VdbModelPathResolution());
}

return resolutions.toArray(new IMarkerResolution[resolutions.size()]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* JBoss, Home of Professional Open Source.
*
* See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
*
* See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
*/
package org.teiid.designer.vdb.ui.build;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IMarkerResolution;
import org.teiid.designer.ui.common.viewsupport.UiBusyIndicator;
import org.teiid.designer.vdb.VdbConstants;
import org.teiid.designer.vdb.ui.Messages;
import org.teiid.designer.vdb.ui.util.VdbUiUtil;

/**
*
*/
public class VdbModelNotInProjectMarkerResolution implements IMarkerResolution {

/**
* {@inheritDoc}
*
* @see org.eclipse.ui.IMarkerResolution#getLabel()
*/
@Override
public String getLabel() {
return Messages.extractMissingModelsLabel;
}

/**
* {@inheritDoc}
*
* @see org.eclipse.ui.IMarkerResolution#run(org.eclipse.core.resources.IMarker)
*/
@Override
public void run(IMarker marker) {
IResource resource = marker.getResource();

// Fix the Marked Model Resource
if(isVdbFile(resource)) {
final IFile theVdbFile = (IFile)resource;

// Add the selected Med
UiBusyIndicator.showWhile(Display.getDefault(), new Runnable() {
@Override
public void run() {
fixVdb(theVdbFile);
}
});

}
}

void fixVdb( IFile theVdb ) {
VdbUiUtil.synchronizeWorkspace(theVdb);
}

/**
* @param resource the resource being checked (never <code>null</code>)
* @return <code>true</code> if resource is a VDB file
*/
private boolean isVdbFile( IResource resource ) {
return ((resource.getType() == IResource.FILE) && VdbConstants.VDB_FILE_EXTENSION.equals(resource.getFileExtension()) && resource.exists());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* JBoss, Home of Professional Open Source.
*
* See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
*
* See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
*/
package org.teiid.designer.vdb.ui.build;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.core.resources.IMarker;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator;


/**
*
*/
public class VdbModelNotInProjectMarkerResolutionGenerator implements IMarkerResolutionGenerator {
/**
* {@inheritDoc}
*
* @see org.eclipse.ui.IMarkerResolutionGenerator#getResolutions(org.eclipse.core.resources.IMarker)
*/
@Override
public IMarkerResolution[] getResolutions(IMarker marker) {
Collection<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();

if( marker.getAttribute(VdbBuilder.MISSING_MODEL, false) ) {
resolutions.add(new VdbExtractModelsSyncVdbMarkerResolution());
resolutions.add(new VdbModelNotInProjectMarkerResolution());

}
return resolutions.toArray(new IMarkerResolution[resolutions.size()]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.teiid.designer.vdb.ui.Messages;
import org.teiid.designer.vdb.ui.editor.VdbEditor;
import org.teiid.designer.vdb.ui.util.VdbUiRefactorHandler;
import org.teiid.designer.vdb.ui.util.VdbUiUtil;

/**
*
Expand Down Expand Up @@ -69,7 +70,7 @@ public void run() {
}

void fixVdb( IFile theVdb ) {
VdbUtil.synchronizeVdb(theVdb);
VdbUiUtil.synchronizeVdb(theVdb, false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ refactorModelVdbDependencyMessage_openEditors = \
fixVdbPath_OpenEditorTitle= VDB Editor Open
fixVdbPath_OpenEditorMessage= VDB editor for "{0}" will be closed before before synchronizing model path.
synchronizeVdbLabel = Synchronize VDB
extractMissingModelsLabel = Extract missing models into project
extractMissingModelsAndSyncLabel = Extract missing models into project and synchronize VDB


0 comments on commit 59da275

Please sign in to comment.