Skip to content

Commit

Permalink
TEIIDDES-1727: Remove 'show translators' option
Browse files Browse the repository at this point in the history
* As per suggestion on jira, the translators are a permanent feature of a
  teiid server so little point in hiding them, especially as the current
  hiding mechanism is imperfect in its logic.
  • Loading branch information
Paul Richardson committed May 16, 2013
1 parent 21bdc8d commit 6e3db9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.teiid.designer.runtime.preview.PreviewManager;
import org.teiid.designer.runtime.spi.ITeiidDataSource;
import org.teiid.designer.runtime.spi.ITeiidServer;
import org.teiid.designer.runtime.spi.ITeiidTranslator;
import org.teiid.designer.runtime.spi.ITeiidVdb;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.DqpUiPlugin;
Expand All @@ -64,26 +63,6 @@ public class TeiidServerActionProvider extends CommonActionProvider {
* Prefix for language NLS properties
*/
private static final String PREFIX = I18nUtil.getPropertyPrefix(TeiidServerActionProvider.class);

/**
* A <code>ViewerFilter</code> that hides the translators.
*/
private static final ViewerFilter TRANSLATORS_FILTER = new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public boolean select(Viewer viewer,
Object parentElement,
Object element) {
ITeiidTranslator teiidTranslator = RuntimeAssistant.adapt(element, ITeiidTranslator.class);
if (teiidTranslator != null) return false;

return true;
}
};

/**
* A <code>ViewerFilter</code> that hides Preview Data Sources.
Expand Down Expand Up @@ -131,7 +110,6 @@ public boolean select(Viewer viewer,
private static final String MENU_MEMENTO = "menu-settings"; //$NON-NLS-1$
private static final String SHOW_PREVIEW_VDBS = "show-preview-vdbs"; //$NON-NLS-1$
private static final String SHOW_PREVIEW_DATA_SOURCES = "show-preview-data-sources"; //$NON-NLS-1$
private static final String SHOW_TRANSLATORS = "show-translators"; //$NON-NLS-1$

private ICommonActionExtensionSite actionSite;

Expand Down Expand Up @@ -179,8 +157,6 @@ public boolean select(Viewer viewer,

private IAction showPreviewDataSourcesAction;

private IAction showTranslatorsAction;

private IAction enablePreviewAction;

private IMenuListener enablePreviewActionListener = new IMenuListener() {
Expand All @@ -202,15 +178,7 @@ public void menuAboutToShow( IMenuManager manager ) {
* <code>true</code> if the viewer should show preview data sources
*/
private boolean showPreviewDataSources;

/**
* <code>true</code> if the viewer should show translators
*/
private boolean showTranslators;





/**
* Create instance
*/
Expand Down Expand Up @@ -280,10 +248,6 @@ private void updateViewerFilters() {
if (!this.showPreviewVdbs) {
filters.add(PREVIEW_VDB_FILTER);
}

if (!this.showTranslators) {
filters.add(TRANSLATORS_FILTER);
}

// set new content filters
this.viewer.setFilters(filters.toArray(new ViewerFilter[filters.size()]));
Expand All @@ -304,15 +268,7 @@ private void toggleShowPreviewDataSources() {
this.showPreviewDataSources = !this.showPreviewDataSources;
updateViewerFilters();
}

/**
* Handler for when the show translator menu action is selected
*/
private void toggleShowTranslators() {
this.showTranslators = !this.showTranslators;
updateViewerFilters();
}


/*
* Initialize view actions, set icons and action text.
*/
Expand Down Expand Up @@ -483,16 +439,6 @@ public void run() {
}
};
}

// add the show translators action
if (showTranslatorsAction == null) {
showTranslatorsAction = new Action(getString("showTranslatorsMenuItem"), SWT.TOGGLE) { //$NON-NLS-1$
@Override
public void run() {
toggleShowTranslators();
}
};
}

// add the show preview data sources action
if (showPreviewDataSourcesAction == null) {
Expand All @@ -506,7 +452,6 @@ public void run() {
}

showPreviewVdbsAction.setChecked(this.showPreviewVdbs);
showTranslatorsAction.setChecked(this.showTranslators);
showPreviewDataSourcesAction.setChecked(this.showPreviewDataSources);

if (enablePreviewAction == null) {
Expand All @@ -527,7 +472,6 @@ public void setChecked( boolean checked ) {
menuMgr.addMenuListener(enablePreviewActionListener);

menuMgr.add(showPreviewVdbsAction);
menuMgr.add(showTranslatorsAction);
menuMgr.add(showPreviewDataSourcesAction);
menuMgr.add(enablePreviewAction);
}
Expand Down Expand Up @@ -639,7 +583,6 @@ public void saveState(IMemento memento) {
IMemento menuMemento = memento.createChild(MENU_MEMENTO);
menuMemento.putBoolean(SHOW_PREVIEW_DATA_SOURCES, this.showPreviewDataSourcesAction.isChecked());
menuMemento.putBoolean(SHOW_PREVIEW_VDBS, this.showPreviewVdbsAction.isChecked());
menuMemento.putBoolean(SHOW_TRANSLATORS, this.showTranslatorsAction.isChecked());
super.saveState(memento);
}

Expand All @@ -652,11 +595,6 @@ private void restoreLocalPullDown(IMemento viewMemento) {
if (menuMemento != null) {
this.showPreviewDataSources = menuMemento.getBoolean(SHOW_PREVIEW_DATA_SOURCES);
this.showPreviewVdbs = menuMemento.getBoolean(SHOW_PREVIEW_VDBS);
this.showTranslators = menuMemento.getBoolean(SHOW_TRANSLATORS);

if (viewer.getContentProvider() instanceof TeiidServerContentProvider) {
((TeiidServerContentProvider) viewer.getContentProvider()).setShowTranslators(this.showTranslators);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,6 @@ public boolean isShowDataSources() {
public void setShowDataSources(boolean show) {
this.showDataSources = show;
}

/**
* @return the showTranslators
*/
public boolean isShowTranslators() {
return this.showTranslators;
}

/**
* Set show translators flag
*
* @param show
*/
public void setShowTranslators(boolean show) {
this.showTranslators = show;
}

/**
* @return the showVDBs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,11 @@ public final void load() {

// hide translators related variables from other local variables
TRANSLATORS: {
Collection<ITeiidTranslator> translators;

if (provider.isShowTranslators()) {
translators = teiidServer.getTranslators();

if (!translators.isEmpty()) {
children.add(new TranslatorsFolder(this, translators));
}
} else {
translators = Collections.emptyList();
Collection<ITeiidTranslator> translators = teiidServer.getTranslators();
if (!translators.isEmpty()) {
children.add(new TranslatorsFolder(this, translators));
}

break TRANSLATORS;
}
clearError();
Expand Down

0 comments on commit 6e3db9a

Please sign in to comment.