org.eclipse.ui.PlatformUI Java Examples

The following examples show how to use org.eclipse.ui.PlatformUI. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: EditorUtility.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns an array of all editors that have an unsaved content. If the identical content is
 * presented in more than one editor, only one of those editor parts is part of the result.
 * @param skipNonResourceEditors if <code>true</code>, editors whose inputs do not adapt to {@link IResource}
 * are not saved
 *
 * @return an array of dirty editor parts
 * @since 3.4
 */
public static IEditorPart[] getDirtyEditors(boolean skipNonResourceEditors) {
	Set<IEditorInput> inputs= new HashSet<IEditorInput>();
	List<IEditorPart> result= new ArrayList<IEditorPart>(0);
	IWorkbench workbench= PlatformUI.getWorkbench();
	IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
	for (int i= 0; i < windows.length; i++) {
		IWorkbenchPage[] pages= windows[i].getPages();
		for (int x= 0; x < pages.length; x++) {
			IEditorPart[] editors= pages[x].getDirtyEditors();
			for (int z= 0; z < editors.length; z++) {
				IEditorPart ep= editors[z];
				IEditorInput input= ep.getEditorInput();
				if (inputs.add(input)) {
					if (!skipNonResourceEditors || isResourceEditorInput(input)) {
						result.add(ep);
					}
				}
			}
		}
	}
	return result.toArray(new IEditorPart[result.size()]);
}
 
Example #2
Source Project: APICloud-Studio   Author: apicloudcom   File: WorkspaceAction.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Most SVN workspace actions modify the workspace and thus should
 * save dirty editors.
 * @see org.tigris.subversion.subclipse.ui.actions.SVNAction#needsToSaveDirtyEditors()
 */
protected boolean needsToSaveDirtyEditors() {

	IResource[] selectedResources = getSelectedResources();
	if (selectedResources != null && selectedResources.length > 0) {
		IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
		for (IEditorReference editorReference : editorReferences) {
			if (editorReference.isDirty()) {
				try {
					IEditorInput editorInput = editorReference.getEditorInput();
					if (editorInput instanceof IFileEditorInput) {
						IFile file = ((IFileEditorInput)editorInput).getFile();
						if (needsToSave(file, selectedResources)) {
							return true;
						}
					}
				} catch (PartInitException e) {}
			}
		}
	}
	
	return false;
}
 
Example #3
Source Project: eclipse-wakatime   Author: wakatime   File: WakaTime.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static String getActiveProject() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window == null) return null;
    if (window.getPartService() == null) return null;
    if (window.getPartService().getActivePart() == null) return null;
    if (window.getPartService().getActivePart().getSite() == null) return null;
    if (window.getPartService().getActivePart().getSite().getPage() == null) return null;
    if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor() == null) return null;
    if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput() == null) return null;

    IEditorInput input = window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput();

    IProject project = null;

    if (input instanceof FileEditorInput) {
        project = ((FileEditorInput)input).getFile().getProject();
    }

    if (project == null)
        return null;

    return project.getName();
}
 
Example #4
Source Project: bonita-studio   Author: bonitasoft   File: ProcessDiagramUpdateCommand.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
			.getSelection();
	if (selection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		if (structuredSelection.size() != 1) {
			return null;
		}
		if (structuredSelection.getFirstElement() instanceof EditPart
				&& ((EditPart) structuredSelection.getFirstElement()).getModel() instanceof View) {
			EObject modelElement = ((View) ((EditPart) structuredSelection.getFirstElement()).getModel())
					.getElement();
			List editPolicies = CanonicalEditPolicy.getRegisteredEditPolicies(modelElement);
			for (Iterator it = editPolicies.iterator(); it.hasNext();) {
				CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it.next();
				nextEditPolicy.refresh();
			}

		}
	}
	return null;
}
 
Example #5
Source Project: eip-designer   Author: lbroudoux   File: RouteTreeLabelProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Image getImage(Object element) {
   if (element instanceof IProject) {
      return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT);
   }
   if (element instanceof IResource) {
      return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
   }
   if (element instanceof Route) {
      Bundle bundle = FrameworkUtil.getBundle(RouteTreeLabelProvider.class);
      URL url = FileLocator.find(bundle, new Path("icons/obj16/Route.gif"), null);
      ImageDescriptor imageDcr = ImageDescriptor.createFromURL(url);
      return imageDcr.createImage();
   }
   return null;
}
 
