Java Code Examples for org.eclipse.ui.PartInitException

The following are top voted examples for showing how to use org.eclipse.ui.PartInitException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: pgcodekeeper   File: ProjectEditorDiffer.java   View source code 7 votes vote down vote up
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    if (!(input instanceof ProjectEditorInput)) {
        throw new PartInitException(Messages.ProjectEditorDiffer_error_bad_input_type);
    }

    ProjectEditorInput in = (ProjectEditorInput) input;
    Exception ex = in.getError();
    if (ex != null) {
        throw new PartInitException(in.getError().getLocalizedMessage(), ex);
    }

    setInput(input);
    setSite(site);
    setPartName(in.getName());

    proj = new PgDbProject(in.getProject());
    sp = new ProjectEditorSelectionProvider(proj.getProject());

    // message box
    if(!site.getPage().getPerspective().getId().equals(PERSPECTIVE.MAIN)){
        askPerspectiveChange(site);
    }
    getSite().setSelectionProvider(sp);
}
 
Example 2
Project: n4js   File: AbstractOutlineWorkbenchTest.java   View source code 6 votes vote down vote up
protected void openOutlineView() throws PartInitException, InterruptedException {
	outlineView = editor.getEditorSite().getPage().showView("org.eclipse.ui.views.ContentOutline");
	executeAsyncDisplayJobs();
	Object adapter = editor.getAdapter(IContentOutlinePage.class);
	assertTrue(adapter instanceof OutlinePage);
	outlinePage = new SyncableOutlinePage((OutlinePage) adapter);
	outlinePage.resetSyncer();
	try {
		outlinePage.waitForUpdate(EXPECTED_TIMEOUT);
	} catch (TimeoutException e) {
		System.out.println("Expected timeout exceeded: " + EXPECTED_TIMEOUT);// timeout is OK here
	}
	treeViewer = outlinePage.getTreeViewer();
	assertSelected(treeViewer);
	assertExpanded(treeViewer);
	assertTrue(treeViewer.getInput() instanceof IOutlineNode);
	IOutlineNode rootNode = (IOutlineNode) treeViewer.getInput();
	List<IOutlineNode> children = rootNode.getChildren();
	assertEquals(1, children.size());
	modelNode = children.get(0);
}
 
Example 3
Project: convertigo-eclipse   File: SequenceTreeObject.java   View source code 6 votes vote down vote up
public void openXMLSequenceEditor(IProject project) {
	Sequence sequence = getObject();
	
	IFile	file = project.getFile("_private/"+sequence.getName()+".xml");
	
	
	IWorkbenchPage activePage = PlatformUI
									.getWorkbench()
									.getActiveWorkbenchWindow()
									.getActivePage();
	if (activePage != null) {
		try {
			activePage.openEditor(new XMLSequenceEditorInput(file,sequence),
									"com.twinsoft.convertigo.eclipse.editors.xml.XMLSequenceEditor");
		}
		catch(PartInitException e) {
			ConvertigoPlugin.logException(e, "Error while loading the step editor '" + sequence.getName() + "'");
		} 
	}
}
 
Example 4
Project: Hydrograph   File: ELTOpenFileEditorListener.java   View source code 6 votes vote down vote up
private void openInbuiltOperationClass(String operationName, PropertyDialogButtonBar propertyDialogButtonBar) {
	String operationClassName = null;
	Operations operations = XMLConfigUtil.INSTANCE.getComponent(FilterOperationClassUtility.INSTANCE.getComponentName())
			.getOperations();
	List<TypeInfo> typeInfos = operations.getStdOperation();
	for (int i = 0; i < typeInfos.size(); i++) {
		if (typeInfos.get(i).getName().equalsIgnoreCase(operationName)) {
			operationClassName = typeInfos.get(i).getClazz();
			break;
		}
	}
	propertyDialogButtonBar.enableApplyButton(true);
	javaProject = FilterOperationClassUtility.getIJavaProject();
	if (javaProject != null) {
		try {
			IType findType = javaProject.findType(operationClassName);
			JavaUI.openInEditor(findType);
		} catch (JavaModelException | PartInitException e) {
			Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,Messages.CLASS_NOT_EXIST,null);
			StatusManager.getManager().handle(status, StatusManager.BLOCK);
			logger.error(e.getMessage(), e);
		}
	} else {
		WidgetUtility.errorMessage(Messages.SAVE_JOB_MESSAGE);
	}
}
 
