use of org.eclipse.ui.forms.widgets.Section in project rap by entirej.
the class EJRWTMultiRecordBlockRenderer method buildGuiComponent.
@Override
public void buildGuiComponent(EJRWTEntireJGridPane blockCanvas) {
EJFrameworkExtensionProperties appProp = EJCoreProperties.getInstance().getApplicationDefinedProperties();
if (appProp != null) {
EJFrameworkExtensionProperties propertyGroup = appProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ACTION_GROUP);
if (propertyGroup != null) {
addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_QUERY_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_QUERY_KEY);
addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_INSERT_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_INSERT_KEY);
addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_UPDATE_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_UPDATE_KEY);
addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_DELETE_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_DELETE_KEY);
addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_REFRESH_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_REFRESH_KEY);
}
}
EJBlockProperties blockProperties = _block.getProperties();
EJMainScreenProperties mainScreenProperties = blockProperties.getMainScreenProperties();
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.widthHint = mainScreenProperties.getWidth();
gridData.heightHint = mainScreenProperties.getHeight();
gridData.horizontalSpan = mainScreenProperties.getHorizontalSpan();
gridData.verticalSpan = mainScreenProperties.getVerticalSpan();
gridData.grabExcessHorizontalSpace = mainScreenProperties.canExpandHorizontally();
gridData.grabExcessVerticalSpace = mainScreenProperties.canExpandVertically();
if (gridData.grabExcessHorizontalSpace) {
gridData.minimumWidth = mainScreenProperties.getWidth();
}
if (gridData.grabExcessVerticalSpace) {
gridData.minimumHeight = mainScreenProperties.getHeight();
}
EJFrameworkExtensionProperties rendererProp = blockProperties.getBlockRendererProperties();
blockCanvas.setLayoutData(gridData);
EJFrameworkExtensionProperties sectionProperties = null;
if (rendererProp != null) {
sectionProperties = rendererProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
}
if (sectionProperties != null && sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
int style = ExpandableComposite.TITLE_BAR;
String mode = sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE);
if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TWISTIE.equals(mode)) {
style = style | ExpandableComposite.TWISTIE;
} else if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TREE_NODE.equals(mode)) {
style = style | ExpandableComposite.TREE_NODE;
}
if (sectionProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
style = style | ExpandableComposite.EXPANDED;
}
Section section = toolkit.createSection(blockCanvas, style);
section.setLayoutData(gridData);
String title = sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
if (title != null) {
section.setText(title);
}
String frameTitle = mainScreenProperties.getFrameTitle();
EJRWTImageRetriever.getGraphicsProvider().rendererSection(section);
if (mainScreenProperties.getDisplayFrame() && frameTitle != null && frameTitle.length() > 0) {
Group group = new Group(section, SWT.NONE);
group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
group.setLayout(new FillLayout());
group.setLayoutData(gridData);
hookKeyListener(group);
group.setText(frameTitle);
_mainPane = new EJRWTEntireJGridPane(group, 1);
_mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
section.setClient(group);
} else {
_mainPane = new EJRWTEntireJGridPane(section, 1, mainScreenProperties.getDisplayFrame() ? SWT.BORDER : SWT.NONE);
_mainPane.setLayoutData(gridData);
if (!mainScreenProperties.getDisplayFrame())
_mainPane.cleanLayoutHorizontal();
_mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
section.setClient(_mainPane);
}
final EJFrameworkExtensionPropertyList propertyList = sectionProperties.getPropertyList(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTIONS);
if (propertyList != null && propertyList.getAllListEntries().size() > 0) {
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
final ToolBar toolbar = toolBarManager.createControl(section);
final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
toolbar.setCursor(handCursor);
// Cursor needs to be explicitly disposed
toolbar.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (handCursor != null && handCursor.isDisposed() == false) {
handCursor.dispose();
}
}
});
List<EJFrameworkExtensionPropertyListEntry> allListEntries = propertyList.getAllListEntries();
for (EJFrameworkExtensionPropertyListEntry entry : allListEntries) {
final String actionID = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_ID);
String actionImage = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_IMAGE);
String actionName = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_NAME);
String actionTooltip = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_TOOLTIP);
if (actionID != null) {
Action action = new Action(actionID, IAction.AS_PUSH_BUTTON) {
@Override
public void runWithEvent(Event event) {
_block.executeActionCommand(actionID, EJScreenType.MAIN);
}
};
if (actionName != null) {
action.setText(actionName);
}
if (actionTooltip != null) {
action.setDescription(actionTooltip);
}
if (actionImage != null && actionImage.length() > 0) {
action.setImageDescriptor((EJRWTImageRetriever.createDescriptor(actionImage)));
}
toolBarManager.add(action);
}
}
toolBarManager.update(true);
section.setTextClient(toolbar);
}
} else {
String frameTitle = mainScreenProperties.getFrameTitle();
if (mainScreenProperties.getDisplayFrame() && frameTitle != null && frameTitle.length() > 0) {
Group group = new Group(blockCanvas, SWT.NONE);
group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
group.setLayout(new FillLayout());
group.setLayoutData(gridData);
hookKeyListener(group);
group.setText(frameTitle);
_mainPane = new EJRWTEntireJGridPane(group, 1);
_mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
} else {
_mainPane = new EJRWTEntireJGridPane(blockCanvas, 1, mainScreenProperties.getDisplayFrame() ? SWT.BORDER : SWT.NONE);
_mainPane.setLayoutData(gridData);
if (!mainScreenProperties.getDisplayFrame())
_mainPane.cleanLayout();
_mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
}
}
hookKeyListener(_mainPane);
int style = SWT.VIRTUAL;
if (!rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.HIDE_TABLE_BORDER, false)) {
style = style | SWT.BORDER;
}
Collection<EJItemGroupProperties> allItemGroupProperties = _block.getProperties().getScreenItemGroupContainer(EJScreenType.MAIN).getAllItemGroupProperties();
final Table table;
if (rendererProp.getBooleanProperty(EJRWTTreeBlockDefinitionProperties.FILTER, false)) {
if (allItemGroupProperties.size() > 0) {
EJItemGroupProperties displayProperties = allItemGroupProperties.iterator().next();
if (displayProperties.dispayGroupFrame() && displayProperties.getFrameTitle() != null && displayProperties.getFrameTitle().length() > 0) {
Group group = new Group(_mainPane, SWT.NONE);
group.setLayout(new GridLayout());
group.setText(displayProperties.getFrameTitle());
group.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
filterTree = new EJRWTAbstractFilteredTable(group, style) {
@Override
public void filter(String filter) {
if (_filteredContentProvider != null && (filter == null && _filteredContentProvider.getFilter() != null || !filter.equals(_filteredContentProvider.getFilter()))) {
_filteredContentProvider.setFilter(filter);
filterText = filter;
getViewer().setInput(filter);
if (getFocusedRecord() == null) {
selectRow(0);
}
notifyStatus();
}
}
@Override
protected TableViewer doCreateTableViewer(Composite parent, int style) {
return _tableViewer = new TableViewer(parent, style);
}
};
} else {
filterTree = new EJRWTAbstractFilteredTable(_mainPane, displayProperties.dispayGroupFrame() ? style | SWT.BORDER : style) {
@Override
public void filter(String filter) {
if (_filteredContentProvider != null && (filter == null && _filteredContentProvider.getFilter() != null || !filter.equals(_filteredContentProvider.getFilter()))) {
_filteredContentProvider.setFilter(filter);
filterText = filter;
getViewer().setInput(filter);
if (getFocusedRecord() == null) {
selectRow(0);
}
notifyStatus();
}
}
@Override
protected TableViewer doCreateTableViewer(Composite parent, int style) {
return _tableViewer = new TableViewer(parent, style);
}
};
filterTree.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
}
} else {
filterTree = new EJRWTAbstractFilteredTable(_mainPane, style) {
@Override
public void filter(String filter) {
if (_filteredContentProvider != null && (filter == null && _filteredContentProvider.getFilter() != null || !filter.equals(_filteredContentProvider.getFilter()))) {
_filteredContentProvider.setFilter(filter);
filterText = filter;
getViewer().setInput(filter);
if (getFocusedRecord() == null) {
selectRow(0);
}
notifyStatus();
}
}
@Override
protected TableViewer doCreateTableViewer(Composite parent, int style) {
return _tableViewer = new TableViewer(parent, style);
}
};
filterTree.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
}
table = (_tableViewer = filterTree.getViewer()).getTable();
defaultMessage = rendererProp.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_MESSAGE);
if (defaultMessage != null)
filterTree.getFilterControl().setMessage(defaultMessage);
} else {
filterTree = null;
if (allItemGroupProperties.size() > 0) {
EJItemGroupProperties displayProperties = allItemGroupProperties.iterator().next();
if (displayProperties.dispayGroupFrame() && displayProperties.getFrameTitle() != null && displayProperties.getFrameTitle().length() > 0) {
Group group = new Group(_mainPane, SWT.NONE);
group.setLayout(new FillLayout());
group.setText(displayProperties.getFrameTitle());
group.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
table = new Table(group, style);
} else {
table = new Table(_mainPane, displayProperties.dispayGroupFrame() ? style | SWT.BORDER : style);
table.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
}
} else {
table = new Table(_mainPane, style);
table.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
}
_tableViewer = new TableViewer(table);
}
table.setLinesVisible(rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.SHOW_VERTICAL_LINES, true));
table.setHeaderVisible(rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.SHOW_HEADING_PROPERTY, true));
int fixedColumns = rendererProp.getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.COLUMNS_FIXED, -1);
if (fixedColumns > 0) {
table.setData(EJ_RWT.FIXED_COLUMNS, fixedColumns);
}
int rowHeight = rendererProp.getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.DISPLAY_HEIGH_PROPERTY, -1);
if (rowHeight > 0) {
table.setData(EJ_RWT.CUSTOM_ITEM_HEIGHT, rowHeight);
}
Control[] children = table.getChildren();
for (Control control : children) {
hookKeyListener(control);
}
hookKeyListener(table);
EJRWTTableViewerColumnFactory factory = new EJRWTTableViewerColumnFactory(_tableViewer);
ColumnViewerToolTipSupport.enableFor(_tableViewer);
boolean autoSize = false;
final List<ColumnLabelProvider> nodeTextProviders = new ArrayList<ColumnLabelProvider>();
table.setData(EJ_RWT.MARKUP_ENABLED, rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ENABLE_MARKUP, false));
boolean markEscapeHtml = false;
for (EJItemGroupProperties groupProperties : allItemGroupProperties) {
Collection<EJScreenItemProperties> itemProperties = groupProperties.getAllItemProperties();
autoSize = itemProperties.size() == 1;
for (EJScreenItemProperties screenItemProperties : itemProperties) {
EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) screenItemProperties;
ColumnLabelProvider screenItem = createScreenItem(factory, mainScreenItemProperties);
if (screenItem instanceof HtmlBaseColumnLabelProvider) {
table.setData(EJ_RWT.MARKUP_ENABLED, true);
markEscapeHtml = !rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ENABLE_MARKUP, false);
}
if (screenItem != null) {
nodeTextProviders.add(screenItem);
if (autoSize) {
EJFrameworkExtensionProperties itemBl = mainScreenItemProperties.getBlockRendererRequiredProperties();
autoSize = itemBl != null && itemBl.getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0) <= 0;
}
}
}
}
if (markEscapeHtml)
for (ColumnLabelProvider columnLabelProvider : nodeTextProviders) {
if (columnLabelProvider instanceof HtmlEscapeSupport) {
HtmlEscapeSupport escapeSupport = (HtmlEscapeSupport) columnLabelProvider;
escapeSupport.setEscape();
}
}
if (autoSize) {
table.addControlListener(new ControlListener() {
@Override
public void controlResized(ControlEvent e) {
if (table.getSize().x > 10) {
table.getColumn(0).setWidth(table.getSize().x - 10);
}
}
@Override
public void controlMoved(ControlEvent e) {
// TODO Auto-generated method stub
}
});
}
table.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent arg0) {
setHasFocus(false);
}
@Override
public void focusGained(FocusEvent arg0) {
setHasFocus(true);
}
});
_mainPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent arg0) {
if (!table.isFocusControl()) {
setHasFocus(true);
}
}
});
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent arg0) {
if (!table.isFocusControl()) {
setHasFocus(true);
}
}
});
_tableViewer.setContentProvider(_filteredContentProvider = new FilteredContentProvider() {
boolean matchItem(EJDataRecord rec) {
if (filter != null && filter.trim().length() > 0) {
for (ColumnLabelProvider filterTextProvider : nodeTextProviders) {
String text = filterTextProvider.getText(rec);
if (text != null && text.toLowerCase().contains(filter.toLowerCase())) {
return true;
}
}
}
return false;
}
@Override
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
_tableBaseRecords.clear();
if (arg2 != null && arg2.equals(filter) && filter.trim().length() > 0) {
// filter
for (EJDataRecord record : _block.getBlock().getRecords()) {
if (matchItem(record)) {
_tableBaseRecords.add(record);
}
}
} else {
filter = null;
if (filterTree != null) {
filterTree.clearText();
}
_tableBaseRecords.addAll(_block.getBlock().getRecords());
}
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object arg0) {
return _tableBaseRecords.toArray();
}
});
_tableViewer.setInput(new Object());
selectRow(0);
// add double click action
final String doubleClickActionCommand = rendererProp.getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.DOUBLE_CLICK_ACTION_COMMAND);
if (doubleClickActionCommand != null) {
_tableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent arg0) {
_block.executeActionCommand(doubleClickActionCommand, EJScreenType.MAIN);
}
});
}
_tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent arg0) {
EJDataRecord focusedRecord = getFocusedRecord();
if (focusedRecord != null) {
_block.newRecordInstance(focusedRecord);
}
notifyStatus();
}
});
table.addListener(SWT.MouseDown, new Listener() {
@Override
public void handleEvent(Event event) {
Point pt = new Point(event.x, event.y);
TableItem item = table.getItem(pt);
if (item == null || item.isDisposed())
return;
for (int i = 0; i < table.getColumnCount(); i++) {
if (item == null || item.isDisposed())
return;
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
TableColumn column = table.getColumn(i);
if (column != null && column.getData("ITEM") instanceof EJScreenItemController) {
((EJScreenItemController) column.getData("ITEM")).executeActionCommand();
}
}
}
}
});
}
use of org.eclipse.ui.forms.widgets.Section in project rap by entirej.
the class EJRWTTreeRecordBlockDefinition method addBlockControlToCanvas.
@Override
public EJDevBlockRendererDefinitionControl addBlockControlToCanvas(EJMainScreenProperties mainScreenProperties, EJDevBlockDisplayProperties blockDisplayProperties, Composite parent, FormToolkit toolkit) {
EJFrameworkExtensionProperties rendererProperties = blockDisplayProperties.getBlockRendererProperties();
if (blockDisplayProperties != null) {
rendererProperties = rendererProperties.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
}
Composite layoutBody;
if (rendererProperties != null && rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
int style = ExpandableComposite.TITLE_BAR;
String mode = rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE);
if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TWISTIE.equals(mode)) {
style = style | ExpandableComposite.TWISTIE;
} else if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TREE_NODE.equals(mode)) {
style = style | ExpandableComposite.TREE_NODE;
}
if (rendererProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
style = style | ExpandableComposite.EXPANDED;
}
String title = rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
Section section = toolkit.createSection(parent, style);
if (title != null)
section.setText(title);
section.setFont(parent.getFont());
section.setForeground(parent.getForeground());
if (mainScreenProperties.getDisplayFrame()) {
layoutBody = new Group(section, SWT.NONE);
layoutBody.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
if (mainScreenProperties.getFrameTitle() != null)
((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
} else {
layoutBody = toolkit.createComposite(section);
}
section.setClient(layoutBody);
} else {
if (mainScreenProperties.getDisplayFrame()) {
layoutBody = new Group(parent, SWT.NONE);
if (mainScreenProperties.getFrameTitle() != null)
((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
} else {
layoutBody = new Composite(parent, SWT.NONE);
}
}
layoutBody.setLayout(new FillLayout());
EJDevItemGroupDisplayProperties displayProperties = null;
if (blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().size() > 0) {
displayProperties = blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().iterator().next();
}
StringBuilder builder = new StringBuilder();
if (displayProperties != null)
for (EJDevScreenItemDisplayProperties screenItem : displayProperties.getAllItemDisplayProperties()) {
if (!screenItem.isSpacerItem()) {
EJFrameworkExtensionProperties properties = ((EJDevMainScreenItemDisplayProperties) screenItem).getBlockRendererRequiredProperties();
String prefix = properties.getStringProperty(EJRWTTreeBlockDefinitionProperties.ITEM_PREFIX);
if (prefix != null) {
builder.append(prefix);
}
builder.append(screenItem.getReferencedItemName());
String sufix = properties.getStringProperty(EJRWTTreeBlockDefinitionProperties.ITEM_SUFFIX);
if (sufix != null) {
builder.append(sufix);
}
}
}
String tag = builder.toString();
if (tag.length() == 0) {
tag = "<empty>";
}
final Tree browser = new Tree(layoutBody, SWT.BORDER);
for (int i = 0; i < 4; i++) {
TreeItem iItem = new TreeItem(browser, 0);
iItem.setText(tag + " " + (i + 1));
for (int j = 0; j < 4; j++) {
TreeItem jItem = new TreeItem(iItem, 0);
jItem.setText(tag + " " + (j + 1));
}
}
return new EJDevBlockRendererDefinitionControl(blockDisplayProperties, Collections.<EJDevItemRendererDefinitionControl>emptyList());
}
use of org.eclipse.ui.forms.widgets.Section in project rap by entirej.
the class EJRWTTreeTableRecordBlockDefinition method addBlockControlToCanvas.
@Override
public EJDevBlockRendererDefinitionControl addBlockControlToCanvas(EJMainScreenProperties mainScreenProperties, EJDevBlockDisplayProperties blockDisplayProperties, Composite parent, FormToolkit toolkit) {
EJFrameworkExtensionProperties rendererProperties = blockDisplayProperties.getBlockRendererProperties();
if (blockDisplayProperties != null) {
rendererProperties = rendererProperties.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
}
Composite layoutBody;
if (rendererProperties != null && rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
int style = ExpandableComposite.TITLE_BAR;
String mode = rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE);
if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TWISTIE.equals(mode)) {
style = style | ExpandableComposite.TWISTIE;
} else if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TREE_NODE.equals(mode)) {
style = style | ExpandableComposite.TREE_NODE;
}
if (rendererProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
style = style | ExpandableComposite.EXPANDED;
}
String title = rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
Section section = toolkit.createSection(parent, style);
if (title != null)
section.setText(title);
section.setFont(parent.getFont());
section.setForeground(parent.getForeground());
if (mainScreenProperties.getDisplayFrame()) {
layoutBody = new Group(section, SWT.NONE);
layoutBody.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
if (mainScreenProperties.getFrameTitle() != null)
((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
} else {
layoutBody = toolkit.createComposite(section);
}
section.setClient(layoutBody);
} else {
if (mainScreenProperties.getDisplayFrame()) {
layoutBody = new Group(parent, SWT.NONE);
if (mainScreenProperties.getFrameTitle() != null)
((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
} else {
layoutBody = new Composite(parent, SWT.NONE);
}
}
layoutBody.setLayout(new GridLayout(mainScreenProperties.getNumCols(), false));
EJRWTTreeRendererDefinitionControl control = addTreeTable(blockDisplayProperties, layoutBody, toolkit);
return control;
}
use of org.eclipse.ui.forms.widgets.Section in project egit by eclipse.
the class CommitViewerComparator method createFileSection.
private Section createFileSection(Composite container) {
Section filesSection = toolkit.createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.CLIENT_INDENT);
GridDataFactory.fillDefaults().grab(true, true).applyTo(filesSection);
Composite filesArea = toolkit.createComposite(filesSection);
filesSection.setClient(filesArea);
toolkit.paintBordersFor(filesArea);
GridLayoutFactory.fillDefaults().extendedMargins(2, 2, 2, 2).applyTo(filesArea);
ToolBar filesToolbar = new ToolBar(filesSection, SWT.FLAT);
filesSection.setTextClient(filesToolbar);
PatternFilter patternFilter = new PatternFilter() {
@Override
protected boolean isLeafMatch(Viewer viewer, Object element) {
if (element instanceof CommitItem) {
CommitItem commitItem = (CommitItem) element;
return wordMatches(commitItem.path);
}
return super.isLeafMatch(viewer, element);
}
};
patternFilter.setIncludeLeadingWildcard(true);
FilteredCheckboxTree resourcesTreeComposite = new FilteredCheckboxTree(filesArea, toolkit, SWT.FULL_SELECTION, patternFilter) {
@Override
protected WorkbenchJob doCreateRefreshJob() {
// workaround for file filter not having an explicit change
// listener
WorkbenchJob filterJob = super.doCreateRefreshJob();
filterJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
updateFileSectionText();
}
});
}
}
});
return filterJob;
}
};
Tree resourcesTree = resourcesTreeComposite.getViewer().getTree();
resourcesTree.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
resourcesTreeComposite.setLayoutData(GridDataFactory.fillDefaults().hint(600, 200).grab(true, true).create());
resourcesTree.addSelectionListener(new CommitItemSelectionListener());
resourcesTree.setHeaderVisible(true);
if (getPreferenceStore().getBoolean(UIPreferences.WARN_BEFORE_COMMITTING) && getPreferenceStore().getBoolean(UIPreferences.BLOCK_COMMIT)) {
ignoreErrors = new Button(resourcesTreeComposite, SWT.CHECK);
ignoreErrors.setText(UIText.CommitDialog_IgnoreErrors);
ignoreErrors.setSelection(false);
ignoreErrors.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.getSource();
boolean enable = button.getSelection();
updateMessage();
updateCommitButtons(enable);
}
});
}
TreeColumn statCol = new TreeColumn(resourcesTree, SWT.LEFT);
statCol.setText(UIText.CommitDialog_Status);
statCol.setWidth(150);
statCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByStatus));
TreeColumn resourceCol = new TreeColumn(resourcesTree, SWT.LEFT);
resourceCol.setText(UIText.CommitDialog_Path);
resourceCol.setWidth(415);
resourceCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByFile));
filesViewer = resourcesTreeComposite.getCheckboxTreeViewer();
new TreeViewerColumn(filesViewer, statCol).setLabelProvider(createStatusLabelProvider());
new TreeViewerColumn(filesViewer, resourceCol).setLabelProvider(new CommitPathLabelProvider());
ColumnViewerToolTipSupport.enableFor(filesViewer);
filesViewer.setContentProvider(new CommitFileContentProvider());
filesViewer.setUseHashlookup(true);
IDialogSettings settings = org.eclipse.egit.ui.Activator.getDefault().getDialogSettings();
if (settings.get(SHOW_UNTRACKED_PREF) != null) {
// note, no matter how the dialog settings are, if
// the preferences force us to include untracked files
// we must show them
showUntracked = Boolean.valueOf(settings.get(SHOW_UNTRACKED_PREF)).booleanValue() || getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
}
filesViewer.addFilter(new CommitItemFilter());
filesViewer.setInput(items.toArray());
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(createContextMenuListener());
filesViewer.getTree().setMenu(menuManager.createContextMenu(filesViewer.getTree()));
filesViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
updateFileSectionText();
}
});
showUntrackedItem = new ToolItem(filesToolbar, SWT.CHECK);
Image showUntrackedImage = UIIcons.UNTRACKED_FILE.createImage();
UIUtils.hookDisposal(showUntrackedItem, showUntrackedImage);
showUntrackedItem.setImage(showUntrackedImage);
showUntrackedItem.setToolTipText(UIText.CommitDialog_ShowUntrackedFiles);
showUntrackedItem.setSelection(showUntracked);
showUntrackedItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showUntracked = showUntrackedItem.getSelection();
filesViewer.refresh(true);
updateFileSectionText();
updateMessage();
}
});
ToolItem checkAllItem = new ToolItem(filesToolbar, SWT.PUSH);
Image checkImage = UIIcons.CHECK_ALL.createImage();
UIUtils.hookDisposal(checkAllItem, checkImage);
checkAllItem.setImage(checkImage);
checkAllItem.setToolTipText(UIText.CommitDialog_SelectAll);
checkAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
filesViewer.setAllChecked(true);
updateFileSectionText();
updateMessage();
}
});
ToolItem uncheckAllItem = new ToolItem(filesToolbar, SWT.PUSH);
Image uncheckImage = UIIcons.UNCHECK_ALL.createImage();
UIUtils.hookDisposal(uncheckAllItem, uncheckImage);
uncheckAllItem.setImage(uncheckImage);
uncheckAllItem.setToolTipText(UIText.CommitDialog_DeselectAll);
uncheckAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
filesViewer.setAllChecked(false);
updateFileSectionText();
updateMessage();
}
});
if (!allowToChangeSelection) {
amendingItem.setSelection(false);
amendingItem.setEnabled(false);
showUntrackedItem.setSelection(false);
showUntrackedItem.setEnabled(false);
checkAllItem.setEnabled(false);
uncheckAllItem.setEnabled(false);
filesViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (!event.getChecked())
filesViewer.setAllChecked(true);
updateFileSectionText();
}
});
filesViewer.setAllChecked(true);
} else {
final boolean includeUntracked = getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
for (CommitItem item : items) {
if (!preselectAll && !preselectedFiles.contains(item.path))
continue;
if (item.status == Status.ASSUME_UNCHANGED)
continue;
if (!includeUntracked && item.status == Status.UNTRACKED)
continue;
filesViewer.setChecked(item, true);
}
}
statCol.pack();
resourceCol.pack();
return filesSection;
}
use of org.eclipse.ui.forms.widgets.Section in project egit by eclipse.
the class CommitEditorPage method createSection.
Section createSection(Composite parent, FormToolkit toolkit, String title, int span, int extraStyles) {
Section section = toolkit.createSection(parent, extraStyles);
GridDataFactory.fillDefaults().span(span, 1).grab(true, true).applyTo(section);
section.setText(title);
addSectionTextToFocusTracking(section);
return section;
}
Aggregations