Example #6
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: LayoutActionGroup.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public LayoutAction(PackageExplorerPart packageExplorer, boolean flat) {
	super("", AS_RADIO_BUTTON); //$NON-NLS-1$

	fIsFlatLayout= flat;
	fPackageExplorer= packageExplorer;
	if (fIsFlatLayout) {
		setText(PackagesMessages.LayoutActionGroup_flatLayoutAction_label);
		JavaPluginImages.setLocalImageDescriptors(this, "flatLayout.gif"); //$NON-NLS-1$
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_FLAT_ACTION);
	} else {
		setText(PackagesMessages.LayoutActionGroup_hierarchicalLayoutAction_label);
		JavaPluginImages.setLocalImageDescriptors(this, "hierarchicalLayout.gif"); //$NON-NLS-1$
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_HIERARCHICAL_ACTION);
	}
	setChecked(packageExplorer.isFlatLayout() == fIsFlatLayout);
}
 
Example #7
Source Project: statecharts   Author: Yakindu   File: CreateSubdiagramCommand.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean isEnabled() {
	IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (activeWorkbenchWindow == null)
		return false;
	ISelection selection = activeWorkbenchWindow.getActivePage().getSelection();
	if (selection == null)
		return false;
	Node unwrap = unwrap(selection);
	if (unwrap == null) {
		return false;
	}
	State state = (State) unwrap.getElement();
	if (state==null || state.isComposite())
		return false;
	BooleanValueStyle inlineStyle = DiagramPartitioningUtil.getInlineStyle(unwrap);
	if (inlineStyle != null && !inlineStyle.isBooleanValue())
		return false;
	return super.isEnabled();
}
 
Example #8
Source Project: tmxeditor8   Author: heartsome   File: XLIFFEditor.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 启动编辑器。
 * 
 * @param site
 *            the site
 * @param input
 *            the input
 * @throws PartInitException
 *             the part init exception
 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
 *      org.eclipse.ui.IEditorInput)
 */
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("init(IEditorSite site, IEditorInput input)");
	}
	setSite(site);
	setInput(input);
	// 设置Editor标题栏的显示名称,否则名称用plugin.xml中的name属性
	setPartName(input.getName());

	Image oldTitleImage = titleImage;
	if (input != null) {
		IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
		IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
		ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
		titleImage = imageDesc != null ? imageDesc.createImage() : null;
	}

	setTitleImage(titleImage);
	if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
		oldTitleImage.dispose();
	}

	getSite().setSelectionProvider(this);
}
 
Example #9
Source Project: xds-ide   Author: excelsior-oss   File: XFindPanel.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected ToolItem createClose(final ToolBar bar) {
    final ToolItem close = new ToolItem(bar, SWT.PUSH);
    final ImageDescriptor image = PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE);
    if (image != null)
        close.setImage(image.createImage());
    close.setToolTipText(Messages.XFindPanel_Close_tooltip); //$NON-NLS-1$
    close.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            hidePanel();
        }
    });
    return close;
}
 
Example #10
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: PromoteTempWizard.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void createControl(Composite parent) {
	Composite result= new Composite(parent, SWT.NONE);
	setControl(result);
	GridLayout layout= new GridLayout();
	layout.numColumns= 2;
	layout.verticalSpacing= 8;
	result.setLayout(layout);

	addFieldNameField(result);
	addVisibilityControl(result);
	addInitizeInRadioButtonGroup(result);
	addDeclareStaticCheckbox(result);
	addDeclareFinalCheckbox(result);

	Dialog.applyDialogFont(result);
	PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PROMOTE_TEMP_TO_FIELD_WIZARD_PAGE);

	updateStatus();
}
 
Example #11
Source Project: xtext-eclipse   Author: eclipse   File: DefaultTemplateProjectCreator.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
	SubMonitor subMonitor = SubMonitor.convert(monitor, projectFactories.size());
	try {
		IWorkbench workbench = PlatformUI.getWorkbench();
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
		for (ProjectFactory projectFactory : projectFactories) {
			projectFactory.setWorkbench(workbench);
			projectFactory.setWorkspace(workspace);
			projectFactory.createProject(subMonitor, null);
			subMonitor.worked(1);
		}
	} finally {
		subMonitor.done();
	}
}
 
