Search in sources :

Example 11 with IAction

use of de.janrufmonitor.ui.jface.application.action.IAction in project janrufmonitor by tbrandt77.

the class OpenJournalAction method getSubActions.

public IAction[] getSubActions() {
    List localCallManagers = getRuntime().getCallManagerFactory().getTypedCallManagers(ILocalRepository.class);
    List remoteCallManagers = getRuntime().getCallManagerFactory().getTypedCallManagers(IRemoteRepository.class);
    IAction[] actions = new IAction[localCallManagers.size() + (remoteCallManagers.size() > 0 ? remoteCallManagers.size() : 0)];
    for (int i = 0; i < localCallManagers.size(); i++) {
        actions[i] = new LocalAction((ILocalRepository) localCallManagers.get(i));
    }
    if (remoteCallManagers.size() > 0)
        for (int i = 0; i < remoteCallManagers.size(); i++) {
            actions[i + localCallManagers.size()] = new RemoteAction((IRemoteRepository) remoteCallManagers.get(i));
        }
    return actions;
}
Also used : IAction(de.janrufmonitor.ui.jface.application.action.IAction) ILocalRepository(de.janrufmonitor.repository.types.ILocalRepository) ArrayList(java.util.ArrayList) List(java.util.List)

Example 12 with IAction

use of de.janrufmonitor.ui.jface.application.action.IAction in project janrufmonitor by tbrandt77.

the class AbstractMenuBuilder method addAction.

protected void addAction(MenuManager m, String id) {
    if (id == null)
        return;
    if (id.startsWith(AbstractMenuBuilder.SEPARATOR_SIGN)) {
        this.addSeparator(m);
        return;
    }
    IAction a = ActionRegistry.getInstance().getAction(id, this.m_app);
    if (a != null) {
        if (a.hasSubActions() && a instanceof AbstractAction) {
            IAction[] subActions = a.getSubActions();
            if (subActions != null && subActions.length > 0) {
                MenuManager subActionsMenu = new MenuManager(((AbstractAction) a).getText());
                m.add(subActionsMenu);
                for (int i = 0; i < subActions.length; i++) {
                    subActionsMenu.add((org.eclipse.jface.action.IAction) subActions[i]);
                }
            }
        } else {
            m.add((org.eclipse.jface.action.IAction) a);
            this.m_logger.info("Added menu entry <" + id + "> to " + this.m_app.getID());
        }
    }
}
Also used : IAction(de.janrufmonitor.ui.jface.application.action.IAction) MenuManager(org.eclipse.jface.action.MenuManager)

Example 13 with IAction

use of de.janrufmonitor.ui.jface.application.action.IAction in project janrufmonitor by tbrandt77.

the class AbstractTreeTableApplication method createContents.

protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));
    List actions = this.getMenuBuilder().getToolbarActions();
    if (this.isShowToolbar() && actions != null && actions.size() > 0 && this.getToolBarManager() != null) {
        ToolBar tb = this.getToolBarManager().createControl(composite);
        for (int i = 0, j = actions.size(); i < j; i++) {
            final org.eclipse.jface.action.IAction a = (org.eclipse.jface.action.IAction) actions.get(i);
            if (a != null && a.getImageDescriptor() != null) {
                ToolItem ti = new ToolItem(tb, SWT.PUSH);
                Image img = (a).getImageDescriptor().createImage();
                ti.setImage(img);
                ti.setText(a.getText());
                if (a instanceof AbstractAction) {
                    ti.setText(((AbstractAction) a).getShortText());
                }
                ti.setToolTipText(a.getToolTipText());
                ti.addSelectionListener(new SelectionAdapter() {

                    public void widgetSelected(SelectionEvent e) {
                        a.run();
                    }
                });
            }
        }
    }
    addRenderBeforeTableHooks(composite);
    // add filter capability
    Composite line = new Composite(composite, SWT.NONE);
    line.setLayout(new GridLayout(6, false));
    if (this.getFilterManager() != null) {
        Composite view = new Composite(line, SWT.NONE);
        view.setLayout(new GridLayout(2, false));
        new Label(view, SWT.NONE).setText(this.getI18nManager().getString(this.getNamespace(), "current_view", "label", this.getLanguage()));
        new Label(view, SWT.NONE);
        this.currentView = new Combo(view, SWT.READ_ONLY | SWT.FLAT);
        this.currentView.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                String filterName = currentView.getItem(currentView.getSelectionIndex());
                IFilter[] selectedFilters = (IFilter[]) currentView.getData(filterName);
                getApplication().getConfiguration().setProperty(CFG_FILTER, getFilterManager().getFiltersToString(selectedFilters));
                getApplication().storeConfiguration();
                updateViews(true);
            }
        });
        if (getFilterAction() != null) {
            Button filterAction = new Button(view, SWT.PUSH);
            filterAction.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent e) {
                    de.janrufmonitor.ui.jface.application.action.IAction action = getFilterAction();
                    if (action != null)
                        action.run();
                }
            });
            filterAction.setImage(SWTImageManager.getInstance(this.getRuntime()).get(IJAMConst.IMAGE_KEY_FILTER_GIF));
            filterAction.pack();
        }
    }
    final de.janrufmonitor.ui.jface.application.action.IAction action = getQuickSearchAction();
    if (this.isShowQuickSearch() && action != null) {
        Composite view = new Composite(line, SWT.NONE);
        view.setLayout(new GridLayout(2, false));
        new Label(view, SWT.NONE).setText(this.getI18nManager().getString(this.getNamespace(), "quicksearch", "label", this.getLanguage()));
        new Label(view, SWT.NONE);
        final Combo search = new Combo(view, SWT.FLAT);
        final String empty = this.getConfiguration().getProperty(CFG_SEARCHTERMS, "");
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.minimumWidth = 300;
        search.setLayoutData(gd);
        search.add(empty);
        final List sh = this.getSearchHistory();
        for (int i = 0; i < sh.size(); i++) {
            if (!empty.equalsIgnoreCase((String) sh.get(i)))
                search.add((String) sh.get(i));
        }
        search.select(0);
        search.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                action.setData(search.getText());
                action.run();
            }
        });
        search.setToolTipText(this.getI18nManager().getString(this.getNamespace(), "quicksearch", "description", this.getLanguage()));
        search.addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent e) {
                if (e.character == 13) {
                    action.setData(search.getText());
                    if (!sh.contains(search.getText())) {
                        sh.add(search.getText());
                        search.add(search.getText());
                    }
                    setSearchHistory(sh);
                    action.run();
                }
            }
        });
    }
    Tree t = new Tree(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
    viewer = new TreeViewer(t);
    Tree tree = ((TreeViewer) viewer).getTree();
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    tree.setHeaderVisible(true);
    tree.addTreeListener(new TreeAdapter() {

        public void treeExpanded(TreeEvent e) {
            if (e.item != null) {
                TreeItem item = (TreeItem) e.item;
                TreeItem[] items = item.getItems();
                for (int i = 0; i < items.length; i++) {
                    items[i].setBackground(item.getBackground());
                    items[i].setForeground(item.getForeground());
                }
            }
        }
    });
    this.updateProviders();
    // added drag and drop feature
    if (this.getDropTargetHandler() != null) {
        int operations = DND.DROP_MOVE;
        Transfer[] types = new Transfer[] { FileTransfer.getInstance() };
        DropTarget target = new DropTarget(tree, operations);
        target.setTransfer(types);
        target.addDropListener(new DropTargetAdapter() {

            public void drop(DropTargetEvent event) {
                // A drop has occurred, copy over the data
                if (event.data == null) {
                    event.detail = DND.DROP_NONE;
                    return;
                }
                getDropTargetHandler().execute((String[]) event.data);
            }
        });
    }
    FontData tableFontData = tree.getFont().getFontData()[0];
    int size = Integer.parseInt(this.getConfiguration().getProperty(CFG_FONT_SIZE, "8"));
    tree.setFont(this.getSizedFont(tableFontData, size, false));
    AbstractMenuBuilder mb = this.getMenuBuilder();
    if (mb != null)
        tree.setMenu(mb.createPopupMenu(tree));
    tree.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.DEL) {
                de.janrufmonitor.ui.jface.application.action.IAction action = getDeleteAction();
                if (action != null)
                    action.run();
            }
        }
    });
    tree.addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent e) {
            de.janrufmonitor.ui.jface.application.action.IAction action = getAssignAction();
            if (action != null)
                action.run();
        }
    });
    // 2006/08/02: this is a workaround: No multiple line in table possibe
    Listener paintListener = new Listener() {

        int name_column = getColumnNumber("name");

        int address_column = getColumnNumber("address");

        public void handleEvent(Event event) {
            if (event.index != name_column && event.index != address_column)
                return;
            switch(event.type) {
                case SWT.MeasureItem:
                    {
                        TreeItem item = (TreeItem) event.item;
                        String text = item.getText(event.index);
                        Point size = event.gc.textExtent(text);
                        event.width = size.x;
                        event.height = Math.max(event.height, size.y + 7);
                        break;
                    }
                case SWT.PaintItem:
                    {
                        TreeItem item = (TreeItem) event.item;
                        String text = item.getText(event.index);
                        Point size = event.gc.textExtent(text);
                        int offset2 = (event.index == 0 ? Math.max(0, (event.height - size.y) / 2) : 0) + 3;
                        event.gc.drawText(text, event.x + offset2, event.y + offset2, true);
                        break;
                    }
                case SWT.EraseItem:
                    {
                        event.detail &= ~SWT.FOREGROUND;
                        TreeItem item = (TreeItem) event.item;
                        event.gc.setBackground(item.getBackground(event.index));
                        event.gc.setForeground(item.getForeground(event.index));
                        break;
                    }
            }
        }
    };
    tree.addListener(SWT.MeasureItem, paintListener);
    tree.addListener(SWT.PaintItem, paintListener);
    tree.addListener(SWT.EraseItem, paintListener);
    addRenderAfterTableHooks(composite);
    tree.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (e.widget instanceof Tree) {
                TreeItem[] selectedItems = ((Tree) e.widget).getSelection();
                if (selectedItems != null && selectedItems.length > 0)
                    lastMarkedTreeItem = ((Tree) e.widget).indexOf(selectedItems[0]);
                else
                    lastMarkedTreeItem = -1;
            }
        }
    });
    updateViews(true);
    List startupActions = this.getMenuBuilder().getStartupActions();
    if (startupActions != null && startupActions.size() > 0) {
        IAction a = null;
        for (int i = 0, j = startupActions.size(); i < j; i++) {
            a = (IAction) startupActions.get(i);
            if (a != null) {
                a.setApplication(this);
                a.run();
            }
        }
    }
    return composite;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) TreeAdapter(org.eclipse.swt.events.TreeAdapter) Image(org.eclipse.swt.graphics.Image) KeyEvent(org.eclipse.swt.events.KeyEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) List(java.util.List) ArrayList(java.util.ArrayList) ToolItem(org.eclipse.swt.widgets.ToolItem) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) IAction(de.janrufmonitor.ui.jface.application.action.IAction) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FontData(org.eclipse.swt.graphics.FontData) MouseAdapter(org.eclipse.swt.events.MouseAdapter) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) IAction(de.janrufmonitor.ui.jface.application.action.IAction) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) IFilter(de.janrufmonitor.repository.filter.IFilter) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) Transfer(org.eclipse.swt.dnd.Transfer) FileTransfer(org.eclipse.swt.dnd.FileTransfer) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 14 with IAction

