Search in sources :

Example 1 with IAction

use of org.eclipse.jface.action.IAction in project tdi-studio-se by Talend.

the class CodeView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    this.parent = parent;
    parent.setLayout(new FillLayout());
    ECodeLanguage language = LanguageManager.getCurrentLanguage();
    ISourceViewer viewer = null;
    final StyledText text;
    int styles = SWT.H_SCROLL | SWT.V_SCROLL;
    document = new Document();
    switch(language) {
        case JAVA:
            IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
            viewer = new JavaSourceViewer(parent, null, null, false, styles, store);
            viewer.setDocument(document);
            JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools();
            tools.setupJavaDocumentPartitioner(viewer.getDocument(), IJavaPartitions.JAVA_PARTITIONING);
            SimpleJavaSourceViewerConfiguration config = new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, true);
            viewer.configure(config);
            viewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
            document = viewer.getDocument();
            break;
        // empty since only have java
        default:
    }
    viewer.setEditable(false);
    text = viewer.getTextWidget();
    // getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
    IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
    IAction wrapAction = new Action() {

        @Override
        public void run() {
            text.setWordWrap(isChecked());
        }
    };
    //$NON-NLS-1$
    wrapAction.setToolTipText("wrap");
    wrapAction.setChecked(false);
    //$NON-NLS-1$
    wrapAction.setImageDescriptor(ImageDescriptor.createFromFile(DesignerPlugin.class, "/icons/wrap.gif"));
    tbm.add(wrapAction);
    createMenu();
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) StyledText(org.eclipse.swt.custom.StyledText) SimpleJavaSourceViewerConfiguration(org.eclipse.jdt.internal.ui.text.SimpleJavaSourceViewerConfiguration) IAction(org.eclipse.jface.action.IAction) JavaTextTools(org.eclipse.jdt.ui.text.JavaTextTools) FillLayout(org.eclipse.swt.layout.FillLayout) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) DesignerPlugin(org.talend.designer.core.DesignerPlugin) JavaSourceViewer(org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 2 with IAction

use of org.eclipse.jface.action.IAction in project tdi-studio-se by Talend.

the class ErDiagramMenuProvider method buildContextMenu.

@Override
public void buildContextMenu(IMenuManager menu) {
    menu.add(new Separator(RELATION));
    menu.add(new Separator(GEFActionConstants.GROUP_EDIT));
    IAction action;
    action = getAction(ActionFactory.DELETE.getId());
    ((ErDiagramItemDeleteAction) action).update();
    if (action.isEnabled()) {
        menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    }
    CreateRelationAction createRelation;
    createRelation = new CreateRelationAction(part);
    createRelation.update();
    if (createRelation.isEnabled()) {
        menu.add(createRelation);
    }
    TableAddAction addAction = new TableAddAction(part);
    addAction.update();
    menu.add(addAction);
}
Also used : TableAddAction(org.talend.sqlbuilder.erdiagram.ui.actions.TableAddAction) IAction(org.eclipse.jface.action.IAction) ErDiagramItemDeleteAction(org.talend.sqlbuilder.erdiagram.ui.actions.ErDiagramItemDeleteAction) CreateRelationAction(org.talend.sqlbuilder.erdiagram.ui.actions.CreateRelationAction) Separator(org.eclipse.jface.action.Separator)

Example 3 with IAction

use of org.eclipse.jface.action.IAction in project tdi-studio-se by Talend.

the class DBTreeActionGroup method fillContextMenu.

/**
     * Fill the node context menu with all the correct actions.
     * 
     * @param menu MenuManager.
     * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public void fillContextMenu(IMenuManager menu) {
    // find our target node..
    IStructuredSelection selection = (IStructuredSelection) pTreeViewer.getSelection();
    // check if we have a valid selection
    if (selection == null) {
        return;
    }
    ArrayList selectedNodes = new ArrayList();
    Iterator it = selection.iterator();
    while (it.hasNext()) {
        Object object = it.next();
        if (object instanceof INode) {
            selectedNodes.add(object);
        }
    }
    if (selectedNodes.size() == 0) {
        return;
    }
    INode[] nodes = (INode[]) selectedNodes.toArray(new INode[] {});
    IAction[] actions = getContextActions(nodes);
    for (int i = 0; i < actions.length; i++) {
        menu.add(actions[i]);
    }
}
Also used : INode(org.talend.sqlbuilder.dbstructure.nodes.INode) IAction(org.eclipse.jface.action.IAction) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 4 with IAction

use of org.eclipse.jface.action.IAction in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method turnToJobScriptPage.

protected void turnToJobScriptPage(int newPageIndex) {
    if (jobletEditor != getEditor(newPageIndex)) {
        return;
    }
    ICreateXtextProcessService convertJobtoScriptService = CorePlugin.getDefault().getCreateXtextProcessService();
    try {
        final String scriptValue = convertJobtoScriptService.convertJobtoScript(getProcess().saveXmlFile());
        IFile file = (IFile) jobletEditor.getEditorInput().getAdapter(IResource.class);
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(scriptValue.getBytes());
        if (file.exists()) {
            jobletEditor.getDocumentProvider().getDocument(jobletEditor.getEditorInput()).set(scriptValue);
            boolean isProcessReadOnly = ((JobEditorInput) getEditor(0).getEditorInput()).isReadOnly();
            IProxyRepositoryFactory rFactory = ProxyRepositoryFactory.getInstance();
            if (isProcessReadOnly || rFactory.isUserReadOnlyOnCurrentProject()) {
                IDocumentProvider provider = jobletEditor.getDocumentProvider();
                Class p = provider.getClass();
                Class[] type = new Class[1];
                type[0] = Boolean.TYPE;
                Object[] para = new Object[1];
                para[0] = Boolean.TRUE;
                Method method = p.getMethod("setReadOnly", type);
                method.invoke(provider, para);
            }
            //$NON-NLS-1$
            IAction action = jobletEditor.getAction("FoldingRestore");
            action.run();
            jobletEditor.doSave(null);
        } else {
            file.create(byteArrayInputStream, true, null);
        }
        if (propertyListener == null) {
            propertyListener = new IPropertyListener() {

                @Override
                public void propertyChanged(Object source, int propId) {
                    if (source instanceof IEditorPart && ((IEditorPart) source).isDirty()) {
                        getProcess().setProcessModified(true);
                        getProcess().setNeedRegenerateCode(true);
                    }
                }
            };
            jobletEditor.addPropertyListener(propertyListener);
        }
    } catch (PartInitException e) {
        ExceptionHandler.process(e);
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    } catch (IOException e) {
        ExceptionHandler.process(e);
    } catch (SecurityException e) {
        ExceptionHandler.process(e);
    } catch (NoSuchMethodException e) {
        ExceptionHandler.process(e);
    } catch (IllegalArgumentException e) {
        ExceptionHandler.process(e);
    } catch (IllegalAccessException e) {
        ExceptionHandler.process(e);
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
    }
    changeContextsViewStatus(false);
}
Also used : IFile(org.eclipse.core.resources.IFile) ICreateXtextProcessService(org.talend.core.services.ICreateXtextProcessService) IPropertyListener(org.eclipse.ui.IPropertyListener) PartInitException(org.eclipse.ui.PartInitException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IAction(org.eclipse.jface.action.IAction) Method(java.lang.reflect.Method) IEditorPart(org.eclipse.ui.IEditorPart) IOException(java.io.IOException) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) InvocationTargetException(java.lang.reflect.InvocationTargetException) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) IResource(org.eclipse.core.resources.IResource)

Example 5 with IAction

use of org.eclipse.jface.action.IAction in project tdi-studio-se by Talend.

the class AbstractTalendEditor method configureGraphicalViewer.

@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    /** * Manage the view in the Outline ** */
    ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
    viewer.setSelectionManager(new TalendSelectionManager());
    TalendScalableFreeformRootEditPart root = new TalendScalableFreeformRootEditPart(getEditorInput());
    List<String> zoomLevels = new ArrayList<String>();
    zoomLevels.add(ZoomManager.FIT_ALL);
    zoomLevels.add(ZoomManager.FIT_WIDTH);
    zoomLevels.add(ZoomManager.FIT_HEIGHT);
    root.getZoomManager().setZoomLevelContributions(zoomLevels);
    // root.getZoomManager().setZoomAnimationStyle(ZoomManager.ANIMATE_NEVER);
    IAction zoomIn = new ZoomInAction(root.getZoomManager());
    IAction zoomOut = new ZoomOutAction(root.getZoomManager());
    getActionRegistry().registerAction(zoomIn);
    getActionRegistry().registerAction(zoomOut);
    IHandlerService service = (IHandlerService) getEditorSite().getService(IHandlerService.class);
    service.activateHandler(zoomIn.getActionDefinitionId(), new ActionHandler(zoomIn));
    service.activateHandler(zoomOut.getActionDefinitionId(), new ActionHandler(zoomOut));
    IAction directEditAction = new DirectEditAction(this);
    getActionRegistry().registerAction(directEditAction);
    getSelectionActions().add(directEditAction.getId());
    IAction copyAction = new GEFCopyAction(this);
    getActionRegistry().registerAction(copyAction);
    getSelectionActions().add(copyAction.getId());
    // setAction(copyAction.getId(), copyAction);
    IAction pasteAction = new GEFPasteAction(this);
    getActionRegistry().registerAction(pasteAction);
    getSelectionActions().add(pasteAction.getId());
    // setAction(pasteAction.getId(), pasteAction);
    IAction deleteAction = new GEFDeleteAction(this);
    getActionRegistry().registerAction(deleteAction);
    getSelectionActions().add(deleteAction.getId());
    // setAction(deleteAction.getId(), deleteAction);
    IAction undoAction = new GEFUndoAction(this);
    getActionRegistry().registerAction(undoAction);
    getSelectionActions().add(undoAction.getId());
    IAction redoAction = new GEFRedoAction(this);
    getActionRegistry().registerAction(redoAction);
    getSelectionActions().add(redoAction.getId());
    IAction setRefAction = new ConnectionSetAsMainRef(this);
    getActionRegistry().registerAction(setRefAction);
    getSelectionActions().add(setRefAction.getId());
    IAction modifyMergeAction = new ModifyMergeOrderAction(this);
    getActionRegistry().registerAction(modifyMergeAction);
    getSelectionActions().add(modifyMergeAction.getId());
    IAction modifyOutputOrderAction = new ModifyOutputOrderAction(this);
    getActionRegistry().registerAction(modifyOutputOrderAction);
    getSelectionActions().add(modifyOutputOrderAction.getId());
    List<IAction> calcOrderActions = ModifyConnectionOrderAction.getOrderActions(this);
    for (IAction orderAction : calcOrderActions) {
        getActionRegistry().registerAction(orderAction);
        getSelectionActions().add(orderAction.getId());
    }
    viewer.setRootEditPart(root);
    PartFactory partFactory = new PartFactory();
    // set the factory to use for creating EditParts for elements in the model
    getGraphicalViewer().setEditPartFactory(partFactory);
    getGraphicalViewer().setKeyHandler(new NodePartKeyHander(getGraphicalViewer()).setParent(getCommonKeyHandler()));
    // GraphicalViewer graViewer = getGraphicalViewer();
    // graViewer.setKeyHandler(new GraphicalViewerKeyHandler(graViewer));
    initializeActivationCodeTrigger();
    /** * Management of the context menu ** */
    ContextMenuProvider cmProvider = new TalendEditorContextMenuProvider(this, viewer, getActionRegistry());
    viewer.setContextMenu(cmProvider);
    /** * Management of the Zoom ** */
    /*
         * ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString()); if
         * (manager != null) { manager.setZoom(getProcess().getZoom()); }
         */
    // Scroll-wheel Zoom
    getGraphicalViewer().setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
    /** * Snap To Grid ** */
    // Grid properties
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(AbstractTalendEditor.GRID_SIZE, AbstractTalendEditor.GRID_SIZE));
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(true));
    // We keep grid visibility and enablement in sync
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(true));
    IAction showGrid = new ToggleGridAction(getGraphicalViewer());
    getActionRegistry().registerAction(showGrid);
    /** * Snap To Geometry ** */
    getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(false));
    IAction snapAction = new ToggleSnapToGeometryAction(getGraphicalViewer());
    getActionRegistry().registerAction(snapAction);
    configurationSubJob(viewer);
}
Also used : ModifyMergeOrderAction(org.talend.designer.core.ui.action.ModifyMergeOrderAction) ToggleSnapToGeometryAction(org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction) GEFCopyAction(org.talend.designer.core.ui.action.GEFCopyAction) GEFPasteAction(org.talend.designer.core.ui.action.GEFPasteAction) GEFDeleteAction(org.talend.designer.core.ui.action.GEFDeleteAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) ProcessTreePartFactory(org.talend.designer.core.ui.editor.outline.ProcessTreePartFactory) ArrayList(java.util.ArrayList) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider) ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) NodePartKeyHander(org.talend.designer.core.ui.NodePartKeyHander) ModifyOutputOrderAction(org.talend.designer.core.ui.action.ModifyOutputOrderAction) DirectEditAction(org.eclipse.gef.ui.actions.DirectEditAction) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) IAction(org.eclipse.jface.action.IAction) ConnectionSetAsMainRef(org.talend.designer.core.ui.action.ConnectionSetAsMainRef) ToggleGridAction(org.eclipse.gef.ui.actions.ToggleGridAction) GEFUndoAction(org.talend.designer.core.ui.action.GEFUndoAction) Dimension(org.eclipse.draw2d.geometry.Dimension) IHandlerService(org.eclipse.ui.handlers.IHandlerService) GEFRedoAction(org.talend.designer.core.ui.action.GEFRedoAction) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Aggregations

IAction (org.eclipse.jface.action.IAction)387 Action (org.eclipse.jface.action.Action)147 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)79 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)57 Separator (org.eclipse.jface.action.Separator)55 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)50 MenuManager (org.eclipse.jface.action.MenuManager)39 IMenuManager (org.eclipse.jface.action.IMenuManager)37 ArrayList (java.util.ArrayList)36 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)35 IContributionItem (org.eclipse.jface.action.IContributionItem)31 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)26 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)22 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)18 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)16 IToolBarManager (org.eclipse.jface.action.IToolBarManager)16 IEditorPart (org.eclipse.ui.IEditorPart)15 Point (org.eclipse.swt.graphics.Point)14 Iterator (java.util.Iterator)13 Menu (org.eclipse.swt.widgets.Menu)13