Search in sources :

Example 6 with CombinedTemplateCreationEntry

use of org.eclipse.gef.palette.CombinedTemplateCreationEntry in project cubrid-manager by CUBRID.

the class PaletteFactory method createComponentsDrawer.

/**
	 * create components drawer
	 * 
	 * @return drawer
	 */
private static PaletteContainer createComponentsDrawer() {
    PaletteDrawer drawer = new PaletteDrawer(Messages.lblReplComponent);
    drawer.setLargeIcon(CubridManagerUIPlugin.getImageDescriptor("icons/replication/replication.gif"));
    drawer.setSmallIcon(CubridManagerUIPlugin.getImageDescriptor("icons/replication/replication.gif"));
    List<ToolEntry> toolEntries = new ArrayList<ToolEntry>();
    ToolEntry toolEntry = new CombinedTemplateCreationEntry(Messages.lblHostTool, Messages.descHostTool, HostNode.class, new SimpleFactory(HostNode.class), CubridManagerUIPlugin.getImageDescriptor("icons/navigator/host.png"), CubridManagerUIPlugin.getImageDescriptor("icons/navigator/host.png"));
    toolEntries.add(toolEntry);
    toolEntry = new CombinedTemplateCreationEntry(Messages.lblMasterTool, Messages.descMasterTool, MasterNode.class, new SimpleFactory(MasterNode.class), CubridManagerUIPlugin.getImageDescriptor("icons/replication/master.png"), CubridManagerUIPlugin.getImageDescriptor("icons/replication/master.png"));
    toolEntries.add(toolEntry);
    toolEntry = new CombinedTemplateCreationEntry(Messages.lblDistributorTool, Messages.descDistributorTool, DistributorNode.class, new SimpleFactory(DistributorNode.class), CubridManagerUIPlugin.getImageDescriptor("icons/replication/distributor.gif"), CubridManagerUIPlugin.getImageDescriptor("icons/replication/distributor.gif"));
    toolEntries.add(toolEntry);
    toolEntry = new CombinedTemplateCreationEntry(Messages.lblSlaveTool, Messages.descSlaveTool, SlaveNode.class, new SimpleFactory(SlaveNode.class), CubridManagerUIPlugin.getImageDescriptor("icons/replication/slave.png"), CubridManagerUIPlugin.getImageDescriptor("icons/replication/slave.png"));
    toolEntries.add(toolEntry);
    drawer.addAll(toolEntries);
    return drawer;
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) ArrayList(java.util.ArrayList) SimpleFactory(org.eclipse.gef.requests.SimpleFactory) ToolEntry(org.eclipse.gef.palette.ToolEntry) SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) ConnectionCreationToolEntry(org.eclipse.gef.palette.ConnectionCreationToolEntry) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 7 with CombinedTemplateCreationEntry

use of org.eclipse.gef.palette.CombinedTemplateCreationEntry in project cubrid-manager by CUBRID.

the class ERSchemaToolBar method init.

/**
	 * Init items on the tool bar
	 */
