use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.
the class RenameDatabaseAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
final CubridDatabase database = (CubridDatabase) obj[0];
ISelectionProvider provider = this.getSelectionProvider();
final TreeViewer viewer = (TreeViewer) provider;
String serverName = database.getServer().getName();
String dbName = database.getName();
final String jobName = serverName + "-" + dbName + "-" + Messages.msgRenameDBRearJobName;
final RenameDatabaseDialog dialog = new RenameDatabaseDialog(getShell(), new ITaskExecutorInterceptor() {
public void completeAll() {
QueryOptions.removePref(database.getDatabaseInfo());
CommonUITool.openInformationBox(Messages.titleSuccess, Messages.bind(Messages.msgRenameDBComplete, jobName));
CommonUITool.refreshNavigatorTree(viewer, database.getParent());
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
dialog.setDatabase(database);
final Shell shell = getShell();
TaskExecutor taskExcutor = new TaskExecutor() {
@SuppressWarnings("unchecked")
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(Messages.getDbSpaceInfoTaskName, IProgressMonitor.UNKNOWN);
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (openErrorBox(shell, msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
if (task instanceof CommonQueryTask) {
dbSpaceInfo = ((CommonQueryTask<DbSpaceInfoList>) task).getResultModel();
}
}
return true;
}
};
dbSpaceInfo = new DbSpaceInfoList();
CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfo);
task.setDbName(database.getLabel());
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess()) {
dialog.setDbSpaceInfoList(dbSpaceInfo);
dialog.open();
}
}
use of org.eclipse.jface.viewers.ISelectionProvider in project dbeaver by serge-rider.
the class ViewValuePanel method createContents.
@Override
public Control createContents(IResultSetPresentation presentation, Composite parent) {
this.presentation = presentation;
viewPlaceholder = new Composite(parent, SWT.NONE);
viewPlaceholder.setLayout(new FillLayout());
viewPlaceholder.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (viewPlaceholder.getChildren().length == 0) {
String hidePanelCmd = ActionUtils.findCommandDescription(ResultSetCommandHandler.CMD_TOGGLE_PANELS, ViewValuePanel.this.presentation.getController().getSite(), true);
UIUtils.drawMessageOverControl(viewPlaceholder, e, "Select a cell to view/edit value", 0);
UIUtils.drawMessageOverControl(viewPlaceholder, e, "Press " + hidePanelCmd + " to hide this panel", 20);
}
}
});
if (this.presentation instanceof ISelectionProvider) {
final ISelectionProvider selectionProvider = (ISelectionProvider) this.presentation;
final ISelectionChangedListener selectionListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (ViewValuePanel.this.presentation.getController().getVisiblePanel() == ViewValuePanel.this) {
refreshValue(false);
}
}
};
selectionProvider.addSelectionChangedListener(selectionListener);
viewPlaceholder.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
selectionProvider.removeSelectionChangedListener(selectionListener);
}
});
}
return viewPlaceholder;
}
use of org.eclipse.jface.viewers.ISelectionProvider in project dbeaver by serge-rider.
the class GenerateSQLContributor method getSelectionFromPart.
@Nullable
static IStructuredSelection getSelectionFromPart(IWorkbenchPart part) {
if (part == null) {
return null;
}
ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
if (selectionProvider == null) {
return null;
}
ISelection selection = selectionProvider.getSelection();
if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
return null;
}
return (IStructuredSelection) selection;
}
use of org.eclipse.jface.viewers.ISelectionProvider in project xtext-eclipse by eclipse.
the class MarkOccurrencesTest method testMarkOccurrencesCrossFile.
@Test
public void testMarkOccurrencesCrossFile() throws Exception {
String model1 = "Zonk { Bar(Foo) {} Baz(Foo Bar) {} }";
String model2 = "Foo {}";
IFile modelFile1 = IResourcesSetupUtil.createFile("test/src/Test1.outlinetestlanguage", model1);
IResourcesSetupUtil.createFile("test/src/Test2.outlinetestlanguage", model2);
IResourcesSetupUtil.waitForBuild();
XtextEditor editor = openEditor(modelFile1);
ISelectionProvider selectionProvider = editor.getSelectionProvider();
selectionProvider.setSelection(new TextSelection(model1.indexOf("Foo"), 1));
IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
ExpectationBuilder listener = new ExpectationBuilder().added(OCCURRENCE_ANNOTATION_TYPE, model1.indexOf("Foo", 3), 3).added(OCCURRENCE_ANNOTATION_TYPE, model1.lastIndexOf("Foo"), 3);
listener.start();
annotationModel.addAnnotationModelListener(listener);
setMarkOccurrences(true);
listener.verify(TIMEOUT);
}
use of org.eclipse.jface.viewers.ISelectionProvider in project xtext-eclipse by eclipse.
the class XtextEditor method uninstallSelectionChangedListener.
private void uninstallSelectionChangedListener() {
ISelectionProvider selectionProvider = getSelectionProvider();
if (selectionProvider != null) {
if (selectionProvider instanceof IPostSelectionProvider) {
final IPostSelectionProvider postSelectionProvider = (IPostSelectionProvider) selectionProvider;
postSelectionProvider.removePostSelectionChangedListener(selectionChangedListener);
} else {
selectionProvider.removeSelectionChangedListener(selectionChangedListener);
}
}
}
Aggregations