org.eclipse.ui.IViewSite Java Examples

The following examples show how to use org.eclipse.ui.IViewSite. 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 File: AbstractAlarmsEventsView.java    From neoscada with Eclipse Public License 1.0 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 #2
Source File: EnhancedTextField.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public void connectGlobalActions(IViewSite site){
	makeActions();
	IActionBars actionBars = site.getActionBars();
	actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
	actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cutAction);
	actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
	globalMenuListener = new IMenuListener() {
		@Override
		public void menuAboutToShow(IMenuManager manager){
			if (text.getSelectionCount() == 0) {
				copyAction.setEnabled(false);
				cutAction.setEnabled(false);
			} else {
				copyAction.setEnabled(true);
				cutAction.setEnabled(true);
			}
			
		}
	};
	// TODO
	// ApplicationActionBarAdvisor.editMenu.addMenuListener(globalMenuListener);
	ElexisEventDispatcher.getInstance().addListeners(eeli_user);
}
 
Example #3
Source File: ControlView.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
    super.init(site, memento);
    if (memento != null) {
        fInitialConnections = new ArrayList<>();
        for(int i = 0; ; i++) {
            String id = memento.getString(KEY_REMOTE_PROVIDER + i);
            String name = memento.getString(KEY_REMOTE_CONNECTION_NAME + i);
            if ((id == null) || (name == null)) {
                break;
            }
            IRemoteConnection conn = TmfRemoteConnectionFactory.getRemoteConnection(id, name);
            if (conn != null) {
                fInitialConnections.add(conn);
            }
        }
    }
}
 
Example #4
Source File: CodeSelectorFactory.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public static void makeTabs(CTabFolder ctab, IViewSite site, String point){
	String settings = null;
	if (point.equals(ExtensionPointConstantsUi.VERRECHNUNGSCODE)) {
		settings = CoreHub.userCfg.get(Preferences.USR_SERVICES_DIAGNOSES_SRV, null);
	} else if (point.equals(ExtensionPointConstantsUi.DIAGNOSECODE)) {
		settings = CoreHub.userCfg.get(Preferences.USR_SERVICES_DIAGNOSES_DIAGNOSE, null);
	}
	
	java.util.List<IConfigurationElement> list = Extensions.getExtensions(point);
	if (settings == null) {
		addAllTabs(list, ctab, point);
	} else {
		addUserSpecifiedTabs(list, settings, ctab, point);
	}
	
	if (ctab.getItemCount() > 0) {
		ctab.setSelection(0);
	}
}
 
Example #5
Source File: StatusLineMessageTimerManager.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
static IStatusLineManager getStatusLineManager()
{
	try
	{
		IWorkbenchPartSite site = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
				.getActivePart().getSite();
		return ((IViewSite) site).getActionBars().getStatusLineManager();
	}
	catch (Exception e)
	{
		// try to get the IStatusLineManager through an active editor
		try
		{
			return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()
					.getEditorSite().getActionBars().getStatusLineManager();
		}
		catch (Exception e1)
		{
		}
	}
	return null;
}
 
Example #6
Source File: PackageExplorerPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
	super.init(site, memento);
	if (memento == null) {
		String persistedMemento= fDialogSettings.get(TAG_MEMENTO);
		if (persistedMemento != null) {
			try {
				memento= XMLMemento.createReadRoot(new StringReader(persistedMemento));
			} catch (WorkbenchException e) {
				// don't do anything. Simply don't restore the settings
			}
		}
	}
	fMemento= memento;
	if (memento != null) {
		restoreLayoutState(memento);
		restoreLinkingEnabled(memento);
		restoreRootMode(memento);
	}
	if (getRootMode() == WORKING_SETS_AS_ROOTS) {
		createWorkingSetModel();
	}
}
 
