use of org.eclipse.ui.WorkbenchException in project mdw-designer by CenturyLinkCloud.
the class AssetSearchQuery method openExternalEvent.
private void openExternalEvent(ExternalEvent eventHandler) {
try {
IWorkbenchPage page = MdwPlugin.getActivePage();
ProcessExplorerView processExplorer = (ProcessExplorerView) page.findView(ProcessExplorerView.VIEW_ID);
if (processExplorer != null) {
processExplorer.setFocus();
processExplorer.select(eventHandler);
page.showView("org.eclipse.ui.views.PropertySheet");
}
} catch (WorkbenchException ex) {
PluginMessages.uiError(MdwPlugin.getShell(), ex, "Event Handler", eventHandler.getProject());
}
}
use of org.eclipse.ui.WorkbenchException in project tdq-studio-se by Talend.
the class CreateNewAnalysisAction method run.
/*
* (non-Jsdoc)
*
* @see org.eclipse.ui.intro.config.IIntroAction#run(org.eclipse.ui.intro.IIntroSite, java.util.Properties)
*/
public void run(IIntroSite site, Properties params) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (factory.isUserReadOnlyOnCurrentProject()) {
// $NON-NLS-1$
MessageDialog.openWarning(// $NON-NLS-1$
null, // $NON-NLS-1$
DefaultMessagesImpl.getString("CreateNewAnalysisAction.readOnlyErrorTitle"), // $NON-NLS-1$
DefaultMessagesImpl.getString("CreateNewAnalysisAction.readOnlyErrorMessage"));
} else {
PlatformUI.getWorkbench().getIntroManager().closeIntro(PlatformUI.getWorkbench().getIntroManager().getIntro());
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == workbenchWindow) {
return;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (null == workbenchPage) {
return;
}
IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
if (!IBrandingConfiguration.PERSPECTIVE_DQ_ID.equals(currentPerspective.getId())) {
// show dq perspective
try {
workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_DQ_ID, workbenchWindow);
workbenchPage = workbenchWindow.getActivePage();
} catch (WorkbenchException e) {
ExceptionHandler.process(e);
return;
}
}
run();
}
}
use of org.eclipse.ui.WorkbenchException in project tdq-studio-se by Talend.
the class PreferredPerspectivePartListener method refresh.
public static void refresh(final IWorkbenchPart part) {
if (!(part instanceof IPrefersPerspective)) {
return;
}
final IWorkbenchWindow workbenchWindow = part.getSite().getPage().getWorkbenchWindow();
IPerspectiveDescriptor activePerspective = workbenchWindow.getActivePage().getPerspective();
final List<String> preferredPerspectiveId = ((IPrefersPerspective) part).getPreferredPerspectiveId();
if (preferredPerspectiveId == null || preferredPerspectiveId.size() < 1) {
return;
}
if (activePerspective == null || !preferredPerspectiveId.contains(activePerspective.getId())) {
// Switching of the perspective is delayed using Display.asyncExec because switching the perspective while
// the workbench is activating parts might cause conflicts.
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
String perspectiveId = preferredPerspectiveId.get(0);
// $NON-NLS-1$ //$NON-NLS-2$
log.debug("Switching to preferred perspective " + perspectiveId + " for " + part.getClass());
try {
workbenchWindow.getWorkbench().showPerspective(perspectiveId, workbenchWindow);
} catch (WorkbenchException e) {
// $NON-NLS-1$ //$NON-NLS-2$
log.warn("Could not switch to preferred perspective " + perspectiveId + " for " + part.getClass(), e);
}
}
});
}
}
use of org.eclipse.ui.WorkbenchException in project abstools by abstools.
the class Debugger method startABSRuntime.
/**
* Used to start the ABS Runtime. If an earlier Runtime is present, it is shut down first.
*
* @param projectName
* @param mainClassName
* @param genPath
* @param debuggerArgsSystemObserver
* @param debuggerArgsTotalScheduler
* @param debuggerIsInDebugMode
* @param debuggerArgsRandomSeed
* @param fliClassPath
* @param outStream
* @param ignoreMissingFLIClasses
* @param useFifoSemantics
* @throws InvalidRandomSeedException
*/
public static void startABSRuntime(final String projectName, final String mainClassName, final Path genPath, String debuggerArgsSystemObserver, String debuggerArgsTotalScheduler, boolean debuggerIsInDebugMode, String debuggerArgsRandomSeed, boolean terminateOnException, List<URL> fliClassPath, PrintStream outStream, PrintStream errStream, boolean ignoreMissingFLIClasses, boolean useFifoSemantics) throws InvalidRandomSeedException {
if (DO_DEBUG)
System.out.println("start internal debugger");
final ABSRuntime r = new ABSRuntime();
if (debuggerIsInDebugMode)
r.enableDebugging(true);
r.setOutStream(outStream);
r.setErrStream(errStream);
r.addFLIClassPath(fliClassPath);
r.setIgnoreMissingFLIClasses(ignoreMissingFLIClasses);
if (useFifoSemantics) {
r.setScheduableTasksFilter(new ScheduableTasksFilterFifo());
}
r.terminateOnException(terminateOnException);
boolean useOurScheduling = addSchedulingStrategy(debuggerArgsTotalScheduler, r);
final boolean useOurSystemObserver = addSystemObservers(debuggerArgsSystemObserver, r);
if (debuggerArgsRandomSeed != null && !debuggerArgsRandomSeed.isEmpty()) {
String seedString = debuggerArgsRandomSeed.replace("-Dabs.randomseed=", "");
Long seedNumber = getSeed(seedString);
r.setRandomSeed(seedNumber);
}
final ThreadGroup tg = new ThreadGroup("ABS " + mainClassName);
tg.setDaemon(true);
final Thread debuggerRunner = new Thread(tg, new Runnable() {
@Override
public void run() {
try {
if (DO_DEBUG) {
System.out.println("Start ABSRuntime .. ");
System.out.println("path: " + genPath.toString());
System.out.println("name:" + mainClassName);
}
r.start(genPath.toFile(), mainClassName);
} catch (ClassNotFoundException e) {
exceptionHandling(e);
} catch (InstantiationException e) {
exceptionHandling(e);
} catch (IllegalAccessException e) {
exceptionHandling(e);
}
}
private void exceptionHandling(final Exception e) {
standardExceptionHandling(e);
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
showErrorMessage("Not able to start ABSRuntime.\n" + e.getMessage());
}
});
}
});
if (useOurScheduling) {
enableHightlighting();
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
try {
PlatformUI.getWorkbench().showPerspective(ABSDEBUGPERSPECTIVE_ID, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
getDebugger().initDebugger(projectName, r, debuggerRunner, useOurSystemObserver);
if (DebugUtils.getRunAutomatically()) {
DebugUtils.getSchedulerRef().resumeAutomaticScheduling();
}
} catch (WorkbenchException e) {
standardExceptionHandling(e);
showErrorMessage("Could not open ABS debug perspective");
}
}
});
} else {
debuggerRunner.start();
}
}
use of org.eclipse.ui.WorkbenchException in project hale by halestudio.
the class ShowLayoutMenuHandler method execute.
/**
* @see IHandler#execute(ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IViewPart viewPart = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().findView(StyledMapView.ID);
if (viewPart instanceof MapView) {
// view visible - show layout menu
final MenuManager manager = new MenuManager();
manager.setRemoveAllWhenShown(true);
final IconPainterLayoutContribution contribution = new IconPainterLayoutContribution();
manager.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
// populate context menu
manager.add(contribution);
}
});
Shell shell = HandlerUtil.getActiveShell(event);
final Menu menu = manager.createContextMenu(shell);
// determine location
Point cursorLocation = Display.getCurrent().getCursorLocation();
// default to cursor location
Point location = cursorLocation;
// try to determine from control
Control cursorControl = Display.getCurrent().getCursorControl();
if (cursorControl != null) {
if (cursorControl instanceof ToolBar) {
ToolBar bar = (ToolBar) cursorControl;
ToolItem item = bar.getItem(bar.toControl(cursorLocation));
if (item != null) {
Rectangle bounds = item.getBounds();
location = bar.toDisplay(bounds.x, bounds.y + bounds.height);
}
} else {
// show below control
location = cursorControl.toDisplay(0, cursorControl.getSize().y);
}
}
menu.setLocation(location);
menu.addMenuListener(new MenuListener() {
@Override
public void menuShown(MenuEvent e) {
// do nothing
}
@Override
public void menuHidden(MenuEvent e) {
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
/*
* Dispose everything as it is used only once. Done
* asynchronously as otherwise we interfere with the
* menu click handling.
*/
manager.dispose();
contribution.dispose();
menu.dispose();
}
});
}
});
// show menu
menu.setVisible(true);
} else {
// view not visible - just show map perspective
try {
PlatformUI.getWorkbench().showPerspective(StyledMapPerspective.ID, HandlerUtil.getActiveWorkbenchWindow(event));
} catch (WorkbenchException e) {
log.error("Could not open map perspective", e);
}
}
return null;
}
Aggregations