Example 5
Project: n4js   File: N4IDEXpectRunListener.java   View source code 6 votes vote down vote up
/**
 * Called when all tests have finished
 *
 * @param result
 *            the summary of the test run, including all the tests that failed
 */
@Override
public void testRunFinished(Result result) throws Exception {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {

			IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
			try {
				N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
						N4IDEXpectView.ID);
				view.notifySessionFinished();
			} catch (PartInitException e) {
				N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
			}
		}
	});
}
 
Example 6
Project: n4js   File: N4IDEXpectRunListener.java   View source code 6 votes vote down vote up
/**
 * Called when an atomic test has finished, whether the test succeeds or fails.
 *
 * @param description
 *            the description of the test that just ran
 */
@Override
public void testFinished(Description description) throws Exception {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {

			IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
			try {
				N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
						N4IDEXpectView.ID);
				view.notifyFinishedExecutionOf(description);
			} catch (PartInitException e) {
				N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
			}
		}
	});
}
 
Example 7
Project: convertigo-eclipse   File: TransactionTreeObject.java   View source code 6 votes vote down vote up
public void openXMLTransactionEditor(IProject project) {
	Transaction transaction = (Transaction)this.getObject();
	
	IFile	file = project.getFile("_private/"+transaction.getName()+".xml");
	
	
	IWorkbenchPage activePage = PlatformUI
									.getWorkbench()
									.getActiveWorkbenchWindow()
									.getActivePage();
	if (activePage != null) {
		try {
			activePage.openEditor(new XMLTransactionEditorInput(file,transaction),
									"com.twinsoft.convertigo.eclipse.editors.xml.XMLTransactionEditor");
		} catch(PartInitException e) {
			ConvertigoPlugin.logException(e, "Error while loading the transaction editor '" + transaction.getName() + "'");
		} 
	}
}
 
Example 8
Project: n4js   File: XpectCompareCommandHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

	IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
	try {
		view = (N4IDEXpectView) windows[0].getActivePage().showView(
				N4IDEXpectView.ID);
	} catch (PartInitException e) {
		N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
	}

	Description desc = (Description) selection.getFirstElement();
	if (desc.isTest() && view.testsExecutionStatus.hasFailed(desc)) {
		Throwable failureException = view.testsExecutionStatus.getFailure(desc).getException();

		if (failureException instanceof ComparisonFailure) {
			ComparisonFailure cf = (ComparisonFailure) failureException;
			// display comparison view
			displayComparisonView(cf, desc);
		}
	}
	return null;
}
 
Example 9
Project: convertigo-eclipse   File: MyAbstractAction.java   View source code 6 votes vote down vote up
public IEditorPart getConnectorEditor(Connector connector) {
	IEditorPart editorPart = null;
	IWorkbenchPage activePage = getActivePage();
	if (activePage != null) {
		if (connector != null) {
			IEditorReference[] editorRefs = activePage.getEditorReferences();
			for (int i=0;i<editorRefs.length;i++) {
				IEditorReference editorRef = (IEditorReference)editorRefs[i];
				try {
					IEditorInput editorInput = editorRef.getEditorInput();
					if ((editorInput != null) && (editorInput instanceof ConnectorEditorInput)) {
						if (((ConnectorEditorInput)editorInput).is(connector)) {
							editorPart = editorRef.getEditor(false);
							break;
						}
					}
				}
				catch(PartInitException e) {
					//ConvertigoPlugin.logException(e, "Error while retrieving the connector editor '" + editorRef.getName() + "'");
				}
			}
		}
	}
	return editorPart;
}
 
Example 10
Project: gw4e.project   File: GW4EEditor.java   View source code 6 votes vote down vote up
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	super.init(site, input);
	setSite(site);
	setPartName(input.getName());
	setInputWithNotify(input);
	site.setSelectionProvider(this);
	if (getEditorInput() instanceof FileEditorInput) {
		FileEditorInput fei = (FileEditorInput) getEditorInput();
		IFile file = fei.getFile();
		gWGraph = ResourceManager.load(file);
		Display.getDefault().asyncExec(new Runnable() {
			@Override
			public void run() {
				gWGraph.initialize(getGraphicalViewer().getEditPartRegistry());
				if (!ResourceManager.isEditable(file)) {
					gWGraph.setReadOnly(true);
					getGraphicalViewer().getControl().setEnabled(false);
					String title = MessageUtil.getString("conversion");
					String message = MessageUtil.getString("not_formatted_as_json_convert_it");
					DialogManager.displayWarning(title, message);
				}
			}
		});
	}

}
 