Example #7
Source File: KonsDetailView.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void setUnlocked(boolean unlocked){
	boolean hlMandantEnabled =
		actEncounter != null && BillingServiceHolder.get().isEditable(actEncounter).isOK()
			&& CoreHub.acl.request(AccessControlDefaults.KONS_REASSIGN) && unlocked;
	hlMandant.setEnabled(hlMandantEnabled);
	boolean cbFallEnabled = actEncounter != null
		&& BillingServiceHolder.get().isEditable(actEncounter).isOK() && unlocked;
	comboViewerFall.getCombo().setEnabled(cbFallEnabled);
	text.setEditable(unlocked);
	
	// update the UI
	IToolBarManager mgr = ((IViewSite) getSite()).getActionBars().getToolBarManager();
	IContributionItem[] items = mgr.getItems();
	for (IContributionItem iContributionItem : items) {
		iContributionItem.update();
	}
}
 
Example #8
Source File: BugExplorerView.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
    viewMemento = memento;
    if (memento == null) {
        IDialogSettings dialogSettings = FindbugsPlugin.getDefault().getDialogSettings();
        String persistedMemento = dialogSettings.get(TAG_MEMENTO);
        if (persistedMemento == null) {
            // See bug 2504068. First time user opens a view, no settings
            // are defined
            // but we still need to enforce initialisation of content
            // provider
            // which can only happen if memento is not null
            memento = XMLMemento.createWriteRoot("bugExplorer");
        } else {
            try {
                memento = XMLMemento.createReadRoot(new StringReader(persistedMemento));
            } catch (WorkbenchException e) {
                // don't do anything. Simply don't restore the settings
            }
        }
    }
    super.init(site, memento);
}
 
Example #9
Source File: Handler.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private static Object execute(IViewSite origin, String commandID, Map<String, Object> params){
	if (origin == null) {
		log.error("origin is null");
		return null;
	}
	IHandlerService handlerService = (IHandlerService) origin.getService(IHandlerService.class);
	ICommandService cmdService = (ICommandService) origin.getService(ICommandService.class);
	try {
		Command command = cmdService.getCommand(commandID);
		String name = StringTool.unique("CommandHandler"); //$NON-NLS-1$
		paramMap.put(name, params);
		Parameterization px = new Parameterization(new DefaultParameter(), name);
		ParameterizedCommand parmCommand =
			new ParameterizedCommand(command, new Parameterization[] {
				px
		});
		
		return handlerService.executeCommand(parmCommand, null);
		
	} catch (Exception ex) {
		throw new RuntimeException("add.command not found"); //$NON-NLS-1$
	}
}
 
Example #10
Source File: ErstelleRnnCommand.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public static Object ExecuteWithParams(IViewSite origin, Tree<?> tSelection){
	IHandlerService handlerService = (IHandlerService) origin.getService(IHandlerService.class);
	ICommandService cmdService = (ICommandService) origin.getService(ICommandService.class);
	try {
		Command command = cmdService.getCommand(ID);
		Parameterization px =
			new Parameterization(command.getParameter("ch.elexis.RechnungErstellen.parameter"), //$NON-NLS-1$
				new TreeToStringConverter().convertToString(tSelection));
		ParameterizedCommand parmCommand =
			new ParameterizedCommand(command, new Parameterization[] {
				px
			});
		
		return handlerService.executeCommand(parmCommand, null);
		
	} catch (Exception ex) {
		throw new RuntimeException("add.command not found"); //$NON-NLS-1$
	}
}
 
Example #11
Source File: EigendiagnoseDetailDisplay.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public Composite createDisplay(Composite parent, IViewSite site){
	form = UiDesk.getToolkit().createForm(parent);
	TableWrapLayout twl = new TableWrapLayout();
	form.getBody().setLayout(twl);
	
	tblPls = new LabeledInputField.AutoForm(form.getBody(), data);
	tblPls.setModelService(ModelServiceHolder.get());
	
	TableWrapData twd = new TableWrapData(TableWrapData.FILL_GRAB);
	twd.grabHorizontal = true;
	tblPls.setLayoutData(twd);
	TableWrapData twd2 = new TableWrapData(TableWrapData.FILL_GRAB);
	tComment = UiDesk.getToolkit().createText(form.getBody(), StringTool.leer, SWT.BORDER);
	tComment.setLayoutData(twd2);
	return form.getBody();
}
 