Example #12
Source Project: tmxeditor8   Author: heartsome   File: ImportProjectWizardPage2.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 获取所有已经被打开的文件
 * @return
 */
private Map<IFile, IEditorPart> getAllOpenedIFile(){
	Map<IFile, IEditorPart> openedIfileMap = new HashMap<IFile, IEditorPart>();
	
	IEditorReference[] referenceArray = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
	for(IEditorReference reference : referenceArray){
		IEditorPart editor = reference.getEditor(true);
		// 如果这是一个 nattable 编辑器
		if (XLIFF_EDITOR_ID.equals(editor.getSite().getId())) {
			IXliffEditor xlfEditor = (IXliffEditor)editor;
			if (xlfEditor.isMultiFile()) {
				for(File file : xlfEditor.getMultiFileList()){
					openedIfileMap.put(ResourceUtils.fileToIFile(file.getAbsolutePath()), editor);
				}
			}else {
				openedIfileMap.put(((FileEditorInput)editor.getEditorInput()).getFile(), editor);
			}
		}else {
			// 其他情况,直接将文件丢进去就行了
			openedIfileMap.put(((FileEditorInput)editor.getEditorInput()).getFile(), editor);
		}
	}
	return openedIfileMap;
}
 
Example #13
Source Project: xtext-eclipse   Author: eclipse   File: XtextPluginImages.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private static final void initializeImageMaps() {
	if(imagesInitialized)
		return;
	
	annotationImagesFixable.put(XtextEditor.ERROR_ANNOTATION_TYPE, get(OBJ_FIXABLE_ERROR));
	annotationImagesFixable.put(XtextEditor.WARNING_ANNOTATION_TYPE, get(OBJ_FIXABLE_WARNING));
	annotationImagesFixable.put(XtextEditor.INFO_ANNOTATION_TYPE, get(OBJ_FIXABLE_INFO));

	ISharedImages sharedImages= PlatformUI.getWorkbench().getSharedImages();
	Image error = sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
	Image warning = sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
	Image info = sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
	annotationImagesNonFixable.put(XtextEditor.ERROR_ANNOTATION_TYPE, error);
	annotationImagesNonFixable.put(XtextEditor.WARNING_ANNOTATION_TYPE, warning);
	annotationImagesNonFixable.put(XtextEditor.INFO_ANNOTATION_TYPE, info);
	
	Display display = Display.getCurrent();
	annotationImagesDeleted.put(XtextEditor.ERROR_ANNOTATION_TYPE, new Image(display, error, SWT.IMAGE_GRAY));
	annotationImagesDeleted.put(XtextEditor.WARNING_ANNOTATION_TYPE, new Image(display, warning, SWT.IMAGE_GRAY));
	annotationImagesDeleted.put(XtextEditor.INFO_ANNOTATION_TYPE, new Image(display, info, SWT.IMAGE_GRAY));
	
	imagesInitialized = true;
}
 
Example #14
Source Project: translationstudio8   Author: heartsome   File: WordsFA.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 输出字数统计结果到结果窗体中
 * @param WordsFAResultMap
 */
public void printWordsFAReslut() {
	String htmlPath = createFAResultHtml();
	try {
		model.getAnalysisIFileList().get(0).getProject().getFolder("Intermediate").getFolder("Report").refreshLocal(IResource.DEPTH_INFINITE, null);
	} catch (CoreException e1) {
		e1.printStackTrace();
	}
	
	final FileEditorInput input = new FileEditorInput(ResourceUtils.fileToIFile(htmlPath));
	if (PlatformUI.getWorkbench().isClosing()) {
		return;
	}
	
	Display.getDefault().asyncExec(new Runnable() {
		public void run() {
			try {
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, QAConstant.FA_HtmlBrowserEditor, true);
			} catch (PartInitException e) {
				logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log5"), e);
				e.printStackTrace();
			}
		}
	});
}
 