Example 11
Project: pgcodekeeper   File: NavigatorOutlineActionProvider.java   View source code 6 votes vote down vote up
@Override
public void run() {
    if (isEnabled()) {
        try {
            ITextEditor editor = (ITextEditor) IDE.openEditor(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
                    segment.getParentFile(), EDITOR.SQL, true);
            editor.setHighlightRange(segment.offset, segment.length, true);
            editor.selectAndReveal(segment.offset, segment.length);
        } catch (PartInitException e) {
            Log.log(e);
            ExceptionNotifier.notifyDefault(Messages.PgNavigatorActionProvider_failed_to_open_editor, e);
        }
    }
}
 
Example 12
Project: convertigo-eclipse   File: ConvertigoPlugin.java   View source code 6 votes vote down vote up
public IEditorPart getApplicationComponentEditor() {
	IEditorPart editorPart = null;
	IWorkbenchPage activePage = getActivePage();
	if (activePage != null) {
		IEditorReference[] editorRefs = activePage.getEditorReferences();
		for (int i=0;i<editorRefs.length;i++) {
			IEditorReference editorRef = (IEditorReference)editorRefs[i];
			try {
				IEditorInput editorInput = editorRef.getEditorInput();
				if ((editorInput != null) && (editorInput instanceof ApplicationComponentEditorInput)) {
					editorPart = editorRef.getEditor(false);
					break;
				}
			}
			catch(PartInitException e) {
				//ConvertigoPlugin.logException(e, "Error while retrieving the connector editor '" + editorRef.getName() + "'");
			}
		}
	}
	return editorPart;
}
 
Example 13
Project: gw4e.project   File: ResourceManagerTest.java   View source code 6 votes vote down vote up
@Test
public void testCloseEditor() throws Exception {
	
	IJavaProject project = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, true, true);
	IFile impl = (IFile) ResourceManager
			.getResource(project.getProject().getFullPath().append("src/test/java/SimpleImpl.java").toString());
	Display.getDefault().syncExec(() -> {
		try {
			IWorkbenchWindow iww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
			ResourceManager.closeEditor(impl, iww);
		} catch (PartInitException e) {
			ResourceManager.logException(e);
		}});
	 
	Waiter.waitUntil(new EditorClosedCondition("SimpleImpl.java"));
}
 
Example 14
Project: Tarski   File: MarkUtilities.java   View source code 6 votes vote down vote up
public static void focusMarker(final IMarker marker) {
  Display.getDefault().syncExec(new Runnable() {

    @Override
    public void run() {
      try {
        IDE.openEditor(
            MarkerActivator.getDefault().getWorkbench().getWorkbenchWindows()[0].getActivePage(),
            marker);
      } catch (final PartInitException e1) {

        e1.printStackTrace();
      }
    }
  });
}
 
Example 15
Project: Tarski   File: MarkerFactory.java   View source code 6 votes vote down vote up
/**
 * Note: it compares marker's resource file name and open editors' file name.
 *
 * @param marker
 * @return if marker's editor is open, return editor, else return null
 */
public static IEditorPart getOpenEditorOfMarker(final IMarker marker) {
  final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
  for (final IWorkbenchWindow iWorkbenchWindow : windows) {
    final IWorkbenchPage[] pages = iWorkbenchWindow.getPages();
    for (final IWorkbenchPage iWorkbenchPage : pages) {
      final IEditorReference[] editors = iWorkbenchPage.getEditorReferences();
      for (final IEditorReference iEditorReference : editors) {
        try {
          if (iEditorReference instanceof IFileEditorInput) {
            final IFileEditorInput input = (IFileEditorInput) iEditorReference.getEditorInput();
            final IFile file = input.getFile();
            // TODO Caused by: java.lang.NullPointerException when delete marker on ecore editor.
            if (file.getFullPath().equals(marker.getResource().getFullPath())) {
              return iEditorReference.getEditor(false);
            }
          }
        } catch (final PartInitException e) {
          e.printStackTrace();
        }
      }
    }
  }
  return null;
}
 