Example #12
Source File: DynamicViewMenu.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Get the original menu which is used to find the menu item.
 */
private void getMenu() {
  final ToolBarManager toolBarManager = (ToolBarManager) ((IViewSite) reference.getPart(true).getSite()).getActionBars().getToolBarManager();
  PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
    @Override
    public void run() {
      originalMenu = new Menu(toolBarManager.getControl());
    }
  });
}
 
Example #13
Source File: BaseDebugView.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
    IViewSite viewSite = getViewSite();
    if (viewSite != null) {
        configureToolBar(viewSite);
    }

    parent.setLayout(new GridLayout(1, true));

    viewer = new TreeViewer(parent);
    provider = createContentProvider();
    viewer.setContentProvider(provider);
    viewer.setLabelProvider(new PyDebugModelPresentation(false));

    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getTree());

    MenuManager menuManager = new MenuManager();
    Menu menu = menuManager.createContextMenu(viewer.getTree());
    viewer.getTree().setMenu(menu);
    IWorkbenchPartSite site = getSite();
    site.registerContextMenu(menuManager, viewer);
    site.setSelectionProvider(viewer);

    this.parent = parent;

    listener = createListener();
    if (listener != null) {
        DebugPlugin plugin = DebugPlugin.getDefault();

        ILaunchManager launchManager = plugin.getLaunchManager();
        launchManager.addLaunchListener(listener);

        plugin.addDebugEventListener(listener);
    }
}
 
Example #14
Source File: CurrentExceptionView.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configureToolBar(IViewSite viewSite) {
    IActionBars actionBars = viewSite.getActionBars();
    IToolBarManager toolBar = actionBars.getToolBarManager();
    //IMenuManager menuManager = actionBars.getMenuManager(); -- not adding anything to the menu for now.

    toolBar.add(new EditIgnoredCaughtExceptions(this));
}
 
Example #15
Source File: ObligationsView.java    From tlaplus with MIT License 5 votes vote down vote up
public void init(IViewSite site) throws PartInitException {
	super.init(site);
	// Register a SLP to refresh the obligation view once it has been
	// created. This used to be done as part of the
	// ProverSpecLifecycleParticipant. However, the PSLP is created from an
	// Extension Point which means it potentially runs *before* the UI is
	// fully initialized. If this is interleaved with a spec open event, it
	// means the UIHelper.runUIAsync(..) tries to create a UI and then
	// nullpointers.
	// See dipose() where the lifecycle participant is de-registered again.
	// It should be safe to receive events even if the Obligations View
	// isn't open, but it's good practice to remove listeners past disposal.
	// Even if it just saves a few CPU cycles in an hour.
	Activator.getSpecManager().addSpecLifecycleParticipant(specLifecycleParticipant);
}
 
Example #16
Source File: ReferrersView.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configureToolBar(IViewSite viewSite) {
    IActionBars actionBars = viewSite.getActionBars();
    IToolBarManager toolBar = actionBars.getToolBarManager();
    //IMenuManager menuManager = actionBars.getMenuManager(); -- not adding anything to the menu for now.

    toolBar.add(new ClearCurrentReferrers(this));

}
 
Example #17
Source File: MonitorsViewTable.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
protected void hookContextMenu ( final Control control, final ISelectionProvider selectionProvider, final IViewSite viewSite )
{
    final MenuManager menuMgr = new MenuManager ( "#PopupMenu" ); //$NON-NLS-1$
    menuMgr.setRemoveAllWhenShown ( true );
    menuMgr.addMenuListener ( new IMenuListener () {
        @Override
        public void menuAboutToShow ( final IMenuManager manager )
        {
            fillContextMenu ( manager );
        }
    } );
    final Menu menu = menuMgr.createContextMenu ( control );
    control.setMenu ( menu );
    viewSite.registerContextMenu ( menuMgr, selectionProvider );
}
 
