use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.
the class ShowAllContainersCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final boolean checked = !HandlerUtil.toggleCommandState(event.getCommand());
if (activePart instanceof DockerContainersView) {
final DockerContainersView containersView = (DockerContainersView) activePart;
containersView.showAllContainers(checked);
}
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.
the class ShowInSystemExplorerCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<DockerContainerVolume> volumes = CommandUtils.getSelectedVolumes(activePart);
if (volumes == null || volumes.isEmpty()) {
return null;
}
final DockerContainerVolume selectedVolume = volumes.get(0);
final File hostFile = new File(selectedVolume.getHostPath());
final String launchCmd = getShowInSystemExplorerCommand(hostFile);
if (launchCmd == null) {
return null;
}
final Job job = new Job(CommandMessages.getString("command.showIn.systemExplorer")) {
// $NON-NLS-1$
@Override
protected IStatus run(final IProgressMonitor monitor) {
try {
final Process p = getLaunchProcess(launchCmd, hostFile);
final int retCode = p.waitFor();
if (retCode != 0 && !Util.isWindows()) {
Activator.log(new DockerException(CommandMessages.getFormattedString(// $NON-NLS-1$
"command.showIn.systemExplorer.failure.command.execute", launchCmd, Integer.toString(retCode))));
}
} catch (IOException | InterruptedException e) {
Activator.logErrorMessage(CommandMessages.getFormattedString(// $NON-NLS-1$
"command.showIn.systemExplorer.failure", launchCmd), e);
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.
the class ShowInWebBrowserCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<IDockerPortMapping> portMappings = getSelectedPortMappings(activePart);
if (portMappings == null || portMappings.isEmpty()) {
return null;
}
final Job job = new Job(// $NON-NLS-1$
CommandMessages.getString("command.showIn.webBrowser")) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
try {
final IDockerConnection currentConnection = getCurrentConnection(activePart);
final IDockerPortMapping selectedPort = portMappings.get(0);
final URI connectionURI = new URI(currentConnection.getUri());
if (// $NON-NLS-1$
"tcp".equalsIgnoreCase(connectionURI.getScheme()) || // $NON-NLS-1$
"unix".equalsIgnoreCase(connectionURI.getScheme()) || // $NON-NLS-1$
"http".equalsIgnoreCase(connectionURI.getScheme()) || // $NON-NLS-1$
"https".equalsIgnoreCase(connectionURI.getScheme())) {
final String host = // $NON-NLS-1$
"unix".equalsIgnoreCase(connectionURI.getScheme()) ? "127.0.0.1" : // $NON-NLS-1$
connectionURI.getHost();
final URL location = new // $NON-NLS-1$
URL(// $NON-NLS-1$
"http", // $NON-NLS-1$
host, selectedPort.getPublicPort(), // $NON-NLS-1$
"/");
openLocationInWebBrowser(location);
}
} catch (URISyntaxException | MalformedURLException e) {
Activator.logErrorMessage(CommandMessages.getString(// $NON-NLS-1$
"command.showIn.webBrowser.failure"), e);
}
monitor.done();
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project knime-core by knime.
the class AbstractRepositoryView method init.
/**
* {@inheritDoc}
*/
@Override
public void init(final IViewSite site) throws PartInitException {
super.init(site);
// Bug#5807 set the initial focus on the search field.
site.getPage().addPartListener(new IPartListener() {
@Override
public void partOpened(final IWorkbenchPart part) {
}
@Override
public void partDeactivated(final IWorkbenchPart part) {
}
@Override
public void partClosed(final IWorkbenchPart part) {
}
@Override
public void partBroughtToTop(final IWorkbenchPart part) {
}
@Override
public void partActivated(final IWorkbenchPart part) {
if (part == AbstractRepositoryView.this) {
m_toolbarSearchText.getText().setFocus();
}
}
});
}
use of org.eclipse.ui.IWorkbenchPart in project dbeaver by dbeaver.
the class CompileHandler method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
List<OracleSourceObject> objects = new ArrayList<>();
IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
if (partSite != null) {
final ISelectionProvider selectionProvider = partSite.getSelectionProvider();
if (selectionProvider != null) {
ISelection selection = selectionProvider.getSelection();
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
for (Iterator<?> iter = ((IStructuredSelection) selection).iterator(); iter.hasNext(); ) {
final Object item = iter.next();
final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(item, OracleSourceObject.class);
if (sourceObject != null) {
objects.add(sourceObject);
}
}
}
}
if (objects.isEmpty()) {
final IWorkbenchPart activePart = partSite.getPart();
final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(activePart, OracleSourceObject.class);
if (sourceObject != null) {
objects.add(sourceObject);
}
}
}
if (!objects.isEmpty()) {
if (objects.size() > 1) {
element.setText("Compile " + objects.size() + " objects");
} else {
final OracleSourceObject sourceObject = objects.get(0);
String objectType = TextUtils.formatWord(sourceObject.getSourceType().name());
element.setText("Compile " + objectType);
}
}
}
Aggregations