Example 16
Project: convertigo-eclipse   File: XslRuleEditor.java   View source code 6 votes vote down vote up
/**
 * This method initializes the Xsl Source Editor
 * 
 */
private void createXslSourceEditor() {
	GridData gridData = new org.eclipse.swt.layout.GridData();
	gridData.horizontalSpan = 2;
	gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	gridData.grabExcessVerticalSpace = true;
	gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
	
	try {
		xmlEditor.init(eSite, eInput);
		xmlEditor.setInitializationData(getConfigurationElement(), null, null);
	} catch (PartInitException e) {
		ConvertigoPlugin.logException(e, "Error inialiazing XSL editor '" + eInput.getName() + "'");
	}
	
	xmlEditor.createPartControl(sashForm);
	
	/* see #2299 */
	//Control childs[] = sashForm.getChildren();
	//childs[1].setLayoutData(gridData);
	
}
 
Example 17
Project: gemoc-studio   File: OpenEditor.java   View source code 6 votes vote down vote up
public static void openFile(File file) {
	if (file.exists() && file.isFile()) {
		IFileStore fileStore = EFS.getLocalFileSystem().getStore(
				file.toURI());
		IWorkbenchPage page = PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow().getActivePage();

		try {
			IDE.openEditorOnFileStore(page, fileStore);
		} catch (PartInitException e) {
			// Put your exception handler here if you wish to
		}
	} else {
		// Do something if the file does not exist
	}
}
 
Example 18
Project: convertigo-eclipse   File: ProjectTreeObject.java   View source code 6 votes vote down vote up
public void openConnectorEditor(Connector connector) {
	IWorkbenchPage activePage = PlatformUI
									.getWorkbench()
									.getActiveWorkbenchWindow()
									.getActivePage();
	if (activePage != null) {
		if (connector != null) {
			try {
				activePage.openEditor(new ConnectorEditorInput(connector),
						"com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor");
			}
			catch(PartInitException e) {
				ConvertigoPlugin.logException(e, "Error while loading the connector editor '" + connector.getName() + "'");
			}
		}
	}
}
 
Example 19
Project: convertigo-eclipse   File: SheetTreeObject.java   View source code 6 votes vote down vote up
public void openXslEditor(IProject project) {
	Sheet sheet = getObject();
	String projectName = sheet.getProject().getName();
	String parentStyleSheet = sheet.getUrl();
	Path filePath = new Path(sheet.getUrl());
	IFile file = project.getFile(filePath);
	
	IWorkbenchPage activePage = PlatformUI
									.getWorkbench()
									.getActiveWorkbenchWindow()
									.getActivePage();
	if (activePage != null) {
		try {
			activePage.openEditor(new XslFileEditorInput(file, projectName, sheet),
					"com.twinsoft.convertigo.eclipse.editors.xsl.XslRuleEditor");
		}
		catch(PartInitException e) {
			ConvertigoPlugin.logException(e, "Error while loading the xsl editor '" + parentStyleSheet + "'");
		}
	}
}
 
Example 20
Project: convertigo-eclipse   File: ConvertigoPlugin.java   View source code 6 votes vote down vote up
/**
 * Gets the jscript editor associated with given transaction.
 * !!MUST BE CALLED IN A UI-THREAD!!
 * @return IEditorPart : the found jscript editor or null
 */
public IEditorPart getJscriptTransactionEditor(Transaction transaction) {
	IEditorPart editorPart = null;
	IWorkbenchPage activePage = getActivePage();
	if (activePage != null) {
		if (transaction != null) {
			IEditorReference[] editorRefs = activePage.getEditorReferences();
			for (int i=0;i<editorRefs.length;i++) {
				IEditorReference editorRef = (IEditorReference)editorRefs[i];
				try {
					IEditorInput editorInput = editorRef.getEditorInput();
					if ((editorInput != null) && (editorInput instanceof JscriptTransactionEditorInput)) {
						if (((JscriptTransactionEditorInput)editorInput).transaction.equals(transaction)) {
							editorPart = editorRef.getEditor(false);
							break;
						}
					}
				}
				catch(PartInitException e) {
					//ConvertigoPlugin.logException(e, "Error while retrieving the jscript transaction editor '" + editorRef.getName() + "'");
				}
			}
		}
	}
	return editorPart;
}
 
