Search in sources :

Example 46 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project linuxtools by eclipse.

the class ImageBuildPage method createControl.

@Override
public void createControl(Composite parent) {
    final Composite container = new Composite(parent, SWT.NULL);
    FormLayout layout = new FormLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    container.setLayout(layout);
    Label label = new Label(container, SWT.NULL);
    Label nameLabel = new Label(container, SWT.NULL);
    nameLabel.setText(WizardMessages.getString(NAME_LABEL));
    nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
    nameText.addModifyListener(Listener);
    nameText.setToolTipText(WizardMessages.getString(NAME_TOOLTIP));
    Label dirLabel = new Label(container, SWT.NULL);
    dirLabel.setText(WizardMessages.getString(DIRECTORY_LABEL));
    directoryText = new Text(container, SWT.BORDER | SWT.SINGLE);
    directoryText.addModifyListener(Listener);
    directoryText.setToolTipText(WizardMessages.getString(DIRECTORY_TOOLTIP));
    Button browse = new Button(container, SWT.NULL);
    browse.setText(WizardMessages.getString(BROWSE_LABEL));
    browse.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        DirectoryDialog d = new DirectoryDialog(container.getShell());
        String k = d.open();
        if (k != null)
            directoryText.setText(k);
    }));
    editButton = new Button(container, SWT.NULL);
    editButton.setText(WizardMessages.getString(EDIT_LABEL));
    editButton.setEnabled(false);
    editButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        String dir = directoryText.getText();
        IFileStore fileStore = EFS.getLocalFileSystem().getStore(// $NON-NLS-1$
        new Path(dir).append("Dockerfile"));
        // $NON-NLS-1$
        java.nio.file.Path filePath = Paths.get(dir, "Dockerfile");
        if (!Files.exists(filePath)) {
            try {
                Files.createFile(filePath);
            } catch (IOException e1) {
            // File won't exist, and directory should be
            // writable
            }
        }
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        try {
            IEditorPart dockerFileEditor = IDE.openEditorOnFileStore(page, fileStore);
            IWorkbenchPartSite site = page.getActivePart().getSite();
            EModelService s = site.getService(EModelService.class);
            MPartSashContainerElement p = site.getService(MPart.class);
            s.detach(p, 100, 100, 500, 375);
            dockerFileEditor.getEditorSite().getShell().setText(WizardMessages.getString(// $NON-NLS-1$
            "ImageBuild.editor.name"));
            editors.add(dockerFileEditor);
        } catch (PartInitException e1) {
            Activator.log(e1);
        }
        validate();
    }));
    Point p1 = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Point p2 = directoryText.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Point p3 = browse.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    int centering = (p2.y - p1.y + 1) / 2;
    int centering2 = (p3.y - p2.y + 1) / 2;
    FormData f = new FormData();
    f.top = new FormAttachment(0);
    label.setLayoutData(f);
    f = new FormData();
    f.top = new FormAttachment(label, 11 + centering + centering2);
    f.left = new FormAttachment(0, 0);
    nameLabel.setLayoutData(f);
    f = new FormData();
    f.top = new FormAttachment(label, 11 + centering2);
    f.left = new FormAttachment(nameLabel, 5);
    f.right = new FormAttachment(browse, -10);
    nameText.setLayoutData(f);
    f = new FormData();
    f.top = new FormAttachment(nameLabel, 11 + centering + centering2);
    f.left = new FormAttachment(0, 0);
    dirLabel.setLayoutData(f);
    f = new FormData();
    f.top = new FormAttachment(nameLabel, 11);
    f.right = new FormAttachment(100);
    editButton.setLayoutData(f);
    f = new FormData();
    f.top = new FormAttachment(nameLabel, 11);
    f.right = new FormAttachment(editButton, -10);
    browse.setLayoutData(f);
    f = new FormData();
    f.top = new FormAttachment(nameLabel, 11 + centering2);
    f.left = new FormAttachment(nameLabel, 5);
    f.right = new FormAttachment(browse, -10);
    directoryText.setLayoutData(f);
    if (lastDirectoryPath != null) {
        directoryText.setText(lastDirectoryPath);
    }
    setControl(container);
    setPageComplete(false);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) IDE(org.eclipse.ui.ide.IDE) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Activator(org.eclipse.linuxtools.docker.ui.Activator) Point(org.eclipse.swt.graphics.Point) HashSet(java.util.HashSet) IMessageProvider(org.eclipse.jface.dialogs.IMessageProvider) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) WizardPage(org.eclipse.jface.wizard.WizardPage) EFS(org.eclipse.core.filesystem.EFS) IEditorPart(org.eclipse.ui.IEditorPart) IFileStore(org.eclipse.core.filesystem.IFileStore) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) Files(java.nio.file.Files) FormLayout(org.eclipse.swt.layout.FormLayout) PlatformUI(org.eclipse.ui.PlatformUI) IFileInfo(org.eclipse.core.filesystem.IFileInfo) FormData(org.eclipse.swt.layout.FormData) MPartSashContainerElement(org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement) Set(java.util.Set) IOException(java.io.IOException) FormAttachment(org.eclipse.swt.layout.FormAttachment) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) EModelService(org.eclipse.e4.ui.workbench.modeling.EModelService) SWTImagesFactory(org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory) Paths(java.nio.file.Paths) ModifyListener(org.eclipse.swt.events.ModifyListener) Path(org.eclipse.core.runtime.Path) SWT(org.eclipse.swt.SWT) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) Path(org.eclipse.core.runtime.Path) FormData(org.eclipse.swt.layout.FormData) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) Composite(org.eclipse.swt.widgets.Composite) EModelService(org.eclipse.e4.ui.workbench.modeling.EModelService) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) IOException(java.io.IOException) IEditorPart(org.eclipse.ui.IEditorPart) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Button(org.eclipse.swt.widgets.Button) MPartSashContainerElement(org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement) IFileStore(org.eclipse.core.filesystem.IFileStore) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) FormAttachment(org.eclipse.swt.layout.FormAttachment) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 47 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project knime-core by knime.

