Skip to content

Commit

Permalink
Created alternative action/dialog to generate a VDB XML file with one…
Browse files Browse the repository at this point in the history
… page dialog and allow custom editing of XML
  • Loading branch information
blafond committed Mar 15, 2017
1 parent b2bae34 commit 409f47f
Show file tree
Hide file tree
Showing 25 changed files with 1,534 additions and 93 deletions.
2 changes: 2 additions & 0 deletions plugins/org.teiid.designer.dqp.ui/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ generateArchiveVdbAction.tooltip = Generate VDB Archive and Models from Dynamic
generateDynamicVdbAction.name = Generate Dynamic VDB
generateDynamicVdbAction.label = Generate Dynamic VDB
generateDynamicVdbAction.tooltip = Generate Dynamic VDB XML from VDB Archive
generateDynamicVdbAction2.name = Generate VDB XML
generateDynamicVdbAction2.label = Generate VDB XML

generateWarAction.name = Generate SOAP War
generateWarAction.label = Generate SOAP War
Expand Down
9 changes: 9 additions & 0 deletions plugins/org.teiid.designer.dqp.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@
label="%generateDynamicVdbAction.label">
</resourceAction>
</extension>
<extension
id="GenerateDynamicVdbAction2"
name="%generateDynamicVdbAction2.name"
point="org.teiid.designer.ui.modelResourceAction">
<resourceAction
name="org.teiid.designer.runtime.ui.actions.GenerateDynamicVdbAction2"
label="%generateDynamicVdbAction2.label">
</resourceAction>
</extension>
<extension
id="GenerateArchiveVdbAction"
name="%generateArchiveVdbAction.name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,31 @@ public class Messages extends NLS {
public static String PreviewDataWorker_vdbDeploymentErrorTitle;
public static String PreviewDataWorker_previewVdbJndiMissingErrorTitle;

public static String GenerateDynamicVdbDialog_dynamicVdbDefinition;
public static String GenerateDynamicVdbDialog_options;
public static String GenerateDynamicVdbDialog_name;
public static String GenerateDynamicVdbDialog_fileName;
public static String GenerateDynamicVdbDialog_selectedVdbFile;
public static String GenerateDynamicVdbDialog_saveAsVdbXmlFile;
public static String GenerateDynamicVdbDialog_initialMessage;
public static String GenerateDynamicVdbDialog_okMessage;
public static String GenerateDynamicVdbDialog_location;
public static String GenerateDynamicVdbDialog_locationUndefined;
public static String GenerateDynamicVdbDialog_browse;
public static String GenerateDynamicVdbDialog_saveToWorkspace;
public static String GenerateDynamicVdbDialog_saveToFileSystem;
public static String GenerateDynamicVdbDialog_fileContents;
public static String GenerateDynamicVdbDialog_allowEditXml;
public static String GenerateDynamicVdbDialog_reset;
public static String GenerateDynamicVdbDialog_overwriteFilesOptionLabel;
public static String GenerateDynamicVdbDialog_overwriteVDBOptionTooltip;
public static String GenerateDynamicVdbDialog_version;
public static String GenerateDynamicVdbDialog_dynamicVdbNameTooltip;
public static String GenerateDynamicVdbDialog_dynamicVdbFileNameToolTip;
public static String GenerateDynamicVdbDialog_excludeSourceDdlMetadata;
public static String GenerateDynamicVdbDialog_suppressDefaultAttributesOption;
public static String GenerateDynamicVdbDialog_suppressDefaultAttributesOptionTooltip;