Example #15
Source Project: xtext-xtend   Author: eclipse   File: XtendQuickfixProvider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Fix(IssueCodes.WRONG_FILE)
public void fixWrongFileRenameClass(final Issue issue, final IssueResolutionAcceptor acceptor) {
	URI uri = issue.getUriToProblem();
	String className = uri.trimFileExtension().lastSegment();
	String label = String.format("Rename class to '%s'", className);
	acceptor.accept(issue, label, label, null, (element, context) -> {
		context.getXtextDocument().modify(resource -> {
			IRenameElementContext renameContext = renameContextFactory.createRenameElementContext(element, null,
					new TextSelection(context.getXtextDocument(), issue.getOffset(), issue.getLength()), resource);
			final ProcessorBasedRefactoring refactoring = renameRefactoringProvider.getRenameRefactoring(renameContext);
			((RenameElementProcessor) refactoring.getProcessor()).setNewName(className);
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, true, monitor -> {
				try {
					if (!refactoring.checkFinalConditions(monitor).isOK())
						return;
					Change change = refactoring.createChange(monitor);
					change.initializeValidationData(monitor);
					PerformChangeOperation performChangeOperation = new PerformChangeOperation(change);
					performChangeOperation.setUndoManager(RefactoringCore.getUndoManager(), refactoring.getName());
					performChangeOperation.setSchedulingRule(ResourcesPlugin.getWorkspace().getRoot());
					performChangeOperation.run(monitor);
				} catch (CoreException e) {
					logger.error(e);
				}
			});
			return null;
		});
	});
}
 
Example #16
Source Project: tmxeditor8   Author: heartsome   File: AcceptTerm0.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** (non-Javadoc)
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(
			"net.heartsome.cat.ts.ui.term.view.termView");		
	if (viewPart != null && viewPart instanceof ITermViewPart) {				
		ITermViewPart matchView = (ITermViewPart) viewPart;
		matchView.acceptTermByIndex(10);
	}
	return null;
}
 
Example #17
Source Project: bonita-studio   Author: bonitasoft   File: DuplicateDiagramAction.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void duplicate(MainProcess diagram) {
    String newProcessLabel = diagram.getName();
    String newProcessVersion = diagram.getVersion();
    DiagramRepositoryStore diagramRepositoryStore = repositoryAccessor.getRepositoryStore(DiagramRepositoryStore.class);
    final OpenNameAndVersionForDiagramDialog dialog = new OpenNameAndVersionForDiagramDialog(
            Display.getDefault().getActiveShell(),
            diagram, diagramRepositoryStore);
    dialog.forceNameUpdate();
    if (dialog.open() == Dialog.OK) {
        final Identifier identifier = dialog.getIdentifier();
        newProcessLabel = identifier.getName();
        newProcessVersion = dialog.getIdentifier().getVersion();
        List<ProcessesNameVersion> pools = dialog.getPools();
        final DuplicateDiagramOperation op = new DuplicateDiagramOperation();
        op.setDiagramToDuplicate(diagram);
        op.setNewDiagramName(newProcessLabel);
        op.setNewDiagramVersion(newProcessVersion);
        op.setPoolsRenamed(pools);
        final IProgressService service = PlatformUI.getWorkbench().getProgressService();
        try {
            service.run(true, false, op);
        } catch (InvocationTargetException | InterruptedException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
        DiagramFileStore store = diagramRepositoryStore.getDiagram(newProcessLabel, newProcessVersion);
        store.open();
    }
}
 
Example #18
Source Project: bonita-studio   Author: bonitasoft   File: PlatformUtil.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static Optional<IEditorPart> findActiveEditor() {
    if (PlatformUI.isWorkbenchRunning()) {
        return Optional.ofNullable(PlatformUI.getWorkbench())
                .map(IWorkbench::getActiveWorkbenchWindow)
                .map(IWorkbenchWindow::getActivePage)
                .map(IWorkbenchPage::getActiveEditor);
    }
    return Optional.empty();
}
 
Example #19
Source Project: tracecompass   Author: tracecompass   File: FilterViewer.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static Color getThemeColor(String themeColorName, int systemDefault) {
    ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
    Color c = colorRegistry.get(themeColorName);

    if (c == null) {
        c = Display.getDefault().getSystemColor(systemDefault);
    }
    return c;
}
 
Example #20
Source Project: Pydev   Author: fabioz   File: KeyBindingHelper.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param fActivateEditorBinding
 */
public static void executeCommand(String commandId) {
    IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
    try {
        handlerService.executeCommand(commandId, null);
    } catch (Exception e) {
        Log.log(e);
    }

}
 
Example #21
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: CodeStylePreferencePage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
	IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
	fConfigurationBlock= new NameConventionConfigurationBlock(getNewStatusChangedListener(), getProject(), container);

	super.createControl(parent);
	PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CODE_MANIPULATION_PREFERENCE_PAGE);
}
 