the class WorkflowCoachView method updateFrequencyColumnHeadersAndToolTips.

/**
 * Updates the names and tooltips of the frequency column headers.
 */
private void updateFrequencyColumnHeadersAndToolTips() {
    m_namesAndToolTips = NodeRecommendationManager.getInstance().getNodeTripleProviders().stream().filter(p -> p.isEnabled()).map(p -> new Pair<>(p.getName(), p.getDescription())).collect(Collectors.toList());
    if (m_namesAndToolTips == null || m_namesAndToolTips.isEmpty()) {
        updateInputNoProvider();
        return;
    }
    // reset table sorter
    IElementComparer sorter = m_viewer.getComparer();
    if (sorter != null && sorter instanceof TableColumnSorter) {
        ((TableColumnSorter) sorter).setColumn(null);
    }
    // enforce to change the viewer state to update the headers
    m_viewerState = null;
    m_lastSelection = "";
    changeViewerStateTo(ViewerState.RECOMMENDATIONS);
    // get current selection from the workbench and update the recommendation list
    IEditorPart activeEditor = getViewSite().getPage().getActiveEditor();
    if (activeEditor == null) {
        // if no workflow is opened
        updateInput(NO_WORKFLOW_OPENED_MESSAGE);
    } else {
        IWorkbenchPartSite site = activeEditor.getSite();
        if (site != null) {
            ISelectionProvider selectionProvider = site.getSelectionProvider();
            if (selectionProvider != null) {
                ISelection selection = selectionProvider.getSelection();
                if (selection != null && selection instanceof IStructuredSelection) {
                    updateInput(selection);
                    return;
                }
            }
        }
        updateInput(StructuredSelection.EMPTY);
    }
}
Also used : Arrays(java.util.Arrays) IUpdateListener(org.knime.workbench.workflowcoach.NodeRecommendationManager.IUpdateListener) TableViewer(org.eclipse.jface.viewers.TableViewer) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) DND(org.eclipse.swt.dnd.DND) TableColumn(org.eclipse.swt.widgets.TableColumn) IToolBarManager(org.eclipse.jface.action.IToolBarManager) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) NodeContainer(org.knime.core.node.workflow.NodeContainer) IStatus(org.eclipse.core.runtime.IStatus) ISelectionListener(org.eclipse.ui.ISelectionListener) Composite(org.eclipse.swt.widgets.Composite) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) Cursor(org.eclipse.swt.graphics.Cursor) IEditorPart(org.eclipse.ui.IEditorPart) NodeProvider(org.knime.workbench.core.nodeprovider.NodeProvider) KNIMEJob(org.knime.core.util.KNIMEJob) CommunityTripleProvider(org.knime.workbench.workflowcoach.data.CommunityTripleProvider) PlatformUI(org.eclipse.ui.PlatformUI) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) Display(org.eclipse.swt.widgets.Display) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore) NodeModel(org.knime.core.node.NodeModel) Collectors(java.util.stream.Collectors) WorkflowCoachPreferenceInitializer(org.knime.workbench.workflowcoach.prefs.WorkflowCoachPreferenceInitializer) RepositoryManager(org.knime.workbench.repository.RepositoryManager) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Transfer(org.eclipse.swt.dnd.Transfer) IElementComparer(org.eclipse.jface.viewers.IElementComparer) MouseEvent(org.eclipse.swt.events.MouseEvent) List(java.util.List) MouseListener(org.eclipse.swt.events.MouseListener) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) Wrapper(org.knime.core.ui.wrapper.Wrapper) SWT(org.eclipse.swt.SWT) Optional(java.util.Optional) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MouseAdapter(org.eclipse.swt.events.MouseAdapter) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) ViewPart(org.eclipse.ui.part.ViewPart) WorkflowEditor(org.knime.workbench.editor2.WorkflowEditor) LocalDateTime(java.time.LocalDateTime) Table(org.eclipse.swt.widgets.Table) AtomicReference(java.util.concurrent.atomic.AtomicReference) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) Pair(org.knime.core.util.Pair) HashSet(java.util.HashSet) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) UpdateJob(org.knime.workbench.workflowcoach.prefs.UpdateJob) UpdatableNodeTripleProvider(org.knime.workbench.workflowcoach.data.UpdatableNodeTripleProvider) NodeLogger(org.knime.core.node.NodeLogger) GridData(org.eclipse.swt.layout.GridData) NodeRecommendationManager(org.knime.workbench.workflowcoach.NodeRecommendationManager) HeadlessPreferencesConstants(org.knime.workbench.core.preferences.HeadlessPreferencesConstants) NodeFactory(org.knime.core.node.NodeFactory) CombinatoricsUtils(org.apache.commons.math3.util.CombinatoricsUtils) Iterator(java.util.Iterator) Job(org.eclipse.core.runtime.jobs.Job) KNIMECorePlugin(org.knime.workbench.core.KNIMECorePlugin) NodeTemplate(org.knime.workbench.repository.model.NodeTemplate) ChronoUnit(java.time.temporal.ChronoUnit) UpdateListener(org.knime.workbench.workflowcoach.prefs.UpdateJob.UpdateListener) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) NodeRecommendation(org.knime.workbench.workflowcoach.NodeRecommendationManager.NodeRecommendation) Comparator(java.util.Comparator) Collections(java.util.Collections) FrameworkUtil(org.osgi.framework.FrameworkUtil) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) IElementComparer(org.eclipse.jface.viewers.IElementComparer) ISelection(org.eclipse.jface.viewers.ISelection) IEditorPart(org.eclipse.ui.IEditorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 48 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project eclipse.platform.swt by eclipse.

the class LauncherView method launchItem.

/**
 * Runs the specified launch item.
 *
 * @param itemDescriptor the launch item to execute
 */
private void launchItem(ItemDescriptor itemDescriptor) {
    /* Case 1: The launch item is a view */
    String pluginViewId = itemDescriptor.getView();
    if (pluginViewId != null) {
        final IWorkbenchPart workbenchPart = this;
        final IWorkbenchPartSite workbenchPartSite = workbenchPart.getSite();
        final IWorkbenchPage workbenchPage = workbenchPartSite.getPage();
        try {
            workbenchPage.showView(pluginViewId);
        } catch (PartInitException e) {
            LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.Invocation"), e);
        }
        return;
    }
    /* Case 2: The launch item is a standalone program */
    if (workbenchShell == null)
        return;
    try {
        Object instance = itemDescriptor.createItemInstance();
        if (instance != null) {
            Display display = workbenchShell.getDisplay();
            Method openMethod = instance.getClass().getDeclaredMethod("open", new Class[] { Display.class });
            openMethod.invoke(instance, display);
        }
    } catch (NoSuchMethodException e) {
        LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.DoesNotImplementMethod"), null);
    } catch (Exception e) {
        LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.CouldNotInstantiateClass"), e);
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) Method(java.lang.reflect.Method) PartInitException(org.eclipse.ui.PartInitException) Display(org.eclipse.swt.widgets.Display)

Example 49 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project tmdm-studio-se by Talend.

the class EntityCommitHandler method updateReferenceForNewName.

private void updateReferenceForNewName(XSDElementDeclaration xsdElementDeclaration, String oldName) {
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IWorkbenchPartSite site = activePage.getActivePart().getSite();
    SchemaTreeContentProvider contentProvider = new SchemaTreeContentProvider(site, getCommitedObj().getSchema());
    Object[] objs = Util.getAllObject(site, new ArrayList<Object>(), contentProvider);
    Object[] allForeignKeyAndInfos = Util.getAllForeignKeyRelatedInfos(site, new ArrayList<Object>(), contentProvider, new HashSet<Object>());
    String newName = getCommitedObj().getName();
    Util.updateReference(xsdElementDeclaration, objs, allForeignKeyAndInfos, oldName, newName);
    EntitySyncProcessor.syncNameForAnnotation(xsdElementDeclaration, oldName, newName);
    xsdElementDeclaration.updateElement();
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) SchemaTreeContentProvider(com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 50 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project tmdm-studio-se by Talend.

the class NewViewAction method doRun.

@Override
protected void doRun() {
    updateParentItem();
    int type = getType();
    IWorkbenchPartSite site = commonViewer.getCommonNavigator().getSite();
    ViewInputDialog2 vid = new ViewInputDialog2(site, getShell(), getDialogTitle(), Messages.Common_inputName, getInputValidator(), false, type);
    vid.setBtnShow(true);
    vid.create();
    vid.getShell().setSize(new Point(500, 320));
    vid.setBlockOnOpen(true);
    if (vid.open() == Window.CANCEL) {
        return;
    }
    String key = vid.getEntityName();
    String filterName = vid.getFilterName();
    Item item = null;
    if (filterName == null) {
        item = createServerObject(key);
    } else {
        // $NON-NLS-1$
        String filterPart = "";
        if (!filterName.isEmpty()) {
            // $NON-NLS-1$
            filterPart = "#" + filterName;
        }
        item = createServerObject(PREFIX_VIEW_UPPER + key + filterPart);
    }
    commonViewer.refresh(selectObj);
    commonViewer.expandToLevel(selectObj, 1);
    openEditor(item);
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Item(org.talend.core.model.properties.Item) WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ViewInputDialog2(org.talend.mdm.repository.ui.dialogs.ViewInputDialog2) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Aggregations

IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)73 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)13 ISelection (org.eclipse.jface.viewers.ISelection)12 IEditorPart (org.eclipse.ui.IEditorPart)12 ArrayList (java.util.ArrayList)10 MenuManager (org.eclipse.jface.action.MenuManager)9 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 Composite (org.eclipse.swt.widgets.Composite)9 Display (org.eclipse.swt.widgets.Display)9 Shell (org.eclipse.swt.widgets.Shell)9 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)9 Menu (org.eclipse.swt.widgets.Menu)7 IEditorSite (org.eclipse.ui.IEditorSite)7 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)7 SWT (org.eclipse.swt.SWT)6 PartInitException (org.eclipse.ui.PartInitException)6 List (java.util.List)5 IToolBarManager (org.eclipse.jface.action.IToolBarManager)4 Separator (org.eclipse.jface.action.Separator)4