Java Code Examples for org.eclipse.swt.widgets.TreeItem#dispose()
The following examples show how to use
org.eclipse.swt.widgets.TreeItem#dispose() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PTWidgetTree.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @see org.eclipse.nebula.widgets.opal.propertytable.AbstractPTWidget#refillData() */ @Override public void refillData() { try { if (tree != null) { tree.setRedraw(false); for (final TreeItem treeItem : tree.getItems()) { treeItem.dispose(); } } fillData(); } finally { tree.setRedraw(true); tree.redraw(); tree.update(); } }
Example 2
Source File: ParameterSection.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Removes the parameter. * * @param itemToRemove the item to remove * @param nameToRemove the name to remove */ private void removeParameter(TreeItem itemToRemove, String nameToRemove) { TreeItem parentItem = itemToRemove.getParentItem(); ConfigurationGroup cg = null; String parentGroupName = getName(parentItem.getText()); if (parentGroupName.equals(NOT_IN_ANY_GROUP)) cpd.setConfigurationParameters(removeConfigurationParameter(cpd.getConfigurationParameters(), nameToRemove)); else if (parentGroupName.equals(COMMON_GROUP)) cpd.setCommonParameters(commonParms = removeConfigurationParameter(cpd.getCommonParameters(), nameToRemove)); else { cg = getConfigurationGroup(parentGroupName); cg.setConfigurationParameters(removeConfigurationParameter(cg.getConfigurationParameters(), nameToRemove)); } removeParmSettingFromMultipleGroups(itemToRemove, REMOVE_FROM_GUI); itemToRemove.dispose(); if (null != cg && cg.getConfigurationParameters().length == 0) { removeGroup(parentItem, getName(parentItem)); } }
Example 3
Source File: ResourcePickerDialog.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Override public void handleEvent(Event event) { if (event.widget == resourcesUI && event.type == SWT.Expand) { TreeItem expandedNode = (TreeItem) event.item; TreeItem maybeDummy = expandedNode.getItem(0); if (null == maybeDummy.getData()) { maybeDummy.dispose(); IResource parentResource = (IResource)expandedNode.getData(); try { populate(expandedNode, ((IContainer)parentResource).members()); } catch (CoreException e) { throw new InternalErrorCDE("unhandled exception", e); } } } else if (event.widget == resourcesUI && event.type == SWT.Selection) { copyValuesFromGUI(); } super.handleEvent(event); }
Example 4
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 6 votes |
private void removeSym(TreeItem currentItem) { int sym; while (!(currentItem.getData() instanceof Integer)) { currentItem = currentItem.getParentItem(); if (currentItem == null) return; } sym = (Integer) currentItem.getData(); MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); dialog.setText("Confirm Sym Close"); dialog.setMessage("Are you sure you want to close this Sym?"); if (dialog.open() == SWT.OK) { ProjectManager.saveProjects(sym); RepDevMain.SYMITAR_SESSIONS.get(sym).disconnect(); RepDevMain.SYMITAR_SESSIONS.remove(sym); currentItem.dispose(); } tree.notifyListeners(SWT.Selection, null); }
Example 5
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 6 votes |
private void removeProject(TreeItem cur) { while (cur != null && !(cur.getData() instanceof Project)) cur = cur.getParentItem(); if (cur == null) return; Project proj = (Project) cur.getData(); RemProjShell.Result result = RemProjShell.confirm(display, shell, proj); if (result == RemProjShell.Result.OK_KEEP) { cur.dispose(); ProjectManager.removeProject(proj, false); } else if (result == RemProjShell.Result.OK_DELETE) { cur.dispose(); ProjectManager.removeProject(proj, true); } tree.notifyListeners(SWT.Selection, null); }
Example 6
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 6 votes |
private void removeDir(TreeItem currentItem) { String dir; while (!(currentItem.getData() instanceof String)) { currentItem = currentItem.getParentItem(); if (currentItem == null) return; } dir = (String) currentItem.getData(); MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); dialog.setText("Confirm Directory Close"); dialog.setMessage("Are you sure you want to close this directory?"); if (dialog.open() == SWT.OK) { ProjectManager.saveProjects(dir); Config.getMountedDirs().remove(dir); currentItem.dispose(); } tree.notifyListeners(SWT.Selection, null); }
Example 7
Source File: SelectObjectDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void removeEmptyFolders( TreeItem[] treeitems ) { for ( TreeItem item : treeitems ) { if ( item.getImage().equals( GUIResource.getInstance().getImageArrow() ) && item.getItemCount() == 0 ) { item.dispose(); } else { removeEmptyFolders( item.getItems() ); } } }
Example 8
Source File: ScriptDialog.java From hop with Apache License 2.0 | 5 votes |
private void modifyScriptTree( CTabItem ctabitem, int iModType ) { switch ( iModType ) { case DELETE_ITEM: TreeItem dItem = getTreeItemByName( ctabitem.getText() ); if ( dItem != null ) { dItem.dispose(); input.setChanged(); } break; case ADD_ITEM: TreeItem item = new TreeItem( wTreeScriptsItem, SWT.NULL ); item.setImage( imageActiveScript ); item.setText( ctabitem.getText() ); input.setChanged(); break; case RENAME_ITEM: input.setChanged(); break; case SET_ACTIVE_ITEM: input.setChanged(); break; default: break; } }
Example 9
Source File: ScriptDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void modifyScriptTree( CTabItem ctabitem, int iModType ) { switch ( iModType ) { case DELETE_ITEM: TreeItem dItem = getTreeItemByName( ctabitem.getText() ); if ( dItem != null ) { dItem.dispose(); input.setChanged(); } break; case ADD_ITEM: TreeItem item = new TreeItem( wTreeScriptsItem, SWT.NULL ); item.setImage( imageActiveScript ); item.setText( ctabitem.getText() ); input.setChanged(); break; case RENAME_ITEM: input.setChanged(); break; case SET_ACTIVE_ITEM: input.setChanged(); break; default: break; } }
Example 10
Source File: CapabilitySection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Removes the all feat item gui. * * @param editItem the edit item * @param column the column */ private void removeAllFeatItemGui(TreeItem editItem, int column) { TreeItem allFeatItem = getAllFeatItem(editItem); if (null == allFeatItem) // throw new InternalErrorCDE("invalid state"); return; // happens when no allfeat is set allFeatItem.setText(column, ""); String otherCol = allFeatItem.getText((column == INPUT_COL) ? OUTPUT_COL : INPUT_COL); if (null == otherCol || "".equals(otherCol)) allFeatItem.dispose(); }
Example 11
Source File: AbstractSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Swap tree items. * * @param itemBelow the item below * @param newSelection the new selection */ public static void swapTreeItems(TreeItem itemBelow, int newSelection) { TreeItem parent = itemBelow.getParentItem(); if (null == parent) throw new InternalErrorCDE("invalid arg"); int i = getIndex(itemBelow); TreeItem itemAbove = parent.getItems()[i - 1]; TreeItem newItemAbove = new TreeItem(parent, SWT.NONE, i - 1); copyTreeItem(newItemAbove, itemBelow); TreeItem newItemBelow = new TreeItem(parent, SWT.NONE, i); copyTreeItem(newItemBelow, itemAbove); itemAbove.dispose(); itemBelow.dispose(); parent.getParent().setSelection(new TreeItem[] { parent.getItems()[newSelection] }); }
Example 12
Source File: AbstractSectionParm.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Removes the included parm settings from single group. * * @param groupName the group name * @param cps in ParameterSection of items an array of tree items to remove Can be all items under a * particular group, or a set of items from different groups */ public void removeIncludedParmSettingsFromSingleGroup(String groupName, ConfigurationParameter[] cps) { ConfigurationParameterSettings modelSettings = getModelSettings(); // modelSettings.setParameterValue() if (groupName.equals(COMMON_GROUP)) throw new InternalErrorCDE("invalid state"); //$NON-NLS-1$ if (groupName.equals(NOT_IN_ANY_GROUP)) { modelSettings.setParameterSettings(nameValuePairArray0); } else { for (int i = 0; i < cps.length; i++) modelSettings.setParameterValue(groupName, cps[i].getName(), null); } if (null != settings) { TreeItem settingGroup = getSettingsGroupTreeItemByName(groupName); if (groupName.equals(COMMON_GROUP) || groupName.equals(NOT_IN_ANY_GROUP)) { disposeAllChildItems(settingGroup); } else { if (getConfigurationParameterDeclarations().getConfigurationGroupDeclarations(groupName).length == 1) { settingGroup.dispose(); } else { for (int i = 0; i < cps.length; i++) { findMatchingParm(settingGroup, cps[i].getName()).dispose(); } } } } }
Example 13
Source File: ExtnlResBindSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Removes the binding. * * @param item the item */ private void removeBinding(TreeItem item) { ExternalResourceBinding xrb = getXRBindingFromTreeItem(item); getResourceManagerConfiguration().removeExternalResourceBinding(xrb); removeBoundFlagInDependencySection(xrb); item.dispose(); setFileDirty(); }
Example 14
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 5 votes |
private int removeFile(TreeItem cur, int lastResult) { if (!(cur.getData() instanceof SymitarFile)) return 0; SymitarFile file = (SymitarFile) cur.getData(); Project proj = (Project) cur.getParentItem().getData(); int result = lastResult; if ((lastResult & RemFileShell.REPEAT) == 0) result = RemFileShell.confirm(display, shell, proj, file); if ((result & RemFileShell.OK) > 0 && (result & RemFileShell.DELETE) == 0) { proj.removeFile(file, false); cur.dispose(); } else if ((result & RemFileShell.OK) > 0 && (result & RemFileShell.DELETE) > 0) { proj.removeFile(file, true); cur.dispose(); } if (!proj.isLocal()) ProjectManager.saveProjects(proj.getSym()); else ProjectManager.saveProjects(proj.getDir()); tree.notifyListeners(SWT.Selection, null); for (CTabItem c : mainfolder.getItems()) { if (c.getData("file") != null && c.getData("file").equals(file)) { c.dispose(); } } return result; }
Example 15
Source File: ExpressionTreeSupport.java From birt with Eclipse Public License 1.0 | 5 votes |
private void clearTreeItem( TreeItem treeItem ) { if ( treeItem == null || treeItem.isDisposed( ) ) { return; } treeItem.dispose( ); }
Example 16
Source File: UserDefinedJavaClassDialog.java From hop with Apache License 2.0 | 5 votes |
private void modifyTabTree( CTabItem ctabitem, TabActions action ) { switch ( action ) { case DELETE_ITEM: TreeItem dItem = getTreeItemByName( ctabitem.getText() ); if ( dItem != null ) { dItem.dispose(); input.setChanged(); } break; case ADD_ITEM: TreeItem item = new TreeItem( wTreeClassesItem, SWT.NULL ); item.setImage( imageActiveScript ); item.setText( ctabitem.getText() ); input.setChanged(); break; case RENAME_ITEM: input.setChanged(); break; case SET_ACTIVE_ITEM: input.setChanged(); break; default: break; } }
Example 17
Source File: ParameterSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Removes the group. * * @param itemToRemove the item to remove * @param nameToRemove the name to remove */ private void removeGroup(TreeItem itemToRemove, String nameToRemove) { if (nameToRemove.equals(COMMON_GROUP)) { removeCommonParmSettingsFromMultipleGroups(); cpd.setCommonParameters(configurationParameterArray0); commonParms = configurationParameterArray0; // can't really remove the <Common> group so remove all the parms disposeAllChildItems(itemToRemove); } else if (nameToRemove.equals(NOT_IN_ANY_GROUP)) { // remove settings for all non-group parm definitions removeIncludedParmSettingsFromSingleGroup(NOT_IN_ANY_GROUP, null); cpd.setConfigurationParameters(configurationParameterArray0); // remove all non-group parm definitions disposeAllChildItems(itemToRemove); } else { ConfigurationGroup cg = getConfigurationGroup(nameToRemove); // remove settings for all parms in the group too // also updates the settings GUI if the GUI is initialized removeIncludedParmSettingsFromMultipleGroups(cg.getNames(), cg.getConfigurationParameters()); // remove group cpd.setConfigurationGroups(removeConfigurationGroup(cpd.getConfigurationGroups(), cg)); itemToRemove.dispose(); // also disposes children of group in // GUI } }
Example 18
Source File: RelPanel.java From Rel with Apache License 2.0 | 4 votes |
private void removeSubtree(String section) { TreeItem root = treeRoots.get(section); if (root != null) treeRoots.remove(section); root.dispose(); }
Example 19
Source File: CapabilitySection.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Handle remove. * * @param removeItem the remove item * @param itemKind the item kind */ private void handleRemove(TreeItem removeItem, int itemKind) { int selectionIndex = tt.indexOf(tt.getSelection()[0]); Capability c = getCapability(removeItem); switch (itemKind) { case CS: { if (Window.CANCEL == Utility.popOkCancel("Confirm Remove", "This action will remove an entire capability set. Please confirm.", MessageDialog.WARNING)) { maybeSetSelection(tt, selectionIndex + 1); return; } removeCapabilitySet(c); removeItem.dispose(); break; } case LANG_ITEM: { c.setLanguagesSupported(stringArrayRemove(c.getLanguagesSupported(), removeItem .getText(NAME_COL))); removeItem.dispose(); break; } case SOFA_ITEM: { if (Window.CANCEL == Utility .popOkCancel( "Confirm Removal of Sofa", "This action will remove this Sofa as a capability, and delete its mappings if no other capability set declares this Sofa." + " Please confirm.", MessageDialog.WARNING)) { maybeSetSelection(tt, selectionIndex + 1); return; } String sofaName = removeItem.getText(NAME_COL); boolean isInput = INPUT.equals(removeItem.getText(INPUT_COL)); if (isInput) c.setInputSofas((String[]) Utility.removeElementFromArray(c.getInputSofas(), sofaName, String.class)); else c.setOutputSofas((String[]) Utility.removeElementFromArray(c.getOutputSofas(), sofaName, String.class)); removeItem.dispose(); if (!anyCapabilitySetDeclaresSofa(sofaName, isInput)) { Comparator comparator = new Comparator() { @Override public int compare(Object o1, Object o2) { String name = (String) o1; SofaMapping sofaMapping = (SofaMapping) o2; if (name.equals(sofaMapping.getAggregateSofaName())) return 0; return 1; } }; editor.getAeDescription().setSofaMappings( (SofaMapping[]) Utility.removeElementsFromArray(getSofaMappings(), sofaName, SofaMapping.class, comparator)); sofaMapSection.markStale(); } break; } case TYPE: { if (Window.CANCEL == Utility.popOkCancel("Confirm Removal of Type", "This action will remove this type as a capability. Please confirm.", MessageDialog.WARNING)) { maybeSetSelection(tt, selectionIndex + 1); return; } TreeItem[] features = removeItem.getItems(); if (null != features) for (int i = 0; i < features.length; i++) { removeFeature(c, features[i]); } String typeNameToRemove = getFullyQualifiedName(removeItem); if (isInput(removeItem)) c.setInputs(typeOrFeatureArrayRemove(c.getInputs(), typeNameToRemove)); if (isOutput(removeItem) /* || isUpdate(removeItem) */) c.setOutputs(typeOrFeatureArrayRemove(c.getOutputs(), typeNameToRemove)); removeItem.dispose(); break; } case FEAT: { removeFeature(c, removeItem); break; } default: throw new InternalErrorCDE("invalid state"); } maybeSetSelection(tt, selectionIndex - 1); finishAction(); }
Example 20
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Handle remove type. * * @param item the item */ private void handleRemoveType(final TreeItem item) { TypeDescription td = getTypeDescriptionFromTableTreeItem(item); String sTypeNameToRemove = td.getName(); // pop a dialog mentioning typesRequiringThisOne, saying that others must be // deleted first.... if (null == showTypesRequiringThisOneMessage(sTypeNameToRemove, !ALLOWED)) return; boolean bTypeInUseElsewhere = isTypeInUseElsewhere(sTypeNameToRemove); if (bTypeInUseElsewhere) { String sCascadeDeleteTitle = CASCADE_DELETE_WARNING; String sCascadeDeleteMessage = CASCADE_MESSAGE; boolean bContinue = MessageDialog.openConfirm(getSection().getShell(), sCascadeDeleteTitle, sCascadeDeleteMessage); if (!bContinue) { return; } } TypeDescription localTd = getLocalTypeDefinition(td); removeType(localTd, getTypeSystemDescription()); if (isImportedType(td)) { // although the type itself still remains in the merged type system, // features may be removed by this action, so // a remerge is needed rebuildMergedTypeSystem(); refresh(); } else { removeType(td, getMergedTypeSystemDescription()); // update GUI setSelectionOneUp(tt, item); item.dispose(); } TypeFeature[] featuresToRemove = computeFeaturesToRemove(localTd, getMergedTypeSystemDescription().getType(td.getName())); if (bTypeInUseElsewhere && !isImportedType(td) && !isBuiltInType(td)) { deleteTypeOrFeatureMentions(sTypeNameToRemove, TYPES, null); } // if removing a type which is also imported or built-in, which is a supertype of something // this action can change the feature set. if (null != featuresToRemove) for (int i = 0; i < featuresToRemove.length; i++) { deleteTypeOrFeatureMentions(featuresToRemove[i].featureName, FEATURES, featuresToRemove[i].typeName); } editor.removeDirtyTypeName(sTypeNameToRemove); finishAction(); }