public void init() {
    loginState = erSchemaEditor.getDatabase().isLogined();
    selectDbItem = new ToolItem(this, SWT.SEPARATOR);
    Composite comp = createSelectDbLabel();
    selectDbItem.setControl(comp);
    selectDbItem.setWidth(180);
    //model change
    ToolItem selectModelItem = new ToolItem(this, SWT.SEPARATOR);
    Composite selectModelComp = createDropDownComp();
    selectModelItem.setControl(selectModelComp);
    selectModelItem.setWidth(100);
    physicalLogicalModelViewsMenu = new PhysicalLogicalNavigatorMenu(this, erSchemaEditor, selectModelLabel);
    new ToolItem(this, SWT.SEPARATOR | SWT.VERTICAL);
    //physical/logical data type map item
    physicalLogicalMapItem = new ToolItem(this, SWT.PUSH);
    physicalLogicalMapItem.setImage(CommonUIPlugin.getImage("/icons/er/set_global_view_model.png"));
    physicalLogicalMapItem.setToolTipText(Messages.btnNameSetPhysicalLogicalMap);
    physicalLogicalMapItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            erSchemaEditor.openPhysicalLogicalMapDialog();
        }
    });
    new ToolItem(this, SWT.SEPARATOR | SWT.VERTICAL);
    // open erwin xml file
    openItem = new ToolItem(this, SWT.PUSH);
    openItem.setImage(CommonUIPlugin.getImage("/icons/queryeditor/file_open.png"));
    openItem.setToolTipText(Messages.btnTipOpenFile);
    openItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            erSchemaEditor.doOpen();
        }
    });
    // save erwin xml file
    saveItem = new ToolItem(this, SWT.PUSH);
    saveItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_save.png"));
    saveItem.setToolTipText(Messages.btnTipSaveFile);
    saveItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            erSchemaEditor.doSave(new NullProgressMonitor());
        }
    });
    // save as erwin xml file
    saveAsItem = new ToolItem(this, SWT.PUSH);
    saveAsItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_saveas.png"));
    saveAsItem.setToolTipText(Messages.btnTipSaveAsFile);
    saveAsItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            erSchemaEditor.doSaveAs();
        }
    });
    new ToolItem(this, SWT.SEPARATOR | SWT.VERTICAL);
    newTableItem = new ToolItem(this, SWT.PUSH);
    newTableItem.setToolTipText(Messages.btnTipCreateTable);
    final CombinedTemplateCreationEntry tableEntry = PaletteViewerCreator.getTableEntry(erSchemaEditor.getERSchema());
    newTableItem.setImage(tableEntry.getSmallIcon().createImage());
    newTableItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            erSchemaEditor.getEditDomain().setActiveTool(tableEntry.createTool());
        }
    });
    connectLineItem = new ToolItem(this, SWT.PUSH);
    connectLineItem.setToolTipText(Messages.btnTipConnection);
    final ConnectionCreationToolEntry conn = PaletteViewerCreator.getConnectionEntry();
    connectLineItem.setImage(conn.getSmallIcon().createImage());
    connectLineItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            erSchemaEditor.getEditDomain().setActiveTool(conn.createTool());
        }
    });
    new ToolItem(this, SWT.SEPARATOR | SWT.VERTICAL);
    // Zoom In
    zoomInItem = new ToolItem(this, SWT.PUSH);
    zoomInItem.setImage(CommonUIPlugin.getImage("icons/action/zoom_in.png"));
    zoomInItem.setToolTipText(Messages.actionZoomIn);
    zoomInItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            erSchemaEditor.doZoomIn();
        }
    });
    // Zoom Out
    zoomOutItem = new ToolItem(this, SWT.PUSH);
    zoomOutItem.setImage(CommonUIPlugin.getImage("icons/action/zoom_out.png"));
    zoomOutItem.setToolTipText(Messages.actionZoomOut);
    zoomOutItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            erSchemaEditor.doZoomOut();
        }
    });
    new ToolItem(this, SWT.SEPARATOR | SWT.VERTICAL);
    if (!erSchemaEditor.getDatabase().isVirtual()) {
        // compare ddl sql
        ddlCompareItem = new ToolItem(this, SWT.PUSH);
        ddlCompareItem.setImage(CommonUIPlugin.getImage("icons/action/schema_compare_wizard.png"));
        ddlCompareItem.setToolTipText(Messages.btnCompareDDL);
        ddlCompareItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                erSchemaEditor.compareDDL2DB();
            }
        });
        //sync comment to db
        syncCommentItem = new ToolItem(this, SWT.PUSH);
        syncCommentItem.setImage(CommonUIPlugin.getImage("icons/er/sync_comments_to_db.png"));
        syncCommentItem.setToolTipText(Messages.btnTipSyncComments);
        syncCommentItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                erSchemaEditor.syncComments();
            }
        });
    }
    //generate SQL for synchronizing comments to db
    generateSyncCommentSQLItem = new ToolItem(this, SWT.PUSH);
    generateSyncCommentSQLItem.setImage(CommonUIPlugin.getImage("icons/er/generate_sync_comments_sqls.png"));
    generateSyncCommentSQLItem.setToolTipText(Messages.btnTipGenerateSyncCommentsSQL);
    generateSyncCommentSQLItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            try {
                erSchemaEditor.generateSyncCommentSQL();
            } catch (PartInitException e) {
                LOGGER.error(e.getMessage());
                CommonUITool.openErrorBox(erSchemaEditor.getSite().getShell(), e.getMessage());
            } catch (SQLException e) {
                LOGGER.error(e.getMessage());
                CommonUITool.openErrorBox(erSchemaEditor.getSite().getShell(), e.getMessage());
            }
        }
    });
    new ToolItem(this, SWT.SEPARATOR | SWT.VERTICAL);
    // automatic layout
    autoLayoutItem = new ToolItem(this, SWT.SEPARATOR);
    Composite autoLayoutComp = createAutoLayoutComp();
    autoLayoutItem.setControl(autoLayoutComp);
    autoLayoutItem.setWidth(120);
    new ToolItem(this, SWT.SEPARATOR | SWT.VERTICAL);
    // search comp
    searchItem = new ToolItem(this, SWT.SEPARATOR);
    Composite searchcomp = createSearchComp();
    searchItem.setControl(searchcomp);
    searchItem.setWidth(150);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Composite(org.eclipse.swt.widgets.Composite) SQLException(java.sql.SQLException) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ConnectionCreationToolEntry(org.eclipse.gef.palette.ConnectionCreationToolEntry) PartInitException(org.eclipse.ui.PartInitException) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 8 with CombinedTemplateCreationEntry