Example #18
Source File: EventPoolView.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void init ( final IViewSite site, final IMemento memento ) throws PartInitException
{
    super.init ( site, memento );

    if ( memento != null )
    {
        final String s = memento.getString ( "columnSettings" ); //$NON-NLS-1$
        if ( s != null )
        {
            this.initialColumnSettings = this.gson.fromJson ( s, new TypeToken<List<ColumnProperties>> () {}.getType () );
        }
    }
}
 
Example #19
Source File: TmfView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Return the Eclipse view ID in the format 'Primary ID':'Secondary ID' or
 * simply 'Primary ID' if secondary ID is null
 *
 * @return This view's view ID
 * @since 2.2
 */
protected @NonNull String getViewId() {
    IViewSite viewSite = getViewSite();
    String secondaryId = viewSite.getSecondaryId();
    if (secondaryId == null) {
        return String.valueOf(viewSite.getId());
    }
    return viewSite.getId() + VIEW_ID_SEPARATOR + secondaryId;
}
 
Example #20
Source File: TmxEditorViewer.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(IViewSite site) throws PartInitException {
	super.init(site);
	this.openCloseListener = new ArrayList<TmxEditorOpenCloseListener>();
	undoRedoActionGroup = new UndoRedoActionGroup(getSite(), getSite().getWorkbenchWindow().getWorkbench()
			.getOperationSupport().getUndoContext(), true);
	PlatformUI.getWorkbench().addWorkbenchListener(workbenchListener);
}
 
Example #21
Source File: LayeredDisplayView.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init(final IViewSite site) throws PartInitException {
	super.init(site);
	if (getOutput() != null) {
		setPartName(getOutput().getName());
	}
}
 
Example #22
Source File: TestView.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init(final IViewSite site) throws PartInitException {
	super.init(site);
	// if (!SwtGui.ALL_TESTS_RUNNING) {
	experiments.clear();
	super.reset();
	// }
}
 
Example #23
Source File: FindOccurrencesInFileAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new <code>FindOccurrencesInFileAction</code>. The action
 * requires that the selection provided by the site's selection provider is of type
 * <code>IStructuredSelection</code>.
 *
 * @param site the site providing context information for this action
 * @since 3.1
 */
public FindOccurrencesInFileAction(IWorkbenchSite site) {
	super(site);

	if (site instanceof IViewSite)
		fActionBars= ((IViewSite)site).getActionBars();
	else if (site instanceof IEditorSite)
		fActionBars= ((IEditorSite)site).getActionBars();
	else if (site instanceof IPageSite)
		fActionBars= ((IPageSite)site).getActionBars();

	setText(SearchMessages.Search_FindOccurrencesInFile_label);
	setToolTipText(SearchMessages.Search_FindOccurrencesInFile_tooltip);
	PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_OCCURRENCES_IN_FILE_ACTION);
}
 
Example #24
Source File: LocationCopyAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
LocationCopyAction(IViewSite viewSite, Clipboard clipboard, LocationViewer locationViewer) {
	fClipboard= clipboard;
	fViewSite= viewSite;
	fLocationViewer= locationViewer;

	setText(CallHierarchyMessages.LocationCopyAction_copy);
	setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
	setEnabled(!fLocationViewer.getSelection().isEmpty());

	locationViewer.addSelectionChangedListener(new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			setEnabled(! event.getSelection().isEmpty());
		}
	});
}
 
Example #25
Source File: MatchViewPart.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
	init(site);
	site.getPage().addPostSelectionListener(this);
	site.getPage().addPartListener(new PartAdapter2() {
		@Override
		public void partClosed(IWorkbenchPartReference partRef) {
			if (gridTable == null || gridTable.isDisposed()) {
				getSite().getPage().removePartListener(this); // 关闭视图后,移除此监听
			} else {
				if ("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor".equals(partRef.getId())) {
					IEditorReference[] editorReferences = getSite().getPage().getEditorReferences();
					if (editorReferences.length == 0) { // 所有编辑器全部关闭的情况下。
						if (matcherThread != null) {
							matcherThread.interrupt();
						}
						manualTranslationThread.interruptCurrentTask();

						tmMatcher.clearDbResources();
						tuInfoBean.resetTuInfo();
						copyEnable.resetSelection();
						gridTable.removeAll();
						handler = null;
						setMatchMessage(null, "", "");
						setProcessMessage(null, "", "");
					}
				}
			}
		}
	});
	site.getActionBars().getStatusLineManager().setMessage(Messages.getString("view.MatchViewPart.statusLine"));
}
 