Example 21
Project: convertigo-eclipse   File: ConvertigoPlugin.java   View source code 6 votes vote down vote up
/**
 * Gets the source picker view.
 * !!MUST BE CALLED IN A UI-THREAD!!
 * @return SourcePickerView : the source picker view of Convertigo Plugin
 * @throws  
 */
public MobileDebugView getMobileDebugView() {
	MobileDebugView mobileDebugView = null;
	try {
		IWorkbenchPage activePage = getActivePage();
		if (activePage != null) {
			IViewPart viewPart =  activePage.findView("com.twinsoft.convertigo.eclipse.views.mobile.MobileDebugView");
			if (viewPart != null)
				mobileDebugView = (MobileDebugView) viewPart;
		}
		if (mobileDebugView == null) {
			mobileDebugView = (MobileDebugView) getActivePage().showView("com.twinsoft.convertigo.eclipse.views.mobile.MobileDebugView");
		}
	} catch (PartInitException e) {
		logException(e, "Failed to get the MobileDebugView");
	}
	return mobileDebugView;
}
 
Example 22
Project: convertigo-eclipse   File: ProjectTreeObject.java   View source code 6 votes vote down vote up
public void closeSequenceEditors(Sequence sequence) {
	IWorkbenchPage activePage = PlatformUI
									.getWorkbench()
									.getActiveWorkbenchWindow()
									.getActivePage();
	if (activePage != null) {
		if (sequence != null) {
			IEditorReference[] editorRefs = activePage.getEditorReferences();
			for (int i=0;i<editorRefs.length;i++) {
				IEditorReference editorRef = (IEditorReference)editorRefs[i];
				try {
					IEditorInput editorInput = editorRef.getEditorInput();
					if ((editorInput != null) && (editorInput instanceof SequenceEditorInput)) {
						if (((SequenceEditorInput)editorInput).is(sequence)) {
							activePage.closeEditor(editorRef.getEditor(false),true);
							break;
						}
					}
				}
				catch(PartInitException e) {
					ConvertigoPlugin.logException(e, "Error while retrieving the sequence editor '" + editorRef.getName() + "'");
				}
			}
		}
	}
}
 
Example 23
Project: neoscada   File: OpenSignalGenerator.java   View source code 6 votes vote down vote up
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    for ( final Item item : getItems () )
    {
        GeneratorView view;
        try
        {
            view = (GeneratorView)getActivePage ().showView ( GeneratorView.VIEW_ID, asSecondardId ( item ), IWorkbenchPage.VIEW_ACTIVATE );
        }
        catch ( final PartInitException e )
        {
            throw new ExecutionException ( "Failed to open view", e );
        }
        view.setDataItem ( item );
    }

    return null;
}
 
Example 24
Project: neoscada   File: AbstractItemAction.java   View source code 6 votes vote down vote up
@Override
public void run ( final IAction action )
{
    final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, this.message, null );
    for ( final Item item : this.items )
    {
        try
        {
            processItem ( item );
        }
        catch ( final PartInitException e )
        {
            status.add ( e.getStatus () );
        }
    }
    if ( !status.isOK () )
    {
        showError ( status );
    }
}
 
Example 25
Project: neoscada   File: AbstractAlarmsEventsView.java   View source code 6 votes vote down vote up
@Override
public void init ( final IViewSite site, final IMemento memento ) throws PartInitException
{
    if ( memento != null )
    {
        this.connectionId = memento.getString ( CONNECTION_ID );
        this.connectionUri = memento.getString ( CONNECTION_URI );
    }

    super.init ( site, memento );
    try
    {
        // it is OK to fail at this stage
        reInitializeConnection ( this.connectionId, this.connectionUri );
    }
    catch ( final Exception e )
    {
        logger.warn ( "init () - couldn't recreate connection", e ); //$NON-NLS-1$
        // just reset all values
        this.connectionId = null;
        this.connectionUri = null;
        this.connectionService = null;
        this.connectionTracker = null;
    }
}
 
