diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties')
29 files changed, 0 insertions, 4067 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionDialogCellEditor.java deleted file mode 100644 index a68e86cc0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionDialogCellEditor.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * - * Dialog Cell Editor for Action browser. - * - * @author Xiao-guang Zhang - */ -public class ActionDialogCellEditor extends EditableDialogCellEditor { - - - /** - * Default constructor - */ - public ActionDialogCellEditor() { - super(); - } - - - /** - * @param parent - */ - public ActionDialogCellEditor(Composite parent) { - super(parent); - } - - /** - * @param parent - * @param style - */ - public ActionDialogCellEditor(Composite parent, int style) { - super(parent, style); - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - String actionExpression = getDefaultText().getText(); - // IStructuredSelection selectionToPass = StructuredSelection.EMPTY; - // Create a new jsf Wizard - - // FIXME sfshi 2005-11-16 - // ActionSelectionWizard actionSelectionWizard = - // new ActionSelectionWizard(ActionSelectionWizard.CONSIDER_METHODS); - // actionSelectionWizard.init(EditorPlugin.getDefault().getWorkbench(), - // selectionToPass); - // actionSelectionWizard.setActionExpression(actionExpression); - // //using a wizard dialog to display the new jsf wizard - // WizardDialog actionSelectionWizardDialog = - // new WizardDialog(cellEditorWindow.getShell(),actionSelectionWizard); - // if (actionSelectionWizardDialog.open() == WizardDialog.OK ) - // { - // actionExpression = actionSelectionWizard.getActionExpression(); - // } - return actionExpression; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeDialogCellEditor.java deleted file mode 100644 index 3c683411e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeDialogCellEditor.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * - * Dialog Cell Editor for Action's outcome browser. - * - * @author Xiao-guang Zhang - */ -public class ActionOutcomeDialogCellEditor extends EditableDialogCellEditor { - /** the source PFLink element */ - PageflowElement element; - - /** - * @param element - */ - public ActionOutcomeDialogCellEditor(PageflowElement element) { - super(); - this.element = element; - } - - /** - * @param parent - * @param element - */ - public ActionOutcomeDialogCellEditor(Composite parent, - PageflowElement element) { - super(parent); - this.element = element; - } - - - /** - * @param parent - * @param style - * @param element - */ - public ActionOutcomeDialogCellEditor(Composite parent, int style, - PageflowElement element) { - super(parent, style); - this.element = element; - } - - /** - * get the previous JSP page, it can be null if the previous node is not - * PFPage, but PFAction. - * - * @param element_ - * @return - */ - private String getPreviousJSPPath(PageflowElement element_) { - String jspPath = null; - if (element_ instanceof PageflowLink) { - PageflowNode source = ((PageflowLink) element_).getSource(); - - if (source instanceof PageflowPage) { - jspPath = ((PageflowPage) source).getPath(); - } - } - return jspPath; - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - String outcome = getDefaultText().getText(); - - String jspPathName = WebrootUtil.getProjectPath(element, - getPreviousJSPPath(element)); - - ActionOutcomeSelectionDialog selectionDialog = new ActionOutcomeSelectionDialog( - getControl().getShell(), outcome, jspPathName); - - if (selectionDialog.open() == Window.OK) { - outcome = selectionDialog.getSelectedAction(); - } - - return outcome; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeSelectionDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeSelectionDialog.java deleted file mode 100644 index 46d3fc451..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeSelectionDialog.java +++ /dev/null @@ -1,376 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.ColumnPixelData; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.Separator; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.JSPUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Text; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; - -/** - * This dialog is used to edit outcome property of link component of Pageflow - * Designer. - * - * @author Xiao-guang Zhang - */ -public class ActionOutcomeSelectionDialog extends Dialog { - - /** property's name text control */ - private Text actionText; - - /** linked source jsp file name */ - private String jspName; - - /** the current outcome */ - private String outcome; - - /** action table control */ - private Table actionTable; - - /** Column width of component name and action */ - private static final int COMPONENT_COL_WIDTH = 160; - - private static final int ACTION_COL_WIDTH = 160; - - /** Dialog default height and width */ - private static final int DIALOG_DEFAULT_WIDTH = 400; - - private static final int DIALOG_DEFAULT_HEIGHT = 300; - - private static String JSF_EL_LEFT_BRACE = "#{"; - - private static String JSF_EL_RIGHT_BRACE = "}"; - - /** the listener for the text modification */ - private ModifyListener modifyListener; - - /** - * @param parentShell - * @param outcome - * @param jspName - */ - public ActionOutcomeSelectionDialog(Shell parentShell, String outcome, - String jspName) { - super(parentShell); - this.outcome = outcome; - this.jspName = jspName; - - modifyListener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - verifyComplete(); - } - }; - } - - /* - * (non-Javadoc) - * - * @see Dialog#createDialogArea(Composite) - */ - protected Control createDialogArea(Composite parent) { - GridLayout gridLayout; - - Composite container = (Composite) super.createDialogArea(parent); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gridLayout.marginWidth = 10; - gridLayout.marginHeight = 10; - container.setLayout(gridLayout); - GridData gd = new GridData(GridData.FILL_BOTH); - // gd.widthHint = 300; - gd.heightHint = DIALOG_DEFAULT_HEIGHT; - gd.widthHint = DIALOG_DEFAULT_WIDTH; - container.setLayoutData(gd); - - Label choiceLabel = new Label(container, SWT.LEFT); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - // gd.widthHint = 100; - choiceLabel.setLayoutData(gd); - // Pageflow.Property.Action.OutcomeSelectionDialog.Choice = Enter the - // outcome or select one from action list below: - choiceLabel - .setText(PageflowMessages.Pageflow_Property_Action_OutcomeSelectionDialog_Choice); - - createOutcomeSection(container); - - createActionListSection(container); - - return container; - } - - /** - * create a Outcome input section - * - * @param container - */ - protected void createOutcomeSection(Composite container) { - Composite outcomeSection = new Composite(container, SWT.NONE); - GridLayout gl = new GridLayout(); - gl.numColumns = 1; - gl.marginWidth = 0; - outcomeSection.setLayout(gl); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - outcomeSection.setLayoutData(gd); - - actionText = new Text(outcomeSection, SWT.BORDER); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL - | GridData.FILL_HORIZONTAL); - actionText.setLayoutData(gd); - - actionText.addModifyListener(modifyListener); - - if (outcome != null && outcome.length() > 0) { - actionText.setText(outcome); - } - } - - /** - * create action list table section - * - * @param container - */ - protected void createActionListSection(Composite container) { - final Group actionSection = new Group(container, SWT.NONE); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - actionSection.setLayout(gridLayout); - GridData gd = new GridData(GridData.FILL_BOTH); - actionSection.setLayoutData(gd); - - String actionListTitle = PageflowMessages.Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Title;//$NON-NLS-1$ - - if (jspName != null && jspName.length() > 0) { - actionListTitle += " in " + jspName; - } - // Pageflow.Property.Action.OutcomeSelectionDialog.ActionListTable.Title - // = Actions - actionSection.setText(actionListTitle); - - actionTable = new Table(actionSection, SWT.BORDER | SWT.FULL_SELECTION); - actionTable.setLayoutData(new GridData(GridData.FILL_BOTH)); - actionTable.setHeaderVisible(true); - actionTable.setLinesVisible(true); - TableLayout layout = new TableLayout(); - actionTable.setLayout(layout); - - layout.addColumnData(new ColumnPixelData(COMPONENT_COL_WIDTH)); - layout.addColumnData(new ColumnPixelData(ACTION_COL_WIDTH)); - TableColumn componentCol = new TableColumn(actionTable, SWT.NONE); - // Pageflow.Property.Action.OutcomeSelectionDialog.ActionListTable.Component - // = Component ID - componentCol - .setText(PageflowMessages.Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Component); //$NON-NLS-1$ - TableColumn actionCol = new TableColumn(actionTable, SWT.NONE); - - // Pageflow.Property.Action.OutcomeSelectionDialog.ActionListTable.Action - // = Action - actionCol - .setText(PageflowMessages.Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Action);//$NON-NLS-1$ - - actionTable.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - TableItem selItem = (TableItem) e.item; - String action = selItem.getText(1); - if (action != null && action.length() > 0) - actionText.setText(action); - } - }); - - addActionsInJSP(); - - } - - /** - * Creates a separator line. Expects a <code>GridLayout</code> with at - * least 1 column. - * - * @param composite - * the parent composite - * @param nColumns - * number of columns to span - */ - protected void createSeparator(Composite composite, int nColumns) { - (new Separator(SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(null, - composite, nColumns, convertHeightInCharsToPixels(1)); - } - - /* - * (non-Javadoc) - * - * @see Dialog#createButtonsForButtonBar(Composite) - */ - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, - true); - createButton(parent, IDialogConstants.CANCEL_ID, - IDialogConstants.CANCEL_LABEL, false); - - verifyComplete(); - } - - /* - * (non-Javadoc) - * - * @see Dialog#configureShell(Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - - // Pageflow.Property.Action.OutcomeSelectionDialog.Title = Outcome - // Selection - newShell - .setText(PageflowMessages.Pageflow_Property_Action_OutcomeSelectionDialog_Title); //$NON-NLS-1$ - - } - - /* - * (non-Javadoc) - * - * @see Dialog#buttonPressed(int) - */ - protected void buttonPressed(int buttonId) { - if (buttonId == IDialogConstants.CANCEL_ID) { - setReturnCode(CANCEL); - close(); - return; - } else if (buttonId == IDialogConstants.OK_ID) { - setReturnCode(OK); - - outcome = actionText.getText(); - - close(); - return; - } - super.buttonPressed(buttonId); - } - - /** - * - * check the dialog inputs are complete or not, and set the OK button enable - * or not. - */ - private void verifyComplete() { - if (getButton(IDialogConstants.OK_ID) != null) { - getButton(IDialogConstants.OK_ID).setEnabled(isDialogComplete()); - } - } - - /** - * check the dialog inputs are complete or not. - * - * @return - */ - private boolean isDialogComplete() { - return isValidName(); - } - - /** - * the input name is valid or not - * - * @return - */ - private boolean isValidName() { - return actionText.getText().length() > 0; - } - - /** - * get the selected action in the action table - * - * @return - selected action - */ - public String getSelectedAction() { - return outcome; - } - - /** - * add actions in the source jsp file to the action list table control - * - */ - private void addActionsInJSP() { - List actionNodes = JSPUtil.getActionListInJSPFile(jspName); - - if (actionNodes != null) { - for (int i = 0, n = actionNodes.size(); i < n; i++) { - Element node = (Element) actionNodes.get(i); - StringBuffer componentName = new StringBuffer(); - - Attr idAttr = node.getAttributeNode("id"); - if (idAttr != null) - componentName.append(idAttr.getNodeValue()); - - componentName.append("(").append(node.getTagName()).append(")"); //$NON-NLS-1$ - - Attr actionAttr = node.getAttributeNode("action"); - if (actionAttr != null) { - String action = actionAttr.getValue(); - if (isValidEL(action)) - addActionTableItem(componentName.toString(), action); - } - } - } - } - - /** - * @param expressionString - * @return true if expressionString is valid EL - */ - public static boolean isValidEL(String expressionString) { - if (expressionString == null || expressionString.length() == 0) - return true; - - return (expressionString.startsWith(JSF_EL_LEFT_BRACE) && expressionString - .endsWith(JSF_EL_RIGHT_BRACE)) - || (!expressionString.startsWith(JSF_EL_LEFT_BRACE) && !expressionString - .endsWith(JSF_EL_RIGHT_BRACE)); - } - - /** - * add a new action item in the previous jsp page. - * - * @param componentName - - * JSF component element - * @param action - - * value of action's attribute - */ - private void addActionTableItem(String componentName, String action) { - if (componentName != null && componentName.length() > 0 - && action != null && action.length() > 0) { - TableItem item = new TableItem(actionTable, SWT.NONE); - item.setText(0, componentName); - item.setText(1, action); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionSectionDescriptor.java deleted file mode 100644 index 217366634..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionSectionDescriptor.java +++ /dev/null @@ -1,11 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditableDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditableDialogCellEditor.java deleted file mode 100644 index ee2cd23b6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditableDialogCellEditor.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.text.MessageFormat; - -import org.eclipse.jface.viewers.DialogCellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusAdapter; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; - -/** - * @author Hong-tao Meng - */ -public abstract class EditableDialogCellEditor extends DialogCellEditor { - private Text text; - - /** - * - */ - public EditableDialogCellEditor() { - super(); - } - - /** - * @param parent - */ - public EditableDialogCellEditor(Composite parent) { - super(parent); - } - - /** - * @param parent - * @param style - */ - public EditableDialogCellEditor(Composite parent, int style) { - super(parent, style); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.DialogCellEditor#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite cell) { - text = new Text(cell, SWT.LEFT); - text.setFont(cell.getFont()); - text.setBackground(cell.getBackground()); - text.addKeyListener(new KeyAdapter() { - // hook key pressed - see PR 14201 - public void keyPressed(KeyEvent e) { - keyReleaseOccured(e); - // disposed this cell editor - if ((getControl() == null) || getControl().isDisposed()) { - return; - } - } - }); - // when the text control has focus, the cellEditor will deactive even - // when you press the button. - // Add the follow codes enable switch to the button control. - text.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent e) { - boolean newValidState = isCorrect(text.getText()); - if (newValidState) { - markDirty(); - doSetValue(text.getText()); - } else { - // try to insert the current value into the error message. - setErrorMessage(MessageFormat.format(getErrorMessage(), - new Object[] { text.getText().toString() })); - } - } - }); - - return text; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#doSetFocus() - */ - protected void doSetFocus() { - text.setFocus(); - text.selectAll(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.DialogCellEditor#updateContents(java.lang.Object) - */ - protected void updateContents(Object value) { - if (text == null) { - return; - } - - String text_ = "";//$NON-NLS-1$ - if (value != null) { - text_ = value.toString(); - } - this.text.setText(text_); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#keyReleaseOccured(org.eclipse.swt.events.KeyEvent) - */ - protected void keyReleaseOccured(KeyEvent keyEvent) { - if (keyEvent.character == '\r') { - boolean newValidState = isCorrect(text.getText()); - if (newValidState) { - markDirty(); - doSetValue(text.getText()); - } else { - // try to insert the current value into the error message. - setErrorMessage(MessageFormat.format(getErrorMessage(), - new Object[] { text.getText().toString() })); - } - fireApplyEditorValue(); - } - super.keyReleaseOccured(keyEvent); - } - - /** - * @return the default text - */ - public Text getDefaultText() { - return text; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditorSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditorSectionDescriptor.java deleted file mode 100644 index 6628690b6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditorSectionDescriptor.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.List; - -import org.eclipse.jface.viewers.IFilter; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section.EditorSection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.ISection; -import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor; - - - -/** - * @author jchoi - */ -public class EditorSectionDescriptor implements ISectionDescriptor { - /** - * constructor - */ - public EditorSectionDescriptor() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() { - return ITabbedPropertiesConstants.EDITOR_SECTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() { - return new EditorSection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() { - return ITabbedPropertiesConstants.ATTRIBUTE_TAB_ID; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) { - Object object = null; - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - object = structuredSelection.getFirstElement(); - // The editor section in the attribute tab will be shown for only - // pageflow element - if (object instanceof PageflowEditPart) { - return true; - } - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() { - return ITabbedPropertiesConstants.TOP_SECTION; - } - - public int getEnablesFor() { - return ENABLES_FOR_ANY; - } - - public IFilter getFilter() { - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ExistingPagePathDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ExistingPagePathDialogCellEditor.java deleted file mode 100644 index f6ba9c348..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ExistingPagePathDialogCellEditor.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.ListChoiceDialog; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * The cell editor used to locate an existing pageflow page node in current - * pageflow. - * - * @author hmeng - * - */ -public class ExistingPagePathDialogCellEditor extends EditableDialogCellEditor { - Pageflow pageflow; - - /** - * - */ - public ExistingPagePathDialogCellEditor() { - super(); - } - - /** - * @param parent - * @param style - */ - public ExistingPagePathDialogCellEditor(Composite parent, int style) { - super(parent, style); - } - - /** - * @param parent - * @param pageflow - */ - public ExistingPagePathDialogCellEditor(Composite parent, Pageflow pageflow) { - super(parent); - this.pageflow = pageflow; - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#openDialogBox(Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - String jsfSelection = ""; - if (getDefaultText() != null && getDefaultText().getText().length() > 0) { - jsfSelection = getDefaultText().getText(); - } - ListChoiceDialog dialog = new ListChoiceDialog(cellEditorWindow - .getShell(), getPagePaths(), - PageflowMessages.ExistingPagePathDialogCellEdito_LabelText); - - if (dialog.open() == Window.OK) { - jsfSelection = dialog.getResult(); - } - return jsfSelection; - } - - /** - * Collect page paths in current pageflow. - * - * @return - */ - private String[] getPagePaths() { - List result = new ArrayList(); - List list = pageflow.getNodes(); - for (int i = 0; i < list.size(); i++) { - String path = ((PageflowPage) list.get(i)).getPath(); - if (path != null && path.trim().length() > 0) { - result.add(path); - } - } - String[] r = (String[]) result.toArray(new String[result.size()]); - Arrays.sort(r); - return r; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSection.java deleted file mode 100644 index 85884e39d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSection.java +++ /dev/null @@ -1,379 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.MultiPageEditorPart; -import org.eclipse.ui.part.PageBook; -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.ui.views.properties.PropertySheetPage; -import org.eclipse.ui.views.properties.tabbed.ISection; -import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; -import org.eclipse.wst.sse.ui.StructuredTextEditor; - -/** - * This class defines the general tab for pageflow attributes. This class - * defines the controls shown in this sectin and their event handler. For - * MultiPageEditorPart, if it support getAdapter(IEditorPart.class) to get the - * current active editor, then, this section can get the different - * PropertySheetPage for different sub EditorPart. - * - * @author Xiao-guang Zhang - */ -public class GeneralViewSection implements ISection, - ISelectionChangedListener { - /** the pagebook */ - private PageBook pageBook = null; - - /** - * A data structure used to store the information about a single page within - * a MultiPageEditorPart - */ - protected static class PageRec { - - /** - * The part including editorpart, or Control - */ - public IWorkbenchPart part; - - /** - * The page. - */ - public IPropertySheetPage page; - - /** - * Creates a new page record initialized to the given part and page. - * - * @param part - * @param page - */ - public PageRec(IWorkbenchPart part, IPropertySheetPage page) { - this.part = part; - this.page = page; - } - - /** - * Disposes of this page record by <code>null</code>ing its fields. - */ - public void dispose() { - part = null; - page = null; - } - } - - /** - * Map from parts to part records (key type: <code>IWorkbenchPart</code>; - * value type: <code>PartRec</code>). - */ - private Map mapPartToRec = new HashMap(); - - /** - * The page record for the default page. - */ - private PageRec defaultPageRec; - - /** - * The page rec which provided the current page or <code>null</code> - */ - private PageRec activeRec; - - /* - * (non-Javadoc) - * - * @see com.createControls(Composite, TabbedPropertySheetPage) - */ - public void createControls(Composite parent, - TabbedPropertySheetPage tabbedPropertySheetPage) { - FillLayout layout = new FillLayout(); - layout.marginWidth = ITabbedPropertyConstants.HSPACE; - layout.marginHeight = ITabbedPropertyConstants.VSPACE; - - // composite.setLayout(layout); - parent.setLayout(layout); - // pagebook - pageBook = new PageBook(parent, SWT.BORDER); - - // create a default property page. - createDefaultPage(); - - // Show the default page - if (defaultPageRec != null) { - showPageRec(defaultPageRec); - } - } - - /** - * Shows page contained in the given page record in this view. The page - * record must be one from this pagebook view. - * <p> - * The <code>PageBookView</code> implementation of this method asks the - * pagebook control to show the given page's control, and records that the - * given page is now current. Subclasses may extend. - * </p> - * - * @param pageRec - * the page record containing the page to show - */ - protected void showPageRec(PageRec pageRec) { - // If already showing do nothing - if (activeRec == pageRec) { - return; - } - // If the page is the same, just set activeRec to pageRec - if (activeRec != null && pageRec != null - && activeRec.page == pageRec.page) { - activeRec = pageRec; - return; - } - - // Show new page. - activeRec = pageRec; - Control pageControl = activeRec.page.getControl(); - if (pageControl != null && !pageControl.isDisposed()) { - // Verify that the page control is not disposed - // If we are closing, it may have already been disposed - pageBook.showPage(pageControl); - } - } - - /** - * Creates a page for a given part. Adds it to the pagebook but does not - * show it. - * - * @param part - * The part we are making a page for. - * @return IWorkbenchPart - */ - private PageRec createPage(IWorkbenchPart part) { - PageRec rec = doCreatePage(part); - if (rec != null) { - mapPartToRec.put(part, rec); - } - return rec; - } - - /* - * (non-Javadoc) Method declared on PageBookView. - */ - /** - * @param part - * @return PageRec for part - */ - protected PageRec doCreatePage(IWorkbenchPart part) { - // FIXME: Because the PropertySheetPage of StructuredTextEditor has a - // bug: - // the editor can't be opened twice if the property view is shown. - // This bug only exists in WTP 1.0.0 version. - if (part instanceof StructuredTextEditor) { - return null; - } - // Try to get an property page. - Object obj = part.getAdapter(IPropertySheetPage.class); - if (obj instanceof IPropertySheetPage) { - IPropertySheetPage page = (IPropertySheetPage) obj; - - page.createControl(getPageBook()); - - return new PageRec(part, page); - } - // There is no content property page - return null; - } - - private void createDefaultPage() { - // Create the default PropertySheetPage rec. - IPropertySheetPage defaultPage = new PropertySheetPage(); - defaultPage.createControl(getPageBook()); - - defaultPageRec = new PageRec(null, defaultPage); - } - - /** - * Returns the pagebook control for this view. - * - * @return the pagebook control, or <code>null</code> if not initialized - */ - protected PageBook getPageBook() { - return pageBook; - } - - /** - * Returns the page record for the given part. - * - * @param part - * the part - * @return the corresponding page record, or <code>null</code> if not - * found - */ - protected PageRec getPageRec(Object part) { - return (PageRec) mapPartToRec.get(part); - } - - /* - * (non-Javadoc) - * - * @see ISection#setInput(IWorkbenchPart, ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) { - if (part instanceof MultiPageEditorPart) { - IEditorPart subPage = (IEditorPart) part - .getAdapter(IEditorPart.class); - if (subPage != null) { - // get or Create a PropertySheetPage for the part. - PageRec rec = getPageRec(subPage); - if (rec == null) { - rec = createPage(subPage); - } - - // Show the page. - if (rec != null) { - showPageRec(rec); - } else { - showPageRec(defaultPageRec); - } - } - } - activeRec.page.selectionChanged(part, selection); - } - - /* - * (non-Javadoc) - * - * @see ISection#aboutToBeShown() - */ - public void aboutToBeShown() { - refresh(); - } - - /* - * (non-Javadoc) - * - * @see ISection#aboutToBeHidden() - */ - public void aboutToBeHidden() { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see ISection#dispose() - */ - public void dispose() { - // Deref all of the pages. - activeRec = null; - if (defaultPageRec != null) { - // check for null since the default page may not have - // been created (ex. perspective never visible) - defaultPageRec.page.dispose(); - defaultPageRec = null; - } - Map clone = (Map) ((HashMap) mapPartToRec).clone(); - Iterator iter = clone.values().iterator(); - while (iter.hasNext()) { - PageRec rec = (PageRec) iter.next(); - removePage(rec); - } - } - - /** - * Removes a page record. If it is the last reference to the page dispose of - * it - otherwise just decrement the reference count. - * - * @param rec - */ - private void removePage(PageRec rec) { - mapPartToRec.remove(rec.part); - - Control control = rec.page.getControl(); - if (control != null && !control.isDisposed()) { - // Dispose the page's control so pages don't have to do this in - // their - // dispose method. - // The page's control is a child of this view's control so if this - // view - // is closed, the page's control will already be disposed. - control.dispose(); - } - - // free the page - doDestroyPage(rec.part, rec); - } - - /** - * Destroys a page in the pagebook for a particular part. - * - * @param part - * the input part - * @param rec - * a page record for the part - */ - protected void doDestroyPage(IWorkbenchPart part, PageRec rec) { - IPropertySheetPage page = rec.page; - page.dispose(); - rec.dispose(); - } - - /* - * (non-Javadoc) - * - * @see ISection#getMinimumHeight() - */ - public int getMinimumHeight() { - return SWT.DEFAULT; - } - - /* - * (non-Javadoc) - * - * @see com.ibm.xtools.common.ui.properties.ISection#shouldUseExtraSpace() - */ - public boolean shouldUseExtraSpace() { - /** - * here should return true, otherwise, the component controls will not - * fill the whole panel of the tab. - */ - return true; - } - - /* - * (non-Javadoc) - * - * @see com.ibm.xtools.common.ui.properties.ISection#refresh() - */ - public void refresh() { - return; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - setInput((IWorkbenchPart) event.getSource(), event.getSelection()); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSectionDescriptor.java deleted file mode 100644 index dd4786fc1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSectionDescriptor.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.List; - -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.IFilter; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementTreeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowLinkEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.ISection; -import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor; - -/** - * This class defines the section descriptor for pageflow attributes. Following - * is the typical function of SectionDescriptor for tabbed property views. 1. In - * tabbed property view, there are multiple sections, one or more than one - * sections can be composed of one tab. 2. Each of section has an ID, and their - * relationship is defined by the function "getAfterSection". 3. Not all - * sections are enabled always. They are enabled according to current - * WorkbenchPart and selection, which is defined in function "appliesTo". - * - * @author Xiao-guang Zhang - */ -public class GeneralViewSectionDescriptor implements ISectionDescriptor { - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#getId() - */ - public String getId() { - return ITabbedPropertiesConstants.GENERAL_TAB_ID; - } - - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() { - return null; - } - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() { - return new GeneralViewSection(); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.xtools.common.ui.properties.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() { - return ITabbedPropertiesConstants.GENERAL_TAB_ID; - } - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#appliesTo(IWorkbenchPart, ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) { - Object object = null; - // FIXME: Should move the appliesTo to differnt page of - // MultiPageEditorPart. - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - object = structuredSelection.getFirstElement(); - // The general tab will be shown for only pageflow element and - // pageflow link editparts - if (object instanceof PageflowElementEditPart - || object instanceof PageflowElementTreeEditPart) { - return true; - } else if (object instanceof PageflowLinkEditPart) { - PageflowLink pfLink = (PageflowLink) ((PageflowLinkEditPart) object) - .getModel(); - if (PageflowValidation.getInstance().isValidLinkForProperty( - pfLink)) { - return true; - } - } else { - return true; - } - } else if (selection instanceof ITextSelection) { - return true; - } - - return false; - } - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() { - return ""; - } - - public int getEnablesFor() { - return ENABLES_FOR_ANY; - } - - - public IFilter getFilter() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ITabbedPropertiesConstants.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ITabbedPropertiesConstants.java deleted file mode 100644 index e7ce738b8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ITabbedPropertiesConstants.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -/** - * @author jchoi - * @version - */ -public interface ITabbedPropertiesConstants { - /** - * used to set grid data height hints on dialog fields - */ - public static int BROWSE_HEIGHT = 18; - - /** - * used to set grid data width hints on dialog fields - */ - public static int BROWSE_WIDTH = 20; - - /** - * the general tag id - */ - public static final String GENERAL_TAB_ID = "org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.general"; - - /** - * the attribute tag id - */ - public static final String ATTRIBUTE_TAB_ID = "org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.attribute"; - - /** - * the link section id - */ - public static final String LINK_SECTION = "attribute.link"; // 4 - - /** - * the page section id - */ - public static final String PAGE_SECTION = "attribute.page"; // 3 - - /** - * the editor section id - */ - public static final String EDITOR_SECTION = "attribute.editor"; // 1 - - /** - * the top section id - */ - public static final String TOP_SECTION = "top"; // 0 - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/LinkSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/LinkSectionDescriptor.java deleted file mode 100644 index d0cc43028..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/LinkSectionDescriptor.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.List; - -import org.eclipse.jface.viewers.IFilter; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowLinkEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section.LinkSection; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.ISection; -import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor; - -/** - * @author jchoi - * @version - */ -public class LinkSectionDescriptor implements ISectionDescriptor { - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() { - return ITabbedPropertiesConstants.LINK_SECTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() { - return new LinkSection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() { - return ITabbedPropertiesConstants.ATTRIBUTE_TAB_ID; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) { - Object object = null; - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - object = structuredSelection.getFirstElement(); - if (object instanceof PageflowLinkEditPart) { - PageflowLink pfLink = (PageflowLink) ((PageflowLinkEditPart) object).getModel(); - if (PageflowValidation.getInstance().isValidLinkForProperty( - pfLink)) { - - return true; - } - - } - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() { - return ITabbedPropertiesConstants.TOP_SECTION; - } - - public int getEnablesFor() { - return ENABLES_FOR_ANY; - } - - public IFilter getFilter() { - return null; - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PagePathDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PagePathDialogCellEditor.java deleted file mode 100644 index 606511a97..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PagePathDialogCellEditor.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * Dialog Cell Editor for Page path browser. - * - * @author Xiao-guang Zhang - */ -public class PagePathDialogCellEditor extends EditableDialogCellEditor { - PageflowPage element; - - /** - * Default constructor - */ - public PagePathDialogCellEditor() { - super(); - } - - /** - * @param parent - * @param element - */ - public PagePathDialogCellEditor(Composite parent, PageflowPage element) { - super(parent); - this.element = element; - } - - - /** - * @param parent - * @param style - */ - public PagePathDialogCellEditor(Composite parent, int style) { - super(parent, style); - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#openDialogBox(Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - String jsfSelection = ""; - if (getDefaultText() != null && getDefaultText().getText().length() > 0) { - jsfSelection = getDefaultText().getText(); - IProject project = WebrootUtil.getProject(element); - ProjectWebPageSelectionDialog dlg = new ProjectWebPageSelectionDialog( - cellEditorWindow.getShell(), project); - if (dlg.open() == Window.OK) { - jsfSelection = dlg.getResultFilePath(); - } - } - return jsfSelection; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageSectionDescriptor.java deleted file mode 100644 index 4e7fc8096..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageSectionDescriptor.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.List; - -import org.eclipse.jface.viewers.IFilter; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowNodeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPageImpl; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section.PageSection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.ISection; -import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor; - -/** - * @author jchoi - * @version - */ -public class PageSectionDescriptor implements ISectionDescriptor { - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() { - return ITabbedPropertiesConstants.PAGE_SECTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() { - return new PageSection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() { - return ITabbedPropertiesConstants.ATTRIBUTE_TAB_ID; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) { - Object object = null; - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - object = structuredSelection.getFirstElement(); - if (object instanceof PageflowNodeEditPart) { - Object model = ((PageflowNodeEditPart) object).getModel(); - if (model instanceof PageflowPageImpl) { - return true; - } - } - } - return false; - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() { - return ITabbedPropertiesConstants.TOP_SECTION; - } - - public int getEnablesFor() { - return ENABLES_FOR_ANY; - } - - - public IFilter getFilter() { - return null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowElementPropertySource.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowElementPropertySource.java deleted file mode 100644 index a62b1da0a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowElementPropertySource.java +++ /dev/null @@ -1,478 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -/** - * This class is intended to be a generic property source for all the objects in - * the application's model. It currently only supports String and boolean types, - * and doesn't support reset or nested properties. It uses information in the - * EMF EAttribute and EDataType classes to get the id, display name, and type - * information. - * - * @author Xiao-guang Zhang - */ -public class PageflowElementPropertySource implements IPropertySource { - /** attribute name of "path" and "action", which have special property editor */ - private static final String PAGEFLOW_PATH = "path"; //$NON-NLS-1$ - - static final String PAGEFLOW_NAME = "name"; //$NON-NLS-1$ - - static final String PAGEFLOW_COMMENT = "comment"; //$NON-NLS-1$ - - private static final String PAGEFLOW_CONFIG_FILE = "configfile"; //$NON-NLS-1$ - - /** pageflow elememt */ - PageflowElement element; - - /** boolean value's label */ - private static final String P_VALUE_TRUE_LABEL = PageflowMessages.Pageflow_Label_True; - - private static final String P_VALUE_FALSE_LABEL = PageflowMessages.Pageflow_Label_False; - - /** Integer value for boolean type */ - private static final int P_VALUE_TRUE = 0; - - private static final int P_VALUE_FALSE = 1; - - static class BooleanLabelProvider extends LabelProvider { - public String getText(Object element) { - String[] values = new String[] { P_VALUE_TRUE_LABEL, - P_VALUE_FALSE_LABEL }; - return values[((Integer) element).intValue()]; - } - - public Image getImage(Object element) { - return EditorPlugin.getDefault().getImage( - "facesconfig/Pageflow_BooleanValue.gif"); //$NON-NLS-1$ - } - } - - static class PageflowLabelProvider extends LabelProvider { - - public Image getImage(Object element) { - if (element instanceof String) { - return EditorPlugin.getDefault().getImage( - "facesconfig/Pageflow_TextValue.gif");//$NON-NLS-1$ - } else if (element instanceof Integer) { - return EditorPlugin.getDefault().getImage( - "facesconfig/Pageflow_IntegralValue.gif");//$NON-NLS-1$ - } else { - return EditorPlugin.getDefault().getImage( - "facesconfig/Pageflow_GenericValue.gif");//$NON-NLS-1$ - } - } - } - - /** - * constructor - * - * @param element - - * pageflow element model. - */ - public PageflowElementPropertySource(PageflowElement element) { - this.element = element; - } - - /* - * (non-Javadoc) - * - * @see IPropertySource#getEditableValue() - */ - public Object getEditableValue() { - return element; - } - - /* - * (non-Javadoc) - * - * @see IPropertySource#getPropertyDescriptors() - */ - public IPropertyDescriptor[] getPropertyDescriptors() { - // property descriptors - List propertyDescriptors = new Vector(); - - // if (element instanceof PageflowLink) { - // return getLinkPropertyDescriptors(); - // } - - Iterator it; - EClass cls = element.eClass(); - - it = cls.getEAllAttributes().iterator(); - while (it.hasNext()) { - EAttribute attr = (EAttribute) it.next(); - if (attr.isID() - || attr.getFeatureID() == PageflowPackage.PAGEFLOW__REFERENCE_LINK) { - continue; - } - EDataType type = attr.getEAttributeType(); - if (type.getInstanceClass() == String.class) { - PropertyDescriptor propertyDescriptor; - if (attr.getName().equalsIgnoreCase(PAGEFLOW_PATH)) { - propertyDescriptor = getPagePathPropertyDescriptor(attr); - } else if (attr.getName() - .equalsIgnoreCase(PAGEFLOW_CONFIG_FILE)) { - propertyDescriptor = null; - } else { - propertyDescriptor = new TextPropertyDescriptor(Integer - .toString(attr.getFeatureID()), getString(attr - .getName())); - } - if (propertyDescriptor != null) { - propertyDescriptor - .setLabelProvider(new PageflowLabelProvider()); - propertyDescriptors.add(propertyDescriptor); - } - - } else if (type.getInstanceClass() == boolean.class) { - PropertyDescriptor propertyDescriptor; - propertyDescriptor = getBooleanTypePropertyDescriptor(attr); - propertyDescriptor.setLabelProvider(new BooleanLabelProvider()); - propertyDescriptors.add(propertyDescriptor); - } - } - - return (IPropertyDescriptor[]) propertyDescriptors - .toArray(new IPropertyDescriptor[] {}); - } - - /** - * @return - */ - // TODO: method not used; dead? -// private IPropertyDescriptor[] getLinkPropertyDescriptors() { -// // property descriptors -// List propertyDescriptors = new Vector(); -// -// Iterator it; -// EClass cls = element.eClass(); -// -// it = cls.getEAllAttributes().iterator(); -// while (it.hasNext()) { -// EAttribute attr = (EAttribute) it.next(); -// if (attr.isID() -// || attr.getName().equalsIgnoreCase(PAGEFLOW_NAME) -// || attr.getName().equalsIgnoreCase(PAGEFLOW_COMMENT) -// || attr.getFeatureID() == PageflowPackage.PAGEFLOW__REFERENCE_LINK) { -// continue; -// } -// -// EDataType type = attr.getEAttributeType(); -// if (type.getInstanceClass() == String.class) { -// PropertyDescriptor propertyDescriptor; -// -// propertyDescriptor = new TextPropertyDescriptor(Integer -// .toString(attr.getFeatureID()), getString(attr -// .getName())); -// -// if (propertyDescriptor != null) { -// propertyDescriptor -// .setLabelProvider(new PageflowLabelProvider()); -// propertyDescriptors.add(propertyDescriptor); -// } -// -// } else if (type.getInstanceClass() == boolean.class) { -// PropertyDescriptor propertyDescriptor; -// propertyDescriptor = getBooleanTypePropertyDescriptor(attr); -// propertyDescriptor.setLabelProvider(new BooleanLabelProvider()); -// propertyDescriptors.add(propertyDescriptor); -// } -// } -// -// return (IPropertyDescriptor[]) propertyDescriptors -// .toArray(new IPropertyDescriptor[] {}); -// } - - /** - * get the property descriptor for the attribute "path" of page component - * - * @param attr - - * EAttribute - * @return - */ - private PropertyDescriptor getPagePathPropertyDescriptor(EAttribute attr) { - PropertyDescriptor propertyDescriptor = new PropertyDescriptor(Integer - .toString(attr.getFeatureID()), getString(attr.getName())) { - public CellEditor createPropertyEditor(Composite parent) { - CellEditor editor = new PagePathDialogCellEditor(parent, - (PageflowPage) element); - if (getValidator() != null) { - editor.setValidator(getValidator()); - } - return editor; - } - - /** - * Returns the input validator for editing the property. - * - * @return the validator used to verify correct values for this - * property, or <code>null</code> - */ - protected ICellEditorValidator getValidator() { - return new ICellEditorValidator() { - public String isValid(Object value) { - if (((PageflowPage) element).getPath() != null - && value != null - && !((PageflowPage) element).getPath() - .equalsIgnoreCase((String) value)) { - if (PageflowValidation.getInstance().isExistedPage( - ((PageflowPage) element).getPageflow(), - (String) value)) { - // Pageflow.PageflowEditor.Alert.DNDResourceTitle - // = Pageflow Creation Error - // Pageflow.PageflowEditor.Alert.ExistingPage = - // The web page {0} is already existed in - // current PageFlow. - EditorPlugin - .getAlerts() - .error( - "Pageflow.PageflowEditor.Alert.DNDResourceTitle", - "Pageflow.PageflowEditor.Alert.ExistingPage", - value); - - return EditorPlugin - .getResourceString("Pageflow.PageflowEditor.Alert.ExistingPage"); - } - } - return null; - } - - }; - } - - }; - return propertyDescriptor; - } - - /** - * get the property descriptor for the attribute "action" of Action - * component - * - * @param attr - - * EAttribute - * @return - */ - // TODO: method not used; dead? -// private PropertyDescriptor getActionPropertyDescriptor(EAttribute attr) { -// PropertyDescriptor propertyDescriptor = new PropertyDescriptor(Integer -// .toString(attr.getFeatureID()), getString(attr.getName())) { -// public CellEditor createPropertyEditor(Composite parent) { -// CellEditor editor = new ActionDialogCellEditor(parent); -// if (getValidator() != null) { -// editor.setValidator(getValidator()); -// } -// return editor; -// } -// -// /** -// * Returns the input validator for editing the property. -// * -// * @return the validator used to verify correct values for this -// * property, or <code>null</code> -// */ -// protected ICellEditorValidator getValidator() { -// return new ICellEditorValidator() { -// public String isValid(Object value) { -// -// return null; -// } -// -// }; -// } -// }; -// return propertyDescriptor; -// } - - /** - * get the property descriptor for the attribute "outcome" of Link component - * - * @param attr - - * EAttribute - * @return - */ - // TODO: method not used; dead? -// private PropertyDescriptor getActionOutcomePropertyDescriptor( -// EAttribute attr) { -// PropertyDescriptor propertyDescriptor = new PropertyDescriptor(Integer -// .toString(attr.getFeatureID()), getString(attr.getName())) { -// public CellEditor createPropertyEditor(Composite parent) { -// CellEditor editor = new ActionOutcomeDialogCellEditor(parent, -// element); -// if (getValidator() != null) { -// editor.setValidator(getValidator()); -// } -// return editor; -// } -// }; -// return propertyDescriptor; -// } - - /** - * get property descriptor for the attribute with the boolean type - * - * @param attr - - * EAttribute - * @return - */ - PropertyDescriptor getBooleanTypePropertyDescriptor(EAttribute attr) { - PropertyDescriptor propertyDescriptor; - propertyDescriptor = new ComboBoxPropertyDescriptor(Integer - .toString(attr.getFeatureID()), getString(attr.getName()), - new String[] { P_VALUE_TRUE_LABEL, P_VALUE_FALSE_LABEL }); - return propertyDescriptor; - } - - /** - * Get a translated string from the resource locator. - * @param key - * @return the string for the key - */ - protected final String getString(String key) { - if ("comment".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_comment; - } - - if ("name".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_name; - } - - if ("largeicon".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_largeicon; - } - - if ("smallicon".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_smallicon; - } - - if ("source".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_source; - } - - if ("target".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_target; - } - - if ("fromaction".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_fromaction; - } - - if ("path".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_path; - } - if ("begin".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_begin; - } - if ("end".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_end; - } - if ("configfile".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_configfile; - } - if ("outcome".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_outcome; - } - if ("redirect".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_redirect; - } - - return ""; - } - - /* - * (non-Javadoc) - * - * @see IPropertySource#getPropertyValue(Object) - */ - public Object getPropertyValue(Object id) { - EStructuralFeature feature = element.eClass().getEStructuralFeature( - Integer.parseInt((String) id)); - - Object result = element.eGet(feature); - - if (result instanceof Boolean) { - if (result == Boolean.TRUE) { - result = new Integer(P_VALUE_TRUE); - } else { - result = new Integer(P_VALUE_FALSE); - } - } - - return result != null ? result : ""; - } - - /* - * (non-Javadoc) - * - * @see IPropertySource#isPropertySet(Object) - */ - public boolean isPropertySet(Object id) { - return false; - } - - /* - * (non-Javadoc) - * - * @see IPropertySouce#resetPropertyValue(Object) - */ - public void resetPropertyValue(Object id) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see IPropertySource#setPropertyValue(Object, Object) - */ - public void setPropertyValue(Object id, Object value) { - EStructuralFeature feature = element.eClass().getEStructuralFeature( - Integer.parseInt((String) id)); - - Object result = element.eGet(feature); - // if the attribute is boolean type, the value should be changed from - // string "true" or "false" - // to Boolean.TRUE or Boolean.FALSE - if (result instanceof Boolean) { - if (value.equals(new Integer(P_VALUE_TRUE))) { - value = Boolean.TRUE; - } else { - value = Boolean.FALSE; - } - } - element.eSet(feature, value); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowLinkPropertySource.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowLinkPropertySource.java deleted file mode 100644 index 8eaf8199a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowLinkPropertySource.java +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -/** - * The property source for Pageflow Link. - * - * @author hmeng - */ - -public class PageflowLinkPropertySource extends PageflowElementPropertySource { - - /** - * @param element - */ - public PageflowLinkPropertySource(PageflowElement element) { - super(element); - } - - public Object getPropertyValue(Object id) { - Object result = super.getPropertyValue(id); - if (Integer.parseInt((String) id) == PageflowPackage.PF_LINK__SOURCE - || Integer.parseInt((String) id) == PageflowPackage.PF_LINK__TARGET) { - result = ((PageflowPage) result).getPath(); - } - return result; - } - - public void setPropertyValue(Object id, Object value) { - if (Integer.parseInt((String) id) == PageflowPackage.PF_LINK__SOURCE) { - ((PageflowLink) element).setSourcePath((String) value); - - } else if (Integer.parseInt((String) id) == PageflowPackage.PF_LINK__TARGET) { - ((PageflowLink) element).setTargetPath((String) value); - } else { - super.setPropertyValue(id, value); - } - } - - public IPropertyDescriptor[] getPropertyDescriptors() { - // property descriptors - List propertyDescriptors = new Vector(); - - Iterator it; - EClass cls = element.eClass(); - - it = cls.getEAllAttributes().iterator(); - while (it.hasNext()) { - EAttribute attr = (EAttribute) it.next(); - if (attr.isID() - || attr.getName().equalsIgnoreCase(PAGEFLOW_NAME) - || attr.getName().equalsIgnoreCase(PAGEFLOW_COMMENT) - || attr.getFeatureID() == PageflowPackage.PAGEFLOW__REFERENCE_LINK) { - continue; - } - - EDataType type = attr.getEAttributeType(); - if (type.getInstanceClass() == String.class) { - PropertyDescriptor propertyDescriptor; - - propertyDescriptor = new TextPropertyDescriptor(Integer - .toString(attr.getFeatureID()), - getString(attr.getName())); - - if (propertyDescriptor != null) { - propertyDescriptor - .setLabelProvider(new PageflowLabelProvider()); - propertyDescriptors.add(propertyDescriptor); - } - - } else if (type.getInstanceClass() == boolean.class) { - PropertyDescriptor propertyDescriptor; - propertyDescriptor = getBooleanTypePropertyDescriptor(attr); - propertyDescriptor.setLabelProvider(new BooleanLabelProvider()); - propertyDescriptors.add(propertyDescriptor); - } - } - it = cls.getEReferences().iterator(); - while (it.hasNext()) { - EReference attr = (EReference) it.next(); - if (attr.getFeatureID() == PageflowPackage.PF_LINK__SOURCE - || attr.getFeatureID() == PageflowPackage.PF_LINK__TARGET) { - - PropertyDescriptor propertyDescriptor; - - propertyDescriptor = getExistingPagePathPropertyDescriptor(attr); - - if (propertyDescriptor != null) { - propertyDescriptor - .setLabelProvider(new PageflowLabelProvider()); - propertyDescriptors.add(propertyDescriptor); - } - } - } - - return (IPropertyDescriptor[]) propertyDescriptors - .toArray(new IPropertyDescriptor[] {}); - } - - /** - * The link's ends can be modified to another page existing in current pageflow. - * @param attr - * @return - */ - private PropertyDescriptor getExistingPagePathPropertyDescriptor( - EReference attr) { - PropertyDescriptor propertyDescriptor = new PropertyDescriptor(Integer - .toString(attr.getFeatureID()), getString(attr.getName())) { - public CellEditor createPropertyEditor(Composite parent) { - CellEditor editor = new ExistingPagePathDialogCellEditor( - parent, (Pageflow) element.eContainer()); - if (getValidator() != null) { - editor.setValidator(getValidator()); - } - return editor; - } - - /** - * Returns the input validator for editing the property. - * - * @return the validator used to verify correct values for this - * property, or <code>null</code> - */ - protected ICellEditorValidator getValidator() { - return new ICellEditorValidator() { - public String isValid(Object value) { - if (value != null) { - if (!PageflowValidation.getInstance() - .isExistedPage( - ((Pageflow) element.eContainer()), - (String) value)) { - // Pageflow.PageflowEditor.Alert.DNDResourceTitle - // = Pageflow Creation Error - // Pageflow.PageflowEditor.Alert.ExistingPage = - // The web page {0} is already existed in - // current PageFlow. - EditorPlugin.getAlerts().info("Note", - "Please select an existing page"); - // "Pageflow.PageflowEditor.Alert.DNDResourceTitle", - // "Pageflow.PageflowEditor.Alert.ExistingPage", - // (String) value); - - return EditorPlugin - .getResourceString("Pageflow.PageflowEditor.Alert.ExistingPage"); - } - } - return null; - } - - }; - } - - }; - return propertyDescriptor; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionDescriptorProvider.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionDescriptorProvider.java deleted file mode 100644 index e36d2828e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionDescriptorProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor; -import org.eclipse.ui.views.properties.tabbed.ISectionDescriptorProvider; - -/** - * this class defines all section descriptors for pageflow. Similar with - * PropertyDescriptors, this class defines all sections used by pageflow through - * SectionDescriptor. - * - */ -public class PageflowSectionDescriptorProvider implements - ISectionDescriptorProvider { - /** - * Default constructor - */ - public PageflowSectionDescriptorProvider() { - super(); - } - - /* - * (non-Javadoc) - * - * @see ISectionDescriptorProvider#getSectionDescriptors() - */ - public ISectionDescriptor[] getSectionDescriptors() { - ISectionDescriptor[] descriptors = new ISectionDescriptor[] { - new LinkSectionDescriptor(), new PageSectionDescriptor(), - new EditorSectionDescriptor(), - new GeneralViewSectionDescriptor() }; - return descriptors; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionLabelProvider.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionLabelProvider.java deleted file mode 100644 index c6adc01f3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionLabelProvider.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.gef.editparts.AbstractEditPart; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementTreeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowLinkEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.swt.graphics.Image; - -/** - * This class defines label provider for the property view's title. Tabbed - * property view has a common area as a Title. Different decription and image - * can be shown according to Different selection. - * - */ -public class PageflowSectionLabelProvider extends LabelProvider { - - /** - * Default constructor - */ - public PageflowSectionLabelProvider() { - super(); - } - - /* - * (non-Javadoc) - * - * @see getImage(java.lang.Object) - */ - public Image getImage(Object object) { - Image result = EditorPlugin.getDefault().getImage( - "facesconfig/FacesConfig_Pageflow16.gif"); - - return result; - } - - /* - * (non-Javadoc) - * - * @see getText(java.lang.Object) - */ - public String getText(Object object) { - String result = null; - if (object instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) object; - Object pageflow = structuredSelection.getFirstElement(); - if (pageflow instanceof PageflowElementEditPart - || pageflow instanceof PageflowLinkEditPart - || pageflow instanceof PageflowElementTreeEditPart) { - - if (((PageflowElement) ((AbstractEditPart) pageflow).getModel()) - .eClass() == PageflowPackage.eINSTANCE.getPageflow()) { - result = PageflowMessages.Pageflow_Model_Items_Pageflow; - } else if (((PageflowElement) ((AbstractEditPart) pageflow) - .getModel()).eClass() == PageflowPackage.eINSTANCE - .getPFPage()) { - result = PageflowMessages.Pageflow_Model_Items_PFPage; - } else if (((PageflowElement) ((AbstractEditPart) pageflow) - .getModel()).eClass() == PageflowPackage.eINSTANCE - .getPFLink()) { - result = PageflowMessages.Pageflow_Model_Items_PFLink; - } - } - } - return result; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ProjectWebPageSelectionDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ProjectWebPageSelectionDialog.java deleted file mode 100644 index eb218e82e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ProjectWebPageSelectionDialog.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jst.jsf.common.ui.internal.dialogs.CommonResourceDialog; -import org.eclipse.swt.widgets.Shell; - -/** - * @author hmeng - */ - -public class ProjectWebPageSelectionDialog extends CommonResourceDialog { - - /** - * @param parentShell - * @param project - * @param style - */ - public ProjectWebPageSelectionDialog(Shell parentShell, IProject project, - int style) { - super(parentShell, project, style); - init(); - } - - /** - * @param parentShell - * @param project - */ - public ProjectWebPageSelectionDialog(Shell parentShell, IProject project) { - super(parentShell, project); - init(); - } - - private void init() { - setResourceDescription("Web page"); - setSuffixs(new String[] { "jsp", "jspx", "jsf", "html", "htm" }); - } - - /** - * @return the rseult file path - */ - public String getResultFilePath() { - String result = ""; - IFile selectedFile = (IFile) getResult()[0]; - IPath path = selectedFile.getProjectRelativePath(); - path = path.removeFirstSegments(1); - result = "/" + path.toString(); - return result; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.java deleted file mode 100644 index a9747a9b7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.osgi.util.NLS; - -/** - * NLS Message bundle for properties - * - */ -public final class PropertyMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PropertyMessages"; - - private PropertyMessages() { - // Do not instantiate - } - - static { - NLS.initializeMessages(BUNDLE_NAME, PropertyMessages.class); - } - - /** - * see PropertyMessages.properties - */ - public static String property_displayName; - /** - * see PropertyMessages.properties - */ - public static String property_description; - /** - * see PropertyMessages.properties - */ - public static String property_configFile; - /** - * see PropertyMessages.properties - */ - public static String property_largeIcon; - - /** - * see PropertyMessages.properties - */ - public static String property_smallIcon; - - /** - * see PropertyMessages.properties - */ - public static String property_fromAction; - - /** - * see PropertyMessages.properties - */ - public static String property_fromView; - - /** - * see PropertyMessages.properties - */ - public static String property_fromOutcome; - - /** - * see PropertyMessages.properties - */ - public static String property_redirect; - - /** - * see PropertyMessages.properties - */ - public static String property_browseButton; - - /** - * see PropertyMessages.properties - */ - public static String property_Command_SetValue; - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.properties b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.properties deleted file mode 100644 index b2a7b4ce1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.properties +++ /dev/null @@ -1,22 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2006 Oracle Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Oracle Corporation - initial API and implementation -############################################################################### -property_displayName=Display Name: -property_description=Description: -property_configFile=Faces-config file: -property_largeIcon=Large Icon: -property_smallIcon=Small Icon: -property_fromAction=From Action: -property_fromView=Page Path: -property_fromOutcome=From Outcome: -property_redirect=Redirect: -property_browseButton=... - -property_Command_SetValue=Set {0} Property diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartGroup.java deleted file mode 100644 index 6ccbc2c4f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartGroup.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldGroup; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PropertyMessages; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author jchoi - * @version - */ -/*package*/ abstract class AbstractEditPartGroup extends DialogFieldGroup { - - private StringDialogField descField; - - private StringDialogField displayNameField; - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - displayNameField = new StringDialogField(); - displayNameField.setLabelText(PropertyMessages.property_displayName); - displayNameField - .setDialogFieldChangeListener(getDefaultChangeListener()); - descField = new StringDialogField(); - - descField.setLabelText(PropertyMessages.property_description); - descField.setDialogFieldChangeListener(getDefaultChangeListener()); - - } - - - /** - * @param toolkit - * @param parent - * @param col - */ - protected void layoutDialogFields(FormToolkit toolkit, Composite parent, - int col) { - displayNameField.doFillIntoGrid(toolkit, parent, col); - descField.doFillIntoGrid(toolkit, parent, col); - - } - - /** - * @param elem - */ - protected void refreshData(PageflowElement elem) { - descField.setTextWithoutUpdate(elem.getComment()); - displayNameField.setTextWithoutUpdate(elem.getName()); - } - - /** - * @return the description field - */ - protected StringDialogField getDescField() { - return descField; - } - - /** - * @return the display name field - */ - protected StringDialogField getDisplayNameField() { - return displayNameField; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#validateDialogFields() - */ - public IStatus[] validateDialogFields() { - - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartSection.java deleted file mode 100644 index 00dcfca48..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartSection.java +++ /dev/null @@ -1,238 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import java.util.EventObject; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.commands.CommandStackListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldChangeListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; - -/** - * This is base section, which support GEF command stack to redo/undo setting - * properties. - * - * @author jchoi, Xiao-guang Zhang - */ -/*package*/ abstract class AbstractEditPartSection extends AbstractPropertySection { - - IDialogFieldChangeListener changeListener = new IDialogFieldChangeListener() { - public void dialogFieldChanged(DialogField field) { - validate(); - } - }; - - /** property source of edit part */ - private IPropertySource propertySource; - - /** EditPart instance */ - private EditPart editPart; - - /** map for property registry to store a map between the property id and name */ - private Map propertyRegistry; - - /** GEF command stack */ - private CommandStack commandStack; - - /** command stack listener to refresh the section */ - private CommandStackListener commandStackListener; - - /** - * - */ - public AbstractEditPartSection() { - super(); - } - - /** - * refresh the whole section - * - */ - public void refreshData() { - super.refresh(); - } - - /** - * TODO: this method seems unused - */ - public abstract void validate(); - - /** - * dispose the command stack listener - */ - public void dispose() { - super.dispose(); - if (getCommandStack() != null) { - getCommandStack().removeCommandStackListener( - getCommandStackListener()); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) { - if (part != null) { - if (part.getAdapter(CommandStack.class) != null) { - setCommandStack((CommandStack) part - .getAdapter(CommandStack.class)); - } - - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - if (structuredSelection.getFirstElement() instanceof EditPart) { - editPart = (EditPart) structuredSelection.getFirstElement(); - } - - if (editPart != null - && ((IAdaptable) editPart) - .getAdapter(IPropertySource.class) != null) { - propertySource = (IPropertySource) ((IAdaptable) editPart) - .getAdapter(IPropertySource.class); - } - - } - } - - super.setInput(part, selection); - } - - /** - * get the commandstacklistener, if not existed, create a new one. - * - * @return - */ - private CommandStackListener getCommandStackListener() { - if (commandStackListener == null) { - commandStackListener = new CommandStackListener() { - public void commandStackChanged(EventObject e) { - refreshData(); - } - }; - } - return commandStackListener; - } - - /** - * set a <code>CommandStack</code> forthis section, and add a - * <code>CommandStackListener</code> for this commandstack - * - * @param stack - */ - public void setCommandStack(CommandStack stack) { - commandStack = stack; - stack.addCommandStackListener(getCommandStackListener()); - } - - /** - * get the <code>CommandStack</code> - * - * @return the command stack - */ - public CommandStack getCommandStack() { - return commandStack; - } - - /** - * get the property source registered for current editpart - * - * @return the property source - */ - public IPropertySource getPropertySource() { - return propertySource; - } - - /** - * get the property's EMF featureID based on property name. - * - * @param propertyName - * @return the feature id for propertyName - */ - protected Object getFeatureID(String propertyName) { - if (editPart != null && !(editPart.getModel() instanceof EObject)) { - return null; - } - - Object propertyID = getPropertyRegistry().get(propertyName); - if (propertyID == null) { - - EClass cls = ((EObject) editPart.getModel()).eClass(); - for (Iterator it = cls.getEAllAttributes().iterator(); it.hasNext();) { - EAttribute attr = (EAttribute) it.next(); - if (attr.getName().equalsIgnoreCase(propertyName)) { - propertyID = Integer.toString(attr.getFeatureID()); - getPropertyRegistry().put(propertyName, propertyID); - break; - } - } - } - return propertyID; - } - - /** - * @return the property registry - */ - protected Map getPropertyRegistry() { - if (propertyRegistry == null) { - propertyRegistry = new HashMap(); - } - return propertyRegistry; - } - - /** - * get the input edit part - * - * @return the input - */ - public Object getInput() { - return editPart; - } - - /** - * set the value of property - * - * @param propertyName - * @param propertyValue - */ - public void setValue(String propertyName, Object propertyValue) { - if (propertyName != null && propertyValue != null - && getPropertySource() != null) { - SetPropertyValueCommand setCommand = new SetPropertyValueCommand( - propertyName); - setCommand.setTarget(getPropertySource()); - setCommand.setPropertyId(getFeatureID(propertyName)); - setCommand.setPropertyValue(propertyValue); - if (getCommandStack() != null) { - getCommandStack().execute(setCommand); - } else { - setCommand.execute(); - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorGroup.java deleted file mode 100644 index dd6bea929..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorGroup.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author jchoi - * @version - */ -/*package*/ class EditorGroup extends AbstractEditPartGroup { - private Pageflow pageflow = null; - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - super.initialize(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#refreshData() - */ - public void refreshData() { - if (pageflow != null) { - super.refreshData(pageflow); - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#layoutDialogFields(org.eclipse.ui.forms.widgets.FormToolkit, - * org.eclipse.swt.widgets.Composite) - */ - public void layoutDialogFields(FormToolkit toolkit, Composite parent) { - Composite top; - if (toolkit == null) { - top = new Composite(parent, SWT.NONE); - } else { - top = toolkit.createComposite(parent); - } - FillLayout fillLayout = new FillLayout(SWT.VERTICAL); - parent.setLayout(fillLayout); - - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - top.setLayout(layout); - - Label separator = toolkit.createSeparator(top, SWT.HORIZONTAL); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - separator.setLayoutData(data); - super.layoutDialogFields(toolkit, top, 3); - - } - - /** - * @param elem - */ - public void setPropertyProvider(Pageflow elem) { - pageflow = elem; - this.refreshData(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorSection.java deleted file mode 100644 index 1b9d62cd8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorSection.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; - -/** - * Edit section for Pagflow (EditPart) - * - * @author jchoi, Xiao-guang Zhang - */ -public class EditorSection extends AbstractEditPartSection { - /** edit group */ - private EditorGroup group; - - /** the emf model for Pageflow */ - private Pageflow pageflow; - - /** - * - */ - public EditorSection() { - super(); - group = new EditorGroup(); - group.setDefaultChangeListener(changeListener); - group.initialize(); - - group.getDisplayNameField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - EditorSection.this.setValue( - PageflowPackageImpl.eINSTANCE - .getPageflowElement_Name().getName(), - group.getDisplayNameField().getText()); - } - }); - - group.getDescField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - EditorSection.this - .setValue( - PageflowPackageImpl.eINSTANCE - .getPageflowElement_Comment() - .getName(), group - .getDescField().getText()); - } - }); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#createControls(org.eclipse.swt.widgets.Composite, - * org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage) - */ - public void createControls(Composite parent, - TabbedPropertySheetPage aTabbedPropertySheetPage) { - super.createControls(parent, aTabbedPropertySheetPage); - TabbedPropertySheetWidgetFactory factory = aTabbedPropertySheetPage - .getWidgetFactory(); - Composite top = factory.createFlatFormComposite(parent); - - group.layoutDialogFields(factory, top); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) { - super.setInput(part, selection); - - if (getInput() != null && getInput() instanceof PageflowEditPart) { - Object model = ((PageflowEditPart) getInput()).getModel(); - if (model instanceof Pageflow) { - pageflow = (Pageflow) model; - refreshData(); - } - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.properties.sections.AbstractEditPartSection#refreshData() - */ - public void refreshData() { - super.refreshData(); - group.setPropertyProvider(pageflow); - } - - public void validate() { - // do nothing. - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkGroup.java deleted file mode 100644 index 1c2db0c57..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkGroup.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ComboDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IStringButtonAdapter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.ActionOutcomeSelectionDialog; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.ITabbedPropertiesConstants; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PropertyMessages; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author jchoi - * @version - */ -/*package*/ class LinkGroup extends AbstractEditPartGroup { - private StringButtonDialogField fromOutcomeField; - - private StringDialogField fromActionField; - - private ComboDialogField redirectField; - - private PageflowLink pfLink; - - /** Integer value for boolean type */ - private static final Integer P_VALUE_TRUE = new Integer(0); - - private static final Integer P_VALUE_FALSE = new Integer(1); - - private class StringButtonAdapter implements IStringButtonAdapter { - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.IStringButtonAdapter#changeControlPressed(org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogField) - */ - public void changeControlPressed(DialogField field) { - String outcome = ""; - String jspPage = ""; - Shell shell = field.getLabelControl(null, null).getShell(); - if (pfLink != null) { - outcome = pfLink.getOutcome(); - jspPage = WebrootUtil.getProjectPath(pfLink, - getPreviousJSPPath(pfLink)); - ActionOutcomeSelectionDialog actionDialog = new ActionOutcomeSelectionDialog( - shell, outcome, jspPage); - if (actionDialog.open() == Window.OK) { - outcome = actionDialog.getSelectedAction(); - fromOutcomeField.setText(outcome); - pfLink.setOutcome(outcome); - refreshData(); - } - } - } - - /** - * @param _element - * @return - */ - private String getPreviousJSPPath(PageflowElement element) { - String jspPath = null; - if (element instanceof PageflowLink) { - PageflowNode source = ((PageflowLink) element).getSource(); - if (source instanceof PageflowPage) { - jspPath = ((PageflowPage) source).getPath(); - } - } - return jspPath; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - fromOutcomeField = new StringButtonDialogField( - new StringButtonAdapter()); - fromOutcomeField.setLabelText(PropertyMessages.property_fromOutcome); - fromOutcomeField.setButtonLabel("..."); - fromOutcomeField - .setDialogFieldChangeListener(getDefaultChangeListener()); - fromActionField = new StringDialogField(); - fromActionField.setLabelText(PropertyMessages.property_fromAction); - fromActionField - .setDialogFieldChangeListener(getDefaultChangeListener()); - redirectField = new ComboDialogField(SWT.DROP_DOWN | SWT.READ_ONLY); - redirectField.setLabelText(PropertyMessages.property_redirect); - redirectField - .setDialogFieldChangeListener((getDefaultChangeListener())); - List redirectList; - redirectList = new ArrayList(); - redirectList.add(Boolean.TRUE.toString()); - redirectList.add(Boolean.FALSE.toString()); - redirectField.setItems((String[]) redirectList.toArray(new String[0])); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#refreshData() - */ - public void refreshData() { - if (pfLink != null) { - fromOutcomeField.setTextWithoutUpdate(pfLink.getOutcome()); - fromActionField.setTextWithoutUpdate(pfLink.getFromaction()); - if (pfLink.isRedirect()) { - redirectField.setTextWithoutUpdate(Boolean.TRUE.toString()); - } else { - redirectField.setTextWithoutUpdate(Boolean.FALSE.toString()); - } - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#layoutDialogFields(org.eclipse.ui.forms.widgets.FormToolkit, - * org.eclipse.swt.widgets.Composite) - */ - public void layoutDialogFields(FormToolkit toolkit, Composite parent) { - Composite top; - if (toolkit == null) { - top = new Composite(parent, SWT.NONE); - } else { - top = toolkit.createComposite(parent); - } - FillLayout fillLayout = new FillLayout(SWT.VERTICAL); - parent.setLayout(fillLayout); - - int numberOfColumns = 4; - GridLayout layout = new GridLayout(numberOfColumns, false); - top.setLayout(layout); - - fromActionField.doFillIntoGrid(toolkit, top, numberOfColumns); - fromOutcomeField.doFillIntoGrid(toolkit, top, numberOfColumns); - redirectField.doFillIntoGrid(toolkit, top, numberOfColumns); - - LayoutUtil.setHorizontalGrabbing(fromOutcomeField.getTextControl( - toolkit, top)); - GridData data = new GridData(); - data.widthHint = ITabbedPropertiesConstants.BROWSE_WIDTH; - data.heightHint = ITabbedPropertiesConstants.BROWSE_HEIGHT; - - fromOutcomeField.getChangeControl(toolkit, top).setLayoutData(data); - - } - - /** - * @param elem - */ - public void setPropertyProvider(PageflowLink elem) { - pfLink = elem; - this.refreshData(); - } - - /** - * @return the outcome field - */ - public StringButtonDialogField getFromOutcomeField() { - return fromOutcomeField; - } - - /** - * @return the fromAction field - */ - public StringDialogField getFromActionField() { - return fromActionField; - } - - /** - * @return the redirect field - */ - public ComboDialogField getRedirectField() { - return redirectField; - } - - /** - * @return the redirect value - */ - public Integer getRedirectValue() { - if (redirectField.getText().equalsIgnoreCase(Boolean.TRUE.toString())) { - return LinkGroup.P_VALUE_TRUE; - } - return LinkGroup.P_VALUE_FALSE; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkSection.java deleted file mode 100644 index c6b0dce56..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkSection.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowLinkEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; - -/** - * Edit section for Pagflow Link element (EditPart) - * - * @author jchoi - */ -public class LinkSection extends AbstractEditPartSection { - /** edit group */ - private LinkGroup group; - - /** the emf model for Pageflow link */ - private PageflowLink pfLink; - - /** - * - */ - public LinkSection() { - super(); - group = new LinkGroup(); - group.setDefaultChangeListener(changeListener); - group.initialize(); - - group.getFromOutcomeField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - LinkSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPFLink_Outcome().getName(), group - .getFromOutcomeField().getText()); - } - }); - - group.getRedirectField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - LinkSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPFLink_Redirect().getName(), group - .getRedirectValue()); - } - }); - group.getFromActionField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - LinkSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPFLink_Fromaction().getName(), group - .getFromActionField().getText()); - } - }); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#createControls(org.eclipse.swt.widgets.Composite, - * org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage) - */ - public void createControls(Composite parent, - TabbedPropertySheetPage aTabbedPropertySheetPage) { - super.createControls(parent, aTabbedPropertySheetPage); - TabbedPropertySheetWidgetFactory factory = aTabbedPropertySheetPage - .getWidgetFactory(); - Composite top = factory.createFlatFormComposite(parent); - - group.layoutDialogFields(factory, top); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) { - super.setInput(part, selection); - - if (getInput() != null && getInput() instanceof PageflowLinkEditPart) { - Object model = ((PageflowLinkEditPart) getInput()).getModel(); - if (model instanceof PageflowLink) { - pfLink = (PageflowLink) model; - if (PageflowValidation.getInstance().isValidLinkForProperty( - pfLink)) { - refreshData(); - } - } - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.properties.sections.AbstractEditPartSection#refreshData() - */ - public void refreshData() { - super.refresh(); - group.setPropertyProvider(pfLink); - } - - public void validate() { - // do nothing - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageGroup.java deleted file mode 100644 index e7e5f331b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageGroup.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IStringButtonAdapter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.ITabbedPropertiesConstants; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.ProjectWebPageSelectionDialog; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PropertyMessages; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author jchoi - * @version - */ -/*package*/ class PageGroup extends AbstractEditPartGroup { - - private StringButtonDialogField fromViewField; - - private PageflowPage pfPage = null; - - private StringDialogField largeIconField; - - private StringDialogField smallIconField; - - class StringButtonAdapter implements IStringButtonAdapter { - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.IStringButtonAdapter#changeControlPressed(org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogField) - */ - public void changeControlPressed(DialogField field) { - IProject project = WebrootUtil.getProject(pfPage); - ProjectWebPageSelectionDialog dlg = new ProjectWebPageSelectionDialog( - field.getLabelControl(null, null).getShell(), project); - if (dlg.open() == Window.OK) { - fromViewField.setText(dlg.getResultFilePath()); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - fromViewField = new StringButtonDialogField(new StringButtonAdapter()); - fromViewField.setLabelText(PropertyMessages.property_fromView); - fromViewField.setButtonLabel("..."); - fromViewField.setDialogFieldChangeListener(getDefaultChangeListener()); - - largeIconField = new StringDialogField(); - largeIconField.setLabelText(PropertyMessages.property_largeIcon); - largeIconField - .setDialogFieldChangeListener((getDefaultChangeListener())); - smallIconField = new StringDialogField(); - smallIconField.setLabelText(PropertyMessages.property_smallIcon); - smallIconField - .setDialogFieldChangeListener((getDefaultChangeListener())); - super.initialize(); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#refreshData() - */ - public void refreshData() { - if (pfPage != null) { - fromViewField.setTextWithoutUpdate(assertString(pfPage.getPath())); - largeIconField.setTextWithoutUpdate(assertString(pfPage - .getLargeicon())); - smallIconField.setTextWithoutUpdate(assertString(pfPage - .getSmallicon())); - super.refreshData(pfPage); - - } - - } - /** - * @param value - * @return the assertion string - */ - private static String assertString(String value) { - return value == null ? "" : value; - } - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#layoutDialogFields(org.eclipse.ui.forms.widgets.FormToolkit, - * org.eclipse.swt.widgets.Composite) - */ - public void layoutDialogFields(FormToolkit toolkit, Composite parent) { - Composite top; - if (toolkit == null) { - top = new Composite(parent, SWT.NONE); - } else { - top = toolkit.createComposite(parent); - } - FillLayout fillLayout = new FillLayout(SWT.VERTICAL); - parent.setLayout(fillLayout); - - int numberOfColumns = 4; - GridLayout layout = new GridLayout(numberOfColumns, false); - top.setLayout(layout); - - fromViewField.doFillIntoGrid(toolkit, top, numberOfColumns); - LayoutUtil.setHorizontalGrabbing(fromViewField.getTextControl(toolkit, - top)); - largeIconField.doFillIntoGrid(toolkit, top, numberOfColumns); - smallIconField.doFillIntoGrid(toolkit, top, numberOfColumns); - super.layoutDialogFields(toolkit, top, 4); - - GridData data = new GridData(); - data.widthHint = ITabbedPropertiesConstants.BROWSE_WIDTH; - data.heightHint = ITabbedPropertiesConstants.BROWSE_HEIGHT; - - fromViewField.getChangeControl(toolkit, top).setLayoutData(data); - } - - /** - * @param elem - */ - public void setPropertyProvider(PageflowPage elem) { - pfPage = elem; - this.refreshData(); - } - - /** - * @return the fromView field - */ - public StringButtonDialogField getFromViewField() { - return fromViewField; - } - - /** - * @return the large icon field - */ - public StringDialogField getLargeIconField() { - return largeIconField; - } - - /** - * @return the small icon field - */ - public StringDialogField getSmallIconField() { - return smallIconField; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageSection.java deleted file mode 100644 index 00b214a4b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageSection.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowNodeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; - -/** - * Edit section for Pagflow Page Element (EditPart) - * - * @author jchoi, Xiao-guang Zhang - */ -public class PageSection extends AbstractEditPartSection { - /** edit group */ - private PageGroup group; - - /** the emf model for Pageflow page */ - private PageflowPage pfPage = null; - - /** - * - */ - public PageSection() { - super(); - group = new PageGroup(); - group.setDefaultChangeListener(changeListener); - group.initialize(); - - group.getFromViewField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - if (pfPage != null) { - String jsfNew = group.getFromViewField().getText(); - if (jsfNew != null && jsfNew.length() > 0) { - if (PageflowValidation.getInstance() - .isExistedPage(pfPage.getPageflow(), - jsfNew)) { - // Pageflow.PageflowEditor.Alert.DNDResourceTitle - // = Pageflow Creation Error - // Pageflow.PageflowEditor.Alert.ExistingPage - // = The web page {0} is already existed in - // current PageFlow. - EditorPlugin - .getAlerts() - .error( - "Pageflow.PageflowEditor.Alert.DNDResourceTitle", - "Pageflow.PageflowEditor.Alert.ExistingPage", - jsfNew); - } else { - PageSection.this - .setValue( - PageflowPackageImpl.eINSTANCE - .getPFPage_Path() - .getName(), jsfNew); - } - } - } - } - }); - - group.getLargeIconField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - PageSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPFPage_Largeicon().getName(), group - .getLargeIconField().getText()); - } - }); - group.getSmallIconField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - PageSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPFPage_Smallicon().getName(), group - .getSmallIconField().getText()); - } - }); - - group.getDescField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - PageSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPageflowElement_Comment().getName(), group - .getDescField().getText()); - } - }); - - group.getDisplayNameField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - PageSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPageflowElement_Name().getName(), group - .getDisplayNameField().getText()); - } - }); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#createControls(org.eclipse.swt.widgets.Composite, - * org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage) - */ - public void createControls(Composite parent, - TabbedPropertySheetPage aTabbedPropertySheetPage) { - super.createControls(parent, aTabbedPropertySheetPage); - TabbedPropertySheetWidgetFactory factory = aTabbedPropertySheetPage - .getWidgetFactory(); - Composite top = factory.createFlatFormComposite(parent); - - group.layoutDialogFields(factory, top); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) { - super.setInput(part, selection); - - if (getInput() != null && getInput() instanceof PageflowNodeEditPart) { - Object model = ((PageflowNodeEditPart) getInput()).getModel(); - if (model instanceof PageflowPage) { - pfPage = (PageflowPage) model; - refreshData(); - } - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.properties.sections.AbstractEditPartSection#refreshData() - */ - public void refreshData() { - super.refreshData(); - group.setPropertyProvider(pfPage); - } - - public void validate() { - // do nothing - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/SetPropertyValueCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/SetPropertyValueCommand.java deleted file mode 100644 index 96d227628..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/SetPropertyValueCommand.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import java.text.MessageFormat; - -import org.eclipse.gef.commands.Command; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PropertyMessages; -import org.eclipse.ui.views.properties.IPropertySource; - -/*package*/ class SetPropertyValueCommand extends Command { - - private Object propertyValue; - - private Object propertyID; - - private Object undoValue; - - private boolean resetOnUndo; - - private IPropertySource target; - - /** - * @param propLabel - */ - public SetPropertyValueCommand(String propLabel) { - super(MessageFormat.format( - PropertyMessages.property_Command_SetValue, - new Object[] { propLabel }).trim()); - } - - public boolean canExecute() { - return true; - } - - public void execute() { - boolean wasPropertySet = getTarget().isPropertySet(propertyID); - undoValue = getTarget().getPropertyValue(propertyID); - if (undoValue instanceof IPropertySource) { - undoValue = ((IPropertySource) undoValue).getEditableValue(); - } - if (propertyValue instanceof IPropertySource) { - propertyValue = ((IPropertySource) propertyValue) - .getEditableValue(); - } - getTarget().setPropertyValue(propertyID, propertyValue); - resetOnUndo = wasPropertySet != getTarget().isPropertySet(propertyID); - if (resetOnUndo) { - undoValue = null; - } - } - - /** - * @return the target - */ - private IPropertySource getTarget() { - return target; - } - - void setTarget(IPropertySource aTarget) { - target = aTarget; - } - - public void redo() { - execute(); - } - - void setPropertyId(Object pName) { - propertyID = pName; - } - - void setPropertyValue(Object val) { - propertyValue = val; - } - - public void undo() { - if (resetOnUndo) { - getTarget().resetPropertyValue(propertyID); - } else { - getTarget().setPropertyValue(propertyID, undoValue); - } - } -} |