use of org.eclipse.jface.viewers.ISelection in project flux by eclipse.
the class SyncDisconnectHandler method setEnabled.
@Override
public void setEnabled(Object evaluationContext) {
Repository repository = org.eclipse.flux.core.Activator.getDefault().getRepository();
if (repository != null && evaluationContext instanceof IEvaluationContext) {
IEvaluationContext evalContext = (IEvaluationContext) evaluationContext;
Object selection = evalContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
if (selection instanceof ISelection) {
IProject[] selectedProjects = getSelectedProjects((ISelection) selection);
for (IProject project : selectedProjects) {
if (repository.isConnected(project)) {
setBaseEnabled(true);
return;
}
}
}
}
setBaseEnabled(false);
}
use of org.eclipse.jface.viewers.ISelection in project tdi-studio-se by Talend.
the class UIManager method moveRecord.
public void moveRecord(TreeViewer schemaTreeViewer, boolean left) {
if (schemaTreeViewer == null) {
return;
}
ISelection selection = schemaTreeViewer.getSelection();
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof SchemasKeyData) {
SchemasKeyData data = (SchemasKeyData) element;
SchemasKeyData parent = data.getParent();
if (left) {
SchemasKeyData grandfather = parent.getParent();
if (grandfather != null) {
// not in root.
List<SchemasKeyData> children = grandfather.getChildren();
int index = -1;
for (int i = 0; i < children.size(); i++) {
if (children.get(i) == parent) {
index = i;
break;
}
}
if (index > -1) {
int index2 = index + 1;
if (index2 > children.size()) {
grandfather.addChild(data);
} else {
grandfather.addChild(index2, data);
}
}
}
} else {
SchemasKeyData sibling = null;
for (SchemasKeyData skd : parent.getChildren()) {
if (skd == data) {
break;
} else {
sibling = skd;
}
}
if (sibling != null) {
sibling.addChild(data);
}
}
schemaTreeViewer.refresh();
}
}
}
use of org.eclipse.jface.viewers.ISelection in project tdi-studio-se by Talend.
the class OpenExistVersionProcessAction method doRun.
@Override
protected void doRun() {
ISelection selection = getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
RepositoryNode node = (RepositoryNode) obj;
IPath path = RepositoryNodeUtilities.getPath(node);
String originalName = node.getObject().getLabel();
RepositoryObject repositoryObj = new RepositoryObject(node.getObject().getProperty());
repositoryObj.setRepositoryNode(node.getObject().getRepositoryNode());
OpenExistVersionProcessWizard wizard = new OpenExistVersionProcessWizard(repositoryObj);
WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
dialog.setPageSize(300, 250);
//$NON-NLS-1$
dialog.setTitle(Messages.getString("OpenExistVersionProcess.open.dialog"));
if (dialog.open() == Dialog.OK) {
refresh(node);
// refresh the corresponding editor's name
IEditorPart part = getCorrespondingEditor(node);
if (part != null && part instanceof IUIRefresher) {
((IUIRefresher) part).refreshName();
} else {
processRoutineRenameOperation(originalName, node, path);
}
}
}
use of org.eclipse.jface.viewers.ISelection in project tdi-studio-se by Talend.
the class RunProcess method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
ISelection selection = getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof RepositoryNode)) {
return;
}
// Add this job to running history list.
JobLaunchShortcutManager.run(selection);
}
use of org.eclipse.jface.viewers.ISelection in project tdi-studio-se by Talend.
the class ProcessVersionComposite method addPopUpMenu.
/**
* DOC Administrator Comment method "addPoppuMenu".
*/
private void addPopUpMenu() {
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager mgr) {
if (getParentWizard() == null) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action instanceof OpenExistVersionProcessAction) {
continue;
}
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
Object o = structuredSelection.getFirstElement();
if (o instanceof RepositoryNode) {
((AContextualAction) action).setAvoidUnloadResources(true);
}
if (action.isVisible()) {
mgr.add(action);
}
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
}
Aggregations