static {
NLS.initializeMessages("org.teiid.designer.runtime.ui.messages", Messages.class); //$NON-NLS-1$
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package org.teiid.designer.runtime.ui.actions;

import java.util.Iterator;
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.DqpUiPlugin;
import org.teiid.designer.runtime.ui.Messages;
import org.teiid.designer.runtime.ui.DqpUiConstants.Images;
import org.teiid.designer.runtime.ui.wizards.vdbs.GenerateArchiveVdbWizard;
import org.teiid.designer.ui.actions.SortableSelectionAction;
import org.teiid.designer.ui.common.eventsupport.SelectionUtilities;
import org.teiid.designer.vdb.VdbUtil;
import org.teiid.designer.vdb.ui.VdbUiPlugin;

public class DeployJarAction extends SortableSelectionAction implements DqpUiConstants {
private static final String label = "Deploy Jar"; //$NON-NLS-1$
/**
* @since 5.0
*/
public DeployJarAction() {
super(label, SWT.DEFAULT);
setImageDescriptor(DqpUiPlugin.getDefault().getImageDescriptor(Images.CREATE_WAR));
}

/**
* @see org.teiid.designer.ui.actions.SortableSelectionAction#isValidSelection(org.eclipse.jface.viewers.ISelection)
* @since 5.0
*/
@Override
public boolean isValidSelection( ISelection selection ) {
// Enable for single/multiple Virtual Tables
return jarFileSelected(selection);
}

/**
* @see org.eclipse.jface.action.IAction#run()
* @since 5.0
*/
@Override
public void run() {
final IWorkbenchWindow iww = VdbUiPlugin.singleton.getCurrentWorkbenchWindow();

Object obj = SelectionUtilities.getSelectedObject(getSelection());
IFile theFile = (IFile)obj;

// Check server to see if it's running
// if it's not warn the user

// If it's running, then get the server and call:

// server.deployDriver(jarOrRarFile);

}



/**
* @see org.teiid.designer.ui.actions.ISelectionAction#isApplicable(org.eclipse.jface.viewers.ISelection)
* @since 5.0
*/
@Override
public boolean isApplicable( ISelection selection ) {
return jarFileSelected(selection);
}

private boolean jarFileSelected( ISelection theSelection ) {
boolean result = false;
List<Object> allObjs = SelectionUtilities.getSelectedObjects(theSelection);
if (!allObjs.isEmpty() && allObjs.size() == 1) {
Iterator<Object> iter = allObjs.iterator();
result = true;
Object nextObj = null;
while (iter.hasNext() && result) {
nextObj = iter.next();

if (nextObj instanceof IFile) {
IFile theFile = (IFile)nextObj;

result = theFile.getFileExtension().equalsIgnoreCase("JAR");
} else {
result = false;
}
}
}

return result;
}

private Shell getShell() {
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package org.teiid.designer.runtime.ui.actions;

import java.util.Iterator;
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.DqpUiPlugin;
import org.teiid.designer.runtime.ui.Messages;
import org.teiid.designer.runtime.ui.wizards.vdbs.GenerateDynamicVdbDialog;
import org.teiid.designer.runtime.ui.wizards.vdbs.GenerateDynamicVdbManager;
import org.teiid.designer.ui.actions.SortableSelectionAction;
import org.teiid.designer.ui.common.actions.ModelActionConstants;
import org.teiid.designer.ui.common.eventsupport.SelectionUtilities;
import org.teiid.designer.ui.viewsupport.ModelUtilities;

public class GenerateDynamicVdbAction2 extends SortableSelectionAction implements DqpUiConstants {
private static final String label = DqpUiConstants.UTIL.getString("label"); //$NON-NLS-1$
/**
* @since 5.0
*/
public GenerateDynamicVdbAction2() {
super(label, SWT.DEFAULT);
setImageDescriptor(DqpUiPlugin.getDefault().getImageDescriptor(Images.DYNAMIC_VDB));
setId(ModelActionConstants.Resource.GENERATE_VDB_XML);
}

/**
* @see org.teiid.designer.ui.actions.SortableSelectionAction#isValidSelection(org.eclipse.jface.viewers.ISelection)
* @since 5.0
*/
@Override
public boolean isValidSelection( ISelection selection ) {
// Enable for single/multiple Virtual Tables
return vdbSelected(selection);
}

/**
* @see org.eclipse.jface.action.IAction#run()
* @since 5.0
*/
@Override
public void run() {

Object obj = SelectionUtilities.getSelectedObject(getSelection());
if (obj instanceof IFile) {
IFile vdbXmlFile = (IFile)obj;

try {
GenerateDynamicVdbManager vdbManager = new GenerateDynamicVdbManager(vdbXmlFile);

GenerateDynamicVdbDialog dialog = new GenerateDynamicVdbDialog(getShell(), vdbManager);

if( dialog.open() == IDialogConstants.OK_ID) {
vdbManager.write();
}
return;
} catch (Exception ex) {
MessageDialog.openError(getShell(),
Messages.GenerateDynamicVdbAction_exceptionTitle,
ex.getLocalizedMessage());
}
}

MessageDialog.openInformation(getShell(),
Messages.GenerateDynamicVdbAction_nothingExportedTitle,
Messages.GenerateDynamicVdbAction_nothingExportedMessage);

}

/**
* @see org.teiid.designer.ui.actions.ISelectionAction#isApplicable(org.eclipse.jface.viewers.ISelection)
* @since 5.0
*/
@Override
public boolean isApplicable( ISelection selection ) {
return vdbSelected(selection);
}

private boolean vdbSelected( ISelection theSelection ) {
boolean result = false;
List<Object> allObjs = SelectionUtilities.getSelectedObjects(theSelection);
if (!allObjs.isEmpty() && allObjs.size() == 1) {
Iterator<Object> iter = allObjs.iterator();
result = true;
Object nextObj = null;
while (iter.hasNext() && result) {
nextObj = iter.next();

if (nextObj instanceof IFile) {
result = ModelUtilities.isVdbFile((IFile)nextObj);
} else {
result = false;
}
}
}

return result;
}

private Shell getShell() {
return Display.getCurrent().getActiveShell();
}
}

0 comments on commit 409f47f

Please sign in to comment.