Example 26
Project: convertigo-eclipse   File: ApplicationComponentEditor.java   View source code 6 votes vote down vote up
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	setSite(site);
	setInput(input);
	
	applicationEditorInput = (ApplicationComponentEditorInput) input;
	ApplicationComponent application = applicationEditorInput.application;
	Project project = application.getProject();

	datasetDir = new File(project.getDirPath() + "/dataset");
	datasetDir.mkdirs();
	
	devicePref = new File(Engine.USER_WORKSPACE_PATH, "studio/device-" + project.getName() + ".json");
	
	setPartName(project.getName() + " [A: " + application.getName() + "]");
	terminateNode();
}
 
Example 27
Project: neoscada   File: AlarmNotifier.java   View source code 6 votes vote down vote up
private void triggerMainCommand ()
{
    try
    {
        if ( numberOfAckAlarms () > 0 )
        {
            executeCommand ( this.ackAlarmsAvailableCommand );
        }
        else
        {
            executeCommand ( this.alarmsAvailableCommand );
        }
    }
    catch ( final PartInitException ex )
    {
        throw new RuntimeException ( ex );
    }
}
 
Example 28
Project: neoscada   File: EditorHelper.java   View source code 6 votes vote down vote up
public static void handleOpen ( final IWorkbenchPage page, final ISelection selection )
{
    final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, "Open editor", null );

    final IEditorInput[] inputs = EditorHelper.createInput ( selection );

    for ( final IEditorInput input : inputs )
    {
        try
        {
            if ( input instanceof ConfigurationEditorInput )
            {
                page.openEditor ( input, MultiConfigurationEditor.EDITOR_ID, true );
            }
            else if ( input instanceof FactoryEditorInput )
            {
                page.openEditor ( input, FactoryEditor.EDITOR_ID, true );
            }
        }
        catch ( final PartInitException e )
        {
            status.add ( e.getStatus () );
        }
    }
}
 
Example 29
Project: eclipse-bash-editor   File: OpenWithBashEditor.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IFile file = getSelectedFile();
	if (file==null){
		return null;
	}
	IWorkbenchPage page = EclipseUtil.getActivePage();
	if (page==null){
		return null;
	}
	try {
		page.openEditor(new FileEditorInput(file), BashEditor.EDITOR_ID);
	} catch (PartInitException e) {
		throw new ExecutionException("Was not able to open bash editor for file:"+file.getName(),e);
	}
	return null;
}
 
Example 30
Project: convertigo-eclipse   File: ConnectorTreeObject.java   View source code 6 votes vote down vote up
private IEditorPart getConnectorEditor(IWorkbenchPage activePage, Connector connector) {
	IEditorPart editorPart = null;
	if (activePage != null) {
		if (connector != null) {
			IEditorReference[] editorRefs = activePage.getEditorReferences();
			for (int i=0;i<editorRefs.length;i++) {
				IEditorReference editorRef = (IEditorReference)editorRefs[i];
				try {
					IEditorInput editorInput = editorRef.getEditorInput();
					if ((editorInput != null) && (editorInput instanceof ConnectorEditorInput)) {
						if (((ConnectorEditorInput)editorInput).is(connector)) {
							editorPart = editorRef.getEditor(false);
							break;
						}
					}
				}
				catch(PartInitException e) {
					//ConvertigoPlugin.logException(e, "Error while retrieving the connector editor '" + editorRef.getName() + "'");
				}
			}
		}
	}
	return editorPart;
}
 
Example 31
Project: solidity-ide   File: NewFileWizard.java   View source code 6 votes vote down vote up
@Override
public boolean performFinish() {
	IFile file = mainPage.createNewFile();
	if (file == null) {
		return false;
	}

	selectAndReveal(file);

	// Open editor on new file.
	IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
	try {
		if (dw != null) {
			IWorkbenchPage page = dw.getActivePage();
			if (page != null) {
				IDE.openEditor(page, file, true);
			}
		}
	} catch (PartInitException e) {
		openError(dw.getShell(), "Problems opening editor", e.getMessage(), e);
	}

	return true;
}
 