Example #22
Source Project: translationstudio8   Author: heartsome   File: StyledTextCellEditor.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void close() {
	if (close) {
		return;
	}

	for (Listener listener : closingListeners) {
		Event event = new Event();
		event.data = this;
		listener.handleEvent(event);
	}

	close = true; // 状态改为已经关闭
	xliffEditor.getTable().removeDisposeListener(this);

	StyledText text = viewer.getTextWidget();
	if (text != null && !text.isDisposed()) {
		actionHandler.removeTextViewer();
		text.setMenu(null); // dispose前应去掉右键menu,因为右键menu是和nattable共享的
		viewer.reset();
		text.dispose();
		text = null;
	}

	// 如果 XLIFF 编辑器仍处于激活状态,则把焦点交给编辑器
	try {
		IWorkbenchPart activepart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
				.getActivePart();
		if (xliffEditor.equals(activepart)) {
			xliffEditor.setFocus();
		}
	} catch (NullPointerException e) {
	}

	// NatTable table = xliffEditor.getTable();
	// int[] rowPositions = new int[] { hsCellEditor.getRowPosition() };
	// table.doCommand(new AutoResizeCurrentRowsCommand(table, rowPositions, table.getConfigRegistry()));
}
 
Example #23
Source Project: ice   Author: eclipse   File: MeshElementTreeView.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Update elementTreeViewer when new elements are added to the mesh.
 * 
 * @param component
 * 
 * @see IUpdateableListener#update(IUpdateable)
 */
@Override
public void update(IUpdateable component) {

	// If the update came from the mesh component, redraw the mesh
	if (component == meshComponent) {

		logger.info("ICEMeshPage Message: " + "Mesh changed!");

		// Sync with the display
		PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
			@Override
			public void run() { // Just do a blanket update - no need to
								// check
								// the component
				if (elementTreeViewer != null) {
					logger.info("MeshElementTreeView Message: "
							+ "Updating element view.");

					// Set the tree content
					if (meshComponent != null) {
						elementTreeViewer
								.setInput(meshComponent.getPolygons());
					}

					// Refresh the view
					elementTreeViewer.refresh();
					elementTreeViewer.getTree().redraw();
				}
			}
		});
	}

	return;
}
 
Example #24
Source Project: hybris-commerce-eclipse-plugin   Author: SAP   File: ImpexTypeHyperlink.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void open() {
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	
	String typeLocation = Activator.getDefault().getTypeLoaderInfo(location);
	String fileName = typeLocation.substring(0, typeLocation.indexOf(":"));
	String extensionName = fileName.replaceAll("-items.xml", "");
	String lineNumberStr = typeLocation.substring(typeLocation.indexOf(":") + 1, typeLocation.indexOf("("));
	
	IProject extension = ResourcesPlugin.getWorkspace().getRoot().getProject(extensionName);
   	IFile itemsxml = extension.getFile("resources/" + fileName);
   	if (itemsxml.exists()) {
       	IMarker marker;
       	try {
			marker = itemsxml.createMarker(IMarker.TEXT);
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put(IMarker.LINE_NUMBER, Integer.parseInt(lineNumberStr));
			marker.setAttributes(map);
			//IDE.openEditor(getSite().getPage(), marker);
			IDE.openEditor(page, marker);
			marker.delete();
		}
       	catch (CoreException e) {
       		Activator.logError("Eclipse CoreException", e);
		}
   	}
   	else {
   		MessageBox dialog = new MessageBox(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
   		dialog.setText("Extension not found");
   		dialog.setMessage("The extension " + extensionName + " was not found in the workspace. Please import it and try again.");
   		dialog.open();
   	}
}
 
Example #25
Source Project: elexis-3-core   Author: elexis   File: PrintTakingsListHandler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	IPatient patient = ContextServiceHolder.get().getActivePatient().orElse(null);
	if (patient == null)
		return null;
	
	String medicationType =
		event.getParameter("ch.elexis.core.ui.medication.commandParameter.medication"); //$NON-NLS-1$
	// if not set use selection
	if (medicationType == null || medicationType.isEmpty()) {
		medicationType = "selection";
	}
	
	List<IPrescription> prescRecipes = getPrescriptions(patient, medicationType, event);
	if (!prescRecipes.isEmpty()) {
		prescRecipes = sortPrescriptions(prescRecipes, event);
		try {
			RezeptBlatt rpb = (RezeptBlatt) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getActivePage().showView(RezeptBlatt.ID);
			rpb.createEinnahmeliste((Patient) NoPoUtil.loadAsPersistentObject(patient),
				NoPoUtil.loadAsPersistentObject(
					prescRecipes.toArray(new IPrescription[prescRecipes.size()]),
					Prescription.class));
		} catch (PartInitException e) {
			log.error("Error outputting recipe", e);
		}
	}
	
	return null;
}
 