use of de.janrufmonitor.ui.jface.application.action.IAction in project janrufmonitor by tbrandt77.

the class AbstractTableApplication method createContents.

protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));
    if (this.getMenuBuilder() != null) {
        List actions = this.getMenuBuilder().getToolbarActions();
        if (this.isShowToolbar() && actions != null && actions.size() > 0 && this.getToolBarManager() != null) {
            ToolBar tb = this.getToolBarManager().createControl(composite);
            for (int i = 0, j = actions.size(); i < j; i++) {
                final org.eclipse.jface.action.IAction a = (org.eclipse.jface.action.IAction) actions.get(i);
                if (a != null && a.getImageDescriptor() != null) {
                    ToolItem ti = new ToolItem(tb, SWT.PUSH);
                    Image img = (a).getImageDescriptor().createImage();
                    ti.setImage(img);
                    ti.setText(a.getText());
                    if (a instanceof AbstractAction) {
                        ti.setText(((AbstractAction) a).getShortText());
                    }
                    ti.setToolTipText(a.getToolTipText());
                    ti.addSelectionListener(new SelectionAdapter() {

                        public void widgetSelected(SelectionEvent e) {
                            a.run();
                        }
                    });
                }
            }
        }
    }
    addRenderBeforeTableHooks(composite);
    // add filter capability
    Composite line = new Composite(composite, SWT.NONE);
    line.setLayout(new GridLayout(6, false));
    if (this.getFilterManager() != null && this.getConfiguration().getProperty(CFG_ENABLE_FILTER_VIEW, "true").equalsIgnoreCase("true")) {
        Composite view = new Composite(line, SWT.NONE);
        view.setLayout(new GridLayout(2, false));
        new Label(view, SWT.NONE).setText(this.getI18nManager().getString(this.getNamespace(), "current_view", "label", this.getLanguage()));
        new Label(view, SWT.NONE);
        this.currentView = new Combo(view, SWT.READ_ONLY | SWT.FLAT);
        this.currentView.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                String filterName = currentView.getItem(currentView.getSelectionIndex());
                IFilter[] selectedFilters = (IFilter[]) currentView.getData(filterName);
                getApplication().getConfiguration().setProperty(CFG_FILTER, getFilterManager().getFiltersToString(selectedFilters));
                getApplication().storeConfiguration();
                updateViews(true);
            }
        });
        if (getFilterAction() != null) {
            Button filterAction = new Button(view, SWT.PUSH);
            filterAction.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent e) {
                    de.janrufmonitor.ui.jface.application.action.IAction action = getFilterAction();
                    if (action != null)
                        action.run();
                }
            });
            filterAction.setImage(SWTImageManager.getInstance(this.getRuntime()).get(IJAMConst.IMAGE_KEY_FILTER_GIF));
            filterAction.pack();
        }
    }
    final de.janrufmonitor.ui.jface.application.action.IAction action = getQuickSearchAction();
    if (this.isShowQuickSearch() && action != null) {
        Composite view = new Composite(line, SWT.NONE);
        view.setLayout(new GridLayout(2, false));
        new Label(view, SWT.NONE).setText(this.getI18nManager().getString(this.getNamespace(), "quicksearch", "label", this.getLanguage()));
        new Label(view, SWT.NONE);
        final Combo search = new Combo(view, SWT.FLAT);
        final String empty = this.getConfiguration().getProperty(CFG_SEARCHTERMS, "");
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.minimumWidth = 300;
        search.setLayoutData(gd);
        search.add(empty);
        final List sh = this.getSearchHistory();
        for (int i = 0; i < sh.size(); i++) {
            if (!empty.equalsIgnoreCase((String) sh.get(i)))
                search.add((String) sh.get(i));
        }
        search.select(0);
        search.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                action.setData(search.getText());
                action.run();
            }
        });
        search.setToolTipText(this.getI18nManager().getString(this.getNamespace(), "quicksearch", "description", this.getLanguage()));
        search.addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent e) {
                if (e.character == 13) {
                    action.setData(search.getText());
                    if (!sh.contains(search.getText())) {
                        sh.add(search.getText());
                        search.add(search.getText());
                    }
                    setSearchHistory(sh);
                    action.run();
                }
            }
        });
    }
    viewer = new TableViewer(composite, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI | SWT.VIRTUAL);
    final Table table = ((TableViewer) viewer).getTable();
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    table.setHeaderVisible(true);
    this.updateProviders();
    // added drag and drop feature
    if (this.getDropTargetHandler() != null) {
        int operations = DND.DROP_MOVE;
        Transfer[] types = new Transfer[] { FileTransfer.getInstance() };
        DropTarget target = new DropTarget(table, operations);
        target.setTransfer(types);
        target.addDropListener(new DropTargetAdapter() {

            public void drop(DropTargetEvent event) {
                // A drop has occurred, copy over the data
                if (event.data == null) {
                    event.detail = DND.DROP_NONE;
                    return;
                }
                getDropTargetHandler().execute((String[]) event.data);
            }
        });
    }
    FontData tableFontData = table.getFont().getFontData()[0];
    int size = Integer.parseInt(this.getConfiguration().getProperty(CFG_FONT_SIZE, "8"));
    table.setFont(this.getSizedFont(tableFontData, size, false));
    AbstractMenuBuilder mb = this.getMenuBuilder();
    if (mb != null)
        table.setMenu(mb.createPopupMenu(table));
    table.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.DEL) {
                de.janrufmonitor.ui.jface.application.action.IAction action = getDeleteAction();
                if (action != null && action instanceof org.eclipse.jface.action.IAction && ((org.eclipse.jface.action.IAction) action).isEnabled())
                    action.run();
            }
        }
    });
    table.addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent e) {
            de.janrufmonitor.ui.jface.application.action.IAction action = getAssignAction();
            if (action != null && action instanceof org.eclipse.jface.action.IAction && ((org.eclipse.jface.action.IAction) action).isEnabled())
                action.run();
        }
    });
    // 2006/08/02: this is a workaraound: No multiple line in table possibe
    Listener paintListener = new Listener() {

        int name_column = getColumnNumber("name");

        int address_column = getColumnNumber("address");

        int img_column = getColumnNumber("imagepreview");

        // removed 2010/02/17: do to usability notes column is not rendered with SWT.WRAP
        // int notes_column = getColumnNumber("notes");
        public void handleEvent(Event event) {
            if (event.index == img_column) {
                TableItem it = (TableItem) event.item;
                it.setText(event.index, IJAMConst.CRLF + IJAMConst.CRLF + IJAMConst.CRLF);
                switch(event.type) {
                    case SWT.MeasureItem:
                        {
                            TableItem item = (TableItem) event.item;
                            String text = item.getText(event.index);
                            Point size = event.gc.textExtent(text);
                            event.width = size.x;
                            event.height = Math.max(event.height, size.y + 7);
                            break;
                        }
                    case SWT.PaintItem:
                        {
                            TableItem item = (TableItem) event.item;
                            String text = item.getText(event.index);
                            Point size = event.gc.textExtent(text);
                            int offset2 = (event.index == 0 ? Math.max(0, (event.height - size.y) / 2) : 0) + 3;
                            event.gc.drawText(text, event.x + offset2, event.y + offset2, true);
                            break;
                        }
                    case SWT.EraseItem:
                        {
                            event.detail &= ~SWT.FOREGROUND;
                            break;
                        }
                }
                return;
            }
            if (event.index != name_column && event.index != address_column)
                /**
                 *&& event.index!=notes_column
                 */
                return;
            switch(event.type) {
                case SWT.MeasureItem:
                    {
                        TableItem item = (TableItem) event.item;
                        String text = item.getText(event.index);
                        Point size = event.gc.textExtent(text);
                        event.width = size.x;
                        event.height = Math.max(event.height, size.y + 7);
                        break;
                    }
                case SWT.PaintItem:
                    {
                        TableItem item = (TableItem) event.item;
                        String text = item.getText(event.index);
                        Point size = event.gc.textExtent(text);
                        int offset2 = (event.index == 0 ? Math.max(0, (event.height - size.y) / 2) : 0) + 3;
                        event.gc.drawText(text, event.x + offset2, event.y + offset2, true);
                        break;
                    }
                case SWT.EraseItem:
                    {
                        event.detail &= ~SWT.FOREGROUND;
                        break;
                    }
            }
        }
    };
    table.addListener(SWT.MeasureItem, paintListener);
    table.addListener(SWT.PaintItem, paintListener);
    table.addListener(SWT.EraseItem, paintListener);
    // table.addListener(SWT.SetData, new Listener() {
    // 
    // public void handleEvent(Event e) {
    // TableItem item = (TableItem)e.item;
    // int index = table.indexOf(item);
    // item.setText("Item "+index);
    // 
    // }
    // 
    // });
    addRenderAfterTableHooks(composite);
    table.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (e.widget instanceof Table) {
                lastMarkedRow = ((Table) e.widget).getSelectionIndex();
            }
        }
    });
    updateViews(true);
    if (this.getMenuBuilder() != null) {
        List startupActions = this.getMenuBuilder().getStartupActions();
        if (startupActions != null && startupActions.size() > 0) {
            IAction a = null;
            for (int i = 0, j = startupActions.size(); i < j; i++) {
                a = (IAction) startupActions.get(i);
                if (a != null) {
                    a.setApplication(this);
                    a.run();
                }
            }
        }
    }
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ArrayList(java.util.ArrayList) List(java.util.List) IAction(de.janrufmonitor.ui.jface.application.action.IAction) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) IAction(de.janrufmonitor.ui.jface.application.action.IAction) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) IFilter(de.janrufmonitor.repository.filter.IFilter) GridData(org.eclipse.swt.layout.GridData) FileTransfer(org.eclipse.swt.dnd.FileTransfer) Transfer(org.eclipse.swt.dnd.Transfer) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTarget(org.eclipse.swt.dnd.DropTarget) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 15 with IAction