use of org.eclipse.gef.palette.CombinedTemplateCreationEntry in project cubrid-manager by CUBRID.

the class PaletteViewerCreator method createPaletteRoot.

/**
	 * Create palette for ER canvas
	 * 
	 * @return
	 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public PaletteRoot createPaletteRoot(ERSchema erSchema) {
    paletteRoot = new PaletteRoot();
    paletteRoot.setLabel("");
    paletteRoot.setSmallIcon(null);
    paletteRoot.setLargeIcon(null);
    PaletteGroup controls = new PaletteGroup("Controls");
    paletteRoot.add(controls);
    ToolEntry tool = new SelectionToolEntry();
    controls.add(tool);
    paletteRoot.setDefaultEntry(tool);
    controls.add(new MarqueeToolEntry());
    PaletteDrawer drawer = new PaletteDrawer("New Component", null);
    List entries = new ArrayList();
    ConnectionCreationToolEntry connection = getConnectionEntry();
    CombinedTemplateCreationEntry tableEntry = getTableEntry(erSchema);
    entries.add(connection);
    entries.add(tableEntry);
    drawer.addAll(entries);
    paletteRoot.add(drawer);
    return paletteRoot;
}
Also used : PaletteRoot(org.eclipse.gef.palette.PaletteRoot) SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) ArrayList(java.util.ArrayList) ConnectionCreationToolEntry(org.eclipse.gef.palette.ConnectionCreationToolEntry) ArrayList(java.util.ArrayList) List(java.util.List) MarqueeToolEntry(org.eclipse.gef.palette.MarqueeToolEntry) ToolEntry(org.eclipse.gef.palette.ToolEntry) SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) ConnectionCreationToolEntry(org.eclipse.gef.palette.ConnectionCreationToolEntry) PaletteGroup(org.eclipse.gef.palette.PaletteGroup) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry) MarqueeToolEntry(org.eclipse.gef.palette.MarqueeToolEntry)

Example 9 with CombinedTemplateCreationEntry

use of org.eclipse.gef.palette.CombinedTemplateCreationEntry in project tdi-studio-se by Talend.

the class TalendPaletteViewer method addRecentlyUsedComponent.

public void addRecentlyUsedComponent(IComponent component) {
    EComponentType componentType = component.getComponentType();
    if (componentType == EComponentType.JOBLET_INPUT_OUTPUT || componentType == EComponentType.JOBLET_TRIGGER) {
        return;
    }
    if (recentlyUsedEditPart != null) {
        List children = recentlyUsedEditPart.getChildren();
        int insertIndex = 0;
        boolean alreadyExist = false;
        if (children != null) {
            for (; insertIndex < children.size(); insertIndex++) {
                TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
                CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
                int compareResult = entryModule.getLabel().compareTo(component.getName());
                if (0 == compareResult) {
                    alreadyExist = true;
                    break;
                }
            // if (0 < compareResult) {
            // break;
            // }
            }
        }
        // if already exist, remove first
        if (alreadyExist) {
            if (0 == insertIndex) {
                return;
            }
            TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
            CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
            removeRecentlyUsedComponent(entryModule);
        }
        // if (!alreadyExist) {
        TalendCombinedTemplateCreationEntry newRecently = TalendEditorPaletteFactory.createEntryFrom(component);
        newRecently.setTimestemp(new Date());
        newRecently.setParent(recentlyUsedEditPart.getDrawer());
        EditPart child = recentlyUsedEditPart.createChild(newRecently);
        PaletteDrawer paletteDrawer = recentlyUsedEditPart.getDrawer();
        if (paletteDrawer != null) {
            // paletteDrawer.add(insertIndex, newRecently);
            paletteDrawer.add(0, newRecently);
        }
        // reobtain
        children = recentlyUsedEditPart.getChildren();
        if (children != null) {
            int size = children.size();
            final int recentlyUsedSize = PaletteSettingsPreferencePage.getPaletteRencentlyUsedListSize();
            if (recentlyUsedSize < size) {
                TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(recentlyUsedSize);
                CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
                removeRecentlyUsedComponent(entryModule);
            }
        }
        // needn't use this, or will cause problem
        // recentlyUsedEditPart.addChild(child, insertIndex);
        // }
        refreshRecentlyUsedComponentToReference();
    }
}
Also used : EditPart(org.eclipse.gef.EditPart) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) List(java.util.List) ArrayList(java.util.ArrayList) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry) EComponentType(org.talend.core.model.components.EComponentType) Date(java.util.Date)

Example 10 with CombinedTemplateCreationEntry

use of org.eclipse.gef.palette.CombinedTemplateCreationEntry in project tdi-studio-se by Talend.

the class TalendPaletteViewer method addFavoritesComponent.

public void addFavoritesComponent(CombinedTemplateCreationEntry component) {
    if (favoritesEditPart != null) {
        List children = favoritesEditPart.getChildren();
        int insertIndex = 0;
        boolean alreadyExist = false;
        if (children != null) {
            for (; insertIndex < children.size(); insertIndex++) {
                TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
                CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
                int compareResult = entryModule.getLabel().toLowerCase().compareTo(component.getLabel().toLowerCase());
                if (0 == compareResult) {
                    alreadyExist = true;
                    break;
                }
                if (0 < compareResult) {
                    break;
                }
            }
        }
        if (!alreadyExist) {
            TalendEditorPaletteFactory.addNewFavoriteIntoPreference(component.getLabel());
            CombinedTemplateCreationEntry newFavorite = TalendEditorPaletteFactory.createEntryFrom(component);
            newFavorite.setParent(favoritesEditPart.getDrawer());
            EditPart child = favoritesEditPart.createChild(newFavorite);
            PaletteDrawer paletteDrawer = favoritesEditPart.getDrawer();
            if (paletteDrawer != null) {
                paletteDrawer.add(insertIndex, newFavorite);
            }
        // needn't use this, or will cause problem
        // favoritesEditPart.addChild(child, insertIndex);
        }
    }
}
Also used : EditPart(org.eclipse.gef.EditPart) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) List(java.util.List) ArrayList(java.util.ArrayList) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry)

Aggregations

CombinedTemplateCreationEntry (org.eclipse.gef.palette.CombinedTemplateCreationEntry)13 ArrayList (java.util.ArrayList)11 List (java.util.List)9 PaletteDrawer (org.eclipse.gef.palette.PaletteDrawer)9 ConnectionCreationToolEntry (org.eclipse.gef.palette.ConnectionCreationToolEntry)3 CreationToolEntry (org.eclipse.gef.palette.CreationToolEntry)3 PaletteEntry (org.eclipse.gef.palette.PaletteEntry)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)3 IComponent (org.talend.core.model.components.IComponent)3 HashMap (java.util.HashMap)2 Hashtable (java.util.Hashtable)2 Iterator (java.util.Iterator)2 LinkedList (java.util.LinkedList)2 EditPart (org.eclipse.gef.EditPart)2 PaletteRoot (org.eclipse.gef.palette.PaletteRoot)2 SelectionToolEntry (org.eclipse.gef.palette.SelectionToolEntry)2 ToolEntry (org.eclipse.gef.palette.ToolEntry)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 EComponentType (org.talend.core.model.components.EComponentType)2 IPaletteFilter (org.talend.designer.core.IPaletteFilter)2