Example 32
Project: convertigo-eclipse   File: ConnectorTreeObject.java   View source code 6 votes vote down vote up
public void openConnectorEditor() {
	Connector connector = getObject();
	synchronized (connector) {
		IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		if (activePage != null) {
			IEditorPart editorPart = getConnectorEditor(activePage, connector);
			
			if (editorPart != null)
				activePage.activate(editorPart);
			else {
				try {
					editorPart = activePage.openEditor(new ConnectorEditorInput(connector),
									"com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor");
				} catch (PartInitException e) {
					ConvertigoPlugin.logException(e,
							"Error while loading the connector editor '"
									+ connector.getName() + "'");
				}
			}
		}
	}
}
 
Example 33
Project: n4js   File: AbstractPluginUITest.java   View source code 5 votes vote down vote up
/**
 * Shows then returns with the view with the given unique view part identifier. May return with {@code null} if the
 * view cannot be found.
 *
 * @param id
 *            the unique ID of the view part to show.
 * @return the view part or {@code null} if the view part cannot be shown.
 */
protected IViewPart showView(final String id) {
	try {
		return getPage().showView(checkNotNull(id, "id"));
	} catch (final PartInitException e) {
		final String message = "Error occurred while initializing view with ID: '" + id + "'.";
		LOGGER.error(message, e);
		throw new RuntimeException(message, e);
	}
}
 
Example 34
Project: solidity-ide   File: OpenURLWithExternalBrowserAction.java   View source code 5 votes vote down vote up
@Override
public void run(IIntroSite site, Properties params) {

	try {
		PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser()
				.openURL(new URL(params.getProperty("url")));
	} catch (PartInitException | MalformedURLException e) {
		e.printStackTrace();
	}
}
 
Example 35
Project: time4sys   File: ConstraintsActionBarContributor.java   View source code 5 votes vote down vote up
@Override
public void run() {
	try {
		getPage().showView("org.eclipse.ui.views.PropertySheet");
	}
	catch (PartInitException exception) {
		ConstraintsEditorPlugin.INSTANCE.log(exception);
	}
}
 
Example 36
Project: OCCI-Studio   File: OCCIActionBarContributor.java   View source code 5 votes vote down vote up
@Override
public void run() {
	try {
		getPage().showView("org.eclipse.ui.views.PropertySheet");
	}
	catch (PartInitException exception) {
		OCCIEditorPlugin.INSTANCE.log(exception);
	}
}
 
Example 37
Project: Open_Source_ECOA_Toolset_AS5   File: ServicesEditor.java   View source code 5 votes vote down vote up
/**
 * Creates page 0 of the multi-page editor, which contains a text editor.
 */
void createPage0() {
	try {
		editor = new TextEditor();
		int index = addPage(editor, getEditorInput());
		setPageText(index, "XML");
		setPartName(((FileEditorInput) editor.getEditorInput()).getFile().getName());
	} catch (PartInitException e) {
		ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus());
	}
}
 
Example 38
Project: n4js   File: OpenGeneratedSourceInEditorHandler.java   View source code 5 votes vote down vote up
private void tryOpenFileInEditor(final IFile file, final IFile generatedFile) {
	final IEditorDescriptor desc = getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
	if (null != desc) {
		final IWorkbenchPage page = getWorkbench().getActiveWorkbenchWindow().getActivePage();
		try {
			page.openEditor(new FileEditorInput(generatedFile), desc.getId());
		} catch (final PartInitException e) {
			throw new RuntimeException("Error while trying to open generated JS file for " + file, e);
		}
	}
}
 
Example 39
Project: ContentAssist   File: JCompilationUnitEditor.java   View source code 5 votes vote down vote up
/**
 * Records the file open operation when the editor is instantiated.
 * @param site the editor site
 * @param input the editor input
 * @exception PartInitException if this editor was not initialized successfully
 */
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    super.init(site, input);
    
    if (historyManager == null) {
        historyManager = HistoryManager.getInstance();
        historyManager.start(this);
        
        historyManager.recordFileOpenOperation(getInputFile(), getSourceCode());
    }
}
 
Example 40
Project: Open_Source_ECOA_Toolset_AS5   File: AppAbstractEditPart.java   View source code 5 votes vote down vote up
@Override
public void performRequest(Request req) {
	if (req.getType().equals(RequestConstants.REQ_OPEN)) {
		try {
			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
			page.showView(IPageLayout.ID_PROP_SHEET);
		} catch (PartInitException e) {
			e.printStackTrace();
		}
	}
}