Example #26
Source Project: gama   Author: gama-platform   File: OpenFileAction.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new action that will open instances of the specified editor on the then-selected file resources.
 *
 * @param page
 *            the workbench page in which to open the editor
 * @param descriptor
 *            the editor descriptor, or <code>null</code> if unspecified
 */
public OpenFileAction(final IWorkbenchPage page, final IEditorDescriptor descriptor) {
	super(page);
	setText(descriptor == null ? IDEWorkbenchMessages.OpenFileAction_text : descriptor.getLabel());
	PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IIDEHelpContextIds.OPEN_FILE_ACTION);
	setToolTipText(IDEWorkbenchMessages.OpenFileAction_toolTip);
	setId(ID);
	this.editorDescriptor = descriptor;
}
 
Example #27
Source Project: elexis-3-core   Author: elexis   File: RnContentProvider.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public Object[] getElements(final Object inputElement){
	IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
	try {
		progressService.run(true, true, new IRunnableWithProgress() {
			
			@Override
			public void run(final IProgressMonitor monitor){
				reload(monitor);
				if (monitor.isCanceled()) {
					monitor.done();
				}
				
				rlv.getSite().getShell().getDisplay().syncExec(new Runnable() {
					@Override
					public void run(){
						InvoiceListBottomComposite invoiceListeBottomComposite =
							rlv.getInvoiceListeBottomComposite();
						if (invoiceListeBottomComposite != null) {
							invoiceListeBottomComposite.update(Integer.toString(iPat),
								Integer.toString(iRn), mAmount.getAmountAsString(),
								mOpen.getAmountAsString());
						}
					}
				});
			}
		});
	} catch (Throwable ex) {
		ExHandler.handle(ex);
	}
	
	return result == null ? new Tree[0] : result;
}
 
Example #28
Source Project: erflute   Author: dbflute-session   File: ModelPropertiesEditPart.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void performRequestOpen() {
    final ERDiagram diagram = getDiagram();
    final ModelProperties copyModelProperties = diagram.getDiagramContents().getSettings().getModelProperties().clone();
    final ModelPropertiesDialog dialog =
            new ModelPropertiesDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), copyModelProperties);
    if (dialog.open() == IDialogConstants.OK_ID) {
        final ChangeModelPropertiesCommand command = new ChangeModelPropertiesCommand(diagram, copyModelProperties);
        executeCommand(command);
    }
}
 
Example #29
Source Project: APICloud-Studio   Author: apicloudcom   File: BrowserCommandHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	if (browserURL == null)
	{
		return null;
	}

	try
	{
		IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();

		if (support.isInternalWebBrowserAvailable())
		{
			support.createBrowser(
					IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.LOCATION_BAR
							| IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.STATUS, browserId,
					null, // Set the name to null so that the browser tab will display the title of page loaded in
							// the browser
					null).openURL(browserURL);
		}
		else
		{
			support.getExternalBrowser().openURL(browserURL);
		}
	}
	catch (PartInitException e)
	{
		IdeLog.logError(UIPlugin.getDefault(), e);
	}

	return null;
}
 
Example #30
Source Project: e4macs   Author: MulgaSoft   File: EmacsPlusCmdHandler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Add an asynchronous call to show the message
 */
protected void asyncShowMessage(final IWorkbenchPart wpart, final String message, final boolean error) {
	PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
		public void run() {
			EmacsPlusUtils.showMessage(wpart, message, error);
		}});
}