Example #26
Source File: TerminologyViewPart.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
	init(site);

	final IWorkbenchPage page = site.getPage();
	page.addPostSelectionListener(this);
	page.addPartListener(new PartAdapter2() {
		@Override
		public void partClosed(IWorkbenchPartReference partRef) {
			if (gridTable == null || gridTable.isDisposed()) {
				page.removePartListener(this); // 关闭视图后,移除此监听
			} else {
				if ("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor".equals(partRef.getId())) {
					IEditorReference[] editorReferences = page.getEditorReferences();
					if (editorReferences.length == 0) { // 所有编辑器全部关闭的情况下。
						matcher.clearResources();
						firstAction.setEnabled(false);
						copyEnable.resetSelection();
						gridTable.removeAll();
					}
				}
			}
		}
	});
	site.getActionBars().getStatusLineManager()
			.setMessage(Messages.getString("view.TerminologyViewPart.statusLine"));
}
 
Example #27
Source File: PackagesView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
	super.init(site, memento);
	//this must be created before all actions and filters
	fWrappedViewer= new PackageViewerWrapper();
	restoreLayoutState(memento);
}
 
Example #28
Source File: TerminologyViewPart.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
	init(site);

	final IWorkbenchPage page = site.getPage();
	page.addPostSelectionListener(this);
	page.addPartListener(new PartAdapter2() {
		@Override
		public void partClosed(IWorkbenchPartReference partRef) {
			if (gridTable == null || gridTable.isDisposed()) {
				page.removePartListener(this); // 关闭视图后,移除此监听
			} else {
				if ("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor".equals(partRef.getId())) {
					IEditorReference[] editorReferences = page.getEditorReferences();
					if (editorReferences.length == 0) { // 所有编辑器全部关闭的情况下。
						matcher.clearResources();
						firstAction.setEnabled(false);
						copyEnable.resetSelection();
						gridTable.removeAll();
					}
				}
			}
		}
	});
	site.getActionBars().getStatusLineManager()
			.setMessage(Messages.getString("view.TerminologyViewPart.statusLine"));
}
 
Example #29
Source File: MatchViewPart.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
	init(site);
	site.getPage().addPostSelectionListener(this);
	site.getPage().addPartListener(new PartAdapter2() {
		@Override
		public void partClosed(IWorkbenchPartReference partRef) {
			if (gridTable == null || gridTable.isDisposed()) {
				getSite().getPage().removePartListener(this); // 关闭视图后,移除此监听
			} else {
				if ("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor".equals(partRef.getId())) {
					IEditorReference[] editorReferences = getSite().getPage().getEditorReferences();
					if (editorReferences.length == 0) { // 所有编辑器全部关闭的情况下。
						synchronized (matchDataContainer) {
							matchDataContainer.clear();
							if (matcherThread != null) {
								matcherThread.interrupt();
							}
						}
						manualTranslationThread.interruptCurrentTask();

						tmMatcher.clearDbResources();
						copyEnable.resetSelection();
						gridTable.removeAll();
						sourceText.setText("");
						setMatchMessage(null, "", "");
						setProcessMessage(null, "", "");
					}
				}
			}
		}
	});
	site.getActionBars().getStatusLineManager().setMessage(Messages.getString("view.MatchViewPart.statusLine"));
}
 
Example #30
Source File: PropertiesView.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(IViewSite site) throws PartInitException {
	super.init(site);
	getSite().getPage().addPostSelectionListener(tmxEditorSelectionListener);
	TmxEditorViewer editorViewer = TmxEditorViewer.getInstance();
	if (editorViewer == null) {
		return;
	}
	editorViewer.addOpenCloseListener(editorOpenCloseListener);
	getSite().getPage().addPartListener(this);
}