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;
}
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);
}
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;
}
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();
}
}
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);
}
}
}
Aggregations