Skip to content

Commit

Permalink
TEIIDDES-2459: Adds version guard listener
Browse files Browse the repository at this point in the history
* In addition to dialog question when calling the
SetDefaultServerAction,
  a warning should be displayed if a server is added and its the first

* ServerVersionGuard listener for default server changes and displays a
  warning if the server version is greater than the default
  • Loading branch information
Paul Richardson authored and blafond committed Mar 30, 2015
1 parent 8f56a3b commit efedbf2
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.teiid.designer.runtime.preview.PreviewManager;
import org.teiid.designer.runtime.preview.jobs.TeiidPreviewVdbCleanupJob;
import org.teiid.designer.runtime.spi.ITeiidServerManager;
import org.teiid.designer.runtime.ui.server.ServerVersionGuard;
import org.teiid.designer.ui.common.AbstractUiPlugin;
import org.teiid.designer.ui.common.actions.ActionService;
import org.teiid.designer.ui.common.util.UiUtil;
Expand Down Expand Up @@ -143,6 +144,9 @@ public void start( BundleContext context ) throws Exception {
super.start(context);
// Initialize logging/i18n/debugging utility
((PluginUtilImpl)UTIL).initializePlatformLogger(this);

ITeiidServerManager manager = DqpPlugin.getInstance().getServerManager();
manager.addListener(ServerVersionGuard.getInstance());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ StatusBarUpdater.num_elements_selected={0} elements selected

DqpUiPlugin.errorDialogTitle = Error

#########################################
# ServerVersionGuard
#########################################
ServerVersionGuard.notifyUnsupportedMsgTitle=Unsupported Teiid Version
ServerVersionGuard.notifyUnsupportedMsg=The default Teiid Instance has an unsupported version. Care should be taken in modelling against this version and deploying artifacts to the server.

########## ConnectorBindingsTreeProvider ##########

ConnectorBindingsTreeProvider.unexpectedElement={0} - {1}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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.runtime.ui.server;

import static org.teiid.designer.runtime.ui.DqpUiConstants.UTIL;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.teiid.core.designer.util.StringConstants;
import org.teiid.designer.runtime.spi.ExecutionConfigurationEvent;
import org.teiid.designer.runtime.spi.IExecutionConfigurationListener;
import org.teiid.designer.runtime.spi.ITeiidServer;
import org.teiid.designer.runtime.ui.DqpUiPlugin;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;
import org.teiid.designer.runtime.version.spi.TeiidServerVersion;

/**
*
*/
public class ServerVersionGuard implements IExecutionConfigurationListener, StringConstants {

private static IExecutionConfigurationListener instance;

/**
* @return singleton instance
*/
public static IExecutionConfigurationListener getInstance() {
if (instance == null)
instance = new ServerVersionGuard();

return instance;
}

@Override
public void configurationChanged(ExecutionConfigurationEvent event) {
if (ExecutionConfigurationEvent.EventType.DEFAULT != event.getEventType())
return;

if (ExecutionConfigurationEvent.TargetType.SERVER != event.getTargetType())
return;

ITeiidServer instance = event.getUpdatedServer();
ITeiidServerVersion version = instance.getServerVersion();
if (! version.isGreaterThan(TeiidServerVersion.Version.TEIID_DEFAULT.get()))
return;

IWorkbench workbench = DqpUiPlugin.getDefault().getWorkbench();
if (workbench == null)
return;

IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
if (window == null)
return;

MessageDialog.openWarning(window.getShell(),
UTIL.getString(getClass().getSimpleName() + DOT + "notifyUnsupportedMsgTitle"), //$NON-NLS-1$
UTIL.getString(getClass().getSimpleName() + DOT + "notifyUnsupportedMsg")); //$NON-NLS-1$
}

}

0 comments on commit efedbf2

Please sign in to comment.