Skip to content

Commit

Permalink
Tidy up some teiid view related issues
Browse files Browse the repository at this point in the history
* EditServerAction
* TeiidServerEditor
 * Rather than refreshing using the action (pointless, since the
   view is not modal), make the editor signal a server refresh
   event.

* SetDefaultServerAction
 * Improves clarity of logic

* TeiidServerContentProvider
 * Improve refresh thread's ability to fire by waiting for
   pending updates rather than a flag
 * Remove event.getServer() since this can creata an exception
 * Add tooltips to tree content

* TeiidView
 * Remove extraneous methods

* AbstractTeiidFolder
* TeiidDataNode
* TeiidResourceNode
* TeiidServerContainerNode
 * Uses the toString() method for tooltips
  • Loading branch information
Paul Richardson committed Nov 10, 2012
1 parent ee1c4ff commit 23d908a
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 297 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ VdbDefinitionLabelProvider.none.ReadOnly = (no connector defined)
duplicateNameMsg=A connector with the name "{0}" already exists.
nameIsValidMsg=Name is valid

########## TeiidServerLabelProvider #############
TeiidDataNode.activeVdb=ACTIVE
TeiidDataNode.inactiveVdb=INACTIVE

########## TeiidView ##########
TeiidView.openAction.text=Open
TeiidView.title.text=Teiid
Expand All @@ -100,8 +104,6 @@ TeiidView.undeployVdbActionTooltip=Undeploy VDB from Teiid
TeiidView.showPreviewVdbsMenuItem = Show Preview VDBs
TeiidView.showPreviewDataSourcesMenuItem = Show Preview Data Sources
TeiidView.showTranslatorsMenuItem = Show Translators
TeiidView.activeVdb=ACTIVE
TeiidView.inactiveVdb=INACTIVE
TeiidView.executeVdbAction=Execute VDB
TeiidView.createDataSourceAction.text=Create Data Source
TeiidView.createDataSourceAction.tooltip=Create Data Source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
import org.eclipse.ui.actions.BaseSelectionListenerAction;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.runtime.TeiidServerManager;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.DqpUiPlugin;
import org.teiid.designer.runtime.ui.views.TeiidView;
import org.teiid.designer.ui.common.util.UiUtil;


/**
Expand Down Expand Up @@ -64,7 +61,7 @@ public EditServerAction( Shell shell,
this.shell = shell;
this.teiidServerManager = teiidServerManager;
}

// ===========================================================================================================================
// Methods
// ===========================================================================================================================
Expand Down Expand Up @@ -95,13 +92,6 @@ else if (teiidServerManager.getServers().size() > 1) {
if( this.serverBeingEdited == null ) return;

DqpUiPlugin.editTeiidServer(serverBeingEdited);

// refresh viewer in Teiid View to display latest label
TeiidView teiidView = (TeiidView)UiUtil.getViewPart(DqpUiConstants.Extensions.CONNECTORS_VIEW_ID);

if (teiidView != null) {
teiidView.updateLabel(this.serverBeingEdited);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,17 @@ protected boolean updateSelection( IStructuredSelection selection ) {
TeiidServer teiidServer = RuntimeAssistant.getServerFromSelection(selection);

// enable only if selected object is server and not same server
if (teiidServer != null) {
this.selectedServer = teiidServer;
if (this.teiidServerManager.getDefaultServer() != null
&& !this.selectedServer.equals(this.teiidServerManager.getDefaultServer())) {
return true;
}
}
if (teiidServer == null)
return false;

this.selectedServer = teiidServer;

// No default server selected so display the action to allow it
if (teiidServerManager.getDefaultServer() == null)
return true;

if (! this.selectedServer.equals(this.teiidServerManager.getDefaultServer()))
return true;

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ public void doSave(IProgressMonitor monitor) {

dirty = false;
firePropertyChange(IEditorPart.PROP_DIRTY);

serverManager.notifyListeners(ExecutionConfigurationEvent.createServerRefreshEvent(teiidServer));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,31 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.ui.views.as7.management.content.IContainerNode;
import org.jboss.ide.eclipse.as.ui.views.as7.management.content.IContentNode;
import org.jboss.tools.as.wst.server.ui.xpl.ServerToolTip;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.ExecutionConfigurationEvent;
import org.teiid.designer.runtime.IExecutionConfigurationListener;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.server.RuntimeAssistant;
import org.teiid.designer.runtime.ui.views.content.AbstractTeiidFolder;
import org.teiid.designer.runtime.ui.views.content.DataSourcesFolder;
import org.teiid.designer.runtime.ui.views.content.TeiidDataNode;
import org.teiid.designer.runtime.ui.views.content.TeiidResourceNode;
import org.teiid.designer.runtime.ui.views.content.TranslatorsFolder;
import org.teiid.designer.runtime.ui.views.content.VdbsFolder;
Expand Down Expand Up @@ -69,23 +75,14 @@ public class TeiidServerContentProvider implements ITreeContentProvider {
private boolean showTranslators = true;

private class RefreshThread extends Thread {
private boolean refreshCompleted = true;


private boolean die = false;

private LinkedBlockingQueue<Object> queue = new LinkedBlockingQueue<Object>();

public RefreshThread() {
super(TeiidServerContentProvider.this + "." + RefreshThread.class.getSimpleName()); //$NON-NLS-1$
setDaemon(true);

// Tracks loadElementJob to determine when it has finished
loadElementJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
refreshCompleted = true;
}
});
}


Expand All @@ -107,11 +104,10 @@ public void refresh() {
public void run() {
while (! Thread.currentThread().isInterrupted() && ! die) {
try {
if (refreshCompleted) {
if (pendingUpdates.size() == 0) {
queue.take();

// Successfully taken from the queue so do the refresh
refreshCompleted = false;
doRefreshWork();
}

Expand Down Expand Up @@ -255,17 +251,14 @@ public void run() {

@Override
public void configurationChanged( final ExecutionConfigurationEvent event ) {

TeiidServer eventServer = event.getServer();
if (eventServer == null)
return;

refreshThread.refresh();
}
};

private RefreshThread refreshThread = new RefreshThread();

private ServerToolTip tooltip;

/**
* Content will include VDBs, translators, and data sources.
* @since 5.0
Expand Down Expand Up @@ -468,6 +461,29 @@ public boolean hasChildren( Object element ) {
public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
if (viewer instanceof TreeViewer) {
this.viewer = (TreeViewer) viewer;
if( tooltip != null )
tooltip.deactivate();

tooltip = new ServerToolTip(this.viewer.getTree()) {

@Override
protected boolean isMyType(Object selected) {
return RuntimeAssistant.adapt(selected, AbstractTeiidFolder.class) != null ||
RuntimeAssistant.adapt(selected, TeiidDataNode.class) != null ||
RuntimeAssistant.adapt(selected, TeiidServer.class) != null;
}
@Override
protected void fillStyledText(Composite parent, StyledText sText, Object o) {
if (o instanceof TreeItem) {
String text = ((TreeItem) o).getData().toString();
sText.setText(text.replace("\n", "<br>")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
};
tooltip.setShift(new Point(15, 8));
tooltip.setPopupDelay(500); // in ms
tooltip.setHideOnMouseDown(true);
tooltip.activate();
} else {
this.viewer = null;
}
Expand Down

0 comments on commit 23d908a

Please sign in to comment.