use of de.janrufmonitor.ui.jface.application.action.IAction in project janrufmonitor by tbrandt77.

the class ActionRegistry method getAction.

public synchronized IAction getAction(String id, IApplication app) {
    String key = id + app.getID();
    if (this.m_actions.containsKey(key)) {
        IAction action = (IAction) this.m_actions.get(key);
        action.setApplication(app);
        return action;
    }
    String className = this.m_configuration.getProperty(PARAMETERNAME + id, "");
    if (className.length() > 0) {
        try {
            Class classObject = Thread.currentThread().getContextClassLoader().loadClass(className);
            IAction action = (IAction) classObject.newInstance();
            action.setApplication(app);
            action.setID(id);
            this.m_actions.put(key, action);
            return action;
        } catch (ClassNotFoundException ex) {
            this.m_logger.severe("Could not find class: " + className);
        } catch (InstantiationException ex) {
            this.m_logger.severe("Could not instantiate class: " + className);
        } catch (IllegalAccessException ex) {
            this.m_logger.severe("Could not access class: " + className);
        } catch (Exception e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
    return null;
}
Also used : IAction(de.janrufmonitor.ui.jface.application.action.IAction)

Aggregations

IAction (de.janrufmonitor.ui.jface.application.action.IAction)17 List (java.util.List)13 ArrayList (java.util.ArrayList)10 IFilter (de.janrufmonitor.repository.filter.IFilter)4 ILocalRepository (de.janrufmonitor.repository.types.ILocalRepository)4 Message (de.janrufmonitor.exception.Message)2 ITracker (de.janrufmonitor.repository.imexport.ITracker)2 SWTExecuter (de.janrufmonitor.ui.swt.SWTExecuter)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Comparator (java.util.Comparator)2 Iterator (java.util.Iterator)2 Properties (java.util.Properties)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 DropTarget (org.eclipse.swt.dnd.DropTarget)2 DropTargetAdapter (org.eclipse.swt.dnd.DropTargetAdapter)2 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)2 FileTransfer (org.eclipse.swt.dnd.FileTransfer)2 Transfer (org.eclipse.swt.dnd.Transfer)2